I'm using pytun to setup a TUN and forward packets that arrive on it to another machine using UDP. What's puzzling me is that even though I've configured the TUN to have MTU of 141 bytes, I'm reading packets of size 145 on it. See the code below:
from pytun import TunTapDevice
tun = TunTapDevice(name="vpn")
tun.addr = '10.8.0.1'
tun.dstaddr = '10.8.0.2'
tun.netmask = '255.255.255.0'
tun.mtu = 141
tun.up()
assert len(tun.read(1000)) <= tun.mtu # <-- fails for some packets
I've verified the actual MTU of the interface using ifconfig
.
Am I missing something?