Skip to content

Conversation

acooks
Copy link

@acooks acooks commented Mar 10, 2023

Here is a potential implementation of path MTU discovery. It has recently been mentioned in issue #54 and #71

Some test results here:

https://github.com/acooks/icmplib/wiki

The results show that interfaces conform to the Robustness principle in that they may accept packets somewhat larger than the configured MTU, but won't send anything larger than the configured MTU.

Characterizing that asymmetric behavior was what motivated me to implement the pmtu discovery.

acooks and others added 4 commits February 18, 2023 14:23
 - only discover pmtu for reachable hosts
 - pick a starting test point closer to the more probable MTU
 - tune the interval and timeout based on discovered RTT
if verbose:
print("❌")

test_size = lower + int((upper - lower) / 2)
Copy link

Choose a reason for hiding this comment

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

Thanks for implementing this feature. I'm currently looking into adding PMTUD to MeshPing, a little network monitoring tool I'm building. I'm currently working on a somewhat-hacky PMTUD implementation, but I'd also love to contribute back to icmplib, hence I found your PR. Your implementation looks a lot cleaner than mine 😄 I'd just like to point out that, rather than guessing and trying new MTU values when you get an error back, the new MTU is actually included in the downstream gateways' ICMP messages, and you can query them from the socket:

    def get_mtu(self):
        return self._sock.getsockopt(socket.IPPROTO_IP, IP_MTU)

Similar for IPv6:

    def get_mtu(self):
        return self._sock.getsockopt(socket.IPPROTO_IPV6, IPV6_MTU)

Maybe this would be a nice addition? 🙂

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the comment and apologies for the delayed response.

I agree, a brute-force PMTU discovery mechanism like this is not often needed these days.

However, the reason I had for implementing this feature is that there are some network devices, like fibre media converters, that operate as bridges on an Ethernet segment, and are entirely transparent at the IP layer - except when they're dropping large Ethernet frames.

In that scenario, there are no ICMP messages to signal the MTU constraint, and that's the scenario I needed this tool for.

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.

2 participants