CN Unit-2
CN Unit-2
Error Detection
When sender transmits data to the receiver, the data might get scrambled by noise or data might
get corrupted during the transmission.
Error detection is a technique that is used to check if any error occurred in the data during the
transmission.
In this technique,
One extra bit called as parity bit is sent along with the original data bits.
Parity bit helps to check if any error occurred in the data during the transmission.
Page |1
Total number of 1’s in the data unit to be transmitted is counted.
The total number of 1’s in the data unit is made even in case of even parity.
The total number of 1’s in the data unit is made odd in case of odd parity.
This is done by adding an extra bit called as parity bit.
Advantage-
This technique is guaranteed to detect an odd number of bit errors (one, three, five and so
on).
Disadvantage-
This technique cannot detect an even number of bit errors (two, four, six and so on).
Page |2
Vertical Redundancy Check -:
Vertical redundancy check is maintenance of parity bit. An additional bit is added with
original block to ensure that data transmitted correctly. It is also known as parity check
technique.
In VRC there are two types of parity bit “Even parity bit” and “Odd parity bit“.
Page |3
o Parity check bits are computed for each row, which is equivalent to the single-parity
check.
o In Two-Dimensional Parity check, a block of bits is divided into rows, and the redundant
row of bits is added to the whole block.
o At the receiving end, the parity bits are compared with the parity bits computed from the
received data.
Checksum
Error detection using checksum method involves the following steps-
Step-01:
At sender side,
If m bit checksum is used, the data unit to be transmitted is divided into segments of m
bits.
All the m bit segments are added.
The result of the sum is then complemented using 1’s complement arithmetic.
The value so obtained is called as checksum.
Step-02:
The data along with the checksum value is transmitted to the receiver.
Page |4
Step-03:
At receiver side,
If m bit checksum is being used, the received data unit is divided into segments of m bits.
All the m bit segments are added along with the checksum value.
The value so obtained is complemented and the result is checked.
Case-01:
Case-02:
Example-
Step-01:
At sender side,
The given data unit is divided into segments of 8 bits as-
Page |5
Now, all the segments are added and the result is obtained as-
10011001 + 11100010 + 00100100 + 10000100 = 1000100011
Since the result consists of 10 bits, so extra 2 bits are wrapped around.
00100011 + 10 = 00100101 (8 bits)
Now, 1’s complement is taken which is 11011010.
Thus, checksum value = 11011010
Step-02:
The data along with the checksum value is transmitted to the receiver.
Step-03:
At receiver side,
The received data unit is divided into segments of 8 bits.
All the segments along with the checksum value are added.
Sum of all segments + Checksum value = 00100101 + 11011010 = 11111111
Complemented value = 00000000
Since the result is 0, receiver assumes no error occurred in the data and therefore accepts
it.
CRC Generator-
The power of each term gives the position of the bit and the coefficient gives the value of the bit.
Page |6
Example-
The algebraic polynomial chosen as a CRC generator should have at least the following
properties-
Rule-01:
Rule-02:
Page |7
This condition guarantees that all the burst errors affecting an odd number of bits are
detected.
Important Notes-
The newly formed code word (Original data + CRC) is transmitted to the receiver.
At receiver side,
The transmitted code word is received.
The received code word is divided with the same CRC generator.
On division, the remainder so obtained is checked.
Case-01: Remainder = 0
Page |8
If the remainder is zero,
Receiver assumes that no error occurred in the data during the transmission.
Receiver accepts the data.
Case-02: Remainder ≠ 0
Problem-01:
A bit stream 1101011011 is transmitted using the standard CRC method. The generator
polynomial is x4+x+1. What is the actual bit string transmitted?
Solution-
Page |9
Here, CRC = 1110.
Now,
Page |10
The code word to be transmitted is obtained by replacing the last 4 zeroes of
11010110110000 with the CRC.
Thus, the code word transmitted to the receiver = 11010110111110.
Error Correction
Error Correction codes are used to detect and correct the errors when data is transmitted from the
sender to the receiver.
o Backward error correction: Once the error is discovered, the receiver requests the
sender to retransmit the entire data unit.
o Forward error correction: In this case, the receiver uses the error-correcting code
which automatically corrects the errors.
A single additional bit can detect the error, but cannot correct it.
Suppose r is the number of redundant bits and d is the total number of the data bits. The number
of redundant bits r can be calculated by using the formula:
2r>=d+r+1
The value of r is calculated by using the above formula. For example, if the value of d is 4, then
the possible smallest value that satisfies the above relation would be 3.
To determine the position of the bit which is in error, a technique developed by R.W Hamming is
Hamming code
Hamming Code
Parity bits: The bit which is appended to the original data of binary bits so that the total number
of 1s is even or odd.
Even parity: To check for even parity, if the total number of 1s is even, then the value of the
parity bit is 0. If the total number of 1s occurrences is odd, then the value of the parity bit is 1.
Odd Parity: To check for odd parity, if the total number of 1s is even, then the value of parity
bit is 1. If the total number of 1s is odd, then the value of parity bit is 0.
Page |11
o The 'r' bits are placed in the positions 1,2,.....2k-1.
o At the receiving end, the parity bits are recalculated. The decimal value of the parity bits
determines the position of an error.
The number of redundant bits is 3. The three bits are represented by r1, r2, r4. The position of the
redundant bits is calculated with corresponds to the raised power of 2. Therefore, their
corresponding positions are 1, 21, 22.
1. The position of r1 = 1
2. The position of r2 = 2
3. The position of r4 = 4
Page |12
Determining the Parity bits
Determining the r1 bit
The r1 bit is calculated by performing a parity check on the bit positions whose binary
representation includes 1 in the first position.
We observe from the above figure that the bit positions that includes 1 in the first position are 1,
3, 5, 7. Now, we perform the even-parity check at these bit positions. The total number of 1 at
these bit positions corresponding to r1 is even, therefore, the value of the r1 bit is 0.
Determining r2 bit
The r2 bit is calculated by performing a parity check on the bit positions whose binary
representation includes 1 in the second position.
We observe from the above figure that the bit positions that includes 1 in the second position
are 2, 3, 6, 7. Now, we perform the even-parity check at these bit positions. The total number of
1 at these bit positions corresponding to r2 is odd, therefore, the value of the r2 bit is 1.
Page |13
Determining r4 bit
The r4 bit is calculated by performing a parity check on the bit positions whose binary
representation includes 1 in the third position.
We observe from the above figure that the bit positions that includes 1 in the third position are 4,
5, 6, 7. Now, we perform the even-parity check at these bit positions. The total number of 1 at
these bit positions corresponding to r4 is even, therefore, the value of the r4 bit is 0.
Suppose the 4th bit is changed from 0 to 1 at the receiving end, then parity bits are recalculated.
R1 bit
We observe from the above figure that the binary representation of r1 is 1100. Now, we perform
the even-parity check, the total number of 1s appearing in the r1 bit is an even number.
Therefore, the value of r1 is 0.
Page |14
R2 bit
We observe from the above figure that the binary representation of r2 is 1001. Now, we perform
the even-parity check, the total number of 1s appearing in the r2 bit is an even number.
Therefore, the value of r2 is 0.
R4 bit
We observe from the above figure that the binary representation of r4 is 1011. Now, we perform
the even-parity check, the total number of 1s appearing in the r4 bit is an odd number. Therefore,
the value of r4 is 1.
o The binary representation of redundant bits, i.e., r4r2r1 is 100, and its corresponding
decimal value is 4. Therefore, the error occurs in a 4th bit position. The bit value must be
changed from 1 to 0 to correct the error.
Flow Control-
Flow control tells the sender how much data should be sent to the receiver so that it is not lost.
This mechanism makes the sender wait for an acknowledgment before sending the next data.
Flow control restricts the number of frames the sender can send before it waits for an
acknowledgment from the receiver.
Page |15
There are two ways to control the flow of data:
Stop and Wait Protocol is the simplest flow control protocol.It works under the following
conditions-
Communication channel is perfect.
No error occurs during transmission.
Page |16
Sender sends a data packet to the receiver.
Sender stops and waits for the acknowledgement for the sent packet from the receiver.
Receiver receives and processes the data packet.
Receiver sends an acknowledgement to the sender.
After receiving the acknowledgement, sender sends the next data packet to the receiver.
Advantages-
Disadvantages-
Page |17
Sender will keep waiting for the acknowledgement for infinite time.
Stop and wait ARQ is a one bit sliding window protocol where-
Sender window size = 1
Receiver window size = 1
Time out timer helps to solve the problem of lost data packet.
After sending a data packet to the receiver, sender starts the time out timer.
If the data packet gets acknowledged before the timer expires, sender stops the time out timer.
If the timer goes off before receiving the acknowledgement, sender retransmits the same data
packet.
After retransmission, sender resets the timer.
This prevents the occurrence of deadlock.
2. Lost Acknowledgement-
Page |18
Sequence number on data packets help to solve the problem of delayed acknowledgement.
Consider the acknowledgement sent by the receiver gets lost.
Then, sender retransmits the same data packet after its timer goes off.
This prevents the occurrence of deadlock.
The sequence number on the data packet helps the receiver to identify the duplicate data
packet.
Receiver discards the duplicate packet and re-sends the same acknowledgement.
3. Delayed Acknowledgement-
Sequence number on acknowledgements help to solve the problem of delayed
acknowledgement.
Page |19
4. Damaged Packet-
If receiver receives a corrupted data packet from the sender, it sends a negative
acknowledgement (NAK) to the sender.
NAK requests the sender to send the data packet again.
Advantages-
Page |20
Stop and Wait ARQ support half duplex.
Only one packet or frame can be sent at a time.
Disadvantages-
There is no pipelining, channel utilization is very low.
Maximum number of frames that sender can send without acknowledgement = Sender window
size
A window is a buffer where we store the frames. Each frame in a window is numbered. If the
window size is n then the frames are numbered from the number 0 to n-1.
Suppose the size of the window is 4. So, the frames would be numbered as 0,1,2,3,0,1,2,3,0,…
so on.
Advantages –
It performs much better than stop-and-wait flow control.
This method increases efficiency.
Multiples frames can be sent one after another.
Page |21
Disadvantages-
The main issue is complexity at the sender and receiver due to the transferring of multiple
frames.
The receiver might receive data frames or packets out the sequence.
Page |22
Acknowledge Lost
Channel Allocation-:
Channel allocation is a process in which a single channel is divided and allotted to multiple
users in order to carry user specific tasks. There are user’s quantity may vary every time the
process takes place. If there is N number of users and channel is divided into N equal-sized sub
channels, Each user is assigned one portion. If the number of users are small and don’t vary at
Page |23
times, then Frequency Division Multiplexing can be used as it is a simple and efficient channel
bandwidth allocating technique.
Channel allocation problem can be solved by two schemes: Static Channel Allocation in LANs
and MANs, and Dynamic Channel Allocation.
It is the classical or traditional approach of allocating a single channel among multiple competing
users using Frequency Division Multiplexing (FDM). if there are N users, the frequency channel
is divided into N equal sized portions (bandwidth), each user being assigned one portion. Since
each user has a private frequency band, there is no interference between users.
It is not suitable in case of a large number of users with variable bandwidth requirements.
For example, suppose that there is a classroom full of students. When a teacher asks a question,
all the students (small channels) in the class start answering the question at the same time
(transferring the data simultaneously). All the students respond at the same time due to which
Page |24
data is overlap or data lost. Therefore it is the responsibility of a teacher (multiple access
protocol) to manage the students and make them one answer.
All the station has the equal priority to send the data over a channel. In random access protocol,
one or more stations cannot depend on another station nor any station control another station.
Depending on the channel's state (idle or busy), each station transmits the data frame.
If more than one station sends the data over a channel, there may be a collision or data conflict.
Due to the collision, the data frame packets may be lost or changed.
There are the different methods of random-access protocols such as-
o Aloha
o CSMA
o CSMA/CD
o CSMA/CA
Aloha
It is designed for wireless LAN (Local Area Network) but can also be used in a shared medium to transmit
data. Using this method, any station can transmit data across a network simultaneously when a data
frameset is available for transmission.
Aloha Rules
Channel Load (G) = Number of request per second/Number of slots per second
Pure Aloha
In pure Aloha, when each station transmits data to a channel without checking whether the
channel is idle or not, the chances of collision may occur, and the data frame can be lost. When
any station transmits the data frame to a channel, the pure Aloha waits for the receiver's
acknowledgment. If it does not acknowledge the receiver end within the specified time, the
station waits for a random amount of time, called the backoff time (Tb).
Page |26
Slotted Aloha
In slotted Aloha, the shared channel is divided into a fixed time interval called slots. So that, if a
station wants to send a frame to a shared channel, the frame can only be sent at the beginning of
the slot, and only one frame is allowed to be sent to each slot. And if the stations are unable to
send data to the beginning of the slot, the station will have to wait until the beginning of the slot
for the next time. However, the possibility of a collision remains when trying to send a frame at
the beginning of two or more station time slot.
Page |27
CSMA (Carrier Sense Multiple Access)
It is a carrier sense multiple access based on media access protocol to sense the traffic on a channel
(idle or busy) before transmitting the data. It means that if the channel is idle, the station can send data to
the channel. Otherwise, it must wait until the channel becomes idle. Hence, it reduces the chances of a
collision on a transmission medium.
1-Persistent: In the 1-Persistent mode of CSMA that defines each node, first sense the shared channel
and if the channel is idle, it immediately sends the data. Else it must wait and keep track of the status of
the channel to be idle and broadcast the frame unconditionally as soon as the channel is idle.
Page |28
Non-Persistent: It is the access mode of CSMA that defines before transmitting the data, each node must
sense the channel, and if the channel is inactive, it immediately sends the data. Otherwise, the station
must wait for a random time (not continuously), and when the channel is found to be idle, it transmits the
frames.
P-Persistent: It is the combination of 1-Persistent and Non-persistent modes. The P-Persistent mode
defines that each node senses the channel, and if the channel is inactive, it sends a frame with
a P probability. If the data is not transmitted, it waits for a (q = 1-p probability) random time and
resumes the frame with the next time slot.
O- Persistent: It is an O-persistent method that defines the superiority of the station before the
transmission of the frame on the shared channel. If it is found that the channel is inactive, each station
waits for its turn to retransmit the data.
Page |29
CSMA/ CD
It is a carrier sense multiple access/ collision detection network protocol to transmit data
frames. It first senses the shared channel before broadcasting the frames, and if the channel is
idle, it transmits a frame to check whether the transmission was successful. If the frame is
successfully received, the station sends another frame. If any collision is detected in the
CSMA/CD, the station sends a jam/ stop signal to the shared channel to terminate data
transmission. After that, it waits for a random time before sending a frame to a channel.
Page |30
CSMA/ CA
It is a method of reducing data frame collision on a shared channel. In the controlled access
method, each station interacts and decides to send a data frame by a particular station approved
by all other stations. It means that a single station cannot send the data frames unless all other
stations are not approved. It has three types of controlled access: Reservation, Polling,
and Token Passing.
1. Reservation:
In the reservation method, a station needs to make a reservation before sending data. Time is
divided into intervals. In each interval, a reservation frame precedes the data frames sent in that
interval.
Page |31
If there are N stations in the system, there are exactly N reservation minislots in the reservation
frame. Each minislot belongs to a station. When a station needs to send a data frame, it makes a
reservation in its own minislot.
The following figure shows a situation with five stations and a five-minislot reservation frame.
In the first interval, only stations 1, 3, and 4 have made reservations. In the second interval, only
station 1 has made a reservation.
2. Polling:
Polling works with topologies in which one device is designated as a primary station and the
other devices are secondary stations. All data exchanges must be made through the primary
device even when the ultimate destination is a secondary device.
The primary device controls the link; the secondary devices follow its instructions.
If the primary wants to receive data, it asks the secondaries if they have anything to send, this is
called poll function. If the primary wants to send data, it tells the secondary to get ready to
receive; this is called select function.
Page |32
Select:
The select function is used whenever the primary device has something to send. If it has
something to send, the primary device sends it
Poll:
The poll function is used by the primary device to solicit transmissions from the secondary
devices. When the primary is ready to receive data, it must ask (poll) each device in turn if it has
anything to send.
3. Token Passing:
In the token-passing method, the stations in a network are organized in a logical ring. In other
words, for each station, there is a predecessor and a successor. The predecessor is the station
which is logically before the station in the ring; the successor is the station which is after the
station in the ring.
In this method, a special packet called a token circulates through the ring. The possession of the
token gives the station the right to access the channel and send its data. When a station has some
data to send, it waits until it receives the token from its predecessor. It then holds the token and
sends its data. When the station has no more data to send, it releases the token, passing it to the
next logical station in the ring. The station cannot send data until it receives the token again in
the next round.
Page |33
Channelization Protocols
It is a channelization protocol that allows the total usable bandwidth in a shared channel to be
shared across multiple stations based on their time, distance and codes. It can access all the
stations at the same time to send the data frames to the channel.
Following are the various methods to access the channel based on their time, distance and codes:
FDMA
It is a frequency division multiple access (FDMA) method used to divide the available
bandwidth into equal bands so that multiple users can send data through a different frequency to
the sub channel. Each station is reserved with a particular band to prevent the crosstalk between
the channels and interferences of stations.
Page |34
TDMA
Time Division Multiple Access (TDMA) is a channel access method. It allows the same
frequency bandwidth to be shared across multiple stations. And to avoid collisions in the shared
channel, it divides the channel into different frequency slots that allocate stations to transmit the
data frames. The same frequency bandwidth into the shared channel by dividing the signal into
various time slots to transmit it. However, TDMA has an overhead of synchronization that
specifies each station's time slot by adding synchronization bits to each slot.
CDMA
Code Division Multiple Access is a channel access method. In CDMA, all stations can
simultaneously send the data over the same channel. It means that it allows each station to
transmit the data frames with full frequency on the shared channel at all times. It does not require
the division of bandwidth on a shared channel based on time slots. If multiple stations send data
to a channel simultaneously, their data frames are separated by a unique code sequence. Each
station has a different unique code for transmitting the data over a shared channel. For example,
there are multiple users in a room that are continuously speaking. Data is received by the users if
only two-person interact with each other using the same language.
Page |35