title: Boost ASIO dropping UDP packets
body: <p>I've modified handle_send_to function of <a href="http://www.boost.org/doc/libs/1_45_0/doc/html/boost_asio/example/echo/async_udp_echo_server.cpp" rel="noreferrer">BOOST ASIO example</a>  to look like this- </p>
  
  <pre><code>{   
  
  ctr++;
  cout&lt;&lt;"Counter: "&lt;&lt;ctr&lt;&lt;" data= "&lt;&lt;data&lt;&lt;endl;
  
  socket_.async_receive_from(boost::asio::buffer(data_, max_length), sender_endpoint_,boost::bind(&amp;server::handle_receive_from, this,boost::asio::placeholders::error,boost::asio::placeholders::bytes_transferred));
  
  }
  </code></pre>
  
  <p>The intent is to basically increment the counter every time UDP connection is handled. </p>
  
  <p>The test client is sending data like this- </p>
  
  <pre><code>for(;;){
  ctr++;
  printf("ctr= %lu\n",ctr);
  snprintf(buf2, 10,"%lu",ctr);
  if ((numbytes = sendto(sockfd, buf2, strlen(buf2), 0,p-&gt;ai_addr, p-&gt;ai_addrlen)) == -1)   
  {
  perror("client: sendto");
  exit(1);
  }
  }
  </code></pre>
  
  <p>After running the test client, I see on the server side :</p>
  
  <pre><code>Counter= 358239 data= 369880
  </code></pre>
  
  <p>the data part shows the message #. The test client has indeed sent 369880 messages but as you can see counter is only 358239 (drop of 11641 messages). </p>
  
  <p>What could be possibly wrong here?</p>
  
  <p>Both hosts (sender and receiver, running Ubuntu 10.04 LTS) are okay with resources- I don't see CPU, memory or network saturating. </p>
  
  <p>The output of <code>netstat -su</code> looks like- </p>
  
  <pre><code>Udp:
      38569571 packets received
      1003583 packets to unknown port received.
      74619 packet receive errors
      267 packets sent
      RcvbufErrors: 74619
  </code></pre>
  
  <p>How do I troubleshoot large number of <code>packets to unknown port received</code> ?</p>