title: How can hping be so fast to send packets?
body: <p>I have compared two tools for the speed of sending packets, <code>hping</code> and <code>packETHcli</code>. The command line options for packETHcli is  </p>
  
  <pre><code>./packETHcli -i eth0 -m 2 -n 0 -d -1 -f icmpSample.pcap
  </code></pre>
  
  <p>and for hping is </p>
  
  <pre><code>hping --flood 192.168.0.1
  </code></pre>
  
  <p>But in iptraf, it shows that the packets sending speed of hping is about 10 times faster than packETHcli.</p>
  
  <p>Both tools use raw sockets, but why such a big difference?</p>
  
  <p>Here is the link to get the source codes.</p>
  
  <p>hping: <a href="http://wiki.hping.org/" rel="nofollow">http://wiki.hping.org/</a></p>
  
  <p>packETHcli: <a href="http://sourceforge.net/projects/packeth/" rel="nofollow">http://sourceforge.net/projects/packeth/</a></p>
  
  <p><strong>EDIT:</strong>
   I noticed that the <code>hping</code> use AF_INET raw socket, the payload is TCP. <code>packETHcli</code> use PF_PACKET raw socket, and in my example the payload is and IP packet with payload of ICMP.
  Do it make the difference of the packet sending speed ?</p>
  
  <p><strong>EDIT2</strong></p>
  
  <p>This time,I use ifconfig to find the TX packets count difference between before and after running <code>hping3</code> and <code>packETHcli</code>.  And found that the packets generating rates are close for the two tools. <code>hping3</code> is about 100000 packets per seconds and <code>packETHcli</code> is about 80000 packets per seconds. </p>
  
  <p>I also use <code>vnstat</code> to measure the packets generating rates. And the result is consistent with the number I get from <code>ifconfig</code>.</p>
  
  <p>So, it seems that <code>iptraf</code> lies. And I use <code>iptraf</code> to monitor the repeated resending of a TCP packet, without update the IP ID number and TCP sequence number. <code>iptraf</code> think my packet sending rate is 0 packets per seconds. May be <code>iptraf</code> don't count the duplicated packets?</p>