title: Generating packets
body: <p>I want to know how to generate a packet in c. Supposed we have a type as follows:</p>
  
  <pre><code>struct ipheader {
      int version;
      int hdLen;
      int tos;
      int totLen;
      int id;
      ......
      int dstIp;
  }
  </code></pre>
  
  <p>And we have a ipheader type:</p>
  
  <pre><code>struct ipheader ip;
  
  //init the ip
  .....
  </code></pre>
  
  <p>How can I generate a packet(just ip header part) from "ip". Could anyone show me how? </p>
  
  <p>I want to know to generate packets with information such as  mac address, ip header, tcp header, payload. Then I can use the "pcap_sendpacket" function to send the packets I have generated. Could someone give me a little example.</p>