Sample Solutions: TH TH TH

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Department of Computer Science and Information Systems, BITS Pilani

Second Semester 2017-2018


Computer Networks (CS F303)
MID SEMESTER TEST Regular (CLOSE BOOK) SAMPLE SOLUTIONS
Duration: 90 Mints (2:00 to 3:30 PM) Date: 9-3-2018 MM: 50
Note: All questions are compulsory. Answer sub parts of a question (if any) together.
Assume 1K = 103, 1M = 106, 1G = 109
Q.1 Consider a source A that uses TCP Reno (Fast Retransmit + Fast Recovery) to transfer a file of 12 KBytes to destination
B. Each packet has a payload of 1 KBytes. Assume that three packets are lost during the file transfer: the 4th and 8th data
packets and ack of 9th data packet (assume data packets numbering starts from 1). [8+2=10M]
a) Draw the time line diagram (a sample is shown in Fig.1) of the entire file transfer. Ignore the connection setup,
connection close, processing and transmission times. Assume that retransmission timeout (RTO) is 4xRTT. How many
RTTs does it take to transfer the entire file?
Sol: Total 10 RTTs will be required. <1 mark>

<8 marks: Important things to be shown are 4th data packet loss, 3 dup ACKs, 4th packet retransmission & 8th packet loss
& timeout, 9th packet ACK lost & sending other remaining packets in next RTT>
b) How many RTTs would be required to transfer the file, if there is no packet loss happens?
Sol: Total 4 RTTs will be sufficient to transmit 12 packets (MSS) for no packet loss scenario. (1, 2, 4, 5 = 12 packets)
<2 marks for correct answer, no partial marks>

Page 1 of 6
Fig.1
Q.2 The mechanisms used to provide reliable data transfer are Checksum, ACKs, NAKs, Timers and Sequence Numbering.
Consider a sender and receiver that are connected by a sender-to-receiver channel that can corrupt and lose packets.
The receiver-to-sender channel is reliable (i.e., it will not lose or corrupt packets). Neither channel will reorder packets.
You can assume timeout estimation mechanism which overrules any possibility of premature timeout.
You have to design a stop-and-wait style reliable data transfer protocol for this scenario (let us name it as rdt 4.0) using
only those mechanisms (among the five listed above) that are absolutely required. That is, if you use a mechanism that
is not required, your answer will not be given full credit, even if the protocol works. Your protocol should have the
functionality to reliably deliver data under the stated assumptions. [7+3=10M]
a) Show the sender and receiver Finite State Machines (FSMs) of rdt 4.0 protocol.
Sol: rdt_send(data)
snkpkt = make_pkt(data, checksum)
udt_send(sndpkt) Sender FSM
starttimer(T)

Wait for timeout


call from Wait for
above ACK udt_send(sndpkt)
starttimer(T)

rdt_rcv(rcvpkt) && isACK(rcvpkt)


stop timer
<5 marks for sender FSM>

Wait for
call from
below

rdt_rcv(rcvpkt) && notcorrupt(rcvpkt)


extract (rcvpkt ,data )
deliver_data(data)
u dt_send(ACK)
<2 marks for receiver FSM>
Receiver FSM
Explanation:
Because the sender-to-receiver channel can corrupt packets, the data-sent on the sender-to-receiver channel will
need a checksum to detect bit errors.
Because the sender-to-receiver channel can lose packets, we will need to have a timer to timeout and retransmit
packets that have not been received by the receiver.
The receiver will need to indicate which packets it has received by using an ACK message; if a packet is not received
or is received corrupted, no ACK is sent.
There is no need for sequence numbers, since there will be no unneeded (and unexpected at the receiver)
retransmissions.
There is no need of NAKs, no response required by receiver for the arrival of corrupted packets. Such packets will
be retransmitted by the sender when timer expires.
Checksum is not required at receiver side because receiver to sender channel is reliable.

b) The rdt 4.0 sender sends packets of length 10 KBytes over a link of 2 Mbps. The average Round Trip Time (RTT) is equal
to 120 milli sec. Calculate the channel utilization for rdt 4.0 under no packet loss scenario.
Sol: Packet transmission time = L/R = (104 x 8)/2 x 106 = 40 milli sec
Channel Utilization = L/R/(RTT + L/R)
Page 2 of 6
= 40/(40+120) = 40/160 = 25% or 0.25 <3 marks for correct answer, no partial marks>
Q.3 Answer the following questions: [2+2+3=7M]
a) Suppose host A wants to send a file of 4,00,000 Bytes to host B. The path from host A to host B has four links, of rates
R1 = 2 Mbps, R2 = 1 Mbps, R3 = 1 Mbps, R4 = 3 Mbps. The intermediate switches do forward incoming bits as soon as they
are received, without any delay. How long will it take to transfer the file to host B? Assume no other traffic in the network.
Sol: Total time required to transfer the file = total_bits/transmission_rate
Transmission rate equals to the BW of bottleneck link (i.e. 1 Mbps)
Time = (4 x 105 x 8)/106 = 3.2 sec (2 marks for correct answer; no partial marking)
b) In general, when a router receives a packet it forwards the packet to the next hop on the path towards destination.
Explain, how does the Traceroute program forces the intermediate routers to send back a packet to the source host?
Sol: Traceroute sends packets with TTL values that gradually increase from packet to packet, starting with TTL value
of one. Routers decrement TTL values of packets by one when routing and discard packets whose TTL value has
reached zero, returning the ICMP error message “ICMP Time Exceeded”. (Note: TTL value expired and ICMP error
message is required to be mentioned for full credit. 1 Mark for each)
c) Consider a Distributed Hash Table (DHT) design approach for P2P file sharing application, in which (key, value) pairs
are randomly scattered across all the peers. Each peer maintains a list of the IP addresses of all participating peers.
Compare this DHT with circular DHT (discussed in the class) in terms of query performance and scalability.
Sol: The given DHT based approach is un-scalable because it would require each peer to know about all other peers let
say N and each query have to be send to all N peers. So per query on an average N messages are required.
In circular DHT each peer need to know about only it’s two peers (immediate successor and immediate predecessor). On
an average N/2 messages are required for each query for N peers. Circular DHT with finger table reduces per query
messages to O (log2N) with additional peer information at each peer. (With m bit ID space, m number of neighboring
peer information is kept at each peer.) <Looking for two information; How many peers information needs to be kept
at each peer? How many messages (average) are required for a query?> <1.5 for each information>
Q.4 Answer the following questions based on socket programming concepts: [3+2=5M]
a) What is the purpose of bind() system call? Describe the requirement of binding sockets with respect to client and
server for both TCP and UDP sockets.
Sol: The bind() system call binds a particular port to the socket. In other words, bind() assigns a name to the socket.
The bind() is useful in following manner:
i) Servers register their well-known address with the system. It tells the system "this is my address and any messages
received for this address are to be given to me." Both connection-oriented and connectionless servers need to do this
before accepting client requests.
ii) A client can register a specific address for itself. (Client side bind() is not mandatory for both TCP and UDP. The
operating system binds the requested socket to a random local port when the response received from the server.)
iii) A connectionless client needs to assure that the system assigns it some unique address, so that the other end (the
server) has a valid return address to send its responses to. This corresponds to making certain an envelope has a valid
return address, if we expect to get a reply from the person we sent the letter to.
< 1 mark for bind() definition, 2 for its requirement>
b) What is the correct order in which a server process must invoke the system calls accept(), bind(), listen(), and recv()
according to UNIX socket API. Which one of these is/are a blocking call(s)?
Sol: The correct order is bind(), listen(), accept(), and recv() <1 mark for correct order, no partial marks>

Page 3 of 6
For a blocking system call, the caller can't do anything until the system call returns. So based on this definition
accept() and recv() are blocking calls. <0.5 + 0.5 for accept() + recv(), no marks if your answer includes bind()>
Q.5 Assume that the client wants to retrieve the www.abc.com home page but has no information about the
www.abc.com web server IP address. All links shown in the Fig.2 have 10 Mbps capacity except link between client and
web cache server which is of capacity 100 Mbps. Assume there is no queuing delay at the routers, and the packet
processing delays at routers and nodes are all negligible. [3+3+2+2=10]
a) Describe the process of the client obtaining the IP address for the hostname www.abc.com under the assumption that
local DNS server cache is empty. Assume DNS queries are processed iteratively.

Fig.3

Fig.2
Sol: The DNS query for obtaining IP address for the host name www.abc.com will be processed as follows:
i) Client send the DNS query to local DNS server
ii) Local DNS server sends query to root server and receives “.com” TLD server information from root server
iii) Local DNS server sends DNS query to “.com” TLD server and receives information about authoritative server of
abc.com
iv) Local DNS server contacts to authoritative server of abc.com to get IP address of abc.com and receives desired IP
address.
v) Local DNS server caches it and reply back to the client.) <0.5 for each step> + 0.5 for complete answer is correct
b) The www. abc.com main page is 500 Kbits in size and refers to 8 images stored on same server. All images have a size
of 1250 Kbits. Assume that the RTT between client and server is 300 milli sec. Assuming non-persistent HTTP with no
parallel TCP connections, how long does it take to download all web objects (main page + 8 images) to the client? Do not
include the time required to obtain the IP address of the www.abc.com in your calculation.
Sol: Total 9 objects needs to be transferred using non-persistent HTTP with no parallel TCP connections. Two RTTs
required per object including connection establishment but excluding object transfer time.
Thus total time to download all objects becomes = 18 RTT + 9 objects transmission time
= 18 RTT + [(500 +1250 x 8) x 103]/10 x 106 <all links are of 10 Mbps>
= 18 x 300 + 1050 = 6450 milli sec <partial marks: 2 for 18 RTT + 1 for transmission time calculation for objects>

Page 4 of 6
c) Let us assume that www.abc.com is a very popular web site and the many client requests cannot be handled by a single
server but rather by a cluster of web servers (each having a different IP address). Describe the process that DNS offers
for load balancing.

Sol: The authoritative DNS server keeps a list of IP addresses (one corresponding to each replicated web server) for
canonical name of the web server. The DNS server sends an entire list of IP addresses in response to the DNS query but
rotates ordering within each reply. Client typically sends request to first IP in the list.

OR

Sometimes DNS server responds the query with a single IP address from the list in round robin fashion. Eventually, load
balancing is achieved at request level; i.e. number of requests (http requests) are distributed equally among multiple
replicas of web server. <both answers will be considered for full credit of 2 marks>

d) Now let us assume that 40% of the web requests that originate from the local network can be satisfied by the local
cache and 60% of the requests are satisfied at the origin (in this specific case we assume they are all satisfied by
www.abc.com). The bandwidth between client and web cache is 100 Mbps in this case. What is the total average
bandwidth with which web objects are served to clients in the local network?

Sol: The 40% requests are satisfied from local network at the rate of 100 Mbps and the remaining 60% requests are
delivered at the rate of 10 Mbps. Thus the average bandwidth will be 0.4 x 100 + 0.6 x 10 = 46 Mbps. <No partial marks
(0/2)>

Q.6 Consider the network topology shown in Fig.3 that comprises two Routers (i.e., R1 and R2) and two end hosts (i.e.,
H1 and H2). Host H1 transmits data to host H2 over a TCP-Reno connection between H1 and H2. Host H1 have abundant
amount of data to send. Assume there is no other traffic in the network. Ignore ACK packets and packet headers in your
calculation as their contribution is negligible in comparison to the payload (application data). [2+3+3=8M]
To answer (a) and (b), consider the assumption that the RTT of the connection is 240 milli sec and routers don’t have
buffers.
a) What will be the maximum possible TCP sender window size (in Bytes)?
Sol: Under the assumption of no other traffic and the absence of buffers at routers, the maximum possible TCP sender
window is equals to the “Bandwidth delay product”.
TCP Window size = (BW of bottleneck link R1-R2) x RTT of the connection
= 109 x 240 x 10-3 = 24 x 107 bits = 30 MBytes <2 marks for correct answer, no partial marks>
b) What is the average throughput of this TCP connection? Assume packet loss can occur only due to network congestion.
Ignore slow start phase in your calculation.
Sol: TCP sender window grows until it reaches to its max. possible value (i.e., W = 30 Mbytes) and thereafter packet loss
will occur. After packet loss sender will reduce its window to half of the value at which loss occurs (i.e., W/2) (assuming
loss is identified by 3 Dup ACKs or avoiding slow start phase). Now TCP sender window will increase linearly until next
packet loss does not occur or window size does not become W. Therefore, TCP sender window will oscillate between W
and W/2.
So the average window size becomes = (W + W/2) /2 = (3 x W) /4 = 90/4 = 22.5 MBytes
Thus throughput = avg. window size/RTT = 22.5 x 106/240 x 10-3 = 750 Mbits/sec < 3 marks for correct answer>
c) Now let us assume, we have added a buffer to each interface of the routers of capacity equals to the “maximum
possible TCP sender window size” (calculated in part (a)). Briefly explain the impact of large size router buffers on TCP
throughput value?

Sol: The buffer availability at routers of size equals to the 30 MBytes increases the TCP throughput as now one window
worth of bytes is buffered in the router and another window worth of bytes are in transmission. In other words, the
Page 5 of 6
reduced window size (i.e., after packet loss occurs) is equals to W (i.e., 30 MBytes). Now sender window will oscillate
between 2W and W. Thus average sender window will be 3W/2. <2 marks>

But the availability of large buffers at router introduce large queuing delay. The queuing delay also increases the average
RTT of the connection. The increase in RTT reduces the throughput gain attained due to the buffers and lowers the
application performance in-terms of end to end delay. <1 marks >

#####

Page 6 of 6

You might also like