Want to keep learning?

This content is taken from the Raspberry Pi Foundation & National Centre for Computing Education's online course, Networking with Python: Socket Programming for Communication. Join the course to learn more.

Data loss: how does it happen and what can we do about it?

When you transmit data through the internet, you are sending electrical signals across metal, through plastic, and even through the air, sometimes all the way to the other side of the world. Errors happen all the time, and there are many different factors that can cause them. I will give you an overview of some of the more common causes, but if you feel I missed out an important one, leave a comment for your fellow learners.

Noise

The signals you send are susceptible to outside influences such as radio waves and electrical surges. The distortion these things cause is called noise, and in truth all signals pick up some noise. Waves are often drawn as perfect lines following a wave or a digital signal pattern, but in reality they look a lot more like the ones below.

A analogue signal (a sine wave) and a digital signal (a square wave) are each shown, along with some random noise. The combined signal + noise is also shown in each case.

These signals are still readable, both by the computer and with your eyes. You can see where the ones and zeroes are on the digital signal, but if the noise gets too great, the signal can rise or fall far enough to be read by the computer as another value:

A noisy digital signal, where at one point the noise causes the signal to cross over a threshold (represented by a horizontal dotted line), resulting in a bit being read as a 0 rather than a 1

Poor connections

The network of cabling that the internet communicates across, both copper and fibre-optic, is great but not perfect. Connections have to be maintained and some may be left too long and deteriorate. Modern connections are of high quality and use the latest technology to allow lightning-fast communication. The older connections were cutting-edge when they were laid down, but are much slower than modern cables. When your signal travels across these connections, the signal can be distorted, causing errors.

Crosstalk errors

Signals can interfere with each other too, especially if they are being transmitted along cables that are close to one another. The electromagnetic fields caused by each signal can interfere with the other signals, causing distortions.

Error detection

Whatever the cause, errors will occur, so you need to be able to detect and correct them.

Checksums

When data is sent across a network it is sent in its encoded form, a collection of 1s and 0s that represent the data as a number. Checksums are arithmetic processes performed on the bits that comprise the data; they use the data to produce a result to send along with the message. The receiver then performs the same process and checks their result against the one received. Even a small change should result in a noticeable change to the result of the checksum calculation.

Parity bits

One of the most common types of checksum is a parity bit. To set a parity bit, the sender must count how many 1s and 0s there are in a message. There are two main types of parity bit: even and odd. In even parity, the parity bit will be used to make sure the total number of 1s in the data is even. If the message has an odd amount of 1s already, the parity bit will be set to 1, making the total number of 1s even. If the number of 1s is already even, a parity bit of 0 will be used. Similarly, for odd parity, the parity bit ensures that the total count of 1s is odd.

Parity bits allow for a quick check of the data that comes in, but the system is not perfect; for example, if two bits are incorrect, the parity bit will still appear correct.

How do we deal with it?

If you detect an error in a message, there is very little you can do to reconstruct it. If you know for certain what should be sent, you can adjust the message. In most situations this won’t be possible, so the only course of action is to ask for the data to be resent.

Automatic repeat requests

This process is called an automatic repeat request, and is the most common form of error correction. The protocol being used will dictate when and how often repeats are requested, but the process itself is universal.

These requests can come from any device on the data’s journey, not just the receiving computer. This is why it is important that checksums are quick to calculate and check, so that all of the network switches and computers can check for the validity of the data they are routing as they receive it. This distributes the workload of error detection and correction, which helps keep the internet moving.

The nuts and bolts of error correction

To set you up for the rest of the week, I would like you to do some reading and research to share with the class.

Use Google or another search tool to research forward error correction. How does it work, and how does it reduce transmission errors?

Share your findings in the comments and discuss the systems you have learnt about with your fellow learners.

Share this article:

This article is from the free online course:

Networking with Python: Socket Programming for Communication

Raspberry Pi Foundation