implement pmtu discovery on udp connection that serves as vpn tunnel.

Hi, I've created a socket which is bound to virtual interface, and receive all outgoing traffic due to default routing table rule setting.
Once outgoing packet arrive, it will be encapsulated with some VPN header and sent to the remote tunnel gateway through the physical interface.

I was wondering if I can implement any sort of path mtu discovery algorithm to the tunnel gateway, in order to avoid packet fragmentation and improve the performance.

one solution I was thinking of is to set the DF bit in the IP header for some random outgoing packets, and catch any icmp response with the following header :
  • Type: 3 (Destination Unreachable)
  • Code: 4 (Fragmentation Needed and Don't Fragment was Set)
than I keep response length and send icmp packet with reduced size until I reach the maximum packet size with DF=1 that get success response.

I was wondering if there are better ways to do it.. maybe using some built-in mechanism ?

Perhaps the following setting make this automatically (net.inet.tcp.path_mtu_discovery) ? if not, is there a way to read it somehow from the routing table cache ?

Thanks !
 
You mean to do this programmatically? I.e. coding it yourself? Then it should probably be moved to "Userland Programming and Scripting".
 
Back
Top