Networking Detailed Course#

Table of Contents#

  1. 1. Autonomous Systems & BGP Routing
  2. 2. TCP Congestion Control: CUBIC & BBR
  3. 3. Flow Control & Sliding Window Scaling
  4. 4. Linux Socket Lifecycle & Ring Buffers
  5. 5. Zero-Copy I/O: sendfile & splice
  6. 6. QUIC Protocol Architecture & Multiplexing
  7. 7. Anycast Routing & Edge CDNs
  8. 8. DDoS Mitigation & SYN Cookies
  9. 9. High-Throughput Linux sysctl Tuning
  10. 10. Top Networking Engineering Questions

1. Autonomous Systems & BGP Routing#

The global Internet is not a single mesh; it is a network of networks called Autonomous Systems (ASes) operated by ISPs, cloud giants (AWS, Google, Cloudflare), and telecommunications providers, each identified by an Autonomous System Number (ASN).

2. TCP Congestion Control: CUBIC & BBR#

While Flow Control prevents a fast sender from overwhelming a slow receiver, Congestion Control prevents senders from overwhelming the shared intermediate routers on the network:

  1. Loss-Based (TCP Reno / CUBIC): Assumes packet loss indicates network congestion. Sends data exponentially (Slow Start), then linearly (Congestion Avoidance). When a packet drops, CUBIC slashes the Congestion Window (cwnd) by a multiplicative factor and uses a cubic growth curve. Weakness: Suffers from Bufferbloat on modern high-speed links with massive router queues.
  2. Model-Based (Google BBR - Bottleneck Bandwidth and RTT): Rather than waiting for packet drops, BBR measures the maximum delivery rate (bandwidth) and minimum round-trip time (RTprop). It paces packet transmission exactly at the pipe's capacity, eliminating queue build-up and latency spikes.

3. Flow Control & Sliding Window Scaling#

TCP Flow Control coordinates delivery speeds using the Receive Window (rwnd):

4. Linux Socket Lifecycle & Ring Buffers#

Tracing data from a physical Ethernet wire into an application process:

  1. NIC & DMA: Network Interface Card receives optical/electrical pulses, reconstructs the Ethernet frame, and writes it directly into host RAM ring buffers via Direct Memory Access (DMA).
  2. Hard IRQ & SoftIRQ (NAPI): The NIC raises a hardware interrupt to the CPU. The kernel schedules a software interrupt (NAPI softirq) to poll the ring buffer in batches, avoiding interrupt storms.
  3. TCP Stack: Kernel strips the Ethernet header, validates IP checksum, decodes TCP sequence numbers, reassembles packets, and deposits data into the socket's receive queue.
  4. Application Read: Process calls read() or recv(), copying data from kernel space into the user application buffer.

5. Zero-Copy I/O: sendfile & splice#

Traditional file serving requires 4 context switches and 4 data copies (Disk → Kernel → User space → Kernel → NIC). Linux sendfile() achieves Zero-Copy:

// Traditional approach: 4 copies, 4 context switches
read(file_fd, buffer, len);
write(socket_fd, buffer, len);

// Zero-Copy approach: 2 context switches, 0 user-space copies
sendfile(socket_fd, file_fd, NULL, len);
// The kernel streams data directly from page cache to the NIC DMA buffer!

6. QUIC Protocol Architecture & Multiplexing#

QUIC (RFC 9000) reinvents transport layer semantics by embedding reliable multiplexing directly on top of UDP:

7. Anycast Routing & Edge CDNs#

Traditional hosting uses Unicast (one IP address belongs to exactly one physical server). Modern networks (Cloudflare, Google, AWS CloudFront) use BGP Anycast:

8. DDoS Mitigation & SYN Cookies#

In a SYN Flood Attack, an attacker sends millions of spoofed TCP SYN packets without ever sending the final ACK, overflowing the kernel's connection backlog and freezing the server.

SYN Cookies (Linux solution): When the backlog queue fills, the kernel stops allocating memory for incoming connections. Instead, it encodes the client's IP, port, and a cryptographic timestamp into the initial 32-bit sequence number (Y). When the client responds with ACK (containing Y + 1), the server validates the signature and establishes the socket without ever having held state.

9. High-Throughput Linux sysctl Tuning#

# /etc/sysctl.d/99-networking.conf
# Increase maximum listen queue backlog for high-concurrency servers
net.core.somaxconn = 65535
net.ipv4.tcp_max_syn_backlog = 65535

# Enable BBR congestion control
net.core.default_qdisc = fq
net.ipv4.tcp_congestion_control = bbr

# Expand TCP socket buffer sizes for 10GbE+ links
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216

# Accelerate socket recycling
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 15

10. Top Networking Engineering Questions#

High-Frequency Systems Questions

  1. What happens when you type https://example.com into a browser? DNS resolution (cache → recursive → authoritative) → TCP 3-way handshake → TLS 1.3 ECDHE key negotiation → HTTP GET request → Server process → Response stream → Browser DOM rendering.
  2. Why does HTTP/3 run on UDP instead of TCP? To eliminate transport-layer head-of-line blocking caused by TCP's strict in-order packet byte delivery, enable instant 0-RTT handshakes, and support connection migration across networks.
  3. What is MTU and Path MTU Discovery? The maximum packet size supported without fragmentation (usually 1500 bytes). PMTUD sends packets with the DF (Don't Fragment) bit set; if a packet is too large, the intermediate router drops it and replies with ICMP "Fragmentation Needed" specifying its MTU.

Next Steps: Review quick mental models in the Networking Crash Course, or explore OS kernel internals in the OS Detailed Course. Return to the TechToday Homepage.