<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>C&#43;&#43; on Sinodun Internet Technologies</title>
    <link>https://sinodun.com/tags/c&#43;&#43;/</link>
    <description>Recent content in C&#43;&#43; on Sinodun Internet Technologies</description>
    <generator>Hugo</generator>
    <language>en</language>
    <copyright>Copyright 2026 Sinodun IT</copyright>
    <lastBuildDate>Tue, 27 Jun 2017 00:00:00 +0100</lastBuildDate>
    <atom:link href="https://sinodun.com/tags/c++/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>More on Debian Jessie/Ubuntu Trusty packet capture woes</title>
      <link>https://sinodun.com/post/more-pcap/</link>
      <pubDate>Tue, 27 Jun 2017 00:00:00 +0100</pubDate>
      <guid>https://sinodun.com/post/more-pcap/</guid>
      <description>&lt;p&gt;Back in September I wrote about a problem we’d come across when capturing traffic with &lt;code&gt;pcap_dispatch()&lt;/code&gt; or &lt;code&gt;pcap_next_ex()&lt;/code&gt; on Ubuntu Trusty or Debian Jessie. When the traffic was slow, we saw packets not being captured.&lt;/p&gt;&#xA;&lt;p&gt;We’ve since done a bit more digging. The problem, we think, is a bug in the Linux kernel &lt;code&gt;select()&lt;/code&gt; system call. With both &lt;code&gt;pcap_dispatch()&lt;/code&gt; and&#xA;&lt;code&gt;pcap_next_ex()&lt;/code&gt; we’re using a central loop that is basically:&lt;/p&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;pcap_dispatch();&#xA;select(pcapfd, timeout);&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;The length of timeout in the select() call shouldn’t matter. But it does. In our test scenario, set it to 1ms and every packet in a ping to an otherwise idle network connection will be captured. Set it to 2s and most or all will be missed.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Packet capture woes with libpcap on Ubuntu Trusty and Debian Jessie</title>
      <link>https://sinodun.com/post/packet-capture/</link>
      <pubDate>Thu, 29 Sep 2016 00:00:00 +0100</pubDate>
      <guid>https://sinodun.com/post/packet-capture/</guid>
      <description>&lt;p&gt;Usually when you’re using libpcap to capture network traffic, your chief worry will be whether or not your application will keep up with the flow of traffic.&lt;/p&gt;&#xA;&lt;p&gt;Today, though, I’ve stubbed my toe on a problem with traffic that’s too slow. It happens with both Ubuntu Trusty and Debian Jessie. If there’s a gap between packets of more than about 50 milliseconds, the first packet to arrive after the gap will be dropped and you’ll never see it. I was capturing DNS queries and responses, and found that with a query rate of under 20 queries per second you start dropping queries. By the time you’re down to 15 queries per second, nearly every query is dropped.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
