Home / Learn / AI Networking / Packet Processing in Hardware Explained

On this pageThe time budgetWhat processing a packet involvesParsingMatch-action tablesPipelinesFixed and programmableStateless and stateful processingFast path and slow pathOther hardware functionsBuffering and queueingWhere it is foundImplementation technologiesDesign challengesWhy AI raises the stakesFor chip designersCommon questionsRelated guides

Packet Processing in Hardware Explained

Hardware packet processing means inspecting, modifying and forwarding network packets in dedicated circuits instead of in software on a general-purpose processor. A switch, a network card or a DPU has only a few nanoseconds to deal with each packet on a fast link. Purpose-built logic can do the work in that time, in a predictable number of steps, for every packet. It is the reason networks keep pace with rising link speeds.

The time budget

The case for hardware starts with arithmetic.

On a 100 gigabit per second link, the smallest Ethernet packets can arrive at roughly 150 million per second. That leaves under seven nanoseconds per packet. At 400 or 800 gigabits, the budget shrinks in proportion.

A processor core running software needs tens to hundreds of nanoseconds to handle a packet, more if it misses its cache. Software can keep up only by using many cores, and its timing varies from packet to packet. Hardware handles packets in a pipeline, with several in progress at once, and at a fixed pace.

What processing a packet involves

Whatever the device, the steps are similar.

  • Parse. Identify the headers: Ethernet, IP, transport, tunnels, and so on.
  • Classify. Decide which flow or rule the packet belongs to.
  • Look up. Find the matching entries in forwarding, policy or connection tables.
  • Act. Forward, drop, modify, encapsulate, mirror or count.
  • Queue and schedule. Place the packet in a queue and decide when it leaves.
  • Deparse. Reassemble the headers, as modified, in front of the payload.

Parsing

A parser reads the first bytes of a packet and works out which headers are present. Each header says what follows it, so the parser moves through a graph of possible sequences.

Hardware parsers extract the fields that later stages need, such as addresses, ports and tags, into a compact set of metadata that travels with the packet through the pipeline. Parsers may be fixed, supporting a set list of protocols, or programmable.

Match-action tables

The core of most packet processing hardware is the match-action table. A table takes some fields as a key, finds a matching entry and returns an action to perform.

Match typeHow it worksTypical useHardware
ExactKey must equal the entryConnection tracking, address tablesHash tables in memory
Longest prefixThe most specific matching prefix winsIP routingSpecialized tree or hash structures
Ternary, or wildcardEntries can ignore some bitsAccess control, classificationTernary content-addressable memory
RangeKey falls within boundsPort rangesExpanded into ternary entries or dedicated logic

Ternary content-addressable memory compares a key against every entry at once, which is fast and costly in area and power. Hash tables are far cheaper per entry and must deal with collisions. Much of the craft in designing these devices lies in getting large tables at low cost.

Pipelines

Tables are arranged in a sequence of stages. A packet’s metadata moves from stage to stage, with each performing a lookup and applying actions. Because every stage holds a different packet at any moment, the pipeline’s throughput is set by the time of one stage, not the whole sequence.

Actions include rewriting fields, adding or removing headers, decrementing counters such as the hop limit, updating statistics and choosing an output port.

Fixed and programmable

Fixed-function hardware implements a defined set of protocols and behaviors. It is the most efficient and cannot handle what it was not designed for.

Programmable hardware lets the parser, tables and actions be defined after manufacture. The language most associated with this is P4, in which a designer describes how packets should be parsed and processed, and a compiler maps the description onto the device.

Programmability matters where protocols change, as with virtual network encapsulations and the new AI transports. It costs some area and power compared with a fixed design.

Stateless and stateful processing

Some functions need only the packet in hand: routing by destination, filtering by a static rule.

Others need memory of what came before.

  • Connection tracking for stateful firewalls and address translation.
  • Metering and rate limiting.
  • Load balancing that keeps a flow on the same server.
  • Transport protocols, which track sequence numbers, acknowledgements and congestion state.
  • Telemetry that measures flows over time.

Stateful processing needs tables that the data path can update at line rate, which is harder than read-only lookup.

Fast path and slow path

A common design splits work in two.

  • Fast path. Hardware handles the packets of established flows using table entries.
  • Slow path. The first packet of a new flow, and unusual cases, go to software on processor cores. Software makes the decision and installs an entry so that following packets stay in hardware.

This gives the flexibility of software for decisions and the speed of hardware for volume. Its weakness is workloads with very many short flows, where the slow path sees too much traffic.

Other hardware functions

  • Checksums and integrity codes.
  • Encryption and decryption inline, for protocols such as IPsec and MACsec.
  • Encapsulation and decapsulation for overlay networks.
  • Segmentation and reassembly.
  • Traffic management. Many queues with scheduling and shaping.
  • Timestamping for precise time synchronization and measurement.
  • Mirroring and sampling for monitoring.

Buffering and queueing

Packets must wait when an output is busy. Hardware manages buffer memory, tracks the depth of each queue and schedules departures by priority or weight.

This is also where congestion signals originate: marking packets when a queue is long, sending pause frames or trimming packets. and Lossless Ethernet and PFC Explained.

Where it is found

DeviceRole of packet processing
Switch chipsForwarding between many ports at the highest rates
Network interface cardsOffloads, filtering, steering to processor cores
SmartNICs and DPUsVirtual switching, security, storage and transport, with programmability
RoutersLarge routing tables and rich traffic management
Security appliancesDeep inspection, firewalls
Network-attached acceleratorsIntegrated network endpoints

Implementation technologies

  • ASICs. Highest performance and efficiency. Fixed or programmable pipelines.
  • FPGAs. Reconfigurable logic. Flexible, with lower density and higher power for the same function.
  • Network processors. Many cores specialized for packet work, with hardware assists.
  • General-purpose processors with optimized software and kernel-bypass frameworks. The most flexible and the least efficient per packet.

Many devices combine several: a hardware pipeline for the fast path and processor cores for the rest.

Design challenges

  • Table capacity against area and power.
  • Update speed. Changing entries without disturbing traffic.
  • Timing closure at very high clock rates. Wide data paths that process many bytes per cycle are used to keep clock speeds practical.
  • Multiple packets per cycle. At the highest speeds, more than one small packet can arrive in a single clock cycle of the data path, and the logic must handle them in parallel.
  • Verification. The number of protocol combinations and corner cases is enormous.
  • Latency. Each pipeline stage adds delay.
  • Flexibility without losing efficiency.

Why AI raises the stakes

AI networks push packet processing in specific ways.

For chip designers

Teams building networking into a chip must decide how much of the pipeline to design and how much to license. Parsers, classifiers, table engines, traffic managers and protocol-specific blocks are all available as IP, with varying degrees of programmability. The trade-offs are the usual ones: differentiation, risk, schedule and the cost of verification.

Common questions

Why process packets in hardware instead of software?

At modern link speeds there are only a few nanoseconds per packet. Dedicated hardware can meet that budget consistently and with far less energy than processor cores running software.

What is a match-action table?

A structure that looks up selected packet fields and returns an action, such as forward, drop or modify. Pipelines of these tables are the basis of most packet processing hardware.

What is P4?

A language for describing how a network device should parse and process packets. It lets the behavior of programmable hardware be defined in software and compiled to the device.

Related guides