Add os-tcp-mtu utility
-
Add os-tcp-mtu utility
Makes a host connection to an arbitrary TCP/IP host:port, and checks the estimates of the MTU/MSS provided by various getsockopt() calls, just as OpenConnect uses in calculate_mtu().
-
Check IP and TCP options sizes in os-tcp-mtu
-
Don't build os-tcp-mtu on Windows, because it doesn't work
TODO:
- Implement a working os-tcp-mtu for Windows, and build that too.
- Use https://github.com/morristech/android-ifaddrs as
as a drop-in replacement for
getifaddrs(3)on Android
(This was factored out in a readily-mergeable form from the old branch https://gitlab.com/openconnect/openconnect/-/commits/check_tcp_mtu_tool; see #452 (comment 1356107899))
Examples of os-tcp-mtu in use
Localhost (defaulting to Legacy IP):
$ ./os-tcp-mtu localhost 443
Resolving IP address for destination hostname localhost ...
Resolved destination as Legacy IP address: 127.0.0.1
Trying to connect to 127.0.0.1:443 ...
Connected from source 127.0.0.1:58700
OS estimates of MTU/MSS for connected TCP socket:
getsockopt TCP_INFO -> rcv_mss 536, snd_mss 32741, advmss 65483, pmtu 65535
getsockopt IP_MTU -> mtu 65535
getsockopt TCP_MAXSEG -> mss 32741
ioctl SIOCGIFMTU -> ifr_mtu 65536 (for lo interface)
Localhost (via IPv6):
$ ./os-tcp-mtu localhost 443 ::1
Resolving IPv6 address for destination hostname localhost ...
Resolved destination as IPv6 address: ::1
Bound to source address of [::1]
Trying to connect to [::1]:443 ...
Connected from source [::1]:44709
OS estimates of MTU/MSS for connected TCP socket:
getsockopt TCP_INFO -> rcv_mss 536, snd_mss 32732, advmss 65464, pmtu 65536
getsockopt IP_MTU -> mtu 65536
getsockopt TCP_MAXSEG -> mss 32732
ioctl SIOCGIFMTU -> ifr_mtu 65536 (for lo interface)
Remote IPv4 host (via Legacy IP over VPN interface):
$ ./os-tcp-mtu 8.8.8.8 443
Trying to connect to 8.8.8.8:443 ...
Connected from source 192.168.1.123:49244
OS estimates of MTU/MSS for connected TCP socket:
getsockopt TCP_INFO -> rcv_mss 536, snd_mss 1198, advmss 1198, pmtu 1250
getsockopt IP_MTU -> mtu 1250
getsockopt TCP_MAXSEG -> mss 1198
ioctl SIOCGIFMTU -> ifr_mtu 1250 (for tun0 interface)
Refusing to connect with mismatched source/destination address families:
$ ./os-tcp-mtu 8.8.8.8 443 ::1
Source and destination addresses must be same IP version.
Edited by Daniel Lenski