lokikiller / 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_loop #34

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
pcap_loop offers a neat and efficient way of capturing/reading packets 
continuously.

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

Original issue reported on code.google.com by matthias...@gmail.com on 6 Aug 2014 at 12:45

GoogleCodeExporter commented 9 years ago
Is there a particular use case that pcap_loop can do that the current use 
ReadPacketData is unable to accomplish?

I've avoided doing this in the past because calling Go from C is just as slow 
as calling C from Go (there is a bunch of stuff that Go has to do to make sure 
the Go scheduler plays well with C code, etc).

My main reason for trying out pcap_loop was to hopefully speed up capture, but 
in my tests that hasn't happened.  If you have a particular use case in mind, 
though, that you think pcap_loop would work well for, I'm definitely interested.

Original comment by gconnell@google.com on 6 Aug 2014 at 11:04

GoogleCodeExporter commented 9 years ago
I created a test to demonstrate that pcap_loop drops fewer packets when 
capturing from a busy interface, compared to ReadPacketData.

https://gist.github.com/rade/b5adaa67d8b4d05c0c05

Except the results show the exact opposite. Oops.

And in our app too I actually get better performance from ReadPacketData.

So let's close this issue for now. If at some future point we discover a 
compelling case for pcap_loop we can open another issue.

Original comment by matthias...@gmail.com on 7 Aug 2014 at 10:58

GoogleCodeExporter commented 9 years ago
Cool, thanks for the understanding (and the test!).  Marking WontFix

Original comment by gconnell@google.com on 7 Aug 2014 at 2:46