Closed GoogleCodeExporter closed 9 years ago
Hey, will,
Thanks for the report! Could you describe (or paste the code showing) how
you're sending your packet from inside gopacket_local_test.go? Are you using
gopacket/pcap's WritePacketData?
--Graeme
Original comment by gconnell@google.com
on 27 May 2014 at 4:40
It's pretty boring -- net.DialUDP() followed by a write.
https://github.com/willglynn/gopacket-local-test/blob/master/gopacket_local_test
.go#L29-L47
Original comment by w...@willglynn.com
on 27 May 2014 at 4:42
Hi,
I have the same issue. Didn't have a look at the code yet but the pcap binding
from github.com/miekg/pcap works form me. So it is not a general pcap issue.
I'm using libpcap version 1.3.0 - Apple version 41
Original comment by boombuler@gmail.com
on 28 May 2014 at 5:43
Okay, I'm slowly narrowing down what the problem isn't. No strong leads yet,
but switching back to pcap_open_live doesn't help, nor does setting the promisc
flag. BTW, I've got libpcap 1.59 on my mac, but I'm hoping it'll work.
Could y'all run pcap/pcap_tester locally and let me know what comes out of that?
It works on my Mac, which makes me thing that it's not losing all packets, just
most of them. Not that that's a good thing :-P
Original comment by gconnell@google.com
on 28 May 2014 at 11:34
pcap/pcap_tester seems to work:
$ go run pcap_tester.go
2014/05/28 19:55:17 Trying capture on "lo0"
2014/05/28 19:55:17 Error capturing on "lo0": skipping loopback
2014/05/28 19:55:17 Trying capture on "gif0"
2014/05/28 19:55:23 Error capturing on "gif0": readpacketdata: Timeout Expired
2014/05/28 19:55:23 Trying capture on "stf0"
2014/05/28 19:55:29 Error capturing on "stf0": readpacketdata: Timeout Expired
2014/05/28 19:55:29 Trying capture on "en0"
2014/05/28 19:55:31 Read packet, 66 bytes, CI: {Timestamp:2014-05-28
19:55:29.67557 -0500 CDT CaptureLength:66 Length:66}
2014/05/28 19:55:31 Successfully captured on "en0"
Original comment by w...@willglynn.com
on 29 May 2014 at 12:56
uhmmm I've found the following:
linktype: Null
for my wifi device... I guess that should not happen?
Original comment by boombuler@gmail.com
on 29 May 2014 at 6:11
I've seen that too. Setting a filter seems to magically change the link type to
Ethernet.
Original comment by w...@willglynn.com
on 29 May 2014 at 2:19
Hmm ,I'm not seeing a similar linktype issue on my end. Could you print out
the linktype with %d to get the numeric value?
Original comment by gconnell@google.com
on 29 May 2014 at 4:31
I updated the code:
https://github.com/willglynn/gopacket-local-test/commit/401b5cddba09444010db12d0
c167ea6fd7f89059
$ go test --short
--- FAIL: TestCapture (1.03 seconds)
gopacket_local_test.go:61: starting capture on interface "en0"
gopacket_local_test.go:70: link type before setting filter: 0
gopacket_local_test.go:76: link type after setting filter: 1
gopacket_local_test.go:78: capturing on "en0"
gopacket_local_test.go:99: 2014-05-29 11:44:00.725931513 -0500 CDT: packet sent
gopacket_local_test.go:95: 2014-05-29 11:44:01.726452175 -0500 CDT: no packets received, timing out
FAIL
exit status 1
FAIL github.com/willglynn/gopacket-local-test 1.235s
Original comment by w...@willglynn.com
on 29 May 2014 at 4:45
I've committed code which should fix the LinkType issue, but it's still not
fixing the underlying problem of not seeing packets, as far as I can tell.
Regardless, please 'go get' the master branch (or tag v1.1.0) and let me know
if you see any changes in behavior.
https://code.google.com/p/gopacket/source/detail?r=c05ae030104a8d789a11bd686b4e1
d1c08468f65
https://code.google.com/p/gopacket/source/detail?r=c9be950d1eb93ba5422d713c4dc00
64bed2fb0f0
Original comment by gsconn...@gmail.com
on 29 May 2014 at 6:56
Link types now behave as expected:
$ go test github.com/willglynn/gopacket-local-test
--- FAIL: TestCapture (30.00 seconds)
gopacket_local_test.go:61: starting capture on interface "en0"
gopacket_local_test.go:70: link type before setting filter: 1
gopacket_local_test.go:76: link type after setting filter: 1
gopacket_local_test.go:78: capturing on "en0"
gopacket_local_test.go:99: 2014-05-29 14:14:39.721288149 -0500 CDT: packet sent
gopacket_local_test.go:95: 2014-05-29 14:15:09.708665821 -0500 CDT: no packets received, timing out
FAIL
FAIL github.com/willglynn/gopacket-local-test 30.216s
Original comment by w...@willglynn.com
on 29 May 2014 at 7:15
Found the issue, with 99% confidence:
https://github.com/jvinet/knock/issues/5
Basically, "read timeout considered harmful" on some platforms.
Handling this correctly is going to be difficult while maintaining backwards
compatibility... I'll see what I can do. I might fudge stuff internally to do
what I want. :)
Original comment by gsconn...@gmail.com
on 30 May 2014 at 4:30
Sweet success!
Commit
https://code.google.com/p/gopacket/source/detail?r=01c3d077bd9a98fac6954a18089ad
30795d1d230 should fix your issues. Make sure you're not passing 0 as a
timeout into OpenLive directly... see the changes to doc.go for gory details.
I think with this commit, we'll manage to keep backwards compatibility while
still providing the expected behavior for all users.
Marking issue as fixed, but please update if any issues are still coming up.
Thanks for all the help on this!
Original comment by gsconn...@gmail.com
on 30 May 2014 at 5:20
Awesome, thanks!
ok github.com/willglynn/gopacket-local-test 0.234s
Original comment by w...@willglynn.com
on 30 May 2014 at 1:15
my project still doesn't work but there might be other bugs on my side :)
Thanks for the super fast fixing speed!
Original comment by boombuler@gmail.com
on 30 May 2014 at 1:24
Original issue reported on code.google.com by
w...@willglynn.com
on 27 May 2014 at 3:39