While IPv6 represents the future of the internet, IPv4 remains the dominant protocol, making Network Address Translation (NAT) a critical component of modern network infrastructure. Traditionally, operators have faced a choice between expensive, proprietary hardware appliances or flexible but performance-limited software solutions like the standard Linux Netfilter framework. This paper introduces Quick NAT, a high-performance software-based NAT system designed for commodity servers that achieves 10 Gbit/s line-rate performance, significantly outperforming standard kernel implementations.
The Bottlenecks of Software NAT
Standard software NAT implementations, such as Linux's iptables, suffer from three primary performance bottlenecks:
- Sequential Rule Searching: Rules are typically checked one by one. As the number of rules grows into the thousands, lookup latency spikes dramatically.
- Lock Contention: In multi-core environments, CPU cores frequently compete for global locks to update connection tracking tables, which severely limits scalability.
- Kernel Overhead: The overhead of moving data between the network interface card (NIC) and the operating system kernel involves slow interrupts and multiple memory-copying operations.
The Quick NAT Architecture
Quick NAT addresses these challenges by moving the entire NAT logic into user-space and rethinking the data structures used for rule matching and connection tracking. The system is built on top of the Data Plane Development Kit (DPDK), which allows it to bypass the Linux kernel entirely. By utilizing polling instead of interrupts and zero-copy memory management, Quick NAT minimizes the CPU cycles required per packet.
As shown in the architecture diagram, the system consists of several key modules:
- Connection Tracking: Uses a localized, lock-free hash table to manage active flows.
- Rule Lookup (QNS): Implements a novel searching algorithm to find translation rules rapidly.
- Address Resource Pool: Manages the available public IP addresses and ports.
- Five-tuple Modification: Performs the actual header rewrites in-place using zero-copy pointers.
Innovation: The QNS Algorithm
To eliminate the $O(n)$ complexity of sequential rule searching, the authors developed the Quick NAT Search (QNS) algorithm. Instead of a single linear list, rules are organized into 32 sub-hash tables, each corresponding to a specific IP mask length (from /0 to /32).
When a packet arrives, the system performs a hash-based lookup starting from the longest prefix (most specific rule) to the shortest. This turns a slow linear search into a near-instant $O(1)$ lookup, making the system's performance independent of the total number of rules configured.
Multi-Core Scalability
To solve the lock contention problem, Quick NAT employs a Localized Parallel Architecture. It uses Receive Side Scaling (RSS) to distribute incoming traffic across CPU cores. Crucially, the system pre-calculates which core will handle the return traffic for a given flow and pre-populates that specific core's local connection table. This design eliminates the need for global locks, allowing performance to scale linearly with the number of CPU cores.
Performance Evaluation
The system was tested on a commodity server equipped with an Intel Core i7-5930k and a 10 Gbit/s NIC. The results were transformative:
- Latency: For a set of 10,000 rules, the standard Linux search took approximately 30,120 ns, whereas Quick NAT’s QNS algorithm required only 45 ns.
- Throughput: Quick NAT achieved a 10 Gbit/s line rate even for the smallest 64-byte packets. In comparison, the standard Linux kernel could only reach line rate for packets larger than 800 bytes.
- Scalability: While Netfilter's performance plateaued quickly due to lock contention, Quick NAT hit the 10 Gbit/s hardware limit using just three CPU cores.
Conclusion
Quick NAT demonstrates that with the right architectural choices—specifically user-space processing, lock-free data structures, and hash-based rule searching—commodity hardware can match the performance of dedicated network appliances. Future work may extend this architecture to support 40G/100G interfaces and complex application-level gateways.
Summary updated