Unit 2 (Part 1)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

Error Detection in Computer

Networks
••

Error is a condition when the receiver’s information does not match the sender’s
information. During transmission, digital signals suffer from noise that can introduce
errors in the binary bits traveling from sender to receiver. That means a 0 bit may
change to 1 or a 1 bit may change to 0.
Data (Implemented either at the Data link layer or Transport Layer of the OSI Model)
may get scrambled by noise or get corrupted whenever a message is transmitted. To
prevent such errors, error-detection codes are added as extra data to digital
messages. This helps in detecting any errors that may have occurred during message
transmission.
Types of Errors

Single-Bit Error

A single-bit error refers to a type of data transmission error that occurs when one bit
(i.e., a single binary digit) of a transmitted data unit is altered during transmission,
resulting in an incorrect or corrupted data unit.

Single-Bit Error

No of prints: Page 1 of
19
Multiple-Bit Error

A multiple-bit error is an error type that arises when more than one bit in a data
transmission is affected. Although multiple-bit errors are relatively rare when
compared to single-bit errors, they can still occur, particularly in high-noise or high-
interference digital environments.

Multiple-Bit Error

Burst Error

When several consecutive bits are flipped mistakenly in digital transmission, it


creates a burst error. This error causes a sequence of consecutive incorrect
values.

No of prints: Page 2 of
19
Burst Error

To detect errors, a common technique is to introduce redundancy bits that


provide additional information. Various techniques for error detection
include::
1. Simple Parity Check
2. Two-dimensional Parity Check
3. Checksum
4. Cyclic Redundancy Check (CRC)

Error Detection Methods

Simple Parity Check

Simple-bit parity is a simple error detection method that involves adding an


extra bit to a data transmission. It works as:
• 1 is added to the block if it contains an odd number of 1’s, and
• 0 is added if it contains an even number of 1’s
This scheme makes the total number of 1’s even, that is why it is called even
parity checking.

No of prints: Page 3 of
19
Disadvantages
• Single Parity check is not able to detect even no. of bit error.
• For example, the Data to be transmitted is 101010. Codeword
transmitted to the receiver is 1010101 (we have used even parity).
Let’s assume that during transmission, two of the bits of code word
flipped to 1111101.
On receiving the code word, the receiver finds the no. of ones to be
even and hence no error, which is a wrong assumption.

Two-dimensional Parity Check

Two-dimensional Parity check bits are calculated for each row, which is
equivalent to a simple parity check bit. Parity check bits are also calculated for
all columns, then both are sent along with the data. At the receiving end, these
are compared with the parity bits calculated on the received data.

( Figure is shown below)

No of prints: Page 4 of
19
Checksum

Checksum error detection is a method used to identify errors in transmitted


data. The process involves dividing the data into equally sized segments and
No of prints: Page 5 of
19
using a 1’s complement to calculate the sum of these segments. The calculated
sum is then sent along with the data to the receiver. At the receiver’s end, the
same process is repeated and if all zeroes are obtained in the sum, it means that
the data is correct.
Checksum – Operation at Sender’s Side
• Firstly, the data is divided into k segments each of m bits.
• On the sender’s end, the segments are added using 1’s complement
arithmetic to get the sum. The sum is complemented to get the
checksum.
• The checksum segment is sent along with the data segments.
Checksum – Operation at Receiver’s Side
• At the receiver’s end, all received segments are added using 1’s
complement arithmetic to get the sum. The sum is complemented.
• If the result is zero, the received data is accepted; otherwise discarded.

Disadvantages
• If one or more bits of a segment are damaged and the corresponding
bit or bits of opposite value in a second segment are also damaged.

No of prints: Page 6 of
19
Cyclic Redundancy Check (CRC)

• Unlike the checksum scheme, which is based on addition, CRC is based


on binary division.
• In CRC, a sequence of redundant bits, called cyclic redundancy check
bits, are appended to the end of the data unit so that the resulting data
unit becomes exactly divisible by a second, predetermined binary
number.
• At the destination, the incoming data unit is divided by the same
number. If at this step there is no remainder, the data unit is assumed
to be correct and is therefore accepted.
• A remainder indicates that the data unit has been damaged in transit
and therefore must be rejected.

No of prints: Page 7 of
19
Error Correction Techniques

Error correction techniques find out the exact number of bits that have been
corrupted and as well as their locations. There are two principle ways

• Backward Error Correction (Retransmission) − If the receiver detects an error in the


incoming frame, it requests the sender to retransmit the frame. It is a relatively simple
technique. But it can be efficiently used only where retransmitting is not expensive as in
fiber optics and the time for retransmission is low relative to the requirements of the
application.
• Forward Error Correction − If the receiver detects some error in the incoming frame, it
executes error-correcting code that generates the actual frame. This saves bandwidth
required for retransmission. It is inevitable in real-time systems. However, if there are too
many errors, the frames need to be retransmitted.

The four main error correction codes are

• Hamming Codes

No of prints: Page 8 of
19
• Binary Convolution Code
• Reed – Solomon Code
• Low-Density Parity-Check Code

Hamming code for single error correction, double error detection

Hamming code is a block code that is capable of detecting up to two simultaneous


bit errors and correcting single-bit errors. It was developed by R.W. Hamming for
error correction.

In this coding method, the source encodes the message by inserting redundant
bits within the message. These redundant bits are extra bits that are generated
and inserted at specific positions in the message itself to enable error detection
and correction. When the destination receives this message, it performs
recalculations to detect errors and find the bit position that has error.

Hamming Code for Single Error Correction

The procedure for single error correction by Hamming Code includes two parts,
encoding at the sender’s end and decoding at receiver’s end.

Encoding a message by Hamming Code

The procedure used by the sender to encode the message encompasses the
following steps −

• Step 1 − Calculation of the number of redundant bits.


• Step 2 − Positioning the redundant bits.
• Step 3 − Calculating the values of each redundant bit.

Once the redundant bits are embedded within the message, this is sent to the
destination.

Step 1 − Calculation of the number of redundant bits.

If the message contains m number of data bits, r number of redundant bits are
added to it so that is able to indicate at least (m + r + 1) different states. Here, (m +
r) indicates location of an error in each of bit positions and one additional state
indicates no error. Since, r bits can indicate 2r states, 2r must be at least equal
to (m + r + 1). Thus the following equation should hold −

No of prints: Page 9 of
19
2r ≥ 𝑚 + 𝑚 + 1

Example 1 − If the data is of 7 bits, i.e. m = 7, the minimum value of r that will
satisfy the above equation is 4, (24 ≥ 7 + 4 + 1). The total number of bits in the
encoded message, (m + r) = 11. This is referred as (11,4) code.

Step 2 − Positioning the redundant bits.

The r redundant bits placed at bit positions of powers of 2, i.e. 1, 2, 4, 8, 16 etc.


They are referred in the rest of this text as r1 (at position 1), r2 (at position
2), r3 (at position 4), r4 (at position 8) and so on.

Example 2 − If, m = 7 comes to 4, the positions of the redundant bits are as follows

Step 3 − Calculating the values of each redundant bit.

The redundant bits are parity bits. A parity bit is an extra bit that makes the
number of 1s either even or odd. The two types of parity are −

• Even Parity − Here the total number of bits in the message is made even.
• Odd Parity − Here the total number of bits in the message is made odd.

Each redundant bit, ri, is calculated as the parity, generally even parity, based
upon its bit position. It covers all bit positions whose binary representation includes
a 1 in the ith position except the position of ri. Thus −

• r1 is the parity bit for all data bits in positions whose binary representation includes a 1 in
the least significant position excluding 1 (3, 5, 7, 9, 11 and so on)
• r2 is the parity bit for all data bits in positions whose binary representation includes a 1 in
the position 2 from right except 2 (3, 6, 7, 10, 11 and so on)
• r3 is the parity bit for all data bits in positions whose binary representation includes a 1 in
the position 3 from right except 4 (5-7, 12-15, 20-23 and so on)

Example 3 − Suppose that the message 1100101 needs to be encoded using even
parity Hamming code. Here, m = 7 and r comes to 4. The values of redundant bits
will be as follows −

No of prints: Page 10 of
19
Hence, the message sent will be 11000101100.

Decoding a message in Hamming Code

Once the receiver gets an incoming message, it performs recalculations to detect


errors and correct them. The steps for recalculation are −

• Step 1 − Calculation of the number of redundant bits.


• Step 2 − Positioning the redundant bits.
• Step 3 − Parity checking.
• Step 4 − Error detection and correction

Step 1) Calculation of the number of redundant bits

Using the same formula as in encoding, the number of redundant bits are
ascertained.

2r ≥ 𝑚 + 𝑚 + 1

where m is the number of data bits and r is the number of redundant bits.

Step 2) Positioning the redundant bits

The r redundant bits placed at bit positions of powers of 2, i.e. 1, 2, 4, 8, 16 etc.

Step 3) Parity checking

Parity bits are calculated based upon the data bits and the redundant bits using
the same rule as during generation of c1, c2, c3, c4 etc. Thus

c1 = parity(1, 3, 5, 7, 9, 11 and so on)

c2 = parity(2, 3, 6, 7, 10, 11 and so on)

c3 = parity(4-7, 12-15, 20-23 and so on)

Step 4) Error detection and correction

The decimal equivalent of the parity bits binary values is calculated. If it is 0, there
is no error. Otherwise, the decimal value gives the bit position which has error. For
No of prints: Page 11 of
19
example, if c1c2c3c4 = 1001, it implies that the data bit at position 9, decimal
equivalent of 1001, has error. The bit is flipped (converted from 0 to 1 or vice
versa) to get the correct message.

Example 4 − Suppose that an incoming message 11110101101 is received.

Step 1 − At first the number of redundant bits are calculated using the formula
2r ≥ m + r + 1. Here, m + r + 1 = 11 + 1 = 12. The minimum value of r such that
2r ≥ 12 is 4.

Step 2 − The redundant bits are positioned as below −

Step 3 − Even parity checking is done −

c1 = even_parity(1, 3, 5, 7, 9, 11) = 0

c2 = even_parity(2, 3, 6, 7, 10, 11) = 0

c3 = even_parity (4, 5, 6, 7) = 0

c4 = even_parity (8, 9, 10, 11) = 0

Step 4 - Since the value of the check bits c1c2c3c4 = 0000 = 0, there are no errors
in this message.

Hamming Code for double error detection

The Hamming code can be modified to correct a single error and detect double
errors by adding a parity bit as the MSB, which is the XOR of all other bits.

Example 5 − If we consider the codeword, 11000101100, sent as in example 3,


after adding P = XOR(1,1,0,0,0,1,0,1,1,0,0) = 0, the new codeword to be sent will
be 011000101100.

At the receiver’s end, error detection is done as shown in the following table −

No of prints: Page 12 of
19
What is Pure ALOHA?

The•• ALOHA protocol was first developed at the University of Hawaii in the early 1970s
for packet radio networks. However, it can be used in any situation where multiple
devices share a common communication channel. This protocol allows devices to
transmit data at any time, without a set schedule. This is known as a random access
technique, and it is asynchronous because there is no coordination between devices.
When multiple devices attempt to transmit data at the same time, it can result in a
collision, where the data becomes garbled. In this case, each device will simply wait a
random amount of time before attempting to transmit again. The basic concept of the
ALOHA protocol can be applied to any system where uncoordinated users are
competing for the use of a shared channel.
Pure ALOHA:
• Pure ALOHA refers to the original ALOHA protocol. The idea is that each
station sends a frame whenever one is available. Because there is only one
channel to share, there is a chance that frames from different stations will
collide.
• The pure ALOHA protocol utilizes acknowledgments from the receiver to
ensure successful transmission. When a user sends a frame, it expects
confirmation from the receiver. If no acknowledgment is received within a
designated time period, the sender assumes that the frame was not
received and retransmits the frame.
• When two frames attempt to occupy the channel simultaneously, a collision
occurs and both frames become garbled. If the first bit of a new frame
overlaps with the last bit of a frame that is almost finished, both frames will
be completely destroyed and will need to be retransmitted. If all users
retransmit their frames at the same time after a time-out, the frames will
collide again.
• To prevent this, the pure ALOHA protocol dictates that each user waits a
random amount of time, known as the back-off time, before retransmitting
the frame. This randomness helps to avoid further collisions.

No of prints: Page 13 of
19
Pure ALOHA procedure

• The time-out period is equal to the maximum possible round-trip


propagation delay, which is twice the amount of time required to send a
frame between the two most widely separated stations (2 x Tp).
• Let all the packets have the same length. And each requires a one-time unit
for transmission (tp). Consider any user to send packet A at a time. If any
other user B has generated a packet between time (to), and (to + tp), the
end of packet B will collide with the beginning of packet A. Since in a pure
ALOHA packet, a station does not listen to the channel before transmitting,
it has no way of knowing that the above frame was already underway.

No of prints: Page 14 of
19
Vulnerable period for packet A

• Similarly, if another user wants to transmit between (to, +tp) and (to +2tp)
i.e. packet C, the beginning of packet C will collide with the end of packet A.
Thus if two packets overlap by even the smallest amount in the vulnerable
period both packets will be corrupted and need to be retransmitted.
Key Features of Pure ALOHA:
1. Random Access: Devices can send data whenever they have something to
transmit, without needing to wait for a predetermined time slot.
2. Uncoordinated Transmission: Devices do not coordinate with each other before
transmitting. They simply attempt to send data whenever they have data to send.

What is Slotted ALOHA?


•••
Slotted ALOHA is an improved version of the pure ALOHA protocol that aims to make
communication networks more efficient. In this version, the channel is divided into
small, fixed-length time slots and users are only allowed to transmit data at the
beginning of each time slot. This synchronization of transmissions reduces the chances
of collisions between devices, increasing the overall efficiency of the network.
The channel time is separated into time slots in slotted ALOHA, and stations are only
authorized to transmit at particular times. These time slots correspond to the packet
transmission time exactly. All users are then synchronized to these time slots so that
whenever a user sends a packet, it must precisely match the next available channel slot.

No of prints: Page 15 of
19
As a result, wasted time due to collisions can be reduced to one packet time or the
susceptible period can be half.
When a user wants to transmit a frame, it waits until the next time slot and then sends
the frame. If the frame is received successfully, the receiver sends an acknowledgment.
If the acknowledgment is not received within a time-out period, the sender assumes
that the frame was not received and retransmits the frame in the next time slot.

Transmission attempts and random retransmission delay for colliding packets in slotted ALOHA

Slotted ALOHA increases channel utilization by reducing the number of collisions.


However, it also increases the delay for users, as they have to wait for the next time
slot to transmit their frames. It’s also worth noting that there is a variant of slotted
ALOHA called “non-persistent slotted ALOHA” which is a variation of slotted ALOHA,
in this variant the station that wants to send data, first listens to the channel before
sending the data. If the channel is busy it waits for a certain time before trying again.

No of prints: Page 16 of
19
Throughput of Slotted ALOHA:
The quantity of successful transmissions at each time slot determines the throughput
of the Slotted Aloha protocol. The Slotted Aloha protocol has a maximum throughput
of about 18.4%. This is because there is a significant risk of collisions when numerous
nodes try to transmit at the same time, which causes missed packets and a decreased
overall throughput. When less than or equal to 37% of the network’s total nodes are
actively transmitting data, the maximum throughput is reached.
Due to the high frequency of collisions, the throughput of Slotted Aloha is typically
substantially lower than 18.4% in practice It is not a widely used protocol in today’s
contemporary networks because of this.

The maximum throughput of a slotted ALOHA channel is given by the formula:


Throughput (S) = G x e-G
The maximum Throughput occurs at G = 1,
i.e. S = 1/e = 0.368
Where:
G = the offered load (or the number of packets being transmitted per time slot). The
offered load is a measure of the number of nodes attempting to transmit in a given time
slot.

Comparison of the throughput as a function of offered load for Pure and Slotted ALOHA

The throughput is a function of the offered load and it ranges from 0 to 1. As the offered
load increases, the throughput decreases as more collisions occur, resulting in less
successful transmissions. The maximum throughput is achieved when the offered load
is equal to 0.37 and it is approximately 0.184.
No of prints: Page 17 of
19
It is important to note that the above equation assumes that all the packets are of the
same length and that the channel is error-free. In practice, the throughput is usually
much lower than this due to a number of factors such as packet errors, channel noise,
and the overhead of retransmissions.
Assumption of Slotted ALOHA:
• All frames are of the same size.
• Time is divided into equal-sized slots, a slot equals the time to transmit one
frame
• Nodes start to transmit frames only at beginning of slots.
• Nodes are synchronized.
• If two or more nodes transmit in a slot, all nodes detect collision before the
slot ends.
Advantages of Slotted ALOHA:
• Simplicity: The Slotted Aloha protocol is relatively simple to implement
and understand, making it an easy option for low-complexity networks.
• Flexibility: Slotted Aloha can be used in a wide range of network
environments, including those with varying numbers of nodes and varying
traffic loads
• Low overhead: Slotted Aloha does not require complex management or
control mechanisms, which can help to reduce the overhead and complexity
of the network.
Disadvantages of Slotted ALOHA:
• Low throughput: The maximum throughput of the Slotted Aloha protocol
is relatively low at around 18.4%, which can be limiting for high-bandwidth
applications.
• High collision rate: The high collision rate in slotted ALOHA can result in a
high packet loss rate, which can negatively impact the overall performance
of the network.
• Inefficiency: The protocol is inefficient at high loads, as the efficiency
decreases as the number of nodes attempting to transmit increases.

Differences Between Pure Aloha and Slotted Aloha

Pure Aloha Slotted Aloha

In this Aloha, any station can transmit In this, any station can transmit the data at the
the data at any time. beginning of any time slot.

In this, The time is continuous and not In this, The time is discrete and globally
globally synchronized. synchronized.

Vulnerable time for Pure Aloha = 2 x


Vulnerable time for Slotted Aloha = Tt
Tt
No of prints: Page 18 of
19
Pure Aloha Slotted Aloha

In Pure Aloha, the Probability of


In Slotted Aloha, the Probability of successful
successful transmission of the data
transmission of the data packet
packet
= G x e-G
= G x e-2G

In Pure Aloha, Maximum efficiency In Slotted Aloha, Maximum efficiency


= 18.4% = 36.8%

Pure Aloha doesn’t reduce the number Slotted Aloha reduces the number of collisions
of collisions to half. to half and doubles the efficiency of Pure Aloha.

1. What is the advantage of Pure Aloha over Slotted Aloha?

Answer:
The advantage of pure aloha over slotted aloha is that there is no fixed size, and
it has the ability to start transmission at any particular time and no need for
synchronization.

2. What is the formula for throughput of Pure Aloha and Slotted Aloha?

Answer:
Pure Aloha: S = G x e -2G
Slotted Aloha: S = G x e -G

No of prints: Page 19 of
19

You might also like