Sunday, March 1, 2020

Line Encoding for Communications Networks

There are several common line encoding protocols and understanding the advantages and disadvantages of each is important.  I came up with a table that compares each protocol, but first lets discuss a few and the features of each.

The first and simplest protocol is NRZ (non-return to zero) format. You can imagine a bit string you want to transmit, and a clock signal.  On each clock rising edge (for example) a bit would be shifted out onto the communications line (figure 1).   If we calculate the required bandwidth of the communications line, it would be half the bit rate.  The highest bandwidth required would be when alternate 1's and 0's were transmitted.  There are two disadvantages to this simple protocol.  The first is that this is an asynchronous protocol.  The receiver would need to have a very tight tolerance on its clock.  In fact, for very long runs of 0's (or long runs of 1's), no edges in the bit stream would be present.   The old RS-232 protocol used NRZ format.  It modified this format a tad to guaranteed a clock edge every 10 bits by providing for a start and stop bit that creates an edge for the receiver clock to sync to.  This also marked the beginning of each byte.
Figure 1 - NRZ and AMI line encoding

The NRZ format is not DC balanced.  A DC balanced protocol is important when we want to AC couple the pieces of equipment in the communications network.  Engineers found it was important to AC couple the equipment because although the different nodes all had a common ground, they found that ground was not at the same potential everywhere!  Thus ground loops and shifted ground potentials were created that caused havoc with the receivers and transmitters.   The expensive solution used by many RS-232 interfaces was to optical isolate the transmitter/receivers.  This was expense and limited the maximum transmission rate of the link.   A simpler solution is to AC couple the communications line using a transformer or capacitor.  Ethernet uses small transformers in the NIC cards (figure 2).  The benefit of AC coupling is that it blocks any DC level difference between the nodes.  The problem with AC coupling is that it blocks any DC level in the signal as well.
Figure 2 - Typical 10/100 Mbps Twisted-Pair Interface
A line encoding protocol that is DC balanced, that is it does not have a DC component, is AMI (figure 1).  In the AMI line encoding protocol a zero can be transmitted as a zero on the line.  On the other hand, the 1 bit is transmitted as alternate positive and negative voltages.  For every positive voltage bit that is transmitted, a negative bit is transmitted.  Therefore the average voltage on the line is zero and there is no average DC voltage.  The AMI line encoding is still an asynchronous protocol and does not solve the clocking issue.  Long runs of 0's (but NOT long runs of 1's) can cause the receiver to lose sync with transmitter.  What is needed is a protocol that provides more edges.

Manchester encoding solves the clocking issue by XOR'ing the clock signal with the data signal.  When this occurs a clock edge is guaranteed on each bit.  Unfortunately it also double the required bandwidth and it is not DC balanced.

The encoding used by Ethernet is 8B/10B.  In this encoding scheme for every 8 bits in the payload, 10 bits are actually transmitted on the line.  There is a table that maps the 8 input bits to the 10 output bits.  The output values are chosen to provide DC balance.  It does not provide a clock transition on each bit, but it does guarantee a clock transition on at least every 5th bit.  This is enough transitions for modern phase lock loop circuits to keep the receivers clock synced to the transmitter for very high data rates.  Finally, the required bandwidth is somewhere between NRZ and Manchester encoding.

Figure 3 presents a table I created that summarizes these line encoding formats and a few others that will be explored in subsequent lab notes.

Baseband Line Encoding Schemes and features
Line Encoding Scheme
Clock Recovery
Bandwidth*
DC Balanced
Notes
NRZ
No
0.5B
No

NRZ with a clock signal
Yes
B
No
Requires extra wire for the clock signal
Manchester
Yes
B
No
Provides clock edge for every bit
AMI
No
0.5B
Yes

4B/5B
Enough
0.625B
No
Provides at least 1 clock edge every 5 bits
8B/10B
Enough
0.625B
Yes
Used by Ethernet.  Not sufficiently referenced in our book (see pg. 129).  Reference Wikipedia.
Scrambling
Enough
0.5B
?
Prone to “killer packets” and malicious tampering
*where B is the bitrate.
Figure 3 - Comparison of Line encoding scheme features