advanced26 min studyLesson 198 in Engineering

Translation capacity is a tuple and state budget

Model network address and port translation with explicit mapping assumptions, distinguish port exhaustion from bandwidth saturation, and account for retained state.

On this page

What you’ll understand

  • Explain how translated address-port mappings distinguish internal clients.
  • Calculate a destination-specific port budget under explicit reuse assumptions.
  • Diagnose retained translation state and allocation failures separately from throughput.

Network address and port translation lets many internal endpoints share external addresses by maintaining mappings and rewriting packet fields. Its limiting resource is not always link bandwidth. A service can stop opening new connections while moving little traffic because it has exhausted a relevant port or state-allocation pool. The useful question is not how many connections one public address supports in the abstract. Specify the transport protocol, remote endpoint, port pool, mapping behavior, and lifetime before calculating a capacity.

Mappings preserve enough identity for replies

A TCP flow is commonly identified by protocol and source/destination address-port pairs. A translator rewrites the internal source address and port to an external pair and retains enough state to translate replies back to the correct internal endpoint. Two internal clients can use the same local source port because their internal addresses differ. When both contact the same remote address and port through one external address, the translated flows need distinguishable external source ports in the simple model used here.

Mapping and filtering behavior must be distinguished by protocol. An endpoint-independent mapping can reuse an external pair for the same internal endpoint across different remotes. That differs from simultaneous port overloading between distinct internal endpoints, which RFC 5382 forbids for TCP. Therefore 65,536 port values are neither a universal usable pool nor a universal global connection ceiling. Reserved ranges, configured limits, per-subscriber port blocks, collision handling, and quotas can reduce the effective budget. Inspect the documented behavior and actual allocation counters.

Cone remote≤A PC_{\rm one\ remote}\leq A\,P
Under the stated model, A external IPv4 addresses each provide P usable TCP source ports for simultaneous flows to one fixed remote address-port pair. Each flow needs a distinct external tuple. This is a destination-specific upper bound, not a universal limit across all destinations, protocols, or NAT behaviors.↔ Scroll wide equations horizontally.

Closing application work need not release state immediately

Translation state has a lifecycle. Active connections, half-open attempts, recently closed TCP state, and idle UDP mappings can remain allocated according to protocol and implementation rules. A burst of short-lived requests can therefore consume many more mappings than the application's instantaneous active-request count suggests. Longer retention protects delayed traffic and protocol correctness, while shorter retention can cause premature reuse or lost replies. Do not treat indiscriminate timer reduction as a free capacity improvement.

Under a stable arrival process, Little's law relates average retained mapping count to allocation rate times mean retention time, provided the counting boundaries match. Count mappings, not packets, and include the whole measured residence interval. If one application request reuses a connection, several requests may share one mapping; if one request fans out, it may allocate many. Connection pooling can lower allocation churn but introduces its own concurrency and idle-lifetime choices. Validate the effective mapping demand instead of assuming a fixed requests-to-ports ratio.

N=λmWmN=\lambda_m W_m
N is average retained mappings, λ_m is the stable average allocation rate in mappings per second, and W_m is mean mapping residence time in seconds. The identity requires consistent boundaries and a stable system; it is not a deterministic peak-demand bound.↔ Scroll wide equations horizontally.

Observe exhaustion where allocation occurs

Port pressure often first appears as connection-establishment failure or delay, while existing connections continue. Collect allocation failures by external address, destination tuple, protocol, and tenant, alongside state-table occupancy and interface throughput. A large aggregate free count can conceal a saturated per-destination or per-subscriber pool. Packet captures on both sides of the translator can distinguish a request that never received a mapping from a reply that was translated incorrectly or filtered. Return routing also matters because stateful translation expects replies to encounter the appropriate state.

In the queue lab, interpret arrivals and service as abstract mapping-allocation and release work. For each separate comparison, press Reset, set both λ and μ, predict the direction of the normalized fluid backlog, then Play or Step. The display starts with four work units; it has no port identifiers, protocol states, reuse rules, or finite capacity ceiling. Its backlog is not a NAT occupancy forecast. Use the illustration to distinguish arrival/release imbalance from bandwidth, then use measured retention distributions and the actual tuple-allocation rules for production capacity planning.

Budget one hot remote endpoint

A hypothetical translator has two external addresses and 20,000 usable TCP source ports per address for one fixed remote address-port pair. It retains mappings for a mean 30 seconds and receives 1,000 new mappings per second in stable operation.

  1. Under the explicit distinct-port-per-flow model, the destination-specific pool contains 2 × 20,000 = 40,000 mappings. This is not a claim about all possible remote endpoints.

  2. Apply Little's law with consistent mapping boundaries: 1,000 mappings/s × 30 s = 30,000 average retained mappings. The average consumes 75% of the stated pool.

  3. The nominal average headroom is 10,000 mappings, but bursts and per-address imbalance can still exhaust a partition. At 1,500 mappings/s with unchanged retention, the implied 45,000 average exceeds the pool, so that stable unconstrained demand cannot be sustained.

The result

The base average fits the fictional 40,000-entry destination-specific budget, while the higher allocation rate does not. Peak behavior and real mapping rules still require measurement.

Explore the model

Interactive lab

Interactive lab · queue

Allocation and release are different rates

For each fresh comparison, press Reset, set both λ and μ, predict whether the four initial work items grow or drain, then Play or Step. This is only an allocation/release analogy; no NAT ports, mappings, timeouts, tuple reuse, or state-table ceilings are implemented.

Allocation and release are different ratesFluid backlog starts at 4 and follows max(0, 4 + (λ − μ)t). The separate M/M/1 residence-time formula assumes Poisson arrivals, exponential service and λ < μ. Current readings: Fluid backlog: 4; Net rate · λ − μ: −1 /s; M/M/1 mean residence: 1 s. All parameters are adjustable with the labeled controls below.02.557.51001.534.56Elapsed time · sFluid backlogλ < μ
Fluid backlogCurrent time
Fluid backlog
4
Net rate · λ − μ
−1 /s
M/M/1 mean residence
1 s
t = 0 s

Fluid backlog starts at 4 and follows max(0, 4 + (λ − μ)t). The separate M/M/1 residence-time formula assumes Poisson arrivals, exponential service and λ < μ. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forTranslation failures can reflect a state or port budget even while network bandwidth remains available.

Check your understanding

Why is 'one public IP supports exactly 65,536 TCP connections' an unreliable capacity claim?

Try it yourself

A stable workload allocates 400 mappings per second with mean retention 45 seconds. It has a stated effective pool of 24,000 mappings. Calculate average occupancy and the allocation rate that would exactly fill the pool on average.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Use N=λW for average occupancy, then solve the same relation for λ at the pool size. An average-at-capacity result leaves no burst margin.

Compare with the solution

Average occupancy is 400 × 45 = 18,000 mappings, or 75% of the pool. The nominal average-fill rate is 24,000 / 45 ≈ 533.33 mappings per second. This is not a safe operating recommendation: variability, partitions, and changed retention can cause exhaustion earlier. The calculation assumes stable arrivals, consistent mapping lifetimes, and the stated effective pool.

Take it with you

  • NAT capacity depends on protocol tuples and documented mapping-allocation behavior.
  • Retained state can exhaust resources after application work has already ended.
  • Measure allocation failures and pool partitions separately from link bandwidth.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.