-
Notifications
You must be signed in to change notification settings - Fork 61
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
filter icmp id with sock_filter, to optimize rawsocket preformance #136
Conversation
Signed-off-by: nvksie <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting optimization, I like it.
One thing I was thinking about recently is what happens to performance when users are running a lot of Pingers.
Currently we create a new socket for ever Pinger. I was wondering if this was causing us to do a lot of memory copies of all the incoming packets, most of which aren't matched by the listener. I haven't tested this, but if this is correct I was thinking about adding an option to create a single listener socket and pass that to each newly created pinger.
This may slightly conflict with this PR, as it also creates a filter for the packet ID.
But, this could easily be refactored later.
What do you think?
Thanks! |
Oh, I see! You mean using a single raw socket together with sock_filter? Maintaining a map to match ICMP IDs might make the BPF more complex, but it sounds more powerful! |
My thought is that we can just remove the ID filter from the BPF. Just allow all ICMP packets to be read by the library. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs an error
handler.
Signed-off-by: nvksie <[email protected]>
Done |
rawsocket will receive all packets matching the target protocol, including replies to another ping on this host.
with sock_filter we can filter icmp reply packets, only accepting icmp replies that match the id in the sent packet.