Line Coding Techniques in Computer Networks, Explained
In this article
Line coding is the way binary 1s and 0s are turned into an electrical, optical or radio signal that can travel down a wire or fibre. The main techniques are unipolar, polar (NRZ, RZ, Manchester), bipolar (AMI), and multi-level schemes like 2B1Q, each trading bandwidth against clock recovery and DC balance.
Time 10 min · Steps 8 · Level Medium
Line coding converts bits into a physical waveform, and the choice of scheme decides how much bandwidth the link needs, whether the receiver can keep its clock in sync, and how errors are detected. The detail most people get wrong: line coding is not the same as modulation. Line coding shapes the signal on a baseband channel (the wire itself carries the data); modulation shifts data onto a carrier wave for radio or passband channels. In exams and textbooks, the two are separate topics, and mixing them up costs easy marks.
Know the Eight Line Coding Schemes You Will Actually Meet
- Unipolar NRZ. Binary 1 is a positive voltage, 0 is zero volts. Simple, but it has a large DC component and no self-clocking, so long runs of 1s drift.
- Polar NRZ-L (level). 1 is +V, 0 is −V. Half the DC problem of unipolar, but a long run of identical bits still gives no transitions.
- Polar NRZ-I (invert). 1 is a transition at the bit start, 0 is no transition. Better under polarity flips, still weak on long runs of 0s.
- Polar RZ (return to zero). Each bit returns to zero mid-bit, giving a transition every bit, but needs twice the bandwidth of NRZ.
- Manchester. A transition at the middle of every bit: low-to-high means 1, high-to-low means 0 (or the reverse, by convention). Self-clocking and DC-free, at twice NRZ bandwidth; used in classic Ethernet 10BASE-T and in RFID tags.
- Differential Manchester. A mid-bit transition always exists; an extra transition at the start means 0, no extra transition means 1. Used in token ring networks.
- Bipolar AMI (alternate mark inversion). 1s alternate between +V and −V, 0s are zero volts. DC-balanced and a deliberate coding violation lets you spot errors; long runs of 0s remain the weak point.
- Multi-level and block codes. 2B1Q maps two bits to one of four voltage levels (used on ISDN basic-rate lines), 8B6T and 4B/5B pack bits to guarantee transitions while keeping bandwidth close to NRZ.
Compare the Schemes on Bandwidth, Clocking and DC
Three properties decide which scheme a link uses. First, self-clocking: if the signal guarantees transitions, the receiver can recover the bit timing from the data itself, which is why Manchester beats NRZ on noisy links. Second, DC balance: a signal whose average voltage is not zero distorts through transformers and capacitors on real lines; AMI and Manchester solve this, unipolar does not. Third, bandwidth: RZ and Manchester need roughly twice the bandwidth of NRZ for the same bit rate, because their fastest component is at twice the bit frequency. NRZ is the most bandwidth-efficient but the least robust; Manchester is the opposite trade.
Scrambling codes such as B8ZS and HDB3 fix AMI's long-run-of-zeros problem by substituting a pattern of deliberate violations whenever eight or four consecutive 0s appear. The receiver recognises the substitution because it breaks the AMI rule on purpose, restores the zeros, and the link keeps its transitions without extra bandwidth.
Work Through the Bandwidth Arithmetic
Exam questions usually ask for the minimum bandwidth or the bit rate a scheme supports. A useful case: a 1 Mbps link. With NRZ, the worst-case signal alternates every bit, so the fundamental frequency is half the bit rate, about 500 kHz. With Manchester or RZ, the mid-bit transition doubles that to about 1 MHz. Working the other way, a channel that passes 200 kHz can carry about 400 kbps in NRZ but only about 200 kbps in Manchester. Check any answer by asking: how many full cycles does one bit occupy? One full cycle per bit means bandwidth near the bit rate; half a cycle per bit means bandwidth near half the bit rate.
Match Each Scheme to Where It Is Used
Classic Ethernet (10BASE-T) chose Manchester for its reliable clock recovery, accepting the extra bandwidth, because at 10 Mbps the twisted pair had room to spare. Fast Ethernet moved to 4B/5B with MLT-3 encoding to fit 100 Mbps through the same cables. ISDN basic rate uses 2B1Q on the copper local loop. AMI with B8ZS appears on North American T-carrier lines, and HDB3 on European E-carrier lines. Fibre links and modern high-speed copper use block codes plus scrambling rather than any single classic scheme, so the textbook techniques matter most as the reasoning behind today's designs.
Line Coding Questions That Come Up in Exams
How do you draw the waveform for a given bit pattern?
Write the bits along a timeline, one bit per interval, then apply the rule of the scheme strictly: NRZ-L holds the level for the whole bit; RZ drops to zero at the midpoint; Manchester flips at the midpoint with the direction set by the bit; AMI alternates polarity only on 1s. Marks are usually lost by forgetting the mid-bit transition, not by the polarity.
Why does Manchester encoding need more bandwidth?
Because every bit contains at least one full transition, the highest fundamental frequency in the signal is equal to the bit rate, whereas NRZ's worst case is half the bit rate. That doubling is the price of guaranteed clock recovery.
What is a coding violation and why is it useful?
A violation is a pattern that breaks the scheme's own rule, like two consecutive same-polarity 1s in AMI. B8ZS and HDB3 use violations deliberately so the receiver can find substituted zero runs; accidental violations signal line errors.
Which scheme has the best DC balance?
Manchester and AMI (with scrambling to break up zero runs) both average near zero volts. Unipolar is the worst, since its average sits at half the positive voltage whenever 1s are frequent.