prometheus-community / pro-bing

A library for creating continuous probers
MIT License
309 stars 52 forks source link

Allow setting the fragmentation of packets option when sending a ping #23

Closed rolandjitsu closed 1 year ago

rolandjitsu commented 1 year ago

Similar to how you can do:

ping -M do -s 1472 google.com

Screenshot 2023-02-27 at 10 55 20

We should be able to tell pinger to not fragment packets if too large (due to MTU size).

The option seems to be available as https://pkg.go.dev/golang.org/x/net/ipv4#HeaderFlags (I think).

antoinekh commented 1 year ago

+1 This is useful for MTU tests

floatingstatic commented 1 year ago

I need this as well. This can be set with a socket option. Additionally setting DF is not useful in and of itself if we cannot also set the size of the ICMP payload which as far as I can tell is currently not supported in this library. I have proposed a PR that adds some functions that are needed to support setting socket options (SO_MARK in this case) here: https://github.com/prometheus-community/pro-bing/pull/36

If this is accepted and merged I can re-use some of the code to do something like this which I believe will allow setting the DF bit:

syscall.SetsockoptInt(int(fd), syscall.IPPROTO_IP, syscall.IP_MTU_DISCOVER, syscall.IP_PMTUDISC_PROBE)

I'm happy to take a pass at this one.