How do both sides know the MTU

mtu

If I have ComputerA that has their networking interface set with an MTU of 1500 and ComputerB has a network interface with an MTU of 1200 is there any way for ComputerA to know that ComputerB's MTU is 1200 or if it sends large packets it will get from ComputerB a request to fragment the packet?

Best Answer

The hosts can use Path MTU Discovery which is optional for IPv4 and mandatory for IPv6.

With IPv4, a packet is fragmented where it is larger than the egress interface's MTU - that can happen on the source host or any intermediate router. In your example, the router between A and B would fragment the packet.

Fragmentation can put considerable load on routers and was removed for IPv6 routers, so a v6 host needs to discover the path MTU for each destination or fragment oversized packets by itself. If an IPv6 router encounters an oversized packets it returns an ICMP error and drops it.

The MTU is a property of each interface. It is either (hardware) default, configured statically, or by DHCP (option 26). All nodes in a shared L2 segment need to use the same maximum frame size, resulting in the same MTU. If a node sends larger frames than the others can except these are dropped as oversized.