KCA 303 Unit-2
KCA 303 Unit-2
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.
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“.
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.
Case-01:
Case-02:
Example-
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-
CRC Generator-
The power of each term gives the position of the bit and the coefficient gives the value of the bit.
Example-
Page |8
The algebraic polynomial chosen as a CRC generator should have at least the following
properties-
Rule-01:
Rule-02:
Important Notes-
Page |9
Step 2: Transmission to Receiver-
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
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 |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.
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.
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.
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
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.
Suppose the 4th bit is changed from 0 to 1 at the receiving end, then parity bits are recalculated.
Page |16
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.
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
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.
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.
Page |19
After receiving the acknowledgement, sender sends the next data packet to the receiver.
Advantages-
Disadvantages-
Page |20
Stop and Wait ARQ-
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 |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.
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.
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.
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
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.
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.
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
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.
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