0% found this document useful (0 votes)
100 views

KCA 303 Unit-2

Uploaded by

mishrashlok888
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
100 views

KCA 303 Unit-2

Uploaded by

mishrashlok888
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 32

MAHARANA PRATAP GROUP OF INSTITUTIONS

KOTHI MANDHANA, KANPUR


(Approved by AICTE, New Delhi and Affiliated to Dr.AKTU, Lucknow )

Digital Notes
[Department of Computer Application]
Subject Name : Computer Network
Subject Code : KCA-303
Course : MCA
Branch :
Semester : III
Prepared by : Mr. Ajay Pratap Singh

Reference No./MCA/Ajay/KCA-303/2/3

Page |1
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.

Error detection Methods

1. Single Parity Check


2. Cyclic Redundancy Check (CRC)
3. Checksum

Single Parity Check-

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 |2
 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 |3
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“.

Example Even Parity Bit:

Consider data ” 1 1 0 0 0 0 1 ” if we passed this data to Even parity generator.

1. Count the number of 1’s which are 3 so ODD ( 1 1 0 0 0 0 1 ).


2. Now add bit 1 as parity bit so numbers will become ( 1 1 0 0 0 0 1 1).
3. Again count the number we alter the data now number of 1’s are 4 so even.

Page |4
Two-Dimensional Parity Check (LRC)
o Performance can be improved by using Two-Dimensional Parity Check which
organizes the data in the form of a table.
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.

Page |5
Step-02:

 The data along with the checksum value is transmitted to the receiver.

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.

Then, following two cases are possible-

Case-01:

If the result is zero,


 Receiver assumes that no error occurred in the data during the transmission.
 Receiver accepts the data.

Case-02:

If the result is non-zero,


 Receiver assumes that error occurred in the data during the transmission.
 Receiver discards the data and asks the sender for retransmission.

Example-

Consider the data unit to be transmitted is-


10011001111000100010010010000100
Consider 8 bit checksum is used.

Page |6
Step-01:

At sender side,
The given data unit is divided into segments of 8 bits as-

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.

Page |7
Cyclic Redundancy Check-

 Cyclic Redundancy Check (CRC) is an error detection method.


 It is based on binary division.

CRC Generator-

 CRC generator is an algebraic polynomial represented as a bit pattern.


 Bit pattern is obtained from the CRC generator using the following rule-

The power of each term gives the position of the bit and the coefficient gives the value of the bit.

Example-

Consider the CRC generator is x7 + x6 + x4 + x3 + x + 1.


The corresponding binary pattern is obtained as-

Then given CRC generator, the corresponding binary pattern is 11011011.

Properties of CRC Generator-

Page |8
The algebraic polynomial chosen as a CRC generator should have at least the following
properties-

Rule-01:

 It should not be divisible by x.


 This condition guarantees that all the burst errors of length equal to the length of
polynomial are detected.

Rule-02:

 It should be divisible by x+1.


 This condition guarantees that all the burst errors affecting an odd number of bits are
detected.

Important Notes-

If the CRC generator is chosen according to the above rules, then-


 CRC can detect all single-bit errors
 CRC can detect all double-bit errors provided the divisor contains at least three logic 1’s.
 CRC can detect any odd number of errors provided the divisor is a factor of x+1.
 CRC can detect all burst error of length less than the degree of the polynomial.
 CRC can detect most of the larger burst errors with a high probability.

Step 1: Calculation of CRC at sender side-

 A string of n 0’s is appended to the data unit to be transmitted.


 Here, n is one less than the number of bits in CRC generator.
 Binary division is performed of the resultant string with the CRC generator.
 After division, the remainder so obtained is called as CRC.
 It may be noted that CRC also consists of n bits.

Page |9
Step 2: Transmission to Receiver-

 The newly formed code word (Original data + CRC) is transmitted to the receiver.

Step3: Checking at Receiver Side-

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.

The following two cases are possible-

Case-01: Remainder = 0

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

If the remainder is non-zero,


 Receiver assumes that some error occurred in the data during the transmission.
 Receiver rejects the data and asks the sender for retransmission.

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 |10
 The generator polynomial G(x) = x4 + x + 1 is encoded as 10011.
 Clearly, the generator polynomial consists of 5 bits.
 So, a string of 4 zeroes is appended to the bit stream to be transmitted.
 The resulting bit stream is 11010110110000.

Now, the binary division is performed as-

Page |11
Here, CRC = 1110.

Page |12
Now,
 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.

Error Correction can be handled in two ways:

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.

Page |13
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.

Algorithm of Hamming code:


o An information of 'd' bits are added to the redundant bits 'r' to form d+r.
o The location of each of the (d+r) digits is assigned a decimal value.
o The 'r' bits are placed in the positions 1,2,.....2 k-1.
o At the receiving end, the parity bits are recalculated. The decimal value of the parity bits
determines the position of an error.

Relationship b/w Error position & binary number.

Let's understand the concept of Hamming code through an example:

Suppose the original data is 1010 which is to be sent.

Total number of data bits 'd' = 4


Number of redundant bits r : 2r >= d+r+1
2r>= 4+r+1
Therefore, the value of r is 3 that satisfies the above relation.
Total number of bits = d+r = 4+3 = 7;
Determining the position of the redundant bits

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.

Page |14
1. The position of r1 = 1
2. The position of r2 = 2
3. The position of r4 = 4

Representation of Data on the addition of parity bits:

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.

Page |15
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.

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.

Data transferred is given below:

Suppose the 4th bit is changed from 0 to 1 at the receiving end, then parity bits are recalculated.

Page |16
R1 bit

The bit positions of the r1 bit are 1,3,5,7

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.

R2 bit

The bit positions of r2 bit are 2,3,6,7.

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

The bit positions of r4 bit are 4,5,6,7.

Page |17
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.

There are two ways to control the flow of data:

1. Stop and Wait Protocol


2. Sliding Window Protocol

Page |18
Stop and Wait Protocol-

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.

Working- The working of a stop and wait protocol are as follows-


 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.

Page |19
 After receiving the acknowledgement, sender sends the next data packet to the receiver.

Advantages-

The advantages of stop and wait protocol are-


 It is very simple to implement.
 The incoming packet from receiver is always an acknowledgement.

Disadvantages-

The disadvantages of stop and wait protocol are-


1. It is extremely inefficient because-
 It makes the transmission process extremely slow.
2. If the data packet sent by the sender gets lost, then-
 Sender will keep waiting for the acknowledgement for infinite time.

Page |20
Stop and Wait ARQ-

Stop and Wait ARQ assumes-


 The communication channel is noisy.
 Errors may get introduced in the data during the transmission.

Stop and wait ARQ is a one bit sliding window protocol where-
 Sender window size = 1
 Receiver window size = 1

1. Lost Data Packet-

 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 |21
 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 |22
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.

Page |23
Advantages-
 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.

Sliding Window Protocol-

 Sliding window protocol is a flow control protocol.


 It allows the sender to send multiple frames before needing the acknowledgements.
 Sender slides its window on receiving the acknowledgements for the sent frames.
 This allows the sender to send more frames.

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.

Page |24
Advantages –
 It performs much better than stop-and-wait flow control.
 This method increases efficiency.
 Multiples frames can be sent one after another.

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.

Go back N ARQ Protocol-

 In Go back N, sender window size is N and receiver window size is always 1.


 Go back N uses cumulative acknowledgements.
 Go back N may use independent acknowledgements
 Go back N does not accept the corrupted frames and silently discards them.
 Go back N does not accept out of order frames and silently discards them.
 Go back N leads to retransmission of entire window if for any frame, no ACK is received
by the sender.
 Go back N leads to retransmission of lost frames after expiry of time out timer.

Selective Repeat ARQ Protocol-

 In SR protocol, sender window size is always same as receiver window size.


Sender window size = Receiver window size = 2n/2 = 2n-1
 SR protocol uses independent acknowledgements only.
 SR protocol does not accept the corrupted frames but does not silently discard them.
 SR protocol accepts the out of order frames.
 SR protocol requires sorting at the receiver’s side.
 SR protocol requires searching at the sender’s side.
 SR protocol leads to retransmission of lost frames after expiry of time out timer.

Page |25
Multiple Access Protocol-:
When a sender and receiver have a dedicated link to transmit data packets, the data link control is
enough to handle the channel. Suppose there is no dedicated path to communicate or transfer the
data between two devices. In that case, multiple stations access the channel and simultaneously
transmits the data over the channel. It may create collision and cross talk. Hence, the multiple
access protocol is required to reduce the collision and avoid crosstalk between the channels.

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
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.

Random Access Protocol -

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.

Page |26
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

1. Any station can transmit data to a channel at any time.


2. It does not require any carrier sensing.
3. Collision and data frames may be lost during the transmission of data through multiple stations.
4. Acknowledgment of the frames exists in Aloha. Hence, there is no collision detection.
5. It requires retransmission of data after some random amount of time.

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 |27
1. The total vulnerable time of pure Aloha is 2 * Tfr.
2. Maximum throughput occurs when G = 1/ 2 that is 18.4%.
3. Successful transmission of data frame is S = G * e ^ - 2 G.

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.

1. Maximum throughput occurs in the slotted Aloha when G = 1 that is 37%.


2. The probability of successfully transmitting the data frame in the slotted Aloha is S = G *
e ^ - 2 G.
3. The total vulnerable time required in slotted Aloha is Tfr.

Page |28
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.

CSMA Access Modes

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.

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.

CSMA/ CA

It is a carrier sense multiple access/collision avoidance network protocol for carrier


transmission of data frames. It is a protocol that works with a medium access control layer.

Page |30
When a data frame is sent to a channel, it receives an acknowledgment to check whether the
channel is clear. If the station receives only a single (own) acknowledgments, that means the data
frame has been successfully transmitted to the receiver. But if it gets two signals (its own and
one more in which the collision of frames), a collision of the frame occurs in the shared channel.
Detects the collision of the frame when a sender receives an acknowledgment signal.

Controlled Access Protocol

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.

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:

Page |31
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.

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 |32

You might also like