scroot / gopacket

Automatically exported from code.google.com/p/gopacket
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

add API for pcap_set_immediate_mode #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
In immediate mode packets get delivered to the application as soon as they 
arrive, rather than after a timeout. This makes it very important for latency 
sensitive live captures. In my app this cuts the latency introduced by pcap 
from 2.5ms to 0.5ms.

The function was introduced in 
https://github.com/the-tcpdump-group/libpcap/commit/48bc6c35b191857f39b628bd586b
d94a03fd13d7 and released with libpcap 1.5.0 on 30th October 2013. The docs for 
it are, erhm, bare. Best explanation for the issue it is addressing is at 
http://stackoverflow.com/questions/15979033/libpcap-not-receiving-in-real-time-s
eems-to-be-buffering-packets.

Curiously, when using earlier versions of pcap, such as 1.3.0, which is in 
Debian Wheezy - the current 'stable', I do not experience the 2.5ms delay. The 
entire area of timeouts in pcap is a dog's breakfast (largely thanks to o/s and 
kernel differences), and has seen many changes.

Patch available on a branch at 
https://code.google.com/r/matthiasradestock-gopacket-pcap/source/list?name=pcap_
set_immediate_mode

Original issue reported on code.google.com by matthias...@gmail.com on 8 Aug 2014 at 9:16

GoogleCodeExporter commented 9 years ago

Original comment by gconnell@google.com on 15 Aug 2014 at 3:36

GoogleCodeExporter commented 9 years ago
Hmm, this one is tricky.

I need to make sure I support common libpcap versions, like the ones that come 
with ubuntu, etc and are old.  libpcap folks, though, appear to have nothing 
#defined that differentiates between versions that I can use to check for this 
in the preprocessor phase.  pcap_lib_version is a function, so I can't #ifdef 
it.

As far as I can tell, I can either:
1) use some esoteric value added around libpcap1.5 
(PCAP_ERROR_TSTAMP_PRECISION_NOTSUP or something like that)
2) add in the function and break everyone that doesn't have it (nope)
3) add in the function commented out, let folks uncomment it (nope)

I'm going to try #1 for now and see how that compiles on various systems.

Original comment by gconnell@google.com on 15 Aug 2014 at 4:03

GoogleCodeExporter commented 9 years ago
#1 was the answer I had prepared for when you were inevitably going to bring up 
the version issue. So we are in agreement ;)

Original comment by matthias...@gmail.com on 15 Aug 2014 at 4:32

GoogleCodeExporter commented 9 years ago
https://code.google.com/p/gopacket/source/detail?r=d5007b02aabc80b3a4373ca88f7a1
7903661e54a

Original comment by gconnell@google.com on 15 Aug 2014 at 4:43