MTU

Created

The MTU (maximum transmission unit) is the largest IP packet a link can carry in one frame, headers included: 1,500 bytes on Ethernet. Every link has its own MTU, and a packet crosses many links between two hosts. The smallest MTU along the way is the path MTU, and it limits every packet on that path. A packet larger than the next link’s MTU is either split into fragments or dropped with an ICMP error that tells the sender to send smaller ones.

The mental model: the MTU belongs to the link, and IP has to live with it. TCP sizes its own segments to fit, so a TCP program never chooses a packet size. UDP and ICMP send what the program hands them, so a UDP program has to stay within the path MTU itself.

Four hosts in a row: client, r1, r2, and server. The link from client to r1 has MTU 1500, the link from r1 to r2 has MTU 1400, and the link from r2 to server has MTU 1500. The smallest, 1400, is the path MTU.

The lab is four Alpine containers on Linux 6.12: client at 10.80.1.10 and fd80:1::10, server at 10.80.3.20 and fd80:3::20, and two routers between them, r1 and r2. Every link is 1,500 bytes unless a test sets the link between r1 and r2 to 1,400. Two more networks connect client and server directly, one at 1,500 bytes and one at 9,000. tcpdump captured packets, iperf3 and small Python programs sent data, a Go 1.26 program read the socket options, and nstat gave the kernel’s counters.

MTU, path MTU, and MSS

TermWhat it limitsSet byValue in the lab
MTUOne IP packet on one link, IP header included, link header notThe link’s interface, ip link set eth0 mtu 14001,500
Path MTUOne IP packet across every link between two hostsThe smallest link MTU on the path, learned by the sender1,400 with the small middle link
MSS (maximum segment size)The data in one TCP segment, without the IP and TCP headersEach end announces its own in the SYN1,460 on a 1,500 link
Frame sizeOne Ethernet frame on the wireThe MTU plus the 14-byte Ethernet header and 4-byte checksum1,518
  • The MTU counts the IP packet, not the frame. A 1,500-byte IP packet is a 1,514-byte frame in a capture, which omits the checksum.
  • MSS is a TCP idea. It is the MTU minus 20 bytes of IPv4 header and 20 of TCP header, so 1,460 for 1,500; over IPv6 the header is 40 bytes, so 1,440.
  • Each host knows only its own links’ MTUs. The path MTU has to be discovered, and it can change when routes change.

Don’t fragment

DF (don’t fragment) is one bit in the IPv4 header. A router that has to forward a packet onto a link too small for it splits the packet into fragments when DF is clear, and drops it when DF is set. DF sits beside MF (more fragments) and the fragment offset, which together let the destination put fragments back together. All three are in the IP header, not in the Ethernet frame, so they apply to every protocol IPv4 carries.

Bytes 4 to 7 of the IPv4 header in three captured packets: identification, 16 bits; a reserved bit; DF; MF; and fragment offset, 13 bits. A TCP segment: identification 0x201b, DF 1, MF 0, offset 0. The first fragment of a 2,000-byte UDP datagram: identification 0xbed3, DF 0, MF 1, offset 0. Its second fragment: identification 0xbed3, DF 0, MF 0, offset 185, which is byte 1,480.

  • With every link at 1,500, the client sent a 1,300-byte TCP write and a 2,000-byte UDP datagram. Bytes 6 and 7 of the header held the flags and offset: 40 00 for the TCP segment, 20 00 for the first fragment, and 00 b9 for the second.
  • The UDP datagram didn’t fit in 1,500 bytes, so the client sent it as two fragments without DF. They share identification 0xbed3, which tells the destination they belong together.
  • IPv6 has no DF bit. Its routers never fragment, as if DF were always set, and a sender that fragments adds a fragment header instead.
LinkMTU
Ethernet, and a Mac’s Wi-Fi interface en01,500
Ethernet jumbo framesOften 9,000; not part of the Ethernet standard, so every device on the link has to agree
PPPoE, used by some DSL and fiber providers1,492: 8 bytes of PPPoE and PPP header
Loopback, Linux lo65,536
Loopback, macOS lo016,384
IPv6 minimum1,280; Linux turns IPv6 off on a link that is smaller
IPv4 minimum68 to forward; every host must accept a 576-byte packet, reassembled if needed
  • Loopback never reaches a wire, so its MTU is just a large number. A TCP SYN over Linux loopback announced MSS 65,495, the most an IPv4 packet’s 16-bit total length allows. A connection over macOS lo0 reported a segment size of 16,332: 16,384 minus 52 bytes of headers and options.
  • A bridge, a dummy interface, and a VLAN interface each started at 1,500.

What fits in one packet

Four 1,500-byte packets and the data each carries. TCP over IPv4: IP header 20 bytes, TCP header 20, timestamp option 12, data 1,448. UDP over IPv4: IP 20, UDP 8, data 1,472. Ping over IPv4: IP 20, ICMP 8, data 1,472. TCP over IPv6: IPv6 header 40, TCP 20, timestamp option 12, data 1,428.

  • ping -M do -s 1472 reached the server, and -s 1473 failed at once with Message too large: 1,473 bytes of data, 8 of ICMP, and 20 of IP make 1,501. -M do sets DF. Over IPv6 the limit was 1,452, because the header is 40 bytes.
  • A UDP datagram fits in one packet up to the same 1,472 bytes over IPv4, and one write is one datagram.
  • TCP segments carried 1,448 bytes of data, not 1,460. When both ends agree to timestamps, as Linux does by default, every segment carries a 12-byte timestamp option, and MSS doesn’t count options.

Tunnels

A tunnel wraps each packet in another packet, so the inner packet loses room to the outer headers. Each new tunnel interface, created over the 1,500-byte link, started with an MTU smaller by that overhead:

Three tunnels, each carrying an inner packet inside a 1,500-byte outer packet. IP-in-IP: outer IP header 20 bytes, inner packet 1,480. VXLAN: outer IP 20, UDP 8, VXLAN 8, inner Ethernet header 14, inner packet 1,450. WireGuard: outer IPv6 40, UDP 8, WireGuard header 16, inner packet 1,420, authentication tag 16.

TunnelMTUOverhead
IP-in-IP, ipip1,48020: an outer IPv4 header
IPv6 in IPv4, sit1,48020
GRE1,47624: outer IPv4 and a 4-byte GRE header
GRE carrying Ethernet, gretap1,46238: GRE and an inner Ethernet header
VXLAN over IPv41,45050: outer IPv4, UDP, VXLAN, inner Ethernet
Geneve over IPv41,45050, before any options
IPv6 in IPv6, ip6tnl1,45248: outer IPv6 and an 8-byte destination option that limits nesting
GRE over IPv6, ip6gre1,44852
VXLAN over IPv61,43070
WireGuard1,42080, room for an outer IPv6 header; over IPv4 the overhead is 60
  • The tunnel’s MTU is what programs above it see. A host inside a VPN, or a container on a VXLAN overlay, has a path MTU below 1,500 when the physical links under it are 1,500.
  • A tunnel whose MTU is set too high sends outer packets too large for the link under it, and those meet the same fragment-or-drop choice as any other packet, as jumbo frames under a tunnel shows.

Too big: fragment or drop

  • A packet larger than the next link’s MTU is fragmented if DF is clear, and dropped if DF is set. The router that drops it sends ICMP “fragmentation needed”, type 3 code 4, with the next link’s MTU in it. IP packets shows the fragments’ fields.
  • Fragments are fragile. Losing one loses the whole packet. Only the first fragment carries the port numbers, so a firewall or NAT router that filters on ports can’t match the rest without reassembling them first. Linux holds fragments in memory for up to 30 seconds waiting for the set.
  • IPv6 routers never fragment. They drop the packet and send ICMPv6 “packet too big”. With the middle link at 1,400, a 1,452-byte ping got Packet too big: mtu=1400 from r1. After that, the client fragmented it itself: 1,352 bytes of data in the first fragment, the most that fits under 1,400 with the 40-byte header and an 8-byte fragment header.
  • Linux sets DF on every TCP packet and, by default, on UDP datagrams that fit the path MTU. A UDP datagram larger than the path MTU is fragmented by the sender instead.

MSS: TCP fits itself

  • Each end announces an MSS in its SYN from its own link’s MTU. A sender uses the smaller of the peer’s MSS and its own route’s MTU minus the headers, so a small MTU at either end limits both directions.
  • With the server’s link set to 1,400, the client announced MSS 1,460 and the server 1,360. Segments in both directions carried 1,348 bytes of data, and no ICMP was sent.
  • A SYN without the MSS option means 536 bytes over IPv4 and 1,220 over IPv6.
  • MSS can’t see a small link in the middle of the path. Both ends announced 1,460 when only the link between r1 and r2 was 1,400. That case needs path MTU discovery.

Path MTU discovery

Path MTU discovery has the sender set DF on its packets and lower its packet size when a router reports a smaller next link.

Path MTU discovery over TCP. The client sends SYN with MSS 1460, and the server answers SYN-ACK with MSS 1460. The client sends 1,500 bytes with DF set to r1, whose next link has MTU 1400. r1 answers with ICMP fragmentation needed, MTU 1400. The client then sends 1,400-byte packets, which reach the server.

With the middle link at 1,400, an upload from the client began with ten 1,500-byte segments, the initial window:

  • r1 answered each with ICMP fragmentation needed, mtu 1400: ten messages of 576 bytes, each quoting the start of the packet it dropped so the client could match it to the connection.
  • The client resent the data in 1,400-byte packets, 1,348 bytes of data each, within 0.1 ms of the first ICMP message.
  • ip route get 10.80.3.20 then showed cache expires 597sec mtu 1400, and a new connection’s MSS was 1,348 from its start.
  • Over IPv6, ICMPv6 packet too big did the same, and ip -6 route get showed expires 598sec mtu 1400.
  • tracepath finds the path MTU without a connection: it sent 1,500-byte probes and reported pmtu 1400 at hop 2, then Resume: pmtu 1400 hops 3.

The path MTU cache

The kernel stores a learned path MTU per destination, not per socket, so every socket to that host uses it.

  • An entry expires after net.ipv4.route.mtu_expires, 600 seconds, and then the kernel tries the link’s MTU again. ICMP only ever reports a smaller MTU, so without probing, as in PLPMTUD below, a larger path MTU is found only this way.
  • A forged ICMP message, sent from r1 with mtu 300 and quoting the client’s UDP socket, set the cache to mtu lock 552. Linux doesn’t go below net.ipv4.route.min_pmtu, 552 bytes, so a forged message can’t force packets smaller than that.
  • lock means the kernel stopped setting DF for that destination. A 1,000-byte datagram then left as fragments of 548 and 500 bytes, and a 500-byte datagram was sent without DF.
  • A second forged message, mtu 1200, left the entry at 552. An ICMP message can lower a cached path MTU but not raise it: on an unlocked entry of 1,400, a forged mtu 1450 left it at 1,400.

Commands

ping -s sets the bytes of ICMP data, so the packet is that plus 8 bytes of ICMP and 20 of IPv4, or 40 of IPv6. With DF set, the largest size that gets an answer is the path MTU minus 28 over IPv4, and minus 48 over IPv6.

Linux:

ip link show eth0           # link MTU
ip link set eth0 mtu 1400   # set it
ping -M do -s 1472 host     # DF, 1,500 bytes, IPv4
ping -6 -M do -s 1452 host  # DF, 1,500 bytes, IPv6
tracepath -n host           # path MTU, hop by hop
ip route get host           # cached path MTU
ss -ti dst host             # TCP MSS and path MTU

macOS:

ifconfig en0                        # link MTU
networksetup -getMTU en0            # link MTU and its setting
sudo ifconfig en0 mtu 1400          # set it
ping -D -s 1472 host                # DF, 1,500 bytes, IPv4
sudo ping6 -D -s 1452 host          # DF, 1,500 bytes, IPv6
ping -D -g 1372 -G 1472 -h 10 host  # DF, 1,372 to 1,472 by 10
traceroute -F host 1500             # DF, 1,500 bytes, by hop
route -n get host                   # route MTU, mtu column
  • Linux ping has no sweep option, so trying several sizes takes one ping -M do -s per size. macOS has no tracepath; traceroute -F tests one size per run.

Linux ping -M chooses what happens to DF. On the path with the 1,400 link, a 1,472-byte ping gave:

ModeDFResult
-M doSet; never fragmentFirst ping: Frag needed and DF set (mtu = 1400) from r1. Next ping: Message too large at once, from the cached path MTU
-M probeSet, ignoring the cached path MTUFrag needed from r1 again
-M wantSet while the packet fits the known path MTU; fragment locally once it doesn’tFirst ping lost to Frag needed. Next ping answered, sent by the client as fragments of 1,396 and 124 bytes
-M dontClearAnswered; the client sent 1,500 bytes, and r1 fragmented it
  • On a Mac, ping -D -s 1473 to a host on the internet failed at once with sendto: Message too long. A sweep from 1,470 to 1,474 got answers up to 1,472.
  • macOS ping6 asks the kernel to fragment every packet to fit 1,280 bytes, the IPv6 minimum, so a large ping6 gets an answer whatever the path MTU. -D turns fragmentation off, and without sudo it failed with IPV6_DONTFRAG: Operation not permitted.
  • A ping that gets no answer and no Frag needed message can mean a black hole or ICMP blocked at the far end; ping can’t tell which.

Black holes

A path MTU black hole is a path that drops large packets without any ICMP message, so the sender never learns to send smaller ones. A firewall that drops all ICMP causes one; a link whose two ends disagree on the MTU causes another.

A path MTU black hole. The client sends SYN with MSS 1460, and the server answers SYN-ACK with MSS 1460. The client sends 1,500 bytes with DF to r1, whose next link has MTU 1400. r1 drops it, and a filter drops its ICMP message. The client sends the same 1,500 bytes again after 0.2, 0.4, and 0.8 seconds and more.

r1 dropped its own fragmentation needed messages with iptables. The client connected, sent 100 bytes and got a reply, then sent 200 KB:

SetupConnect, small message200 KB upload
No fix2 msNo progress after 60 s; 8 retransmission timeouts
tcp_mtu_probing = 1 on the client2 msDone in 6.4 s; MSS fell to 1,024, then rose to 1,347
MSS clamping on r12 msDone at once; MSS 1,348 from the start
  • Small packets fit, so the handshake and short messages worked. Only full-size segments vanished. So a black hole looks like a connection that opens, carries short messages, and then stalls on the first full-size segment.
  • Each retransmission waited twice as long as the one before, starting at 0.2 s. Without ICMP, nothing told TCP that size was the problem.
  • tcp_mtu_probing turns on packetization-layer path MTU discovery (PLPMTUD), which learns the path MTU from TCP’s own losses instead of ICMP. At 1, the Linux default being 0, it starts after repeated timeouts: here after five, 6.3 s in. It drops to tcp_base_mss, 1,024, and probes upward with larger segments, keeping the largest that is acknowledged. At 2, it runs on every connection from the start.
  • MSS clamping has a router rewrite the MSS in each SYN that passes through it. iptables -t mangle -A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu on r1 changed the client’s SYN from 1,460 to 1,360 and the server’s SYN-ACK from 1,460 to 1,360, since both directions cross the 1,400 link. It is meant for a router in front of a smaller link, such as a PPPoE or VPN link, so TCP through it doesn’t depend on ICMP.
  • Clamping only fixes TCP. A UDP datagram larger than the path MTU, sent with DF, still vanishes.
  • A link whose two ends disagree also makes a black hole. With the client’s end of the 9,000 network at 9,000 and the server’s at 1,500, TCP worked, because the server announced MSS 1,460. A ping of 8,000 bytes got no answer, and the server’s interface counted the frames as dropped.

Segmentation offload

  • With the default settings, tcpdump on the sending client showed TCP segments of 65,160 bytes of data, 45 times 1,448, far above the MTU.
  • The kernel hands large segments to the interface and lets it cut them into MTU-sized packets: TSO (TCP segmentation offload) does it in the network card, and GSO (generic segmentation offload) does it in software just before the driver. A capture on the sender sees the packet before it is cut.
  • With ethtool -K eth0 tso off gso off, the same capture showed segments of 1,448. Packets on a real wire are within the MTU. GRO (generic receive offload) does the reverse on the receiver, merging packets before the stack sees them.

Jumbo frames

A jumbo frame is an Ethernet frame that carries more than 1,500 bytes, often 9,000. The Ethernet standard doesn’t define them, so devices differ in the largest size they accept, and every host and switch on a link has to be set to match. A link whose ends disagree is a black hole for large packets, as black holes shows.

A larger MTU means fewer packets for the same data, and much of the kernel’s work is per packet rather than per byte. Client to server over the direct networks, 3 seconds of iperf3, the median of three runs:

OffloadsMTU 1,500MTU 9,000
On: TSO, GSO, GRO112.6 Gbit/s112.7 Gbit/s
Off15.1 Gbit/s55.3 Gbit/s
  • With offloads on, the kernel already handled 64 KB at a time, so the MTU made no difference. With offloads off, every 1,500-byte packet went through the stack on its own, and the CPU limited the transfer.
  • These links are virtual, so the numbers show the per-packet cost, not a network card’s speed. A jumbo MTU helps only on paths where every link carries jumbo frames; the rest of the path still limits packets to its own MTU.

Jumbo frames under a tunnel

A tunnel’s overhead comes out of the MTU of the hosts inside it. A physical network with jumbo frames leaves room for that overhead, so a VXLAN overlay on it can give its hosts a full 1,500. Two more containers, each on a 9,000-byte network and a 1,500-byte network, ran a VXLAN link with an MTU of 1,500 over each:

Underlay1,472-byte ping with DF, inside the tunnelOn the underlay
MTU 9,000AnsweredOne outer packet of 1,550 bytes
MTU 1,500AnsweredTwo outer fragments, 1,500 and 70 bytes
MTU 1,500, VXLAN df setFirst ping lost; then Message too large at onceThe kernel lowered the inner path MTU to 1,450
  • Created without naming the link under it (dev eth0), each VXLAN interface started at 1,500, whatever the underlay. Created with dev eth0 on the 1,500 link, as in the tunnels section, it started at 1,450.
  • Linux leaves DF clear on VXLAN’s outer packets by default, so the inner packet’s DF didn’t stop the outer packet from being fragmented. The ping worked, but every full-size packet in the tunnel crossed as two fragments.
  • With df set, the outer packets carried DF. The first 1,550-byte outer packet didn’t fit, so the kernel dropped it and lowered the cached path MTU inside the tunnel: ip route get showed mtu 1450. After that a 1,422-byte ping fit.

Cloud networks set their own limits:

NetworkDefault MTULargest MTUWhere larger packets stop
AWS EC2Not stated; every instance type supports 1,5009,001 on current-generation instance types1,500 through an internet gateway, over VPN, and between regions without a transit gateway; 8,500 over inter-region VPC peering
Google Cloud VPC1,4608,896, set per VPC networkGoogle’s docs note that the internet generally uses 1,500
Azure1,5009,000 with the Microsoft Azure Network Adapter, 3,900 with Mellanox adaptersOnly within the virtual network and directly peered networks in the same region; not through gateways, global peering, or to the internet

The kernel and the program

StepDone by
Set a link’s MTUAdministrator, or the tunnel driver when it creates the link
Announce MSS in the SYN, cut a byte stream into segments that fitKernel, for TCP
Set DF and learn the path MTU from ICMPKernel, for TCP, and by default for UDP datagrams that fit
Cache the path MTU per destination, expire it after 600 sKernel
Choose a UDP datagram’s sizeProgram
Notice a black hole and probe for the path MTUKernel for TCP with tcp_mtu_probing; the program for UDP

In a program

In Go, the syscall package reaches the socket options through SyscallConn. A dialed UDP socket set IP_MTU_DISCOVER to IP_PMTUDISC_DO, which sets DF and forbids fragmenting, then wrote datagrams over the path with the 1,400 link:

WriteReturnedIP_MTU after
1,473 bytesmessage too long1,500
1,472 bytesNo error; r1 dropped it and sent ICMP1,400
1,372 bytesmessage too long, the error stored from the ICMP message1,400
1,372 bytesNo error; delivered1,400
1,472 bytesmessage too long1,400
  • The 1,472-byte datagram was lost, and the program learned of it only from the next write, which failed even though 1,372 bytes fit. A program on UDP has to resend the lost datagram itself, smaller.
  • IP_MTU reads the path MTU of a connected socket, and TCP_MAXSEG reads a TCP connection’s MSS: 1,348 over the same path.
  • Without IP_MTU_DISCOVER, Linux uses IP_PMTUDISC_WANT: DF on datagrams that fit, and fragments for the ones that don’t.
  • QUIC runs on UDP and sets DF on every datagram. It requires a path that carries 1,200-byte datagrams, and it can find a larger path MTU from ICMP or with probes of its own, the datagram form of PLPMTUD. DNS clients advertise a 1,232-byte limit for answers over UDP, so answers fit in one packet.

IP packets covers fragment fields, ICMP the error messages, TCP the handshake that carries MSS, and UDP datagram sizes.

References: RFC 791: Internet Protocol, RFC 8200: IPv6, RFC 1191: Path MTU discovery, RFC 8201: Path MTU discovery for IPv6, RFC 2923: TCP problems with path MTU discovery, RFC 4821: Packetization layer path MTU discovery, RFC 8899: Datagram PLPMTUD, RFC 9293: TCP, maximum segment size, RFC 1812: Requirements for IPv4 routers, RFC 2516: PPPoE, RFC 7348: VXLAN, RFC 8926: Geneve, WireGuard protocol, RFC 9000: QUIC, datagram size, ip(7), tcp(7), Linux IP sysctl, Linux segmentation offloads, iptables-extensions(8), TCPMSS, tracepath(8), ip-link(8), VXLAN, Amazon EC2 network MTU, Google Cloud VPC MTU, Azure VM MTU, Go syscall package