Make your own free website on
Consider a TCP client application that writes a small application header(8B) followed by a small request(12B). It then waits for a reply from the server. What happens if the request is sent using two writes (8B, then 12B) versus a single write of 20B?
Sol. Consider,
Scenario 1: Here two separate packets are sent for application header and request i.e 8bytes and 12 bytes resp.
Scenario 2: Here single packet is sent consisting both header and request i.e 8B+12B = 20B
Packets in Scenario 1:
1) for application header packet construction will be
Data link hdr + IP hdr + TCP hdr + application hdr size
= 26B + 20B + 20B + 8B
= 74B
2) for request packet construction will be
Data link hdr + IP hdr + TCP hdr + request size
= 26B + 20B + 20B + 12B
= 78B
Therefore, total bytes sent in scenario 1 will be
74B + 78B = 152B
Packet in Scenario 2:
User Data = Application hdr + request
= 8B + 12B = 20B
total bytes sent = Data link hdr + IP hdr + TCP hdr + User Data
= 26B + 20B + 20B + 20B = 86B

Therefore, certainly scenario 2 performs well then scenario 1
Efficiency of scenario 2 as opposed to scenario 1:
= (86/152)*100
= 56.58 %
Other Advantages:
1) Bandwidth is saved in scenario 2.
2) OS processing is comparatively less in scenario 2. Since less number of packets means less number of interrupts and less number of system calls for handling packets.

If the TCP round-trip time, RTT, is currently 30ms and the following acknowledgements come in after 26, 32 and 24 ms, resp, what is the new RTT estimate? use alpha = 0.9.
Sol: (ref page 541 Tanenbaum , 3rd Edition)
For each connection TCP maintains a variable, RTT, that is the best current estimate of the round-trip time to the destination in question. When a segment is sent, a timer is started, both to see how long the acknowledgement takes and to trigger a retransmission if it takes too long. If the acknowledgement gets back before the
timer expires, TCP measures how long the acknowledgement took, say, M. It then updates RTT according to the formula:
RTT = alpha*RTT + (1 - alpha) * M ............ (1)
where alpha is a smoothing factor that determines how much weight is given to the old value.
RTT = current RTT = 30ms
alpha = 0.9

1) After 1st ack is reached i.e M = 26ms
we substitue values in equation 1, we get,
RTT = 0.9*30+(1-0.9)*26
= 29.6ms
This now becomes current RTT.

2) After 2nd ack is reached i.e M = 32ms
we substitue values in equation 1, we get,
RTT = 0.9*29.6+(1-0.9)*32
= 29.84ms
This now becomes current RTT.

2) After 3rd ack is reached i.e M = 24ms
we substitue values in equation 1, we get,
RTT = 0.9*29.84+(1-0.9)*24
= 29.256ms
This now becomes current RTT.
Thus the new RTT estimate is 29.256ms

Using the RSA public key cryptosystem, with a=1, b=2, etc.
1. if p=7 and q=11, list five legal values for d.
2. if p=13, q=31 & d=7, find e.
3. using p=5, q=11 & d=27, find e and encrypt "abcdefghij".
Sol: (ref page 599 Tanenbaum, 3rd Edition)
Basic RSA Algorithm:
1. Choose two primes, p & q.
2. Compute n=p*q and z=(p-1)*(q-1).
3. Choose a number relatively prime to z and call it d.
4. Find e such that e*d=1modz.
i)given: p=7, q=11
n = p*q = 77
z = (p-1)(q-1) = 60
we have to find numbers relatively prime to 60.
Relatively prime numbers:
Two numbers are relatively prime when they share no factors in common other than 1. In other words, if the greatest common divisor of a and n is equal to 1. This is written: gcd(a,n) = 1
The numbers 15 and 28 are relatively prime, 15 and 27 are not, and 13 and 500 are. A prime number is relatively prime to all other numbers except its multiples.
Therefore, legal values for d are:
13, 17, 19, 23, 29 etc.
ii)given: p=13, q=31 & d=7, e=?
e=103 (This value is derived by using extended euclidean algorithm. Contact rahul for details)
iii)given: p=5, q=11, d=27, e=?
e=3 (This value is derived by using extended euclidean algorithm. Contact rahul for details)
C= P3(mod 55)

Sym Num P3 C=P3(mod 55) C7 C7(mod33) Sym
A 1 1 1 1 1 A
B 2 8 8 2.4178524 2 B
C 3 27 27 4.4342638 3 C
D 4 64 9 5.8149725 4 D
E 5 125 15 5.6815131 5 E
F 6 216 51 1.2717246 6 F
G 7 343 13 1.1925330 7 G
H 8 512 17 1.6677133 8 H
I 9 729 14 8.8197630 9 I
J 10 1000 10 1027 10 J

You login to a Unix system that you have never used before and want to find the subnet directed broadcast address for all attached interfaces that support broad-casting. How can you do this?
Sol. Unix has a command `ifconfig' which gives output the network address and corresponding subnet mask of all the interfaces that are up currently.
Steps in finding subnet directed broadcast address:
1) Use ifconfig to find all interfaces in the machine
2) for each interface repeat step 3 & 4
3) Compute the network prefix address of the interface
Example: for an interfaces its
IP Addr =
Subnet Mask =
To compute the network prefix we have to logically AND the IP Addr and subnet mask
or in binary
AND 11111111.11111111.11111111.00000000
where 192.168.10 is network prefix and the ending 0 is the host prefix
4) Once we get the network prefix and host prefix, stuff all 1's in the host prefix and keep the network prefix as it is, we get,
which is the subnet directed broadcast address.