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

Computer Networks Notes

This document discusses different types of communication channels and flow control protocols in computer networks. It describes simplex, half-duplex, and full-duplex channels. It then explains the stop-and-wait protocol, including how it works, factors affecting its efficiency, and its advantages and limitations. It also discusses how stop-and-wait ARQ improves on stop-and-wait protocol by adding sequence numbers and a timeout timer to address issues like packet loss.

Uploaded by

trevor
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
543 views

Computer Networks Notes

This document discusses different types of communication channels and flow control protocols in computer networks. It describes simplex, half-duplex, and full-duplex channels. It then explains the stop-and-wait protocol, including how it works, factors affecting its efficiency, and its advantages and limitations. It also discusses how stop-and-wait ARQ improves on stop-and-wait protocol by adding sequence numbers and a timeout timer to address issues like packet loss.

Uploaded by

trevor
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 421

Computer Networks Notes

Introduction-

Types of Communication Channels-

1. Simplex channel
2. Half duplex channel
3. Full duplex channel
 
1. Simplex Channel-
 
 A simplex communication channel can send the signals only in one direction.
 Thus, entire bandwidth of the channel can be used during the transmission.
 
Example-
 
Radio station
 Radio station is a good example of a simplex communication channel.
 A radio station always sends signals to its audience.
 It never receives signals from the audience.
 
2. Half Duplex Channel-

 A full duplex communication channel can send signals in both the directions at the same
time.
 Full duplex communication channels greatly increases the efficiency of communication.
 
Example-
 
Telephone
 Telephone is a good example of a full duplex channel.
 Both the persons can speak as well as hear each other at the same time.
 
Channel Capacity-
The total number of bits a channel can hold is called as its capacity.
 

Capacity of a half duplex channel


= Bandwidth x Propagation delay

Capacity of a full duplex channel


= 2 x Capacity of a half duplex channel
= 2 x Bandwidth x Propagation delay

 
To gain better understanding about communication channels in networking,
Flow Control in Computer Networks-
In computer networks, flow control is defined as-
A set of procedures which are used for restricting the amount of data that a sender can send to
the receiver.

There are various flow control protocols which are classified as-
Stop and Wait Protocol-
 

Stop and Wait Protocol is the simplest flow control protocol.

 
It works under the following assumptions-
 Communication channel is perfect.
 No error occurs during transmission.
 
Working-

The working of a stop and wait protocol may be explained as-


 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.
 
These steps are illustrated below-

Analysis-
 
Now, let us analyze in depth how the transmission is actually carried out-
 
 Sender puts the data packet on the transmission link.
 Data packet propagates towards the receiver’s end.
 Data packet reaches the receiver and waits in its buffer.
 Receiver processes the data packet.
 Receiver puts the acknowledgement on the transmission link.
 Acknowledgement propagates towards the sender’s end.
 Acknowledgement reaches the sender and waits in its buffer.
 Sender processes the acknowledgement.
 
These steps are illustrated below-

otal Time-
 

Total time taken in sending one data packet


= (Transmission delay + Propagation delay + Queuing delay + Processing delay)packet
+
(Transmission delay + Propagation delay + Queuing delay + Processing delay)ACK

 
Assume-
 Queuing delay and processing delay to be zero at both sender and receiver side.
 Transmission time for the acknowledgement to be zero since it’s size is very small.
 
Under the above assumptions.
 

Total time taken in sending one data packet


= (Transmission delay + Propagation delay)packet + (Propagation delay)ACK

 
We know,
 Propagation delay depends on the distance and speed.
 So, it would be same for both data packet and acknowledgement.
 
So, we have-
 

Total time taken in sending one data packet


= (Transmission delay)packet + 2 x Propagation delay

 
Efficiency-
 
Efficiency of any flow control control protocol is given by-
 

Efficiency (η) = Useful Time / Total Time

 
where-
 Useful time = Transmission delay of data packet = (Transmission delay)packet
 Useless time = Time for which sender is forced to wait and do nothing = 2 x Propagation
delay
 Total time = Useful time + Useless time
 
Thus,

Factors Affecting Efficiency-


 
We know,
Efficiency (η)
= (Transmission delay)packet / { (Transmission delay)packet + 2 x Propagation delay }
 
Dividing numerator and denominator by (Transmission delay)packet, we get-
 

From here, we can observe-


 Efficiency (η) ∝ 1 / Distance between sender and receiver
 Efficiency (η) ∝ 1 / Bandwidth
 Efficiency (η) ∝ Transmission speed
 Efficiency (η) ∝ Length of data packet
 
Throughput-
 
 Number of bits that can be sent through the channel per second is called as its throughput.

Round Trip Time-


 

Round Trip Time = 2 x Propagation delay

 
Advantages-
 
The advantages of stop and wait protocol are-
 It is very simple to implement.
 The incoming packet from receiver is always an acknowledgement.
 
Limitations-
 
The limitations of stop and wait protocol are-
Point-01:
 
It is extremely inefficient because-
 It makes the transmission process extremely slow.
 It does not use the bandwidth entirely as each single packet and acknowledgement uses
the entire time to traverse the link.
 
Point-02:
 
If the data packet sent by the sender gets lost, then-
 Sender will keep waiting for the acknowledgement for infinite time.
 Receiver will keep waiting for the data packet for infinite time.
 
Point-03:

If acknowledgement sent by the receiver gets lost, then-


 Sender will keep waiting for the acknowledgement for infinite time.
 Receiver will keep waiting for another data packet for infinite time.
 
Important Notes-
 
Note-01:
 
Efficiency may also be referred by the following names-
 Line Utilization
 Link Utilization
 Sender Utilization
 Utilization of Sender
 
Note-02:
 
Throughput may also be referred by the following names-
 Bandwidth Utilization
 Effective Bandwidth
 Maximum data rate possible
 Maximum achievable throughput
Note-03:
 
Stop and Wait protocol performs better for LANs than WANs.
This is because-
 Efficiency of the protocol is inversely proportional to the distance between sender and
receiver.
 So, the protocol performs better where the distance between sender and receiver is less.
 The distance is less in LANs as compared to WANs.
 
To gain better understanding about Stop and Wait Protocol,
Stop and Wait Protocol-
Before you go through this article, make sure that you have gone through the previous article
on Stop and Wait Protocol.

In stop and wait protocol,


 Sender sends one data packet and then waits for its acknowledgement.
 Sender sends the next packet only after it receives the acknowledgement for the previous
packet.
The main problem faced by the Stop and Wait protocol is the occurrence of deadlock due to-

1. Loss of data packet


2. Loss of acknowledgement
Stop and Wait 
Stop and Wait ARQ is an improved and modified version of Stop and Wait protocol.
Stop and Wait ARQ assumes-
 The communication channel is noisy.
 Errors may get introduced in the data during the transmission.
 
Working-
 
 Stop and wait ARQ works similar to stop and wait protocol.
 It provides a solution to all the limitations of stop and wait protocol.
 Stop and wait ARQ includes the following three extra elements.
Thus, we can say-
 

Stop and Wait ARQ


= Stop and Wait Protocol + Time Out Timer + Sequence Numbers for Data Packets and
Acknowledgements

 
Number of Sequence Numbers Required-
Number of Sequence Numbers Required-
 

NOTE
For any sliding window protocol to work without any problem,
the following condition must be satisfied-
Available Sequence Numbers >= Sender Window Size + Receiver Window Size

 
Stop and wait ARQ is a one bit sliding window protocol where-
 Sender window size = 1
 Receiver window size = 1
 
Thus, in stop and wait ARQ,
Minimum number of sequence numbers required
= Sender Window Size + Receiver Window Size
=1+1
=2
 
Thus,
 Minimum number of sequence numbers required in Stop and Wait ARQ = 2.
 The two sequence numbers used are 0 and 1.
 
How Stop and Wait ARQ Solves All Problems?
 
1. Problem of 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. Problem of Lost Acknowledgement-


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

Role of Sequence Number on Data Packets


 
Consider the above example-
 
Step-01:
 
 Sender sends a data packet with sequence number-0 to the receiver.
 
Step-02:
 
 Receiver receives the data packet correctly.
 Receiver now expects data packet with sequence number-1.
 Receiver sends the acknowledgement ACK-1.
 
Step-03:
 
 Acknowledgement ACK-1 sent by the receiver gets lost on the way.
Step-04:
 
 Sender receives no acknowledgement and time out occurs.
 Sender retransmits the same data packet with sequence number-0.
 This will be a duplicate packet for the receiver.
 
Step-05:
 
 Receiver receives the data packet and discovers it is the duplicate packet.
 It expects the data packet with sequence number-1 but receiving the data packet with
sequence number-0.
 It discards the duplicate data packet and re-sends acknowledgement ACK-1.
 ACK-1 requests the sender to send a data packet with sequence number-1.
 This avoids the inconsistency of data.
 
Conclusion-
 
 Had the sequence numbers not been allotted to the data packets, receiver would have
accepted the duplicate data packet thinking of it as the new data packet.
 This is how sequence numbers allotted to the data packets prove to be useful for
identifying the duplicate data packets and discarding them.
3. Problem of Delayed Acknowledgement-
 
 Sequence number on acknowledgements help to solve the problem of delayed
acknowledgement.
 
Role of Sequence Number on Acknowledgements
 
Consider the above example-
 
Step-01:
 
 Sender sends a data packet with sequence number-0 to the receiver.
 
Step-02:
 
 Receiver receives the data packet correctly.
 Receiver now expects data packet with sequence number-1.
 Receiver sends the acknowledgement ACK-1.
 
Step-03:
 
 Acknowledgement ACK-1 sent by the receiver gets delayed in reaching the sender.
 
Step-04:
 
 Sender receives no acknowledgement and time out occurs.
 Sender retransmits the same data packet with sequence number-0.
 This will be a duplicate packet for the receiver.
 
Step-05:
 
 Receiver receives the data packet and discovers it is the duplicate packet.
 It expects the data packet with sequence number-1 but receiving the data packet with
sequence number-0.
 It discards the duplicate data packet and re-sends acknowledgement ACK-1.
 ACK-1 requests the sender to send a data packet with sequence number-1.
 
Step-06:
 
 Two acknowledgements ACK1 reaches the sender.
 When first acknowledgement ACK1 reaches the sender, sender sends the next data
packet with sequence number 1.
 When second acknowledgement ACK1 reaches the sender, sender rejects the duplicate
acknowledgement.
 This is because it has already sent the data packet with sequence number-1 and now
sender expects the acknowledgement with sequence number 0 from the receiver.
Conclusion-
 
 Had the sequence numbers not been allotted to the acknowledgements, sender would
have accepted the duplicate acknowledgement thinking of it as the new acknowledgement for
the latest data packet sent by it.
 This is how sequence numbers allotted to the acknowledgements prove to be useful for
identifying duplicate acknowledgements and discarding them.
4. Problem of 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.

Stop and Wait Protocol Vs Stop and Wait ARQ-


 
The following comparison table states the differences between the two protocols-
 

Stop and Wait Protocol Stop and Wait ARQ

It assumes that the communication channel is It assumes that the communication channel is
perfect and noise free. imperfect and noisy.

Data packet sent by the sender can never get


Data packet sent by the sender may get corrupt.
corrupt.

There is no concept of negative A negative acknowledgement is sent by the


acknowledgements. receiver if the data packet is found to be corrupt.
Sender starts the time out timer after sending the
There is no concept of time out timer.
data packet.

Data packets and acknowledgements are


There is no concept of sequence numbers.
numbered using sequence numbers.

 
Limitation of Stop and Wait ARQ-

The major limitation of Stop and Wait ARQ is its very less efficiency.

 
To increase the efficiency, protocols like Go back N and Selective Repeat are used.
 
Explanation-
 
In stop and wait ARQ,
 Sender window size is 1.
 This allows the sender to keep only one frame unacknowledged.
 So, sender sends one frame and then waits until the sent frame gets acknowledged.
 After receiving the acknowledgement from the receiver, sender sends the next frame.
 

The major limitation of Stop and Wait ARQ is its very less efficiency.

 
To increase the efficiency, protocols like Go back N and Selective Repeat are used.
 
Explanation-
 
In stop and wait ARQ,
 Sender window size is 1.
 This allows the sender to keep only one frame unacknowledged.
 So, sender sends one frame and then waits until the sent frame gets acknowledged.
 After receiving the acknowledgement from the receiver, sender sends the next frame.
 

Here,
 Sender uses Tt time for transmitting the packet over the link.
 Then, sender waits for 2 x Tp time.
 After 2 x Tp time, sender receives the acknowledgement for the sent frame from the
receiver.
 Then, sender sends the next frame.
 This 2 x Tp waiting time is the actual cause of less efficiency.
 
Efficiency Improvement-
 
 The efficiency of stop and wait ARQ can be improved by increasing the window size.
 This allows the sender to keep more than one unacknowledged frame in its window.
 Thus, sender can send frames in the waiting time too.
Th
This gives rise to the concept of sliding window protocols.
PRACTICE PROBLEMS BASED ON STOP AND WAIT PROTOCOL-
 
Problem-01:
 
If the bandwidth of the line is 1.5 Mbps, RTT is 45 msec and packet size is 1 KB, then find the
link utilization in stop and wait.
 
Solution-
 
Given-
 Bandwidth = 1.5 Mbps
 RTT = 45 msec
 Packet size = 1 KB
 
Calculating Transmission Delay-
Transmission delay (Tt)
= Packet size / Bandwidth
= 1 KB / 1.5 Mbps
= (210 x 8 bits) / (1.5 x 106 bits per sec)
= 5.461 msec
Calculating Propagation Delay-
Propagation delay (Tp)
= Round Trip Time / 2
= 45 msec / 2
= 22.5 msec
Calculating Value Of ‘a’-
 
a = Tp / Tt
a = 22.5 msec / 5.461 msec
a = 4.12
 
Calculating Link Utilization-
 
Link Utilization or Efficiency (η)
= 1 / 1+2a
= 1 / (1 + 2 x 4.12)
= 1 / 9.24
= 0.108
= 10.8 %
Problem-02:
 
A channel has a bit rate of 4 Kbps and one way propagation delay of 20 msec. The channel uses
stop and wait protocol. The transmission time of the acknowledgement frame is negligible. To
get a channel efficiency of at least 50%, the minimum frame size should be-
1. 80 bytes
2. 80 bits
3. 160 bytes
4. 160 bits
 
Solution-
 
Given-
 Bandwidth = 4 Kbps
 Propagation delay (Tp) = 20 msec
 Efficiency >= 50%
 
Let the required frame size = L bits.
 
Calculating Transmission Delay-
Transmission delay (Tt)
= Packet size / Bandwidth
= L bits / 4 Kbps
 
Calculating Value Of ‘a’-
 
a = Tp / Tt
a = 20 msec / ( L bits / 4 Kbps)
a = (20 msec x 4 Kbps) / L bits
 
Condition For Efficiency To Be At least 50%-
 
For efficiency to be at least 50%, we must have-
1 / 1+2a >= 1/2
a <= 1/2
 
Substituting the value of ‘a’, we get-
(20 msec x 4 Kbps) / L bits <= 1/2
L bits >= (20 msec x 4 Kbps) x 2
L bits >= (20 x 10-3 sec x 4 x 103 bits per sec) x 2
L bits >= 20 x 4 bits x 2
L >= 160
 
From here, frame size must be at least 160 bits.
Thus, Correct Option is (D).
 
Problem-03:
 
What is the throughput achievable in stop and wait protocol by a maximum packet size of 1000
bytes and network span of 10 km.
Assume the speed of light in cable is 70% of the speed of light in vaccum.
 
Solution-
 
We have-
 In the given question, we are not provided with the network’s bandwidth.
 So, in the above formula of throughput, we have ignored the term Tt from the
denominator.
 Although it is incorrect, but we still ignore it for solving the question.
 
Now, Given-
 L = 1000 bytes
 d = 10 km = 104 m
 v = 70% of 3 x 108 m/sec = 2.1 x 108 m/sec
 
Substituting the values in the above relation, we get-
Throughput
= 1000 bytes / [ 2 x 104 m / (2.1 x 108 m/sec)]
= 1.05 x 107 bytes per sec
= 10.5 MBps
 
Problem-04:
If the packet size is 1 KB and propagation time is 15 msec, the channel capacity is 109 b/sec, then
find the transmission time and utilization of sender in stop and wait protocol.
 
Solution-
 
Given-
 Packet size = 1 KB
 Propagation time (Tp) = 15 msec
 Channel capacity = Bandwidth (here) = 109 b/sec
 
NOTE-
 
 Generally, channel capacity is the total number of bits which a channel can hold. So, its
unit is bits.
 But here, channel capacity is actually given as bandwidth because its unit is b/sec.
 
Calculating Transmission Delay-
Transmission delay (Tt)
= Packet size / Bandwidth
= 1 KB / 109 bits per sec
= 210 bits / 109 bits per sec
= 1.024 μsec
 
Calculating Value Of ‘a’-
 
a = Tp / Tt
a = 15 msec / 1.024 μsec
a = 15000 μsec / 1.024 μsec
a = 14648.46
 
Calculating Sender Utilization-
Sender Utilization or Efficiency (η)
= 1 / 1+2a
= 1 / (1 + 2 x 1468.46)
= 1 / 29297.92
= 0.0000341
= 0.00341 %
 
Problem-05:
 
Consider a MAN with average source and destination 20 Km apart and one way delay of 100
μsec. At what data rate does the round trip delay equals the transmission delay for a 1 KB
packet?
 
Solution-
Given-
 Distance = 20 Km
 Propagation delay (Tp) = 100 μsec
 Packet size = 1 KB
 
We need to have-
Round Trip Time = Transmission delay
2 x Propagation delay = Transmission delay
 
Substituting the values in the above relation, we get-
2 x 100 μsec = 1 KB / Bandwidth
Bandwidth = 1 KB / 200 μsec
Bandwidth = (210 x 106 / 200 ) bytes per sec
Bandwidth = 5.12 MBps or 40.96 Mbps
 
Problem-06:
 
Consider two hosts X and Y connected by a single direct link of rate 106 bits/sec. The distance
between the two hosts is 10,000 km and the propagation speed along the link is 2 x 108 m/sec.
Host X sends a file of 50,000 bytes as one large message to host Y continuously. Let the
transmission and propagation delays be p milliseconds and q milliseconds respectively.
Then the value of p and q are-
1. p = 50 and q = 100
2. p = 50 and q = 400
3. p = 100 and q = 50
4. p = 400 and q = 50
 
Solution-
 
Given-
 Bandwidth = 106 bits/sec
 Distance = 10,000 km
 Propagation speed = 2 x 108 m/sec
 Packet size = 50,000 bytes
 
Calculating Transmission Delay-
 
Transmission delay (Tt)
= Packet size / Bandwidth
= 50000 bytes / 106 bits per sec
= (5 x 104 x 8 bits) / 106 bits per sec
= ( 4 x 105 bits ) / 106 bits per sec
= 0.4 sec
= 400 msec
 
Calculating Propagation Delay-
 
Propagation delay (Tp)
= Distance / Propagation speed
= 10000 km / (2 x 108 m/sec)
= 107 m / (2 x 108 m/sec)
= 50 msec
 
Thus, Option (D) is correct.
Problem-07:
 
The values of parameters for the stop and wait ARQ protocol are as given below-
 Bit rate of the transmission channel = 1 Mbps
 Propagation delay from sender to receiver = 0.75 ms
 Time to process a frame = 0.25 ms
 Number of bytes in the information frame = 1980
 Number of bytes in the acknowledge frame = 20
 Number of overhead bytes in the information frame = 20
Assume that there are no transmission errors. Then the transmission efficiency (in %) of the stop
and wait ARQ protocol for the above parameters is ___________ . (correct to 2 decimal places)
 
Solution-
Problem-07:
 
The values of parameters for the stop and wait ARQ protocol are as given below-
 Bit rate of the transmission channel = 1 Mbps
 Propagation delay from sender to receiver = 0.75 ms
 Time to process a frame = 0.25 ms
 Number of bytes in the information frame = 1980
 Number of bytes in the acknowledge frame = 20
 Number of overhead bytes in the information frame = 20
Assume that there are no transmission errors. Then the transmission efficiency (in %) of the stop
and wait ARQ protocol for the above parameters is ___________ . (correct to 2 decimal places)
 
Solution-
Calculating Total Time-
 
Total time
= Transmission delay of data frame + Propagation delay of data frame + Processing delay of data
frame + Transmission delay of acknowledgement + Propagation delay of acknowledgement
= (1980 bytes / 1 Mbps) + 0.75 msec + 0.25 msec + (20 bytes / 1 Mbps) + 0.75 msec
= 15.840 msec + 0.75 msec + 0.25 msec + 0.160 msec + 0.75 msec
= 17.75 msec
 
Calculating Efficiency-
 
Efficiency (η)
= Useful time / Total time
= 15.680 msec / 17.75 msec
= 0.8833
= 88.33%
Problem-08:
 
A sender uses the stop and wait ARQ protocol for reliable transmission of frames. Frames are of
size 1000 bytes and the transmission rate at the sender is 80 Kbps. Size of an acknowledgement
is 100 bytes and the transmission rate at the receiver is 8 Kbps. The one way propagation delay is
100 msec.
Assuming no frame is lost, the sender throughput is __________ bytes/sec.
 
Solution-
 
Given-
 Frame size = 1000 bytes
 Sender bandwidth = 80 Kbps
 Acknowledgement size = 100 bytes
 Receiver bandwidth = 8 Kbps
 Propagation delay (Tp) = 100 msec
 
Calculating Transmission Delay Of Data Frame-
Transmission delay (Tt)
= Frame size / Sender bandwidth
= 1000 bytes / 80 Kbps
= (1000 x 8 bits) / (80 x 103 bits per sec)
= 0.1 sec
= 100 msec
 
Calculating Transmission Delay Of Acknowledgement-
 
Transmission delay (Tt)
= Acknowledgement size / Receiver bandwidth
= 100 bytes / 8 Kbps
= (100 x 8 bits) / (8 x 103 bits per sec)
= 100 msec
 Calculating Useful Time-
 
Useful Time
= Transmission delay of data frame
= 100 msec
 
Calculating Total Time-
 
Total Time
= Transmission delay of data frame + Propagation delay of data frame + Transmission delay of
acknowledgement + Propagation delay of acknowledgement
= 100 msec + 100 msec + 100 msec + 100 msec
= 400 msec
 
Calculating Efficiency-
 
Efficiency (η)
= Useful time / Total time
= 100 msec / 400 msec
=1/4
= 25%
 
Calculating Sender Throughput-
 
Sender throughput
= Efficiency (η) x Sender bandwidth
= 0.25 x 80 Kbps
= 20 Kbps
= (20 x 1000 / 8) bytes per sec
= 2500 bytes/sec
 
Problem-09:
 
Using stop and wait protocol, sender wants to transmit 10 data packets to the receiver. Out of
these 10 data packets, every 4th data packet is lost. How many packets sender will have to send
in total?
 
Solution-

Draw a time line diagram and analyze.


The packets will be sent as-
1, 2, 3, 4, 4, 5, 6, 7, 7, 8, 9, 10, 10
The lost packets are- 4, 7 and 10.
Thus, sender will have to send 13 data packets in total.
 Flow Control Protocols-
 
In computer networking, there are various flow control protocols-
Flow Control Protocols-
 
In computer networking, there are various flow control protocols-
 
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.
 It is called so because it involves sliding of sender’s window.
 

Maximum number of frames that sender can send without acknowledgement


= Sender window size

 
Optimal Window Size-
 
In a sliding window protocol, optimal sender window size = 1 + 2a

 
Derivation-
 
We know,

To get 100% efficiency, we must have-


η=1
Tt / (Tt + 2Tp) = 1
Tt = Tt + 2Tp
 
Thus,
 To get 100% efficiency, transmission time must be Tt + 2Tp instead of Tt.
 This means sender must send the frames in waiting time too.
 Now, let us find the maximum number of frames that can be sent in time Tt + 2Tp.
 
We have-
 In time Tt, sender sends one frame.
 Thus, In time Tt + 2Tp, sender can send (Tt + 2Tp) / Tt frames i.e. 1+2a frames.
 
Thus, to achieve 100% efficiency, window size of the sender must be 1+2a.
 
Required Sequence Numbers-
 
 Each sending frame has to be given a unique sequence number.
 Maximum number of frames that can be sent in a window = 1+2a.
 So, minimum number of sequence numbers required = 1+2a.
 

To have 1+2a sequence numbers,


Minimum number of bits required in sequence number field = ⌈log2(1+2a)⌉

 
NOTE-
 
 When minimum number of bits is asked, we take the ceil.
 When maximum number of bits is asked, we take the floor.
 
Choosing a Window Size-
 
The size of the sender’s window is bounded by-
 
1. Receiver’s Ability-
 
 Receiver’s ability to process the data bounds the sender window size.
 If receiver can not process the data fast, sender has to slow down and not transmit the
frames too fast.
 
2. Sequence Number Field-
 
 Number of bits available in the sequence number field also bounds the sender window
size.
 If sequence number field contains n bits, then 2n sequence numbers are possible.
 Thus, maximum number of frames that can be sent in one window = 2n.
 

For n bits in sequence number field, Sender Window Size = min (1+2a , 2n)

 
Implementations of Sliding Window Protocol-
 
The two well known implementations of sliding window protocol are-

1. Go back N Protocol
2. Selective Repeat Protocol
 
Efficiency-
 
Efficiency of any flow control protocol may be expressed as-
Example-
 
In Stop and Wait ARQ, sender window size = 1.
Thus,
Efficiency of Stop and Wait ARQ = 1 / 1+2a
 
PRACTICE PROBLEMS BASED ON SLIDING WINDOW PROTOCOL-
 
Problem-01:
 
If transmission delay and propagation delay in a sliding window protocol are 1 msec and 49.5
msec respectively, then-
1. What should be the sender window size to get the maximum efficiency?
2. What is the minimum number of bits required in the sequence number field?
3. If only 6 bits are reserved for sequence numbers, then what will be the efficiency?
 
Solution-
 
Given-
 Transmission delay = 1 msec
 Propagation delay = 49.5 msec
 
Part-01:
 
To get the maximum efficiency, sender window size
= 1 + 2a
= 1 + 2 x (Tp / Tt)
= 1 + 2 x (49.5 msec / 1 msec)
= 1 + 2 x 49.5
= 100
Thus,
For maximum efficiency, sender window size = 100
 
Part-02:
 
Minimum number of bits required in the sequence number field
= ⌈log2(1+2a)⌉
= ⌈log2(100)⌉
= ⌈6.8⌉
=7
Thus,
Minimum number of bits required in the sequence number field = 7
 
Part-03:
 
If only 6 bits are reserved in the sequence number field, then-
Maximum sequence numbers possible = 26 = 64
Now,
Efficiency
= Sender window size in the protocol / Optimal sender window size
= 64 / 100
= 0.64
= 64%
Problem-02:
 
If transmission delay and propagation delay in a sliding window protocol are 1 msec and 99.5
msec respectively, then-
1. What should be the sender window size to get the maximum efficiency?
2. What is the minimum number of bits required in the sequence number field?
3. If only 7 bits are reserved for sequence numbers, then what will be the efficiency?
 
Solution-
 
Given-
 Transmission delay = 1 msec
 Propagation delay = 99.5 msec
 
Part-01:
 
To get the maximum efficiency, sender window size
= 1 + 2a
= 1 + 2 x (Tp / Tt)
= 1 + 2 x (99.5 msec / 1 msec)
= 1 + 2 x 99.5
= 200
Thus,
For maximum efficiency, sender window size = 200
 
Part-02:
 
Minimum number of bits required in the sequence number field
= ⌈log2(1+2a)⌉
= ⌈log2(200)⌉
= ⌈7.64⌉
=8
Thus,
Minimum number of bits required in the sequence number field = 8
Part-03:
 
If only 6 bits are reserved in the sequence number field, then-
Maximum sequence numbers possible = 27 = 128
Now,
Efficiency
= Sender window size in the protocol / Optimal sender window size
= 128 / 200
= 0.64
= 64%
PRACTICE PROBLEMS BASED ON SLIDING WINDOW PROTOCOL-
 
Problem-01:
 
A 3000 km long trunk operates at 1.536 Mbps and is used to transmit 64 byte frames and uses
sliding window protocol. If the propagation speed is 6 μsec / km, how many bits should the
sequence number field be?
 
Solution-
 
Given-
 Distance = 3000 km
 Bandwidth = 1.536 Mbps
 Packet size = 64 bytes
 Propagation speed = 6 μsec / km
 
Calculating Transmission Delay-
 
Transmission delay (Tt)
= Packet size / Bandwidth
= 64 bytes / 1.536 Mbps
= (64 x 8 bits) / (1.536 x 106 bits per sec)
= 333.33 μsec
 
Calculating Propagation Delay-
 
For 1 km, propagation delay = 6 μsec
For 3000 km, propagation delay = 3000 x 6 μsec = 18000 μsec
 
Calculating Value Of ‘a’-
 
a = Tp / Tt
a = 18000 μsec / 333.33 μsec
a = 54
 
Calculating Bits Required in Sequence Number Field-
 Bits required in sequence number field
= ⌈log2(1+2a)⌉
= ⌈log2(1 + 2 x 54)⌉
= ⌈log2(109)⌉
= ⌈6.76⌉
= 7 bits
 
Thus,
 Minimum number of bits required in sequence number field = 7
 With 7 bits, number of sequence numbers possible = 128
 We use only (1+2a) = 109 sequence numbers and rest remains unused.
 
Problem-02:
 
Compute approximate optimal window size when packet size is 53 bytes, RTT is 60 msec and
bottleneck bandwidth is 155 Mbps.
 
Solution-
Given-
 Packet size = 53 bytes
 RTT = 60 msec
 Bandwidth = 155 Mbps
 
Calculating Transmission Delay-
 
Transmission delay (Tt)
= Packet size / Bandwidth
= 53 bytes / 155 Mbps
= (53 x 8 bits) / (155 x 106 bits per sec)
= 2.735 μsec
 
Calculating Propagation Delay-
 
Propagation delay (Tp)
= Round Trip Time / 2
= 60 msec / 2
= 30 msec
Calculating Value of ‘a’-
 
a = Tp / Tt
a = 30 msec / 2.735 μsec
a = 10968.921
 
Calculating Optimal Window Size-
 
Optimal window size
= 1 + 2a
= 1 + 2 x 10968.921
= 21938.84
 
Thus, approximate optimal window size = 21938 frames.
 
Problem-03:
A sliding window protocol is designed for a 1 Mbps point to point link to the moon which has a
one way latency (delay) of 1.25 sec. Assuming that each frame carries 1 KB of data, what is the
minimum number of bits needed for the sequence number?
 
Solution-
 
Given-
 Bandwidth = 1 Mbps
 Propagation delay (Tp) = 1.25 sec
 Packet size = 1 KB
 
Calculating Transmission Delay-
 
Transmission delay (Tt)
= Packet size / Bandwidth
= 1 KB / 1 Mbps
= (210 x 8 bits) / (106 bits per sec)
= 8.192 msec
Calculating Value of ‘a’-
 
a = Tp / Tt
a = 1.25 sec / 8.192 msec
a = 152.59
 
Calculating Bits Required in Sequence Number Field-
 
Bits required in sequence number field
= ⌈log2(1+2a)⌉
= ⌈log2(1 + 2 x 152.59)⌉
= ⌈log2(306.176)⌉
= ⌈8.25⌉
= 9 bits
 
Thus,
 Minimum number of bits required in sequence number field = 9
 With 9 bits, number of sequence numbers possible = 512.
 We use only (1+2a) sequence numbers and rest remains unused.

Problem-04:
 
Host A is sending data to host B over a full duplex link. A and B are using the sliding window
protocol for flow control. The send and receive window sizes are 5 packets each. Data packets
(sent only from A to B) are all 1000 bytes long and the transmission time for such a packet is 50
μs. Acknowledgement packets (sent only from B to A) are very small and require negligible
transmission time. The propagation delay over the link is 200 μs. What is the maximum
achievable throughput in this communication?
1. 7.69 x 106 Bps
2. 11.11 x 106 Bps
3. 12.33 x 106 Bps
4. 15.00 x 106 Bps
 
Solution-
 
Given-
 Sender window size = Receiver window size = 5
 Packet size = 1000 bytes
 Transmission delay (Tt) = 50 μs
 Propagation delay (Tp) = 200 μs
Calculating Bandwidth-
 
We know,
Transmission delay = Packet size / Bandwidth
 
So, Bandwidth
= Packet Size / Transmission delay (Tt)
= 1000 bytes / 50 μs
= (1000 x 8 bits) / (50 x 10-6 sec)
= 160 Mbps
 
Calculating Value of ‘a’-
 
a = Tp / Tt
a = 200 μsec / 50 μsec
a=4
Calculating Optimal Window Size-
 
Optimal window size
= 1 + 2a
=1+2x4
=9
 
Calculating Efficiency-
 
Efficiency (η)
= Sender window size / Optimal window size
=5/9
= 0.5555
= 55.55%
 
Calculating Maximum Achievable Throughput-
 
Maximum achievable throughput
= Efficiency (η) x Bandwidth
= 0.5555 x 160 Mbps
= 88.88 Mbps
= 88.88 x 106 bps or 11.11 x 106 Bps
 
Thus, Option (B) is correct.
 
Problem-05:
 
Station A uses 32 byte packets to transmit messages to station B using a sliding window
protocol. The round trip delay between A and B is 80 msec and the bottleneck bandwidth on the
path between A and B is 128 Kbps. What is the optimal window size that A should use?
1. 20
2. 40
3. 160
4. 320
Solution-
 
Given-
 Packet size = 32 bytes
 Round Trip Time = 80 msec
 Bandwidth = 128 Kbps
 
Calculating Transmission Delay-
 
Transmission delay (Tt)
= Packet size / Bandwidth
= 32 bytes / 128 Kbps
= (32 x 8 bits) / (128 x 103 bits per sec)
= 2 msec
 
Calculating Propagation Delay-
 
Propagation delay (Tp)
= Round Trip Time / 2
= 80 msec / 2
= 40 msec
 
Calculating Value of ‘a’-
 
a = Tp / Tt
a = 40 msec / 2 msec
a = 20
Calculating Optimal Window Size-
 
Optimal window size
= 1 + 2a
= 1 + 2 x 20
= 41 which is close to option (B)
Thus, Option (B) is correct.
 
Sliding Window Protocol-
 
Before you go through this article, make sure that you have gone through the previous article
on Sliding Window Protocol.
The two well known implementations of sliding window protocol are-
 
1. Go back N Protocol
2. Selective Repeat Protocol
Go and Back N protocol
Go back N protocol is an implementation of sliding window protocol
Point-01:
 

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

 
In Go back N,
 Sender window size = N. Example in Go back 10, sender window size will be 10.
 Receiver window size is always 1 for any value of N.
 
Point-02:
 

Go back N uses cumulative acknowledgements.

 
In Go back N,
 Receiver maintains an acknowledgement timer.
 Each time the receiver receives a new frame, it starts a new acknowledgement timer.
 After the timer expires, receiver sends the cumulative acknowledgement for all the
frames that are unacknowledged at that moment.
 
NOTE-
 
 A new acknowledgement timer does not start after the expiry of old acknowledgement
timer.
 It starts after a new frame is received.
 
Point-03:
 

Go back N may use independent acknowledgements too.

 
 The above point does not mean that Go back N can not use independent
acknowledgements.
 Go back N may use independent acknowledgements too if required.
 The kind of acknowledgement used depends on the expiry of acknowledgement timer.
 
Example-
 
 Consider after the expiry of acknowledgement timer, there is only one frame left to be
acknowledged.
 Then, Go back N sends the independent acknowledgement for that frame.
 
Point-04:

Go back N does not accept the corrupted frames and silently discards them.

 
In Go back N,
 If receiver receives a frame that is corrupted, then it silently discards that frame.
 The correct frame is retransmitted by the sender after the time out timer expires.
 Silently discarding a frame means-
“Simply rejecting the frame and not taking any action”
Point-05:
 
Go back N does not accept out of order frames and silently discards them.

 
In Go back N,
 If receiver receives a frame whose sequence number is not what the receiver expects,
then it silently discards that frame.
 All the following frames are also discarded.
 This is because receiver window size is 1 and therefore receiver can not accept out of
order frames.
 
Point-06:
 

Go back N leads to retransmission of entire window if for any frame, no ACK is received by the
sender.

 
In Go back N,
 Receiver silently discards the frame if it founds the frame to be either corrupted or out of
order.
 It does not send any acknowledgement for such frame.
 It silently discards the following frames too.
 
Thus,
 If for any particular frame, sender does not receive any acknowledgement, then it
understands that along with that frame, all the following frames must also have been discarded
by the receiver.
 So, sender has to retransmit all the following frames too along with that particular frame.
 Thus, it leads to the retransmission of entire window.
 That is why, the protocol has been named as “Go back N“.
 
Point-07:
 

Go back N leads to retransmission of lost frames after expiry of time out timer.
 
In Go back N,
 Consider a frame being sent to the receiver is lost on the way.
 Then, it is retransmitted only after time out timer expires for that frame at sender’s side.
 
Efficiency of Go back N-
 
Efficiency of any flow control protocol is given by-
 

Efficiency = Sender Window Size in Protocol / (1 + 2a)

 
In Go back N protocol, sender window size = N.
Thus,
PRACTICE PROBLEMS BASED ON GO BACK N PROTOCOL-
 
Problem-01:
 
A 20 Kbps satellite link has a propagation delay of 400 ms.The transmitter employs the “go back
n ARQ” scheme with n set to 10.
Assuming that each frame is 100 bytes long, what is the maximum data rate possible?
1. 5 Kbps
2. 10 Kbps
3. 15 Kbps
4. 20 Kbps
 
Solution-
 
Given-
 Bandwidth = 20 Kbps
 Propagation delay (Tp) = 400 ms
 Frame size = 100 bytes
 Go back N is used where N = 10
Calculating Transmission Delay-
 
Transmission delay (Tt)
= Frame size / Bandwidth
= 100 bytes / 20 Kbps
= (100 x 8 bits) / (20 x 103 bits per sec)
= 0.04 sec
= 40 msec
 
Calculating Value Of ‘a’-
 
a = Tp / Tt
a = 400 msec / 40 msec
a = 10
 
Calculating Efficiency-
 
Efficiency (η)
= N / (1+2a)
= 10 / (1 + 2 x 10)
= 10 / 21
= 0.476
= 47.6 %
 
Calculating Maximum Data Rate Possible-
 
Maximum data rate possible or Throughput
= Efficiency x Bandwidth
= 0.476 x 20 Kbps
= 9.52 Kbps
≅ 10 Kbps
 
Thus, Correct Option is (B)
 
Problem-02:
 
Consider the Go back N protocol with a sender’s window size of ‘n’. Suppose that at time ‘t’, the
next inorder packet the receiver is expecting has a sequence number of ‘K’. Assume that the
medium does not reorder messages.
Answer the following questions-
 
Part-01:
 
What are the possible sets of sequence numbers inside the sender’s window at time ‘t’. Assume
the sender has already received the ACKs.
 
1. [K-1, K+n-1]
2. [K, K+n-1]
3. [K, K+n]
4. [K+n, K-1]
Part-02:
 
If acknowledgements are still on their way to sender, what are all possible values of the ACK
field in the messages currently propagating back to the sender at a time ‘t’?
 
1. [K-n, K-1]
2. [K-1, K-n]
3. [K, K-n]
4. [K-n, K+1]
 
Solution-
 
Part-01:
 
 In Go back N protocol, the receiver window size is 1.
 It is given that receiver expects the packet having sequence number ‘K’.
 It means it has processed all the packets ranging from 0 to K-1.
 It is given that sender has received the acknowledgement for all these packets.
 So, outstanding packets in sender’s window waiting for the acknowledgement starts from
K.
 Sender window size = n.
 Therefore, last packet in sender’s window will have sequence number K+n-1.
 
Thus, Option (B) is correct.
 
Part-02:
 
 Acknowledgement number is the next expected sequence number by the receiver.
 Receiver expects the packet having sequence number ‘K’ at time ‘t’.
 It means it has received the packets ranging from 0 to K-1 whose acknowledgements are
are on the way.
 For the (K-1)th packet, acknowledgement number would be ‘K’.
 For the (K-2)th packet, acknowledgement number would be ‘K-1’ and so on.
 
Now,
 At any time, maximum number of outstanding packets can be ‘n’.
 This is because sender’s window size is ‘n’.
 Therefore, the possible values of acknowledgement number ranges from [K-n+1, ……,
K-3, K-2, K-1, K] (total n values)
 Here, we have assumed that the acknowledgement for all the packets are sent
independently.
 
Thus, Option (C) is correct.
Problem-03:
 
Station A needs to send a message consisting of 9 packets to station B using a sliding window
(window size 3) and go back n error control strategy. All packets are ready and immediately
available for transmission.
If every 5th packet that A transmits gets lost (but no ACKs from B ever get lost), then what is the
number of packets that A will transmit for sending the message to B?
1. 12
2. 14
3. 16
4. 18
 
Solution-
 
Given-
 Total number of packets to be sent = 9
 Go back N is used where N = 3
 Every 5th packet gets lost
 
Step-01:
 
 ince sender window size is 3, so sender sends 3 packets (1, 2, 3)-
 

Total packets sent till now from sender side = 3


 
Step-02:
 
After receiving the acknowledgement for packet-1, sender slides its window and sends packet-4.
 
Total packets sent till now from sender side = 4
 
Step-03:
 
After receiving the acknowledgement for packet-2, sender slides its window and sends packet-5.
 

Total packets sent till now from sender side = 5


 
Step-04:
 
After receiving the acknowledgement for packet-3, sender slides its window and sends packet-6.
 

Total packets sent till now from sender side = 6


 
Step-05:
 
After receiving the acknowledgement for packet-4, sender slides its window and sends packet-7.
 

Total packets sent till now from sender side = 7


 
Step-06:
 
 According to question, every 5th packet gets lost.
 So, packet-5 gets lost and when time out occurs, sender retransmits packet-5.
 In Go back N, all the following packets are also discarded by the receiver.
 So, packet-6 and packet-7 are discarded by the receiver and they are also retransmitted.
 Thus, the entire window is retransmitted.
 
So, we have-

Total packets sent till now from sender side = 10


 
Now, the next 5th packet that will be lost will be packet-7. (6, 7, 5, 6, 7)
 
Step-07:
 
After receiving the acknowledgement for packet-5, sender slides its window and sends packet-8.
 

Total packets sent till now from sender side = 11


 
Step-08:
 
After receiving the acknowledgement for packet-6, sender slides its window and sends packet-9.
 

Total packets sent till now from sender side = 12


 
Step-09:
 
 According to question, every 5th packet gets lost.
 So, packet-7 gets lost and when time out occurs, sender retransmits packet-7 and the
following packets.
 Thus, the entire window is retransmitted.
 
So, we have-

Total packets sent till now from sender side = 15


 
Now, the next 5th packet that will be lost will be packet-9. (8, 9, 7, 8, 9)
 
Step-10:
 
After receiving the acknowledgement for packet-7, sender slides its window.
 

Total packets sent till now from sender side = 15


 
Step-11:
 
After receiving the acknowledgement for packet-8, sender slides its window.
 

Total packets sent till now from sender side = 15


 
Step-12:
 
 According to question, every 5th packet gets lost.
 So, packet-9 gets lost and when time out occurs, sender retransmits packet-9.
 
So, we have-

Total packets sent till now from sender side = 16


 
Finally, all the 9 packets got transmitted which took total 16 number of transmissions.
Thus, Correct Option is (C).
 
Problem-04:
 
In Go back 4, if every 6th packet that is being transmitted is lost and if total number of packets to
be sent is 10, then how many transmissions will be required?
 
Solution-
 
 Try yourself!
 We have to solve in exactly the same way as we have solved Problem-03.
 Total number of transmissions required will be 17.
 
Problem-05:
 
A 1 Mbps satellite link connects two ground stations. The altitude of the satellite is 36504 km
and speed of the signal is 3 x 108 m/sec. What should be the packet size for a channel utilization
of 25% for a satellite link using go back 127 sliding window protocol?
1. 120 bytes
2. 60 bytes
3. 240 bytes
4. 90 bytes
 
Solution-
 
Given-
 Bandwidth = 1 Mbps
 Distance = 2 x 36504 km = 73008 km
 Propagation speed = 3 x 108 m/sec
 Efficiency = 25% = 1/4
 Go back N is used where N = 127
 
Let the packet size be L bits.
 
Calculating Transmission Delay-
 
Transmission delay (Tt)
= Packet size / Bandwidth
= L bits / 1 Mbps
= L μsec
 
Calculating Propagation Delay-
 
Propagation delay (Tp)
= Distance / Speed
= (73008 x 103 m) / (3 x 108 m/sec)
= 24336 x 10-5 sec
= 243360 μsec
 
Calculating Value of ‘a’-
 
a = Tp / Tt
a = 243360 μsec / L μsec
a = 243360 / L
 
Calculating Packet Size-
 
Efficiency (η) = N / (1+2a)
Substituting the values, we get-
1/4 = 127 / (1 + 2 x 243360 / L)
1/4 = 127 x L / (L + 486720)
L + 486720 = 508 x L
507 x L = 486720
L = 960
 
From here, packet size = 960 bits or 120 bytes.
Thus, Correct Option is (A).
 
Problem-06:
 
Consider a network connecting two systems located 8000 km apart. The bandwidth of the
network is 500 x 106 bits per second. The propagation speed of the media is 4 x 106 meters per
second. It is needed to design a Go back N sliding window protocol for this network. The
average packet size is 107 bits. The network is to be used to its full capacity.
Assume that processing delays at nodes are negligible. Then, the minimum size in bits of the
sequence number field has to be ______ ?
 
Solution-
 
Given-
 Distance = 8000 km
 Bandwidth = 500 x 106 bps
 Propagation speed = 4 x 106 m/sec
 Packet size = 107 bits
 
Now,
 For using the network to its full capacity, Efficiency (η) = 1
 Efficiency (η) = 1 when sender window size = 1+2a
 
Calculating Transmission Delay-
 
Transmission delay (Tt)
= Packet size / Bandwidth
= 107 bits / (500 x 106 bits per sec)
= 1 / 50 sec
= 0.02 sec
 
Calculating Propagation Delay-
 
Propagation delay (Tp)
= Distance / Speed
= 8000 km / (4 x 106 m/sec)
= 2 sec
 
Calculating Value of ‘a’-
 
a = Tp / Tt
a = 2 sec / 0.02 sec
a = 100
 
Calculating Sender Window Size-
 
Sender window size
= 1 + 2a
= 1 + 2 x 100
= 201
 
Calculating Minimum Size Of Sequence Number Field-
 
Minimum number of bits required in the sequence number field
= ⌈log2(1+2a)⌉
= ⌈log2(201)⌉
= ⌈7.65⌉
=8
Thus, Minimum size of sequence number field = 8 bits.
 
Next Article-Selective Repeat Protocol
 
Get more notes and other study material of Computer Networks.

Selective Repeat Protocol-


 
Selective Repeat protocol or SR protocol is an implementation of a sliding window protocol.
The features and working of this protocol are explained in the following points-
 
Point-01:
 

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

 
In SR protocol,
 Sender window size = Receiver window size
 The size is of course greater than 1 otherwise the protocol will become Stop and Wait
ARQ.
 If n bits are available for sequence numbers, then-
Sender window size = Receiver window size = 2n/2 = 2n-1
 
Point-02:

SR protocol uses independent acknowledgements only.

 
In SR protocol,
 Receiver acknowledges each frame independently.
 As receiver receives a new frame from the sender, it sends its acknowledgement.
 
Point-03:
 

SR protocol does not accept the corrupted frames but does not silently discard them.

 
In SR protocol,
 If receiver receives a frame that is corrupted, then it does not silently discard that frame.
 Receiver handles the situation efficiently by sending a negative acknowledgement
(NACK).
 Negative acknowledgement allows early retransmission of the corrupted frame.

 It also avoids waiting for the time out timer to expire at the sender side to retransmit the
frame.
 
Point-05:
 
SR protocol accepts the out of order frames.

 
In SR protocol,
 Consider receiver receives a frame whose sequence number is not what the receiver
expects.
 Then, it does not discard that frame rather accepts it and keeps it in its window.
 
Point-06:
 

SR protocol requires sorting at the receiver’s side.

 
In SR protocol,
 Receiver window is implemented as a linked list.
 When receiver receives a new frame, it places the new frame at the end of the linked list.
 When the received frames are out of order, receiver performs the sorting.
 Sorting sorts the frames in the correct order.
 
Point-07:
 

SR protocol requires searching at the sender’s side.

 
In SR protocol,
 Receiver does not reject the out of order frames.
 Receiver accepts the out of order frames and sort them later.
 Thus, only the missing frame has to be sent by the sender.
 For sending the missing frame, sender performs searching and finds the missing frame.
 Then, sender selectively repeats that frame.
 Thus, only the selected frame is repeated and not the entire window.
 That is why, the protocol has been named as “Selective Repeat Protocol“.
 
Point-08:
 

SR protocol leads to retransmission of lost frames after expiry of time out timer.

 
In SR protocol,
 Consider a frame being sent to the receiver is lost on the way.
 Then, it is retransmitted only after time out timer expires for that frame at sender’s side.
 
Efficiency of SR Protocol-
 
Efficiency of any flow control protocol is given by-
 

Efficiency = Sender Window Size in Protocol / (1 + 2a)

 
In selective repeat protocol, if sender window size = N, then-
 

Efficiency of SR Protocol = N / (1 + 2a)

 
PRACTICE PROBLEMS BASED ON SELECTIVE REPEAT PROTOCOL-
 
Problem-01:
 
The maximum window size for data transmission using the selective repeat protocol with n bit
frame sequence numbers is-
1. 2n
2. 2n-1
3. 2n-1
4. 2n-2
 
Solution-
 
We know-
 With n bits, total number of sequence numbers possible = 2n.
 In SR Protocol, sender window size = receiver window size = W (say)
 
For any sliding window protocol to work without any problems,
 

Min Available Sequence Numbers


= Sender window size + Receiver window size

 
So, we have-
2n = W + W
2n = 2W
W = 2n-1
Therefore, maximum window size possible of sender and receiver = 2n-1
Thus, Option (B) is correct.
 
Problem-02:
 
In SR protocol, suppose frames through 0 to 4 have been transmitted. Now, imagine that 0 times
out, 5 (a new frame) is transmitted, 1 times out, 2 times out and 6 (another new frame) is
transmitted.
Problem-02:
 
In SR protocol, suppose frames through 0 to 4 have been transmitted. Now, imagine that 0 times
out, 5 (a new frame) is transmitted, 1 times out, 2 times out and 6 (another new frame) is
transmitted.
At this point, what will be the outstanding packets in sender’s window?
 
1. 341526
2. 3405126
3. 0123456
4. 654321
 
Solution-
 
In SR Protocol, only the required frame is retransmitted and not the entire window.
 
Step-01:
 
Frames through 0 to 4 have been transmitted-
4,3,2,1,0
 
Step-02:
 
0 times out. So, sender retransmits it-
0,4,3,2,1
 
Step-03:
 
5 (a new frame) is transmitted-
5,0,4,3,2,1
 
Step-04:
 
1 times out. So, sender retransmits it-
1,5,0,4,3,2
 
Step-05:
 
2 times out. So, sender retransmits it-
2,1,5,0,4,3
 
Step-06:
 
6 (another new frame) is transmitted-
6,2,1,5,0,4,3
 
Thus, Option (B) is correct.
 
Problem-03:
 
The selective repeat protocol is similar to Go back N except in the following way-
 
1. Frame Formats are similar in both the protocols
2. The sender has a window defining maximum number of outstanding frames in both the
protocols
3. Both uses piggybacked acknowledgements where possible and does not acknowledge
every frame explicitly.
4. Both uses piggyback approach that acknowledges the most recently received frame
 
Solution-
 
Also Read-Go back N Protocol
 
Option (A)-
 
 Both the protocols use the same frame formats because both are sliding window
protocols.
 The variation occurs only in the coding and implementation.
 
Option (B)-
 
 In both the protocols, sender has a window which defines the maximum number of
outstanding frames.
 
Option (C)-
 
 Both the protocols use piggybacked acknowledgements wherever possible.
 Sending acknowledgements along with the data are called as piggybacked
acknowledgements.
 But Go back N protocol uses cumulative acknowledgements and does not acknowledge
every frame explicitly.
 On the other hand, Selective repeat protocol acknowledges each frame independently.
 
Option (D)-
 
 Both the protocols use piggyback approach.
 Go back N acknowledges the most recently received frame by sending a cumulative
acknowledgement which includes the acknowledgement for previous packets too if any.
 On the other hand, Selective Repeat protocol acknowledges all the frames independently
and not only the recently received frame.
 
Thus, Options (C) and (D) are correct.
 
Problem-04:
 
Consider a 128 x 103 bits/sec satellited communication link with one way propagation delay of
150 msec. Selective Retransmission (repeat) protocol is used on this link to send data with a
frame size of 1 KB. Neglect the transmission time of acknowledgement. The minimum number
of bits required for the sequence number field to achieve 100% utilization is ________ .
 
Solution-
 
Given-
 Bandwidth = 128 x 103 bits/sec
 Propagation delay (Tp) = 150 msec
 Frame size = 1 KB
 
Now,
 To achieve 100% utilization, efficiency must be 100%.
 Efficiency is 100% when sender window size is optimal i.e. 1+2a
 
Calculating Transmission Delay-
 
Transmission delay (Tt)
= Frame size / Bandwidth
= 1 KB / (128 x 103 bits per sec)
= (1 x 210 x 8 bits) / (128 x 103 bits per sec)
= 64 msec
 
Calculating Value of ‘a’-
 
a = Tp / Tt
a = 150 msec / 64 msec
a = 2.34
 
Calculating Optimal Sender Window Size-
 
Optimal sender window size
= 1 + 2a
= 1 + 2 x 2.34
= ⌈5.68⌉
=6
 
Calculating Number Of Sequence Numbers Required-
 
In SR Protocol, sender window size and receiver window size are same.
So, sender window size = receiver window size = 6
 
Now,
For any sliding window protocol, minimum number of sequence numbers required
= Sender window size + Receiver window size
=6+6
= 12
 
Calculating Bits Required in Sequence Number Field-
 
To have 12 sequence numbers,
Minimum number of bits required in sequence number field
= ⌈log2(12)⌉
=4
 
Thus,
 Minimum number of bits required in sequence number field = 4
 With 4 bits, number of sequence numbers possible = 16
 We use only 12 sequence numbers and rest 4 remains unused.
 
Flow Control Protocols-
 
In computer networking, there are various flow control protocols-
Sliding Window Protocol-
 
 Sliding window protocol allows the sender to send multiple frames before needing the
acknowledgements.
 It is more efficient.
 
Read More-Sliding Window Protocol
 
Implementations-
 
Various implementations of sliding window protocol are-
1. Stop and Wait ARQ
2. Go back N
3. Selective Repeat
 
In this article, we will compare these sliding window protocols.
 
Comparison Table-

Stop and Wait


Go back N Selective Repeat Remarks
ARQ

Go back N and
Selective Repeat
Efficiency 1 / (1+2a) N / (1+2a) N / (1+2a) gives better
efficiency than Stop
and Wait ARQ.

Buffer requirement
in Selective Repeat
Sender Window Sender Window Sender Window is very large.
Size = 1 Size = N Size = N If the system does
Window Size Receiver Window Receiver Window not have lots of
Receiver Window
Size = 1 Size = N memory, then it is
Size = 1
better to choose Go
back N.

Selective Repeat
Minimum number of requires large
sequence numbers 2 N+1 2xN number of bits in
required sequence number
field.

Selective Repeat is
Retransmissions Only the lost Only the lost far better than Go
The entire window
required if a packet is packet is packet is back N in terms of
is retransmitted
lost retransmitted retransmitted retransmissions
required.
Bandwidth
requirement is high
because even if a Selective Repeat is
single packet is lost,
Bandwidth Bandwidth better than Go back
Bandwidth entire window has
requirement is requirement is N in terms of
Requirement to be retransmitted.
Low moderate bandwidth
Thus, if error rate is requirement.
high, it wastes a lot
of bandwidth.

High due to
Go back N is better
searching and
than Selective
CPU usage Low Moderate sorting required at
Repeat in terms of
sender and
CPU usage.
receiver side

Go back N is better
Complex as it
than Selective
Level of difficulty in requires extra logic
Low Moderate Repeat in terms of
Implementation and sorting and
implementation
searching
difficulty.

Sending cumulative
Uses cumulative acknowledgements
acknowledgements reduces the traffic
Uses independent Uses independent
(but may use in the network but if
Acknowledgements acknowledgement acknowledgement
independent it is lost, then the
for each packet for each packet
acknowledgements ACKs for all the
as well) corresponding
packets are lost.

Go back N and
Selective Repeat are
Type of Transmission Half duplex Full duplex Full duplex
better in terms of
channel usage.
 
 
Conclusions-
 
 Go back N is more often used than other protocols.
 SR protocol is less used because of its complexity.
 Stop and Wait ARQ is less used because of its low efficiency.
 Depending on the context and resources availability, Go back N or Selective Repeat is
employed.
 Selective Repeat and Stop and Wait ARQ are similar in terms of retransmissions.
 Go back N and Selective Repeat are similar in terms of efficiency if sender window sizes
are same.
 SR protocol may be considered as a combination of advantages of Stop and Wait ARQ
and Go back N.
 SR protocol is superior to other protocols but because of its complexity, it is less used.
 
Important Notes-
 
Note-01:
 
Protocols at data link layer like HDLC (Low level protocols) use Go back N.
This is because-
1. Bandwidth is high
2. CPU is very busy doing routing job
3. Error rate is low since out of order packets are not possible in wired medium
 
Note-02:
 
Protocols at transport layer like TCP (High level protocols) use selective repeat.
 
PRACTICE PROBLEMS BASED ON SLIDING WINDOW PROTOCOLS-
 
Problem-01:
 
If the bandwidth between the sender and receiver is sufficient, CPU and buffers are moderate,
then which flow control protocol would you suggest to use?
 
Solution-
 
The suggested protocol would be Go back N.
 
Problem-02:
 
If the bandwidth between the sender and receiver is moderate, CPU and buffers are sufficient,
then which flow control protocol would you suggest to use?
 
Solution-
 
The suggested protocol would be Selective Repeat.
 
Flow Control Protocols-
 
In computer networking, there are various flow control protocols-

 Stop and Wait Protocol


 Stop and Wait ARQ
 Go back N Protocol
 Selective Repeat Protocol
 
In this article, we will discuss practice problems based on these flow control protocols.
 
PRACTICE PROBLEMS BASED ON FLOW CONTROL PROTOCOLS-
 
Problem-01:
 
In what protocols is it possible for the sender to receive an acknowledgement for a packet that
falls outside its current window?
1. Stop and Wait
2. Selective Repeat
3. Go back N
4. All of the above
 
Solution-
 
 Delayed Acknowledgements fall outside the current window.
 They may occur in any of the flow control protocols and received by the sender.
 
Thus, correct option is (D).
 
Problem-02:
 
On a wireless link, the probability of packet error is 0.2. A stop and wait protocol is used to
transfer data across the link. The channel condition is assumed to be independent from
transmission to transmission. What is the average number of transmission attempts required to
transfer 100 packets?
1. 100
2. 125
3. 150
4. 200
 
Solution-
 
Method-01:
 
Given-
 Probability of packet error = 0.2
 We have to transfer 100 packets
 
Now,
 When we transfer 100 packets, number of packets in which error will occur = 0.2 x 100 =
20.
 Then, these 20 packets will have to be retransmitted.
 When we retransmit 20 packets, number of packets in which error will occur = 0.2 x 20 =
4.
 Then, these 4 packets will have to be retransmitted.
 When we retransmit 4 packets, number of packets in which error will occur = 0.2 x 4 =
0.8 ≅ 1.
 Then, this 1 packet will have to be retransmitted.
 
From here, average number of transmission attempts required = 100 + 20 + 4 + 1 = 125.
Thus, Option (B) is correct.
 
Method-02:
 

REMEMBER
If there are n packets to be transmitted and p is the probability of packet error, then-
Number of transmission attempts required
= n + np + np2 + np3 + …… + ∞
= n / (1-p)

 
Substituting the given values, we get-
Average number of transmission attempts required = 100 / (1-0.2) = 125.
Thus, Option (B) is correct.
 
Problem-03:
 
Compute the fraction of the bandwidth that is wasted on overhead (headers and retransmissions)
for a protocol on a heavily loaded 50 Kbps satellite channel with data frames consisting of 40
bits header and 3960 data bits. Assume that the signal propagation time from the earth to the
satellite is 270 msec. ACK frames never occur. NAK frames are 40 bits. The error rate for data
frames is 1% and the error rate for NAK frames is negligible.
1. 1.21 %
2. 2.12 %
3. 1.99 %
4. 1.71 %
 
Solution-
 
Consider 100 frames are being sent. Then, we have-
 
Useful Data Sent-
 
Since each frame contains 3960 data bits, so while sending 100 frames,
Useful data sent
= 100 x 3960 bits
= 396000 bits
 
Useless Data Sent / Overhead-
 
In general, overhead is due to headers, retransmissions and negative acknowledgements.
 
Now,
 The error rate for data frames is 1%, therefore out of 100 sent frames, error occurs in one
frame.
 This causes the negative acknowledgement to follow which causes the retransmission.
 
So, we have-
 Overhead due to headers = 100 x 40 bits = 400 bits.
 Overhead due to negative acknowledgement = 40 bits.
 Overhead due to retransmission = 40 bits header + 3960 data bits = 4000 bits.
 
From here,
Total overhead
= 400 bits + 40 bits + 4000 bits
= 8040 bits
 
Calculating Efficiency-
 
Efficiency (η) = Useful data sent / Total data sent
 
Here,
 Useful data sent = 396000 bits
 Total data sent = Useful data sent + Overhead = 396000 bits + 8040 bits = 404040 bits
 
Substituting the values, we get-
Efficiency (η)
= 396000 bits / 404040 bits
= 0.9801
 
Calculating Bandwidth Utilization-
 
Bandwidth Utilization
= Efficiency x Bandwidth
= 0.9801 x 50 Kbps
= 49.005 Kbps
 
Calculating Bandwidth Wasted-
 
Bandwidth wasted
= Bandwidth – Bandwidth Utilization
= 50 Kbps – 49.005 Kbps
= 0.995 Kbps
 
Calculating Fraction of Bandwidth Wasted-
 
Fraction of bandwidth wasted
= Wasted Bandwidth / Total Available Bandwidth
= 0.995 Kbps / 50 Kbps
= 0.0199
= 1.99 %
 
Thus, Option (C) is correct.
 
Error Detection in Computer Networks-
 
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-
 
Some popular error detection methods are-
 
1. Single Parity Check
2. Cyclic Redundancy Check (CRC)
3. Checksum
 
In this article, we will discuss about Single Parity Check.
 
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.
 
Steps Involved-
 
Error detection using single parity check involves the following steps-
 
Step-01:
 
At sender side,
 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.
 
Step-02:
 
 The newly formed code word (Original data + parity bit) is transmitted to the receiver.
 
Step-03:
 
At receiver side,
 Receiver receives the transmitted code word.
 The total number of 1’s in the received code word is counted.
 
Then, following cases are possible-
 If total number of 1’s is even and even parity is used, then receiver assumes that no error
occurred.
 If total number of 1’s is even and odd parity is used, then receiver assumes that error
occurred.
 If total number of 1’s is odd and odd parity is used, then receiver assumes that no error
occurred.
 If total number of 1’s is odd and even parity is used, then receiver assumes that error
occurred.
 
Parity Check Example-
 
Consider the data unit to be transmitted is 1001001 and even parity is used.
Then,
 
At Sender Side-
 
 Total number of 1’s in the data unit is counted.
 Total number of 1’s in the data unit = 3.
 Clearly, even parity is used and total number of 1’s is odd.
 So, parity bit = 1 is added to the data unit to make total number of 1’s even.
 Then, the code word 10010011 is transmitted to the receiver.
 
 
At Receiver Side-
 
 After receiving the code word, total number of 1’s in the code word is counted.
 Consider receiver receives the correct code word = 10010011.
 Even parity is used and total number of 1’s is even.
 So, receiver assumes that no error occurred in the data during the transmission.
 
Advantage-
 
 This technique is guaranteed to detect an odd number of bit errors (one, three, five and so
on).
 If odd number of bits flip during transmission, then receiver can detect by counting the
number of 1’s.
 
Also Read-Checksum
 
Limitation-
 
 This technique can not detect an even number of bit errors (two, four, six and so on).
 If even number of bits flip during transmission, then receiver can not catch the error.
 
EXAMPLE
 
 Consider the data unit to be transmitted is 10010001 and even parity is used.
 Then, code word transmitted to the receiver = 100100011
 Consider during transmission, code word modifies as 101100111. (2 bits flip)
 On receiving the modified code word, receiver finds the number of 1’s is even and even parity
is used.
 So, receiver assumes that no error occurred in the data during transmission though the data is
corrupted.
Error Detection in Computer Networks-
 

Error detection is a technique that is used to check if any error occurred in the data during the
transmission.

 
Some popular error detection methods are-

1. Single Parity Check


2. Cyclic Redundancy Check (CRC)
3. Checksum
 
In this article, we will discuss about Cyclic Redundancy Check (CRC).
 
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-
 

 
Thus, for the given CRC generator, the corresponding binary pattern is 11011011.
 
Properties Of CRC Generator-
 
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.
 
Steps Involved-
 
Error detection using CRC technique involves the following steps-
 
Step-01: Calculation Of CRC At Sender Side-
 
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.
 
Step-02: Appending CRC To Data Unit-
 
At sender side,
 The CRC is obtained after the binary division.
 The string of n 0’s appended to the data unit earlier is replaced by the CRC remainder.
 
Step-03: Transmission To Receiver-
 
 The newly formed code word (Original data + CRC) is transmitted to the receiver.
 
Step-04: 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.
 
Also Read-Parity Check
 
PRACTICE PROBLEMS BASED ON CYCLIC REDUNDANCY CHECK (CRC)-
 
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-
 
 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-
 
Now, the binary division is performed as-
From here, CRC = 1110.
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.
 
Problem-02:
 
A bit stream 10011101 is transmitted using the standard CRC method. The generator polynomial
is x3+1.
1. What is the actual bit string transmitted?
2. Suppose the third bit from the left is inverted during transmission. How will receiver
detect this error?
 
Solution-
 
Part-01:
 
 The generator polynomial G(x) = x3 + 1 is encoded as 1001.
 Clearly, the generator polynomial consists of 4 bits.
 So, a string of 3 zeroes is appended to the bit stream to be transmitted.
 The resulting bit stream is 10011101000.
 
Now, the binary division is performed as-
From here, CRC = 100.
Now,
 The code word to be transmitted is obtained by replacing the last 3 zeroes of
10011101000 with the CRC.
 Thus, the code word transmitted to the receiver = 10011101100.
 
Part-02:
 
According to the question,
 Third bit from the left gets inverted during transmission.
 So, the bit stream received by the receiver = 10111101100.
 
Now,
 Receiver receives the bit stream = 10111101100.
 Receiver performs the binary division with the same generator polynomial as-
From here,
 The remainder obtained on division is a non-zero value.
 This indicates to the receiver that an error occurred in the data during the transmission.
 Therefore, receiver rejects the data and asks the sender for retransmission.
 
Error Detection in Computer Networks-
 

Error detection is a technique that is used to check if any error occurred in the data during the
transmission.

 
Some popular error detection methods are-

1. Single Parity Check


2. Cyclic Redundancy Check (CRC)
3. Checksum
 
In this article, we will discuss about Checksum Method.
 
Checksum-
 
Checksum is an error detection method.
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.
 
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: Result = 0
 
If the result is zero,
 Receiver assumes that no error occurred in the data during the transmission.
 Receiver accepts the data.
 
Case-02: Result ≠ 0
 
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.
 
Checksum Example-
 
Consider the data unit to be transmitted is-
10011001111000100010010010000100
Consider 8 bit checksum is used.
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.
 
Also Read-Parity Check
 
Important Notes-
 
Note-01:
 
 Consider while adding the m bit segments, the result obtained consists of more than m
bits.
 Then, wrap around the extra bits and add to the result so that checksum value consists of
m bits.
 
Note-02:
 
 While calculating the checksum, if checksum value is needed, then assume it to be zero.
 After calculating the checksum value, substitute the checksum value in the checksum
field.
 This will be required during checksum calculation of IP Header, TCP Header and UDP
Header.
 
Note-03:
 
 The checksum is used in the internet by several protocols although not at the data link
layer.
 
Also Read-Cyclic Redundancy Check (CRC)
 
PRACTICE PROBLEM BASED ON CHECKSUM ERROR DETECTION METHOD-
 
Problem-
 
Checksum value of 1001001110010011 and 1001100001001101 of 16 bit segment is-
1. 1010101000011111
2. 1011111000100101
3. 1101010000011110
4. 1101010000111111
 
Solution-
 
We apply the above discussed algorithm to calculate the checksum.
 1001001110010011 + 1001100001001101 = 10010101111100000
 Since, the result consists of 17 bits, so 1 bit is wrapped around and added to the result.
 0010101111100000 + 1 = 0010101111100001
 Now, result consists of 16 bits.
 Now, 1’s complement is taken which is 1101010000011110
 Thus, checksum value = 1101010000011110
 
Types of Communication Links-
 
In computer networking,
 Communication links enable the stations to communicate with each other.
 Stations may communicate using the following types of links-
 

1. Point to Point Link


2. Broadcast Link
 
1. Point to Point Link-
 
 Point to Point link is a dedicated link that exists between the two stations.
 The entire capacity of the link is used for transmission between the two connected
stations only.
 Depending upon the Type Of Channel, the data flow takes place between the stations.
 
Example-
Example-
 

 
2. Broadcast Link-
 
 Broadcast link is a common link to which multiple stations are connected.
 The capacity of the link is shared among the connected stations for transmission.
 
Example-

Access Control-
 

Access Control is a mechanism that controls the access of stations to the transmission link.

 
 Broadcast links require the access control.
 This is because the link is shared among several stations.
 
Need of Access Control-
 
To prevent the occurrence of collision or if the collision occurs, to deal with it.

 
Consider a situation where-
 Multiple stations place their data packets on the link and starts transmitting
simultaneously.
 Such a situation gives rise to a collision among the data packets.
 Collision of data packets causes the data to get corrupt.
 
Example-
 
Consider the following scenario-

Here,
 Two stations A and D starts transmitting their data packets simultaneously.
 This situation gives rise to a collision between the data packets transmitted by them.
 Thus, to prevent the collision or to deal with it, access control is needed.
 
Access Control Methods-
 

Access control methods are the methods used for providing access control.

 
 They prevent the collision or deal with it and ensures smooth flow of traffic on the
network.
 They are implemented at the data link layer of the OSI reference model.
 
Various access control methods used are-

1. Time Division Multiplexing


2. Polling
3. CSMA / CD
4. Token Passing
5. Aloha

Time Division Multplexing


 Time of the link is devided into fixed size intervals called time slots or time slices
 Time slots are allocated to the stations in round Robin manner
 Each station transmit its data during the time slot allocated to it.
 In case, station does not have any data to send, its time slot goes waste
Example-
Size Of Time Slots-
 
The size of each time slot is kept such that each station gets sufficient time for the following
tasks-
 To put its data packet on to the transmission link
 Last bit of the packet is able to get out of the transmission link
 
Thus,
 

Size of each time slot = Tt + Tp

 
where-
 Tt = Transmission delay
 Tp = Propagation delay
 
NOTE-
 
To keep the size of time slots constant,
 We have assumed that all the stations want to send the packets of same size.
 This keeps Tt constant for all the stations.
 We have considered the worst case when both the stations are present at the two extreme
ends.
 This ensures Tp will be maximum and all the stations will get sufficient time to propagate
their data.
 
Efficiency-

Efficiency (η) = Useful Time / Total Time

 
 Useful time = Transmission delay of data packet = Tt
 Useless time = Propagation delay of data packet = Tp
 
Thus,
 

 
Important Formulas-
 
 Size of each time slot in Time Division Multiplexing = Tt + Tp
 Efficiency (η) = 1 / (1+a) where a = Tp / Tt
 Effective Bandwidth / Bandwidth Utilization / Throughput = Efficiency(η) x Bandwidth
 Maximum Available Effective Bandwidth = Total number of stations x Bandwidth
requirement of 1 station
 
Disadvantage-
 
 If any station does not have the data to send during its time slot, then its time slot goes
waste.
 This reduces the efficiency.
 This time slot could have been allotted to some other station willing to send data.
 
PRACTICE PROBLEM BASED ON TIME DIVISION MULTIPLEXING (TDM)-
 
Problem-
 
If transmission delay and propagation delay of a packet in Time Division Multiplexing is 1 msec
each at 4 Mbps bandwidth, then-
1. Find the efficiency.
2. Find the effective bandwidth.
3. How many maximum stations can be connected to the network if each station requires 2
Kbps bandwidth?
 
Solution-
Given-
 Transmission delay (Tt) = 1msec
 Propagation delay (Tp) = 1msec
 Bandwidth = 4 Mbps
 
Part-01:
 
For a TDM Network,

Efficiency (η) = 1 / 1+a where a = Tp / Tt

 
Calculating Value Of ‘a’-
 
a = Tp / Tt
a = 1 msec / 1 msec
a=1
 
Calculating Efficiency-
 
Efficiency (η)
= 1 / (1+a)
= 1 / (1 + 1)
=1/2
= 0.5
= 50%
Part-02:
 
We know-
 

Effective Bandwidth = Efficiency (η) x Bandwidth

 
Thus,
Effective Bandwidth
= 0.5 x 4 Mbps
= 2 Mbps
 
Part-03:
 
We know-
 

Maximum Effective Bandwidth


= Total number of stations x Bandwidth requirement of 1 station

 
et the total number of stations that can be connected be N.
Then, we have-
2 Mbps = N x 2 Kbps
N = 1000
Thus, maximum 1000 stations can be connected.
 
Polling-
 
In this access control method,
 A polling is conducted in which all the stations willing to send data participates.
 The polling algorithm chooses one of the stations to send the data.
 The chosen station sends the data to the destination.
 After the chosen station has sent the data, the cycle repeats.
 
Example-
Here-
 Tpoll = Time taken for polling
 Tsend = Time taken for sending the data = Transmission delay + Propagation delay = Tt +
Tp
 
Efficiency-
 

Efficiency (η) = Useful Time / Total Time

 
 Useful time = Transmission delay of data packet = Tt
 Useless time = Time wasted during polling + Propagation delay of data packet = Tpoll + Tp
 
Thus,
Thus,
 

 
Advantages-
 
 Unlike in Time Division Multiplexing, no slot is ever wasted.
 It leads to maximum efficiency and bandwidth utilization.
 
Disadvantages-
 
 Time is wasted during polling.
 Link sharing is not fair since each station has the equal probability of winning in each
round.
 Few stations might starve for sending the data.
 
Important Formulas-
 
 Efficiency (η) = Tt / (Tpoll + Tt + Tp)
 Effective Bandwidth / Bandwidth Utilization / Throughput = Efficiency(η) x Bandwidth
 Maximum Available Effective Bandwidth = Total number of stations x Bandwidth
requirement of 1 station
Access Control in Networking-
 
Before you go through this article, make sure that you have gone through the previous article
on Access Control.
We have discussed-
 Access Control is a mechanism that controls the access of stations to the transmission
link.
 Broadcast links require the access control mechanism.
 There are various access control methods-
 

1. Time Division Multiplexing


2. Polling
3. CSMA / CD
4. Token Passing
5. Aloha
 
In this article, we will discuss about CSMA / CD.
CSMA / CD
This access control method works as follows-
 
Step-01: Sensing the Carrier-
 
 Any station willing to transmit the data senses the carrier.
 If it finds the carrier free, it starts transmitting its data packet otherwise not.
 
How?
 
 Each station can sense the carrier only at its point of contact with the carrier.
 It is not possible for any station to sense the entire carrier.
 Thus, there is a huge possibility that a station might sense the carrier free even when it is
actually not.
 
Example-
 
Consider the following scenario-
 

At the current instance,


 If station A senses the carrier at its point of contact, then it will find the carrier free.
 But the carrier is actually not free because station D is already transmitting its data.
 If station A starts transmitting its data now, then it might lead to a collision with the data
transmitted by station D.
 
Step-02: Detecting the Collision-
 
In CSMA / CD,
 It is the responsibility of the transmitting station to detect the collision.
 For detecting the collision, CSMA / CD implements the following condition.
 This condition is followed by each station-
 
Transmission delay >= 2 x Propagation delay

 
Meaning-
 
According to this condition,
 Each station must transmit the data packet of size whose transmission delay is at least
twice its propagation delay.
 If the size of data packet is smaller, then collision detection would not be possible.
 
Length Of Data Packet-
 
We know-
 Transmission delay = Length of data packet (L) / Bandwidth (B)
 Propagation delay = Distance between the two stations (D) / Propagation speed (V)
 
Substituting values in the above condition, we get-
L / B >= 2 x D / V
Thus,
 

L >= 2 x B x D / V

 
Understanding the Condition To Detect Collision With Example
 
 Consider at time 10:00 am, station A senses the carrier.
 It finds the carrier free and starts transmitting its data packet to station D.
 Let the propagation delay be 1 hour.
(We are considering station D for the worst case)
 

 
 Let us consider the scenario at time 10:59:59:59 when the packet is about to reach the station
D.
 At this time, station D senses the carrier.
 It finds the carrier free and starts transmitting its data packet.
 Now, as soon as station D starts transmitting its data packet, a collision occurs with the data
packet of station A at time 11:00 am.
 

 
 After collision occurs, the collided signal starts travelling in the backward direction.
 The collided signal takes 1 hour to reach the station A after the collision has occurred.
 For station A to detect the collided signal, it must be still transmitting the data.
 So, transmission delay of station A must be >= 1 hour + 1 hour >= 2 hours to detect the
collision.
 That is why, for detecting the collision, condition is Tt >= 2Tp.

 
Two cases are possible-
 
Case-01:
 
If no collided signal comes back during the transmission,
 It indicates that no collision has occurred.
 The data packet is transmitted successfully.
 
Case-02:
 
If the collided signal comes back during the transmission,
 It indicates that the collision has occurred.
 The data packet is not transmitted successfully.
 Step-03 is followed.
 
Step-03: Releasing Jam Signal-
 
 Jam signal is a 48 bit signal.
 It is released by the transmitting stations as soon as they detect a collision.
 It alerts the other stations not to transmit their data immediately after the collision.
 Otherwise, there is a possibility of collision again with the same data packet.
 Ethernet sends the jam signal at a frequency other than the frequency of data signals.
 This ensures that jam signal does not collide with the data signals undergone collision.
 
Step-04: Waiting For Back Off Time-
 
 After the collision, the transmitting station waits for some random amount of time called
as back off time.
 After back off time, it tries transmitting the data packet again.
 If again the collision occurs, then station again waits for some random back off time and
then tries again.
 The station keeps trying until the back off time reaches its limit.
 After the limit is reached, station aborts the transmission.
 Back off time is calculated using Back Off Algorithm.
 
CSMA / CD Flowchart-
 
The following CSMA / CD flowchart represents the CSMA / CD procedure-
Efficiency-
 

Efficiency (η) = Useful Time / Total Time

 
Before a successful transmission,
 There may occur many number of collisions.
 2 x Tp time is wasted during each collision.
 
Thus,
 Useful time = Transmission delay of data packet = Tt
 Useless time = Time wasted during collisions + Propagation delay of data packet = c x 2
x Tp + Tp
 Here, c = Number of contention slots / collision slots.
 
Thus,
 

 
Here,
 c is a variable.
 This is because number of collisions that might occur before a successful transmission
are variable.
 
Probabilistic Analysis shows-
 

Average number of collisions before a successful transmission = e

 
Substituting c = e in the above relation, we get-
 
 
Probabilistic Analysis-
 
Let us perform the probabilistic analysis to find the average number of collisions before a
successful transmission.
 
Consider-
 Number of stations connected to a CSMA / CD network = n
 Probability of each station to transmit the data = p
 
 
Transmission will be successful only when-
 One station transmits the data
 Other (n-1) stations do not transmit the data.
 
Thus, Probability of successful transmission is given by-
 

 
Now, let us find the maximum value of Psuccessful transmission.
For maximum value, we put-
 

 
On solving,
 

At p = 1/n, we get the maximum value of Psuccessful transmission

 
Thus,
(Psuccessful transmission)max
= nC1 x 1/n x (1 – 1/n)n-1
= n x 1/n x (1 – 1/n)n-1
= (1 – 1/n)n-1
 

(Psuccessful transmission)max = (1 – 1/n)n-1

 
If there are sufficiently large number of stations i.e. n → ∞, then we have-
 

 
Number of times a station must try before successfully transmitting the data packet
= 1 / Pmax (Using Poisson’s distribution)
= 1 / (1/e)
=e
 
From here, we conclude-
Average number of collisions that might occur before a successful transmission = e
 
Important Notes-
 
Note-01:
 
 CSMA / CD is used in wired LANs.
 CSMA / CD is standardized in IEEE 802.3
 
Note-02:
 
 CSMA / CD only minimizes the recovery time.
 It does not take any steps to prevent the collision until it has taken place.
 
Important Formulas-
 
 Condition to detect collision: Transmission delay >= 2 x Propagation delay
 Minimum length of data packets in CSMA / CD = 2 x Bandwidth x Distance / Speed
 Efficiency of CSMA / CD = 1 / (1 + 6.44 x a) where a = Tp / Tt
 Probability of successful transmission = nC1 x p x (1-p)n-1
 Average number of collisions before a successful transmission = e
 

CSMA / CD Protocol-
 
Before you go through this article, make sure that you have gone through the previous
article on CSMA / CD Protocol.
We have discussed-

 CSMA / CD stands for Carrier Sense Multiple Access / Collision Detection.


 It allows the stations to sense the carrier and transmit data if the carrier is free.
 
The following CSMA / CD flowchart shows the CSMA / CD procedure-
 
 
Back Off Time-
 
In CSMA / CD protocol,

 After the occurrence of collision, station waits for some random back off time and
then retransmits.
 This waiting time for which the station waits before retransmitting the data is called
as back off time.
 Back Off Algorithm is used for calculating the back off time.
 

Back Off Algorithm-


 
After undergoing the collision,

 Transmitting station chooses a random number in the range [0, 2n-1] if the packet is
undergoing collision for the nth time.
 If station chooses a number k, then-
 

Back off time = k x Time slot

where value of one time slot = 1 RTT


 

Example-
 
Consider the following scenario where stations A and D start transmitting their data
simultaneously-
 

 
For simplicity,

 We consider the value of time slot = 1 unit.


 Thus, back off time = K units.
 

Scene-01: For 1st Data Packet Of Both Stations-


 

 Both the stations start transmitting their 1st data packet simultaneously.


 This leads to a collision.
 Clearly, the collision on both the packets is occurring for the 1st time.
 So, collision number for the 1st data packet of both the stations = 1.
 

At Station A-
 
After detecting the collision,

 Station A randomly chooses a number in the range [0, 21-1] = [0,1].


 If station A chooses the number KA, then back off time = KA units.
 

At Station D-
 
After detecting the collision,

 Station D randomly chooses a number in the range [0, 21-1] = [0,1].


 If station D chooses the number KD, then back off time = KD units.
 
Following 4 cases are possible-
 

KA KD Remarks

 In this case, both the stations start retransmitting their data


0 0 immediately.
 This case leads to a collision again.
 In this case, station A starts retransmitting its data
immediately while station D waits for 1 unit of time.
0 1
 This case leads to A successfully retransmitting its data
after the 1st collision.

 In this case, station A waits for 1 unit of time while station D


starts retransmitting its data immediately.
1 0
 This case leads to D successfully retransmitting its data
after the 1st collision.

 In this case, both the stations wait for 1 unit of time and
1 1 then starts retransmitting their data simultaneously.
 This case leads to a collision again.

 
From here,

 Probability of station A to successfully retransmit its data after the 1st collision = 1 / 4


 Probability of station D to successfully retransmit its data after the 1st collision = 1 / 4
 Probability of occurrence of collision again after the 1st collision = 2 / 4 = 1 / 2
 
Now,

 Consider case-02 occurs.


 This causes station A to successfully retransmit its 1st packet after the 1st collision.
 

Scene-02: For 2nd Data Packet Of Station A And 1st


Data Packet Of Station D-
 
Consider after some time,

 Station A starts transmitting its 2nd data packet and station D starts retransmitting its
st
1  data packet simultaneously.
 This leads to a collision.
 

At Station A-
 

 The 2nd data packet of station A undergoes collision for the 1st time.


 So, collision number for the 2nd data packet of station A = 1.
 Now, station A randomly chooses a number in the range [0, 21-1] = [0,1].
 If station A chooses the number KA, then back off time = KA units.
 

At Station D-
 

 The 1st data packet of station D undergoes collision for the 2nd time.


 So, collision number for the 1st data packet of station D = 2.
 Now, station D randomly chooses a number in the range [0, 22-1] = [0,3].
 If station D chooses the number KD, then back off time = KD units.
 
Following 8 cases are possible-
 

KA KD Remarks

 In this case, both the stations start retransmitting their


0 0 data immediately.
 This case leads to a collision again.

 In this case, station A starts retransmitting its data


immediately while station D waits for 1 unit of time.
0 1
 This case leads to A successfully retransmitting its data
after the 2nd collision.

 In this case, station A starts retransmitting its data


immediately while station D waits for 2 unit of time.
0 2
 This case leads to A successfully retransmitting its data
after the 2nd collision.

 In this case, station A starts retransmitting its data


immediately while station D waits for 3 unit of time.
0 3
 This case leads to A successfully retransmitting its data
after the 2nd collision.

1 0  In this case, station A waits for 1 unit of time while


station D starts retransmitting its data immediately.
 This case leads to D successfully retransmitting its data
after the 2nd collision.

 In this case, both the stations wait for 1 unit of time and
1 1 then starts retransmitting their data simultaneously.
 This case leads to a collision again.

 In this case, station A waits for 1 unit of time while


station D waits for 2 unit of time.
1 2
 This case leads to A successfully retransmitting its data
after the 2nd collision.

 In this case, station A waits for 1 unit of time while


station D waits for 3 unit of time.
1 3
 This case leads to A successfully retransmitting its data
after the 2nd collision.

 
From here,

 Probability of station A to successfully retransmit its data after the 2nd collision = 5 / 8


 Probability of station D to successfully retransmit its data after the 2nd collision = 1 / 8
 Probability of occurrence of collision again after the 2nd collision = 2 / 8 = 1 / 4
 
Now,

 Consider case-03 occurs.


 This causes station A to successfully retransmit its 2nd packet after the 2nd collision.
 

Scene-03: For 3rd Data Packet Of Station A And 1st


Data Packet Of Station D-
 
Consider after some time,

 Station A starts transmitting its 3rd data packet and station D starts retransmitting its
1st data packet simultaneously.
 This leads to a collision.
 

At Station A-
 

 The 3rd data packet of station A undergoes collision for the 1st time.


 So, collision number for the 3rd data packet of station A = 1.
 Now, station A randomly chooses a number in the range [0, 21-1] = [0,1].
 If station A chooses the number KA, then back off time = KA unit.
 

At Station D-
 

 The 1st data packet of station D undergoes collision for the 3rd time.


 So, collision number for the 1st data packet of station D = 3.
 Now, station D randomly chooses a number in the range [0, 23-1] = [0,7].
 If station D chooses the number KD, then back off time = KD unit.
 
Following 16 cases are possible-
 

KA KD Remarks

 In this case, both the stations start retransmitting their


0 0 data immediately.
 This case leads to a collision again.

 In this case, station A starts retransmitting its data


immediately while station D waits for 1 unit of time.
0 1
 This case leads to A successfully retransmitting its data
after the 3rd collision.

 In this case, station A starts retransmitting its data


immediately while station D waits for 2 unit of time.
0 2
 This case leads to A successfully retransmitting its data
after the 3rd collision.

 In this case, station A starts retransmitting its data


immediately while station D waits for 3 unit of time.
0 3
 This case leads to A successfully retransmitting its data
after the 3rd collision.
 In this case, station A starts retransmitting its data
immediately while station D waits for 4 unit of time.
0 4
 This case leads to A successfully retransmitting its data
after the 3rd collision.

 In this case, station A starts retransmitting its data


immediately while station D waits for 5 unit of time.
0 5
 This case leads to A successfully retransmitting its data
after the 3rd collision.

 In this case, station A starts retransmitting its data


immediately while station D waits for 6 unit of time.
0 6
 This case leads to A successfully retransmitting its data
after the 3rd collision.

 In this case, station A starts retransmitting its data


immediately while station D waits for 7 unit of time.
0 7
 This case leads to A successfully retransmitting its data
after the 3rd collision.

 In this case, station A waits for 1 unit of time while station


D starts retransmitting its data immediately.
1 0
 This case leads to D successfully retransmitting its data
after the 3rd collision.

 In this case, both the stations wait for 1 unit of time and
1 1 then starts retransmitting their data simultaneously.
 This case leads to a collision again.

 In this case, station A waits for 1 unit of time while station


D waits for 2 unit of time.
1 2
 This case leads to A successfully retransmitting its data
after the 3rd collision.

 In this case, station A waits for 1 unit of time while station


D waits for 3 unit of time.
1 3
 This case leads to A successfully retransmitting its data
after the 3rd collision.
 In this case, station A waits for 1 unit of time while station
D waits for 4 unit of time.
1 4
 This case leads to A successfully retransmitting its data
after the 3rd collision.

 In this case, station A waits for 1 unit of time while station


D waits for 5 unit of time.
1 5
 This case leads to A successfully retransmitting its data
after the 3rd collision.

 In this case, station A waits for 1 unit of time while station


D waits for 6 unit of time.
1 6
 This case leads to A successfully retransmitting its data
after the 3rd collision.

 In this case, station A waits for 1 unit of time while station


D waits for 7 unit of time.
1 7
 This case leads to A successfully retransmitting its data
after the 3rd collision.

 
From here,

 Probability of station A to successfully retransmit its data after the 3rd collision = 13 /


16
 Probability of station D to successfully retransmit its data after the 3rd collision = 1 /
16
 Probability of occurrence of collision again after the 3rd collision = 1 / 16
 
In the similar manner, the procedure continues.
 

Important Notes-
 

Note-01:
 
With each successive collision-

 Back off time increases exponentially.


 Collision probability decreases exponentially.
 

Note-02:
 
Back Off Algorithm is also known as Binary Exponential Back Off Algorithm because-

 It works for only two stations.


 The back off time increases exponentially.
 Collision probability decreases exponentially.
 

Note-03:
 

 One disadvantage of Back Off Algorithm is that it shows capture effect.


 It means if a particular station wins the collision one time, then its probability of
winning the successive collisions increases exponentially.
 

Access Control in Networking-


 
Before you go through this article, make sure that you have gone through the previous
article on Access Control.
We have discussed-

 Access Control is a mechanism that controls the access of stations to the


transmission link.
 Broadcast links require the access control mechanism.
 There are various access control methods-
 
 
1. Time Division Multiplexing
2. Polling
3. CSMA / CD
4. Token Passing
5. Aloha
 
In this article, we will discuss about Token Passing.
 
Before discussing Token Passing, let us discuss few important concepts required for
thediscussion.

Time Conversions-
 
In token passing,

 Time may be expressed in seconds, bits or meters.


 To convert the time from one unit to another, we use the following conversion chart-
 
 
Conversion Chart
 

Token Passing Terminology-


 
The following terms are frequently used-
1. Token
2. Ring Latency
3. Cycle Time
 

1. Token-
 

 A token is a small message composed of a special bit pattern.


 It represents the permission to send the data packet.
 A station is allowed to transmit a data packet if and only if it possess the token
otherwise not.
 

2. Ring Latency-
 

Time taken by a bit to complete one revolution of the ring is called as ring latency.

 
 
Let us derive the expression for ring latency.
If-

 Length of the ring = d


 Speed of the bit = v
 Number of stations = N
 Bit delay at each station = b
(Bit delay is the time for which a station holds the bit before transmitting to the other side)
Then-
 
 

Notes-
 

 d / v is the propagation delay (Tp) expressed in seconds.


 Generally, bit delay is expressed in bits.
 So, both the terms (d / v and N x b) have different units.
 While calculating the ring latency, both the terms are brought into the same unit.
 The above conversion chart is used for conversion.
 
After conversion, we have-
 

3. Cycle Time-
 
Time taken by the token to complete one revolution of the ring is called as cycle time.

 
If-

 Length of the ring = d


 Speed of the bit = v
 Number of stations = N
 Token Holding Time = THT
(Token Holding Time is the time for which a station holds the token before transmitting to
the other side)
Then-
 

 
Now, we start discussing about Token Passing Access Control Method.
 

Token Passing-
 
In this access control method,

 All the stations are logically connected to each other in the form of a ring.
 The access of stations to the transmission link is governed by a token.
 A station is allowed to transmit a data packet if and only if it possess the token
otherwise not.
 Each station passes the token to its neighboring station either clockwise or anti-
clockwise.
 
 

Assumptions-
 
Token passing method assumes-

 Each station in the ring has the data to send.


 Each station sends exactly one data packet after acquiring the token.
 

Efficiency-
 

Efficiency (η) = Useful Time / Total Time

 
In one cycle,

 Useful time = Sum of transmission delay of N stations since each station sends 1
data packet = N x Tt
 Total Time = Cycle time = Tp + N x THT
Thus,
 
 
Token Holding Time depends on the strategy implemented.
 

Token Passing Strategies-


 
The following 2 strategies are used in token passing-
 

 
1. Delayed Token Reinsertion (DTR)
2. Early Token Reinsertion (ETR)
 

1. Delayed Token Reinsertion-


 
In this strategy,

 Station keeps holding the token until the last bit of the data packet transmitted by it
takes the complete revolution of the ring and comes back to it.
 

Working-
 
After a station acquires the token,
 It transmits its data packet.
 It holds the token until the data packet reaches back to it.
 After data packet reaches to it, it discards its data packet as its journey is completed.
 It releases the token.
 
The following diagram illustrates these steps for station-1. Same procedure is repeated at
every station.
 

Token Holding Time-


 

Token Holding Time (THT) = Transmission delay + Ring Latency

 
We know,

 Ring Latency = Tp + N x bit delay


 Assuming bit delay = 0 (in most cases), we get-
 

Token Holding Time = Tt + Tp

Efficiency-
 
Substituting THT = Tt + Tp in the efficiency expression, we get-
 
 

2. Early Token Reinsertion-


 
In this strategy,
 Station releases the token immediately after putting its data packet to be transmitted
on the ring.
 

Working-
 

Step-01: At Station-1:
 
Station-1

 Acquires the token


 Transmits packet-1
 Releases the token
 
Step-02: At Station-2:
 
Station-2

 Receives packet-1
 Transmits packet-1
 Acquires the token
 Transmits packet-2
 Releases the token
 
Step-03: At Station-3:
 
Station-3

 Receives packet-1
 Transmits packet-1
 Receives packet-2
 Transmits packet-2
 Acquires the token
 Transmits packet-3
 Releases the token
 
Step-04: At Station-4:
 
Station-4

 Receives packet-1
 Transmits packet-1
 Receives packet-2
 Transmits packet-2
 Receives packet-3
 Transmits packet-3
 Acquires the token
 Transmits packet-4
 Releases the token
 
Step-05: At Station-1:
 

 Receives packet-1
 Discards packet-1 (as its journey is completed)
 Receives packet-2
 Transmits packet-2
 Receives packet-3
 Transmits packet-3
 Receives packet-4
 Transmits packet-4
 Acquires the token
 Transmits packet-1 (new)
 Releases the token
PRACTICE PROBLEMS BASED ON TOKEN RING AND
TOKEN PASSING-
 
Before you go through this article, make sure that you have gone through the previous
article on Token Passing.

Problem-01:
 
Token ring station operates in which of the following modes?
1. Transit mode
2. Listen mode
3. Bypass mode and Receive mode
4. All of the above
 

Solution-
 

 In transmit mode, a station transmits the data.


 In listen mode, a station listens from other station(s).
 In bypass mode, a station simply bypasses the data packet if it is not meant for it.
 In receive mode, a station receives the data packet if it is destined to it.
Therefore, a token ring station operates in all these modes.
Thus, Option (D) is correct.
 

Problem-02:
 
Efficiency of the token ring is high if-
1. Reinsert the token after receiving the last bit of the frame
2. Reinsert the token after receiving the last bit of the header
3. Reinsert the token after last bit of the data packet is transferred
4. Reinsert the token after last bit of the header is transferred
 

Solution-
 

 There are two strategies used in token ring- Early Token Reinsertion (ETR) and
Delayed Token Reinsertion (DTR).
 Efficiency of token ring is high in Early Token Reinsertion (ETR).
Thus, Option (C) is correct.
 

Problem-03:
 
The sending station in IEEE 802.5 sets the address recognized (A) bit and frame copied (C)
bit in MAC header as
1. 1,0
2. 0,0
1. 0,1
2. 1,1
 

Solution-
 

 IEEE 802.5 is token ring.


 Sending station sets both the available bit and copied bit as 0.
 These bits are modified by the receiving station.
 If the receiving station is available, it sets the Available bit to 1.
 If the receiving station successfully copies the data, it sets the Copied bit to 1.
Thus, Option (B) is correct.
 

Problem-04:
 
Which of the following fields in 802.5 MAC header is not included in CRC or FCS?
1. FC
2. Data field
3. FS
4. SA
 

Solution-
 

 IEEE 802.5 is token ring.


 Frame Status (FS) field consists of the Available bit and Copied bit.
 These two bits are modified by the receiving station.
 So, CRC is not computed on Frame Status field otherwise receiving station will have
to bear the overhead of recomputing the CRC.
Thus, Option (C) is correct.
 

Problem-05:
 
What type of acknowledgement system is used in 802.5?
1. Cumulative ACK
2. Independent ACK
3. Piggybacking ACK
4. None
 

Solution-
 

 IEEE 802.5 is token ring.


 The two bits- Available bit and Copied bit acts as the acknowledgement for the
sending station.
 The value of these bits suggests to the sending station that whether the receiving
station has successfully copied the data or not.
 Because the two bits are contained in the data frame, so we can say that
piggybacked acknowledgements are used in token ring.
Thus, Option (C) is correct.
 

Problem-06:
 
In token ring, ______ field is present only in the data / command frame but not in the token
frame.
1. SD
2. AC
3. ED
4. FS
 

Solution-
 

 Frame status (FS) field is present only in the data / command frame.
 A token frame consists of only 3 fields- SD, AC and ED.
Thus, Option (D) is correct.
 

Problem-07:
 
Consider a token ring with latency 500 μsec and packet size of 1500 bytes. What is the
effective throughput rate for both single active host and for many active hosts that can be
achieved if the ring has 3 Mbps bandwidth? Assume the strategy used is delayed token
reinsertion.
1. 2.4 Mbps and 3 Mbps
2. 2.4 Mbps and 2 Mbps
3. 2 Mbps and 3 Mbps
4. 2.4 Mbps and 2.67 Mbps
 

Solution-
 
Given-

 Ring latency = 500 μsec


 Packet Size = 1500 bytes
 Bandwidth = 3 Mbps
 Strategy used is Delayed Token Reinsertion (DTR)
 
Efficiency of Delayed Token Reinsertion (DTR) strategy is-
 
Efficiency of Delayed Token Reinsertion (DTR) strategy is-
 

Calculating Transmission delay-


 
We know,
Transmission delay (Tt)
= Packet size / Bandwidth
= 1500 bytes / 3 Mbps
= (1500 x 8 bits) / (3 x 106 bits per sec)
= 4000 μsec
 

Calculating value of ‘a’-


 
We know,
a = Tp / Tt
a = Latency / Tt
a = 500 μsec / 4000 μsec
a = 0.125
 

Calculating Throughput for single active host-


 
For single active host, N = 1.
Substituting N = 1 in efficiency formula, we get-
Efficiency (η)
= 1 / (1 + 2a)
= 1 / (1 + 2 x 0.125)
= 1 / 1.25
= 0.8
 
Now,
Throughput
= Efficiency (η) x Bandwidth
= 0.8 x 3 Mbps
= 2.4 Mbps
 

Calculating Throughput for many active host-


 
For many active host, N = ∞.
Substituting N = ∞ in efficiency formula, we get-
Efficiency (η)
= 1 / (1 + a)
= 1 / (1 + 0.125)
= 1 / 1.125
= 0.89
 
Now,
Throughput
= Efficiency (η) x Bandwidth
= 0.89 x 3 Mbps
= 2.67 Mbps
Thus, Option (D) is correct.
 
Problem-08:
 
In 802.5, the condition to find out the minimum size of the ring is-
1. Latency of the ring = Transmission delay of the data frame
2. Latency of the ring = Transmission delay of the token frame
3. Latency of the ring = RTT
4. Latency > RTT
 

Solution-
 

 IEEE 802.5 is token ring.


 The condition to find out the minimum size of the ring is-
Latency of the ring >= Transmission delay of the token frame

 In worst case, all the stations goes down and only the monitor station is alive.
 Monitor station sends the token and the token comes back to it.
 To avoid the collision between the first and the last bit of the token, propagation
delay of the token must be at least equal to its transmission delay.
Thus, Option (B) is correct.
 

Problem-09:
 
The stacking station is a station in 802.5 and it can be described as-
1. when it drains the frame and creates a token, it then stores both the old and new
priority of the token
2. A station which stack the token till it gets the last bit of the token
3. It is nothing but monitor station
4. None of the above
 

Solution-
 

 IEEE 802.5 is token ring.


 A station which increases the priority of the token should next decrease the priority of
the token.
 Otherwise once the priority of the token reaches the highest value, it would ever
remain there and thus only the station with the highest packet would drain (take) the
token and use it.
 Thus, a stacking station must remember both the old and new priorities so that when
it later receives the token with new priority, it changes it to old priority.
 This is implemented by using 2 stacks. Each station maintains 2 stacks where one
station keeps track of the old priority and other stack keeps track of the new priority.
Thus, Option (A) is correct.
 

Problem-10:
 
In early token release, the station releases a token as soon as it completes the frame
transmission whether or not the frame header has returned to the station, then what will be
the priority of the token released?
1. The priority in the frame that completes frame transmission
2. Without changing the priority, token will be released
3. Default priority is used
4. The priority in the reservation field of the most recently received frame
 

Solution-
 
Option (D) is correct.
 

Problem-11:
 
Find the efficiency of the ring where data rate of the link is 4 Mbps, number of stations are
20, separated by 100 meters and bit delay in each station is 2.5 bits. Assume early token
reinsertion with packet size of 1000 bits and transmission speed is 2 x 108 m/sec.
 

Solution-
 
Given-

 Data rate = Bandwidth = 4 Mbps


 Number of stations = 20
 Distance between two stations = 100 meters
 Bit delay = 25 bits
 Packet size = 1000 bits
 Strategy used is Early Token Reinsertion (ETR)
Calculating length of ring wire-
 
Total length of ring wire
= Number of stations x Distance between 2 stations
= 20 x 100 meters
= 2000 meters
= 2 km
 
Calculating Transmission delay-
 
Transmission delay (Tt)
= Packet size / Bandwidth
= 1000 bits / 4 Mbps
= 1000 bits / (4 x 106 bits per sec)
= 250 μsec
 
Calculating Propagation delay-
 
Propagation delay (Tt)
= Distance / Speed
= 2 km / (2 x 108 m/sec)
= (2 x 103 m) / (2 x 108 m/sec)
= 10-5 sec
= 10 μsec
 
Calculating Bit delay in seconds-
 
Bit delay
= 25 bits
= 2.5 bits / 4 Mbps
= 25 bits / (4 x 106 bits per sec)
= 0.625 μsec
 
Calculating Ring latency-
 
Ring latency
= Propagation delay + N x Bit delay
= 10 μsec + 20 x 0.625 μsec
= 10 μsec + 12.5 μsec
= 22.5 μsec
 
Calculating value of ‘a’-
 
a
= Ring latency / Tt
= 22.5 μsec / 250 μsec
= 0.09
Calculating Efficiency-
 
Efficiency(η)
= 1 / (1 + a/N)
= 1 / (1 + 0.09 / 20)
= 1 / 1.0045
= 0.9955
= 99.55%
 
Problem-12:
 
A token ring LAN network interconnects M stations using Star Topology in the following
way. All the input and output lines of the token ring station interface are connected to a
cabinet where the actual ring is placed. Suppose that distance from each station to a
cabinet is 100 m and ring latency per station is 8 bits, packets are 1250 B and bandwidth is
25 Mbps.
1. Find the ring latency normalized to packet transmission time.
2. Find the minimum number of packets transmitted by stations, if stations are allowed
to transmit an unlimited number of packet / token. (v = 2 x 108 m/sec)
 

Solution-
 
Based on the given information, the token ring LAN network looks like-
 

(The sketch is for 4 stations)


 
Part-01:
 
Calculating Transmission delay-
 
Transmission delay
= Packet size / Bandwidth
= 1250 B / 25 Mbps
= (1250 x 8 bits) / (25 x 106 bits per sec)
= 400 μsec
 
Calculating Propagation delay-
 
Propagation delay
= Distance / Speed
= (200 x M meters) / (2 x 108 m/sec)
= (200 x M) / (2 x 108) sec
= 100 x M x 10-8 sec
= M μsec
 
 Calculating Bit delay in seconds-
 
Bit delay
= Ring latency per station
= 8 bits
= 8 bits / 25 Mbps
= 0.32 μsec
 
Calculating Ring latency-
 
Ring latency
= Propagation delay + N x Bit delay
= M μsec + M x 0.32 μsec
= 1.32 x M μsec
 
Calculating Ring latency normalized to packet transmission delay-
 
Ring latency normalized to packet transmission time
= Ring latency / Packet transmission time
= 1.32 x M μsec / 400 μsec
= 0.0033 x M
 
Part-02:
 

 The number of packets a station can transmit after holding a token depends on
Token Holding Time and the strategy used.
 Since no information is given in the question about the Time Holding Time, so we
assume that there is no restriction on holding the token.
 Thus, a station can send infinite number of packets after getting a token.
 

Problem-13:
 
A very heavily loaded 1 km long, 10 Mbps token ring has a propagation speed of 200
m/μsec. 50 stations are uniformly spaced around the ring. Data frames are 256 bits
including 32 bits of overhead. Acknowledgements are piggybacked onto the data frames
and are thus included as spare bits within the data frames and are effectively free. The
token is 8 bits long. Is the effective data rate of this ring higher or lower than the effective
data rate of a 10 Mbps CSMA / CD network? Assume ‘Early Token Release’ policy.
 

Solution-
 

Remember
Token Ring always beats the Ethernet in terms of effective bandwidth.

 
Analysis-
 
Efficiency of CSMA / CD-
 
Efficiency of token ring in early token retransmission is given by-
Efficiency(η) = 1 / (1 + 6.44 x a)
This expression is valid when number of stations are very large i.e. N → ∞
 
Efficiency of Token Ring-
 
Case-01:
 
Efficiency of token ring in early token retransmission is given by-
Efficiency(η) = 1 / (1 + a/N)
When N → ∞, Efficiency(η) = 100%
 
Case-02:
 
Efficiency of token ring in delayed token retransmission is given by-
Efficiency(η) = 1 / [1 + a(1 + 1/N)]
When N → ∞, Efficiency(η) = 1 / (1+a)
 
The above analysis clearly shows-
Efficiency of Token Ring in ETR > Efficiency of Token Ring in DTR > Efficiency of Token
Ring in CSMA / CD.
 

Problem-14:
 
A fibre optic token ring used as a MAN is 200 km long and runs at 100 Mbps. After sending
a frame, a station drains the frame from the ring before regenerating the token. The signal
propagation speed in the fibre is 200,000 km/sec and maximum frame size is 1 KB. What is
the maximum efficiency at N=1?
 

Solution-
 
Given-

 Distance = 200 km
 Bandwidth = 100 Mbps
 Propagation speed = 200,000 km/sec = 2 x 108 m/sec
 Frame size = 1 KB
 Number of stations = 1
 Strategy used is Delayed Token Reinsertion
 
Calculating Transmission delay-
 
Transmission delay
= Frame size / Bandwidth
= 1 KB / 100 Mbps
= (1 x 210 x 8 bits) / (100 x 106 bits per sec)
= 81.92 μsec
 
Calculating Propagation delay-
 
Propagation delay
= Distance / Speed
= 200 km / (2 x 108 m/sec)
= (200 x 103 m) / (2 x 108 m/sec)
= 10-3 sec
= 1 msec
 
Calculating value of ‘a’-
 
a
= Tp / Tt
= 1 msec / 81.92 μsec
= 0.0122 x 103
= 12.2
 
Calculating Efficiency-
 
Efficiency(η)
= 1 / [1 + a x (1+ 1/N)]
= 1 / [1 + 12.2 x (1+1)]
= 1 / 25.4
= 0.0394
= 3.94%
 

 The reason behind this much less efficiency is that the distance is too large here.
 Ethernet and Token Ring are meant for LANs.
 If used for MANs or WANs, the efficiency will fall drastically.
 

Problem-15:
 
At a propagation speed of 200 m/μsec, what is the effective length added to a ring by a bit
delay at each repeater or station for-
1. 1 Mbps line
2. 40 Mbps line
 

Solution-
 
Part-01:
 
Effective length added to a ring by a bit delay
= 1 bit / 1 Mbps
= 1 μsec
= 1 μsec x 200 m/μsec
= 200 m
 
Part-02:
 
Effective length added to a ring by a bit delay
= 1 bit / 40 Mbps
= 0.025 μsec
= 0.025 μsec x 200 m/μsec
=5m
 

Problem-16:
 
Consider a 10 Mbps token ring LAN with a ring latency of 400 μs. A host that needs to
transmit seizes the toke. Then it sends a frame of 1000 bytes, removes the frame after it
has circulated all around the ring and finally releases the token. This process is repeated for
every frame. Assuming that only a single host wishes to transmit, the effective data rate is
_____ .
1. 1 Mbps
2. 2 Mbps
3. 5 Mbps
4. 6 Mbps
 

Solution-
 
Given-

 Bandwidth = 10 Mbps
 Ring latency = 400 μsec
 Frame size = 1000 bytes
 Number of stations = 1
 Strategy used is Delayed Toke Reinsertion
 
Calculating Transmission delay-
 
Transmission delay
= Frame size / Bandwidth
= 1000 bytes / 10 Mbps
= (1000 x 8 bits) / (10 x 106 bits per sec)
= 800 μsec
 
Calculating value of ‘a’-
 
a
= Ring latency / Tt
= 400 μsec / 800 μsec
= 0.5
 
Calculating Efficiency-
 
Efficiency(η)
= 1 / [1 + a x (1+ 1/N)]
= 1 / [1 + 0.5 x (1+1)]
=1/2
= 0.50
= 50%
 
Calculating Effective data rate-
 
Effective data rate
= Throughput
= Efficiency(η) x Bandwidth
= 0.5 x 10 Mbps
= 5 Mbps
Thus, Option (C) is correct.
 
Local Area Network-
 

 A Local Area Network (LAN) is a network of computers.


 It is confined to a small area which may be a room, building or a group of buildings.
 A LAN may be wired, wireless or a combination of the two.
 

LAN Technologies-
 
Standard technologies used to build a wired LAN are-

1. Ethernet
2. Token Ring
 
In this article, we will discuss about Ethernet and its Frame Format.
 

Ethernet-
 

 Ethernet is one of the standard LAN technologies used for building wired LANs.
 It is defined under IEEE 802.3.
 

Characteristics-
 
Point-01:
 

 Ethernet uses bus topology.


 In bus topology, all the stations are connected to a single half duplex link.
Point-02:
 

 Ethernet uses CSMA / CD as access control method to deal with the collisions.
 
Point-03:
 

 Ethernet uses Manchester Encoding Technique for converting data bits into signals.
 
Point-04:
 

 For Normal Ethernet, operational bandwidth is 10 Mbps.


 For Fast Ethernet, operational bandwidth is 100 Mbps.
 For Gigabit Ethernet, operational bandwidth is 1 Gbps.
 

Ethernet Frame Format-


 
IEEE 802.3 defines the following Ethernet frame format-
 
 Preamble-
 

 It is a 7 byte field that contains a pattern of alternating 0’s and 1’s.


 It alerts the stations that a frame is going to start.
 It also enables the sender and receiver to establish bit synchronization.
 

2. Start Frame Delimiter (SFD)-


 

 It is a 1 byte field which is always set to 10101011.


 The last two bits “11” indicate the end of Start Frame Delimiter and marks the
beginning of the frame.
 

NOTES
 The above two fields are added by the physical layer and represents the physical layer
header.
 Sometimes, Start Frame Delimiter (SFD) is considered to be a part of Preamble.
 That is why, at many places, Preamble field length is described as 8 bytes.

3. Destination Address-
 

 It is a 6 byte field that contains the MAC address of the destination for which the data
is destined.
 
4. Source Address-
 

 It is a 6 byte field that contains the MAC address of the source which is sending the
data.
 

5. Length-
 

 It is a 2 byte field which specifies the length (number of bytes) of the data field.
 This field is required because Ethernet uses variable sized frames.
 

NOTES
 The maximum value that can be accommodated in this field = 216 – 1 = 65535.
 But it does not mean maximum data that can be sent in one frame is 65535 bytes.
 The maximum amount of data that can be sent in a Ethernet frame is 1500 bytes.
 This is to avoid the monopoly of any single station.

 
The following three fields collectively represents the Ethernet Header–

 Destination Address (6 bytes)


 Source Address (6 bytes)
 Length (2 bytes)
Thus, Ethernet Header Size = 14 bytes.
 

6. Data-
 

 It is a variable length field which contains the actual data.


 It is also called as a payload field.
 The length of this field lies in the range [ 46 bytes , 1500 bytes ].
 Thus, in a Ethernet frame, minimum data has to be 46 bytes and maximum data can
be 1500 bytes.
Minimum Length of Data Field
 

 Ethernet uses CSMA / CD as access control method to deal with collisions.


 For detecting the collisions, CSMA / CD requires-
Minimum length of data packet = 2 x Propagation delay x Bandwidth

 Substituting the standard values of Ethernet, it is found that minimum length of the Ethernet
frame has to be 64 bytes starting from the destination address field to the CRC field and 72 bytes
including the Preamble and SFD fields.
 Therefore, minimum length of the data field has to be = 64 bytes – (6+6+2+4) bytes = 46
bytes
 

Maximum Length of Data Field


 

 The maximum amount of data that can be sent in a Ethernet frame is 1500 bytes.
 This is to avoid the monopoly of any single station.
 If Ethernet allows the frames of big sizes, then other stations may not get the fair chance to
send their data.

Limitations of Using Ethernet-


 
Point-01:
 

 It can not be used for real time applications.


 Real time applications require the delivery of data within some time limit.
 Ethernet is not reliable because of high probability of collisions.
 High number of collisions may cause a delay in delivering the data to its destination.
 
Point-02:
 

 It can not be used for interactive applications.


 Interactive applications like chatting requires the delivery of even very small amount
of data.
 Ethernet requires that minimum length of the data must be 46 bytes.
 
Point-03:
 

 It can not be used for client server applications.


 Client server applications require that server must be given higher priority than
clients.
 Ethernet has no facility to set priorities.
 
Token Ring overcomes these limitations of Ethernet.
 

Important Concept-
 
For data transmission-

 TCP segment sits inside the IP datagram payload field.


 IP datagram sits inside the Ethernet payload field.
 

Ethernet in Networking-
 
Before you go through this article, make sure that you have gone through the previous
article on Ethernet.
We have discussed-

 Ethernet is one of the standard LAN technologies used to build wired LANs.
 Ethernet uses bus topology in which all the stations are connected to a half duplex
link.
 Ethernet uses CSMA / CD as an access control method.
 
PRACTICE PROBLEMS BASED ON ETHERNET
Problem 1
Which of the following characteristic is most basic to LAN?
1. Bit rate
2. Delay x Bandwidth Product
3. Geographical distance
4. Cost
 

Solution-
 

 Geographical distance is the basic criteria on which networks are classified.


 On the basis of geographical distance, networks are classified as LAN, MAN, WAN.
 Thus,Option (C) is correct.
 

Problem-02:
 
On an Ethernet LAN when a collision is detected, the sending station-
1. continues to send the transmission
2. temporarily quits the transmission
3. notifies the destination of an error
4. permanently quits the transmission
 

Solution-
 

 Ethernet uses CSMA / CD as access control method.


 On detecting a collision, the sending station temporarily quits the transmission.
 Transmitting station waits for Back Off time and then tries again.
 Thus, Option (B) is correct.
 

Problem-03:
 
Ethernet implements _________ service for its operation.
1. connection oriented
2. connection less
3. Both A and B
4. Either A or B
 

Solution-
 

REMEMBER
 Connection oriented service involves allocation of the dedicated resources.
 Connection less service does not involve allocation of dedicated resources.
 TCP and Virtual Circuits are connection oriented services.
 IP, Ethernet and Token Ring are connection less services.
 Datagrams are connection less, that is why IP is connection less.

 
When an Ethernet frame is sent,

 Destination is never expected to reserve the buffer or any other resource for the
incoming frame.
 The data is simply dumped at the destination side.
 So, it is connectionless.
 Thus, Option (B) is correct.
 

Problem-04:
 
The collision domain of Fast Ethernet is limited to ______ meters.
1. 2.5
2. 25
3. 250
4. 2500
 

Solution-
 Collision domain defines the number of stations that can get involved in the collision
when connected to a LAN.
 In the given question, collision domain refers to maximum distance a LAN can run to
detect the collisions.
 Ethernet uses CSMA / CD as access control method.
 
In CSMA / CD, condition to detect collisions is-
Distance <= (Length x speed) / (2 x bandwidth)
 
On substituting the values, we get the value of distance
REMEMBER
 For normal Ethernet, collision domain = 2500 meters.
 For Fast Ethernet, collision domain = 250 meters.
 For Gigabit Ethernet, collision domain = 25 meters
Thus, Option (C) is correct.
 

Problem-05:
 
The efficiency of Ethernet-
1. increases when propagation delay and transmission delay are low
2. increases when propagation delay and transmission delay are high
3. increases when propagation delay is low and transmission delay is high
4. increases when propagation delay is high and transmission delay is low
 

Solution-
 

 Efficiency of Ethernet = 1 / ( 1 + 6.44a) where a = Tp / Tt.


 Thus, Option (C) is correct.
 

Problem-06:
 
What is the baud rate of the standard 10 Mbps 802.3 LAN?
1. 20 mega baud
2. 10 mega baud
3. 25 mega baud
4. 40 mega baud
 
Solution-
 
LAN uses Manchester Encoding Technique where-
Baud rate = 2 x Bit rate
 
For 10 Mbps,
Baud rate
= 2 x 10 mega baud
= 20 mega baud
Thus, Option (A) is correct.
 

Problem-07:
 
Consider a 10 Mbps Ethernet LAN that has stations attached to a 2.5 km long coaxial cable.
Given that the transmission speed is 2.3 x 108 m/sec, the packet size is 128 bytes out of
which 30 bytes are overhead, find the effective transmission rate and maximum rate at
which the network can send data.
 

Solution-
 
Given-

 Bandwidth = 10 Mbps
 Distance = 2.5 km
 Transmission speed = 2.3 x 108 m/sec
 Total packet size = 128 bytes
 Overhead = 30 bytes
 
Calculating Transmission Delay-
 
Transmission delay (Tt)
= Packet size / Bandwidth
= 128 bytes / 10 Mbps
= (128 x 8 bits) / (10 x 106 bits per sec)
= 1024 / 107 sec
= 102.4 μsec
 
Calculating Propagation Delay-
 
Propagation delay (Tp)
= Distance / Speed
= 2.5 km / (2.3 x 108 m/sec)
= (2.5 x 103 m) / (2.3 x 108 m/sec)
= 1.08 x 10-5 sec
= 10.8 μsec
 
Calculating Value of ‘a’-
 
a
= Tp / Tt
= 10.8 μsec / 102.4 μsec
= 0.105
 
Calculating Efficiency-
 
Efficiency(η)
= 1 / (1 + 6.44 x a)
= 1 / (1 + 6.44 x 0.105)
= 1 / 1.67
= 0.59
= 59%
 
Calculating Maximum Rate-
 
Maximum rate or Throughput
= Efficiency x Bandwidth
= 0.59 x 10 Mbps
= 5.9 Mbps
 
Calculating Effective Transmission Rate-
 
Effective transmission rate
= Throughput x (128-30 / 128)
= 5.9 Mbps x (98 / 128)
= 0.77 x 5.9 Mbps
= 4.52 Mbps
 

Problem-08:
 
The following frame transition diagram shows an exchange of Ethernet frames between two
computers, A and B connected via a 10BT Hub. Each frame sent by computer A contains
1500 B of Ethernet payload data, while each frame sent by computer B contains 40 B of
Ethernet payload data. Calculate the average utilization of the media during this exchange.
 

 
1. 10%
2. 1.7%
3. 20%
4. 15.2%
 

Solution-
 
Calculating Data Sent By Computer A in One Frame-
 
Given-

 Each frame sent by computer A contains 1500 B of Ethernet payload data.


 This is divided as: 20 bytes of IP Header + 20 bytes of TCP Header + 1460 bytes of
data.
 
So, Total bytes sent by computer A in one frame
= Preamble + SFD + Ethernet Header + Ethernet Payload + CRC
= 7 bytes + 1 byte + 14 bytes + 1500 bytes + 4 bytes
= 1526 bytes
 
Calculating Data Sent By Computer A in 0.6 Seconds:
 
Computer A sends 8 frames in 0.6 seconds.
So, Total bytes sent by computer A in 0.6 seconds
= 8 x 1526 bytes
= 12208 bytes
 
Calculating Data Sent By Computer B in One Frame-
 
Given-

 Each frame sent by computer B contains 40 B of Ethernet payload data.


 This is divided as: 20 bytes of IP Header + 20 bytes of TCP Header + 0 bytes of
data.
 Since minimum data in the payload field of Ethernet must 46 bytes. So, extra 6 bytes
are padded.
 
So, Total bytes sent by computer B in one frame
= Preamble + SFD + Ethernet Header + Ethernet Payload + CRC
= 7 bytes + 1 byte + 14 bytes + (40 bytes + 6 bytes) + 4 bytes
= 72 bytes
 
Calculating Data Sent By Computer B in 0.6 Seconds-
 
Computer B sends 4 frames in 0.6 seconds.
So, Total bytes sent by computer B in 0.6 seconds
= 4 x 72 bytes
= 288 bytes
 
Calculating Total Data Sent in 0.6 Seconds:
 
Total data flow that takes place in 0.6 seconds
= Total data sent by computer A in 0.6 seconds + Total data sent by computer B in 0.6
seconds
= 12208 bytes + 288 bytes
= 12496 bytes
= 99968 bits
 
Calculating Throughput-
 
Throughput
= Amount of data that flows per second
= 99968 bits / 0.6 seconds
= 166613.33 bits/sec
 
Calculating Utilization-
 
Throughput = Efficiency x Bandwidth
So, Efficiency or Utilization
= Throughput / Bandwidth
= (166613.33 bits per sec) / 10 Mbps
= 0.017
= 1.7%
 
Thus, Option (B) is correct.
 

Problem-09:
 
Ethernet adaptor receives all frames and accepts-
1. Frames addressed to its own address
2. Frames addressed to the multicast or broadcast address
3. Frames if it has been placed in promiscuous mode
4. All of the above
 

Solution-
 
In a bus topology Ethernet,

 Ethernet Adaptor enables a computer to access an Ethernet Network.


 If one station sends a frame to other station, then other stations & Ethernet Adaptor
also receives that frame.
 But they accept only those frames which are destined for them.
 Ethernet Adaptor accepts all those frames which are addressed to its own address
or broadcast address or multicast address (if it is present in that multicast group)
 Network administrator may set the network in promiscuous mode.
 This is done to monitor the activities going on in the network.
 So, if Ethernet Adaptor is set in promiscuous mode, it receives and accepts all the
frames.
 Thus, Option (D) is correct.
 

Switching in Computer Networks-


 

The process of moving the data packets towards their destination by forwarding them from one
port to the other port is called as switching.

Switching Techniques-
 
Various switching techniques are-

1. Circuit Switching
2. Message Switching
3. Packet Switching
 
In this article, we will discuss about Circuit Switching.
 

Circuit Switching-
 
This switching technique operates in the following three phases-
1. Establishing a circuit
2. Transferring data
3. Disconnecting the circuit
Establishing a circuit
In this phase,

 A circuit is established between the two ends.


 Circuit provides a dedicated path for data to travel from one to the other end.
 Resources are reserved at intermediate switches which are used during the
transmission.
 The intermediate switches are connected by the physical links.

 Transferring The Data-


 
After the circuit is established,

 The entire data travels over the dedicated path from one end to the other end.
 

3. Disconnecting The Circuit-


 
After the data transfer is completed,

 The circuit is torn down i.e. disconnected.


 

Total Time-
 

Total time taken to transmit a message in circuit switched network


= Connection set up time + Transmission delay + Propagation delay + Tear down time

 
where-

 Transmission delay = Message size / Bandwidth


 Propagation delay = (Number of hops on way x Distance between 2 hops) /
Propagation speed
 
Also Read-Packet Switching
 

Advantages-
 
Circuit switching has the following advantages-

 A well defined and dedicated path exists for the data to travel.
 There is no header overhead.
 There is no waiting time at any switch and the data is transmitted without any delay.
 Data always reaches the other end in order.
 No re ordering is required.
 

Disadvantages-
 
Circuit switching has the following disadvantages-

 The channel is blocked for two ends only.


 It is inefficient in terms of utilization of system resources.
 The time required for establishing the circuit between the two ends is too long.
 Dedicated channels require more bandwidth.
 It is more expensive than other switching techniques.
 Routing decisions can not be changed once the circuit is established.
 

Important Notes-
 

 Circuit switching is implemented at physical layer.


 Circuit switching is now outdated.
 

PRACTICE PROBLEM BASED ON CIRCUIT


SWITCHING TECHNIQUE-
 

Problem-
 
Consider all links in the network use TDM with 24 slots and have a data rate of 1.536 Mbps.
Assume that host A takes 500 msec to establish an end to end circuit with host B before
begin to transmit the file. If the file is 512 kilobytes, then how much time will it take to send
the file from host A to host B?
 

Solution-
 
Given-

 Total bandwidth = 1.536 Mbps


 Bandwidth is shared among 24 slots
 Connection set up time = 500 msec
 File size = 512 KB
 
Calculating Bandwidth Per User-
 
Total bandwidth = Number of users x Bandwidth per user
So, Bandwidth per user
= Total bandwidth / Number of users
= 1.536 Mbps / 24
= 0.064 Mbps
= 64 Kbps
 
Calculating Transmission Delay-
 
Transmission delay (Tt)
= File size / Bandwidth
= 512 KB / 64 Kbps
= (512 x 210 x 8 bits) / (64 x 103 bits per sec)
= 65.536 sec
= 65536 msec
 
Calculating Time Required To Send File-
 
Time taken to send a file in circuit switched network
= Connection set up time + Transmission delay
= 500 msec + 65536 msec
= 66036 sec
= 66.036 msec

Message Switching-
 
In message switching,

 There exists no dedicated path to transfer data.


 The entire message is treated as a single data unit.
 The message is then forwarded from hop to hop.
 Store and Forward is an important characteristic of message switching.
 The message carries a header that contains the full information about the
destination.
 When any intermediate switch receives the message, it stores the entire message.
 The message is stored until sufficient resources become available to transfer it to the
next switch.
 When resources become available, the switch forwards the message to the next
switch.
 

Advantages-
 
Point-01:
 

 It improves the channel efficiency over Circuit Switched Network.


 In circuit switched network, the channel is blocked for two ends only.
 But here, more devices can share the channel.
 
Point-02:
 

 It is helpful in reducing traffic congestion.


 The message may be temporarily stored in the route and then forwarded whenever
required.
 
Point-03:
 

 It is helpful in setting the message priorities due to store and forward technique.
 

Disadvantages-
 
Point-01:
 

 It requires enough storage at every switch to accommodate the entire message


during the transmission.
 
Point-02:
 

 It is extremely slow due to store and forward technique.


 Also, the message has to wait until sufficient resources become available to transfer
it to the next switch.
 

Message switching is replaced by Packet switching.

Packet Switching-
 
In packet switching,

 The entire message to be sent is divided into multiple smaller size packets.
 This process of dividing a single message into smaller size packets is called
as packetization.
 These smaller packets are sent after the other.
 It gives the advantage of pipelining and reduces the total time taken to transmit the
message.
 

Optimal Packet Size-


 
If the packet size is not chosen wisely, then-

 It may result in adverse effects.


 It might increase the time taken to transmit the message.
So, it is very important to choose the packet size wisely.
 

Example-
 
Consider-

 There is a network having bandwidth of 1 MBps.


 A message of size 1000 bytes has to be sent.
 Packet switching technique is used.
 Each packet contains a header of 100 bytes.
 

 
Out of the following, in how many packets the message must be divided so that total time
taken is minimum-
1. 1 packet
2. 5 packets
3. 10 packets
4. 20 packets
 

NOTE
 While calculating the total time, we often ignore the propagation delay.
 The reason is in packet switching, transmission delay dominates over propagation delay.
 This is because each packet is transmitted over the link at each hop.

 
Let us analyze each case one by one.
 

Case-01: Sending Message in 1 Packet-


 
In this case, the entire message is sent in a single packet.
 
Size Of Packet-
 
Packet size
= 1000 bytes of data + 100 bytes of header
= 1100 bytes
 
Transmission Delay-
 
Transmission delay
= Packet size / Bandwidth
= 1100 bytes / 1 MBps
= 1100 x 10-6 sec
= 1100 μsec
= 1.1 msec
 
Total Time Taken-
 
Total time taken to send the complete message from sender to receiver
= 3 x Transmission delay
= 3 x 1.1 msec
= 3.3 msec
 

Case-02: Sending Message in 5 Packets-


 
In this case,

 The entire message is divided into total 5 packets.


 These packets are then sent one after the other.
 
Data Sent in One Packet-
 
Data sent in one packet
= Total data to be sent / Number of packets
= 1000 bytes / 5
= 200 bytes
 
Size Of One Packet-
 
Packet size
= 200 bytes of data + 100 bytes of header
= 300 bytes
 
Transmission Delay-
 
Transmission delay
= Packet size / Bandwidth
= 300 bytes / 1 MBps
= 300 x 10-6 sec
= 300 μsec
= 0.3 msec
 
Time Taken By First Packet-
 
Time taken by the first packet to reach from sender to receiver
= 3 x Transmission delay
= 3 x 0.3 msec
= 0.9 msec
 
Time Taken By Remaining Packets-
 
Time taken by the remaining packets to reach from sender to receiver
= Number of remaining packets x Transmission delay
= 4 x 0.3 msec
= 1.2 msec
 
Total Time Taken-
 
Total time taken to send the complete message from sender to receiver
= 0.9 msec + 1.2 msec
= 2.1 msec
 

Case-03: Sending Data in 10 packets-


 
In this case,

 The entire message is divided into total 10 packets.


 These packets are then sent one after the other.
 
Data Sent in One Packet-
 
Data sent in one packet
= Total data to be sent / Number of packets
= 1000 bytes / 10
= 100 bytes
 
Size Of One Packet-
 
Packet size
= 100 bytes of data + 100 bytes of header
= 200 bytes
 
Transmission Delay-
 
Transmission delay
= Packet size / Bandwidth
= 200 bytes / 1 MBps
= 200 x 10-6 sec
= 200 μsec
= 0.2 msec
 
Time Taken By First Packet-
 
Time taken by the first packet to reach from sender to receiver
= 3 x Transmission delay
= 3 x 0.2 msec
= 0.6 msec
 
Time Taken By Remaining Packets-
 
Time taken by the remaining packets to reach from sender to receiver
= Number of remaining packets x Transmission delay
= 9 x 0.2 msec
= 1.8 msec
 
Total Time Taken-
 
Total time taken to send the complete message from sender to receiver
= 0.6 msec + 1.8 msec
= 2.4 msec
 

Case-04: Sending Data in 20 Packets-


 
In this case,

 The entire message is divided into total 5 packets.


 These packets are then sent one after the other.
 
Data Sent in One Packet-
 
Data sent in one packet
= Total data to be sent / Number of packets
= 1000 bytes / 20
= 50 bytes
 
Size Of One Packet-
 
Packet size
= 50 bytes of data + 100 bytes of header
= 150 bytes
 
Transmission Delay-
 
Transmission delay
= Packet size / Bandwidth
= 150 bytes / 1 MBps
= 150 x 10-6 sec
= 150 μsec
= 0.15 msec
 
Time Taken By First Packet-
 
Time taken by the first packet to reach from sender to receiver
= 3 x Transmission delay
= 3 x 0.15 msec
= 0.45 msec
 
Time Taken By Remaining Packets-
 
Time taken by the remaining packets to reach from sender to receiver
= Number of remaining packets x Transmission delay
= 19 x 0.15 msec
= 2.85 msec
 
Total Time Taken-
 
Total time taken to send the complete message from sender to receiver
= 0.45 msec + 2.85 msec
= 3.3 msec
 

Observations-
 

 When data is sent in 1 packet, total time taken = 3.3 msec


 When data is sent in 5 packets, total time taken = 2.1 msec
 When data is sent in 10 packets, total time taken = 2.4 msec
 When data is sent in 20 packets, total time taken = 3.3 msec
 

Conclusion-
 
We conclude-
 Total time decreases when packet size is reduced but only up to a certain limit.
 If the packet size is reduced beyond a certain limit, then total time starts increasing.
 
From the given choices,

 Sending the message in 5 packets would be most efficient.


 In other words, packet size = 300 bytes would be the best choice.
 

Types of Packet Switching-


 
Packet switching may be carried out in the following 2 ways-
 

 
1. Virtual Circuit Switching
2. Datagram Switching
 

Virtual Circuit Switching-


 
Virtual circuit switching operates in the following three phases-
1. Establishing a circuit
2. Transferring the data
3. Disconnecting the circuit
 
1. Establishing A Circuit-
 
In this phase,

 A logical connection is established between the two ends.


 It provides a dedicated path for data to travel from one to the other end.
 Resources are reserved at intermediate switches which are used during the
transmission.
 

 
2. Transferring The Data-
 
After the connection is established,

 The entire data travels over the dedicated path from one end to the other end.
 
3. Disconnecting The Circuit-
 
After the data transfer is completed,

 The connection is disconnected.


 

Datagram Switching-
 
In datagram switching,

 There exists no dedicated path for data to travel.


 The header of each packet contains the destination address.
 When any intermediate switch receives the packet, it examines its destination
address.
 It then consults the routing table.
 Routing table finds the corresponding port through which the packet should be
forwarded.
 

Virtual Circuit Switching Vs Datagram Switching-


 
The following table shows a comparison between virtual circuit switching and datagram
switching-
 

Virtual Circuit Switching Datagram Switching

The first packet during its transmission-


1) Informs the intermediate switches that
more packets are following. The first packet does not perform any such task
during its transmission.
2) Reserve resources (CPU, bandwidth and
buffer) for the following packets at all the
switches on the way.

The packets are never discarded at


The packets may be discarded at intermediate
intermediate switches and immediately
switches if sufficient resources are not available
forwarded since resources are reserved for
to process the packets.
them.

It is a connection oriented service since


It is a connection less service since no
resources are reserved for the packets at
resources are reserved for the packets.
intermediate switches.

All the packets follow the same dedicated


All the packets take path independently.
path.

Data appears in order at the destination since Data may appear out of order at the destination
all the packets take the same dedicated path. since the packets take path independently.

It is highly reliable since no packets are It is not reliable since packets may be
discarded. discarded.
It is costly. It is cost effective.

Only first packet requires a global header


which identifies the path from one end to
other end. All the packets require a global header which
contains full information about the destination.
All the following packets require a local
header which identifies the path from hop to
hop.

ATM (Asynchronous Transfer Mode) uses


IP Networks use datagram switching.
virtual circuit switching.

Virtual circuit switching is normally Datagram switching is normally implemented at


implemented at data link layer. network layer.

PRACTICE PROBLEM BASED ON PACKET


SWITCHING TECHNIQUE-
 

Problem-
 
In a packet switching network, packets are routed from source to destination along a single
path having two intermediate nodes. If the message size is 24 bytes and each packet
contains a header of 3 bytes, then the optimum packet size is-
1. 4 bytes
2. 6 bytes
3. 7 bytes
4. 9 bytes
 

Solution-
 

 
Let bandwidth of the network = X Bps and 1 / X = a
 
Option-A: Packet Size = 4 Bytes
 
In this case,

 The entire message is divided into packets of size 4 bytes.


 These packets are then sent one after the other.
 
Data Sent in One Packet-
 
Data size
= Packet size – Header size
= 4 bytes – 3 bytes
= 1 byte
Thus, only 1 byte of data can be sent in each packet.
 
Number Of Packets-
 
Number of packets required
= Total data to be sent / Data contained in one packet
= 24 bytes / 1 byte
= 24 packets
 
Transmission Delay-
 
Transmission delay
= Packet size / Bandwidth
= 4 bytes / X Bps
= 4a sec
 
Time Taken By First Packet-
 
Time taken by the first packet to reach from sender to receiver
= 3 x Transmission delay
= 3 x 4a sec
= 12a sec
 
Time Taken By Remaining Packets-
 
Time taken by the remaining packets to reach from sender to receiver
= Number of remaining packets x Transmission delay
= 23 x 4a sec
= 92a sec
 
Total Time Taken-
 
Total time taken to send the complete message from sender to receiver
= 12a sec + 92a sec
= 104a sec
 

Option-B: Packet Size = 6 bytes


 
In this case,

 The entire message is divided into packets of size 6 bytes.


 These packets are then sent one after the other.
 
Data Sent in One Packet-
 
Data size
= Packet size – Header size
= 6 bytes – 3 bytes
= 3 bytes
Thus, only 3 bytes of data can be sent in each packet.
 
Number Of Packets-
 
Number of packets required
= Total data to be sent / Data contained in one packet
= 24 bytes / 3 bytes
= 8 packets
 
Transmission Delay-
 
Transmission delay
= Packet size / Bandwidth
= 6 bytes / X Bps
= 6a sec
 
Time Taken By First Packet-
 
Time taken by the first packet to reach from sender to receiver
= 3 x Transmission delay
= 3 x 6a sec
= 18a sec
 
Time Taken By Remaining Packets-
 
Time taken by the remaining packets to reach from sender to receiver
= Number of remaining packets x Transmission delay
= 7 x 6a sec
= 42a sec
 
Total Time Taken-
 
Total time taken to send the complete message from sender to receiver
= 18a sec + 42a sec
= 60a sec
 
Option-C: Packet Size = 7 bytes
 
In this case,

 The entire message is divided into packets of size 7 bytes.


 These packets are then sent one after the other.
 
Data Sent in One Packet-
 
Data size
= Packet size – Header size
= 7 bytes – 3 bytes
= 4 bytes
Thus, only 4 bytes of data can be sent in each packet.
 
Number Of Packets-
 
Number of packets required
= Total data to be sent / Data contained in one packet
= 24 bytes / 4 bytes
= 6 packets
 
Transmission Delay-
 
Transmission delay
= Packet size / Bandwidth
= 7 bytes / X Bps
= 7a sec
 
Time Taken By First Packet-
 
Time taken by the first packet to reach from sender to receiver
= 3 x Transmission delay
= 3 x 7a sec
= 21a sec
 
Time Taken By Remaining Packets-
 
Time taken by the remaining packets to reach from sender to receiver
= Number of remaining packets x Transmission delay
= 5 x 7a sec
= 35a sec
 
Total Time Taken-
 
Total time taken to send the complete message from sender to receiver
= 21a sec + 35a sec
= 56a sec
 

Option-D: Packet size = 9 Bytes


 
In this case,

 The entire message is divided into packets of size 9 bytes.


 These packets are then sent one after the other.
 
Data Sent in One Packet-
 
Data size
= Packet size – Header size
= 9 bytes – 3 bytes
= 6 bytes
Thus, only 6 bytes of data can be sent in each packet.
 
Number Of Packets-
 
Number of packets required
= Total data to be sent / Data contained in one packet
= 24 bytes / 6 bytes
= 4 packets
 
Transmission Delay-
 
Transmission delay
= Packet size / Bandwidth
= 9 bytes / X Bps
= 9a sec
 
Time Taken By First Packet-
 
Time taken by the first packet to reach from sender to receiver
= 3 x Transmission delay
= 3 x 9a sec
= 27a sec
 
Time Taken By Remaining Packets-
 
Time taken by the remaining packets to reach from sender to receiver
= Number of remaining packets x Transmission delay
= 3 x 9a sec
= 27a sec
 
Total Time Taken-
 
Total time taken to send the complete message from sender to receiver
= 27a sec + 27a sec
= 54a sec
 
Observations-
 
From here,

 Total time taken when packet size is 4 bytes = 104a sec


 Total time taken when packet size is 6 bytes = 60a sec
 Total time taken when packet size is 7 bytes = 56a sec
 Total time taken when packet size is 9 bytes = 54a sec
 
Result-
 
Time taken is minimum when packet size is 9 bytes.
Thus, Option (D) is correct.
 

Difference Between Circuit Switching And Packet


Switching-
 
The following table compares circuit switching and packet switching techniques-
 
Packet Switching
Circuit Switching
Virtual Circuit Switching Datagram Switching

Connection oriented service Connection oriented service Connection less service

Packets may be delivered out


Ensures in order delivery Ensures in order delivery
of order

No reordering is required No reordering is required Reordering is required

A dedicated path exists for A dedicated path exists for No dedicated path exists for
data transfer data transfer data transfer

All the packets take the same All the packets take the same All the packets may not take
path path the same path

Resources are allocated Resources are allocated on


No resources are allocated
before data transfer demand using 1st packet

Stream oriented Packet oriented Packet oriented

Fixed bandwidth Dynamic Bandwidth Dynamic bandwidth

Reliable Reliable Unreliable

No header overheads Only label overheads Higher overheads

Implemented at physical layer Implemented at data link layer Implemented at network layer

Inefficient in terms of resource Provides better efficiency than Provides better efficiency than
utilization circuit switched systems message switched systems
Example- Telephone systems Examples- X.25, Frame relay Example- Internet

Routing Algorithms-
 

 Routing algorithms are meant for determining the routing of packets in a node.
 Routing algorithms are classified as-
 

 
1. Static Routing Algorithms
2. Dynamic Routing Algorithms
 
In this article, we will discuss about distance vector routing.

 Distance Vector Routing Algorithm-


 

Distance Vector Routing is a dynamic routing algorithm.

 
It works in the following steps-
 

Step-01:
 
Each router prepares its routing table. By their local knowledge. each router knows about-

 All the routers present in the network


 Distance to its neighboring routers
 

Step-02:
 

 Each router exchanges its distance vector with its neighboring routers.
 Each router prepares a new routing table using the distance vectors it has obtained
from its neighbors.
 This step is repeated for (n-2) times if there are n routers in the network.
 After this, routing tables converge / become stable.
 

Distance Vector Routing Example-


 
Consider-

 There is a network consisting of 4 routers.


 The weights are mentioned on the edges.
 Weights could be distances or costs or delays.
 

Step-01:
 
Each router prepares its routing table using its local knowledge.
Routing table prepared by each router is shown below-
 
At Router A-
 

Destination Distance Next Hop

A 0 A

B 2 B

C ∞ –

D 1 D

 
At Router B-
 

Destination Distance Next Hop

A 2 A

B 0 B

C 3 C

D 7 D

 
At Router C-
 

Destination Distance Next Hop


A ∞ –

B 3 B

C 0 C

D 11 D

 
At Router D-
 

Destination Distance Next Hop

A 1 A

B 7 B

C 11 C

D 0 D

Step-02:
 

 Each router exchanges its distance vector obtained in Step-01 with its neighbors.
 After exchanging the distance vectors, each router prepares a new routing table.
 
This is shown below-
 
At Router A-
 
 Router A receives distance vectors from its neighbors B and D.
 Router A prepares a new routing table as-
 

 Cost of reaching destination B from router A = min { 2+0 , 1+7 } = 2 via B.


 Cost of reaching destination C from router A = min { 2+3 , 1+11 } = 5 via B.
 Cost of reaching destination D from router A = min { 2+7 , 1+0 } = 1 via D.
 

Explanation For Destination B


 

 Router A can reach the destination router B via its neighbor B or neighbor D.
 It chooses the path which gives the minimum cost.
 Cost of reaching router B from router A via neighbor B = Cost (A→B) + Cost (B→B)= 2 +
0 = 2
 Cost of reaching router B from router A via neighbor D = Cost (A→D) + Cost (D→B) = 1 +
7 = 8
 Since the cost is minimum via neighbor B, so router A chooses the path via B.
 It creates an entry (2, B) for destination B in its new routing table.
 Similarly, we calculate the shortest path distance to each destination router at every
router.

 
Thus, the new routing table at router A is-
 
Destination Distance Next Hop

A 0 A

B 2 B

C 5 B

D 1 D

 
At Router B-
 

 Router B receives distance vectors from its neighbors A, C and D.


 Router B prepares a new routing table as-
 

 Cost of reaching destination A from router B = min { 2+0 , 3+∞ , 7+1 } = 2 via A.
 Cost of reaching destination C from router B = min { 2+∞ , 3+0 , 7+11 } = 3 via C.
 Cost of reaching destination D from router B = min { 2+1 , 3+11 , 7+0 } = 3 via A.
 
Thus, the new routing table at router B is-
 

Destination Distance Next Hop

A 2 A

B 0 B

C 3 C

D 3 A

 
At Router C-
 

 Router C receives distance vectors from its neighbors B and D.


 Router C prepares a new routing table as-
 

 Cost of reaching destination A from router C = min { 3+2 , 11+1 } = 5 via B.


 Cost of reaching destination B from router C = min { 3+0 , 11+7 } = 3 via B.
 Cost of reaching destination D from router C = min { 3+7 , 11+0 } = 10 via B.
 
Thus, the new routing table at router C is-
 

Destination Distance Next Hop

A 5 B

B 3 B

C 0 C

D 10 B

 
At Router D-
 

 Router D receives distance vectors from its neighbors A, B and C.


 Router D prepares a new routing table as-
 

 Cost of reaching destination A from router D = min { 1+0 , 7+2 , 11+∞ } = 1 via A.
 Cost of reaching destination B from router D = min { 1+2 , 7+0 , 11+3 } = 3 via A.
 Cost of reaching destination C from router D = min { 1+∞ , 7+3 , 11+0 } = 10 via B.
 
Thus, the new routing table at router D is-
 

Destination Distance Next Hop

A 1 A

B 3 A

C 10 B

D 0 D

Step-03:
 

 Each router exchanges its distance vector obtained in Step-02 with its neighboring
routers.
 After exchanging the distance vectors, each router prepares a new routing table.
 
This is shown below-
 
At Router A-
 

 Router A receives distance vectors from its neighbors B and D.


 Router A prepares a new routing table as-
 
 

 Cost of reaching destination B from router A = min { 2+0 , 1+3 } = 2 via B.


 Cost of reaching destination C from router A = min { 2+3 , 1+10 } = 5 via B.
 Cost of reaching destination D from router A = min { 2+3 , 1+0 } = 1 via D.
 
Thus, the new routing table at router A is-
 

Destination Distance Next Hop

A 0 A

B 2 B

C 5 B

D 1 D

 
At Router B-
 

 Router B receives distance vectors from its neighbors A, C and D.


 Router B prepares a new routing table as-
 

 Cost of reaching destination A from router B = min { 2+0 , 3+5 , 3+1 } = 2 via A.
 Cost of reaching destination C from router B = min { 2+5 , 3+0 , 3+10 } = 3 via C.
 Cost of reaching destination D from router B = min { 2+1 , 3+10 , 3+0 } = 3 via A.
 
Thus, the new routing table at router B is-
 

Destination Distance Next Hop

A 2 A

B 0 B

C 3 C

D 3 A

 
At Router C-
 

 Router C receives distance vectors from its neighbors B and D.


 Router C prepares a new routing table as-
 

 Cost of reaching destination A from router C = min { 3+2 , 10+1 } = 5 via B.


 Cost of reaching destination B from router C = min { 3+0 , 10+3 } = 3 via B.
 Cost of reaching destination D from router C = min { 3+3 , 10+0 } = 6 via B.
 
Thus, the new routing table at router C is-
 

Destination Distance Next Hop

A 5 B

B 3 B

C 0 C

D 6 B

 
At Router D-
 
 Router D receives distance vectors from its neighbors A, B and C.
 Router D prepares a new routing table as-
 

 Cost of reaching destination A from router D = min { 1+0 , 3+2 , 10+5 } = 1 via A.
 Cost of reaching destination B from router D = min { 1+2 , 3+0 , 10+3 } = 3 via A.
 Cost of reaching destination C from router D = min { 1+5 , 3+3 , 10+0 } = 6 via A.
 
Thus, the new routing table at router D is-
 

Destination Distance Next Hop

A 1 A

B 3 A

C 6 A

D 0 D

 
These will be the final routing tables at each router.
 

Identifying Unused Links-


 
After routing tables converge (becomes stable),

 Some of the links connecting the routers may never be used.


 In the above example, we can identify the unused links as-
 
We have-

 The value of next hop in the final routing table of router A suggests that only edges
AB and AD are used.
 The value of next hop in the final routing table of router B suggests that only edges
BA and BC are used.
 The value of next hop in the final routing table of router C suggests that only edge
CB is used.
 The value of next hop in the final routing table of router D suggests that only edge
DA is used.
 
Thus, edges BD and CD are never used.
 

Important Notes-
 

Note-01:
 
In Distance Vector Routing,

 Only distance vectors are exchanged.


 “Next hop”values are not exchanged.
 This is because it results in exchanging the large amount of data which consumes
more bandwidth.
 

Note-02:
 
While preparing a new routing table-
 A router takes into consideration only the distance vectors it has obtained from its
neighboring routers.
 It does not take into consideration its old routing table.
 

Note-03:
 
The algorithm is called so because-

 It involves exchanging of distance vectors between the routers.


 Distance vector is nothing but an array of distances.
 

Note-04:
 

 The algorithm keeps on repeating periodically and never stops.


 This is to update the shortest path in case any link goes down or topology changes.
 

Note-05:
 

 Routing tables are prepared total (n-1) times if there are n routers in the given
network.
 This is because shortest path between any 2 nodes contains at most n-1 edges if
there are n nodes in the graph.
 

Note-06:
 

 Distance Vector Routing suffers from count to infinity problem.


 Distance Vector Routing uses UDP at transport layer.
 

IP Address in Networking-
 
In networking,

 IP Address is short for Internet Protocol Address.


 It is a unique address assigned to each computing device in an IP network.
 ISP assigns IP Address to all the devices present on its network.
 Computing devices use IP Address to identify and communicate with other devices
in the IP network.
 

Types Of IP Address-
 
IP Addresses may be of the following two types-
 

 
1. Static IP Address
2. Dynamic IP Address
 

1. Static IP Address-
 

 Static IP Address is an IP Address that once assigned to a network element always


remains the same.
 They are configured manually.
 

NOTE
 Some ISPs do not provide static IP addresses.
 Static IP Addresses are more costly than dynamic IP Addresses.

2. Dynamic IP Address-
 
 Dynamic IP Address is a temporarily assigned IP Address to a network element.
 It can be assigned to a different device if it is not in use.
 DHCP or PPPoE assigns dynamic IP addresses.
 

IP Address Format-
 

 IP Address is a 32 bit binary address written as 4 numbers separated by dots.


 The 4 numbers are called as octets where each octet has 8 bits.
 The octets are divided into 2 components- Net ID and Host ID.
 

 
1. Network ID represents the IP Address of the network and is used to identify the
network.
2. Host ID represents the IP Address of the host and is used to identify the host within
the network.
 

IP Address Example-
 
Example of an IP Address is-
00000001.10100000.00001010.11110000
(Binary Representation)
OR
1.160.10.240
(Decimal Representation)
 

IP Addressing-
 
There are two systems in which IP Addresses are classified-
 

 
1. Classful Addressing System
2. Classless Addressing System
 
In this article, we will discuss about Classful Addressing System.
Learn about Classless Addressing System.
 

Classful Addressing-
 
In Classful Addressing System, IP Addresses are organized into following 5 classes-
 

 
1. Class A
2. Class B
3. Class C
4. Class D
5. Class E
 

1. Class A-
 

If the 32 bit binary address starts with a bit 0, then IP Address belongs to class A.

 
In class A IP Address,

 The first 8 bits are used for the Network ID.


 The remaining 24 bits are used for the Host ID.
 

 
Total Number Of IP Addresses-
 
Total number of IP Addresses available in class A
= Numbers possible due to remaining available 31 bits
= 231
 
Total Number Of Networks-
 
Total number of networks available in class A
= Numbers possible due to remaining available 7 bits in the Net ID – 2
= 27 – 2
= 126
(The reason of subtracting 2 is explained later.)
 
Total Number Of Hosts-
 
Total number of hosts that can be configured in class A
= Numbers possible due to available 24 bits in the Host ID – 2
= 224 – 2
(The reason of subtracting 2 is explained later.)
 
Range Of 1st Octet-
 
We have-

 Minimum value of 1st octet = 00000000 = 0


 Maximum value of 1st octet = 01111111 = 127
 
From here,

 Range of 1st octet = [0, 127]


 But 2 networks are reserved and unused.
 So, Range of 1st octet = [1, 126]
 

Use-
 

 Class A is used by organizations requiring very large size networks like NASA,
Pentagon etc.
 

2. Class B-
 

If the 32 bit binary address starts with bits 10, then IP Address belongs to class B.
 
In class B IP Address,

 The first 16 bits are used for the Network ID.


 The remaining 16 bits are used for the Host ID.
 

 
Total Number Of IP Addresses-
 
Total number of IP Addresses available in class B
= Numbers possible due to remaining available 30 bits
= 230
 
Total Number Of Networks-
 
Total number of networks available in class B
= Numbers possible due to remaining available 14 bits in the Net ID
= 214
 
Total Number Of Hosts-
 
Total number of hosts that can be configured in class B
= Numbers possible due to available 16 bits in the Host ID – 2
= 216 – 2
 
Range Of 1st Octet-
 
We have-

 Minimum value of 1st octet = 10000000 = 128


 Maximum value of 1st octet = 10111111 = 191
 
So, Range of 1st octet = [128, 191]
 

Use-
 

 Class B is used by organizations requiring medium size networks like IRCTC, banks
etc.
 

3. Class C-
 

If the 32 bit binary address starts with bits 110, then IP Address belongs to class C.

 
In class C IP Address,

 The first 24 bits are used for the Network ID.


 The remaining 8 bits are used for the Host ID.
 

 
Total Number Of IP Addresses-
 
Total number of IP Addresses available in class C
= Numbers possible due to remaining available 29 bits
= 229
 
Total Number Of Networks-
 
Total number of networks available in class C
= Numbers possible due to remaining available 21 bits in the Net ID
= 221
 
Total Number Of Hosts-
 
Total number of hosts that can be configured in class C
= Numbers possible due to available 8 bits in the Host ID – 2
= 28 – 2
 
Range Of 1st Octet-
 
We have-
 Minimum value of 1st octet = 11000000 = 192
 Maximum value of 1st octet = 110111111 = 223
 
So, Range of 1st octet = [192, 223]
 

Use-
 

 Class C is used by organizations requiring small to medium size networks.


 For example- engineering colleges, small universities, small offices etc.
 
4. Class D-
 

If the 32 bit binary address starts with bits 1110, then IP Address belongs to class D.

 Class D is not divided into Network ID and Host ID.


 

 
Total Number Of IP Addresses-
 
Total number of IP Addresses available in class D
= Numbers possible due to remaining available 28 bits
= 228
 
Range Of 1st Octet-
 
We have-

 Minimum value of 1st octet = 11100000 = 224


 Maximum value of 1st octet = 11101111 = 239
 
So, Range of 1st octet = [224, 239]
 

Use-
 

 Class D is reserved for multicasting.


 In multicasting, there is no need to extract host address from the IP Address.
 This is because data is not destined for a particular host.
 

5. Class E-
 

If the 32 bit binary address starts with bits 1111, then IP Address belongs to class E.

 Class E is not divided into Network ID and Host ID.


 

 
Total Number Of IP Addresses-
 
Total number of IP Addresses available in class E
= Numbers possible due to remaining available 28 bits
= 228
 
Range Of 1st Octet-
 
We have-

 Minimum value of 1st octet = 11110000 = 240


 Maximum value of 1st octet = 11111111 = 255
 
So, Range of 1st octet = [240, 255]
 
Use-
 

 Class E is reserved for future or experimental purposes.


 

Classes of IP Address-
 
All the classes of IP Address are summarized in the following table-
 

1st Octet Number of


Class of IP Total Number of Hosts per Default
Decimal Networks
Address IP Addresses network Subnet Mask
Range available

Class A 231 1 – 126 27 – 2 224 – 2 255.0.0.0

Class B 230 128 – 191 214 216 – 2 255.255.0.0

Class C 229 192 – 223 221 28 – 2 255.255.255.0

Class D 228 224 – 239 Not defined Not defined Not defined

Class E 228 240 – 254 Not defined Not defined Not defined

 
Also Read-Practice Problems On IP Addressing
 

Important Notes-
 

Note-01:
 

 All the hosts in a single network always have the same network ID but different Host
ID.
 However, two hosts in two different networks can have the same host ID.
 

Note-02:
 

 A single network interface can be associated with more than one IP Address.
 

Note-03:
 

 There is no relation between MAC Address and IP Address of a host.


 

Note-04:
 

 IP Address of the network called Net ID is obtained by setting all the bits for Host ID
to zero.
 

Note-05:
 

 Class A Networks accounts for half of the total available IP Addresses.


 

Note-06:
 

In class A, total number of IP Addresses available for networks are 2 less.

 This is to account for the two reserved network IP Addresses 0.xxx.xxx.xxx and
127.xxx.xxx.xxx.
 IP Address 0.0.0.0 is reserved for broadcasting requirements.
 IP Address 127.0.0.1 is reserved for loopback address used for software testing.
 

Note-07:
 
In all the classes, total number of hosts that can be configured are 2 less.

 This is to account for the two reserved IP addresses in which all the bits for host ID
are either zero or one.
 When all Host ID bits are 0, it represents the Network ID for the network.
 When all Host ID bits are 1, it represents the Broadcast Address.
 

Note-08:
 

 Only those devices which have the network layer will have IP Address.
 So, switches, hubs and repeaters does not have any IP Address.

IP Address in Networking-

In networking,
 IP Address is short for Internet Protocol Address.
 It is a unique address assigned to each computing device in an IP network.
 ISP assigns IP Address to all the devices present on its network.
 Computing devices use IP Address to identify and communicate with other devices
in the IP network.
 

Types Of IP Address-
 
IP Addresses may be of the following two types-
 
 
1. Static IP Address
2. Dynamic IP Address
 

1. Static IP Address-
 

 Static IP Address is an IP Address that once assigned to a network element always


remains the same.
 They are configured manually.
 

NOTE
 Some ISPs do not provide static IP addresses.
 Static IP Addresses are more costly than dynamic IP Addresses.

2. Dynamic IP Address-
 

 Dynamic IP Address is a temporarily assigned IP Address to a network element.


 It can be assigned to a different device if it is not in use.
 DHCP or PPPoE assigns dynamic IP addresses.
 

IP Address Format-
 

 IP Address is a 32 bit binary address written as 4 numbers separated by dots.


 The 4 numbers are called as octets where each octet has 8 bits.
 The octets are divided into 2 components- Net ID and Host ID.
 
 
1. Network ID represents the IP Address of the network and is used to identify the
network.
2. Host ID represents the IP Address of the host and is used to identify the host within
the network.
 

IP Address Example-
 
Example of an IP Address is-
00000001.10100000.00001010.11110000
(Binary Representation)
OR
1.160.10.240
(Decimal Representation)
 

IP Addressing-
 
There are two systems in which IP Addresses are classified-
 

 
1. Classful Addressing System
2. Classless Addressing System
 
In this article, we will discuss about Classful Addressing System.
Learn about Classless Addressing System.
 

Classful Addressing-
 
In Classful Addressing System, IP Addresses are organized into following 5 classes-
 

 
1. Class A
2. Class B
3. Class C
4. Class D
5. Class E
 

1. Class A-
 

If the 32 bit binary address starts with a bit 0, then IP Address belongs to class A.

 
In class A IP Address,

 The first 8 bits are used for the Network ID.


 The remaining 24 bits are used for the Host ID.
 
 

Total Number Of IP Addresses-


 
Total number of IP Addresses available in class A
= Numbers possible due to remaining available 31 bits
= 231
 

Total Number Of Networks-


 
Total number of networks available in class A
= Numbers possible due to remaining available 7 bits in the Net ID – 2
= 27 – 2
= 126
(The reason of subtracting 2 is explained later.)
 

Total Number Of Hosts-


 
Total number of hosts that can be configured in class A
= Numbers possible due to available 24 bits in the Host ID – 2
= 224 – 2
(The reason of subtracting 2 is explained later.)
 

Range Of 1st Octet-


 
We have-

 Minimum value of 1st octet = 00000000 = 0


 Maximum value of 1st octet = 01111111 = 127
 
From here,

 Range of 1st octet = [0, 127]


 But 2 networks are reserved and unused.
 So, Range of 1st octet = [1, 126]
 

Use-
 

 Class A is used by organizations requiring very large size networks like NASA,
Pentagon etc.
 

2. Class B-
 

If the 32 bit binary address starts with bits 10, then IP Address belongs to class B.

 
In class B IP Address,

 The first 16 bits are used for the Network ID.


 The remaining 16 bits are used for the Host ID.
 

 
Total Number Of IP Addresses-
 
Total number of IP Addresses available in class B
= Numbers possible due to remaining available 30 bits
= 230
 

Total Number Of Networks-


 
Total number of networks available in class B
= Numbers possible due to remaining available 14 bits in the Net ID
= 214
 

Total Number Of Hosts-


 
Total number of hosts that can be configured in class B
= Numbers possible due to available 16 bits in the Host ID – 2
= 216 – 2
 

Range Of 1st Octet-


 
We have-

 Minimum value of 1st octet = 10000000 = 128


 Maximum value of 1st octet = 10111111 = 191
 
So, Range of 1st octet = [128, 191]
 

Use-
 

 Class B is used by organizations requiring medium size networks like IRCTC, banks
etc.
 
3. Class C-
 

If the 32 bit binary address starts with bits 110, then IP Address belongs to class C.

 
In class C IP Address,

 The first 24 bits are used for the Network ID.


 The remaining 8 bits are used for the Host ID.
 

Total Number Of IP Addresses-


 
Total number of IP Addresses available in class C
= Numbers possible due to remaining available 29 bits
= 229
 

Total Number Of Networks-


 
Total number of networks available in class C
= Numbers possible due to remaining available 21 bits in the Net ID
= 221
 

Total Number Of Hosts-


 
Total number of hosts that can be configured in class C
= Numbers possible due to available 8 bits in the Host ID – 2
= 28 – 2
 

Range Of 1st Octet-


 
We have-

 Minimum value of 1st octet = 11000000 = 192


 Maximum value of 1st octet = 110111111 = 223
 
So, Range of 1st octet = [192, 223]
 

Use-
 

 Class C is used by organizations requiring small to medium size networks.


 For example- engineering colleges, small universities, small offices etc.
 

4. Class D-
 

If the 32 bit binary address starts with bits 1110, then IP Address belongs to class D.

 Class D is not divided into Network ID and Host ID.


 
 

Total Number Of IP Addresses-


 
Total number of IP Addresses available in class D
= Numbers possible due to remaining available 28 bits
= 228
 

Range Of 1st Octet-


 
We have-
 Minimum value of 1st octet = 11100000 = 224
 Maximum value of 1st octet = 11101111 = 239
 
So, Range of 1st octet = [224, 239]
 

Use-
 

 Class D is reserved for multicasting.


 In multicasting, there is no need to extract host address from the IP Address.
 This is because data is not destined for a particular host.
 

5. Class E-
 

If the 32 bit binary address starts with bits 1111, then IP Address belongs to class E.

 Class E is not divided into Network ID and Host ID.


 
 

Total Number Of IP Addresses-


 
Total number of IP Addresses available in class E
= Numbers possible due to remaining available 28 bits
= 228
 

Range Of 1st Octet-


 
We have-

 Minimum value of 1st octet = 11110000 = 240


 Maximum value of 1st octet = 11111111 = 255
 
So, Range of 1st octet = [240, 255]
 

Use-
 

 Class E is reserved for future or experimental purposes.


 

Classes of IP Address-
 
All the classes of IP Address are summarized in the following table-
 

Class of Total Number 1st Octet Number of Hosts per Default


IP Decimal Networks Subnet
of IP Addresses network
Address Range available Mask

Class A 231 1 – 126 27 – 2 224 – 2 255.0.0.0

Class B 230 128 – 191 214 216 – 2 255.255.0.0

Class C 229 192 – 223 221 28 – 2 255.255.255.0

Class D 228 224 – 239 Not defined Not defined Not defined

Class E 228 240 – 254 Not defined Not defined Not defined

 
Also Read-Practice Problems On IP Addressing
 

Important Notes-
 

Note-01:
 

 All the hosts in a single network always have the same network ID but different Host
ID.
 However, two hosts in two different networks can have the same host ID.
 

Note-02:
 

 A single network interface can be associated with more than one IP Address.
 

Note-03:
 

 There is no relation between MAC Address and IP Address of a host.


 

Note-04:
 

 IP Address of the network called Net ID is obtained by setting all the bits for Host ID
to zero.
 

Note-05:
 

 Class A Networks accounts for half of the total available IP Addresses.


 

Note-06:
 

In class A, total number of IP Addresses available for networks are 2 less.

 This is to account for the two reserved network IP Addresses 0.xxx.xxx.xxx and
127.xxx.xxx.xxx.
 IP Address 0.0.0.0 is reserved for broadcasting requirements.
 IP Address 127.0.0.1 is reserved for loopback address used for software testing.
 

Note-07:
 

In all the classes, total number of hosts that can be configured are 2 less.

 This is to account for the two reserved IP addresses in which all the bits for host ID
are either zero or one.
 When all Host ID bits are 0, it represents the Network ID for the network.
 When all Host ID bits are 1, it represents the Broadcast Address.
 

Note-08:
 
 Only those devices which have the network layer will have IP Address.
 So, switches, hubs and repeaters does not have any IP Address.
 

Casting in Networking-
 

Transmitting data (stream of packets) over the network is termed as casting.

Types Of Casting-
 

 
1. Unicast
2. Broadcast
3. Multicast
 

1. Unicast-
 

 Transmitting data from one source host to one destination host is called as unicast.
 It is a one to one transmission.
 
 

Example-
 
Host A having IP Address 11.1.2.3 sending data to host B having IP Address 20.12.4.2.
Here,

 Source Address = IP Address of host A = 11.1.2.3


 Destination Address = IP Address of host B = 20.12.4.2
 

2. Broadcast-
 

 Transmitting data from one source host to all other hosts residing in the same or
other network is called as broadcast.
 It is a one to all transmission.
 
Based on recipient’s network, it is classified as-
1. Limited Broadcast
2. Direct Broadcast
 

A. Limited Broadcast-
 

 Transmitting data from one source host to all other hosts residing in the same
network is called as limited broadcast.
 
 

NOTE
Limited Broadcast Address for any network
= All 32 bits set to 1
= 11111111.11111111.11111111.11111111
= 255.255.255.255

Example-
 
Host A having IP Address 11.1.2.3 sending data to all other hosts residing in the same
network.
Here,

 Source Address = IP Address of host A = 11.1.2.3


 Destination Address = 255.255.255.255
 

B. Direct Broadcast-
 

 Transmitting data from one source host to all other hosts residing in some other
network is called as direct broadcast.
 
 

NOTE
Direct Broadcast Address for any network is the IP Address where-

 Network ID is the IP Address of the network where all the destination hosts are present.
 Host ID bits are all set to 1.

Example-
 
Host A having IP Address 11.1.2.3 sending data to all other hosts residing in the network
having IP Address 20.0.0.0
Here,

 Source Address = IP Address of host A = 11.1.2.3


 Destination Address = 20.255.255.255
 

3. Multicast-
 

 Transmitting data from one source host to a particular group of hosts having interest
in receiving the data is called as multicast.
 It is a one to many transmission.
 
 

Examples-
 

 Sending a message to a particular group of people on whatsapp


 Sending an email to a particular group of people
 Video conference or teleconference
 

MAC Address Vs IP Address-


 
The following table summarizes the differences between MAC Address and IP Address-
 

MAC Address IP Address

It stands for Media Access Control Address. It stands for Internet Protocol Address.

MAC Address identifies the physical address IP Address identifies the connection of a
of a computer on the internet. computer on the internet.

Manufacturer of NIC card assigns the MAC Network Administrator or ISP assigns the IP
Address. Address.

Reverse Address Resolution Protocol (RARP) Address Resolution Protocol (ARP) is used for
is used for resolving physical (MAC) Address resolving IP Address into physical (MAC)
into IP address. address.

NOTE-
 

 Multicast makes use of IGMP (Internet Group Management Protocol) to identify its
group.
 Each group is assigned with an IP Address from class D of IPv4.
 

Important Points-
 

Point-01:
 
For any given IP Address,

 If the range of first octet is [1, 126], then IP Address belongs to class A.
 If the range of first octet is [128, 191], then IP Address belongs to class B.
 If the range of first octet is [192, 223], then IP Address belongs to class C.
 If the range of first octet is [224, 239], then IP Address belongs to class D.
 If the range of first octet is [240, 254], then IP Address belongs to class E.
 

Point-02:
 
For any given IP Address,

 IP Address of its network is obtained by setting all its Host ID part bits to 0.
 

Point-03:
 
For any given IP Address,

 Direct Broadcast Address is obtained by setting all its Host ID part bits to 1.
 
Point-04:
 

 For any given IP Address, limited Broadcast Address is obtained by setting all its bits
to 1.
 For any network, its limited broadcast address is always 255.255.255.255
 

Point-05:
 

 Class D IP Addresses are not divided into Net ID and Host ID parts.
 Class E IP Addresses are not divided into Net ID and Host ID parts.
 

PRACTICE PROBLEMS BASED ON IP ADDRESS IN


NETWORKING-
 

Problem-01:
 
For the following IP Addresses-
1. 1.2.3.4
2. 10.15.20.60
3. 130.1.2.3
4. 150.0.150.150
5. 200.1.10.100
6. 220.15.1.10
7. 250.0.1.2
8. 300.1.2.3
 
Identify the Class, Network IP Address, Direct broadcast address and Limited broadcast
address of each IP Address.
 

Solution-
 

Part-A:
 
Given IP Address is-
1.2.3.4
 

 IP Address belongs to class A


 Network IP Address = 1.0.0.0
 Direct Broadcast Address = 1.255.255.255
 Limited Broadcast Address = 255.255.255.255
 

Part-B:
 
Given IP Address is-
10.15.20.60
 

 IP Address belongs to class A


 Network IP Address = 10.0.0.0
 Direct Broadcast Address = 10.255.255.255
 Limited Broadcast Address = 255.255.255.255
 

Part-C:
 
Given IP Address is-
130.1.2.3
 

 IP Address belongs to class B


 Network IP Address = 130.1.0.0
 Direct Broadcast Address = 130.1.255.255
 Limited Broadcast Address = 255.255.255.255
 

Part-D:
 
Given IP Address is-
150.0.150.150
 

 IP Address belongs to class B


 Network IP Address = 150.0.0.0
 Direct Broadcast Address = 150.0.255.255
 Limited Broadcast Address = 255.255.255.255
 

Part-E:
 
Given IP Address is-
200.1.10.100
 

 IP Address belongs to class C


 Network IP Address = 200.1.10.0
 Direct Broadcast Address = 200.1.10.255
 Limited Broadcast Address = 255.255.255.255
 

Part-F:
 
Given IP Address is-
220.15.1.10
 

 IP Address belongs to class C


 Network IP Address = 220.15.1.0
 Direct Broadcast Address = 220.15.1.255
 Limited Broadcast Address = 255.255.255.255
 

Part-G:
 
Given IP Address is-
250.0.1.2
 

 IP Address belongs to class E


 Network IP Address = Not available
 Direct Broadcast Address = Not available
 Limited Broadcast Address = Not available
 

Part-H:
 
Given IP Address is-
300.1.2.3
 

 This is not a valid IP Address.


 This is because for any given IP Address, the range of its first octet is always [1,
254].
 First and Last IP Addresses are reserved.
 

Problem-02:
 
A device has two or more IP Addresses, the device is called-
1. Workstation
2. Router
3. Gateway
4. All of these
 

Solution-
 

 All the given devices have a network layer.


 So, they will have at least one IP Address.
 
In TCP/IP suite-

 Workstation and gateway have all the 5 layers.


 Router has only 3 layers last layer being network layer.
 

Workstation-
 
 A user may configure more than one IP Addresses in his workstation / computer.
 With more than one IP Address, it remains present in more than one networks.
 So, if one network goes down, it is always reachable from other networks.
 
The following figure shows a host present in more than one networks-
 

 It is important to note that IP Addresses are assigned to interfaces.


 When we buy a new laptop, we usually get 2-3 interfaces.
 Thus, a workstation can have more than one IP Addresses.
 

Router-
 

 A router may be connected to various interfaces.


 Each interface has a unique IP Address.
 Thus, a router may also have more than IP Addresses.
 Similar is the case with gateways because gateways are extension of routers.
 
Thus, Option (D) is correct.
 

Problem-03:
 
A host with IP Address 200.100.1.1 wants to send a packet to all the hosts in the same
network.
What will be-
1. Source IP Address
2. Destination IP Address
 

Solution-
 
1. Source IP Address = IP Address of the sender = 200.100.1.1
2. Destination IP Address = Limited Broadcast Address = 255.255.255.255
 

Problem-04:
 
A host with IP Address 10.100.100.100 wants to use loop back testing.
What will be-
1. Source IP Address
2. Destination IP Address
 

Solution-
 

 Source IP Address = 10.100.100.100


 Destination IP Address = Loopback Testing Address = 127.0.0.1
 

Problem-05:
 
How many bits are allocated for Network ID and Host ID in 23.192.157.234 address?
 

Solution-
 
Given IP Address belongs to class A.
Thus,
 Number of bits reserved for Network ID = 8
 Number of bits reserved for Host ID = 24
 

Problem-06:
 
Which devices can use logical addressing system?
1. Hub
2. Switch
3. Bridge
4. Router
 

Solution-
 

 Devices which have network layer as the last layer can only use logical addressing
system.
 Devices which have data link layer as the last layer can only use physical addressing
system.
 IP Addresses are the logical addresses and MAC Addresses are the physical
addresses.
 

Option-A:
 

 Hub can neither use physical addressing system nor logical addressing system.
 This is because it has physical layer as the last layer.
 

Option-B:
 

 Switch can use physical addressing system but not logical addressing system.
 This is because it has data link layer as the last layer.
 

Option-C:
 

 Bridge can use physical addressing system but not logical addressing system.
 This is because it has data link layer as the last layer.
 

Option-D:
 

 Router can use physical addressing system as well as logical addressing system.
 This is because it has network layer as the last layer.
 
Thus, option (D) is correct.
 

Problem-07:
 
What is the network ID of the IP Address 230.100.123.70?
 

Solution-
 

 Given IP Address belongs to class D.


 Class D IP Addresses are not divided into the Network ID and Host ID parts.
 Thus, there is no network ID for the given IP Address.
 

Problem-08:
 
Match the following-
 
Column-I:
 
1. 200.10.192.100
2. 7.10.230.1
3. 128.1.1.254
4. 255.255.255.255
5. 100.255.255.255
 
Column-II:
 
1. Class A
2. Limited Broadcast Address
3. Direct Broadcast Address
4. Class C
5. Class B
 

Solution-
 
(I, D), (II, A), (III, E), (IV, B), (V, C)
 

Problem-09:
 
Suppose that instead of using 16 bits for network part of a class B Address, 20 bits have
been used. How many class B networks would have been possible?
 

Solution-
 

 Total 20 bits are used for Network ID of class B.


 The first two bits are always set to 10.
 Then, with 18 bits, number of networks possible = 218
 

Problem-10:
 
What is the default mask for 192.0.46.10?

Solution-
 

 Given IP Address belongs to class C.


 For class C, default mask = 255.255.255.0

 IP Addressing-

There are two systems in which IP Addresses are classified-


1. Classful Addressing System
2. Classless Addressing System
 
In this article, we will discuss about Classless Addressing System.
Learn about Classful Addressing System.
 

Classless Addressing-
 

 Classless Addressing is an improved IP Addressing system.


 It makes the allocation of IP Addresses more efficient.
 It replaces the older classful addressing system based on classes.
 It is also known as Classless Inter Domain Routing (CIDR).
 

CIDR Block-
 
When a user asks for specific number of IP Addresses,

 CIDR dynamically assigns a block of IP Addresses based on certain rules.


 This block contains the required number of IP Addresses as demanded by the user.
 This block of IP Addresses is called as a CIDR block.
 
Rules For Creating CIDR Block-
 
A CIDR block is created based on the following 3 rules-
 

Rule-01:
 

 All the IP Addresses in the CIDR block must be contiguous.


 

Rule-02:
 

 The size of the block must be presentable as power of 2.


 Size of the block is the total number of IP Addresses contained in the block.
 Size of any CIDR block will always be in the form 21, 22, 23, 24, 25 and so on.
 

Rule-03:
 

 First IP Address of the block must be divisible by the size of the block.
 

REMEMBER
 
If any binary pattern consisting of (m + n) bits is divided by 2n, then-

 Remainder is least significant n bits


 Quotient is most significant m bits
 
So, any binary pattern is divisible by 2n, if and only if its least significant n bits are 0.
 

Examples-
 
Consider a binary pattern-
01100100.00000001.00000010.01000000
(represented as 100.1.2.64)

 It is divisible by 25 since its least significant 5 bits are zero.


 It is divisible by 26 since its least significant 6 bits are zero.
 It is not divisible by 27 since its least significant 7 bits are not zero.

CIDR Notation-
 
CIDR IP Addresses look like-
a.b.c.d / n
 

 They end with a slash followed by a number called as IP network prefix.


 IP network prefix tells the number of bits used for the identification of network.
 Remaining bits are used for the identification of hosts in the network.
 

Example-
 
An example of CIDR IP Address is-
182.0.1.2 / 28
 
It suggests-

 28 bits are used for the identification of network.


 Remaining 4 bits are used for the identification of hosts in the network.
 

PRACTICE PROBLEMS BASED ON CLASSLESS


INTER DOMAIN ROUTING-
 

Problem-01:
 
Given the CIDR representation 20.10.30.35 / 27. Find the range of IP Addresses in the
CIDR block.
 

Solution-
 
Given CIDR representation is 20.10.30.35 / 27.
 
It suggests-

 27 bits are used for the identification of network.


 Remaining 5 bits are used for the identification of hosts in the network.
 
Given CIDR IP Address may be represented as-
00010100.00001010.00011110.00100011 / 27
 
So,

 First IP Address = 00010100.00001010.00011110.00100000 = 20.10.30.32


 Last IP Address = 00010100.00001010.00011110.00111111 = 20.10.30.63
 
Thus, Range of IP Addresses = [ 20.10.30.32 , 20.10.30.63]
 

Problem-02:
 
Given the CIDR representation 100.1.2.35 / 20. Find the range of IP Addresses in the CIDR
block.
 

Solution-
 
Given CIDR representation is 100.1.2.35 / 20.
 
It suggests-

 20 bits are used for the identification of network.


 Remaining 12 bits are used for the identification of hosts in the network.
 
Given CIDR IP Address may be represented as-
01100100.00000001.00000010.00100011 / 20
 
So,

 First IP Address = 01100100.00000001.00000000.00000000 = 100.1.0.0


 Last IP Address = 01100100.00000001.00001111.11111111 = 100.1.15.255
 
Thus, Range of IP Addresses = [ 100.1.0.0 , 100.1.15.255]
 

Problem-03:
 
Consider a block of IP Addresses ranging from 100.1.2.32 to 100.1.2.47.
1. Is it a CIDR block?
2. If yes, give the CIDR representation.
 

Solution-
 
For any given block to be a CIDR block, 3 rules must be satisfied-
 

Rule-01:
 

 According to Rule-01, all the IP Addresses must be contiguous.


 Clearly, all the given IP Addresses are contiguous.
 So, Rule-01 is satisfied.
 

Rule-02:
 

 According to Rule-02, size of the block must be presentable as 2n.


 Number of IP Addresses in the given block = 47 – 32 + 1 = 16.
 Size of the block = 16 which can be represented as 24.
 So, Rule-02 is satisfied.
 

Rule-03:
 

 According to Rule-03, first IP Address must be divisible by size of the block.


 So, 100.1.2.32 must be divisible by 24.
 100.1.2.32 = 100.1.2.00100000 is divisible by 24 since its 4 least significant bits are
zero.
 So, Rule-03 is satisfied.
 
Since all the rules are satisfied, therefore given block is a CIDR block.
 

CIDR Representation-
 
We have-

 Size of the block = Total number of IP Addresses = 24.


 To have 24 total number of IP Addresses, total 4 bits are required in the Host ID part.
 So, Number of bits present in the Network ID part = 32 – 4 = 28.
 
Thus,

CIDR Representation = 100.1.2.32 / 28

NOTE-
 
For writing the CIDR representation,

 We can choose to mention any IP Address from the CIDR block.


 The chosen IP Address is followed by a slash and IP network prefix.
 We generally choose to mention the first IP Address.
 

Problem-04:
 
Consider a block of IP Addresses ranging from 150.10.20.64 to 150.10.20.127.
1. Is it a CIDR block?
2. If yes, give the CIDR representation.
 

Solution-
 
For any given block to be a CIDR block, 3 rules must be satisfied-
 

Rule-01:
 

 According to Rule-01, all the IP Addresses must be contiguous.


 Clearly, all the given IP Addresses are contiguous.
 So, Rule-01 is satisfied.
 

Rule-02:
 

 According to Rule-02, size of the block must be presentable as 2n.


 Number of IP Addresses in given block = 127 – 64 + 1 = 64.
 Size of the block = 64 which can be represented as 26.
 So, Rule-02 is satisfied.
 

Rule-03:
 

 According to Rule-03, first IP Address must be divisible by size of the block.


 So, 150.10.20.64 must be divisible by 26.
 150.10.20.64 = 150.10.20.01000000 is divisible by 26 since its 6 least significant bits
are zero.
 So, Rule-03 is satisfied.
 
Since all the rules are satisfied, therefore given block is a CIDR block.
 

CIDR Representation-
 
We have-

 Size of the block = Total number of IP Addresses = 26.


 To have 26 total number of IP Addresses, 6 bits are required in the Host ID part.
 So, Number of bits in the Network ID part = 32 – 6 = 26.
 
Thus,

CIDR Representation = 150.10.20.64 / 26

Problem-05:
 
Perform CIDR aggregation on the following IP Addresses-
128.56.24.0/24
128.56.25.0/24
128.56.26.0/24
128.56.27.0/24
 

Solution-
 
All the 4 given entities represent CIDR block in itself.
We have to now perform the aggregation of these 4 blocks.
 

Rule-01:
 

 According to Rule-01, all the IP Addresses must be contiguous.


 Clearly, all the IP Addresses are contiguous.
 So, Rule-01 is satisfied.
 

Rule-02:
 

 According to Rule-02, size of the block must be presentable as 2n.


 Total number of IP Addresses = 28 + 28 + 28 + 28 = 22 x 28 = 210.
 So, Rule-02 is satisfied.
 

Rule-03:
 

 According to Rule-03, first IP Address must be divisible by size of the block.


 So, 128.56.24.0 must be divisible by 210.
 128.56.24.0 = 128.56.00011000.00000000 is divisible by 210 since its 10 least
significant bits are zero.
 So, Rule-03 is satisfied.
 
Since all the 3 rules are satisfied, so they can be aggregated.
 

CIDR Representation-
 
We have-

 Size of the block = Total number of IP Addresses = 210.


 To have 210 total number of IP Addresses, 10 bits are required in the Host ID part.
 So, Number of bits in the Network ID part = 32 – 10 = 22.
 
Thus,

CIDR Representation = 128.56.24.0/22

Problem-06:
 
Perform CIDR aggregation on the following IP Addresses-
200.96.86.0/24
200.96.87.0/24
200.96.88.0/24
200.96.89.0/24
 

Solution-
 
All the 4 given entities represent CIDR block in itself.
We have to now perform the aggregation of these 4 blocks.
 

Rule-01:
 
 According to Rule-01, all the IP Addresses must be contiguous.
 Clearly, all the IP Addresses are contiguous.
 So, Rule-01 is satisfied.
 

Rule-02:
 

 According to Rule-02, size of the block must be presentable as 2n.


 Total number of IP Addresses = 28 + 28 + 28 + 28 = 22 x 28 = 210.
 So, Rule-02 is satisfied.
 

Rule-03:
 

 According to Rule-03, first IP Address must be divisible by size of the block.


 So, 200.96.86.0 must be divisible by 210.
 200.96.86.0 = 200.96.01010110.00000000 is not divisible by 210 since its 10 least
significant bits are not zero.
 So, Rule-03 is unsatisfied.
 
Since all the 3 rules are not satisfied, so they can not be aggregated.

Subnetting in Networking-
 
In networking,
 The process of dividing a single network into multiple sub networks is called
as subnetting.
 The sub networks so created are called as subnets.
 

Example-
 
Following diagram shows the subnetting of a big single network into 4 smaller subnets-
 

Advantages-
 
The two main advantages of subnetting a network are-

 It improves the security.


 The maintenance and administration of subnets is easy.
 

Subnet ID-
 

 Each subnet has its unique network address known as its Subnet ID.
 The subnet ID is created by borrowing some bits from the Host ID part of the IP
Address.
 The number of bits borrowed depends on the number of subnets created.
 

Types of Subnetting-
 
Subnetting of a network may be carried out in the following two ways-
 

 
1. Fixed Length Subnetting
2. Variable Length Subnetting
 

1. Fixed Length Subnetting-


 
Fixed length subnetting also called as classfulsubnetting divides the network into subnets
where-

 All the subnets are of same size.


 All the subnets have equal number of hosts.
 All the subnets have same subnet mask.
 

2. Variable Length Subnetting-


 
Variable length subnetting also called as classless subnetting divides the network into
subnets where-

 All the subnets are not of same size.


 All the subnets do not have equal number of hosts.
 All the subnets do not have same subnet mask.
 

Subnetting Examples-
 
Now, we shall discuss some examples of subnetting a network-
 

Example-01:
 
Consider-

 We have a big single network having IP Address 200.1.2.0.


 We want to do subnetting and divide this network into 2 subnets.
 
Clearly, the given network belongs to class C.
 

 
Also Read-Classes of IP Address
 
For creating two subnets and to represent their subnet IDs, we require 1 bit.
So,

 We borrow one bit from the Host ID part.


 After borrowing one bit, Host ID part remains with only 7 bits.
 

 
 If borrowed bit = 0, then it represents the first subnet.
 If borrowed bit = 1, then it represents the second subnet.
 
IP Address of the two subnets are-

 200.1.2.00000000 = 200.1.2.0
 200.1.2.10000000 = 200.1.2.128
 

For 1st Subnet-


 

 IP Address of the subnet = 200.1.2.0


 Total number of IP Addresses = 27 = 128
 Total number of hosts that can be configured = 128 – 2 = 126
 Range of IP Addresses = [200.1.2.00000000, 200.1.2.01111111] = [200.1.2.0,
200.1.2.127]
 Direct Broadcast Address = 200.1.2.01111111 = 200.1.2.127
 Limited Broadcast Address = 255.255.255.255
 

For 2nd Subnet-


 

 IP Address of the subnet = 200.1.2.128


 Total number of IP Addresses = 27 = 128
 Total number of hosts that can be configured = 128 – 2 = 126
 Range of IP Addresses = [200.1.2.10000000, 200.1.2.11111111] = [200.1.2.128,
200.1.2.255]
 Direct Broadcast Address = 200.1.2.11111111 = 200.1.2.255
 Limited Broadcast Address = 255.255.255.255
 

Example-02:
 
Consider-

 We have a big single network having IP Address 200.1.2.0.


 We want to do subnetting and divide this network into 4 subnets.
 
Clearly, the given network belongs to class C.
 

 
For creating four subnets and to represent their subnet IDs, we require 2 bits.
So,

 We borrow two bits from the Host ID part.


 After borrowing two bits, Host ID part remains with only 6 bits.
 
 

 If borrowed bits = 00, then it represents the 1st subnet.


 If borrowed bits = 01, then it represents the 2nd subnet.
 If borrowed bits = 10, then it represents the 3rd subnet.
 If borrowed bits = 11, then it represents the 4th subnet.
 
IP Address of the four subnets are-

 200.1.2.00000000 = 200.1.2.0
 200.1.2.01000000 = 200.1.2.64
 200.1.2.10000000 = 200.1.2.128
 200.1.2.11000000 = 200.1.2.192
 

For 1st Subnet-


 

 IP Address of the subnet = 200.1.2.0


 Total number of IP Addresses = 26 = 64
 Total number of hosts that can be configured = 64 – 2 = 62
 Range of IP Addresses = [200.1.2.00000000, 200.1.2.00111111] = [200.1.2.0,
200.1.2.63]
 Direct Broadcast Address = 200.1.2.00111111 = 200.1.2.63
 Limited Broadcast Address = 255.255.255.255
 

For 2nd Subnet-


 

 IP Address of the subnet = 200.1.2.64


 Total number of IP Addresses = 26 = 64
 Total number of hosts that can be configured = 64 – 2 = 62
 Range of IP Addresses = [200.1.2.01000000, 200.1.2.01111111] = [200.1.2.64,
200.1.2.127]
 Direct Broadcast Address = 200.1.2.01111111 = 200.1.2.127
 Limited Broadcast Address = 255.255.255.255
 

For 3rd Subnet-


 

 IP Address of the subnet = 200.1.2.128


 Total number of IP Addresses = 26 = 64
 Total number of hosts that can be configured = 64 – 2 = 62
 Range of IP Addresses = [200.1.2.10000000, 200.1.2.10111111] = [200.1.2.128,
200.1.2.191]
 Direct Broadcast Address = 200.1.2.10111111 = 200.1.2.191
 Limited Broadcast Address = 255.255.255.255
 

For 4th Subnet-


 

 IP Address of the subnet = 200.1.2.192


 Total number of IP Addresses = 26 = 64
 Total number of hosts that can be configured = 64 – 2 = 62
 Range of IP Addresses = [200.1.2.11000000, 200.1.2.11111111] = [200.1.2.192,
200.1.2.255]
 Direct Broadcast Address = 200.1.2.11111111 = 200.1.2.255
 Limited Broadcast Address = 255.255.255.255
 

Example-03:
 
Consider-
 We have a big single network having IP Address 200.1.2.0.
 We want to do subnetting and divide this network into 3 subnets.
 
Here, the subnetting will be performed in two steps-
1. Dividing the given network into 2 subnets
2. Dividing one of the subnets further into 2 subnets
 

Step-01: Dividing Given Network into 2 Subnets-


 
The subnetting will be performed exactly in the same way as performed in Example-01.
After subnetting, we have-
 

Step-02: Dividing One Subnet into 2 Subnets-


 

 We perform the subnetting of one of the subnets further into 2 subnets.


 Consider we want to do subnetting of the 2nd subnet having IP Address 200.1.2.128.
 
For creating two subnets and to represent their subnet IDs, we require 1 bit.
So,

 We borrow one more bit from the Host ID part.


 After borrowing one bit, Host ID part remains with only 6 bits.
 
 

 If 2nd borrowed bit = 0, then it represents one subnet.


 If 2nd borrowed bit = 1, then it represents the other subnet.
 
IP Address of the two subnets are-

 200.1.2.10000000 = 200.1.2.128
 200.1.2.11000000 = 200.1.2.192
 

 
Finally, the given single network is divided into 3 subnets having IP Address-

 200.1.2.0
 200.1.2.128
 200.1.2.192
 

For 1st Subnet-


 
 IP Address of the subnet = 200.1.2.0
 Total number of IP Addresses = 27 = 128
 Total number of hosts that can be configured = 128 – 2 = 126
 Range of IP Addresses = [200.1.2.00000000, 200.1.2.01111111] = [200.1.2.0,
200.1.2.127]
 Direct Broadcast Address = 200.1.2.01111111 = 200.1.2.127
 Limited Broadcast Address = 255.255.255.255
 

For 2nd Subnet-


 

 IP Address of the subnet = 200.1.2.128


 Total number of IP Addresses = 26 = 64
 Total number of hosts that can be configured = 64 – 2 = 62
 Range of IP Addresses = [200.1.2.10000000, 200.1.2.10111111] = [200.1.2.128,
200.1.2.191]
 Direct Broadcast Address = 200.1.2.10111111 = 200.1.2.191
 Limited Broadcast Address = 255.255.255.255
 

For 3rd Subnet-


 

 IP Address of the subnet = 200.1.2.192


 Total number of IP Addresses = 26 = 64
 Total number of hosts that can be configured = 64 – 2 = 62
 Range of IP Addresses = [200.1.2.11000000, 200.1.2.11111111] = [200.1.2.192,
200.1.2.255]
 Direct Broadcast Address = 200.1.2.11111111 = 200.1.2.255
 Limited Broadcast Address = 255.255.255.255
 

Disadvantages of Subnetting-
 

Point-01:
 

Subnetting leads to loss of IP Addresses.


 
During subnetting,

 We have to face a loss of IP Addresses.


 This is because two IP Addresses are wasted for each subnet.
 One IP address is wasted for its network address.
 Other IP Address is wasted for its direct broadcasting address.
 

Point-02:
 

Subnetting leads to complicated communication process.

 
After subnetting, the communication process becomes complex involving the following 4
steps-
1. Identifying the network
2. Identifying the sub network
3. Identifying the host
4. Identifying the process
 

PRACTICE PROBLEMS BASED ON SUBNETTING IN


NETWORKING-
 

Problem-01:
 
Suppose a network with IP Address 192.16.0.0. is divided into 2 subnets, find number of
hosts per subnet.
Also for the first subnet, find-
1. Subnet Address
2. First Host ID
3. Last Host ID
4. Broadcast Address
 
Solution-
 

 Given IP Address belongs to class C.


 So, 24 bits are reserved for the Net ID.
 The given network is divided into 2 subnets.
 So, 1 bit is borrowed from the host ID part for the subnet IDs.
 Then, Number of bits remaining for the Host ID = 7.
 Thus, Number of hosts per subnet = 27 = 128.
 

For 1st Subnet-


 
 Subnet Address = First IP Address = 192.16.0.00000000 = 172.16.0.0
 First Host ID = 192.16.0.00000001 = 192.16.0.1
 Last Host ID = 192.16.0.01111110 = 192.16.0.126
 Broadcast Address = Last IP Address = 192.16.0.01111111 = 172.16.0.127
 

Problem-02:
 
What is not true about subnetting?
1. It is applied for a single network
2. It is used to improve security
3. Bits are borrowed from network portion
4. Bits are borrowed from Host portion
 

Solution-
 
Clearly, Option (C) is correct.
 

Problem-03:
 
In a class B, network on the internet has a subnet mask of 255.255.240.0. What is the
maximum number of hosts per subnet?
1. 4096
2. 4094
3. 4092
4. 4090
 

Solution-
 

 Number of bits reserved for network ID in the given subnet mask = 20.
 So, Number of bits reserved for Host ID = 32 – 20 = 12 bits.
 Thus, Number of hosts per subnet = 212 – 2 = 4094.
 In class B, 16 bits are reserved for the network.
 So, Number of bits reserved for subnet ID = 20 – 16 = 4 bits.
 Number of subnets possible = 24 = 16.
 Thus, Option (B) is correct.
 

Subnetting in Networking-
 
Before you go through this article, make sure that you have gone through the previous
article on Subnetting.
We have discussed-

 Subnetting is a process of dividing a single network into multiple sub networks.


 The number of sub networks created depends upon the requirements.
 

Subnet Mask-
 
Subnet mask is a 32 bit number which is a sequence of 1’s followed by a sequence of 0’s
where-

 1’s represent the global network ID part and the subnet ID part.
 0’s represent the host ID part.
 

How to Calculate Subnet Mask?


 
For any given IP Address, the subnet mask is calculated-

 By setting all the bits reserved for network ID part and subnet ID part to 1.
 By setting all the bits reserved for host ID part to 0.
 

Subnet Mask Examples-


 
Now, let us discuss some examples on how to calculate subnet mask for any given
network-
 

Example-01:
 
Consider we have a network having IP Address 200.1.2.0.

 
Clearly, this IP Address belongs to class C.
 
In class C-

 24 bits are reserved for the Network ID part.


 8 bits are reserved for the Host ID part.
 
Subnet mask is obtained-

 By setting the first 24 bits to 1.


 By setting the remaining 8 bits to 0.
 
So, Subnet mask
= 11111111.11111111.11111111.00000000
= 255.255.255.0
 

Example-02:
 
Consider a single network having IP Address 200.1.2.0 is divided into 4 subnets as shown-
 

 
Now, let us calculate the mask subnet for each subnet.
 
For each subnet-

 24 bits identify the global network.


 2 bits identify the subnet.
 6 bits identify the host.
 
For each subnet, subnet mask is obtained-

 By setting the first 26 bits to 1.


 By setting the remaining 6 bits to 0.
 
So, Subnet mask
= 11111111.11111111.11111111.11000000
= 255.255.255.192
 

NOTE
In fixed length subnetting,
All the subnets have same subnet mask since the size of each subnet is same.

Example-03:
 
Consider a single network having IP Address 200.1.2.0 is divided into 3 subnets as shown-
 

 
Now, let us calculate the subnet mask for each subnet.
 

For Subnet A-
 
For subnet A-

 24 bits identify the global network.


 1 bit identify the subnet.
 7 bits identify the host.
 
For subnet A, subnet mask is obtained-

 By setting the first 25 bits to 1.


 By setting the remaining 7 bits to 0.
 
So, Subnet mask
= 11111111.11111111.11111111.10000000
= 255.255.255.128
 

For Subnet B And Subnet C-


 
For subnet B and subnet C-

 24 bits identify the global network.


 2 bits identify the subnet.
 6 bits identify the host.
 
For subnet B and subnet C, subnet mask is obtained-

 By setting the first 26 bits to 1.


 By setting the remaining 6 bits to 0.
 
So, Subnet mask
= 11111111.11111111.11111111.11000000
= 255.255.255.192
 
NOTE
In variable length subnetting,
All the subnets do not have same subnet mask since the size of each subnet is not same.

Use of Subnet Mask-


 

 Subnet mask is used to determine to which subnet the given IP Address belongs to.
 To know more, Read here.
 

Important Notes-
 

Note-01:
 
Default mask for different classes of IP Address are-

 Default subnet mask for Class A = 255.0.0.0


 Default subnet mask for Class B = 255.255.0.0
 Default subnet mask for Class C = 255.255.255.0
 
Also Read-Classes of IP Address
 

Note-02:
 

 Network size is the total number of hosts present in it.


 Networks of same size always have the same subnet mask.
 Networks of different size always have the different subnet mask.
 

Note-03:
 

 For a network having larger size, its subnet mask will be smaller (number of 1’s will
be less).
 For a network having smaller size, its subnet mask will be larger (number of 1’s will
be more).
 

PRACTICE PROBLEMS BASED ON SUBNET MASK-


 

Problem-01:
 
If the subnet mask 255.255.255.128 belongs to class C, find-
1. Number of subnets
2. Number of hosts in each subnet
 

Solution-
 
Given subnet mask
= 255.255.255.128
= 11111111.11111111.11111111.10000000
 
Since 25 bits contain the value 1 and 7 bits contain the value 0, so-

 Number of Net ID bits + Number of Subnet ID bits = 25


 Number of Host ID bits = 7
 
Now,

 It is given that subnet mask belongs to class C.


 So, Number of Net ID bits = 24.
 
Substituting in the above equation, we get-
Number of Subnet ID bits
= 25 – 24
=1
 
Thus,
Number of subnets = 21 = 2

 
Since number of Host ID bits = 7, so-
 

Number of hosts per subnet = 27 – 2 = 126

Problem-02:
 
If a class B network has a subnet mask of 255.255.248.0, what is the maximum number of
hosts per subnet?
1. 1022
2. 1023
3. 2046
4. 2047
 

Solution-
 
Given subnet mask
= 255.255.248.0
= 11111111.11111111.11111000.00000000
 
Since 21 bits contain the value 1 and 11 bits contain the value 0, so-

 Number of Net ID bits + Number of Subnet ID bits = 21


 Number of Host ID bits = 11
 
Since number of Host ID bits = 11, so-
 

Number of hosts per subnet = 211 – 2 = 2046


 
Thus, Option (C) is correct.

PRACTICE PROBLEMS BASED ON SUBNET MASK-


 

Problems-01 to 09:
 
Consider the following subnet masks-
1. 255.0.0.0
2. 255.128.0.0
3. 255.192.0.0
4. 255.240.0.0
5. 255.255.0.0
6. 255.255.254.0
7. 255.255.255.0
8. 255.255.255.224
9. 225.255.255.240
 
For each subnet mask, find-
1. Number of hosts per subnet
2. Number of subnets if subnet mask belongs to class A
3. Number of subnets if subnet mask belongs to class B
4. Number of subnets if subnet mask belongs to class C
5. Number of subnets if total 10 bits are used for the global network ID
 

Solutions-
 
All the problems are solved below one by one-
 

Solution-01:
 
Given subnet mask is 255.0.0.0
So,

 Number of Net ID bits + Number of Subnet ID bits = 8


 Number of Host ID bits = 24
 

Part-A:
 
Since number of Host ID bits = 24, so-
 

Number of hosts per subnet = 224 – 2

Part-B:
 
If the given subnet mask belongs to class A, then number of Net ID bits = 8.
Substituting in the above equation, we get-
Number of Subnet ID bits = 8 – 8 = 0
Thus,
 

Number of subnets = 20 = 1

 
Thus, there will be only one single network.
 

Part-C:
 

 First two octets of the subnet mask are not completely filled with 1’s.
 So, given subnet mask can not belong to class B.
 

Part-D:
 

 First three octets of the subnet mask are not completely filled with 1’s.
 So, given subnet mask can not belong to class C.
 
Part-E:
 

 First 10 bits of the subnet mask are not completely filled with 1’s.
 So, given subnet mask can not use 10 bits for the Network ID.
 

NOTE-
 

 255.0.0.0 is the default mask for class A.


 

Solution-02:
 
Given subnet mask is 255.128.0.0
So,

 Number of Net ID bits + Number of Subnet ID bits = 9


 Number of Host ID bits = 23
 

Part-A:
 
Since number of Host ID bits = 23, so-
 

Number of hosts per subnet = 223 – 2

Part-B:
 
If the given subnet mask belongs to class A, then number of Net ID bits = 8.
Substituting in the above equation, we get-
Number of Subnet ID bits = 9 – 8 = 1
Thus,
 
Number of subnets = 21 = 2

Part-C:
 

 First two octets of the subnet mask are not completely filled with 1’s.
 So, given subnet mask can not belong to class B.
 

Part-D:
 

 First three octets of the subnet mask are not completely filled with 1’s.
 So, given subnet mask can not belong to class C.
 

Part-E:
 

 First 10 bits of the subnet mask are not completely filled with 1’s.
 So, given subnet mask can not use 10 bits for the Network ID.
 

Solution-03:
 
Given subnet mask is 255.192.0.0
So,
 Number of Net ID bits + Number of Subnet ID bits = 10
 Number of Host ID bits = 22
 

Part-A:
 
Since number of Host ID bits = 22, so-
 

Number of hosts per subnet = 222 – 2


 

Part-B:
 
If the given subnet mask belongs to class A, then number of Net ID bits = 8.
Substituting in the above equation, we get-
Number of Subnet ID bits = 10 – 8 = 2
Thus,
 

Number of subnets = 22 = 4

Part-C:
 

 First two octets of the subnet mask are not completely filled with 1’s.
 So, given subnet mask can not belong to class B.
 

Part-D:
 

 First three octets of the subnet mask are not completely filled with 1’s.
 So, given subnet mask can not belong to class C.
 

Part-E:
 
Given 10 bits are used for the Net ID part.
Substituting in the above equation, we get-
Number of Subnet ID bits = 10 – 10 = 0
Thus,
 

Number of subnets = 20 = 1

 
Thus, there will be only one single network.
 

Solution-04:
 
Given subnet mask is 255.240.0.0
So,

 Number of Net ID bits + Number of Subnet ID bits = 12


 Number of Host ID bits = 20
 

Part-A:
 
Since number of Host ID bits = 20, so-
 

Number of hosts per subnet = 220 – 2

Part-B:
 
If the given subnet mask belongs to class A, then number of Net ID bits = 8.
Substituting in the above equation, we get-
Number of Subnet ID bits = 12 – 8 = 4
Thus,
 

Number of subnets = 24 = 16

Part-C:
 

 First two octets of the subnet mask are not completely filled with 1’s.
 So, given subnet mask can not belong to class B.
 

Part-D:
 

 First three octets of the subnet mask are not completely filled with 1’s.
 So, given subnet mask can not belong to class C.
 

Part-E:
 
Given 10 bits are used for the Net ID part.
Substituting in the above equation, we get-
Number of Subnet ID bits = 12 – 10 = 2
Thus,
 

Number of subnets = 22 = 4

Solution-05:
 
Given subnet mask is 255.255.0.0
So,

 Number of Net ID bits + Number of Subnet ID bits = 16


 Number of Host ID bits = 16
 

Part-A:
 
Since number of Host ID bits = 16, so-
 

Number of hosts per subnet = 216 – 2

 
Part-B:
 
If the given subnet mask belongs to class A, then number of Net ID bits = 8.
Substituting in the above equation, we get-
Number of Subnet ID bits = 16 – 8 = 8
Thus,
 

Number of subnets = 28

Part-C:
 
If the given subnet mask belongs to class B, then number of Net ID bits = 16.
Substituting in the above equation, we get-
Number of Subnet ID bits = 16 – 16 = 0
Thus,
 

Number of subnets = 20 = 1

Part-D:
 

 First three octets of the subnet mask are not completely filled with 1’s.
 So, given subnet mask can not belong to class C.
 

Part-E:
 
Given 10 bits are used for the Net ID part.
Substituting in the above equation, we get-
Number of Subnet ID bits = 16 – 10 = 6
Thus,
 

Number of subnets = 26 = 64

NOTE-
 

 255.255.0.0 is the default mask for class B.


 

Solution-06:
 
Given subnet mask is 255.255.254.0
So,

 Number of Net ID bits + Number of Subnet ID bits = 23


 Number of Host ID bits = 9
 

Part-A:
 
Since number of Host ID bits = 9, so-
 

Number of hosts per subnet = 29 – 2

Part-B:
 
If the given subnet mask belongs to class A, then number of Net ID bits = 8.
Substituting in the above equation, we get-
Number of Subnet ID bits = 23 – 8 = 15
Thus,
 
Number of subnets = 215

Part-C:
 
If the given subnet mask belongs to class B, then number of Net ID bits = 16.
Substituting in the above equation, we get-
Number of Subnet ID bits = 23 – 16 = 7
Thus,
 

Number of subnets = 27

Part-D:
 

 First three octets of the subnet mask are not completely filled with 1’s.
 So, given subnet mask can not belong to class C.
 

Part-E:
 
Given 10 bits are used for the Net ID part.
Substituting in the above equation, we get-
Number of Subnet ID bits = 23 – 10 = 13
Thus,
 

Number of subnets = 213

Solution-07:
 
Given subnet mask is 255.255.255.0
So,

 Number of Net ID bits + Number of Subnet ID bits = 24


 Number of Host ID bits = 8
 

Part-A:
 
Since number of Host ID bits = 8, so-
 

Number of hosts per subnet = 28 – 2

Part-B:
 
If the given subnet mask belongs to class A, then number of Net ID bits = 8.
Substituting in the above equation, we get-
Number of Subnet ID bits = 24 – 8 = 16
Thus,
 

Number of subnets = 216

Part-C:
 
If the given subnet mask belongs to class B, then number of Net ID bits = 16.
Substituting in the above equation, we get-
Number of Subnet ID bits = 24 – 16 = 8
Thus,
 
Number of subnets = 28

Part-D:
 
If the given subnet mask belongs to class C, then number of Net ID bits = 24.
Substituting in the above equation, we get-
Number of Subnet ID bits = 24 – 24 = 0
Thus,
 

Number of subnets = 20 = 1

Part-E:
 
Given 10 bits are used for the Net ID part.
Substituting in the above equation, we get-
Number of Subnet ID bits = 24 – 10 = 14
Thus,
 

Number of subnets = 214

NOTE-
 

 255.255.255.0 is the default mask for class C.


 

Solution-08:
 
Given subnet mask is 255.255.255.224
So,

 Number of Net ID bits + Number of Subnet ID bits = 27


 Number of Host ID bits = 5
 

Part-A:
 
Since number of Host ID bits = 5, so-
 

Number of hosts per subnet = 25 – 2

Part-B:
 
If the given subnet mask belongs to class A, then number of Net ID bits = 8.
Substituting in the above equation, we get-
Number of Subnet ID bits = 27 – 8 = 19
Thus,
 

Number of subnets = 219

Part-C:
 
If the given subnet mask belongs to class B, then number of Net ID bits = 16.
Substituting in the above equation, we get-
Number of Subnet ID bits = 27 – 16 = 11
Thus,
 

Number of subnets = 211


 

Part-D:
 
If the given subnet mask belongs to class C, then number of Net ID bits = 24.
Substituting in the above equation, we get-
Number of Subnet ID bits = 27 – 24 = 3
Thus,
 

Number of subnets = 23 = 8

Part-E:
 
Given 10 bits are used for the Net ID part.
Substituting in the above equation, we get-
Number of Subnet ID bits = 27 – 10 = 17
Thus,
 

Number of subnets = 217

Solution-09:
 
Given subnet mask is 255.255.255.240
So,

 Number of Net ID bits + Number of Subnet ID bits = 28


 Number of Host ID bits = 4
 

Part-A:
 
Since number of Host ID bits = 4, so-
 

Number of hosts per subnet = 24 – 2

Part-B:
 
If the given subnet mask belongs to class A, then number of Net ID bits = 8.
Substituting in the above equation, we get-
Number of Subnet ID bits = 28 – 8 = 20
Thus,
 

Number of subnets = 220

Part-C:
 
If the given subnet mask belongs to class B, then number of Net ID bits = 16.
Substituting in the above equation, we get-
Number of Subnet ID bits = 28 – 16 = 12
Thus,
 

Number of subnets = 212

Part-D:
 
If the given subnet mask belongs to class C, then number of Net ID bits = 24.
Substituting in the above equation, we get-
Number of Subnet ID bits = 28 – 24 = 4
Thus,
 

Number of subnets = 24

Part-E:
 
Given 10 bits are used for the Net ID part.
Substituting in the above equation, we get-
Number of Subnet ID bits = 28 – 10 = 18
Thus,
 

Number of subnets = 218

Problem-10:
 
Consider default subnet mask for a network is 255.255.255.0. How many number of
subnets and hosts per subnet are possible if ‘m’ bits are borrowed from HID.
1. 2m , 2(HID-m) – 2
2. 2m , 2(HID-m)
3. 2m – 1, 2(HID-m) – 2
4. 2m , (HID-m) – 2
 

Solution-
 

 Subnet mask = 255.255.255.0


 Number of bits borrowed from Host ID part = m
 So, number of subnets possible = 2m
 Number of bits available for Hosts = HID – m
 So, number of hosts that can be configured = 2(HID – m) – 2
 
Thus, Option (A) is correct.
 

Problem-11:
 
If default subnet mask for a network is 255.255.255.0 and if ‘m’ bits are borrowed from the
NID, then what could be its supernet mask?
1. 255.255.(28-m – 1) x 2m.0
2. 255.255.(28-m) x 2m.0
3. 255.255.(28-m-1) x 2m-1.0
4. 255.255.(28-m) x 2m-1.0
 

Solution-
 
Given-

 Subnet mask = 255.255.255.0


 m bits are chosen from the NID part.
 
Clearly, given subnet mask belongs to class C.
If m = 4, then the subnet mask = 255.255.11110000.0
Now, let us check all the options one by one.
 

Option-A:
 
Given-

 Supernet mask = 255.255.(28-m – 1) x 2m.0


 Third octet = (28-m – 1) x 2m
 
On substituting m = 4, we get-
Third octet
= 15 x 24
= (1111)2 x 24
= 11110000 (Performing Left shift by 4 places)
 
Yes, this is what the third octet should be.
Thus, Option (A) is correct.
 

Option-B:
 
Given-

 Supernet mask = 255.255.(28-m) x 2m.0


 Third octet = (28-m) x 2m
 
On substituting m = 4, we get-
Third octet
= 16 x 24
= (10000)2 x 24
= 100000000 (Performing Left shift by 4 places)
 
This can not be true because these are 9 bits and octet can be only 8 bits.
Thus, Option (B) is incorrect.
Similarly, other options are also incorrect.
 
Finally, Option (A) is the only correct option.
 

 Subnetting in Networking-
 
Before you go through this article, make sure that you have gone through the previous
article on Subnetting.
We have discussed-

 Subnetting is a process of dividing a single network into multiple smaller networks.


 The number of sub networks created depends upon the requirement.
 

Arrangement Of Subnets-
 

 All the subnets are connected to an internal router.


 Internal router is connected to an external router.
 The link connecting the internal router with a subnet is called as an interface.
 

Example-
 
 

Working-
 
When a data packet arrives,

 External router forwards the data packet to the internal router.


 Internal router identifies the interface on which it should forward the incoming data
packet.
 Internal router forwards the data packet on that interface.
 

Routing Table-
 

 A table is maintained by the internal router called as Routing table.


 It helps the internal router to decide on which interface the data packet should be
forwarded.
 
Routing table consists of the following three fields-
1. IP Address of the destination subnet
2. Subnet mask of the subnet
3. Interface
 
Also Read-Subnet Mask
 

Example-
 
Consider a network is subnetted into 4 subnets as shown in the above picture.
 
The IP Address of the 4 subnets are-
1. 200.1.2.0 (Subnet A)
2. 200.1.2.64 (Subnet B)
3. 200.1.2.128 (Subnet C)
4. 200.1.2.192 (Subnet D)
 
Then, Routing table maintained by the internal router looks like-
 

Destination Subnet Mask Interface

200.1.2.0 255.255.255.192 a

200.1.2.64 255.255.255.192 b

200.1.2.128 255.255.255.192 c

200.1.2.192 255.255.255.192 d

Default 0.0.0.0 e
Routing Table Example
 
When a data packet arrives to the internal router, it follows the following steps-
 

Step-01:
 
Router performs the bitwise ANDing of-

 Destination IP Address mentioned on the data packet


 And all the subnet masks one by one.
 

Step-02:
 
Router compares each result with their corresponding IP Address of the destination subnet
in the routing table.
Then, following three cases may occur-
 

Case-01:
 
If there occurs only one match,

 Router forwards the data packet on the corresponding interface.


 

Case-02:
 
If there occurs more than one match,

 Router forwards the data packet on the interface corresponding to the longest subnet
mask.
 

Case-03:
 
If there occurs no match,

 Router forwards the data packet on the interface corresponding to the default entry.
 

Important Notes-
 

Note-01:
 
In fixed length subnetting,

 All the subnets have the same subnet mask.


 So, bitwise ANDing is performed only once.
 
If the result matches to any of the destination subnet IP Address,

 Router forwards the data packet on its corresponding interface.


 Otherwise, it is forwarded on the default interface.
 

Note-02:
 
In variable length subnetting,

 All the subnets do not have the same subnet mask.


 So, bitwise ANDing is performed once with each subnet mask.
 Then, the above three cases are followed.
 

Note-03:
 

 A host may also be directly connected to the router.


 In that case, there exists a host specific route from the router to the host.
 Router saves the IP Address of that host in the “Destination Network” column.
 Router saves 255.255.255.255 in the “Subnet Mask” column.
 The ANDing of its destination address and subnet mask yields the IP Address of the
host.
 When a data packet arrives for that specific host, bitwise ANDing is performed.
 When the result of ANDing is the IP Address of the host, packet is forwarded to its
host specific route.
 

Note-04:
 

 Subnet mask for default route = 0.0.0.0


 Subnet mask for host specific route = 255.255.255.255
 

PRACTICE PROBLEMS BASED ON ROUTING TABLE-


 

Problem-01:
 
A router uses the following routing table-
 

Destination Mask Interface

144.16.0.0 255.255.0.0 eth0

144.16.64.0 255.255.224.0 eth1

144.16.68.0 255.255.255.0 eth2

144.16.68.64 255.255.255.224 eth3

 
A packet bearing a destination address 144.16.68.117 arrives at the router. On which
interface will it be forwarded?
1. eth0
2. eth1
3. eth2
4. eth3
 

Solution-
 
Router performs the bitwise ANDing of-

 Destination address mentioned on the data packet


 And each subnet mask one by one.
 

1st Row-
 
144.16.68.117 AND 255.255.0.0
= 144.16.0.0
Since result is same as the given destination address, so a match occurs.
 

2nd Row-
 
144.16.68.117 AND 255.255.224.0
= 144.16.64.0
Since result is same as the given destination address, so a match occurs.
 

3rd Row-
 
144.16.68.117 AND 255.255.255.0
= 144.16.68.0
Since result is same as the given destination address, so a match occurs.
 

4th Row-
 
144.16.68.117 AND 255.255.255.224
= 144.16.68.96
Since result is not same as the given destination address, so a match does not occur.
 
Now,
 Clearly, there occurs more than one match.
 So, router forwards the packet on the interface corresponding to the longest subnet
mask.
 Out of all, 255.255.255.0 is the longest subnet mask since it has maximum number
of 1s.
 
So,

 Router forwards the packet on the interface corresponding to the subnet mask
255.255.255.0.
 The corresponding interface is eth2.
 
Thus, Option (C) is correct.
 

Problem-02:
 
The routing table of a router is shown below-
 

Destination Mask Interface

128.75.43.0 255.255.255.0 eth0

128.75.43.0 255.255.255.128 eth1

192.12.17.5 255.255.255.255 eth3

default eth2

 
On which interfaces will the router forward packets addressed to destination 128.75.43.16
and 192.12.17.10 respectively?
1. eth1 and eth2
2. eth0 and eth2
3. eth0 and eth3
4. eth1 and eth3
 

Solution-
 
Router performs the bitwise ANDing of-

 Destination address mentioned on the data packet


 And each subnet mask one by one.
 

Packet With Destination Address 128.75.43.16-


 

1st Row-
 
128.75.43.16 AND 255.255.255.0
= 128.75.43.0
Since result is same as the given destination address, so a match occurs.
 

2nd Row-
 
128.75.43.16 AND 255.255.255.128
= 128.75.43.0
Since result is same as the given destination address, so a match occurs.
 

3rd Row-
 
128.75.43.16 AND 255.255.255.255
= 128.75.43.16
Since result is not same as the given destination address, so a match does not occur.
 
Now,

 Clearly, there occurs more than one match.


 So, router forwards the packet on the interface corresponding to the longest subnet
mask.
 Out of all, 255.255.255.128 is the longest subnet mask since it has maximum
number of 1s.
 
So,

 Router forwards the packet on the interface corresponding to the subnet mask
255.255.255.128.
 The corresponding interface is eth1.
 

Packet With Destination Address 192.12.17.10-


 

1st Row-
 
192.12.17.10 AND 255.255.255.0
= 192.12.17.0
Since result is not same as the given destination address, so a match does not occur.
 

2nd Row-
 
192.12.17.10 AND 255.255.255.128
= 192.12.17.0
Since result is not same as the given destination address, so a match does not occur.
 

3rd Row-
 
192.12.17.10 AND 255.255.255.255
= 192.12.17.10
Since result is not same as the given destination address, so a match does not occur.
 
Now,

 Clearly, there occurs no match.


 So, router forwards the packet on the interface corresponding to the default entry.
 The corresponding interface is eth2.
 
Thus, Option (A) is correct.
 

Problem-03:
 
Host specific route has a subnet mask of _____ in the routing table.
1. 255.255.255.255
2. 0.0.0.0
3. 255.0.0.0
4. 0.0.0.255
 

Solution-
 
Option (A) is correct.
 

Problem-04:
 
Default route has a subnet mask of _____ in the routing table.
1. 255.255.255.255
2. 0.0.0.0
3. 255.0.0.0
4. 0.0.0.255
 

Solution-
 
Option (B) is correct.
 

Problem-05:
 
Default route can be described as-
1. Destination values of 0.0.0.0 in the routing table
2. It can be used if network has only one next hop router
3. It is useful in keeping routing table small
4. All of the above
 

Solution-
 
Option (D) is correct.

Subnet Mask-
 
Before you go through this article, make sure that you have gone through the previous
article on Subnet Mask.
We have discussed-

 Subnet mask is a 32 bit address consisting of a sequence of 1’s and 0’s.


 It is used to determine to which subnet the given IP Address belongs to.
 
In this article, we will discuss how subnet mask is used by the host assigned to it.
 

Concept To Know-
 
When any host connects to the internet, ISP provides following 4 things to the host-
1. IP Address
2. Default Gateway
3. Subnet Mask
4. DNS
 

1. IP Address-
 

 ISP assigns an IP Address to the host so that it can be uniquely identified on the
Internet.
 

2. Default Gateway-
 

 Default router connected to the network in which the host is present is the default
gateway for the host.
 

3. Subnet Mask-
 

 Subnet mask is a 32 bit number that is assigned to the host.


 It is used to determine to which network the given IP Address belongs to.
 

4. Domain Name Service (DNS)-


 

 Domain Name Service (DNS) is used to translate the domain name into an IP


Address.
 

Subnet Mask Use-


 

Subnet mask is used to determine to which network the given IP Address belongs to.

 Host use its subnet mask to determine whether the other host it wants to
communicate with is present within the same network or not.
 If the destination host is present within the same network, then source host sends
the packet directly to the destination host.
 If the destination host is present in some other network, then source host routes the
packet to the default gateway (router).
 Router then sends the packet to the destination host.
 

Example-
 
Consider-

 There is a host A present in some network X.


 There is a host B.
 Host A wants to send a packet to host B.
 
Before transmitting the packet, host A determines whether host B is present within the same
network or not.
 

 
Here,

 Host A = Source host


 Host B = Destination host
 
To determine whether destination host is present within the same network or not, source
host follows the following steps-
 

Step-01:
 

 Source host computes its own network address using its own IP Address and subnet
mask.
 After computation, source host obtains its network address with respect to itself.
 

Step-02:
 

 Source host computes the network address of destination host using destination IP
Address and its own subnet mask.
 After computation, source host obtains the network address of destination host with
respect to itself.
 

Step-03:
 
Source host compares the two results obtained in the above steps.
Then, following two cases are possible-
 

Case-01:
 
If the results are same,

 Source host assumes that the destination host is present within the same network.
 Source host sends the packet directly to the destination host.
 

Case-02:
 
If the results are different,

 Source host assumes that the destination host is present in some other network.
 Source host sends the packet via router to the destination host.
 

Important Points-
 

Note-01:
 

 Each host knows only its own subnet mask.


 It does not know the subnet mask of any other host.
 

Note-02:
 

 The conclusion drawn by a host about the presence of other host within the same or
different network might be wrong.
 

Note-03:
 

 Consider host A draws some conclusion about host B.


 Then, same conclusion might not be drawn by host B about host A.
 Both the hosts have to perform the above procedure separately at their ends to
conclude anything.
 

PRACTICE PROBLEMS BASED ON USE OF SUBNET


MASK-
 

Problem-01:
 
Two computers C1 and C2 are configured as follows-

 C1 has IP Address 203.197.2.53 and net mask 255.255.128.0


 C2 has IP Address 203.197.75.201 and net mask 255.255.192.0
 
Which one of the following statements is true?
1. C1 and C2 both assume they are on the same network
2. C2 assumes C1 is on same network but C1 assumes C2 is on a different network
3. C1 assumes C2 is on same network but C2 assumes C1 is on a different network
4. C1 and C2 both assume they are on different networks
 

Solution-
 

At Computer C1-
 
C1 computes its network address using its own IP Address and subnet mask as-
203.197.2.53 AND 255.255.128.0
= 203.197.0.0
 
C1 computes the network address of C2 using IP Address of C2 and its own subnet mask
as-
203.197.75.201 AND 255.255.128.0
= 203.197.0.0
 
Since both the results are same, so C1 assumes that C2 is on the same network.
 

At Computer C2-
 
C2 computes its network address using its own IP Address and subnet mask as-
203.197.75.201 AND 255.255.192.0
= 203.197.64.0
 
C2 computes the network address of C1 using IP Address of C1 and its own subnet mask
as-
203.197.2.53 AND 255.255.192.0
= 203.197.0.0
 
Since both the results are different, so C2 assumes that C1 is on a different network.
Thus, Option (C) is correct.
 

Problem-02:
 
The subnet mask for a particular network is 255.255.31.0. Which of the following pairs of IP
Addresses could belong to this network?
1. 172.57.88.62 and 172.56.87.233
2. 10.35.28.2 and 10.35.29.4
3. 191.203.31.87 and 191.234.31.88
4. 128.8.129.43 and 128.8.161.55
 

Solution-
 
Let the given two IP Addresses belong to Host A and Host B.
 

Checking Option (A)-


 
 Host A IP Address = 172.57.88.62
 Host B IP Address = 172.56.87.233
 

At Host A-
 
Host A computes its network address using its own IP Address and subnet mask-
172.57.88.62 AND 255.255.31.0
= 172.57.24.0
 
Host A computes the network address of Host B using IP Address of Host B and its own
subnet mask-
172.56.87.233 AND 255.255.31.0
= 172.56.23.0
 
Since both the results are different, so host A assumes that host B is on a different network.
Thus, both can’t belong to the same network.
Hence, this option gets eliminated.
 

Checking Option (B)-


 

 Host A IP Address = 10.35.28.2


 Host B IP Address = 10.35.29.4
 

At Host A-
 
Host A computes its network address using its own IP Address and subnet mask-
10.35.28.2 AND 255.255.31.0
= 10.35.28.0
 
Host A computes the network address of Host B using IP Address of Host B and its own
subnet mask-
10.35.29.4 AND 255.255.31.0
= 10.35.29.0
 
Since both the results are different, so host A assumes that host B is on a different network.
Thus, both can’t belong to the same network.
Hence, this option gets eliminated.
 

Checking Option (C)-


 

 Host A IP Address = 191.203.31.87


 Host B IP Address = 191.234.31.88
 

At Host A-
 
Host A computes its network address using its own IP Address and subnet mask-
191.203.31.87 AND 255.255.31.0
= 191.203.31.0
 
Host A computes the network address of Host B using IP Address of Host B and its own
subnet mask-
191.234.31.88 AND 255.255.31.0
= 191.234.31.0
 
Since both the results are same, so host A assumes that host B is on the same network.
 

At Host B-
 
Host B computes its network address using its own IP Address and subnet mask-
191.234.31.88 AND 255.255.31.0
= 191.234.31.0
 
Host B computes the network address of Host A using IP Address of Host A and its own
subnet mask-
191.203.31.87 AND 255.255.31.0
= 191.203.31.0
 
Since both the results are different, so host B assumes that host A is on a different network.
Thus, both can’t belong to the same network.
Hence, this option gets eliminated.
 

Checking Option (D)-


 

 Host A IP Address = 128.8.129.43


 Host B IP Address = 128.8.161.55
 

At Host A-
 
Host A computes its network address using its own IP Address and subnet mask-
128.8.129.43 AND 255.255.31.0
= 128.8.1.0
 
Host A computes the network address of Host B using IP Address of Host B and its own
subnet mask-
128.8.161.55 AND 255.255.31.0
= 128.8.1.0
 
Since both the results are same, so host A assumes that host B is on the same network.
 

At Host B-
 
Host B computes its network address using its own IP Address and subnet mask-
128.8.161.55 AND 255.255.31.0
= 128.8.1.0
 
Host B computes the network address of Host A using IP Address of Host A and its own
subnet mask-
128.8.129.43 AND 255.255.31.0
= 128.8.1.0
 
Since both the results are same, so host B assumes that host A is on the same network.
Thus, both the hosts assume that they belong to the same network.
Hence, Option (D) is correct.
 

Internet Protocol Version 4-


 

 IPv4 short for Internet Protocol Version 4 is the fourth version of the Internet
Protocol (IP).
 IP is responsible to deliver data packets from the source host to the destination host.
 This delivery is solely based on the IP Addresses in the packet headers.
 IPv4 is the first major version of IP.
 IPv4 is a connectionless protocol for use on packet-switched networks.
 

IPv4 Header-
 
The following diagram represents the IPv4 header-
 
 
Let us discuss each field of IPv4 header one by one.
 

1. Version-
 

 Version is a 4 bit field that indicates the IP version used.


 The most popularly used IP versions are version-4 (IPv4) and version-6 (IPv6).
 Only IPv4 uses the above header.
 So, this field always contains the decimal value 4.
 

NOTES
It is important to note-

 Datagrams belonging to different versions have different structures.


 So, they are parsed differently.
 IPv4 datagrams are parsed by version-4 parsers.
 IPv6 datagrams are parsed by version-6 parsers.

2. Header Length-
 

 Header length is a 4 bit field that contains the length of the IP header.
 It helps in knowing from where the actual data begins.
 

Minimum And Maximum Header Length-


 

The length of IP header always lies in the range-


[20 bytes , 60 bytes]

 The initial 5 rows of the IP header are always used.


 So, minimum length of IP header = 5 x 4 bytes = 20 bytes.
 The size of the 6th row representing the Options field vary.
 The size of Options field can go up to 40 bytes.
 So, maximum length of IP header = 20 bytes + 40 bytes = 60 bytes.
 

Concept of Scaling Factor-


 

 Header length is a 4 bit field.


 So, the range of decimal values that can be represented is [0, 15].
 But the range of header length is [20, 60].
 So, to represent the header length, we use a scaling factor of 4.
 
In general,
 
Header length = Header length field value x 4 bytes

Examples-
 

 If header length field contains decimal value 5 (represented as 0101), then-


Header length = 5 x 4 = 20 bytes

 If header length field contains decimal value 10 (represented as 1010), then-


Header length = 10 x 4 = 40 bytes

 If header length field contains decimal value 15 (represented as 1111), then-


Header length = 15 x 4 = 60 bytes
 

NOTES
It is important to note-

 Header length and Header length field value are two different things.
 The range of header length field value is always [5, 15].
 The range of header length is always [20, 60].
 
While solving questions-

 If the given value lies in the range [5, 15] then it must be the header length field value.
 This is because the range of header length is always [20, 60].

3. Type Of Service-
 

 Type of service is a 8 bit field that is used for Quality of Service (QoS).
 The datagram is marked for giving a certain treatment using this field.
 

4. Total Length-
 

 Total length is a 16 bit field that contains the total length of the datagram (in bytes).
 
Total length = Header length + Payload length

 Minimum total length of datagram = 20 bytes (20 bytes header + 0 bytes data)
 Maximum total length of datagram = Maximum value of 16 bit word = 65535 bytes
 

5. Identification-
 

 Identification is a 16 bit field.


 It is used for the identification of the fragments of an original IP datagram.
 
When an IP datagram is fragmented,

 Each fragmented datagram is assigned the same identification number.


 This number is useful during the re assembly of fragmented datagrams.
 It helps to identify to which IP datagram, the fragmented datagram belongs to.
 

6. DF Bit-
 

 DF bit stands for Do Not Fragment bit.


 Its value may be 0 or 1.
 
When DF bit is set to 0,

 It grants the permission to the intermediate devices to fragment the datagram if


required.
 
When DF bit is set to 1,

 It indicates the intermediate devices not to fragment the IP datagram at any cost.
 If network requires the datagram to be fragmented to travel further but settings does
not allow its fragmentation, then it is discarded.
 An error message is sent to the sender saying that the datagram has been discarded
due to its settings.
 

7. MF Bit-
 

 MF bit stands for More Fragments bit.


 Its value may be 0 or 1.
 
When MF bit is set to 0,

 It indicates to the receiver that the current datagram is either the last fragment in the
set or that it is the only fragment.
 
When MF bit is set to 1,

 It indicates to the receiver that the current datagram is a fragment of some larger
datagram.
 More fragments are following.
 MF bit is set to 1 on all the fragments except the last one.
 

8. Fragment Offset-
 

 Fragment Offset is a 13 bit field.


 It indicates the position of a fragmented datagram in the original unfragmented IP
datagram.
 The first fragmented datagram has a fragment offset of zero.
 

Fragment offset for a given fragmented datagram


= Number of data bytes ahead of it in the original unfragmented datagram

Concept Of Scaling Factor-


 

 We use a scaling factor of 8 for the fragment offset.


 Fragment offset field value = Fragment Offset / 8
 

Need Of Scaling Factor For Fragment Offset


 
 In IPv4 header, the total length field comprises of 16 bits.
 Total length = Header length + Payload length.
 Minimum header length = 20 bytes.
 So, maximum amount of data that can be sent in the payload field = 216 – 20 bytes.
 In worst case, a datagram containing 216 – 20 bytes of data might be fragmented in such
a way that the last fragmented datagram contains only 1 byte of data.
 Then, fragment offset for the last fragmented datagram will be (216 – 20) – 1 = 216 -21 ≅
216
(if no scaling factor is used)

 Now, this fragment offset value of 216 can not be represented.


 This is because the fragment offset field consists of only 13 bits.
 Using 13 bits, a maximum number of 213 can be represented.
 So, to represent 216 we use the concept of scaling factor.
 Scaling factor = 216 / 213 = 23 = 8.

9. Time To Live-
 

 Time to live (TTL) is a 8 bit field.


 It indicates the maximum number of hops a datagram can take to reach the
destination.
 The main purpose of TTL is to prevent the IP datagrams from looping around forever
in a routing loop.
 
The value of TTL is decremented by 1 when-

 Datagram takes a hop to any intermediate device having network layer.


 Datagram takes a hop to the destination.
 
If the value of TTL becomes zero before reaching the destination, then datagram is
discarded.
 

NOTES
It is important to note-

 Both intermediate devices having network layer and destination decrements the TTL
value by 1.
 If the value of TTL is found to be zero at any intermediate device, then the datagram is
discarded.
 So, at any intermediate device, the value of TTL must be greater than zero to proceed
further.
 If the value of TTL becomes zero at the destination, then the datagram is accepted.
 So, at the destination, the value of TTL may be greater than or equal to zero.

10. Protocol-
 

 Protocol is a 8 bit field.


 It tells the network layer at the destination host to which protocol the IP datagram
belongs to.
 In other words, it tells the next level protocol to the network layer at the destination
side.
 Protocol number of ICMP is 1, IGMP is 2, TCP is 6 and UDP is 17.
 

Why Protocol Number Is A Part Of IP Header?


 
Consider-

 An IP datagram is sent by the sender to the receiver.


 When datagram reaches at the router, it’s buffer is already full.
 
In such a case,

 Router does not discard the datagram directly.


 Before discarding, router checks the next level protocol number mentioned in its IP
header.
 If the datagram belongs to TCP, then it tries to make room for the datagram in its buffer.
 It creates a room by eliminating one of the datagrams having lower priority.
 This is because it knows that TCP is a reliable protocol and if it discards the datagram,
then it will be sent again by the sender.
 The order in which router eliminate the datagrams from its buffer is-
ICMP > IGMP > UDP > TCP
 
If protocol number would have been inside the datagram, then-

 Router could not look into it.


 This is because router has only three layers- physical layer, data link layer and network
layer.
 
That is why, protocol number is made a part of IP header.

11. Header Checksum-


 

 Header checksum is a 16 bit field.


 It contains the checksum value of the entire header.
 The checksum value is used for error checking of the header.
 
At each hop,

 The header checksum is compared with the value contained in this field.
 If header checksum is found to be mismatched, then the datagram is discarded.
 Router updates the checksum field whenever it modifies the datagram header.
 
The fields that may be modified are-
1. TTL
2. Options
3. Datagram Length
4. Header Length
5. Fragment Offset
 

NOTE
It is important to note-

 Computation of header checksum includes IP header only.


 Errors in the data field are handled by the encapsulated protocol.

 
Also Read-Checksum
 

12. Source IP Address-


 

 Source IP Address is a 32 bit field.


 It contains the logical address of the sender of the datagram.
 

13. Destination IP Address-


 

 Destination IP Address is a 32 bit field.


 It contains the logical address of the receiver of the datagram.
 

14. Options-
 

 Options is a field whose size vary from 0 bytes to 40 bytes.


 This field is used for several purposes such as-
1. Record route
2. Source routing
3. Padding
 

1. Record Route-
 

 A record route option is used to record the IP Address of the routers through which
the datagram passes on its way.
 When record route option is set in the options field, IP Address of the router gets
recorded in the Options field.
 

NOTE
 

The maximum number of IPv4 router addresses that can be recorded in the Record Route
option field of an IPv4 header is 9.

 
Explanation-
 

 In IPv4, size of IP Addresses = 32 bits = 4 bytes.


 Maximum size of Options field = 40 bytes.
 So, it seems maximum number of IP Addresses that can be recorded = 40 / 4 = 10.
 But some space is required to indicate the type of option being used.
 Also, some space is to be left between the IP Addresses.
 So, the space of 4 bytes is left for this purpose.
 Therefore, the maximum number of IP addresses that can be recorded = 9.

2. Source Routing-
 

 A source routing option is used to specify the route that the datagram must take to
reach the destination.
 This option is generally used to check whether a certain path is working fine or not.
 Source routing may be loose or strict.
 

3. Padding-
 

 Addition of dummy data to fill up unused space in the transmission unit and make it
conform to the standard size is called as padding.
 Options field is used for padding.
 

Example-
 

 When header length is not a multiple of 4, extra zeroes are padded in the Options
field.
 By doing so, header length becomes a multiple of 4.
 If header length = 30 bytes, 2 bytes of dummy data is added to the header.
 This makes header length = 32 bytes.
 Then, the value 32 / 4 = 8 is put in the header length field.
 In worst case, 3 bytes of dummy data might have to be padded to make the header
length a multiple of 4.
IP Fragmentation-
 
 IP Fragmentation is a process of dividing the datagram into fragments during its
transmission.
 It is done by intermediary devices such as routers at the destination host at network
layer.
 

Need-
 

 Each network has its maximum transmission unit (MTU).


 It dictates the maximum size of the packet that can be transmitted through it.
 Data packets of size greater than MTU can not be transmitted through the network.
 So, datagrams are divided into fragments of size less than or equal to MTU.
 

Datagram Fragmentation-
 
When router receives a datagram to transmit further, it examines the following-

 Size of the datagram


 MTU of the destination network
 DF bit value in the IP header
 
Then, following cases are possible-
 

Case-01:
 

 Size of the datagram is found to be smaller than or equal to MTU.


 In this case, router transmits the datagram without any fragmentation.
 
Case-02:
 

 Size of the datagram is found to be greater than MTU and DF bit set to 1.
 In this case, router discards the datagram.
 

Case-03:
 

 Size of the datagram is found to be greater than MTU and DF bit set to 0.
 In this case, router divides the datagram into fragments of size less than or equal to
MTU.
 Router attaches an IP header with each fragment making the following changes in it.
 Then, router transmits all the fragments of the datagram.
 

Changes Made By Router-


 
Router makes the following changes in IP header of each fragment-

 It changes the value of total length field to the size of fragment.


 It sets the MF bit to 1 for all the fragments except the last one.
 For the last fragment, it sets the MF bit to 0.
 It sets the fragment offset field value.
 It recalculates the header checksum.
 
Also Read-IPv4 Header
 

IP Fragmentation Examples-
 
Now, lets us discuss some examples of IP fragmentation to understand how the
fragmentation is actually carried out.
 

Example-01:
 
Consider-

 There is a host A present in network X having MTU = 520 bytes.


 There is a host B present in network Y having MTU = 200 bytes.
 Host A wants to send a message to host B.
 

 
Consider router receives a datagram from host A having-

 Header length = 20 bytes


 Payload length = 500 bytes
 Total length = 520 bytes
 DF bit set to 0
 
Now, router works in the following steps-
 

Step-01:
 
Router examines the datagram and finds-

 Size of the datagram = 520 bytes


 Destination is network Y having MTU = 200 bytes
 DF bit is set to 0
 
Router concludes-

 Size of the datagram is greater than MTU.


 So, it will have to divide the datagram into fragments.
 DF bit is set to 0.
 So, it is allowed to create fragments of the datagram.
 

Step-02:
 
Router decides the amount of data that it should transmit in each fragment.
 
Router knows-

 MTU of the destination network = 200 bytes.


 So, maximum total length of any fragment can be only 200 bytes.
 Out of 200 bytes, 20 bytes will be taken by the header.
 So, maximum amount of data that can be sent in any fragment = 180 bytes.
 
Router uses the following rule to choose the amount of data that will be transmitted in one
fragment-
 

RULE
 
The amount of data sent in one fragment is chosen such that-

 It is as large as possible but less than or equal to MTU.


 It is a multiple of 8 so that pure decimal value can be obtained for the fragment offset
field.
 

NOTE
 

 It is not compulsory for the last fragment to contain the amount of data that is a multiple
of 8.
 This is because it does not have to decide the fragment offset value for any other
fragment.

 
Following the above rule,

 Router decides to send maximum 176 bytes of data in one fragment.


 This is because it is the greatest value that is a multiple of 8 and less than MTU.
 

Step-03:
 
Router creates three fragments of the original datagram where-
 First fragment contains the data = 176 bytes
 Second fragment contains the data = 176 byes
 Third fragment contains the data = 148 bytes
 

 
The information contained in the IP header of each fragment is-
 

Header Information Of 1st Fragment-


 

 Header length field value = 20 / 4 = 5


 Total length field value = 176 + 20 = 196
 MF bit = 1
 Fragment offset field value = 0
 Header checksum is recalculated.
 Identification number is same as that of original datagram.
 

Header Information Of 2nd Fragment-


 

 Header length field value = 20 / 4 = 5


 Total length field value = 176 + 20 = 196
 MF bit = 1
 Fragment offset field value = 176 / 8 = 22
 Header checksum is recalculated.
 Identification number is same as that of original datagram.
 

Header Information Of 3rd Fragment-


 

 Header length field value = 20 / 4 = 5


 Total length field value = 148 + 20 = 168
 MF bit = 0
 Fragment offset field value = (176 + 176) / 8 = 44
 Header checksum is recalculated.
 Identification number is same as that of original datagram.
 
Router transmits all the fragments.
 

Step-04:
 
At destination side,

 Receiver receives 3 fragments of the datagram.


 Reassembly algorithm is applied to combine all the fragments to obtain the original
datagram.
 

Example-02:
 
Consider-

 There is a host A present in network X having MTU = 520 bytes.


 There is a host B present in network Y having MTU = 200 bytes.
 There exists a network Z having MTU = 110 bytes.
 Host A wants to send a message to host B.
 
 
Consider Router-1 receives a datagram from host A having-

 Header length = 20 bytes


 Payload length = 500 bytes
 Total length = 520 bytes
 DF bit set to 0
 
Consider Router-1 divides the datagram into 3 fragments as discussed in Example-01.
 
Then,

 First fragment contains the data = 176 bytes


 Second fragment contains the data = 176 byes
 Third fragment contains the data = 148 bytes
 
Now, consider-

 First and third fragment reaches the destination directly.


 However, second fragment takes its way through network Z and reach the
destination through Router-3.
 

Journey Of Second Fragment-


 
Now, let us discuss the journey of fragment-2 and how it finally reaches the destination.
 
Router-2 receives a datagram (second fragment of original datagram) where-

 Header length = 20 bytes


 Payload length = 176 bytes
 Total length = 196 bytes
 DF bit set to 0
 
Now, Router-2 works in the following steps-
 

Step-01:
 
Router-2 examines the datagram and finds-

 Size of the datagram = 196 bytes


 Destination is network Z having MTU = 110 bytes
 DF bit is set to 0
 
Router-2 concludes-

 Size of the datagram is greater than MTU.


 So, it will have to divide the datagram into fragments.
 DF bit is set to 0.
 So, it is allowed to create fragments of the datagram.
 

Step-02:
 
Router-2 decides the amount of data that it should transmit in each fragment.
 
Router-2 knows-

 MTU of the destination network = 110 bytes.


 So, maximum total length of any fragment can be only 110 bytes.
 Out of 110 bytes, 20 bytes will be taken by the header.
 So, maximum amount of data that can be sent in any fragment = 90 bytes.
 
Following the rule,

 Router-2 decides to send maximum 88 bytes of data in one fragment.


 This is because it is the greatest value that is a multiple of 8 and less than MTU.
 

Step-03:
 
Router-2 creates two fragments of the received datagram where-

 First fragment contains the data = 88 bytes


 Second fragment contains the data = 88 byes
 
 
The information contained in the IP header of each fragment is-
 

Header Information Of 1st Fragment-


 

 Header length field value = 20 / 4 = 5


 Total length field value = 88 + 20 = 108
 MF bit = 1
 Fragment offset field value = 176 / 8 = 22
 Header checksum is recalculated.
 Identification number is same as that of original datagram.
 

NOTE-
 

 This fragment is NOT the first fragment of the original datagram.


 It is the first fragment of the datagram received by Router-2.
 The datagram received by Router-2 is the second fragment of the original datagram.
 This datagram will serve as the second fragment of the original datagram.
 Therefore, fragment offset field is set according to the first fragment of the original
datagram.
 

Header Information Of 2nd Fragment-


 

 Header length field value = 20 / 4 = 5


 Total length field value = 88 + 20 = 108
 MF bit = 1
 Fragment offset field value = (176 + 88) / 8 = 33
 Header checksum is recalculated.
 Identification number is same as that of original datagram.
 

NOTE-
 

 This fragment is NOT the last fragment of the original datagram.


 It is the last fragment of the datagram received by Router-2.
 The datagram received by Router-2 is the second fragment of the original datagram.
 This datagram will serve as the third fragment of the original datagram.
 There is another fragment of the original datagram that follows it.
 That is why, here MF bit is not set to 0.
 
Router-2 transmits both the fragments which reaches the destination through Router-3.
Router-3 performs no fragmentation.
 

Step-04:
 
At destination side,

 Receiver receives 4 fragments of the datagram.


 Reassembly algorithm is applied to combine all the fragments to obtain the original
datagram.
 

Reassembly Algorithm-
 
Receiver applies the following steps for reassembly of all the fragments-
1. It identifies whether datagram is fragmented or not using MF bit and Fragment offset
field.
2. It identifies all the fragments belonging to the same datagram using identification
field.
3. It identifies the first fragment. Fragment with offset field value = 0 is the first
fragment.
4. It identifies the subsequent fragments using total length, header length and fragment
offset.
5. It repeats step-04 until MF bit = 0.
 

Fragment Offset field value for the next subsequent fragment


= ( Payload length of the current fragment / 8 ) + Offset field value of the current fragment
= ( Total length – Header length / 8 ) + Offset field value of the current fragment

Fragmentation Overhead-
 

 Fragmentation of datagram increases the overhead.


 This is because after fragmentation, IP header has to be attached with each
fragment.
 

Total Overhead
= (Total number of fragmented datagrams – 1) x size of IP header

Efficiency = Useful bytes transferred / Total bytes transferred


OR
Efficiency = Data without header / Data with header

Bandwidth Utilization or Throughput = Efficiency x Bandwidth

Important Notes-
 

Note-01:
 

 Source side does not require fragmentation due to wise segmentation by transport
layer.
 The transport layer looks at the datagram data limit and frame data limit.
 Then, it performs segmentation in such a way that the resulting data can easily fit in
a frame.
 Thus, there is no need of fragmentation at the source side.
 

Note-02:
 

 Datagrams from the same source to the same destination may take different routes
in the network.
 

Note-03:
 

 Fragment offset field value is set to 0 for the first fragmented datagram.
 MF bit is set to 1 for all the fragmented datagrams except the last one.
 

Note-04:
 

 Unique combinations of MF bit value and fragment offset value.


 

MF bit Offset value Represents

1 0 1st Fragment

1 !=0 Intermediate Fragment

0 !=0 Last Fragment

0 0 No Fragmentation

Note-05:
 
 Identification number for all the fragments is same as that of the original datagram.
 This is to identify all the fragments of the same datagram while re-assembling them.
 

Note-06:
 

 Consider datagram goes through a path where different intermediaries having


different bandwidths.
 Then, while calculating the throughput, consider the minimum bandwidth since it act
as a bottleneck.
 

Note-07:
 

 Fragmentation is done by intermediary devices such as routers.


 The reassembly of fragmented datagrams is done only after reaching the
destination.
 

Note-08:
 
Reassembly is not done at the routers because-

 All the fragments may not meet at the router.


 Fragmented datagrams may reach the destination through independent paths.
 There may be a need for further fragmentation.
 

Note-09:
 
If a fragment (say parent) is re fragmented into multiple datagrams then-
1. The fragment offset value for the first re-fragment is always same as its parent.
2. The MF bit bit value for the last re-fragment is always same as its parent.
 

PRACTICE PROBLEMS BASED ON IP HEADER AND


IP FRAGMENTATION-
 
Problem-01:
 
The intermediate routers between source and destination need the following information in
IP header-
1. Version
2. Protocol
3. Identification Number
4. Source IP Address
 

Solution-
 

Option-A:
 

 Version field indicates the version of IP used.


 This information is required to process the packet appropriately based on its version.
 

Option-B:
 

 Protocol field indicates the next level protocol.


 This information is required by the router to accept or discard the packet if its buffer
is full.
 Based on the priority, router takes its decision.
 

Option-C:
 

 Identification number field identifies the fragments of the same datagram.


 This information is required while re-assembling the datagram fragments.
 

Option-D:
 

 Source IP Address field indicates the IP Address of the source.


 This information is required by the router to send ICMP packet to the source.
 ICMP packet informs the source that its packet has been discarded.
 
Thus, All these fields are required in the IP Header.
 

Problem-02:
 
Fragmentation of a datagram is needed in-
1. Datagram circuit only
2. Virtual circuit only
3. Both (A) and (B)
4. None
 

Solution-
 

 Each network has its Maximum Transmission Unit (MTU).


 If the size of data packet is greater than MTU, then it will have divided into fragments
to transmit it through the network.
 So, fragmentation may be required in datagram circuits as well as virtual circuits.
 Thus, Option (C) is correct.
 

Problem-03:
 
What are all the fields required from IP header to allow the destination to perform
reassembly of fragments?
1. Identification, MF, Offset, Header length and Total length
2. MF, Offset and Destination IP
3. MF, Datagram length, Source IP
4. MF, Options and Offset
 

Solution-
 
Clearly, Option (A) is correct.
 

Problem-04:
 
The checksum in IP must be recomputed at every router because of change in ____ fields.
1. TTL, Options, Identification Number, Offset
2. TTL, Options, Datagram Length, Offset
3. TTL, Options, Data, Offset
4. TTL, Header Length, Offset, ToS
 

Solution-
 
Clearly, Option (B) is correct.
 

Problem-05:
 
If the value available in “fragment offset” field of IP header is 100, then the number of bytes
ahead of this fragment is ___ ?
1. 100 B
2. 400 B
3. 800 B
4. 200 B
 

Solution-
 

 Fragment offset field use a scaling factor of 8.


 If Fragment offset field value = 100, then fragment offset = 8 x 100 = 800.
 It suggests 800 bytes of data is ahead of this fragment.
 Thus, Option (C) is correct.
 

Problem-06:
 
When the source does not trust the routers to route properly or source wishes to make sure
that the packet does not stray from specified path, what options can be used?
1. Loose source routing
2. Trace route
3. Strict source routing
4. Internet Time Stamp
 

Solution-
 
Clearly, Option (C) is correct.
 

Problem-07:
 
The checksum computation in IP header includes-
1. IP header only
2. IP header and data
3. IP header and Pseudo header
4. None
 

Solution-
 

 Checksum computation in IP header includes IP header only.


 Errors in the data field are handled by the encapsulated protocol.
 Thus, Option (A) is correct.
 

Problem-08:
 
Suppose a router receives an IP packet containing 600 data bytes and has to forward the
packet to a network with maximum transmission unit of 200 bytes. Assume that IP header is
20 bytes long. What are fragment offset values for divided packets?
1. 22, 44, 66, 88
2. 0, 22, 44
3. 0, 22, 44, 66
4. 22, 44, 66
 

Solution-
 
Given-
 MTU size of the destination network = 200 bytes
 IP header length = 20
 
Now,

 Maximum amount of data that can be sent in one fragment = 200 – 20 = 180 bytes.
 Amount of data sent in a fragment must be a multiple of 8.
 So, maximum data sent that can be in one fragment = 176 bytes.
 
Thus, 4 fragments are created-

 1st fragment contains 176 bytes of data.


 2nd fragment contains 176 bytes of data.
 3rd fragment contains 176 bytes of data.
 4th fragment contains 72 bytes of data
 
So,

 Fragment offset value for 1st fragment = 0


 Fragment offset value for 2nd fragment = 176 / 8 = 22
 Fragment offset value for 3rd fragment = (176+176) / 8 = 44
 Fragment offset value for 4th fragment = (176 + 176 + 176) / 8 = 66
 
Thus, Option (C) is correct

Transport Layer Protocols-


 
There are mainly two transport layer protocols that are used on the Internet-

.
1. Transmission Control Protocol (TCP)
2. User Datagram Protocol (UDP)
 
In this article, we will discuss about Transmission Control Protocol (TCP).
Learn about User Datagram Protocol.
 

Transmission Control Protocol-


 

 TCP is short for Transmission Control Protocol.


 It is a transport layer protocol.
 It has been designed to send data packets over the Internet.
 It establishes a reliable end to end connection before sending any data.
 

Characteristics Of TCP-
 

Point-01:
 

TCP is a reliable protocol.

 
This is because-

 It guarantees the delivery of data packets to its correct destination.


 After receiving the data packet, receiver sends an acknowledgement to the sender.
 It tells the sender whether data packet has reached its destination safely or not.
 TCP employs retransmission to compensate for packet loss.
 
Read More-TCP Retransmission
 

Point-02:
 

TCP is a connection oriented protocol.

 
This is because-

 TCP establishes an end to end connection between the source and destination.
 The connection is established before exchanging the data.
 The connection is maintained until the application programs at each end finishes
exchanging the data.
 

Point-03:
 

TCP handles both congestion and flow control.

 TCP handles congestion and flow control by controlling the window size.
 TCP reacts to congestion by reducing the sender window size.
 
Read More-TCP Congestion Control
 

Point-04:
 

TCP ensures in-order delivery.

 TCP ensures that the data packets get deliver to the destination in the same order
they are sent by the sender.
 Sequence Numbers are used to coordinate which data has been transmitted and
received.
 

Point-05:
 

TCP connections are full duplex.

 TCP connection allows to send data in both the directions at the same time.
 So, TCP connections are Full Duplex.
 

Point-06:
 

TCP works in collaboration with Internet Protocol.

 A TCP connection is uniquely identified by using-


Combination of port numbers and IP Addresses of sender and receiver.

 IP Addresses indicate which systems are communicating.


 Port numbers indicate which end to end sockets are communicating.
 Port numbers are contained in the TCP header and IP Addresses are contained in
the IP header.
 TCP segments are encapsulated into an IP datagram.
 So, TCP header immediately follows the IP header during transmission.
 

Point-07:
 

TCP can use both selective & cumulative acknowledgements.

 TCP uses a combination of Selective Repeat and Go back N protocols.


 In TCP, sender window size = receiver window size.
 In TCP, out of order packets are accepted by the receiver.
 When receiver receives an out of order packet, it accepts that packet but sends an
acknowledgement for the expected packet.
 Receiver may choose to send independent acknowledgements or cumulative
acknowledgement.
 To sum up, TCP is a combination of 75% SR protocol and 25% Go back N protocol.
 

Point-08:
 

TCP is a byte stream protocol.

 Application layer sends data to the transport layer without any limitation.
 TCP divides the data into chunks where each chunk is a collection of bytes.
 Then, it creates a TCP segment by adding IP header to the data chunk.
 TCP segment = TCP header + Data chunk.
 

Point-09:
 

TCP provides error checking & recovery mechanism.

 
TCP provides error checking and recovery using three simple techniques-
1. Checksum
2. Acknowledgement
3. Retransmission
Transmission Control Protocol-

Before you go through this article, make sure that you have gone through the previous
article on TCP in Networking.

We have discussed-

 Transmission Control Protocol is a transport layer protocol.


 It continuously receives data from the application layer.
 It divides the data into chunks where each chunk is a collection of bytes.
 It then creates TCP segments by adding a TCP header to the data chunks.
 TCP segments are encapsulated in the IP datagram.
 

TCP segment = TCP header + Data chunk

 
In this article, we will discuss about TCP Header.
 

TCP Header-
 
The following diagram represents the TCP header format-
 
 
Let us discuss each field of TCP header one by one.
 

1. Source Port-
 

 Source Port is a 16 bit field.


 It identifies the port of the sending application.
 

2. Destination Port-
 
 Destination Port is a 16 bit field.
 It identifies the port of the receiving application.
 

NOTE
It is important to note-

 A TCP connection is uniquely identified by using-


Combination of port numbers and IP Addresses of sender and receiver

 IP Addresses indicate which systems are communicating.


 Port numbers indicate which end to end sockets are communicating.

3. Sequence Number-
 

 Sequence number is a 32 bit field.


 TCP assigns a unique sequence number to each byte of data contained in the TCP
segment.
 This field contains the sequence number of the first data byte.
 

4. Acknowledgement Number-
 

 Acknowledgment number is a 32 bit field.


 It contains sequence number of the data byte that receiver expects to receive next
from the sender.
 It is always sequence number of the last received data byte incremented by 1.
 

5. Header Length-
 

 Header length is a 4 bit field.


 It contains the length of TCP header.
 It helps in knowing from where the actual data begins.
 

Minimum and Maximum Header length-


 

The length of TCP header always lies in the range-


[20 bytes , 60 bytes]

 The initial 5 rows of the TCP header are always used.


 So, minimum length of TCP header = 5 x 4 bytes = 20 bytes.
 The size of the 6th row representing the Options field vary.
 The size of Options field can go up to 40 bytes.
 So, maximum length of TCP header = 20 bytes + 40 bytes = 60 bytes.
 

Concept of Scaling Factor-


 

 Header length is a 4 bit field.


 So, the range of decimal values that can be represented is [0, 15].
 But the range of header length is [20, 60].
 So, to represent the header length, we use a scaling factor of 4.
 
In general,
 

Header length = Header length field value x 4 bytes


 

Examples-
 

 If header length field contains decimal value 5 (represented as 0101), then-


Header length = 5 x 4 = 20 bytes

 If header length field contains decimal value 10 (represented as 1010), then-


Header length = 10 x 4 = 40 bytes

 If header length field contains decimal value 15 (represented as 1111), then-


Header length = 15 x 4 = 60 bytes
 

NOTES
It is important to note-

 Header length and Header length field value are two different things.
 The range of header length field value is always [5, 15].
 The range of header length is always [20, 60].
 
While solving questions-

 If the given value lies in the range [5, 15] then it must be the header length field value.
 This is because the range of header length is always [20, 60].

6. Reserved Bits-
 

 The 6 bits are reserved.


 These bits are not used.
 

7. URG Bit-
 

URG bit is used to treat certain data on an urgent basis.

 
When URG bit is set to 1,
 It indicates the receiver that certain amount of data within the current segment is
urgent.
 Urgent data is pointed out by evaluating the urgent pointer field.
 The urgent data has be prioritized.
 Receiver forwards urgent data to the receiving application on a separate channel.
 

8. ACK Bit-
 

ACK bit indicates whether acknowledgement number field is valid or not.

 When ACK bit is set to 1, it indicates that acknowledgement number contained in the
TCP header is valid.
 For all TCP segments except request segment, ACK bit is set to 1.
 Request segment is sent for connection establishment during Three Way
Handshake.
 

9. PSH Bit-
 

PSH bit is used to push the entire buffer immediately to the receiving application.

 
When PSH bit is set to 1,

 All the segments in the buffer are immediately pushed to the receiving application.
 No wait is done for filling the entire buffer.
 This makes the entire buffer to free up immediately.
 

NOTE
It is important to note-

 Unlike URG bit, PSH bit does not prioritize the data.
 It just causes all the segments in the buffer to be pushed immediately to the receiving
application.
 The same order is maintained in which the segments arrived.
 It is not a good practice to set PSH bit = 1.
 This is because it disrupts the working of receiver’s CPU and forces it to take an action
immediately.

10. RST Bit-


 

RST bit is used to reset the TCP connection.

 
When RST bit is set to 1,

 It indicates the receiver to terminate the connection immediately.


 It causes both the sides to release the connection and all its resources abnormally.
 The transfer of data ceases in both the directions.
 It may result in the loss of data that is in transit.
 
This is used only when-

 There are unrecoverable errors.


 There is no chance of terminating the TCP connection normally.
 

11. SYN Bit-


 

SYN bit is used to synchronize the sequence numbers.

 
When SYN bit is set to 1,

 It indicates the receiver that the sequence number contained in the TCP header is
the initial sequence number.
 Request segment sent for connection establishment during Three way handshake
contains SYN bit set to 1.
 
12. FIN Bit-
 

FIN bit is used to terminate the TCP connection.

 
When FIN bit is set to 1,

 It indicates the receiver that the sender wants to terminate the connection.
 FIN segment sent for TCP Connection Terminationcontains FIN bit set to 1.
 

13. Window Size-


 

 Window size is a 16 bit field.


 It contains the size of the receiving window of the sender.
 It advertises how much data (in bytes) the sender can receive without
acknowledgement.
 Thus, window size is used for Flow Control.
 

NOTE
It is important to note-

 The window size changes dynamically during data transmission.


 It usually increases during TCP transmission up to a point where congestion is detected.
 After congestion is detected, the window size is reduced to avoid having to drop
packets.

14. Checksum-
 

 Checksum is a 16 bit field used for error control.


 It verifies the integrity of data in the TCP payload.
 Sender adds CRC checksum to the checksum field before sending the data.
 Receiver rejects the data that fails the CRC check.
 
Also Read-CRC |Checksum
 

15. Urgent Pointer-


 

 Urgent pointer is a 16 bit field.


 It indicates how much data in the current segment counting from the first data byte is
urgent.
 Urgent pointer added to the sequence number indicates the end of urgent data byte.
 This field is considered valid and evaluated only if the URG bit is set to 1.
 

USEFUL FORMULAS
 

Formula-01:
Number of urgent bytes = Urgent pointer + 1
 

Formula-02:
End of urgent byte
= Sequence number of the first byte in the segment + Urgent pointer

16. Options-
 

 Options field is used for several purposes.


 The size of options field vary from 0 bytes to 40 bytes.
 
Options field is generally used for the following purposes-
1. Time stamp
2. Window size extension
3. Parameter negotiation
4. Padding
 

A. Time Stamp-
 
When wrap around time is less than life time of a segment,

 Multiple segments having the same sequence number may appear at the receiver
side.
 This makes it difficult for the receiver to identify the correct segment.
 If time stamp is used, it marks the age of TCP segments.
 Based on the time stamp, receiver can identify the correct segment.
 

B. Window Size Extension-


 

 Options field may be used to represent a window size greater than 16 bits.
 Using window size field of TCP header, window size of only 16 bits can be
represented.
 If the receiver wants to receive more data, it can advertise its greater window size
using this field.
 The extra bits are then appended in Options field.
 

C. Parameter Negotiation-
 
Options field is used for parameters negotiation.
Example- During connection establishment,

 Both sender and receiver have to specify their maximum segment size.
 To specify maximum segment size, there is no special field.
 So, they specify their maximum segment size using this field and negotiates.
 

D. Padding-
 

 Addition of dummy data to fill up unused space in the transmission unit and make it
conform to the standard size is called as padding.
 Options field is used for padding.
 

Example-
 

 When header length is not a multiple of 4, extra zeroes are padded in the Options
field.
 By doing so, header length becomes a multiple of 4.
 If header length = 30 bytes, 2 bytes of dummy data is added to the header.
 This makes header length = 32 bytes.
 Then, the value 32 / 4 = 8 is put in the header length field.
 In worst case, 3 bytes of dummy data might have to be padded to make the header
length a multiple of 4.

Transmission Control Protocol-


 
Before you go through this article, make sure that you have gone through the previous
article on TCP in Networking.
 
We have discussed-

 TCP continuously receives data from the application layer.


 It divides the data into chunks where each chunk is a collection of bytes.
 It then creates TCP segments by adding a TCP header to the data chunks.

TCP segment = TCP header + Data chunk

TCP Sequence Number-


 

 Each TCP segment sent by the sender contains some bytes of data.
 TCP assigns a unique number to each data byte for its identification.
 This unique number is called as TCP Sequence Number.
 

Purpose-
 
Sequence number serves the following purposes-

 It helps to identify each data byte uniquely.


 It helps in the segmentation of data into TCP segments and reassemble them later.
 It helps to keep track of how much data has been transferred and received.
 It helps to put the data back into the correct order if it is received in the wrong order.
 It helps to request data when it has been lost in transit.
 

Maximum Number of Sequence Numbers-


 
 In TCP header, sequence number is a 32 bit field.
 So, maximum number of possible sequence numbers = 232.
 These sequence numbers lie in the range [0 , 232 – 1].
 

NOTE-
 

 Maximum number of possible sequence numbers = 232.


 This does not imply that only 232 bytes = 4 GB data can be sent using TCP.
 The concept of wrap around allows to send unlimited data using TCP.
 

Concept Of Wrap Around-


 
The concept of wrap around states-
 

After all the 232 sequence numbers are used up and more data is to be sent,
the sequence numbers can be wrapped around and used again from the starting.

 
In general,

 If the initial sequence number chosen is X.


 Then sequence numbers are used from X to 232 – 1 and then from to 0 to X-1.
 Then, sequence numbers are wrapped around to send more data.
 

Example-
 

 Consider the initial sequence number used is 0.


 Then after sending 4 GB data, all the sequence numbers would get used up.
 To send more data, sequence numbers are reused from the starting.
 Wrapping around can be done again and again to send more and more data.
 

Wrap Around Time-


 
 Time taken to use up all the 232 sequence numbers is called as wrap around time.
 It depends on the bandwidth of the network i.e. the rate at which the bytes go out.
 More the bandwidth, lesser the wrap around time and vice versa.
 

Wrap Around Time ∝ 1 / Bandwidth

Formula-
 
If bandwidth of the network = x bytes/sec, then-
 

Life Time Of TCP Segment-


 
In modern computers,

 Life time of a TCP segment is 180 seconds or 3 minutes.


 It means after sending a TCP segment, it might reach the receiver taking 3 minutes
in the worst case.
 

How Wrap Around Is Possible?


 
It is possible to wrap around the sequence numbers because-

 The life time of a TCP segment is just 180 seconds.


 Wrap around time is much greater than life time of a TCP segment.
 So, by the time the sequence numbers wrap around, there is no probability of
existing any segment having the same sequence number.
 Thus, even after wrapping around, the sequence number of all the bytes will be
unique at any given time.
 

Reducing Wrap Around Time-


 

Wrap around time can be reduced to the life time of a TCP segment.

 
This is because-

 After the life time of a segment completes, it is considered that the segment no
longer exists.
 So, sequence numbers used by the segment frees up and can be reused.
 
To reduce the wrap around time to the life time of segment,

 There must exist as many sequence numbers as there are number of data bytes
sent in time equal to life time of segment.
 

Formula-
 

Number of bits required in the sequence number field


so that wrap around time becomes equal to lifetime of TCP segment
= log2 (lifetime of TCP segment x Bandwidth)

 The number of bits will be greater than 32 bits.


 The extra bits are appended in the Options field of TCP header.
 

PRACTICE PROBLEMS BASED ON WRAP AROUND


TIME IN TCP-
 

Problem-01:
 
Given the bandwidth of a network is 1 MB / sec. Calculate the wrap around time.
 

Solution-
 
We know,

 Wrap around time = Time taken to use all the 232 sequence numbers.
 TCP assigns 1 sequence number to each byte of data.
 
To calculate wrap around time, we just need to calculate how much time will be taken to
send 232 bytes of data.
 
Now,

 Given bandwidth = 1 MB / sec = 106 bytes / sec.


 It means 106 bytes of data is sent in time = 1 sec.
 So, 232 bytes of data will be sent in time = ( 1 / 106 ) x 232 sec.
 On solving, we get 1.19 hours.
 
Thus,

 It will take 1.19 hours to consume all the 232 sequence numbers if bandwidth = 1
MB / sec.
 Wrap Around Time = 1.19 hours.
 
Alternatively,
Using the formula, we have-
Wrap Around Time
= 232 / 106 sec
= 1.19 hours
 

Problem-02:
 
If bandwidth of the network is 1 GBps, how many extra bits will have to be appended in the
Options field so that wrap around time becomes equal to the life time of segment?
 
Solution-
 
For wrap around time to become equal to the life time of TCP segment,
Number of sequence numbers required = Number of bytes sent in life time of TCP segment
 
We know-

 Life time of TCP segment = 180 sec.


 Bandwidth of the network = 1 GBps (Given)
 
Now,
 Number of bytes transferred in 1 sec = 1 GB
 So, number of bytes transferred in 180 sec = 180 GB = 180 x 230 bytes
 So, number of sequence numbers required = 180 x 230
 
Suppose y number of bits in the sequence number field are required to represent the value
180 x 230.
 
So, we have-
2y = 180 x 230
ylog2 = log(180 x 230)
y = log2(180 x 230)
y = log2180 + log2230
y = 7.49 + 30
y≅ 38
 
From here,

 Total number of bits required for sequence numbers = 38 bits.


 In TCP header, sequence number field is a 32 bit field.
 So, extra bits required to be appended in the Options field = 38 – 32 = 6 bits.
 
Alternatively,
Using the formula, we have-
Total bits required
= log2 (life time of TCP segment x bandwidth)
= log2 ( 180 x 230)
= log2180 + log2230
= 7.49 + 30
= 38
 
From here,

 Total number of bits required for sequence numbers = 38 bits.


 In TCP header, sequence number field is a 32 bit field.
 So, extra bits required to be appended in the Options field = 38 – 32 = 6 bits.
 

Problem-03:
 
In a network that has a maximum TPDU size of 128 bytes, a maximum TPDU lifetime of 30
sec and 8 bit sequence number, what is the maximum data rate per connection?
(TPDU is Transport layer protocol data unit which is the segment.)
 

Solution-
 
Given-

 Maximum segment size (MSS) = 128 bytes


 Segment lifetime = 30 sec
 Bits in sequence number = 8
 
Now,

 Maximum number of possible sequence numbers using 8 bits = 28 = 256.


 So, maximum number of bytes that can be uniquely identified = 256 bytes.
 Lifetime of a segment = 30 seconds.
 So, maximum amount of data that can be sent in 30 seconds = 256 bytes.
 
Thus,
Maximum data rate per connection
= 256 bytes / 30 seconds
≈ 68 bits/sec
 

Problem-04:
 
Suppose that the advertised window 1 MB long. If a sequence number is selected at
random from the entire sequence number space, what is the probability that the sequence
number falls inside the advertised window?
 

Solution-
 
We know,

 Number of bits in sequence number field = 32 bits.


 So, Maximum number of sequence numbers possible = 232.
 232 bytes of data can be labeled uniquely with these sequence numbers.
 Advertised window size = 1 MB = 220 bytes which uses 220 sequence numbers.
 
Therefore,
Required probability
= 220 / 232
= 1 / 212

Transmission Control Protocol-


 
Before you go through this article, make sure that you have gone through the previous
article on TCP in Networking.
We have discussed-

 TCP establishes an end to end connection between the sender and receiver.
 This connection is established before exchanging the data.
 TCP connection is reliable and ensures in order delivery.
 
Also Read-TCP Header
 
In this article, we will discuss how a TCP connection is established.
 

3 Way Handshake-
 

Three Way Handshake is a process used for establishing a TCP connection.

 
Consider-

 Client wants to establish a connection with the server.


 Before Three Way Handshake, both client and server are in closed state.
 
TCP Handshake involves the following steps in establishing the connection-
 

Step-01: SYN-
 
For establishing a connection,

 Client sends a request segment to the server.


 Request segment consists only of TCP Header with an empty payload.
 Then, it waits for a reply segment from the server.
 
 
Request segment contains the following information in TCP header-
1. Initial sequence number
2. SYN bit set to 1
3. Maximum segment size
4. Receiving window size
 

1. Initial Sequence Number-


 

 Client sends the initial sequence number to the server.


 It is contained in the sequence number field.
 It is a randomly chosen 32 bit value.
 

2. SYN Bit Set To 1-


 
Client sets SYN bit to 1 which indicates the server-

 This segment contains the initial sequence number used by the client.
 It has been sent for synchronizing the sequence numbers.
 
Also Read-TCP Sequence Number
 

3. Maximum Segment Size (MSS)-


 

 Client sends its MSS to the server.


 It dictates the size of the largest data chunk that client can send and receive from the
server.
 It is contained in the Options field.
 

4. Receiving Window Size-


 

 Client sends its receiving window size to the server.


 It dictates the limit of unacknowledged data that can be sent to the client.
 It is contained in the window size field.
 

Step-02: SYN + ACK-


 
After receiving the request segment,

 Server responds to the client by sending the reply segment.


 It informs the client of the parameters at the server side.
 
 
Reply segment contains the following information in TCP header-
1. Initial sequence number
2. SYN bit set to 1
3. Maximum segment size
4. Receiving window size
5. Acknowledgment number
6. ACK bit set to 1
 

1. Initial Sequence Number-


 

 Server sends the initial sequence number to the client.


 It is contained in the sequence number field.
 It is a randomly chosen 32 bit value.
 

2. SYN Bit Set To 1-


 
Server sets SYN bit to 1 which indicates the client-

 This segment contains the initial sequence number used by the server.
 It has been sent for synchronizing the sequence numbers.
 

3. Maximum Segment Size (MSS)-


 

 Server sends its MSS to the client.


 It dictates the size of the largest data chunk that server can send and receive from
the client.
 It is contained in the Options field.
 

4. Receiving Window Size-


 

 Server sends its receiving window size to the client.


 It dictates the limit of unacknowledged data that can be sent to the server.
 It is contained in the window size field.
 
5. Acknowledgement Number-
 

 Server sends the initial sequence number incremented by 1 as an acknowledgement


number.
 It dictates the sequence number of the next data byte that server expects to receive
from the client.
 

6. ACK Bit Set To 1-


 

 Server sets ACK bit to 1.


 It indicates the client that the acknowledgement number field in the current segment
is valid.
 

Step-03: ACK-
 
After receiving the reply segment,

 Client acknowledges the response of server.


 It acknowledges the server by sending a pure acknowledgement.
 
 
With these, a Full Duplex connection is established.
 

Important Points-
 

Point-01:
 
In step-01 and step-02-

 The connection parameters are established for the first side.


 They are acknowledged by the second side.
 
In step-02 and step-03-

 The connection parameters are established for the second side.


 They are acknowledged by the first side.
 

Point-02:
 

Connection establishment phase consume 1 sequence number of both the sides.

 Request segment consumes 1 sequence number of the requester.


 Reply segment consumes 1 sequence number of the respondent.
 Pure acknowledgements do not consume any sequence number.
 

Point-03:
 

Pure acknowledgement for the reply segment is not necessary.

 
This is because-

 If client sends the data packet immediately, then it will be considered as an


acknowledgement.
 It means that in the first two steps only, the full duplex connection is established.
 

Point-04:
 

For all the segments except the request segment, ACK bit is always set to 1.

 
This is because-

 For the request segment, acknowledgement number field will always be invalid.
 For all other segments, acknowledgement number field will always be valid.
 

Point-05:
 

Certain parameters are negotiated during connection establishment.

 
The negotiation can be on setting the values of following parameters-
1. Window size
2. Maximum segment size
3. Timer values
 

Point-06:
 
In any TCP segment,

 If SYN bit = 1 and ACK bit = 0, then it must be the request segment.
 If SYN bit = 1 and ACK bit = 1, then it must be the reply segment.
 If SYN bit = 0 and ACK bit = 1, then it can be the pure ACK or segment meant for
data transfer.
 If SYN bit = 0 and ACK bit = 0, then this combination is not possible.
 

Point-07:
 

 The combination SYN bit = 0 and ACK bit = 0 is not possible.


 It is because SYN bit = 0 signifies it is not the request segment and reply segment.
 For all other segments, ACK bit is always set to 1.
 

Point-08:
 

 Consider sender sends the segments of size greater than MSS of receiver.
 Then, they are first fragmented first at the receiver side.
 It causes an extra overhead.
 
Point-09:
 

 There is no dedicated field for sending MSS in TCP header.


 This is because MSS has to informed only once.
 So, if dedicated field would be present, then sending it each time would not be
required.
 For this reason, MSS is informed once using Options field.
 
Also Read-TCP Connection Termination
 

PRACTICE PROBLEMS BASED ON THREE WAY


HANDSHAKE-
 

Problem-01:
 
SYN = 0 and ACK = 1 indicates-
1. Open connection packet
2. Open connection ACK
3. Data packet
4. ACK packet
 

Solution-
 
Options (C) and (D) are correct.
 

Problem-02:
 
An acknowledgement by TCP sender guarantees-
1. Data has been delivered to the application
2. Data has been received by TCP module
3. Data has been received by application interface
4. None of the above
 

Solution-
 
Option (A) is correct.

 Three Way Handshake-


 
Before you go through this article, make sure that you have gone through the previous
article on Three Way Handshake.
We have discussed-

 TCP uses Three Way Handshake to establish a connection between the sender and
receiver.
 Connection establishment using Three Way Handshake involves the steps as
shown-
 
 
In this article, we will discuss how a lost TCP segment is retransmitted.
 

TCP Retransmission-
 
After establishing the connection,

 Sender starts transmitting TCP segments to the receiver.


 A TCP segment sent by the sender may get lost on the way before reaching the
receiver.
 This causes the receiver to send the acknowledgement with same ACK number to
the sender.
 As a result, sender retransmits the same segment to the receiver.
 This is called as TCP retransmission.
 

When TCP Retransmission Occurs?


 

When sender discovers that the segment sent by it is lost,


it retransmits the same segment to the receiver.

 
Sender discovers that the TCP segment is lost when-
1. Either Time Out Timer expires
2. Or it receives three duplicate acknowledgements
 

1. Retransmission After Time Out Timer Expiry-


 
Each time sender transmits a TCP segment to the receiver, it starts a Time Out Timer.
Now, following two cases are possible-
 

Case-01:
 

 Sender receives an acknowledgement for the sent segment before the timer goes
off.
 In this case, sender stops the timer.
 

Case-02:
 

 Sender does not receives any acknowledgement for the sent segment and the timer
goes off.
 In this case, sender assumes that the sent segment is lost.
 Sender retransmits the same segment to the receiver and resets the timer.
 
Also Read-Time Out Timer
 

Example-
 

2. Retransmission After Receiving 3 Duplicate


Acknowledgements-
 

 Consider sender receives three duplicate acknowledgements for a TCP segment


sent by it.
 Then, sender assumes that the corresponding segment is lost.
 So, sender retransmits the same segment without waiting for its time out timer to
expire.
 This is known as Early retransmission or Fast retransmission.
 

Example-
 
Consider-
 Sender sends 5 TCP segments to the receiver.
 The second TCP segment gets lost before reaching the receiver.
 
The sequence of steps taking place are-
 

 On receiving segment-1, receiver sends acknowledgement asking for segment-2


next.
(Original ACK)

 On receiving segment-3, receiver sends acknowledgement asking for segment-2


next.
(1st duplicate ACK)
 On receiving segment-4, receiver sends acknowledgement asking for segment-2
next.
(2nd duplicate ACK)

 On receiving segment-5, receiver sends acknowledgement asking for segment-2


next.
(3rd duplicate ACK)
 
Now,

 Sender receives 3 duplicate acknowledgements for segment-2 in total.


 So, sender assumes that the segment-2 is lost.
 So, it retransmits segment-2 without waiting for its timer to go off.
 
 

NOTE
After receiving the retransmitted segment-2,

 Receiver does not send the acknowledgement asking for segment-3 or 4 or 5.


 Receiver sends the acknowledgement asking for segment-6 directly from the sender.
 This is because previous segments have been already received and acknowledgements
for them have been already sent (although wasted in asking for segment-2).

Important Points-
 
Point-01:
 

 Consider time out timer expires before receiving the acknowledgement for a TCP
segment.
 This case suggests the stronger possibility of congestion in the network.
 

Point-02:
 

 Consider sender receives 3 duplicate acknowledgements for the same TCP


segment.
 This case suggests the weaker possibility of congestion in the network.
 

Point-03:
 

 Consider receiver does not receives 3 duplicate acknowledgements for the lost TCP
segment.
 In such a case, retransmission occurs only after time out timer goes off.
 

Point-04:
 

 Retransmission on receiving 3 duplicate acknowledgements is a way to improve the


performance over retransmission on time out.
 
Also Read-TCP Congestion Control
 

PRACTICE PROBLEM BASED ON TCP


RETRANSMISSION-
 

Problem-
 
Consider a TCP connection in a state where there are no outstanding ACKs. The sender
sends two segments back to back. The sequence numbers of the first and second
segments are 230 and 290 respectively. The first segment was lost but the second segment
was received correctly by the receiver.
Let X be the amount of data carried in the first segment (in bytes) and Y be the ACK
number sent by the receiver.
The values of X and Y are-
1. 60 and 290
2. 230 and 291
3. 60 and 231
4. 60 and 230
 

Solution-
 
It is given that sender sends two segments where-

 1st segment contains the sequence number 230 and gets lost.
 2nd segment contains the sequence number 290 and is received correctly.
 

Amount Of Data Sent In First Segment-


 
Given-

 Sequence number of 1st segment = 230


 Sequence number of 2nd segment = 290
 
From here, range of sequence numbers contained in the 1st segment = [230,289].
 
Now,

 Total number of sequence numbers contained in the 1st segment = 289 – 230 + 1 =
60.
 TCP assigns one sequence number to each byte of data.
 Thus, Amount of data contained in the first segment = 60 bytes.
 

ACK Number Sent By Receiver-


 
On receiving the 2nd segment,

 Receiver sends the acknowledgement asking for the first segment only.
 This is because it expects the 1st segment first.
 Receiver keeps sending this ACK number until it receives the first segment correctly.
 Thus, Acknowledgement number = Sequence number of the 1st segment = 230.
 
Thus, Option (D) is correct.

Three Way Handshake-


 
Before you go through this article, make sure that you have gone through the previous
article on Three Way Handshake.
We have discussed-

 TCP uses Three Way Handshake to establish a connection between the sender and
receiver.
 Connection establishment using Three Way Handshake involves the steps as
shown-
 
 
Also Read-TCP Retransmission
 
In this article, we will discuss how a TCP connection is terminated.
 

TCP Connection Termination-


 

A TCP connection is terminated using FIN segment where FIN bit is set to 1.

 
Consider-

 There is a well established TCP connection between the client and server.
 Client wants to terminate the connection.
 
The following steps are followed in terminating the connection-
 

Step-01:
 
For terminating the connection,

 Client sends a FIN segment to the server with FIN bit set to 1.
 Client enters the FIN_WAIT_1 state.
 Client waits for an acknowledgement from the server.
 

Step-02:
 
After receiving the FIN segment,

 Server frees up its buffers.


 Server sends an acknowledgement to the client.
 Server enters the CLOSE_WAIT state.
 
 

Step-03:
 
After receiving the acknowledgement, client enters the FIN_WAIT_2 state.
 
Now,

 The connection from client to server is terminated i.e. one way connection is closed.
 Client can not send any data to the server since server has released its buffers.
 Pure acknowledgements can still be sent from the client to server.
 The connection from server to client is still open i.e. one way connection is still open.
 Server can send both data and acknowledgements to the client.
 
 

Step-04:
 
Now, suppose server wants to close the connection with the client.
 
For terminating the connection,

 Server sends a FIN segment to the client with FIN bit set to 1.
 Server waits for an acknowledgement from the client.
 
 

NOTE
If server wanted,
It could have sent the FIN segment along with the previous acknowledgment that it sent to the
client.

Step-05:
 
After receiving the FIN segment,

 Client frees up its buffers.


 Client sends an acknowledgement to the server (not mandatory).
 Client enters the TIME_WAIT state.
 
 

TIME_WAIT State-
 

 The TIME_WAIT state allows the client to resend the final acknowledgement if it gets
lost.
 The time spent by the client in TIME_WAIT state depends on the implementation.
 The typical values are 30 seconds, 1 minute and 2 minutes.
 After the wait, the connection gets formally closed.
 

Application Layer Protocols-


 
Important application layer protocols are-

1. Domain Name Service (DNS)


2. Hyper Text Transfer Protocol (HTTP)
3. Simple Mail Transfer Protocol (SMTP)
4. Post Office Protocol (POP)
5. File Transfer Protocol (FTP)
 
In this article, we will discuss about Domain Name Service (DNS).
 

DNS in Networking-
 

 DNS is short for Domain Name Service or Domain Name System.


 It is an application layer protocol.
 

Purpose-
 

 DNS is a host name to IP Address translation service.


 It converts the names we type in our web browser address bar to the IP Address of
web servers hosting those sites.
 
 

Need-
 
The need for Domain Name Service arises due to the following reasons-
 

Point-01:
 

 IP Addresses are not static and may change dynamically.


 So, a mapping is required which maps the domain names to the IP Addresses of
their web servers.
 

Point-02:
 

 IP Addresses are a complex series of numbers.


 So, it is difficult to remember IP Addresses directly while it is easy to remember
names.
 

DNS Resolution-
 

DNS Resolution is a process of resolving a domain name onto an IP Address.

 
The following diagram illustrates the process of DNS resolution-
 
 
The steps involved in DNS Resolution are-
 

Step-01:
 

 A user program sends a name query to a library procedure called the resolver.
 

Step-02:
 
Resolver looks up the local domain name cache for a match.

 If a match is found, it sends the corresponding IP Address back.


 If no match is found, it sends a query to the local DNS server.
 

Step-03:
 
DNS server looks up the name.

 If a match is found, it returns the corresponding IP Address to the resolver.


 If no match is found, the local DNS server sends a query to a higher level DNS
server.
 This process is continued until a result is returned.
 

Step-04:
 

 After receiving a response, the DNS client returns the resolution result to the
application.
 

Important Notes-
 

Note-01:
 

DNS uses UDP (port 53) at the transport layer.

 
DNS uses UDP at the transport layer due to the following reasons-
 

Point-01:
 

 UDP is much faster than TCP.


 TCP is slow as it uses Three-way handshake to start the data transfer.
 

Point-02:
 

 DNS requests are very small.


 So, they fits well within UDP segments.
 

Point-03:
 

 Although UDP is not reliable but reliability can be added on application layer.
 Reliability can be added by using timeouts and resend at the application layer.
 
Thus, in the end both speed and protection are achieved.
 

Note-02:
 

DNS is a connection less protocol.

 DNS uses UDP at the transport layer for replying to the DNS queries of clients.
 Therefore, it is a connection less protocol.
 

Note-03:
 

DNS is non-persistent.

 
 

Note-04:
 

DNS is a stateless protocol.

 
This is because-

 DNS server accepts the requests, process them, resolves the query and forget about
them.
 It does not make any assumption how long this will be.
 

Note-05:
 
Mapping an IP Address onto a domain name is referred to as Inverse domain.

 
It is important to note-

 DNS can translate a domain name onto an IP Address.


 Also, it can translate an IP Address onto a domain name.
 

Note-06:
 

For the first time,


There is more delay in translating the domain name onto an IP Address.

 Converting a domain name onto an IP Address is an extra overhead.


 This overhead is called as DNS Overhead.
 It causes an unnecessary delay in serving the request.
 So, there is more delay for the first time.
 To reduce the delay next time, IP Addresses are stored in the computer using log.
 This avoids the DNS overhead next time and takes less time in serving the request.
 When it gets expired, the request is again served through DNS.

Application Layer Protocols-


 
Important application layer protocols are-
 
 
1. Domain Name Service (DNS)
2. Hyper Text Transfer Protocol (HTTP)
3. Simple Mail Transfer Protocol (SMTP)
4. Post Office Protocol (POP)
5. File Transfer Protocol (FTP)
 
In this article, we will discuss about Hyper Text Transfer Protocol (HTTP).
 

Hyper Text Transfer Protocol-


 

 HTTP is short for Hyper Text Transfer Protocol.


 It is an application layer protocol.
 

Purpose-
 

 It is mainly used for the retrieval of data from websites throughout the internet.
 It works on the top of TCP/IP suite of protocols.
 
Working-
 
HTTP uses a client-server model where-

 Web browser is the client.


 Client communicates with the web server hosting the website.
 

 
Whenever a client requests some information (say clicks on a hyperlink) to the website
server.
The browser sends a request message to the HTTP server for the requested objects.
 
Then-

 HTTP opens a connection between the client and server through TCP.


 HTTP sends a request to the server which collects the requested data.
 HTTP sends the response with the objects back to the client.
 HTTP closes the connection.
 

HTTP Connections-
 
HTTP connections can be of two types-
1. Non-persistent HTTP connection
2. Persistent HTTP connection
 
 

Non-persistent HTTP connection Persistent HTTP connection

Non-persistent HTTP connection is one that is


Persistent HTTP connection is one that can
used for serving exactly one request and
be used for serving multiple requests.
sending one response.

HTTP server closes the TCP connection only


HTTP server closes the TCP connection
when it is not used for a certain configurable
automatically after sending a HTTP response.
amount of time.

A new separate TCP connection is used for A single TCP connection is used for sending
each object. multiple objects one after the other.

HTTP 1.0 supports non-persistent HTTP 1.1 supports persistent connections by


connections by default. default.

Example- Example-
 
 
Suppose a request has been made for a
Suppose a request has been made for a
HTML page that contains 10 images (called
HTML page that contains 10 images (called
objects).
objects).
Then,
Then,
With non-persistent connection, all the 11
With persistent connection, all the 11 objects
objects (1 page + 10 images) will be sent one
(1 page + 10 images) will be sent one after
by one.
the other using a single TCP connection.
For getting each object, a new separate
 
connection will be opened and used.
 

Important Notes-
 

Note-01:
 

HTTP uses TCP at the transport layer.

 
This is because-

 Unlike UDP, it guarantees the delivery of data via a Three-way handshake.


 It ensures the re transmission of lost packets.
 HTTP does not have any inbuilt facility for providing reliability.
 So, if HTTP uses UDP, then it will have to maintain or handle the session on its own.
 For example- If a packet gets lost, then HTTP will have to re-transmit the packet.
 

Note-02:
 
It is important to know-

 Any service which does not use TCP should have the inbuilt facility for providing
reliability.
 

Note-03:
 

HTTP uses port number 80.

 HTTP clients uses port 80 to send and receive requested web pages from a HTTP
server.
 Similarly, HTTP server responds to all the requests at port 80.
 

Note-04:
 

HTTP 1.0 is non-persistent and HTTP 1.1 is persistent.

 Already discussed in the above table.


 Persistent connections improve the performance by 20%.
 

Note-05:
 

HTTP 1.0 is a connectionless protocol.

 
This is because-

 After serving the single HTTP request, the connection is closed and it is not used
again.
 So, HTTP 1.0 without connection keep alive is connectionless.
 

Note-06:
 

HTTP is an in-band protocol.

 
This is because-

 HTTP passes the control data (commands) and main data over the same
connection.
 Both control data and main data are processed in the same way without any
distinction.
 No high priority is given to the control data (commands).
 

Note-07:
 
HTTP is a stateless protocol.

 
This is because-

 HTTP server does not maintain any state.


 It forgets about the client after sending the response.
 It treats every new request independently.
 HTTP closes the connection automatically after generating the response for each
request.
 This ensures that no client can engage connection with web server for a long time.
 

What If HTTP Is Stateful Protocol?


 
If HTTP is a stateful protocol, then-

 It will give a chance to the browser window to engage the connection with the web
server for a long time.
 This may unnecessarily create a situation of reaching to maximum connections of a web
server even though most of the connections are idle.

Simple Mail Transfer Protocol-


 

 SMTP is short for Simple Mail Transfer Protocol.


 It is an application layer protocol.
 It is used for sending the emails efficiently and reliably over the internet.
 

Working-
 

 SMTP server is always on a listening mode.


 Client initiates a TCP connection with the SMTP server.
 SMTP server listens for a connection and initiates a connection on that port.
 The connection is established.
 Client informs the SMTP server that it would like to send a mail.
 Assuming the server is OK, client sends the mail to its mail server.
 Client’s mail server use DNS to get the IP Address of receiver’s mail server.
 Then, SMTP transfers the mail from sender’s mail server to the receiver’s mail
server.
 

 
While sending the mail, SMTP is used two times-
1. Between the sender and the sender’s mail server
2. Between the sender’s mail server and the receiver’s mail server
 

NOTE-
 
To receive or download the email,

 Another protocol is needed between the receiver’s mail server and the receiver.
 The most commonly used protocols are POP3 and IMAP.
 

Characteristics of SMTP-
 

 SMTP is a push protocol.


 SMTP uses TCP at the transport layer.
 SMTP uses port number 25.
 SMTP uses persistent TCP connections, so it can send multiple emails at once.
 SMTP is a connection oriented protocol.
 SMTP is an in-band protocol.
 SMTP is a stateless protocol.
 

Important Points-
 

Note-01:
 

SMTP is a pure text based protocol.

 SMTP can only handle the messages containing 7 bit ASCII text.
 SMTP can not transfer other types of data like images, video, audio etc.
 SMTP can not transfer executable files and binary objects.
 SMTP can not transfer the text data of other languages like French, Japanese,
Chinese etc.
(since they are represented in 8 bit codes)
 

Note-02:
 

MIME extends the limited capabilities of email.

 
As the name suggests,

 Multipurpose Internet Email Extension (MIME) is an extension to the internet email


protocol.
 It extends the limited capabilities of email by enabling the users to send and receive
graphics, audio files, video files etc in the message.
 MIME was specially designed for SMTP.
 

Note-03:
 

SMTP is a stateless protocol.


 
This is because-

 It does not maintain the state of its clients.


 If an email is asked to be sent twice, then SMTP server resends it without saying that
the email has already been sent.
 

Note-04:
 

We can not use SMTP at the receiver’s side.

 
This is because-

 SMTP is a push protocol.


 At receiver’s side, a pull protocol like POP3, IMAP is needed.
 Receiver periodically checks if he has any mail from his mail server.
 

Note-05:
 

Sender and receiver can not run SMTP between their machines.

 
This is because-

 Machines can not always be ON.


 So, the functionality has been divided between the client and the mail server.
 The mail server receives the mail on behalf of its client and manages the mail box of
the client.
 

Note-06:
 

SMTP is not suitable for client authentication.


 
This is because-

 SMTP does not require authentication.


 It allows anyone on the Internet to send emails to anyone or even to a large group of
people.
 SMTP Auth short for SMTP Authentication has been provided for authentication.
 

Post Office Protocol-


 

 POP is short for Post Office Protocol.


 It is an application layer protocol.
 

Purpose-
 

 It is a message access protocol.


 It enables the clients to receive or download the emails from their remote mail
server.
 POP version 3 (POP3) is the most popularly used version.
 

Working-
 
To retrieve a message from the mail server-

 Client establishes a TCP connection using port 110.


 Client identifies itself to the server.
 Client issues a series of POP3 commands.
 
 

Characteristics of POP-
 

 POP is a pull protocol.


 POP uses TCP at the transport layer.
 POP uses port number 110.
 POP uses persistent TCP connections.
 POP is a connection oriented protocol.
 POP is an in-band protocol.
 POP is a stateful protocol until the mail is downloaded as well as stateless across
sessions.
 

Internet Message Access Protocol-


 

 IMAP is short for Internet Message Access Protocol.


 It is an application layer protocol.
 It also enables the clients to receive or download the emails from their remote mail
server.
 

POP has been largely superseded by Internet Message Access Protocol (IMAP).

Characteristics of IMAP-
 

 IMAP is a pull protocol.


 IMAP uses TCP at the transport layer.
 IMAP uses port number 143.
 IMAP uses persistent TCP connections.
 IMAP is a connection oriented protocol.
 IMAP is an in-band protocol.
 IMAP is a stateful protocol.
 IMAP distributes mail boxes across multiple servers.
 

POP Vs IMAP-
 
The following table lists the differences between POP and IMAP-
 

Post Office Protocol Internet Message Access Protocol

IMAP allows you to check the mail content


POP allows you to read the mail only after before downloading.
downloading it. So, with IMAP you can choose to download
your messages or just delete them.

The email message is downloaded to the local


The email message is stored on the mail
computer and the copy at the server is
server itself.
deleted.

The user can not organize mails in the mail


The user can organize mails on the server.
box of the mail server.

Mails can only be accessed from a single Mails can be accessed from multiple devices
device. which is the biggest advantage.
In POP, the mail server and client’s mail
In IMAP, the mail server and the client’s mail
account are not synced.
account are synced.
So, changes made in the client’s mail account
So, changes made in the client’s mail account
are not visible on the web mail inbox.
are instantly visible on the web mail inbox.
 
 
Example- Example-
 
 
If you are using POP and marks a mail as
If you are using IMAP and marks a mail as
read, it does not get marked as read in the
read, it gets marked as read in the web mail
web mail inbox because the mails are
inbox too because the changes are taking
downloaded to the computer and so the
place on the server.
changes won’t be visible on the server.

POP is a stateful protocol until the mail is IMAP is a stateful protocol because the IMAP
downloaded as well as stateless across server has to maintain a folder hierarchy for
sessions. each of its users.

IMAP is a better choice for those who


POP is a better choice for those who hardly
frequently check their mails on other
checks their mail on any other computer.
computers.

File Transfer Protocol-


 

 FTP is short for File Transfer Protocol.


 It is an application layer protocol.
 

Purpose-
 

 It is used for exchanging files over the internet.


 It enables the users to upload and download the files from the internet.
 

Working-
 
FTP establishes two TCP connections between the client and the server.
 One connection is used for transferring data.
 Other connection is used for transferring control information.
 

Characteristics of FTP-
 

 FTP uses TCP at the transport layer.


 FTP uses port number 21 for control connection.
 FTP uses port number 20 for data connection.
 FTP uses persistent TCP connections for control connection.
 FTP uses non-persistent connections for data connection.
 FTP is a connection oriented protocol.
 FTP is an out-of-band protocol as data and control information flow over different
connections.
 SMTP is a stateful protocol.
 

Important Notes-
 

Note-01:
 

Emails can’t be sent using FTP.

 
This is because-
 FTP requires the connection establishment between the client and server before
transferring the files.
 So, both have to be online at the same time.
 That is why, emails are not sent using FTP.
 

Note-02:
 

FTP can transfer one file at a time.

 FTP is used for transferring one file at a time in either direction between the client
and the server.
 

Note-03:
 

FTP is a stateful protocol.

 
This is because-

 The client establishes control connection for the duration of an FTP session.
 It typically spans multiple data transfers.
 So, FTP is a stateful protocol.
 

omparison of Application Layer Protocols-


 
The following table compares all the important application layer protocols-
 

DNS HTTP SMTP POP FTP


Stateful /
Stateless Stateless Stateless Stateful Stateful
Stateless

Transport
UDP TCP TCP TCP TCP
Protocol Used

Connectionles
Connectionles Connectionles Connectio Connectio Connectio
s / Connection
s s n Oriented n Oriented n Oriented
Oriented

Control
connection
HTTP 1.0 is is
non-persistent. persistent.
Persistent /
Non-persistent Persistent Persistent Data
Non-persistent HTTP 1.1 is
connection
persistent.
is non-
persistent.

20 for data
connection
.
Port Number 21 for
53 80 25 110
Used control
connection
.

In band / Out- Out-of-


In band In band In band In band
of-band band

You might also like