The following example depicts PCP port allocation with the PORT_SET option in action. For additional examples, see RFC 7753.
In this example, the sequence on the top of Figure: PORT_SET example represents the state of the port forwards for an external IP address before the PCP Request with the PORT_SET option is received. The port 1032 (in red) has already been mapped to a source port for the same client or to a different client.
A PCP client requesting an overlapping set of external ports (while internal ports are different) triggers the following action in SR OS (PCP server):
The SR OS checks if the existing mapping is overlapping with the one for this client. It checks to see if the occupied external port is already mapped to one of the requested internal ports from the 20000 to 20009 range for the same client.
If such overlap between internal and external ports is detected (for example, 20001 is mapped to 1032), then this is considered a refresh, and the response is:
opcode: 1(MAP)
internal port: 20,000
assigned external port: 1032
assigned external ip address:192.0.2.3
Every overlapping pair of internal and external ports are individually acknowledged. No new mapping is allocated.
If there is no overlap (when the external port is mapped to a port outside of the 20000 to 20009 range), and no limit is reached, then the SR OS honors the request where it finds any set containing consecutive 10 ports.
In Figure: PORT_SET example , there is no overlap (external port 1032 belongs to another client or the same client outside of the 20000 to 20009 range) and consequently a block of 10 ports (following parity) is allocated to the client.