Multi-level and dynamic timers for carrier grade NAT
Systems and methods described herein use a variable 2MSL timer (also referred to herein as a “port reuse timer”) for a core network/gateway. A network device in a core network detects closing of a session that uses a port designated for Network Address Translation (NAT), monitors an overall NAT port utilization level, and manages release timing for the port based on the overall port utilization level.
1. A method comprising:
detecting, by a network device, a closing of a Transport Control Protocol (TCP) session, wherein the TCP session uses a port designated for Network Address Translation (NAT);
monitoring, by the network device, an overall NAT port utilization level of the network device; and
assigning, by the network device, one or more timing thresholds for a two-stage timer that permits reuse of the port and releases the port based on the overall NAT port utilization level.
2. The method of claim 1 , wherein assigning the one or more timing thresholds comprises assigning a value to a port reuse timer based on the overall NAT port utilization level, and wherein the method further comprises:
maintaining an assigned state for the port until the port reuse timer expires; and
designating an unassigned state for the port when the port reuse timer expires.
3. The method of claim 2 , where assigning the value to the port reuse timer based on the overall NAT port utilization level further comprises:
selecting from one of a minimum time value, a maximum time value, and an intermediate time value based on a current NAT port utilization level.
4. The method of claim 1 , wherein detecting the closing of the TCP session includes detecting messages indicating both endpoints of the TCP session are ready to close a connection.
5. The method of claim 1 , wherein assigning the one or more timing thresholds further comprises:
starting, in response to the detecting, a first timer;
maintaining the port in an assigned state until the first timer expires; and
designating the port with an intermediate state after the first timer expires and before a second timer expires.
6. The method of claim 5 , wherein the intermediate state permits assignment by the network device when the overall NAT port utilization level exceeds a threshold.
7. The method of claim 5 , wherein ports in an unassigned state are prioritized for assignment over ports in the intermediate state.
8. The method of claim 5 , further comprising:
assigning ports from the intermediate state in order of decreasing age.
9. The method of claim 1 , wherein the network device includes:
a Packet Data Network Gateway (PGW), or
a User Plane Function (UPF).
10. A network device comprising:
a processor configured to:
detect a closing of a Transport Control Protocol (TCP) session, wherein the TCP session uses a port designated for Network Address Translation (NAT);
monitor an overall NAT port utilization level of the network device; and
assign one or more timing thresholds for a two-stage timer that permits reuse of the port and releases the port based on the overall NAT port utilization level.
11. The network device of claim 10 , wherein, when assigning the one or more timing thresholds, the processor is further configured to:
assign a value to a port reuse timer based on the overall NAT port utilization level;
maintain an assigned state for the port until the port reuse timer value expires; and
designate an unassigned state for the port when the port reuse timer value expires.
12. The network device of claim 11 , wherein, when assigning the value to the port reuse timer, the processor is further configured to:
select from one of a minimum time value, a maximum time value, and an intermediate time value based on a current NAT port utilization level.
13. The network device of claim 10 , wherein, when detecting the closing of the TCP session, the processor is further configured to:
detect messages indicating both endpoints of the TCP session are ready to close a connection.
14. The network device of claim 10 , wherein, assigning the one or more timing thresholds, the processor is further configured to:
start, in response to the detecting, a first timer;
maintain the port in an assigned state until the first timer expires; and
designate the port with an intermediate state after the first timer expires and before a second timer expires.
15. The device of claim 14 , wherein the intermediate state permits assignment by the network device when the overall NAT port utilization level exceeds a threshold.
16. The network device of claim 15 , wherein the processor is further configured to:
assign ports from the intermediate state in order of decreasing age.
17. The network device of claim 10 , wherein the network device includes:
a Packet Data Network Gateway (PGW), or
a User Plane Function (UPF).
18. A non-transitory, computer-readable storage medium storing instructions executable by a processor of a network device, which when executed cause the network device to:
detect a closing of a Transport Control Protocol (TCP) session, wherein the TCP session uses a port designated for Network Address Translation (NAT);
monitor an overall NAT port utilization level of the network device; and
assign one or more timing thresholds for a two-stage timer that permits reuse of the port and releases the port based on the overall NAT port utilization level.
19. The non-transitory, computer-readable medium of claim 18 , wherein the instructions to assign one or more timing thresholds further cause the network device to:
assign a value to a port reuse timer based on the overall NAT port utilization level;
maintain an assigned state for the port until the port reuse timer value expires; and
designate an unassigned state for the port when the port reuse timer value expires.
20. The non-transitory, computer-readable medium of claim 18 , wherein the instructions assign one or more timing thresholds further cause the network device to:
select from one of a minimum time value, a maximum time value, or an intermediate time value based on a current NAT port utilization level.