Computer Networking › Section D · The network layer: data plane › Topic D.7
Middleboxes
Between your laptop and a web server there are not only routers. NATs, firewalls, caches and load balancers sit on the path too, reading and sometimes rewriting your packets. These middleboxes are everywhere, and they quietly reshape how the internet can change.
What a middlebox is
A router's standard job is narrow: read the IP header, decrement the TTL, look up the destination and forward. A middlebox is any device on the data path between a source and a destination host that does something other than that standard forwarding. RFC 3234, which surveyed them in 2002, gives a definition along these lines. Some you have met already: the NAT in DHCP and network address translation, the web caches of The web and HTTP, and the match-plus-action rules of Generalized forwarding and SDN, which let one switch act as a firewall or load balancer. Middleboxes have multiplied over the past two decades and now sit in nearly every enterprise, data centre and mobile network.
Three families of service
Middleboxes fall broadly into three groups. Address translation: NAT boxes, including carrier-grade NAT, rewrite IP addresses and port numbers so that private networks can share public addresses. Security: firewalls block traffic by header fields, intrusion detection systems look for known attack patterns, deep packet inspection examines payloads, and e-mail gateways filter spam and phishing. Performance: caches serve popular content close to users, load balancers spread requests across a pool of servers, WAN optimisers compress traffic between branch offices, and performance-enhancing proxies split TCP connections over slow or lossy links such as satellite. Firewalls and intrusion detection are covered in depth in Operational security: firewalls and intrusion detection.
Which layers they touch
A pure router reads only the network-layer header. Middleboxes routinely reach higher. A NAT rewrites network-layer addresses and transport-layer ports, and must fix both checksums. A stateful firewall tracks TCP connections and drops segments that belong to none. A load balancer may read the HTTP request to choose a server. A cache answers application-layer requests itself. To do this, many middleboxes keep per-flow state: a NAT's translation table or a firewall's connection table. That state is why such boxes need every packet of a flow to pass through them, and why a failure can break connections that a stateless router would simply reroute.
Worked example: one request, four boxes
An employee's browser at 10.1.4.20 fetches a page from a company web service. 1. A firewall at the office edge checks the destination port, 443, against policy and records the new TCP connection in its connection table. 2. A NAT rewrites the source to the office's public address and a new port, storing the mapping. 3. At the data centre a load balancer receives the connection for the service's public address and rewrites the destination to one server, 172.18.0.12, keeping that choice for the whole connection. 4. Replies retrace the path, and each box reverses its own rewrite. Check: the browser and server each saw an address that was not the other's real one, yet the connection worked because all four boxes kept state.
The end-to-end argument
The classic internet design kept the core simple and put intelligence in the end hosts. The end-to-end argument, set out by Saltzer, Reed and Clark in 1984, explains why: a function such as reliable delivery can only be done completely and correctly with the help of the endpoints, so building it into the network is at best a performance optimisation. Middleboxes cut across this. They put application- and transport-aware logic inside the network, and they rewrite fields that the endpoints thought were theirs. Some engineers call them an architectural mistake; others argue they meet real, lasting needs and will only increase.
The narrow waist and ossification
The internet's stack is often drawn as an hourglass. Many applications and transports sit above, many link technologies sit below, and one protocol, IP, forms the narrow waist that every device must speak. Middleboxes thicken that waist, because they also expect particular TCP and UDP behaviour. A box that does not recognise a new TCP option or an unfamiliar transport protocol may strip it or drop the packet. This freezing of what the network will carry is called ossification. It is a major reason QUIC, covered in Evolution of the transport layer: QUIC, runs over UDP and encrypts most of its headers, so that middleboxes cannot inspect or interfere with them.
Network functions virtualisation
Traditionally each middlebox was a separate hardware appliance with its own software, management interface and specialist staff, which is costly to buy, run and upgrade. Network functions virtualisation (NFV) instead runs firewalls, NATs, load balancers and even mobile-network core functions as software on ordinary servers, the same idea SDN applied to switches. Capacity then grows by starting more instances rather than buying boxes, and functions can be chained in software in the order a flow needs. A related approach moves middlebox functions into a cloud provider's network, so the customer manages policy rather than hardware.
Worked example: sizing a virtual firewall
An operator replaces hardware firewalls with software ones. Peak traffic is 120 Gbps, each firewall instance can inspect 10 Gbps, and one spare instance must always be ready in case another fails. 1. Instances needed for the load: \(\frac{120}{10} = 12\). 2. Add one spare: 13 instances. 3. Each server can host 4 instances, so servers needed are \(\lceil 13 \div 4 \rceil = \lceil 3.25 \rceil = 4\). 4. If peak traffic grows to 150 Gbps, the operator needs 15 plus 1 spare, 16 instances, still exactly 4 servers. Check: \(12 \times 10 = 120\) Gbps covers the peak, and losing one instance still leaves 12.
Common mistakes to avoid
First, calling every in-network device a router; a middlebox does more than standard IP forwarding. Second, assuming middleboxes read only IP headers; many read transport and application data. Third, forgetting that stateful boxes need both directions of a flow to pass through them. Fourth, thinking NFV removes the middlebox functions; it moves them from appliances into software. Fifth, assuming a new protocol works because the standard allows it; middleboxes on real paths may drop what they do not recognise. Sixth, rounding the number of instances down instead of up when sizing capacity.
Key takeaways
A middlebox is any device on the data path doing more than standard IP forwarding. The three families are address translation (NAT), security (firewalls, intrusion detection, deep packet inspection, mail filters) and performance (caches, load balancers, WAN optimisers, TCP-splitting proxies). Many read and rewrite transport and application fields and keep per-flow state. They cut against the end-to-end argument and widen IP's narrow waist, causing ossification, one reason QUIC encrypts its headers over UDP. NFV runs middlebox functions as software on ordinary servers.
Flashcards
Flashcard
A device on the data path doing more than standard IP forwarding
Test your understanding
Question 1 of 5
Which device is a middlebox rather than a plain router doing standard IP forwarding?
Question 2 of 5
A box between two branch offices compresses traffic so that a slow link carries more data. Which family of middlebox is it?
Question 3 of 5
Why is a NAT said to break the separation between the network layer and the layers above?
Question 4 of 5
Peak traffic is 70 Gbps, each virtual firewall instance handles 8 Gbps, and one spare instance is required. How many instances are needed?
Question 5 of 5
Why does QUIC run over UDP and encrypt most of its headers?
