: /161391/
TCP . ) (2
> <arezoo.rajabi.sharif@gmail.com .
:
5 .
)
( . .
.
.
EX3-STUDENTID .
http://ce.sharif.edu/courses/91-92/1/ce443-1/index.php
Laboratory 3
TCP simulation
Objective
The purpose of this lab is to demonstrate the functioning of TCP, and particularly the four
algorithms used for congestion control: slow start, congestion avoidance, fast retransmit
and fast recovery. The lab provides a number of scenarios to simulate and compare these
algorithms.
Terms
Congestion control
Slow start
Congestion avoidance
Fast recovery
Connection handshake
Fast retransmit
Flow Control
Overview
In this lab we will study TCPs four intertwined congestion control algorithms, namely:
slow start, congestion avoidance, fast retransmit and fast recovery.
The objectives are:
To study the behavior and implementation of slow start and congestion avoidance
algorithms.
To study modifications to the congestion avoidance algorithm, namely fast
retransmit and fast recovery.
Procedure
Slow start and congestion avoidance
Previous versions of TCP start a connection with the sender injecting multiple segments
into the network, up to the windows size advertised by the receiver. This is ok when the
hosts are placed on the same LAN. But if there are routers and slower links between the
sender and the receiver different problems can arise. Some intermediate router must
queue the packets and it is possible for the router to run out of space in the queue. The
algorithm to avoid this is called slow start.
Beginning transmission into a network with unknown conditions requires TCP to slowly
probe the network to determine the available capacity, in order to avoid congesting the
network with an inappropriate large burst of data.
Slow start adds another window to the senders TCP: the congestion window, called
cwnd. When a new connection is established with a host on another network, the
congestion window is initialized to one segment (typically 536 bytes or 512 bytes). The
sender starts by transmitting one segment and waiting for its ACK. When that ACK is
received, the congestion window is increased from one to two, and two segments can be
sent. When each of those two segments is acknowledged, the congestion window is
increased to four. This provides an exponential growth, although it is not exactly
exponential because the receiver may delay its ACKs, typically sending one ACK every
two segments that it receives. The sender can transmit up to the minimum of the
congestion window and the advertised window.
At some point the capacity of the internet can be reached and an intermediate router will
start discarding packets. This tells the sender that its congestion window has gotten too
large.
Congestion avoidance is a way to deal with lost packets. Congestion can occur when data
arrives on a big pipe (a fast LAN) and outputs on a smaller pipe (a slower WAN).
Congestion can also occur when multiple input streams arrive at a router whose output
capacity is less than the sum of the inputs. There are two indications of packet loss at a
sender: a timeout occurring and the receipt of duplicate ACKs. However, the overall
assumption of the algorithm is that packet loss caused by damage is very small (much
less than 1%), therefore the loss of a packet signals congestion somewhere in the network
between the source and destination.
Although congestion avoidance and slow start are independent algorithms with different
objectives, in practice they are implemented together. When congestion occurs TCP must
slow down its transmission rate of packets into the network, and then invokes slow start
to get things going again. [3]
The combined congestion avoidance and slow start algorithms require that two variables
are maintained for each connection:
A congestion window (cwnd).
A slow start threshold size (ssthresh)
The combined algorithm operates as follows:
a) Initialization for a given connection sets cwnd to one segment and sstresh to 65535
bytes.
The initial value of cwnd must be less than or equal to 2*SMSS bytes and must not be
more than 2 segments. SMSS, Sender Maximum Segment Size, is the size of the largest
segment that the sender can transmit.
The initial value of cwnd may be arbitrarily high (some implementations use the size of
the advertised window), but it may be reduced in response to congestion.
b) The TCP output routine never sends more than the minimum of cwnd and receivers
advertised window.
c) When congestion occurs one-half of the current window size is saved in ssthresh.
Additionally, if the congestion is indicated by a timeout, cwnd is set to one segment.
Congestion is indicated by a timeout or the reception of duplicate ACKs.
d) When new data is acknowledged by the other end, increase cwnd. The way in which
cwnd is increased depends on whether TCP is performing slow start or congestion
avoidance. If cwnd is less than or equal to ssthresh, TCP is in slow start, otherwise TCP
is performing congestion avoidance. Slow start continues until TCP is halfway to where it
was when congestion occurred, and then congestion avoidance takes over. This is done
due to the recorded half of the window size that caused the problem.
As mentioned earlier slow start increases congestion window (cwnd) exponentially.
Congestion avoidance on the other hand dictates that congestion window (cwnd) be
incremented by segsize * segsize / cwnd each time an ACK is received, where segsize is
the segment size and cwnd is maintained in bytes. This results in a linear growth of
cwnd, compared to slow starts exponential growth. The increase in cwnd should be at
most one segment each round-trip time (regardless how many ACKs are received in
that RTT) whereas slow start increments cwnd by the number of ACKs received in a
round-trip time. [2]
Value
100%
constant (3600)
constant (9000000)
FTP Server
Best Effort (0)
None
Not Used
Choose Statistics
79) Enter the Paris Subnet.
80) Right click on Server_Paris and select Choose Indivitual Statistics from
the pop-up menu.
81) Expand Node Statistics TCP Connection and select Congestion
Windows Size (bytes)
82) Right click on the Congestion Window Size (bytes) and select Change
Collection mode.
83) Check the Advanced checkbox in the pop-up dialog.
84) Change Capture mode to all values.
85) Click OK to close the dialog.
Fast retransmit
Fast retransmit is a modification to the congestion avoidance algorithm.
The TCP sender should use fast retransmit algorithm to detect and repair loss, based on
incoming duplicate ACKs. The fast retransmit algorithm uses the arrival of 3 duplicate
ACKs (4 identical ACKs without the arrival of any other intervening packets) as an
indication that a segment has been lost. After receiving 3 duplicate ACKs, TCP
performs a retransmission of what appears to be the missing segment, without waiting for
the retransmission timer to expire. The fast retransmit algorithm first appeared in the
4.3BSD Tahoe release.
Fast recovery
Congestion avoidance without slow start is performed after fast retransmit sends what
appears to be the missing segment. It is an improvement that allows high throughput
under moderate congestion, especially for large windows.
In this case the reason for not performing slow start is that the receipt of duplicate
ACKs tells TCP that more than just one packet has been lost. Since the receiver can
only generate the duplicate ACK when another segment is received, that segment has left
the network and is in the receivers buffer. In other words there is still data flowing
between the two ends, and TCP does not want to reduce the flow abruptly by going into
slow start. The fast recovery algorithm appeared in the 4.3BSD Reno release.
The fast retransmit and fast recovery algorithms are usually implemented together as
follows:
a) When the third duplicate ACK is received, set ssthresh to no more than one-half the
current congestion window, cwnd, but no less than two segments. Retransmit the missing
segment, and then set cwnd to ssthresh plus 3 times the segment size. This increases the
congestion window by the number of segments that have left the network and which the
other end has cached.
b) Each time another duplicate ACK arrives, increment cwnd by the segment size. This
inflates the congestion window for the additional segment that has left the network.
c) Transmit a segment (packet) if allowed by the new value of cwnd and the receivers
advertised window.
d) When the next ACK arrives that acknowledges new data, set cwnd to ssthresh. This
ACK should be the acknowledgment of the retransmission from step a, one round-trip
time after the retransmission. Additionally, this ACK should acknowledge all the
intermediate segments sent between the lost packet and the receipt of the first duplicate
ACK. This step is congestion avoidance, since TCP is down to one-half the rate it was at
when the packet was lost.
View results
117) Right click on the workspace and choose Compare Results.
118) Expand Object statistics Choose From Maps Network Paris
Server Paris TCP Connection.
119) Check Congestion Window size (bytes).
120) Select Statistics Stacked in the bottom left roll-down menu.
The first graph illustrates the NoDrop scenario which has no packet loss.
The second graph illustrates the Tahoe scenario which has 0.5% packet loss. When
congestion is indicated by a timeout, cwnd is set to one segment. In other words, slow
start is performed.
The third graph illustrates the Reno scenario which also has 0.5% packet loss. The
congestion window size does not drop to zero as in the Tahoe graph. Fast recovery is
performed instead of slow start.
The lab is complete!