2. TCP/IP Protocol Suite
TCP SERVICES
The relationship of TCP to the other protocols in the TCP/IP
protocol suite. TCP lies between the application layer and the
network layer, and serves as the intermediary between the
application programs and the network operations.
Process-to-Process Communication
Stream Delivery Service
Full-Duplex Communication
Multiplexing and Demultiplexing
Connection-Oriented Service
Reliable Service
5. TCP/IP Protocol Suite
TCP FEATURES
To provide the services mentioned in the previous
section, TCP has several features that are briefly
summarized in this section and discussed later in
detail.
Numbering System
Flow Control
Error Control
Congestion Control
6. TCP/IP Protocol Suite
The bytes of data being transferred in each
connection are numbered by TCP.
The numbering starts with an arbitrarily
generated number.
7. TCP/IP Protocol Suite
Suppose a TCP connection is transferring a file of 5,000 bytes.
The first byte is numbered 10,001. What are the sequence
numbers for each segment if data are sent in five segments,
each carrying 1,000 bytes?
Solution
The following shows the sequence number for each segment:
8. TCP/IP Protocol Suite
The value in the sequence number
field of a segment defines the number
assigned to the first data byte
contained in that segment.
9. TCP/IP Protocol Suite
The value of the acknowledgment field in a
segment defines the number of the next
byte a party expects to receive.
The acknowledgment number is
cumulative.
10. TCP/IP Protocol Suite
SEGMENT
Before discussing TCP in more detail, let us discuss
the TCP packets themselves. A packet in TCP is
called a segment.
Format
Encapsulation
15. TCP/IP Protocol Suite
A TCP CONNECTION
TCP is connection-oriented. It establishes a virtual path between the
source and destination. All of the segments belonging to a message are
then sent over this virtual path. You may wonder how TCP, which uses the
services of IP, a connectionless protocol, can be connection-oriented. The
point is that a TCP connection is virtual, not physical. TCP operates at a
higher level. TCP uses the services of IP to deliver individual segments to
the receiver, but it controls the connection itself. If a segment is lost or
corrupted, it is retransmitted.
Connection Establishment
Data Transfer
Connection Termination
Connection Reset
16. TCP/IP Protocol Suite
Figure Connection establishment using three-way handshake
SYN
U A P R S F
seq: 8000
SYN + ACK
U A P R S F
seq: 15000
ack: 8001
rwnd: 5000
ACK
U A P R S F
seq: 8000
ack: 15001
rwnd: 10000
17. TCP/IP Protocol Suite
A SYN segment cannot carry data, but it
consumes one sequence number.
A SYN + ACK segment cannot carry data,
but does consume one
sequence number.
An ACK segment, if carrying no data,
consumes no sequence number.
22. TCP/IP Protocol Suite
The FIN + ACK segment consumes one
sequence number if it does
not carry data.
Note
23. Computer Networks: TCP Congestion Control
Original Algorithm
•Keep a running average of RTT and compute TimeOut as a function of
this RTT.
•Send packet and keep timestamp ts .
•When ACK arrives, record timestamp ta .
SampleRTT = ta - ts
Compute a weighted average:
R TT = α x EstimatedRTT + (1- α) x SampleRTT
Original TCP spec: α in range (0.8,0.9)
TimeOut = 2 x RTT
24. Computer Networks: TCP Congestion Control
Karn/Partidge Algorithm
An obvious flaw in the original algorithm:
Whenever there is a retransmission it is impossible to know whether to
associate the ACK with the original packet or the retransmitted packet.
Sender Receiver
Original transmission
ACK
Retransmission
Sender Receiver
Original transmission
ACK
Retransmission
(a) (b)
25. Computer Networks: TCP Congestion Control
Karn/Partidge Algorithm
1.Do not measure SampleRTT when sending packet more than once.
2.For each retransmission, set TimeOut to double the last TimeOut.
{ Note – this is a form of exponential backoff based on the believe that
the lost packet is due to congestion.}
26. Computer Networks: TCP Congestion Control
Jacobnson/Karels Algorithm
The problem with the original algorithm is that it did not take into account
the variance of SampleRTT.
TimeOut = µ x EstimatedRTT+ Φ x Deviation
where based on experience µ = 1 and Φ = 4. so,
Timeout = Estimated RTT + 4 * Deviation
27. Deviation = (1 -α) * DeviationRTT + α* |SampleRTT -
Estimated RTT|
where α = 0.25
Deviation is an estimate how much SampleRTT typically deviates
from Estimated RTT.
If there is little fluctuation in SampleRTT then Deviation is small and
Timeout is only a little more than Estimated RTT.
If there is lot of fluctuation, the TimeOut will be much larger than
SampleRTT
28. Evolution of TCP
1975 1980 1985 1990
1982
TCP & IP
RFC 793 & 791
1974
TCP described by
Vint Cerf and Bob Kahn
In IEEE Trans Comm
1983
BSD Unix 4.2
supports TCP/IP
1984
Nagel’s algorithm
to reduce overhead
of small packets;
predicts congestion
collapse
1987
Karn’s algorithm
to better estimate
round-trip time
1986
Congestion collapse
observed
1988
Van Jacobson’s algorithms
congestion avoidance and
congestion control
(most implemented in
4.3BSD Tahoe)
1990
4.3BSD Reno
fast retransmit
delayed ACK’s
1975
Three-way handshake
Raymond Tomlinson
In SIGCOMM 75
29. TCP Through the 1990s
1993 1994 1996
1994
ECN
(Floyd)
Explicit
Congestion
Notification
1993
TCP Vegas
(Brakmo et al)
real congestion
avoidance
1994
T/TCP
(Braden)
Transaction
TCP
1996
SACK TCP
(Floyd et al)
Selective
Acknowledgement
1996
THoe
Improving TCP
startup
1996
FACK TCP
(Mathis et al)
extension to SACK
31. Why are the new flavours better?
• Efficiency!
• When TCP Tahoe and Reno were created, we did not know as much about the
internet as we do now. New technology has been created that better suit the
model of how the internet actually works.
• Specialization
• Not all machines connect to the internet under the same circumstances. Some of
the new TCP flavours provide enhanced performance when dealing with networks
that are not the usual type.
• Integrability
• TCP New Reno, Vegas and Hybla can all play nice when connecting to networks
currently running TCP Reno.
32. TCP congestion-avoidance algorithm
TCP Tahoe and Reno
TCP New Reno
TCP Vegas
TCP Hybla
TCP BIC, Binary Increase Congestion control, Linux
TCP CUBIC, Linux and Windows
TCP Compound TCP,(2003)
TCP Fast TCP,
TCP H-TCP,
TCP Westwood+ (1999),Linux
Compound TCP(2014),Linux
TCP Proportional Rate Reduction,Linux
TCP BBR (2016), Google,Linux
34. •Congestion control algorithm. A modification to the algorithm for
increasing TCP's congestion window (cwnd) that improves both
performance and security.
•Rather than increasing a TCP's congestion window based on the number of
acknowledgments (ACKs) that arrive at the data sender, the congestion
window is increased based on the number of bytes acknowledged by the
arriving ACKs.
•The algorithm improves performance by mitigating (justifying) the impact
of delayed ACKs on the growth of cwnd.
35. •At the same time, the algorithm provides cwnd growth in direct relation to
the probed capacity of a network path, therefore providing a more measured
response to ACKs that cover only small amounts of data (less than a full
segment size) than ACK counting.
•This more appropriate cwnd growth can improve both performance and can
prevent inappropriate cwnd growth in response to a misbehaving receiver.
•On the other hand, in some cases the modified cwnd growth algorithm
causes larger bursts of segments to be sent into the network. In some cases
this can lead to a non-negligible increase in the drop rate and reduced
performance
36. Four Components in TCP Congestion Control
1. Slow Start Technique
2. AIMD Technique
3. Fast Retransmit
4. Fast Recovery
37. Congestion policy in TCP –
Slow Start Phase: starts slowly increment is exponential to
threshold (exponential increment)
Congestion Avoidance Phase: After reaching the threshold
increment is by 1 (additive increment)
Congestion Detection Phase: Sender goes back to Slow
start phase or Congestion avoidance phase. (multiplicative
decrement)
38. Slow Start Phase : exponential increment – In this phase after
every RTT the congestion window size increments
exponentially.
Congestion Avoidance Phase : additive increment – This
phase starts after the threshold value also denoted as ssthresh.
The size of cwnd(congestion window) increases additive.
After each RTT cwnd = cwnd + 1.
39. Congestion Detection Phase : multiplicative decrement
If congestion occurs, the congestion window size is
decreased. The only way a sender can guess that
congestion has occurred is the need to retransmit a
segment.
Retransmission is needed to recover a missing packet
which is assumed to have been dropped by a router due
to congestion. Retransmission can occur in one of two
cases: when the RTO timer times out or when three
duplicate ACKs are received.
40. Computer Networks: TCP Congestion Control
Slow Start
•TCP uses a mechanism called slow start to increase the
congestion window after a connection is initialized or
after a timeout. It starts with a window of two times
the maximum segment size (MSS)
•However, in the second case the source has more
information. The current value of cwnd can be saved as a
congestion threshold.
•This is also known as the “slow start threshold” ssthresh.
In the slow start algorithm, the size of the
congestion window increases exponentially
until it reaches a threshold.
42. TCP/IP Protocol Suite
In the congestion avoidance algorithm the
size of the congestion window
increases additively until
congestion is detected.
On timeout:
1. Congestion window is reset to 1 MSS.
2. "ssthresh" is set to half the congestion
window size before segment loss started.
3. "slow start" is initiated.
43. Case 1 : Retransmission due to Timeout – In this case congestion
possibility is high.
(a) ssthresh is reduced to half of the current window size.
(b) set cwnd = 1
(c) start with slow start phase again.
Case 2 : Retransmission due to 3 Acknowledgement Duplicates
– In this case congestion possibility is less.
(a) ssthresh value reduces to half of the current window size.
(b) set cwnd= ssthresh
(c) start with congestion avoidance phase
45. Computer Networks: TCP Congestion Control
Fast Retransmit TCP Tahoe
•Coarse timeouts remained a problem, and Fast retransmit was added with
TCP Tahoe.
•Since the receiver responds every time a packet arrives, this implies the
sender will see duplicate ACKs.
Basic Idea:: use duplicate ACKs to signal lost packet.
Fast Retransmit
Upon receipt of three duplicate ACKs,
the TCP Sender retransmits the lost packet.
46. Computer Networks: TCP Congestion Control
Fast Retransmit
Packet 1
Packet 2
Packet 3
Packet 4
Packet 5
Packet 6
Retransmit
packet 3
ACK 1
ACK 2
ACK 2
ACK 2
ACK 6
ACK 2
Sender Receiver
Fast Retransmit
Based on three
duplicate ACKs
47. Computer Networks: TCP Congestion Control
Fast Retransmit Advantages
•Generally, fast retransmit eliminates about half the coarse-grain
timeouts.
•This yields roughly a 20% improvement in throughput.
•Note – fast retransmit does not eliminate all the timeouts due
to small window sizes at the source.
48. Computer Networks: TCP Congestion Control
Fast Recovery TCP Reno
•Fast recovery was added with TCP Reno.
•Basic idea:: When fast retransmit detects three duplicate ACKs,
start the recovery process from congestion avoidance region and
use ACKs in the pipe to pace the sending of packets.
Fast Recovery
After Fast Retransmit, half cwnd and commence recovery from this point using
linear additive increase ‘primed’ by left over ACKs in pipe.