Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 7

Data Encoding in Physical Media

Recommended resources

Hello! Welcome to your next lesson on the physical underpinnings of the internet.

In our last session, we identified the three main physical media for data transmission: copper cables, fiber-optic cables, and wireless waves. You now know what materials data travels through.

Today, we move from the "what" to the "how." This lesson addresses the learning outcome: Explain how data is encoded as electrical or light signals on physical media. We'll explore the ingenious methods used to convert the abstract ones and zeros from your computer's memory into tangible physical signals that can race across a wire or a beam of light.

This is where the logic of software meets the physics of the real world—a fundamental concept that bridges your computer science knowledge with the workings of physical hardware.

Let's begin by looking at what these signals actually look like.

Visualizing Electrical Signals in an Ethernet Cable
This image shows an oscilloscope connected to the wires inside an Ethernet cable. The screen of the oscilloscope displays a waveform, which is a visual representation of the changing electrical voltage—the "signal"—carrying data down the wire.

Encoding Data on Copper Wires: From Bits to Volts

The most intuitive way to send binary data over a copper wire is to associate the two binary states, 1 and 0, with two different voltage levels. For example, we could agree that +5 volts represents a 1 and 0 volts represents a 0. By changing the voltage over time, a sender can transmit a sequence of bits to a receiver.

To understand this foundational concept in action, let's watch a video that builds this idea from first principles.

Sending digital information over a wire | Networking tutorial (1 of 13)

The video 'Sending digital information over a wire' by Ben Eater is an excellent, clear explanation of the core principles of data encoding. It shows how varying voltage can represent binary, and how that binary can, in turn, represent information like text.

Watch the video from 0:42 to 04:13. As you watch, focus on these key ideas: How different voltage levels are used as symbols to represent 1 and 0. The concept of a baud rate (or symbol rate) as the speed of transmission. How a sequence of these bits can be interpreted as a number, which can then be mapped to a character using a standard like ASCII.

As the video demonstrated, the core of electrical encoding is a pre-arranged agreement:

  • A mapping: Which voltage level corresponds to which bit.
  • A clock rate: A shared sense of timing so the receiver knows precisely when to measure the voltage on the wire to read each bit.

This simple method is known as a line code or encoding scheme.


A Deeper Look: The Problem with Simple Encoding

The simple "high-voltage-for-1, low-voltage-for-0" scheme is great for understanding the concept, but it runs into problems in the real world. Consider these challenges:

  1. Clock Synchronization: What if the sender transmits a long string of identical bits, like 1111111111111111? The voltage on the line would stay high for a long time. If the sender's and receiver's clocks are even slightly out of sync, the receiver might miscount how many 1s were sent. There are no voltage changes (transitions) to help the receiver re-synchronize its clock.
  2. Baseline Wander: A long string of 0s or 1s can cause the average voltage on the line to drift, making it hard for the receiver to distinguish between high and low levels accurately.

To solve these and other issues, real-world networking standards like Ethernet use more sophisticated encoding schemes. A classic example is 8b/10b encoding. The idea is to take 8-bit chunks of data (bytes) and map them to specially constructed 10-bit symbols before sending them. These 10-bit symbols are designed to guarantee that there are never too many consecutive 1s or 0s, ensuring frequent transitions for clock synchronization.

To see how this works in a real-world scenario, we'll look at a small part of a fascinating blog post by an engineer who debugged a network switch by analyzing the raw electrical signals.

From Oscilloscope to Wireshark: A UDP Story

The article 'From Oscilloscope to Wireshark' is a deep dive, but we'll focus on just one section that explains 8b/10b encoding. This will give you a concrete example of a more robust, real-world encoding scheme.

Read the section titled '8b/10b decoding'. You can ignore the code snippets. Focus on understanding: Why 8b/10b encoding is used (the desirable properties it creates). The concept of 'code-groups' or 'symbols'. The role of 'comma characters' in helping the receiver find the beginning and end of each 10-bit symbol.

The key takeaway here is that real-world encoding is a clever trade-off: we use extra bits (10 bits to send 8 bits of data) to buy us reliability in the physical transmission.


Encoding Data on Fiber-Optic Cables: From Bits to Light

Now let's switch from electricity in copper to light in fiber-optic cables. The underlying principle is remarkably similar, but the physical medium is different. Instead of changing voltage, we turn a light source on and off.

  • Light ON can represent a 1.
  • Light OFF can represent a 0.

This technique of representing data with discrete pulses is a form of Pulse Code Modulation (PCM). The light itself is generated by either an LED or a laser and guided down the glass fiber by the principle of total internal reflection, which we touched on in the last lesson.

How Light Carries Data in Fiber Optic Cables using Pulse Code Modulation
This diagram illustrates how a binary stream (`1011...`) is translated into pulses of light within a fiber-optic cable. The '1's correspond to light pulses, and the '0's to the absence of light.

To understand how this is implemented, let's watch a segment from the video on fiber optics.

How Fiber Optics Works 🌎

This clip from 'How Fiber Optics Works' directly explains the process of converting digital data into light signals for transmission.

Watch the segment from 03:22 to 04:20. Pay attention to how it describes the conversion of digital data into binary light signals using LEDs or lasers.

Just like with copper, fiber-optic systems also need sophisticated encoding schemes to manage clocking and other issues, but the fundamental principle remains the same: representing binary data through the state of a physical phenomenon—in this case, light.


Conclusion

In this lesson, we've demystified how the abstract 1s and 0s of the digital world are translated into physical signals. This process of encoding is a cornerstone of the physical layer of networking.

Key Takeaways:

  • Encoding on Copper: Data is encoded by modulating electrical voltage on a wire. A simple scheme uses high/low voltage for 1/0.
  • Encoding on Fiber: Data is encoded by pulsing light through a glass fiber. A simple scheme uses light-on/light-off for 1/0.
  • Real-World Encoding: Simple schemes have practical limitations. Real-world protocols like Ethernet use more advanced line codes (e.g., 8b/10b encoding) to ensure clock synchronization and signal integrity, making data transmission more robust.

Preview of the Next Lesson:

We now understand the physical media and the signals that travel on them. In the next lesson, we will zoom out to see how these physical components are used to build networks of different sizes and scopes. We'll explore the learning outcome: Define and distinguish between LAN, WAN, MAN, and PAN, and you'll learn what differentiates the network in your home from the one that spans the globe.