Title: Reliability and Congestion Control in TCP
1Reliability and Congestion Control in TCP
- Recall TCP/IP (TCP over the Internet Protocol)
and UDP/IP. - The Internet Protocol is a packet delivery system
with the following characteristics - Unreliable
- Data delivery not guaranteed.
- Packet can be lost, duplicated, delayed, or
delivered out of order. - Does not inform sender or receiver of any
delivery problems.
2IP Data Transfer Mechanism
- Connectionless
- Each packet treated independently from all others
(even between same machines). - A sequence of packets between the same two
machines may take different routes, and some may
arrive while others do not. - Best-Effort Service
- Will try to deliver packets.
- Fails primarily due to insufficient resources or
network failure.
3So What Does IP Provide?
- Provides routing function.
- Determines path over which data will be sent.
- Each IP packet consists of two parts
- Header Contains information related to the
protocol such as the IP address of sender and
receiver. - Data Payload. Information being exchanged.
- Each host has routing table.
- Consists of IP address (well, actually network
prefix) and next hop. - Destination IP address looked up in table. Packet
sent out to next host in path.
4IP Routing
- Each host in path from sender to receiver simply
determines the next hop the packet will take. - Example routing table for some host on Internet
directly connected to networks 221.0.0.0,
201.0.0.0, 122.0.0.0.
To reach host on network
Send to network
247.0.0.0 221.0.0.0 242.0.0.0 201.0.0.0 221.0.0.
0 122.0.0.0
All packets received heading for network
247.0.0.0 send to network 221.0.0.0 (which will
determine next hop for packet).
5TCP/IP
- TCP uses IP delivery and routing services.
- Builds reliability on top of IP services.
- Recall TCP guarantees
- All packets delivered in same order sent.
- No duplicate data.
- All sent data will eventually arrive (barring
catastrophic network failure). - How reliability provided?
6Basic Approach Positive Acknowledgements with
Retransmissions
- Sender keeps record of each packet sent.
- Sets timer when packet sent.
- Waits for acknowledgement before sending next
packet. - Retransmits packet if acknowledgement does not
arrive before timer expires.
7Timing Diagram
Receive Packet 2 Send Ack 2
8Timing Diagram
Sender
Receiver
Network
Packet Lost
Send Packet 1 Start Timer
Packet Should Arrive and Ack Sent
Ack should arrive. Timer Expires
Retransmit Packet 1 Start Timer
Receive Packet 1 Send Ack 1
9Duplicates
- Each packet has sequence number
- Receiving TCP remembers sequence numbers.
- Discards duplicates.
- Includes Sequence number in acknowledgements.
10Sliding Windows
- Simple scheme (send one packet, wait for
acknowledgement, send next ..) is very
inefficient. - Wastes significant bandwidth while waiting.
- Would like to send out more packets before having
to block and wait for response. - Developed idea of sliding window, where all
packets within window can be unacknowledged. - As acknowledgements come in, window is adjusted.
11Sliding Window
120 1 2 3 4 5 6
7
13Sliding Transmission Window in TCP
- TCP uses a sliding window mechanism to control
transmission. - Increases efficiency
- Send all packets within window without waiting
for an acknowledgement. - As acknowledgments for segments come in, the
window is moved. - Example Consider a transmission window size of
five (next slide).
14TCP Retains Three Pointers
0 1 2 3 4 5 6
7
A B C
15Every packet to the left of A has been sent and
acknowledged. Every packet between A and B has
been transmitted. Packets between B and C are
eligible to send but have not yet been
sent. Packets to the right of C are not eligible
for transmission. All packets between A and C
are sent without waiting for an acknowledgement.
16Moving the Transmission Window
- Assume packets 0 2 and 5 have been
acknowledged. - Slide window to first unacknowledged packet (3 in
this example). - Note TCP sets a separate timer for each
outstanding packet in window.
17TCP and Sliding Window
0 1 2 3 4 5 6
7
A B C
18Flow Control
- Do not want to overwhelm capabilities of the
receiver. - Transmission window size is variable and set by
receiver. - Changed in response to buffer availability.
- Do not want to overwhelm the network.
- Accomplished by limiting number of outstanding
(unacknowledged) packets to the size of the
window. - In terms of performance the larger the window the
better. - More efficient to keep the network busy while
waiting for acknowledgements.
19Network Congestion
- The routers along a network path have finite
capacity. - Limit on their ability to deal with network
packets. - If routers get more data than they can handle
will start queuing packets. - When buffer space is exhausted will start
discarding packets. - Condition termed congestion.
- Results in long delays in transferring data.
20TCP and Congestion
- Recall TCP uses a timer to determine when to
retransmit a packet. - If network is congested then packets and
acknowledgements will be lost. - This will trigger more retransmissions.
- Retransmissions will add to network congestion,
resulting in more packet and acknowledgement
loss, resulting - Condition called congestion collapse.
21Avoiding Congestion Collapse
- TCP defines two mechanisms to avoid congestion
collapse - Slow start.
- Multiplicative Decrease.
- Multiplicative Decrease
- TCP maintains a second limit on the size of the
transmission window called congestion window
limit. - The number of packets placed onto the network is
determined by the minimum of the transmission
window and congestion window. - Congestion window is reduced by 50 for each lost
packet.
22First Loss
0 1 2 3 4 5 6
7
Transmission and Congestion Window
New Congestion Window
23Second Loss
0 1 2 3 4 5 6
7
New Congestion Window
Old Congestion Window
Transmission Window
24Time Between Retransmissions
- In addition to aggressively reducing window size
also modifies the amount of before the next
retransmission. - If one packet lost, TCP doubles the time between
retransmissions. - Quite easily reduce window to one packet, and
wait a long time between retransmissions.
25Slow Start
- TCP does not immediately double the size of the
congestion window when packets start flowing
again. - Increases the congestion window by one packet per
acknowledgement. - Assume congestion window is one.
- Send out packet and wait for acknowledgement.
- When received, increase congestion window to two
and send next two packets. - When both acknowledgements are received increase
congestion window to four. - When four are received, increase to eight.