National University of Computer & Emerging Sciences, Karachi
FAST School of Computing
Midterm 2 Examination, Spring 2021 - - Solution
23rd April 2021, 09:45 am – 10:45 am
Course Code: CS-307 Course Name: Computer Networks
Instructor Names: Dr. Sufian Hameed, Dr. Nadeem Kafi, Dr. Hassan Jamil, Dr. Aqsa
Aslam, Mr. Shoaib Raza, Mr. Abdullah Zarshaid
Student Roll No: Section No:
Instructions:
Return the question paper.
All questions must be answered in answer script and according to the sequence given in the question
paper.
Each question carry 10 marks.
In case of any ambiguity, you may make an assumption, however, your assumption should not contradict
any statement in the question paper.
_______________________________________________________________________________________
Time: 60 minutes. Max Marks: 50
Question 1: Design a reliable data transfer protocol between the sender and receiver, operating over a
channel that can lose or corrupt packets (data or ACKs) and is error-prone. Specify the protocol using finite
state machine for the sender side.
Solution:
Question 2: For a p2p file-sharing application, do you agree with the statement, "There is no notion of client
and server sides of a communication session"? Why or why not?
Solution:
No. All communication sessions have a client side and a server side. In a P2P file-sharing application, the peer
that is receiving a file is typically the client and the peer that is sending the file is typically the server.
1 OF 4
Question 3: Draw a time-sequence diagram for the Go-Back-N algorithm with the sender's window size equal
to 4. Assume at t=0, the sender sends packets 0, 1, 2, 3 and packet 2 will be lost.
Solution:
Question 4: Consider a group of routers in the core network as shown in the figure. 1 below.
Figure. 1
a) Show in steps, how data packets entering one interface of a router are forwarded to an output
interface of the same router.
Solution:
Step 1: IP address is extracted from the IP packet header.
Step 2: IP prefix matched with forwarding table and corresponding output interface is read.
Step 3: The IP packets is sent to the output interface queue for further processing.
b) How routing helps forwarding? Explain.
Solution:
The data packets using forwarding tables to traverse down the shortest paths which are calculated
by routing algorithms.
2 OF 4
Question 5: Consider the figure. 2, which plots the evolution of TCP's congestion window at the beginning of
each time unit (where the unit of time is equal to the RTT). In the abstract model for this problem, TCP sends
a "flight" of packets of size cwnd at the beginning of each time unit. The result of sending that flight of
packets is that either (i) all packets are ACKed at the end of the time unit, (ii) there is a timeout for the first
packet, or (iii) there is a triple duplicate ACK for the first packet. In this problem, you are asked to reconstruct
the sequence of events (ACKs, losses) that results in the evolution of TCP's cwnd shown below.
Figure. 2
Congestion Avoidence
Fast Recovery
Timeout
slow start
slow starts Timeout
(a) Give the time unit(s) (in RTT) at which TCP is in slow start.
Solution:
The times where TCP is in slow start are: 1,2,3,13,14,15,24,25,26,28,29,31,35,40.
(b) Give the time unit(s) (in RTT) at which TCP is in congestion avoidance.
Solution:
The times where TCP is in congestion avoidance are:
4,5,6,7,8,9,10,11,12,16,17,19,20,21,22,23,27,30,32,33,34,36,37,38,39
(c) Give the time unit(s) (in RTT) at which TCP is in fast recovery.
Solution:
The times where TCP is in fast recovery are: 18.
(d) Give the time unit(s) (in RTT) at which packets are lost via timeout.
Solution:
The times where TCP has a loss by timeout are: 12,23,27,30,34,39.
(e) Give the time unit(s) (in RTT) at which packets are lost via triple ACK.
Solution:
The times where TCP has a loss by triple duplicate ACK are: 17
(f) Give the time unit(s) (in RTT) at which the value of ssthresh changes (hint: if it changes between t=3 and
t=4, use t=4 in your answer)
Solution:
The times where the ssthresh changes are: 18,24,28,31,40.
3 OF 4
The complete solution is shown in the figure below:
• For intervals of time when TCP is in slow start, the plotted value of cwnd is shown as a green square
• For intervals of time when TCP is in congestion avoidance, the plotted value of cwnd is shown as a yellow
square
• For intervals of time when TCP is in fast recovery, the plotted value of cwnd is shown as an orange square
•The values for ssthresh are shown following a change as a red plus sign
• A flight of packets experiencing a loss has the loss type (which determines the next value of cwnd) labeled
above
BEST OF LUCK!
4 OF 4