Protocol in Code · Track

NAT

5-tuple identity, stateless rewrite, and port allocation under expiry

6 sessions Course material (English)

Sessions

NAT track sessions

Session 01

A Connection Is a 5-Tuple

What identifies a connection to the kernel, and what does it mean that the reply direction is just the same identity with two fields swapped?

Open Session 01
Session 02

Translation Is a Rewrite Function

When a router performs NAT, does it change the packet, or does it produce a new packet and let the old one go?

Open Session 02
Session 03

The Reply Finds Its Way Back

When a reply packet arrives from the internet, how does the router already know where it belongs — and when was that decision actually made?

Open Session 03
Session 04

Ports Are a Shared Resource

One public IP, one ephemeral port range, thousands of private hosts behind it — how does the NAT box hand out a port that no other flow is using, and what happens the moment it runs out?

Open Session 04
Session 05

State Expires, Again

A conntrack entry has no close signal from the network most of the time — so what decides it is dead, and why does that decision take ten times longer for TCP than for UDP?

Open Session 05
Session 06

Build the Toy NAT Box Loop

Every earlier session in this track taught one piece — the tuple, the rewrite, the table, the port pool, the clock. What does a packet's actual round trip through all five look like when they are wired into one box?

Open Session 06