[erlang-questions] Getting the MTU of an IPv4 UDP socket?

Michael Santos <>
Tue Mar 22 22:47:08 CET 2011

On Tue, Mar 22, 2011 at 10:04:09PM +0100, Jesper Louis Andersen wrote:
> What is the easiest way to query MTUs for UDP sockets on Linux and
> Windows (One is ok, I can hack it for Windows). I know that you should
> probably carry out some PMTU discovery phase, but I am somewhat
> interested if you can query this state of a socket and how supported
> it is.
> Meanwhile, I'll cheat and assume the MTU is 1000 bytes :P

You could check /proc or /sysfs on Linux. For example:

1> {ok,F} = file:open("/proc/sys/net/ipv6/conf/wlan0/mtu", [read,binary]).
2> file:read(F, 1024).

3> {ok,F} = file:open("/sys/class/net/wlan0/mtu", [read,binary]).
4> file:read(F, 1024).

More information about the erlang-questions mailing list