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

Don't limit the snaplen by default #155

Closed
tsg opened this issue Jun 4, 2015 · 2 comments
Closed

Don't limit the snaplen by default #155

tsg opened this issue Jun 4, 2015 · 2 comments

Comments

@tsg
Copy link
Contributor

tsg commented Jun 4, 2015

This is triggered by #145, where our default value for snaplen was too small for a virtual interface (docker0).

We could "fix" it by adding docker to the list of virtual interfaces we detect by name, but it seems to me that a better approach would be to read the MTU size of the interface and set the default snaplen based on that.

@tsg
Copy link
Contributor Author

tsg commented Jun 5, 2015

Seems that we cannot rely on the MTU value. Virtual interfaces seem to send arbitrary sized packets, the only limit seems to be 64K. We should still be able to find a reliable way of knowing if an interval is virtual or not.

@tsg tsg added the 1.0.0-beta2 label Jun 8, 2015
@tsg
Copy link
Contributor Author

tsg commented Jun 11, 2015

The two possible solutions I see:

  • simply leave the default to 65535, which is enough in all cases that I've seen and also confirmed by the libpcap man page to be safe for all networks.
  • Do adaptive snaplen: whenever the socket reports that it has seen a packet larger than the current snaplen, double the snaplen.

The second solution makes for an optimized snaplen, but it's clearly more complex and has the disadvantage that we still lose data on each first "bigger" packet. It's also impossible to predict when the loss will happen. It's also not clear right now if changing the snaplen on existing socket can cause any drops during the change.

The good news about the first option is that libpcap doesn't seem to be affected by the snaplen change if the packets are small (~1500 bytes), so when using the pcap sniffer there isn't really a downside to just using 65535.

For the af_packet sniffer type, a larger "frame" size means fewer slots in memory map. So on the same memory consumption, we're more likely to drop packets, but the CPU time consumed also doesn't seem to vary if the the packets are small.

Given the above, I tend to favor the first solution.

@tsg tsg changed the title Set default snaplen based on the MTU size Don't limit the snaplen by default Jun 11, 2015
tsg pushed a commit that referenced this issue Jun 12, 2015
@tsg tsg closed this as completed Jun 12, 2015
tsg added a commit that referenced this issue Dec 2, 2015
Fix #140: Convert offest and line to long fields to prevent overflow
tsg pushed a commit to tsg/beats that referenced this issue Jan 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant