It doesn't calculates the PMTU, it discovers it.
PMTUD is a protocol that requires a sender to discover the largest MTU
by sending repeatedly smaller packets until it stops receiving
an ICMP "Destination Unreachable" response. This is inefficient,
but avoids fermentation.
TCP MSS is a more recent protocol used with TCP at layer 4.
While establishing a new TCP connection, a three-way handshake is
performed. Each device inserts its MSS into TCP headers, so in this sense,
it’s announcing its MSS to the remote device, without any negotiation of
mutually acceptable values.
The problem that needs solving is that a device will only know the MTU,
and therefore the MSS, of its local link, but will not know about a
lower MSS on a link somewhere along the path.
The solution is to configure the routers to rewrite the MSS.
A Cisco router, for example, will have this command configured on a tunnel:
ip tcp adjust mss 1436
When TCP traffic, such as the three-way handshake, passes across
the tunnel, the router will see the MSS is set to 1460 in the TCP header
and will rewrite this to 1436, and the host at the other end will adjust
the maximum payload for this connection accordingly.
This option was previously required to be enabled through direct iptables
rules. However, firewalld for example now enables it as an option that
applies automatically to all rules.
This applies only to TCP, not UDP, and requires routers to participate
in the message routing.
Reference :
TCP MSS Clamping in Firewalld.