Lesser-Known Networking Theories (2)
In the previous post, we mentioned that while Manchester encoding effectively addresses data streams with long runs of consecutive 0s or 1s, it requires twice the bandwidth for the same amount of data—something we want to avoid in high-speed transmission.
Today, we will introduce 4B/5B encoding, which effectively prevents long runs of 0s and 1s in data streams without sacrificing too much bandwidth.
4B/5B
4B/5B takes raw data in 4-bit blocks and maps them into 5-bit blocks. This way, bit streams such as 0000 and 1111 are encoded so they do not consist entirely of 0s or 1s, preventing the issue of being unable to recover the clock signal.
| 4bit | 5bit |
|---|---|
| 0000 | 11110 |
| 0001 | 01001 |
| 0010 | 10100 |
| 0011 | 10101 |
| 0100 | 01010 |
| 0101 | 01011 |
| 0110 | 01110 |
| 0111 | 01111 |
| 1000 | 10010 |
| 1001 | 10011 |
| 1010 | 10110 |
| 1011 | 10111 |
| 1100 | 11010 |
| 1101 | 11011 |
| 1110 | 11100 |
| 1111 | 11101 |
If we look at 0000 and 1111, we can see that after being converted to 5 bits, there is guaranteed to be at least one transition (from high to low voltage or vice versa). Although adding an extra bit requires 20% more bandwidth for the same throughput, it is still a massive improvement compared to Manchester encoding. 1000BASE-X uses 8B/10B encoding, which is conceptually identical to 4B/5B except that it encodes 8 bits at a time. In addition to 1000BASE-X, 8B/10B is also widely used across various high-speed transmission protocols, such as PCIe 1.0/2.0 and USB 3.0.
8B1Q4
For those of us living in 2023, wired network speeds routinely hit 1 Gbps, or even 10 Gbps when higher bandwidth is demanded.
Common Ethernet cables consist of insulated wire pairs twisted together. This twisting design effectively reduces noise. Nonetheless, at very high frequencies, signals are still susceptible to noise interference.

In transmissions such as 100BASE-TX and beyond, 8B1Q4 encoding (8 binary to 1 quinary across 4 pairs) is used. The core principle is sending multiple bits within a single clock cycle to increase data throughput. For instance, although CAT-6 operates at a transmission frequency of 125 MHz, its transmission rate reaches 1 Gbps.
Simply put, 8B1Q4 divides 8 bits + 1 check bit across four pairs. As shown in the image above, there are four wire pairs in total; after dividing the data, each pair represents its data using different voltage levels.
But how is the 9-bit data actually split into four groups? First, it uses 3 bits (the check bit + the first two data bits) to look up a corresponding transformation table. The remaining 6 bits are then encoded according to that table. What is particularly unique is that each wire pair uses 5 distinct voltage levels, rather than just binary high and low voltages. Through this approach, 2 bits can be transmitted per clock cycle across each pair, effectively doubling throughput within the same bandwidth.
This is precisely why CAT-6 achieves a transmission rate of 1 Gbps even though its transmission frequency is only 125 MHz.
Related Posts
- When a Measure Becomes a Target: From the Window Tax to Pull Request Counts I once wrote a script to tally how many PRs I contributed in a quarter, how many reviews I left, and how many tickets I closed, hoping to use numbers to prove my output to my manager. My manager simply remarked that performance isn't just about output. Years later, I finally understood—when a measure becomes a target, it ceases to be a good measure. From the British window tax and the Hanoi rat bounty to evaluating developers by PR counts today, the underlying mechanism is exactly the same.
- Using Cloudflare Images for Image Storage and Transformation Putting an image on a webpage is the simplest task in frontend development. But doing it properly—including resizing, generating multiple formats, and withstanding heavy traffic—is actually an entire end-to-end solution. Eventually, I offloaded everything to Cloudflare Images, keeping only a single original image.
- Stop Using AWS Access Keys Access Keys are an easily overlooked security risk in AWS. By pairing OIDC with IAM Roles, GitHub Actions can securely operate AWS resources without storing any secrets.
- Database Primary Keys: AUTO_INCREMENT, UUID, and UUIDv7 Backend developers often face the choice of primary keys: should you use auto-increment or UUID? What about collisions? How does UUIDv7 compare to created_at + index in performance? Here are the design decisions and benchmark results from testing 20 million rows.