Homework PDF

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

King Fahd University of Petroleum & Minerals

Information and Computer Science Department


ICS 343: Fundamentals of Computer Networks (Term 172)

Homework #02 [Due: MAR. 01 before midnight]

Notes and Submission Guidelines:


1. No group work is allowed and the solution has to be yours (no cheating is allowed).
2. Upload the solution to BB as a PDF file named: 172-ICS343-hw02-201707490
Answer the following questions:

P23-1 [10 points]. In the Stop-and-Wait protocol, show the case in which the receiver receives
a duplicate packet (which is also out of order). Hint: Think about a delayed ACK. What is the
reaction of the receiver to this event?

Solution:

In stop and wait protocol, there is time-out mechanism and therefore, it will not wait for depayed
ACKs. If a packet is sent and ACK not arrive, it will resend it after time-out. And also there is no
out of order delivery because both sender and receiver have the window size of 1 and it will
keep ACK-ing the sender for the packet that not arrived in order.

Sender Reciever

01010 Packet 1

ACK 0 01010
01010
Packet 0
01010

ACK 1 (Lost) 01010

Packet 0 is discarded
01010 Packet 0 resend because duplicate. It is
expecting packet 1 (see
01010 above R window). But
ACK 1 send ACK of 1.
So, the scenario of duplicate packet arises when a packet is sent and received at the receiver
side, but the ACK is lost on the way without reaching to the sender. And when time-out occurs,
the sender resent that packet. What happen here is the packet is already in the receiver side
and when the duplicate packet arrives it simply discards it. How? Please see the diagram.

P23-3 [10 points]. Assume we need to design a Selective-Repeat sliding-window protocol for a
network in which the bandwidth is 1 Gbps and the average distance between the sender and
receiver is 5,000 km. Assume the average packet size is 50,000 bits and the propagation speed
in the media is 2 x 108 m/s. Find the maximum size of the send and receive windows, the
number of bits in the sequence number field (m), and an appropriate time-out value for the
timer.

Solution:

First we need to calculate round trip time (RTT).

RTT=2 x (distance)/speed=2 x (5 x 106 ) / (2 x 108)=0.05s=50ms

Now we need to calculate, The bandwidth-delay product, which equals to

1 Gbps × 50 ms = 50,000,000 bits.

That means the link can send that amount of bits during round trip time.

But the average packet size is 50,000 bits and we need to calculate how many packets can be
sent. Therefore,

No. of packet = (5 x 107 bits ) / (5 x 104 bits) = 1000 packets.


The maximum send window size should be the number of packets it can hold, which is 1000
That means not to allow more than 1000 packets in the pipe.
The maximum receive window size should also be 1000 packets because in SR protocol both
are equal.

Therefore, window size is 1000 ≤ (2m-1).


This means we have to choose the value of m in such a way that above inequality holds in
which case the value is 11.
Therefore, the number of bits in sequence number filed is 11.
As we see from above, the RTT is 0.05s, to avoid early retransmission of the packets and to
prevent congestion; the timeout value should be at least 0.05s.

P23-6 [10 points]. In a network using the Selective-Repeat protocol with m = 4 and the sending
window of size 8, the value of variables are Sf = 62, Sn = 67, and R; = 64. Packet 65 has
already been acknowledged at the sender site; packets 65 and 66 are received out-of-order at
the receiver site. Assume that the network does not duplicate the packets.

a. What are the sequence numbers of pending data packets (in transit, corrupted, or lost)?
b. What are the acknowledgment numbers of pending ACK packets (in transit, corrupted, or
lost)?

Solution:

Sf=62, Sn=67, Rn=64

Packet 65 has already been ACKed at the sender side

Packets 65 and 66 are received out-of-order at the receiver side.

(a) Rn 64 means the receiver is expecting the packet 64, and 62 and 63 already received
and ACKed. Also packet 65 is ACKed from the receiver side. Packet 66 is received at
the receiver side but not ACKed. So, the sequence number of pending packet is 64.

(b) Sn=67 means packets before it are sent. That means packet 64 is already sent and the
receiver is expecting it with Rn=64. Also we have packet number 66 received but not
ACKed. Therefore, acknowledgment number of pending ACK packet is 64 and 66.

P24-32 [10 points]. The ssthresh value for a Taho TCP station is set to 6 MSS. The station now
is in the slow-start state with cwnd = 4 MSS. Show the values of cwnd, sstresh, and the state of
the station before and after each of following events: four consecutive nonduplicate ACKs
arrived followed by a time-out, and followed by three nonduplicate ACKs.

Solution:

TCP taho works as the following way:

In slow start state, generally, TCP sets ssthresh variable with a pre-agreed value, and sets
congestion window (cwnd) to 1. It grows exponentially. If congestion is detected, (time out or
arrival of three duplicate ACKS), it starts with another new slow start algorithm where it sets
ssthresh to half of the current cwnd and cwnd to 1. And continue till the threshold value is
reached. If there is congestion detected in reaching to ssthresh,then TCP enters into a state
called congestion avoidance where the size of congestion window is increased by 1each time
a number of ACKs equal to the current size of window has been received.

In our case here,

Initial condition

ssthresh=6MSS,

initial cwnd size=4MSS

(a) Before 4 consecutive nonduplicate ACKs arrived,

Ssthresh=6MMS, cwnd=4MSS, State of the station=slow state

(b) After 4 consecutive nonduplicate ACKs arrived followed by time-out


Here, TCP starts with cwnd=4, it should be growing exponentially,as it receives 4 non
duplicate ACKs, which means the next cwnd should be 4+4=8( because it sends widow
size of 4 and no. of ACKs for those size 4 window).

But here current cwnd > ssthresh, and also time out occur. We can have this scenario;
we can have current cwnd set to ssthresh (In this cwnd=ssthresh=6) and continue with
congestion avoidance sate increasing the cwnd additively (in this case new cwnd =7,
assuming 6 nondulicate ACKs received, and increasing additively). In this case, ssthresh
will remain 6 until time out occur or 3 duplicate ACKs arrived.

(c) Before 4 consecutive non-duplicate ACKs arrived followed by 3 non-duplicate


ACKs

The values will be same as (b), if we consider the scenario as a single connection.

(d) After 4 consecutive non-duplicate ACKs arrived followed by 3 non-duplicate ACKs

As said above, cwnd=6, ssthresh=6 (until time out occur or 3 duplicate ACKs arrived).
The TCP is in congestion avoidance state and it should follow additive increase, but to
follow that it should receive 6 ACKs to become 7MSS, but here received only 3 ACKs
are received. That means we cannot increase cwnd to 7. The next cwnd size may be {6
+ (1/6 + 1/6 +16+)}. In this situation, cwnd=6.5.

You might also like