Networking & Protocols
Modulation and Shannon
Your laptop says “1 Gbps” and your phone says “Wi-Fi 6, 9.6 Gbps theoretical.” Neither number comes out of thin air — it’s a direct consequence of a formula Claude Shannon wrote in 1948. Every engineering decision about link speed traces back to that same equation.
Three modulation regimes
Virtually all the world’s bits travel over one of three media, each with its own encoding:
Differential voltage on copper (Ethernet, DSL, USB). Two wires carry mirrored signals; the receiver measures the difference to cancel common-mode noise. Gigabit Ethernet uses PAM-5 (Pulse Amplitude Modulation, 5 levels) at 125 MBaud per pair across all four pairs simultaneously. Five voltage levels encode 2.32 bits per symbol; the actual coding is cleverly mapped to carry ~1 Gbps after framing overhead.
Photons through glass (single-mode and multi-mode fibre). A laser switches on and off (or shifts phase/amplitude for coherent modulation) at billions of Hz. Single-mode fibre has a 9 µm core — light propagates without bouncing, enabling tens to thousands of kilometres. Multi-mode fibre (50/62.5 µm core) is cheaper but limited to ~500 m at 1 Gbps. Submarine cables are single-mode with erbium-doped fibre amplifiers (EDFAs) every ~80 km, regenerating the optical signal without converting to electrical.
Modulated radio (Wi-Fi 6, 5G, satellite). A carrier frequency in the GHz range is encoded with OFDM (Orthogonal Frequency Division Multiplexing): the spectrum is sliced into hundreds of narrow orthogonal subcarriers, each carrying a QAM constellation. 1024-QAM packs 10 bits per symbol; Wi-Fi 7 pushes 4096-QAM for 12 bits per symbol. When a client is far from the AP and SNR drops, the system falls back to lower QAM (256-QAM → QPSK) to maintain reliability.
Shannon’s theorem
Claude Shannon proved in 1948 that the maximum error-free bit rate over any channel is:
C = B · log₂(1 + S/N)
where B is bandwidth in Hz and S/N is the signal-to-noise ratio (linear, not dB). Two implications:
- Doubling bandwidth doubles capacity — linear relationship. This is why 5G millimetre-wave (80 GHz channels) is so fast: the B term is enormous.
- Doubling SNR adds only ~1 bit per symbol — logarithmic. Chasing ever-higher modulation gives diminishing returns. Going from 1024-QAM to 4096-QAM requires a pristine RF environment but yields only 2 extra bits per symbol.
- PAM-5 (1G Ethernet)
- 5 levels, 125 MBaud/pair
- 1024-QAM (Wi-Fi 6)
- 10 bits/symbol, needs ~35 dB SNR
- 4096-QAM (Wi-Fi 7)
- 12 bits/symbol, needs ~45 dB SNR
- Shannon limit (40 dB SNR, 20 MHz)
- ~266 Mbps theoretical max
- Coherent 400G optics
- 256-QAM PAM-4 + FEC
- EDFA spacing (submarine)
- ~80 km optical amplifiers
Ethernet framing
At the link layer, every Ethernet frame carries:
- 14-byte header: destination MAC (6 B) + source MAC (6 B) + EtherType (2 B).
- Payload: 46–1500 bytes (MTU 1500) or up to 9000 bytes for jumbo frames.
- 4-byte FCS: CRC-32 frame check sequence. A bad FCS means the frame is dropped at the NIC.
Switches learn MAC-to-port mappings by watching source MACs on incoming frames. When the destination MAC isn’t yet in the table, the switch floods the frame to all ports on the VLAN. ARP resolves IP addresses to MACs within the same L2 segment (covered later in the networking track).
Wi-Fi essentials
Real-world Wi-Fi throughput is always lower than the theoretical “marketing” peak:
- 802.11ax (Wi-Fi 6): theoretical 9.6 Gbps; typical single-user 300–800 Mbps at 5 m on 5 GHz.
- 802.11be (Wi-Fi 7): 4096-QAM, channels up to 320 MHz, Multi-Link Operation (MLO) — simultaneous streams on 2.4/5/6 GHz. Practical 1–3 Gbps per client in clean RF.
- Wi-Fi is a shared medium: all clients on one AP contend for the same channel. A slow client using BPSK (because it’s far away) holds the channel longer per frame, starving faster clients.
- 2.4 GHz: only 3 non-overlapping channels (1, 6, 11 in 20 MHz mode). Dense apartment buildings are saturated.
- 6 GHz (Wi-Fi 6E/7): 60+ non-overlapping channels, no legacy interference, shorter range.
Cellular modulation
4G LTE and 5G NR both use OFDM on the air interface. Key numbers:
- 4G LTE: 30–60 ms RTT, 10–100 Mbps typical. Latency dominated by scheduling, not propagation.
- 5G sub-6 GHz: 15–30 ms RTT, 100 Mbps–1 Gbps.
- 5G mmWave: sub-10 ms RTT, multi-Gbps — but only to ~200 m, blocked by walls and rain.
- 5G URLLC (Ultra-Reliable Low-Latency Communication): sub-1 ms air-interface latency target for industrial robotics — achieved by mini-slots and dedicated scheduling, not physics.
Bandwidth-delay product
BDP = bandwidth × RTT. On a 10 Gbps link with 100 ms RTT:
BDP = 10 × 10⁹ × 0.1 / 8 = 125 MB
This is the maximum number of bytes “in flight” at saturation. If TCP’s receive window is smaller, the sender stalls waiting for ACKs and the link goes underutilised. Modern Linux auto-tunes receive buffers; BBR congestion control models BDP explicitly to pace sends.
Shannon's theorem says capacity grows linearly with bandwidth but logarithmically with SNR. What does this mean for engineering?
Order the encoding steps from data byte to transmitted signal:
- 1 Byte arrives at network card from OS
- 2 Card adds Ethernet framing (header + FCS)
- 3 Line coding is applied (PAM-5 for 1G copper, NRZ for many fibre links)
- 4 FEC adds redundancy bits to allow error correction
- 5 Modulator converts coded symbols to physical signal (voltage / light / radio)
- 6 Signal travels through the medium
- 7 Receiver reverses every step to recover original bytes
Shannon capacity worked example
1/3lesson.inset.pitfall
The slow-client Wi-Fi problem. One weak client using BPSK (1 bit/symbol) holds the radio channel much longer per frame than a nearby client using 1024-QAM (10 bits/symbol). Even though MU-MIMO helps, the slow client still degrades everyone else. Fixes: move the AP closer (raise SNR → higher QAM), enable band steering (push the weak client to 2.4 GHz), or add a second AP for better coverage. In enterprise environments, minimum RSSI policies kick out clients below a signal threshold rather than letting them drag down the cell.
- 01Why does 5G millimetre-wave achieve multi-Gbps speeds despite similar or lower SNR than sub-6 GHz?
- 02What is PAM-5 and why does Gigabit Ethernet use it?
- 03What is the bandwidth-delay product and when does it become a performance bottleneck?
Three media carry the world’s bits: copper (differential voltage, PAM-5), glass fibre (laser pulses, coherent modulation, EDFA amplifiers), and radio (OFDM with QAM constellations). Shannon’s theorem C = B·log₂(1+S/N) sets the maximum bit rate for any channel — linear in bandwidth, logarithmic in SNR. Ethernet frames carry 14-byte headers + 4-byte FCS; the maximum payload is 1500 bytes (standard) or 9000 bytes (jumbo). Wi-Fi is a shared medium where slow clients using low QAM hurt everyone. The bandwidth-delay product (BDP = bandwidth × RTT) determines how many bytes TCP must keep in flight to saturate a link — the reason window scaling and BBR matter on high-latency paths.