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

Numerical in Computer Networks

Uploaded by

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

Numerical in Computer Networks

Uploaded by

Syed Altaf
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 208

Numerical In Computer Networks

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

1|CN_NU MER ICALS _D D P


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

2|CN_NU MER ICALS _D D P


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.

3|CN_NU MER ICALS _D D P


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

4|CN_NU MER ICALS _D D P


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 %
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
5|CN_NU MER ICALS _D D P
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
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
6|CN_NU MER ICALS _D D P
 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-

Given-
 Bandwidth = 1 Mbps
 Propagation delay (Tp) = 0.75 ms
 Processing time (Tprocess) = 0.25 ms
 Data frame size = 1980 bytes
 Acknowledgement frame size = 20 bytes
 Overhead in data frame = 20 bytes

Calculating Useful Time-

Useful data sent


= Transmission delay of useful data bytes sent
= Useful data bytes sent / Bandwidth
= (1980 bytes – 20 bytes) / 1 Mbps
= 1960 bytes / 1 Mbps
= (1960 x 8 bits) / (106 bits per sec)
= 15680 μsec
= 15.680 msec

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
7|CN_NU MER ICALS _D D P
= (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%
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

8|CN_NU MER ICALS _D D P


= (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
9|CN_NU MER ICALS _D D P
=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-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,

2n = W + W
2n = 2W
W = 2n-1
Therefore, maximum window size possible of sender and receiver = 2n-1
Thus, Option (B) is correct.

10 | C N _ N U M E R I C A L S _ D D P
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

11 | C N _ N U M E R I C A L S _ D D P
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

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

12 | C N _ N U M E R I C A L S _ D D P
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

13 | C N _ N U M E R I C A L S _ D D P
= 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.

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

14 | C N _ N U M E R I C A L S _ D D P
= (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.
Compute approximate optimal window size when packet size is 53 bytes, RTT is
60 msec and bottleneck bandwidth is 155 Mbps.

Solution-

15 | C N _ N U M E R I C A L S _ D D P
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

16 | C N _ N U M E R I C A L S _ D D P
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

17 | C N _ N U M E R I C A L S _ D D P
= ⌈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

18 | C N _ N U M E R I C A L S _ D D P
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

19 | C N _ N U M E R I C A L S _ D D P
= 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

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)

20 | C N _ N U M E R I C A L S _ D D P
= 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
Example-

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


The corresponding binary pattern is obtained as-

21 | C N _ N U M E R I C A L S _ D D P
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-

22 | C N _ N U M E R I C A L S _ D D P
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,

23 | C N _ N U M E R I C A L S _ D D P
 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.

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-

24 | C N _ N U M E R I C A L S _ D D P
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:

25 | C N _ N U M E R I C A L S _ D D P
 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.

26 | C N _ N U M E R I C A L S _ D D P
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.
Example:

Checksum value of 1001001110010011 and 1001100001001101 of 16 bit segment


is-
1. 1010101000011111
2. 1011111000100101
3. 1101010000011110
4. 1101010000111111

Solution-

27 | C N _ N U M E R I C A L S _ D D P
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

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
3. 0,1
4. 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.
Problem:
 If the receiving station successfully copies the data, it sets the Copied bit to 1.
Which of the following fields in 802.5 MAC header is not included in CRC or
FCS?
 FC
 Data field
 FS
 SA

Solution-

28 | C N _ N U M E R I C A L S _ D D P
 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.
Problem-06:

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

29 | C N _ N U M E R I C A L S _ D D P
 A token frame consists of only 3 fields- SD, AC and ED.

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-

Calculating Transmission delay-

We know,
Transmission delay (Tt)
30 | C N _ N U M E R I C A L S _ D D P
= 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-

31 | C N _ N U M E R I C A L S _ D D P
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.

32 | C N _ N U M E R I C A L S _ D D P
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

33 | C N _ N U M E R I C A L S _ D D P
= 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

34 | C N _ N U M E R I C A L S _ D D P
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)

35 | C N _ N U M E R I C A L S _ D D P
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

36 | C N _ N U M E R I C A L S _ D D P
= 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-

Checksum value of 1001001110010011 and 1001100001001101 of 16 bit segment


is-
1. 1010101000011111
2. 1011111000100101

37 | C N _ N U M E R I C A L S _ D D P
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

CSMA / CD Protocol-
Problem-02:

In a CSMA / CD network running at 1 Gbps over 1 km cable with no repeaters, the


signal speed in the cable is 200000 km/sec. What is minimum frame size?

Solution-

Given-
 Bandwidth = 1 Gbps
 Distance = 1 km
 Speed = 200000 km/sec

Calculating Propagation Delay-

Propagation delay (Tp)


= Distance / Propagation speed
= 1 km / (200000 km/sec)
= 0.5 x 10-5 sec

38 | C N _ N U M E R I C A L S _ D D P
= 5 x 10-6 sec

Calculating Minimum Frame Size-

Minimum frame size


= 2 x Propagation delay x Bandwidth
= 2 x 5 x 10-6 sec x 109 bits per sec
= 10000 bits

Problem-03:

A 2 km long broadcast LAN has 107 bps bandwidth and uses CSMA / CD. The
signal travels along the wire at 2 x 108 m/sec. What is the minimum packet size
that can be used on this network?
1. 50 B
2. 100 B
3. 200 B
4. None of the above

Solution-

Given-
 Distance = 2 km
 Bandwidth = 107 bps
 Speed = 2 x 108 m/sec

Calculating Propagation Delay-

Propagation delay (Tp)


= Distance / Propagation speed
= 2 km / (2 x 108 m/sec)
= 2 x 103 m / (2 x 108 m/sec)

39 | C N _ N U M E R I C A L S _ D D P
= 10-5 sec

Calculating Minimum Frame Size-

Minimum frame size


= 2 x Propagation delay x Bandwidth
= 2 x 10-5 sec x 107 bits per sec
= 200 bits or 25 bytes
Problem-04:

A and B are the only two stations on Ethernet. Each has a steady queue of frames
to send. Both A and B attempts to transmit a frame, collide and A wins first back
off race. At the end of this successful transmission by A, both A and B attempt to
transmit and collide. The probability that A wins the second back off race is ___ .
1. 0.5
2. 0.625
3. 0.75
4. 1.0

Solution-

According to question, we have-

1st Transmission Attempt-

 Both the stations A and B attempts to transmit a frame.


 A collision occurs.
 Back Off Algorithm runs.
 Station A wins and successfully transmits its 1st data packet.

2nd Transmission Attempt-

 Station A attempts to transmit its 2nd data packet.


40 | C N _ N U M E R I C A L S _ D D P
 Station B attempts to retransmit its 1st data packet.
 A collision occurs.

Now,
 We have been asked the probability of station A to transmit its 2nd data packet
successfully after 2nd collision.
 After the 2nd collision occurs, we have-

At Station A-

 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 from the range [0,21-1] = [0,1].
 Then, station A waits for back off time and then attempts to retransmit its data
packet.
At Station B-

 1st data packet of station B undergoes collision for the 2nd time.
 So, collision number for the 1st data packet of station B = 2.
 Now, station B randomly chooses a number from the range [0,22-1] = [0,3].
 Then, station B waits for back off time and then attempts to retransmit its data
packet.

Following 8 cases are possible-

Station A Station B Remark

0 0 Collision

0 1 A wins

0 2 A wins

0 3 A wins

41 | C N _ N U M E R I C A L S _ D D P
1 0 B wins

1 1 Collision

1 2 A wins

1 3 A wins

From here,
 Probability of A winning the 2nd back off race = 5 / 8 = 0.625.
 Thus, Option (B) is correct.

Problem-05:

Suppose nodes A and B are on same 10 Mbps Ethernet segment and the
propagation delay between two nodes is 225 bit times. Suppose A and B send
frames at t=0, the frames collide then at what time, they finish transmitting a jam
signal. Assume a 48 bit jam signal.

Solution-

Propagation delay (Tp)


= 225 bit times
= 225 bit / 10 Mbps
= 22.5 x 10-6 sec
= 22.5 μsec
At t = 0,

 Nodes A and B start transmitting their frame.


 Since both the stations start simultaneously, so collision occurs at the mid way.
 Time after which collision occurs = Half of propagation delay.
 So, time after which collision occurs = 22.5 μsec / 2 = 11.25 μsec.

42 | C N _ N U M E R I C A L S _ D D P
At t = 11.25 μsec,

 After collision occurs at t = 11.25 μsec, collided signals start travelling back.
 Collided signals reach the respective nodes after time = Half of propagation delay
 Collided signals reach the respective nodes after time = 22.5 μsec / 2 =
11.25 μsec.
 Thus, at t = 22.5 μsec, collided signals reach the respective nodes.

At t = 22.5 μsec,

 As soon as nodes discover the collision, they immediately release the jam signal.
 Time taken to finish transmitting the jam signal = 48 bit time = 48 bits/ 10 Mbps
= 4.8 μsec.

Thus,
Time at which the jam signal is completely transmitted
= 22.5 μsec + 4.8 μsec
= 27.3 μsec or 273 bit times
Problem-07:

The network consists of 4 hosts distributed as shown below-

Assume this network uses CSMA / CD and signal travels with a speed of 3 x
105 km/sec. If sender sends at 1 Mbps, what could be the minimum size of the
packet?
1. 600 bits
2. 400 bits

43 | C N _ N U M E R I C A L S _ D D P
3. 6000 bits
4. 1500 bits
Solution-

 CSMA / CD is a Access Control Method.


 It is used to provide the access to stations to a broadcast link.
 In the given network, all the links are point to point.
 So, there is actually no need of implementing CSMA / CD.
 Stations can transmit whenever they want to transmit.
 We assume that a packet of same length has to be used in the entire network.
 To get the minimum length of the packet, what distance we should choose?
 To get the minimum length of the packet, we should choose the minimum
distance.
 But, then collision would be detected only in the links having distance less than or
equal to that minimum distance.
 For the links, having distance greater than the minimum distance, collision would
not be detected.
 So, we choose the maximum distance so that collision can be detected in all the
links of the network.

So, we use the values-


 Distance = 90 km
 Speed = 3 x 105 km/sec
 Bandwidth = 1 Mbps

Substituting these values, we get-


Minimum size of data packet
= 2 x (90 km / 3 x 105 km per sec) x 1 Mbps
= 2 x 30 x 10-5 sec x 106 bits per sec
CSMA CD | BackOff Algorithm | Problems
Computer Networks
CSMA / CD Protocol-

44 | C N _ N U M E R I C A L S _ D D P
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 allows a station to transmit data if it senses the carrier free.
 After undergoing collision, station waits for random back off time before
transmitting again.
 Back Off Algorithm is used to calculate back off time.

Also Read- Back Off Algorithm

In this article, we will discuss practice problems based on CSMA / CD and Back
Off Algorithm.

PRACTICE PROBLEMS BASED ON CSMA / CD AND BACK OFF


ALGORITHM-

Problem-01:

After the kth consecutive collision, each colliding station waits for a random time
chosen from the interval-
1. (0 to 2k) x RTT
2. (0 to 2k-1) x RTT
3. (0 to 2k-1) x Maximum Propagation delay
4. (0 to 2k-1) x Maximum Propagation delay

Solution-

Clearly, Option (B) is correct.

Problem-02:

45 | C N _ N U M E R I C A L S _ D D P
In a CSMA / CD network running at 1 Gbps over 1 km cable with no repeaters, the
signal speed in the cable is 200000 km/sec. What is minimum frame size?

Solution-

Given-
 Bandwidth = 1 Gbps
 Distance = 1 km
 Speed = 200000 km/sec

Calculating Propagation Delay-

Propagation delay (Tp)


= Distance / Propagation speed
= 1 km / (200000 km/sec)
= 0.5 x 10-5 sec
= 5 x 10-6 sec

Calculating Minimum Frame Size-

Minimum frame size


= 2 x Propagation delay x Bandwidth
= 2 x 5 x 10 -6 sec x 109 bits per sec
= 10000 bits

Problem-03:

A 2 km long broadcast LAN has 107 bps bandwidth and uses CSMA / CD. The
signal travels along the wire at 2 x 108 m/sec. What is the minimum packet size
that can be used on this network?
1. 50 B
2. 100 B

46 | C N _ N U M E R I C A L S _ D D P
3. 200 B
4. None of the above

Solution-

Given-
 Distance = 2 km
 Bandwidth = 107 bps
 Speed = 2 x 108 m/sec

Calculating Propagation Delay-

Propagation delay (Tp)


= Distance / Propagation speed
= 2 km / (2 x 108 m/sec)
= 2 x 103 m / (2 x 108 m/sec)
= 10-5 sec

Calculating Minimum Frame Size-

Minimum frame size


= 2 x Propagation delay x Bandwidth
= 2 x 10-5 sec x 107 bits per sec
= 200 bits or 25 bytes

Thus, Option (D) is correct.

Problem-04:

A and B are the only two stations on Ethernet. Each has a steady queue of frames
to send. Both A and B attempts to transmit a frame, collide and A wins first back

47 | C N _ N U M E R I C A L S _ D D P
off race. At the end of this successful transmission by A, both A and B attempt to
transmit and collide. The probability that A wins the second back off race is ___ .
1. 0.5
2. 0.625
3. 0.75
4. 1.0

Solution-

According to question, we have-

1st Transmission Attempt-

 Both the stations A and B attempts to transmit a frame.


 A collision occurs.
 Back Off Algorithm runs.
 Station A wins and successfully transmits its 1st data packet.

2nd Transmission Attempt-

 Station A attempts to transmit its 2nd data packet.


 Station B attempts to retransmit its 1 st data packet.
 A collision occurs.

Now,
 We have been asked the probability of station A to transmit its 2nd data packet
successfully after 2nd collision.
 After the 2nd collision occurs, we have-

At Station A-

 2nd data packet of station A undergoes collision for the 1st time.
 So, collision number for the 2nd data packet of station A = 1.

48 | C N _ N U M E R I C A L S _ D D P
 Now, station A randomly chooses a number from the range [0,21-1] = [0,1].
 Then, station A waits for back off time and then attempts to retransmit its data
packet.

At Station B-

 1st data packet of station B undergoes collision for the 2nd time.
 So, collision number for the 1st data packet of station B = 2.
 Now, station B randomly chooses a number from the range [0,22-1] = [0,3].
 Then, station B waits for back off time and then attempts to retransmit its data
packet.

Following 8 cases are possible-

Station A Station B Remark

0 0 Collision

0 1 A wins

0 2 A wins

0 3 A wins

1 0 B wins

1 1 Collision

1 2 A wins

1 3 A wins

From here,
 Probability of A winning the 2nd back off race = 5 / 8 = 0.625.
 Thus, Option (B) is correct.

49 | C N _ N U M E R I C A L S _ D D P
Problem-05:

Suppose nodes A and B are on same 10 Mbps Ethernet segment and the
propagation delay between two nodes is 225 bit times. Suppose A and B send
frames at t=0, the frames collide then at what time, they finish transmitting a jam
signal. Assume a 48 bit jam signal.

Solution-

Propagation delay (Tp)


= 225 bit times
= 225 bit / 10 Mbps
= 22.5 x 10-6 sec
= 22.5 μsec

At t = 0,

 Nodes A and B start transmitting their frame.


 Since both the stations start simultaneously, so collision occurs at the mid way.
 Time after which collision occurs = Half of propagation delay.
 So, time after which collision occurs = 22.5 μsec / 2 = 11.25 μsec.

At t = 11.25 μsec,

 After collision occurs at t = 11.25 μsec, collided signals start travelling back.
 Collided signals reach the respective nodes after time = Half of propagation delay
 Collided signals reach the respective nodes after time = 22.5 μsec / 2 =
11.25 μsec.
 Thus, at t = 22.5 μsec, collided signals reach the respective nodes.

50 | C N _ N U M E R I C A L S _ D D P
At t = 22.5 μsec,

 As soon as nodes discover the collision, they immediately release the jam signal.
 Time taken to finish transmitting the jam signal = 48 bit time = 48 bits/ 10 Mbps
= 4.8 μsec.

Thus,
Time at which the jam signal is completely transmitted
= 22.5 μsec + 4.8 μsec
= 27.3 μsec or 273 bit times

Problem-06:

Suppose nodes A and B are attached to opposite ends of the cable with propagation
delay of 12.5 ms. Both nodes attempt to transmit at t=0. Frames collide and after
first collision, A draws k=0 and B draws k=1 in the exponential back off protocol.
Ignore the jam signal. At what time (in seconds), is A’s packet completely
delivered at B if bandwidth of the link is 10 Mbps and packet size is 1000 bits.

Solution-

Given-
 Propagation delay = 12.5 ms
 Bandwidth = 10 Mbps
 Packet size = 1000 bits

Time At Which Collision Occurs-

Collision occurs at the mid way after time


= Half of Propagation delay
= 12.5 ms / 2
= 6.25 ms
Thus, collision occurs at time t = 6.25 ms.
51 | C N _ N U M E R I C A L S _ D D P
Time At Which Collision is Discovered-

Collision is discovered in the time it takes the collided signals to reach the nodes
= Half of Propagation delay
= 12.5 ms / 2
= 6.25 ms
Thus, collision is discovered at time t = 6.25 ms + 6.25 ms = 12.5 ms.

Scene After Collision-

After the collision is discovered,


 Both the nodes wait for some random back off time.
 A chooses k=0 and then waits for back off time = 0 x 25 ms = 0 ms.
 B chooses k=1 and then waits for back off time = 1 x 25 ms = 25 ms.
 From here, A begins retransmission immediately while B waits for 25 ms.

Waiting Time For A-

 After winning the back off race, node A gets the authority to retransmit
immediately.
 But node A does not retransmit immediately.
 It waits for the channel to clear from the last bit aborted by it on discovering the
collision.
 Time taken by the last bit to get off the channel = Propagation delay = 12.5 ms.
 So, node A waits for time = 12.5 ms and then starts the retransmission.
 Thus, node A starts the retransmission at time t = 12.5 ms + 12.5 ms = 25 ms.

Time Taken in Delivering Packet To Node B-

Time taken to deliver the packet to node B


= Transmission delay + Propagation delay

52 | C N _ N U M E R I C A L S _ D D P
= (1000 bits / 10 Mbps) + 12.5 ms
= 100 μs + 12.5 ms
= 0.1 ms + 12.5 ms
= 12.6 ms

Thus, At time t = 25 ms + 12.6 ms = 37.6 ms, the packet is delivered to node B.

Problem-07:

The network consists of 4 hosts distributed as shown below-

Assume this network uses CSMA / CD and signal travels with a speed of 3 x
105 km/sec. If sender sends at 1 Mbps, what could be the minimum size of the
packet?
1. 600 bits
2. 400 bits
3. 6000 bits
4. 1500 bits

Solution-

 CSMA / CD is a Access Control Method.


 It is used to provide the access to stations to a broadcast link.
 In the given network, all the links are point to point.
 So, there is actually no need of implementing CSMA / CD.
 Stations can transmit whenever they want to transmit.

In CSMA / CD,
The condition to detect collision is-
Packet size >= 2 x (distance / speed) x Bandwidth

53 | C N _ N U M E R I C A L S _ D D P
To solve the question,
 We assume that a packet of same length has to be used in the entire network.
 To get the minimum length of the packet, what distance we should choose?
 To get the minimum length of the packet, we should choose the minimum
distance.
 But, then collision would be detected only in the links having distance less than or
equal to that minimum distance.
 For the links, having distance greater than the minimum distance, collision would
not be detected.
 So, we choose the maximum distance so that collision can be detected in all the
links of the network.

So, we use the values-


 Distance = 90 km
 Speed = 3 x 105 km/sec
 Bandwidth = 1 Mbps

Substituting these values, we get-


Minimum size of data packet
= 2 x (90 km / 3 x 105 km per sec) x 1 Mbps
= 2 x 30 x 10-5 sec x 106 bits per sec
= 600 bits
PRACTICE PROBLEMS BASED ON TOKEN RING AND TOKEN
PASSING-

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

54 | C N _ N U M E R I C A L S _ D D P
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-

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
55 | C N _ N U M E R I C A L S _ D D P
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

56 | C N _ N U M E R I C A L S _ D D P
= 0.89 x 3 Mbps
= 2.67 Mbps

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
57 | C N _ N U M E R I C A L S _ D D P
= 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

58 | C N _ N U M E R I C A L S _ D D P
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-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

59 | C N _ N U M E R I C A L S _ D D P
 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

60 | C N _ N U M E R I C A L S _ D D P
= Throughput
= Efficiency(η) x Bandwidth
= 0.5 x 10 Mbps
= 5 Mbps
PRACTICE PROBLEM BASED ON PURE ALOHA AND SLOTTED
ALOHA-

1. Pure Aloha-

 It allows the stations to transmit data at any time whenever they want.
 After transmitting the data packet, station waits for some time.

Then, following 2 cases are possible-


Case-01:

 Transmitting station receives an acknowledgement from the receiving station.


 In this case, transmitting station assumes that the transmission is successful.

Case-02:

 Transmitting station does not receive any acknowledgement within specified time
from the receiving station.
 In this case, transmitting station assumes that the transmission is unsuccessful.

Then,
 Transmitting station uses a Back Off Strategy and waits for some random
amount of time.
 After back off time, it transmits the data packet again.
 It keeps trying until the back off limit is reached after which it aborts the
transmission.

Efficiency-

61 | C N _ N U M E R I C A L S _ D D P
Efficiency of Pure Aloha (η) = G x e-2G

where G = Number of stations willing to transmit data

Maximum Efficiency-

For maximum efficiency,


 We put dη / dG = 0
 Maximum value of η occurs at G = 1/2
 Substituting G = 1/2 in the above expression, we get-

Maximum efficiency of Pure Aloha


= 1/2 x e -2 x 1/2
= 1 / 2e
= 0.184
= 18.4%
Thus,

Maximum Efficiency of Pure Aloha (η) = 18.4%

The maximum efficiency of Pure Aloha is very less due to large number of
collisions.

2. Slotted Aloha-

 Slotted Aloha divides the time of shared channel into discrete intervals called
as time slots.
 Any station can transmit its data in any time slot.
 The only condition is that station must start its transmission from the beginning of
the time slot.

62 | C N _ N U M E R I C A L S _ D D P
 If the beginning of the slot is missed, then station has to wait until the beginning
of the next time slot.
 A collision may occur if two or more stations try to transmit data at the beginning
of the same time slot.

Efficiency-

Efficiency of Slotted Aloha (η) = G x e-G

where G = Number of stations willing to transmit data at the beginning of the same
time slot
Maximum Efficiency-

For maximum efficiency,


 We put dη / dG = 0
 Maximum value of η occurs at G = 1
 Substituting G = 1 in the above expression, we get-

Maximum efficiency of Slotted Aloha


= 1 x e -1
=1/e
= 0.368
= 36.8%

Thus,

Maximum Efficiency of Slotted Aloha (η) =


36.8%

The maximum efficiency of Slotted Aloha is high due to less number of collisions.
Problem-
63 | C N _ N U M E R I C A L S _ D D P
Consider a network using the pure ALOHA medium access control protocol,
where each frame is of length 1,000 bits. The channel transmission rate is 1 Mbps
(=106 bits per second). The aggregate number of transmissions across all the nodes
(including new frame transmissions and retransmitted frames due to collisions) is
modelled as a Poisson process with a rate of 1,000 frames per second. Throughput
is defined as the average number of frames successfully transmitted per second.
The throughput of the network (rounded to the nearest integer) is
______________ .
Explanation:
General Formula of Efficiency of Pure Aloha
= G x e-2G
Where G is number of requests send in given time slot
So now Tt
= L/BW
= 1000/106
= 1 millisecond
For 1000 frames it will be 1000*1 millisecond = 1 second
So now in 1 second total 1000 frames send ,So G =1
Value of e = 2.71(Mathematical constant)
So efficiency
= 1* 2.71^(-2+1)
= 0.1353
Now for 1000 frames it would be 1000*0.1353 = 135.3
(Closest Integer=135)
Ethernet in Networking | Practice Problems

Problem-

A group of N stations share 100 Kbps slotted ALOHA channel. Each station output
a 500 bits frame on an average of 5000 ms even if previous one has not been sent.
What is the required value of N?

Solution-

64 | C N _ N U M E R I C A L S _ D D P
Throughput Of One Station-

Throughput of each station


= Number of bits sent per second
= 500 bits / 5000 ms
= 500 bits / (5000 x 10-3 sec)
= 100 bits/sec

Throughput Of Slotted Aloha-

Throughput of slotted aloha


= Efficiency x Bandwidth
= 0.368 x 100 Kbps
= 36.8 Kbps

Total Number Of Stations-

Throughput of slotted aloha = Total number of stations x Throughput of each


station
Substituting the values, we get-
36.8 Kbps = N x 100 bits/sec
∴ N = 368
Thus, required value of N = 368.

To gain better understanding about Aloha,

Ethernet in Networking | Practice Problems

65 | C N _ N U M E R I C A L S _ D D P
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

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

66 | C N _ N U M E R I C A L S _ D D P
 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(η)

67 | C N _ N U M E R I C A L S _ D D P
= 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.

68 | C N _ N U M E R I C A L S _ D D P
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.

69 | C N _ N U M E R I C A L S _ D D P
 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

70 | C N _ N U M E R I C A L S _ D D P
Calculating Utilization-

Throughput = Efficiency x Bandwidth


So, Efficiency or Utilization
= Throughput / Bandwidth
= (166613.33 bits per sec) / 10 Mbps
= 0.017
= 1.7%
Circuit Switching in Networking | Switching
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-

71 | C N _ N U M E R I C A L S _ D D P
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

 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

Case-01: Sending Message in 1 Packet-

In this case, the entire message is sent in a single packet.

Size Of Packet-

72 | C N _ N U M E R I C A L S _ D D P
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

73 | C N _ N U M E R I C A L S _ D D P
= 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

74 | C N _ N U M E R I C A L S _ D D P
= 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

75 | C N _ N U M E R I C A L S _ D D P
= 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.

76 | C N _ N U M E R I C A L S _ D D P
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

77 | C N _ N U M E R I C A L S _ D D P
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
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

78 | C N _ N U M E R I C A L S _ D D P
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


79 | C N _ N U M E R I C A L S _ D D P
= 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.

80 | C N _ N U M E R I C A L S _ D D P
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-

81 | C N _ N U M E R I C A L S _ D D P
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
82 | C N _ N U M E R I C A L S _ D D P
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

83 | C N _ N U M E R I C A L S _ D D P
= 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

84 | C N _ N U M E R I C A L S _ D D P
= 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.


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

85 | C N _ N U M E R I C A L S _ D D P
 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-

86 | C N _ N U M E R I C A L S _ D D P
Next
Destination Distance
Hop

A 0 A

B 2 B

C ∞ –

D 1 D

At Router B-

Next
Destination Distance
Hop

A 2 A

B 0 B

C 3 C

D 7 D

At Router C-

Next
Destination Distance
Hop

A ∞ –

B 3 B

87 | C N _ N U M E R I C A L S _ D D P
C 0 C

D 11 D

At Router D-

Next
Destination Distance
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.


88 | C N _ N U M E R I C A L S _ D D P
 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-

Next
Destination Distance
Hop

A 0 A

B 2 B

C 5 B

D 1 D

89 | C N _ N U M E R I C A L S _ D D P
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-

Next
Destination Distance
Hop

A 2 A

B 0 B

C 3 C

90 | C N _ N U M E R I C A L S _ D D P
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-

Next
Destination Distance
Hop

A 5 B

B 3 B

C 0 C

91 | C N _ N U M E R I C A L S _ D D P
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-

Next
Destination Distance
Hop

A 1 A

92 | C N _ N U M E R I C A L S _ D D P
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.

93 | C N _ N U M E R I C A L S _ D D P
Thus, the new routing table at router A is-

Next
Destination Distance
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.

94 | C N _ N U M E R I C A L S _ D D P
 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-

Next
Destination Distance
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.

95 | C N _ N U M E R I C A L S _ D D P
 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-

Next
Destination Distance
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-

96 | C N _ N U M E R I C A L S _ D D P
 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-

Next
Destination Distance
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.

97 | C N _ N U M E R I C A L S _ D D P
 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.

98 | C N _ N U M E R I C A L S _ D D P
 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.

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-

99 | C N _ N U M E R I C A L S _ D D P
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-

100 | C N _ N U M E R I C A L S _ D D P
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:

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

101 | C N _ N U M E R I C A L S _ D D P
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.


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]

102 | C N _ N U M E R I C A L S _ D D P
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-

103 | C N _ N U M E R I C A L S _ D D P
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,

104 | C N _ N U M E R I C A L S _ D D P
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.

105 | C N _ N U M E R I C A L S _ D D P
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.
106 | C N _ N U M E R I C A L S _ D D P
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

107 | C N _ N U M E R I C A L S _ D D P
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.

108 | C N _ N U M E R I C A L S _ D D P
Since all the 3 rules are not satisfied, so they can not be aggregated.

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

109 | C N _ N U M E R I C A L S _ D D P
 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.

110 | C N _ N U M E R I C A L S _ D D P
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

111 | C N _ N U M E R I C A L S _ D D P
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:

112 | C N _ N U M E R I C A L S _ D D P
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:

113 | C N _ N U M E R I C A L S _ D D P
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.

114 | C N _ N U M E R I C A L S _ D D P
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,

115 | C N _ N U M E R I C A L S _ D D P
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.

116 | C N _ N U M E R I C A L S _ D D P
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,

117 | C N _ N U M E R I C A L S _ D D P
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

118 | C N _ N U M E R I C A L S _ D D P
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

119 | C N _ N U M E R I C A L S _ D D P
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.

120 | C N _ N U M E R I C A L S _ D D P
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-

121 | C N _ N U M E R I C A L S _ D D P
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:

122 | C N _ N U M E R I C A L S _ D D P
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:

123 | C N _ N U M E R I C A L S _ D D P
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
124 | C N _ N U M E R I C A L S _ D D P
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.

125 | C N _ N U M E R I C A L S _ D D P
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-

126 | C N _ N U M E R I C A L S _ D D P
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:

127 | C N _ N U M E R I C A L S _ D D P
 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.
128 | C N _ N U M E R I C A L S _ D D P
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.

129 | C N _ N U M E R I C A L S _ D D P
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:

130 | C N _ N U M E R I C A L S _ D D P
 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

131 | C N _ N U M E R I C A L S _ D D P
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.

To gain better understanding about Classless Addressing,


Types of Subnetting-

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

132 | C N _ N U M E R I C A L S _ D D P
1. Fixed Length Subnetting
2. Variable Length Subnetting

1. Fixed Length Subnetting-

Fixed length subnetting also called as classful subnetting 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:

133 | C N _ N U M E R I C A L S _ D D P
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-

134 | C N _ N U M E R I C A L S _ D D P
 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:

135 | C N _ N U M E R I C A L S _ D D P
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.

136 | C N _ N U M E R I C A L S _ D D P
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

137 | C N _ N U M E R I C A L S _ D D P
 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

138 | C N _ N U M E R I C A L S _ D D P
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.

139 | C N _ N U M E R I C A L S _ D D P
 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-

140 | C N _ N U M E R I C A L S _ D D P
 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.

141 | C N _ N U M E R I C A L S _ D D P
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.


142 | C N _ N U M E R I C A L S _ D D P
 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

143 | C N _ N U M E R I C A L S _ D D P
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.

To gain better understanding about IPv4 Subnetting,


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-
144 | C N _ N U M E R I C A L S _ D D P
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.

145 | C N _ N U M E R I C A L S _ D D P
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

146 | C N _ N U M E R I C A L S _ D D P
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.

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

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-

147 | C N _ N U M E R I C A L S _ D D P
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-

148 | C N _ N U M E R I C A L S _ D D P
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

149 | C N _ N U M E R I C A L S _ D D P
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.

150 | C N _ N U M E R I C A L S _ D D P
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

Use of Subnet Mask-

 Subnet mask is used to determine to which subnet the given IP Address belongs
to.

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

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

151 | C N _ N U M E R I C A L S _ D D P
 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.

152 | C N _ N U M E R I C A L S _ D D P
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

153 | C N _ N U M E R I C A L S _ D D P
Since number of Host ID bits = 11, so-

Number of hosts per subnet = 211 – 2 = 2046


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:

154 | C N _ N U M E R I C A L S _ D D P
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:

155 | C N _ N U M E R I C A L S _ D D P
 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


Problem-04:

156 | C N _ N U M E R I C A L S _ D D P
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-

157 | C N _ N U M E R I C A L S _ D D P
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.

158 | C N _ N U M E R I C A L S _ D D P
 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-

159 | C N _ N U M E R I C A L S _ D D P
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.

IPv4 Header-

The following diagram represents the IPv4 header-

160 | C N _ N U M E R I C A L S _ D D P
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.

161 | C N _ N U M E R I C A L S _ D D P
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.

162 | C N _ N U M E R I C A L S _ D D P
 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 ___ ?

163 | C N _ N U M E R I C A L S _ D D P
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

164 | C N _ N U M E R I C A L S _ D D P
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

165 | C N _ N U M E R I C A L S _ D D P
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

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-

166 | C N _ N U M E R I C A L S _ D D P
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.

167 | C N _ N U M E R I C A L S _ D D P
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

168 | C N _ N U M E R I C A L S _ D D P
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

169 | C N _ N U M E R I C A L S _ D D P
 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.

170 | C N _ N U M E R I C A L S _ D D P
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-

171 | C N _ N U M E R I C A L S _ D D P
 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.

172 | C N _ N U M E R I C A L S _ D D P
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

173 | C N _ N U M E R I C A L S _ D D P
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.


174 | C N _ N U M E R I C A L S _ D D P
 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.

175 | C N _ N U M E R I C A L S _ D D P
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

176 | C N _ N U M E R I C A L S _ D D P
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

Intermediate
1 !=0
Fragment

0 !=0 Last Fragment

177 | C N _ N U M E R I C A L S _ D D P
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.

178 | C N _ N U M E R I C A L S _ D D P
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.

179 | C N _ N U M E R I C A L S _ D D P
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

180 | C N _ N U M E R I C A L S _ D D P
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.

181 | C N _ N U M E R I C A L S _ D D P
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?

182 | C N _ N U M E R I C A L S _ D D P
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

Problem-04:

If WAN link is 2 Mbps and RTT between source and destination is 300 msec, what
would be the optimal TCP window size needed to fully utilize the line?

183 | C N _ N U M E R I C A L S _ D D P
1. 60,000 bits
2. 75,000 bytes
3. 75,000 bits
4. 60,000 bytes

Solution-

Given-
 Bandwidth = 2 Mbps
 RTT = 300 msec

Optimal TCP Window Size-

Optimal TCP window size


= Maximum amount of data that can be sent in 1 RTT
= 2 Mbps x 300 msec
= 600 x 103 bits
= 60,0000 bits
= 75,000 bytes

Thus, Option (B) is correct.

Problem-05:

Suppose host A is sending a large file to host B over a TCP connection. The two
end hosts are 10 msec apart (20 msec RTT) connected by a 1 Gbps link. Assume
that they are using a packet size of 1000 bytes to transmit the file. For simplicity,
ignore ack packets. At least how big would the window size (in packets) have to be
for the channel utilization to be greater than 80%?
1. 1000
2. 1500
3. 2000
4. 2500

184 | C N _ N U M E R I C A L S _ D D P
Solution-

Given-
 RTT = 20 msec
 Bandwidth = 1 Gbps
 Packet size = 1000 bytes
 Efficiency >= 80%

Window Size For 100% Efficiency-

For 100% efficiency,


Window size
= Maximum number of bits that can be transmitted in 1 RTT
= 1 Gbps x 20 msec
= (109 bits per sec) x 20 x 10-3 sec
= 20 x 106 bits
= 2 x 107 bits

Window Size For 80% Efficiency-

For 80% efficiency,


Window size
= 0.8 x 2 x 107 bits
= 1.6 x 107 bits

In terms of packets,
Window size
= 1.6 x 107 bits / Packet size
= 1.6 x 107 bits / (1000 x 8 bits)
= 0.2 x 104 packets

185 | C N _ N U M E R I C A L S _ D D P
= 2000 packets

Thus, Option (C) is correct.

Problem-06:

A TCP machine is sending windows of 65535 B over a 1 Gbps channel that has a
10 msec one way delay.
1. What is the maximum throughput achievable?
2. What is the line efficiency?

Solution-

Given-
 Window size = 65535 bytes
 Bandwidth = 1 Gbps
 One way delay = 10 msec

Method-01:

Maximum amount of data that can be sent in 1 RTT


= 1 Gbps x (2 x 10 msec)
= (109 bits per sec) x 20 x 10-3 sec
= 20 x 106 bits
= 25 x 105 bytes

Amount of data that is actually being sent in 1 RTT = 65535 bytes

Thus,
Line Efficiency(η)
= Amount of data being sent in 1 RTT / Maximum amount of data that can be sent
in 1 RTT

186 | C N _ N U M E R I C A L S _ D D P
= 65535 bytes / 25 x 105 bytes
= 0.026214
= 2.62%

Now,
Maximum Achievable Throughput
= Efficiency x Bandwidth
= 0.0262 x 1 Gbps
= 26.214 Mbps

Method-02:

Maximum Achievable Throughput


= Number of bits sent per second
= 65535 B / 20 msec
= (65535 x 8 bits) / (20 x 10-3 sec)
= 26.214 Mbps

Now,
Line Efficiency
= Throughput / Bandwidth
= 26.214 Mbps / 1 Gbps
= 26.214 x 10-3
= 0.026214
= 2.62%
Problem-04:

If WAN link is 2 Mbps and RTT between source and destination is 300 msec, what
would be the optimal TCP window size needed to fully utilize the line?
1. 60,000 bits
2. 75,000 bytes

187 | C N _ N U M E R I C A L S _ D D P
3. 75,000 bits
4. 60,000 bytes

Solution-

Given-
 Bandwidth = 2 Mbps
 RTT = 300 msec

Optimal TCP Window Size-

Optimal TCP window size


= Maximum amount of data that can be sent in 1 RTT
= 2 Mbps x 300 msec
= 600 x 103 bits
= 60,0000 bits
= 75,000 bytes

Thus, Option (B) is correct.

Problem-05:

Suppose host A is sending a large file to host B over a TCP connection. The two
end hosts are 10 msec apart (20 msec RTT) connected by a 1 Gbps link. Assume
that they are using a packet size of 1000 bytes to transmit the file. For simplicity,
ignore ack packets. At least how big would the window size (in packets) have to be
for the channel utilization to be greater than 80%?
1. 1000
2. 1500
3. 2000
4. 2500

Solution-

188 | C N _ N U M E R I C A L S _ D D P
Given-
 RTT = 20 msec
 Bandwidth = 1 Gbps
 Packet size = 1000 bytes
 Efficiency >= 80%

Window Size For 100% Efficiency-

For 100% efficiency,


Window size
= Maximum number of bits that can be transmitted in 1 RTT
= 1 Gbps x 20 msec
= (109 bits per sec) x 20 x 10-3 sec
= 20 x 106 bits
= 2 x 107 bits

Window Size For 80% Efficiency-

For 80% efficiency,


Window size
= 0.8 x 2 x 107 bits
= 1.6 x 107 bits

In terms of packets,
Window size
= 1.6 x 107 bits / Packet size
= 1.6 x 107 bits / (1000 x 8 bits)
= 0.2 x 104 packets
= 2000 packets

189 | C N _ N U M E R I C A L S _ D D P
Thus, Option (C) is correct.

Problem-06:

A TCP machine is sending windows of 65535 B over a 1 Gbps channel that has a
10 msec one way delay.
1. What is the maximum throughput achievable?
2. What is the line efficiency?

Solution-

Given-
 Window size = 65535 bytes
 Bandwidth = 1 Gbps
 One way delay = 10 msec

Method-01:

Maximum amount of data that can be sent in 1 RTT


= 1 Gbps x (2 x 10 msec)
= (109 bits per sec) x 20 x 10-3 sec
= 20 x 106 bits
= 25 x 105 bytes

Amount of data that is actually being sent in 1 RTT = 65535 bytes

Thus,
Line Efficiency(η)
= Amount of data being sent in 1 RTT / Maximum amount of data that can be sent
in 1 RTT
= 65535 bytes / 25 x 105 bytes
= 0.026214

190 | C N _ N U M E R I C A L S _ D D P
= 2.62%

Now,
Maximum Achievable Throughput
= Efficiency x Bandwidth
= 0.0262 x 1 Gbps
= 26.214 Mbps

Method-02:

Maximum Achievable Throughput


= Number of bits sent per second
= 65535 B / 20 msec
= (65535 x 8 bits) / (20 x 10-3 sec)
= 26.214 Mbps

Now,
Line Efficiency
= Throughput / Bandwidth
= 26.214 Mbps / 1 Gbps
= 26.214 x 10-3
= 0.026214
= 2.62%
Problem-04:

If WAN link is 2 Mbps and RTT between source and destination is 300 msec, what
would be the optimal TCP window size needed to fully utilize the line?
1. 60,000 bits
2. 75,000 bytes
3. 75,000 bits
4. 60,000 bytes

191 | C N _ N U M E R I C A L S _ D D P
Solution-

Given-
 Bandwidth = 2 Mbps
 RTT = 300 msec

Optimal TCP Window Size-

Optimal TCP window size


= Maximum amount of data that can be sent in 1 RTT
= 2 Mbps x 300 msec
= 600 x 103 bits
= 60,0000 bits
= 75,000 bytes

Thus, Option (B) is correct.

Problem-05:

Suppose host A is sending a large file to host B over a TCP connection. The two
end hosts are 10 msec apart (20 msec RTT) connected by a 1 Gbps link. Assume
that they are using a packet size of 1000 bytes to transmit the file. For simplicity,
ignore ack packets. At least how big would the window size (in packets) have to be
for the channel utilization to be greater than 80%?
1. 1000
2. 1500
3. 2000
4. 2500

Solution-

Given-
192 | C N _ N U M E R I C A L S _ D D P
 RTT = 20 msec
 Bandwidth = 1 Gbps
 Packet size = 1000 bytes
 Efficiency >= 80%

Window Size For 100% Efficiency-

For 100% efficiency,


Window size
= Maximum number of bits that can be transmitted in 1 RTT
= 1 Gbps x 20 msec
= (109 bits per sec) x 20 x 10-3 sec
= 20 x 106 bits
= 2 x 107 bits

Window Size For 80% Efficiency-

For 80% efficiency,


Window size
= 0.8 x 2 x 107 bits
= 1.6 x 107 bits

In terms of packets,
Window size
= 1.6 x 107 bits / Packet size
= 1.6 x 107 bits / (1000 x 8 bits)
= 0.2 x 104 packets
= 2000 packets

Thus, Option (C) is correct.

193 | C N _ N U M E R I C A L S _ D D P
Problem-06:

A TCP machine is sending windows of 65535 B over a 1 Gbps channel that has a
10 msec one way delay.
1. What is the maximum throughput achievable?
2. What is the line efficiency?

Solution-

Given-
 Window size = 65535 bytes
 Bandwidth = 1 Gbps
 One way delay = 10 msec

Method-01:

Maximum amount of data that can be sent in 1 RTT


= 1 Gbps x (2 x 10 msec)
= (109 bits per sec) x 20 x 10-3 sec
= 20 x 106 bits
= 25 x 105 bytes

Amount of data that is actually being sent in 1 RTT = 65535 bytes

Thus,
Line Efficiency(η)
= Amount of data being sent in 1 RTT / Maximum amount of data that can be sent
in 1 RTT
= 65535 bytes / 25 x 105 bytes
= 0.026214
= 2.62%

194 | C N _ N U M E R I C A L S _ D D P
Now,
Maximum Achievable Throughput
= Efficiency x Bandwidth
= 0.0262 x 1 Gbps
= 26.214 Mbps

Method-02:

Maximum Achievable Throughput


= Number of bits sent per second
= 65535 B / 20 msec
= (65535 x 8 bits) / (20 x 10-3 sec)
= 26.214 Mbps

Now,
Line Efficiency
= Throughput / Bandwidth
= 26.214 Mbps / 1 Gbps
= 26.214 x 10-3
= 0.026214
= 2.62%

PRACTICE PROBLEMS BASED ON TCP CONGESTION CONTROL-

Problem-01:

The growth of congestion window takes place-


1. Infinitely
2. Up to Threshold
3. Up to the size of receiver’s window
4. Up to timeout
195 | C N _ N U M E R I C A L S _ D D P
Solution-

Option (C) is correct.

Problem-02:

Consider the effect of using slow start on a line with a 10 msec RTT and no
congestion. The receiver window is 24 KB and the maximum segment size is 2
KB. How long does it take before the first full window can be sent?

Solution-

Given-
 Receiver window size = 24 KB
 Maximum Segment Size = 2 KB
 RTT = 10 msec

Receiver Window Size-

Receiver window size in terms of MSS


= Receiver window size / Size of 1 MSS
= 24 KB / 2 KB
= 12 MSS

Slow Start Threshold-

Slow start Threshold


= Receiver window size / 2
= 12 MSS / 2
= 6 MSS

196 | C N _ N U M E R I C A L S _ D D P
Slow Start Phase-

 Window size at the start of 1st transmission = 1 MSS


 Window size at the start of 2nd transmission = 2 MSS
 Window size at the start of 3rd transmission = 4 MSS
 Window size at the start of 4th transmission = 6 MSS

Since the threshold is reached, so it marks the end of slow start phase.
Now, congestion avoidance phase begins.

Congestion Avoidance Phase-

 Window size at the start of 5th transmission = 7 MSS


 Window size at the start of 6th transmission = 8 MSS
 Window size at the start of 7th transmission = 9 MSS
 Window size at the start of 8th transmission = 10 MSS
 Window size at the start of 9th transmission = 11 MSS
 Window size at the start of 10th transmission = 12 MSS

From here,
 Window size at the end of 9th transmission or at the start of 10 th transmission is 12
MSS.
 Thus, 9 RTT’s will be taken before the first full window can be sent.

So,
Time taken before the first full window is sent
= 9 RTT’s
= 9 x 10 msec
= 90 msec

Problem-03:

197 | C N _ N U M E R I C A L S _ D D P
Consider an instance of TCP’s Additive Increase Multiplicative Decrease (AIMD)
algorithm where the window size at the start of slow start phase is 2 MSS and the
threshold at the start of first transmission is 8 MSS. Assume that a time out occurs
during the fifth transmission. Find the congestion window size at the end of tenth
transmission.
1. 8 MSS
2. 14 MSS
3. 7 MSS
4. 12 MSS

Solution-

Given-
 Window size at the start of slow start phase = 2 MSS
 Threshold at the start of first transmission = 8 MSS
 Time out occurs during 5th transmission

Slow Start Phase-

 Window size at the start of 1st transmission = 2 MSS


 Window size at the start of 2nd transmission = 4 MSS
 Window size at the start of 3rd transmission = 8 MSS

Since the threshold is reached, so it marks the end of slow start phase.
Now, congestion avoidance phase begins.

Congestion Avoidance Phase-

 Window size at the start of 4th transmission = 9 MSS


 Window size at the start of 5th transmission = 10 MSS

It is given that time out occurs during 5th transmission.

198 | C N _ N U M E R I C A L S _ D D P
TCP reacts by-
 Setting the slow start threshold to half of the current congestion window size.
 Decreasing the congestion window size to 2 MSS (Given value is used).
 Resuming the slow start phase.

So now,
 Slow start threshold = 10 MSS / 2 = 5 MSS
 Congestion window size = 2 MSS

Slow Start Phase-

 Window size at the start of 6th transmission = 2 MSS


 Window size at the start of 7th transmission = 4 MSS
 Window size at the start of 8th transmission = 5 MSS

Since the threshold is reached, so it marks the end of slow start phase.
Now, congestion avoidance phase begins.

Congestion Avoidance Phase-

 Window size at the start of 9th transmission = 6 MSS


 Window size at the start of 10th transmission = 7 MSS
 Window size at the start of 11th transmission = 8 MSS

From here,
Window size at the end of 10th transmission
= Window size at the start of 11th transmission
= 8 MSS

Thus, Option (A) is correct.

Problem-04:

199 | C N _ N U M E R I C A L S _ D D P
Suppose that the TCP congestion window is set to 18 KB and a time out occurs.
How big will the window be if the next four transmission bursts are all successful?
Assume that the MSS is 1 KB.

Solution-

Congestion Window Size-

Congestion window size in terms of MSS


= 18 KB / Size of 1 MSS
= 18 KB / 1 KB
= 18 MSS

Reaction Of TCP On Time Out-

TCP reacts by-


 Setting the slow start threshold to half of the current congestion window size.
 Decreasing the congestion window size to 1 MSS.
 Resuming the slow start phase.

So now,
 Slow start threshold = 18 MSS / 2 = 9 MSS
 Congestion window size = 1 MSS

Slow Start Phase-

 Window size at the start of 1st transmission = 1 MSS


 Window size at the start of 2nd transmission = 2 MSS
 Window size at the start of 3rd transmission = 4 MSS
 Window size at the start of 4th transmission = 8 MSS
 Window size at the start of 5th transmission = 9 MSS

200 | C N _ N U M E R I C A L S _ D D P
Thus, after 4 successful transmissions, window size will be 9 MSS or 9 KB.

Problem-05:

On a TCP connection, current congestion window size is 4 KB. The window


advertised by the receiver is 6 KB. The last byte sent by the sender is 10240 and
the last byte acknowledged by the receiver is 8192.

Part-01:

The current window size at the sender is ____.


1. 2048 B
2. 4096 B
3. 6144 B
4. 8192 B

Part-02:

The amount of free space in the sender window is ____.


1. 2048 B
2. 4096 B
3. 6144 B
4. 8192 B

Solution-

Part-01:

Sender window size


= min (Congestion window size, Receiver window size)
= min(4KB , 6KB)
= 4 KB

201 | C N _ N U M E R I C A L S _ D D P
= 4096 B
Thus, Option (B) is correct.

Part-02:

Given-
 Last byte acknowledged by the receiver = 8192
 Last byte sent by the sender = 10240

From here,
 It means bytes from 8193 to 10240 are still present in the sender’s window.
 These bytes are waiting for their acknowledgement.
 Total bytes present in sender’s window = 10240 – 8193 + 1 = 2048 bytes.

From here,
Amount of free space in sender’s window currently
= 4096 bytes – 2048 bytes
= 2048 bytes

Examples on UDP Header

202 | C N _ N U M E R I C A L S _ D D P
sam_2200

Read
Discuss
User Datagram Protocol is a Transport Layer protocol. UDP is a part of the
Internet Protocol suite, referred to as UDP/IP suite. Unlike TCP, it is an unreliable
and connectionless protocol. So, there is no need to establish a connection prior to
data transfer. Though Transmission Control Protocol (TCP) is the dominant
transport layer protocol used with most Internet services; provides assured

203 | C N _ N U M E R I C A L S _ D D P
delivery, reliability, and much more but all these services cost us additional
overhead and latency. Here, UDP comes into the picture. For real-time services
like computer gaming, voice or video communication, live conferences; we need
UDP. Since high performance is needed, UDP permits packets to be dropped
instead of processing delayed packets. There is no error checking in UDP, so it
also saves bandwidth.
User Datagram Protocol (UDP) is more efficient in terms of both latency and
bandwidth.

UDP header :
UDP header is an 8-bytes fixed and simple header. The first 8 Bytes contains all
necessary header information and the remaining part consist of data. UDP port
number fields are each 16 bits long, therefore the range for port numbers defined
from 0 to 65535; port number 0 is reserved. Port numbers help to distinguish
different user requests or processes.

Example-1 :
Given a DUMP of a UDP header in hexadecimal format 06 32 00 0D 00 1C E2
17. Find the following:-
1. Source port number?
2. Destination port number?

204 | C N _ N U M E R I C A L S _ D D P
3. Length of user datagram?
4. Length of the data?
Solution :
1. Source Port –
Source Port is 2 Byte long field used to identify the port number of the source.
The source port number is the first four hexadecimal digits i.e. 06 32 if we
convert hexadecimal to decimal we get 1586.
2. Destination Port –
It is a 2 Byte long field, used to identify the port of the destined packet. The
destination port number is the second four hexadecimal digits 00 0D if we
convert hexadecimal to decimal we get 13
3. Length –
Length is the length of UDP including the header and the data. It is a 16-bits
field. The third four hexadecimal digits 00 1C if we convert hexadecimal to
decimal we get 16 define the length of the whole UDP packet as 28
4. Length of the header –
It is 8 bytes as it is fixed. The length of the data is the length of the whole packet
— the length of the header i.e. 28 – 8 = 20 bytes.
Example-2 :
Given a DUMP of a UDP header in hexadecimal format 04 21 00 0B 00 2A E2
17. Find the following:-
1. Source port number?
2. Destination port number?
3. Length of user datagram?
4. Length of the data?
Solution:
1. The source port number is the first four hexadecimal digits i.e. 04 21 if we
convert hexadecimal to decimal we get 1057
2. The destination port number is the second four hexadecimal digits 00 0B if we
convert hexadecimal to decimal we get 11
3. The third four hexadecimal digits 00 2A if we convert hexadecimal to decimal 42
define the length of the whole UDP packet as 28
4. The length of the data is the length of the whole packet — the length of the
header i.e. 28 – 8 = 20 bytes.
Example-3 :
Given a DUMP of a UDP header in hexadecimal format 03 61 10 1A 10 4C Y2 42.
Find the following:-
1. Source port number?
2. Destination port number?

205 | C N _ N U M E R I C A L S _ D D P
3. Length of user datagram?
4. Length of the data?
Solution:
1. The source port number is the first four hexadecimal digits i.e. 03 61 if we
convert hexadecimal to decimal we get 0865
2. The destination port number is the second four hexadecimal digits 10 1A if we
convert hexadecimal to decimal we get 4122
3. The third four hexadecimal digits 10 4C if we convert hexadecimal to decimal
4172 define the length of the whole UDP packet as 28
4. The length of the data is the length of the whole packet — the length of the
header i.e. 28 – 8 = 20 bytes.

Problems: TCP and UDP 1. The TCP sliding windows are byte-oriented. What does this mean? 2. A TCP
connection is using a window size of 10 000 bytes, and the previous acknowledgment number was 22
001. It receives a segment with acknowledgment number 24 001.

Draw a diagram to show the situation of the window before and after.

3. A client uses UDP to send data to a server. The data are 16 bytes. Calculate the efficiency of this
transmission at the UDP level (ratio of useful bytes to total bytes).

4. Redo Exercise 3. calculating the efficiency of transmission at the IP level using

(a) IPv4 packets (assume no options)

(b) IPv6 packets (assume no extension headers)

5. A client uses TCP to send data to a server. The data are 16 bytes. Calculate the efficiency of this
transmission at the TCP level (ratio of useful bytes to total bytes, assume no options).

6. Redo Exercise 5., calculating the efficiency of transmission at the IP level using

(a) IPv4 packets (assume no options)

(b) IPv6 packets (assume no extension headers)

7. Comment on the results in Exercises 3.–6.. Give examples of applications where it is good to use UDP
and TCP respectively.

8. The following is a dump of a UDP header in hexadecimal form: 06 32 00 0D 00 1C E2 17 What is the

(a) Source port number

(b) Destination port number

206 | C N _ N U M E R I C A L S _ D D P
(c) Total length of the UDP

(d) Length of tha data

(e) Considering that an IP frame can have a maximum total length of 65 535 bytes, what is the maximum
length of the data in a UDP frame?

Solutions:

TCP and UDP

1.It means that the sequence and acknowledgement numbers refer to bytes instead of segments. For
example, the value of the ack-field in a segment defines the number of the next byte a party expects to
receive. 1 Figure 1: Sliding window of Exercise 2..

2. Presumptions: window size = 10000 bytes, previous acknowledgement 22001, receives


acknowledgement 24001. The movement of the window can be seen in Figure 1.

3. Data are 16 bytes, length of UDP header is 8 bytes, so the ratio is 16 16+8 = 2 3 .

4. Data are 16 bytes, length of IP header (no options) + UDP header is 28 bytes, so the ratio is 16 28+16 =
0.364.

5. Data are 16 bytes, length of TCP header (no options) is 20 bytes, so the ratio is 16 20+16 = 4 9 . 6. Data
are 16 bytes, length of IP header (no options) + TCP header (no options) is 40 bytes, so the ratio is 16
16+40 = 0.286.

7. UDP is a very simple protocol with minimal overhead. If a process wants to send a small message and
does not care much about reliability, it can use UDP. Sending a small message using UDP takes much less
interaction between sender and receiver than using TCP. UDP is used in multimedia and multicast
applications, such as multiplayer games. If reliability is wanted on the other hand, TCP should be chosen.
FTP and Telnet use TCP as transport layer protocol.

8. The UDP header has four parts, each of two bytes. That means we get the following interpretation of
the header.

207 | C N _ N U M E R I C A L S _ D D P
(a) Source port number = 063216 = 1586

(b) Destination port number = 000D16 = 13

(c) Total length = 001C16 = 28 bytes

(d) Since the header is 8 bytes the data length is 28 − 8 = 20 bytes.

(e) The IP header is minimum 20 bytes, which gives the maximum payload 65515 bytes. To fit a UDP
frame in this with header of 8 bytes we get data 65515−8 = 65507 bytes.

208 | C N _ N U M E R I C A L S _ D D P

You might also like