New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading directly from tcpdump stdout fails #504

Closed
uberhalit opened this Issue Aug 26, 2018 · 1 comment

Comments

Projects
None yet
1 participant
@uberhalit

uberhalit commented Aug 26, 2018

When trying to read the output of tcpdump with pcap.OpenOfflineFile(os.Stdin) one will continously receive io.EOF error but not a single valid packet.

tcpdump is used like tcpdump -i eth0 -U -s0 -w - | mygopacketapplication. Flag -w - will direct pcap output to standard output.

Wireshark can read from stdin like stated above just fine (using -k -i -). But even when saving this capture from within wireshark and then opening via pcap.OpenOffline("wireshark_capture_from_stdin.pcap") all one will recieve is io.EOF.

@uberhalit

This comment has been minimized.

Show comment
Hide comment
@uberhalit

uberhalit Aug 26, 2018

After manually hex-editing some pcap files I've found the culprit:
tcpdump will insert a VLAN (802.1Q) layer when capturing from a virtual device. However there is a bug regarding BPF when you try to chain together some 'vlan' expressions: the-tcpdump-group/libpcap#158

So instead of vlan or ( tcp port 1111 or 2222 ) one would use ( tcp port 1111 or 2222 ) or vlan. Otherwise you'll never see any normal tcp traffic.

uberhalit commented Aug 26, 2018

After manually hex-editing some pcap files I've found the culprit:
tcpdump will insert a VLAN (802.1Q) layer when capturing from a virtual device. However there is a bug regarding BPF when you try to chain together some 'vlan' expressions: the-tcpdump-group/libpcap#158

So instead of vlan or ( tcp port 1111 or 2222 ) one would use ( tcp port 1111 or 2222 ) or vlan. Otherwise you'll never see any normal tcp traffic.

@uberhalit uberhalit closed this Aug 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment