NIC path and time: kernel bypass, hardware timestamping, PTP, and why time sync is a correctness problem

The kernel network stack is a latency tax you can opt out of, and hardware timestamps plus PTP are the only way to know what your latency actually was — which makes time sync a correctness problem, not a housekeeping one.

Read the briefing
About 3 min to read 6 drills

What to remember

  1. Kernel bypass buys microseconds and costs you tcpdump. Onload, DPDK and AF_XDP move the data path to user space; your traffic no longer passes the tools everyone else debugs with, so capture has to be designed in.
  2. Coalescing is a throughput setting with a latency price. rx-usecs that is great for bulk transfer adds tens of microseconds to a single packet. Latency configs lower it and pay in CPU.
  3. Software timestamps tell you when the kernel got round to it. SO_TIMESTAMPING with NIC support records the wire moment. Anything else is measuring your own scheduler.
  4. PTP without hardware timestamping is NTP with extra steps. Sub-microsecond sync needs timestamps taken in the NIC, and ideally boundary or transparent clocks in the switches.
  5. Clock offset is a monitored dependency with an alert. A drifting clock produces wrong answers — mis-sequenced books, unfair matching, useless audit trails — rather than slow ones.

The big picture

Between the wire and your code sit an interrupt, a softirq, a copy and a scheduler decision. This topic is about removing what you can of that, measuring what remains with timestamps taken in hardware, and keeping the clock that stamps them provably correct.

The mental model

Two questions. How much of the kernel is in my data path, and can I take it out? And whose clock do I trust when I say a packet arrived at 09:30:00.000123 — mine, the NIC's, or the grandmaster's?

In depth

Bypass: taking the kernel out of the path

The standard path costs an interrupt, a softirq, a copy into a socket buffer and a wake-up. Kernel bypass lets user space map the NIC's queues directly: Solarflare Onload does it transparently via LD_PRELOAD for existing socket code, DPDK replaces the stack entirely with poll-mode drivers, AF_XDP keeps the kernel driver but hands frames to user space, and io_uring with busy polling narrows the gap without leaving the stack. Every one of them trades CPU (a core spinning on the queue) and observability (your traffic no longer traverses the tooling everyone else uses) for latency and determinism. Choose deliberately, and plan capture and metrics for the path you actually run.

Interrupts, polling and the small settings that matter

ethtool -c shows coalescing: rx-usecs and rx-frames hold packets to amortise interrupts, which is right for throughput and wrong for a single latency-critical message. ethtool -C … rx-usecs 0 plus busy polling (SO_BUSY_POLL, net.core.busy_poll, or napi_defer_hard_irqs with gro_flush_timeout) trades CPU for immediacy. Other knobs worth knowing: ring sizes (-g) so bursts do not drop, RSS queue count and indirection (-x) so the right flow lands on the right core, and offloads (-k) — GRO and LRO batch packets, which helps throughput and blurs timing, so latency configs often turn them off for the hot interface.

Timestamping: knowing what actually happened

SO_TIMESTAMPING with SOF_TIMESTAMPING_RX_HARDWARE/TX_HARDWARE asks the NIC to stamp the frame as it crosses the wire; ethtool -T <if> tells you what the device supports. That stamp is what makes one-way latency measurable — you cannot derive it from a round trip — and it is what audit trails and fairness claims rest on. Software timestamps (RX_SOFTWARE) are taken when the kernel processes the packet and therefore include your own scheduling noise, which is useful for measuring the stack and useless for measuring the wire.

PTP: making the stamps mean the same thing everywhere

PTP (IEEE 1588) synchronises clocks by exchanging timestamped Sync/Delay_Req messages with a grandmaster and correcting for measured path delay. On Linux, ptp4l disciplines the NIC's PTP hardware clock and phc2sys copies that discipline to the system clock; boundary or transparent clocks in the switches keep queueing delay from being mistaken for distance. What to monitor: offset from master, mean path delay and its variance, phc2sys offset, and the servo state. Alert on all of them — silent drift is the failure mode, and it makes every downstream timestamp wrong at once.

Myths and facts

Myth: PTP replaces NTP and needs no special hardware.

Fact: Sub-microsecond PTP needs hardware timestamping in the NIC and switch support; without it you get NTP-class accuracy with more configuration.

Myth: Kernel bypass is strictly better.

Fact: It costs a spinning core, weakens isolation, and takes your traffic out of the standard tooling. It is a trade you justify per path.

Myth: Interrupt coalescing off is always right.

Fact: It lowers single-packet latency and raises CPU cost; on a throughput path it can make things worse overall.

Myth: A round trip divided by two gives one-way latency.

Fact: Paths are asymmetric and processing is not evenly split. One-way latency needs synchronised clocks and hardware stamps.

How pros do it

  • Choose the data path (stack, busy-poll, AF_XDP, Onload, DPDK) explicitly per workload, and design capture and metrics for it.
  • For the latency interface: minimal coalescing, busy polling, RSS steering to the pinned core, GRO/LRO off, ring sizes large enough for bursts.
  • Use hardware timestamps for anything you will quote, and check ethtool -T before promising them.
  • Run PTP with hardware timestamping, monitor offset, path delay and servo state, and alert before drift becomes visible downstream.
  • Capture at line rate with hardware stamps and keep it — venue disputes and latency regressions are settled with captures, not opinions.

Questions people ask

What accuracy should PTP give me, and how does it get there?

Tens to hundreds of nanoseconds with hardware timestamps and PTP-aware switches. The NIC stamps Sync and Delay_Req as they cross the wire, so the offset calculation leaves the host out entirely, and boundary or transparent clocks stop switch queueing being counted as distance. Without switch support you are at microseconds; with software timestamps you are at tens to hundreds of microseconds and unstable under load — NTP class, whatever the daemon is called.

Onload or DPDK?

Onload if you want existing socket code to go faster with minimal change; DPDK if you are building the data path yourself and want full control. Onload keeps the socket API and most of your tooling; DPDK costs more engineering and gives more headroom. Either way, say how you will capture and monitor a path the kernel no longer sees.

Why do I need one-way latency at all — why not half the round trip?

Because venue-to-you and you-to-venue are different paths with different queueing, and half a round trip hides which side regressed. One-way needs hardware stamps at both ends and clocks that agree, which is what PTP is for. If all you have is a round trip, say so, and do not quote it as one-way.

Does busy polling hurt anything?

It burns a core and raises power draw, and on a shared host it steals capacity from neighbours. On a dedicated latency host it is usually the right call, paired with coalescing turned down and RSS steering the flow to the polling core.

How do I check what my NIC can timestamp?

ethtool -T <if> lists the supported transmit and receive timestamping modes and the PTP hardware clock index. Check for hardware-receive as well as hardware-transmit before you promise one-way numbers on that interface.

Further reading

Drills · 6

Answer in your head, or out loud, before you reveal. Mark each one: "Again" brings it back, "Got it" counts on your desk.

1 Pick the strongest answer

A venue disputes your latency numbers. What measurement of one-way latency from their gateway to your process would you actually defend?

  1. Hardware receive timestamps on a NIC that supports them, with both ends' clocks disciplined by PTP — the stamp records the wire moment and the clocks make the two ends comparable. One-way latency needs synchronised clocks plus stamps taken outside your own scheduler.
  2. Round-trip time from the application, halved. Paths and processing are asymmetric; halving hides which direction regressed.
  3. Software timestamps at the socket layer, which are close enough. They include your own interrupt and scheduling delay, which is exactly what you are trying to exclude.
  4. The venue's own reported latency in their status portal. Useful context, not evidence about your path.
In short

Use hardware receive timestamps from the NIC with both clocks synced by PTP; a halved round trip or a software timestamp is not proof.

Why

ethtool -T tells you whether the NIC can do it, SO_TIMESTAMPING with the hardware flags asks for it, and PTP makes the two ends' clocks mean the same thing. Without all three you are measuring your own stack.

The common mistake

Halving the round trip. The two directions are different paths with different queueing, and halving hides which one regressed.

Read the docs

2 Pick the strongest answer

Your team wants to move the market-data receiver from the kernel stack to DPDK. What do you push back on before you say yes?

  1. It will not help because the kernel is not the bottleneck in any real system. It genuinely removes interrupt, copy and wake-up costs on the hot path.
  2. The traffic leaves the kernel, so existing capture, firewalling and metrics no longer see it — capture and observability have to be rebuilt as part of the work, and a spinning core per queue is now a permanent cost. The performance case is usually sound; the operational cost is what teams under-plan.
  3. DPDK cannot handle multicast. It handles multicast fine.
  4. You would have to abandon PTP. Timing still works; the integration differs.
In short

Raise that the traffic leaves the kernel, so capture, firewalling and metrics must be rebuilt, and one core will spin on each queue for good.

Why

Bypass is a real win and a real commitment: no tcpdump on that interface, your own health metrics, your own capture, and cores permanently burning. Onload is the middle path when you want the win without rewriting the application or the tooling.

The common mistake

Arguing the performance case either way. It is usually sound; what they want to hear is that you have planned capture and observability for a path tcpdump cannot see.

Read the docs

3 Answer out loud

How does PTP actually get you to sub-microsecond, how do you know it is working, and what do you hand a venue or an auditor when they dispute a timestamp? Five to seven sentences.

In short

A strong answer treats time as a monitored dependency: PTP with hardware timestamps, alerts on offset and path delay, and captures kept as evidence.

What a strong answer does
  • correctness: GPS-backed grandmasters (redundant), PTP with hardware timestamping, boundary/transparent clocks, ptp4l disciplining the PHC and phc2sys the system clock, holdover behaviour considered.
  • verification: Offset, path delay and its variance, servo state, phc2sys offset, plus an independent cross-check and alerts before downstream data is affected.
  • evidentiary use: Line-rate capture with hardware stamps, retention that matches the regulatory window, and a documented procedure for answering a venue dispute.
  • communication: Sources → distribution → hosts → monitoring → evidence, with the failure modes named.
Why

Interviewers score whether time is treated as a monitored dependency with evidence obligations, not as a daemon somebody installed.

The common mistake

Treating time as a daemon someone installed. A strong answer names the failure mode — silent drift producing confidently wrong sequencing — and the alert that catches it before downstream data is affected.

4 Find what's broken

This is the provisioning script for the interface that carries your latency-critical feed. Which three lines are working against you?

# provisioning for the latency interface eth2
ethtool -C eth2 rx-usecs 200 rx-frames 64
ethtool -K eth2 gro on lro on
ethtool -G eth2 rx 256
ethtool -L eth2 combined 32
sysctl -w net.core.busy_poll=0
sysctl -w net.core.rmem_max=212992
In short

The bad lines are the 200 µs coalescing, GRO and LRO switched on, and rmem_max left at its small default.

What's broken
  • Line 2: Coalescing at 200 µs / 64 frames holds packets to amortise interrupts, adding up to 200 µs to a single message.
  • Line 3: GRO and LRO batch packets, which raises throughput and destroys per-packet timing fidelity.
  • Line 7: rmem_max left at the 208 KB default is too small for a bursty multicast feed and will drop under load.
Why

A 256-entry ring (line 4) is small but defensible with fast draining; 32 combined queues (line 5) is a steering question rather than a fault; busy_poll=0 (line 6) leaves the default, which you would change alongside the coalescing decision. The three flagged lines each add latency or drop packets outright.

Read the docs

5 Read the output

This host is supposed to be sub-microsecond. What is wrong, and what do you check first?

$ pmc -u -b 0 'GET TIME_STATUS_NP'
    master_offset              4128
    ingress_time               1757000000123456789
    gmPresent                  true
$ journalctl -u ptp4l --since -10min | tail -3
ptp4l[91.2]: master offset       3980 s2 freq  +12988 path delay      1284
ptp4l[92.2]: master offset       4210 s2 freq  +13102 path delay      6721
ptp4l[93.2]: master offset       4128 s2 freq  +13044 path delay     12980
$ ethtool -T eth2 | head -3
Time stamping parameters for eth2:
Capabilities:
    hardware-transmit
  1. gmPresent true means the grandmaster is unreachable. It means a grandmaster is present.
  2. The clock is fine — s2 means fully locked and offsets in nanoseconds are irrelevant. s2 is the servo state, not a quality guarantee; a 4 µs offset with unstable delay is not sub-microsecond sync.
  3. Offset is stuck in the thousands of nanoseconds and path delay is swinging from 1.3 µs to 13 µs, which is queueing in the network rather than distance — check the switch path for PTP awareness (boundary/transparent clock) and for congestion on the sync path. Wildly varying path delay is the signature of a switch that forwards PTP as ordinary traffic under load.
  4. PTP is not supported because ethtool shows only hardware-transmit. head -3 cut the list after its first entry, so this output proves nothing about receive support; the immediate finding is the delay variance.
In short

The path delay jumps from 1.3 µs to 13 µs, so switches are queueing the PTP messages; check the switch path first.

Why

Stable path delay is the assumption PTP's correction rests on. When it swings by an order of magnitude, the switches are queueing sync messages behind data traffic, and no amount of servo tuning fixes that — the fix is PTP-aware switching or a dedicated timing path.

Read the docs

6 Quick recall

Before you promise hardware timestamps on an interface, what do you run to check the NIC can actually do it?

In short

The flag is -T, as in ethtool -T eth0.

Accepted

-T · ethtool -T · --show-time-stamping

Why

ethtool -T <if> lists supported transmit/receive timestamping modes and the PTP hardware clock index.

Next lesson Exchange connectivity: sessions, sequence numbers, reconnects, and failover that does not double-fire
Drill · NIC path and time
0:00

Loading…