Before any strategy, model, or trade exists, packets must travel from an exchange to your CPU.
Most beginners think networking is just:
“Send data over TCP/UDP.”
In reality, networking is often the single largest latency component in an HFT system.
1. The Fundamental Goal of HFT Networking
The goal is not bandwidth. The goal is time-to-first-byte.
HFT networking optimizes for:
- Lowest possible latency
- Minimal jitter
- Predictable packet arrival
A single microsecond advantage can decide profitability.
2. How a Packet Actually Reaches Your Program
When a packet arrives from the exchange, it does not go directly to your application.
Typical path:
- Network Interface Card (NIC)
- Hardware interrupt
- Kernel interrupt handler
- Kernel network stack
- Socket buffer
- System call (
recv) - User-space application
Each step adds:
- Latency
- Cache pollution
- Context switching risk
HFT engineers obsess over every arrow in this chain.
3. Why the Kernel Network Stack Is Expensive
The Linux networking stack is designed for:
- Generality
- Safety
- Fairness
It supports:
- Many protocols
- Many users
- Many devices
But this flexibility costs:
- Multiple memory copies
- Locks
- Branch-heavy code paths
For HFT, this is unacceptable overhead.
4. Interrupts vs Polling (Why Sleeping Is Bad)
Default networking uses interrupts:
- NIC interrupts CPU when data arrives
Problem:
- Interrupts pause your code
- Add jitter
- Trash caches
HFT systems often use polling:
- CPU continuously checks NIC buffers
- No interrupts
This trades:
- Higher CPU usage for:
- Stable latency
- Immediate reaction
Again, predictability beats efficiency.
5. TCP vs UDP: Why UDP Is Preferred
TCP provides:
- Reliability
- Ordering
- Congestion control
But TCP also adds:
- State machines
- Retransmission logic
- Kernel involvement
Most market data feeds use UDP because:
- Data is time-sensitive
- Old packets are useless
- Application handles loss
HFT systems prefer to control behavior explicitly.
6. Kernel Bypass: Skipping the Middleman
Kernel bypass means:
Applications access the NIC directly from user space.
Technologies include:
- DPDK
- Solarflare Onload
- RDMA
Benefits:
- Zero-copy packet access
- No system calls
- No kernel scheduling interference
This can reduce latency by multiple microseconds.
7. Zero-Copy and Memory Layout
Copying data costs time.
Traditional networking:
- NIC → kernel buffer → user buffer
HFT networking:
- NIC DMA directly into user memory
This requires:
- Careful buffer management
- Fixed memory pools
- Cache-aligned structures
Memory layout becomes part of networking design.
8. NICs Are Programmable Computers
Modern NICs:
- Have multiple queues
- Support RSS (Receive Side Scaling)
- Can timestamp packets in hardware
HFT systems:
- Map specific queues to specific cores
- Disable unnecessary offloads
- Use hardware timestamps for accuracy
The NIC is no longer “just hardware” — it’s part of your system.
9. Multicast and Market Data
Market data is often delivered via multicast:
- One sender
- Many receivers
Benefits:
- Low latency
- Efficient distribution
Challenges:
- Packet loss
- No retransmission
HFT systems:
- Detect gaps
- Recover from backup feeds
- Handle bursty traffic
Networking logic and business logic are intertwined.
10. Network Jitter Is the Real Enemy
Average latency matters less than tail latency.
Sources of jitter:
- Interrupt storms
- Cache misses
- Kernel locks
- NUMA misalignment
HFT networking aims to flatten the latency distribution.
A slower but stable system can beat a faster but noisy one.
11. Beginner Mental Model
Think of networking as:
A conveyor belt delivering information to your CPU
Every extra handoff slows it down.
The fewer layers involved, the faster and more predictable the delivery.
12. What Comes Next?
Now that packets arrive fast, we must process them in parallel without chaos.
- Why locks kill latency
- Memory ordering basics
- Single-writer, multi-reader designs
➡ Article 5: Concurrency & Lock-Free Programming for HFT
