Skip to content

Fix probe_mtu() for macOS#7

Merged
deajan merged 5 commits intonetinvent:masterfrom
harmv:mac
Feb 15, 2026
Merged

Fix probe_mtu() for macOS#7
deajan merged 5 commits intonetinvent:masterfrom
harmv:mac

Conversation

@harmv
Copy link
Contributor

@harmv harmv commented Feb 12, 2026

Fixes: #6

@deajan
Copy link
Contributor

deajan commented Feb 12, 2026

Thanks for your time in making that PR.
Just two suggestions: You did add -D parameter for IPv4 ping which should be optional depending on do_not_fragment parameter.
Also, the ping parameter documents is a copy of the one used for linux and is obiously wrong. Would you mind correcting it please ?

@harmv
Copy link
Contributor Author

harmv commented Feb 12, 2026

Done, also added Change default interval probe_mtu() to 0.2s which speeds up stuff greatly. (no need to ever wait 1s)

(note: thats not the wait time for a ping reply, just the dead time, waiting before sending a new one)

else:
command = "ping -c 1 -s {} -W {} -D -i {}".format( mtu_encapsulated, timeout, interval )
command = "ping -c 1 -s {} -W {} -i {}".format( mtu_encapsulated, timeout, interval )
if do_not_fragment:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no -D on ping6

@deajan
Copy link
Contributor

deajan commented Feb 12, 2026

Why did you remove the timeout on the IPv6 ping command ?

Also, please don't set default timeout to .2 seconds as this will fail on anything run by non root users.
The better alternative would be to add an optional timeout arg to probe_mtu(), so the timeout is user controlled.

Thanks for the effort for providing that PR.

@harmv
Copy link
Contributor Author

harmv commented Feb 13, 2026

Why did you remove the timeout on the IPv6 ping command ?

Because ping6 (on mac) does not support a timeout option. (and -W on ping6 means Generate ICMPv6 Node Information DNS Name query, rather than echo-request.)

Also, please don't set default timeout to .2 seconds as this will fail on anything run by non root users. The better alternative would be to add an optional timeout arg to probe_mtu(), so the timeout is user controlled.

This interval works fine for non root.
On linux, only intervals below 2ms require root acess. note: 2ms is a timeout of 0.002 second (100 times smaller that I set it).

These work just fine (commands below on linux, I tested linux & mac)

ping -c 1 -s 1072 -W 4 -i 0.2 -M do -4 kernel.org                   <-- my pull request
ping -c 1 -s 1072 -W 4 -i 0.002 -M do -4 kernel.org               <-- even this works

Only 0.001 fails

$ ping -c 1 -s 1072 -W 4 -i 0.001 -M do -4 kernel.org
PING kernel.org (172.105.4.254) 1072(1100) bytes of data.
ping: cannot flood, minimal interval for user must be >= 2 ms, use -i 0.002 (or higher)

for me both on mac & linux work fine with interval 0.2 as non-root. so I didn't see a reason to default to slower one. do you?

I like your suggestion to add it a parameter. (added commit 4d4de81) for that

Add parameter interval.

new defaul to 0.2s, speeds things up a lot. (was 1s before)
I don't think there is any reason to do this slower.

NB: 0.2 wors for non-root too. (only below 0.002 you require root)
@deajan
Copy link
Contributor

deajan commented Feb 15, 2026

Hmmm, it seems that different systems come with different limits.
RHEL9

ping google.Fr -i .19
PING google.Fr (142.250.74.67) 56(84) bytes of data.
ping: cannot flood; minimal interval allowed for user is 200ms

RHEL10

ping google.fr -4 -i .001
PING google.fr (142.251.209.99) 56(84) bytes of data.
ping: cannot flood, minimal interval for user must be >= 2 ms, use -i 0.002 (or higher)

Let's settle for .2s which seems "good enough".

@deajan deajan merged commit 001f016 into netinvent:master Feb 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

probe_mtu() not working on macOS

2 participants