4 ms·
Since there is no port in ICMP, NAT doesn't have to deal with the problem of sending the ICMP echo reply back to the correct port. ICMP echo requests have an I
by kazinator 3y ago
Since there is no port in ICMP, NAT doesn't have to deal with the problem of sending the ICMP echo reply back to the correct port.
ICMP echo requests have an ID, and that's effectively the same as a source port number.
Correct NAT handling of ICMP echo has to remap the ID in both directions, the same way that correct handling of UDP remaps the source port.
Reason being, if the machine behind NAT is being pinged at the same time by two different hosts, and they happen to use the same request numbers, then it is ambiguous.
Another possibility is not to rewrite the identifiers, but keep a list of remote machines associated with each ID. When there is a clashing ID, the list contains two or more entries (remote IP addresses). So then, when a reply is received from the machine behind the NAT gateway, the NAT chooses one of the entries in the list (say, the least recently added one) and sends the reply to that machine. Then removes the entry.