Encoding is a method of converting a stream of data bits into a predefined code. Codes are groupings of bits used to provide a predictable pattern that can be recognized by both the sender and the receiver. Using predictable patterns helps to distinguish data bits from control bits and provide better media error detection.

Encoding methods at the physical layer may also provide codes for control purposes such as identifying the beginning and end of a frame. The transmitting host will transmit the specific pattern of bits or a code to identify the beginning and end of the frame.

To illustrate this concept, consider the Morse code system developed over 100 years ago. Each character (letter or numeral) is represented by a unique sequence of dots and dashes. The duration of a dash is three times the duration of a dot. For efficiency, the most common letters in the English language have the shortest codes assigned to them. For example, the letter "E," is a single dot. Consider the international code for the distress call, SOS. The letter “S” is three dots and the code for the letter “O” is three dashes. The video is an example of a telegraph operator sending the SOS distress call.

A telegraph operator would encode messages into Morse code and then transmit these codes to another telegraph operator who would then decode the message to reveal the message. Telegraph operators would follow each dot or dash by a short silence, equal to the dot duration and letters of a word are separated by a space equal to three dots (one dash).

Modern encoding techniques perform the same process except that the telegraph operators are now computerized and capable of encoding and decoding messages at lightning speed. Frame encoding methods are far more complex than Morse code but all essentially perform the same purpose.

For example, network encoding methods include:

Note: Faster data rates require more complex encoding, such as 4B/5B, however, explanation of these methods is beyond the scope of this chapter.