Skip to content
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

tcpdump does not truncate packets #460

Closed
ikuzar opened this issue May 21, 2015 · 3 comments
Closed

tcpdump does not truncate packets #460

ikuzar opened this issue May 21, 2015 · 3 comments

Comments

@ikuzar
Copy link

ikuzar commented May 21, 2015

Hi all,
I try to read and truncate packets from a pcap file with tcpdump with a snaplen -s 96 before dumping it:
tcpdump -r input_file.pcap -s 96 -w output_file.pcap
But when I open output_file.pcap with wireshark, packets' length seems to be unchanged... (greater than 96, example: "165 bytes on wire, 165 bytes captured").
Does something go wrong with this syntax ? how does tcpdump work with -s option ?

Here is my environement:
Ubuntu 10.04 Linux 2.6.32-74-generic
tcpdump version 4.0.0
libpcap version 1.0.0

Thanks for your help,

Ikuzar

@stevekay
Copy link
Contributor

stevekay commented Jun 8, 2015

The snaplen parameter only affects captures being read from a network interface. Using the snaplen parameter when reading from a file has no effect.

If you look in tcpdump.c you'll see the pcap_set_snaplen function is only called when doing a live capture.

@guyharris
Copy link
Member

Presumably he wants to take a capture file captured with a large snapshot length, so that it has full packet data, and trim the packets down so that they only contain the data they care about. Wireshark's editcap can do this; it might be a useful enhancement for tcpdump as well.

But, yes, it's an enhancement; it was not something tcpdump was intended to do since the beginning, so it's not a bug that it doesn't work.

@infrastation
Copy link
Member

I agree it would be nice to have this feature, but it has been more than 5 years. If anybody is willing to implement it, they are welcome to prepare the changes and open a pull request. Closing.

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

No branches or pull requests

4 participants