prometheus-community / pro-bing

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

Add support for setting do-not-fragment bit (linux) #39

Closed floatingstatic closed 1 year ago

floatingstatic commented 1 year ago

Closes #23

This PR only attempts to add support for this in linux. It seems it may be feasible to add support for this under windows but I do not have any way of testing this easily so for now this will be omitted. Other platforms I could not get this working as the socket options required to do this are unclear under BSD platforms (for example) but it may be possible to support this after a little more r&d.

I tested using:

pinger.Size = 1472
pinger.SetDoNotFragment(true)

Which yielded a 1500 byte IP packet (my IP MTU is 1500) per tcpdump on the wire:

12:32:09.158203 IP 10.10.0.50 > 10.10.0.1: ICMP echo request, id 39, seq 0, length 1480

Doing the same as the above but setting pinger.Size = 1473 we get the following error from the kernel which is what we expect to see with do-not-fragment set:

sendto: message too long
SuperQ commented 1 year ago

Thanks for the nice improvements.