TCP/IP Protocol Suite 1
Chapter 12
Upon completion you will be able to:
Transmission
Control Protocol
•Be able to name and understand the services offered by TCP
•Understand TCP’s flow and error control and congestion control
•Be familiar with the fields in a TCP segment
•Understand the phases in a connection-oriented connection
•Understand the TCP transition state diagram
•Be able to name and understand the timers used in TCP
•Be familiar with the TCP options
Objectives
TCP/IP Protocol Suite 2
Figure 12.1TCP/IP protocol suite
TCP/IP Protocol Suite 3
12.1 TCP SERVICES
WeexplaintheservicesofferedbyTCPtotheprocessesattheapplication
layer.
The topics discussed in this section include:
Process-to-Process Communication
Stream Delivery Service
Full-Duplex Communication
Connection-Oriented Service
Reliable Service
TCP/IP Protocol Suite 4
Table 12.1 Well-known ports used by TCP
TCP/IP Protocol Suite 6
Figure 12.2Stream delivery
TCP/IP Protocol Suite 7
Figure 12.3Sending and receiving buffers
TCP/IP Protocol Suite 8
Figure 12.4TCP segments
TCP/IP Protocol Suite 9
12.2 TCP FEATURES
Toprovidetheservicesmentionedintheprevioussection,TCPhas
severalfeaturesthatarebrieflysummarizedinthissection.
The topics discussed in this section include:
Numbering System
Flow Control
Error Control
Congestion Control
TCP/IP Protocol Suite 10
The bytes of data being transferred in
each connection are numbered by TCP.
The numbering starts with a randomly
generated number.
Note:
TCP/IP Protocol Suite 12
The value in the sequence number
field of a segment defines the number
of the first data byte contained
in that segment.
Note:
TCP/IP Protocol Suite 13
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.
Note:
TCP/IP Protocol Suite 14
12.3 SEGMENT
ApacketinTCPiscalledasegment
The topics discussed in this section include:
Format
Encapsulation
TCP/IP Protocol Suite 15
Figure 12.5TCP segment format
TCP/IP Protocol Suite 16
Figure 12.6Control field
TCP/IP Protocol Suite 17
I
Table 12.2 Description of flags in the control field
TCP/IP Protocol Suite 18
Figure 12.7Pseudoheader added to the TCP datagram
TCP/IP Protocol Suite 19
The inclusion of the checksum in TCP
is mandatory.
Note:
TCP/IP Protocol Suite 20
Figure 12.8Encapsulation and decapsulation
TCP/IP Protocol Suite 21
12.4 A TCP CONNECTION
TCPisconnection-oriented.Aconnection-orientedtransportprotocol
establishesavirtualpathbetweenthesourceanddestination.Allofthe
segmentsbelongingtoamessagearethensentoverthisvirtualpath.A
connection-orientedtransmissionrequiresthreephases:connection
establishment,datatransfer,andconnectiontermination.
The topics discussed in this section include:
Connection Establishment
Data Transfer
Connection Termination
Connection Reset
TCP/IP Protocol Suite 22
Figure 12.9Connection establishment using three-way handshaking
TCP/IP Protocol Suite 23
A SYN segment cannot carry data, but
it consumes one sequence number.
Note:
TCP/IP Protocol Suite 24
A SYN + ACK segment cannot carry
data, but does consume one
sequence number.
Note:
TCP/IP Protocol Suite 25
An ACK segment, if carrying no data,
consumes no sequence number.
Note:
TCP/IP Protocol Suite 26
Figure 12.10Data transfer
TCP/IP Protocol Suite 27
The FIN segment consumes one
sequence number if it does not carry
data.
Note:
TCP/IP Protocol Suite 28
Figure 12.11Connection termination using three-way handshaking
TCP/IP Protocol Suite 29
The FIN + ACK segment consumes
one sequence number if it does not
carry data.
Note:
TCP/IP Protocol Suite 30
Figure 12.12Half-close
TCP/IP Protocol Suite 31
12.5 STATE TRANSITION DIAGRAM
Tokeeptrackofallthedifferenteventshappeningduringconnection
establishment,connectiontermination,anddatatransfer,theTCP
softwareisimplementedasafinitestatemachine..
The topics discussed in this section include:
Scenarios
TCP/IP Protocol Suite 32
Table 12.3 States for TCP
TCP/IP Protocol Suite 33
Figure 12.13State transition diagram
TCP/IP Protocol Suite 34
Figure 12.14Common scenario
TCP/IP Protocol Suite 35
The common value for MSL is
between 30 seconds and 1 minute.
Note:
TCP/IP Protocol Suite 36
Figure 12.15Three-way handshake
TCP/IP Protocol Suite 37
Figure 12.16Simultaneous open
TCP/IP Protocol Suite 38
Figure 12.17Simultaneous close
TCP/IP Protocol Suite 39
Figure 12.18Denying a connection
TCP/IP Protocol Suite 40
Figure 12.19Aborting a connection
TCP/IP Protocol Suite 41
12.6 FLOW CONTROL
Flowcontrolregulatestheamountofdataasourcecansendbefore
receivinganacknowledgmentfromthedestination.TCPdefinesa
windowthatisimposedonthebufferofdatadeliveredfromthe
applicationprogram.
The topics discussed in this section include:
Sliding Window Protocol
Silly Window Syndrome
TCP/IP Protocol Suite 42
Figure 12.20Sliding window
TCP/IP Protocol Suite 43
A sliding window is used to make
transmission more efficient as well as
to control the flow of data so that the
destination does not become
overwhelmed with data.
TCP’s sliding windows are byte
oriented.
Note:
TCP/IP Protocol Suite 54
Howcanthereceiveravoidshrinkingthewindowinthe
previousexample?
Example9
Solution
Thereceiverneedstokeeptrackofthelastacknowledgment
numberandthelastrwnd.Ifweaddtheacknowledgment
numbertorwndwegetthebytenumberfollowingtheright
wall.Ifwewanttopreventtherightwallfrommovingtothe
left(shrinking),wemustalwayshavethefollowing
relationship.
new ack + new rwnd ≥ last ack + last rwnd
or
new rwnd ≥ (last ack + last rwnd) − new ack
TCP/IP Protocol Suite 55
To avoid shrinking the sender window,
the receiver must wait until more
space is available in its buffer.
Note:
TCP/IP Protocol Suite 56
Some points about TCP’s sliding windows:
❏The size of the window is the lesser of rwndand cwnd.
❏The source does not have to send a full window’s
worth of data.
❏The window can be opened or closed by the receiver,
but should not be shrunk.
❏The destination can send an acknowledgment at any
time as long as it does not result in a shrinking window.
❏The receiver can temporarily shut down the window;
the sender, however, can always send a segment of one
byte after the window is shut down.
Note:
TCP/IP Protocol Suite 57
12.7 ERROR CONTROL
TCPprovidesreliabilityusingerrorcontrol,whichdetectscorrupted,
lost,out-of-order,andduplicatedsegments.ErrorcontrolinTCPis
achievedthroughtheuseofthechecksum,acknowledgment,andtime-
out.
The topics discussed in this section include:
Checksum
Acknowledgment
Acknowledgment Type
Retransmission
Out-of-Order Segments
Some Scenarios
TCP/IP Protocol Suite 58
ACK segments do not consume
sequence numbers and are not
acknowledged.
Note:
TCP/IP Protocol Suite 59
In modern implementations, a
retransmission occurs if the
retransmission timer expires or three
duplicate ACK segments have arrived.
Note:
TCP/IP Protocol Suite 60
No retransmission timer is set for an
ACK segment.
Note:
TCP/IP Protocol Suite 61
Data may arrive out of order and be
temporarily stored by the receiving TCP,
but TCP guarantees that no out-of-order
segment is delivered to the process.
Note:
TCP/IP Protocol Suite 62
Figure 12.25Normal operation
TCP/IP Protocol Suite 63
Figure 12.26Lost segment
TCP/IP Protocol Suite 64
The receiver TCP delivers only
ordered data to the process.
Note:
TCP/IP Protocol Suite 65
Figure 12.27Fast retransmission
TCP/IP Protocol Suite 66
Figure 12.28Lost acknowledgment
TCP/IP Protocol Suite 67
Figure 12.29Lost acknowledgment corrected by resending a segment
TCP/IP Protocol Suite 68
Lost acknowledgments may create
deadlock if they are not properly
handled.
Note:
TCP/IP Protocol Suite 69
12.8 CONGESTION CONTROL
Congestioncontrolreferstothemechanismsandtechniquestokeepthe
loadbelowthecapacity.
The topics discussed in this section include:
Network Performance
Congestion Control Mechanisms
Congestion Control in TCP
TCP/IP Protocol Suite 70
Figure 12.30Router queues
TCP/IP Protocol Suite 71
Figure 12.31Packet delay and network load
TCP/IP Protocol Suite 72
Figure 12.32Throughput versus network load
TCP/IP Protocol Suite 73
Figure 12.33Slow start, exponential increase
TCP/IP Protocol Suite 74
In the slow start algorithm, the size of
the congestion window increases
exponentially until it reaches a
threshold.
Note:
TCP/IP Protocol Suite 75
Figure 12.34Congestion avoidance, additive increase
TCP/IP Protocol Suite 76
In the congestion avoidance algorithm
the size of the congestion window
increases additively until
congestion is detected.
Note:
TCP/IP Protocol Suite 77
Most implementations react differently to
congestion detection:
❏If detection is by time-out, a new slow start phase
starts.
❏If detection is by three ACKs, a new congestion
avoidance phase starts.
Note:
TCP/IP Protocol Suite 78
Figure 12.35TCP congestion policy summary
TCP/IP Protocol Suite 79
Figure 12.36Congestion example
TCP/IP Protocol Suite 80
12.9 TCP TIMERS
Toperformitsoperationsmoothly,mostTCPimplementationsuseat
leastfourtimers.
The topics discussed in this section include:
Retransmission Timer
Persistence Timer
Keepalive Timer
TIME-WAIT Timer
TCP/IP Protocol Suite 81
Figure 12.37TCP timers
TCP/IP Protocol Suite 82
In TCP, there can be only be one RTT
measurement in progress at any time.
Note:
TCP/IP Protocol Suite 89
12.10 OPTIONS
TheTCPheadercanhaveupto40bytesofoptionalinformation.
Optionsconveyadditionalinformationtothedestinationoralignother
options.
TCP/IP Protocol Suite 90
Figure 12.40Options
TCP/IP Protocol Suite 91
Figure 12.41End-of-option option
TCP/IP Protocol Suite 92
EOP can be used only once.
Note:
TCP/IP Protocol Suite 93
Figure 12.42No-operation option
TCP/IP Protocol Suite 94
NOP can be used more than once.
Note:
TCP/IP Protocol Suite 95
Figure 12.43Maximum-segment-size option
TCP/IP Protocol Suite 96
The value of MSS is determined
during connection establishment and
does not change during the
connection.
Note:
TCP/IP Protocol Suite 97
Figure 12.44Window-scale-factor option
TCP/IP Protocol Suite 98
The value of the window scale factor
can be determined only during
connection establishment; it does not
change during the connection.
Note:
TCP/IP Protocol Suite 99
Figure 12.45Timestamp option
TCP/IP Protocol Suite 100
One application of the timestamp
option is the calculation of round trip
time (RTT).
Note:
TCP/IP Protocol Suite 113
12.11 TCP PACKAGE
Wepresentasimplified,bare-bonesTCPpackagetosimulatetheheartof
TCP.Thepackageinvolvestablescalledtransmissioncontrolblocks,a
setoftimers,andthreesoftwaremodules.
The topics discussed in this section include:
Transmission Control Blocks (TCBs)
Timers
Main Module
Input Processing Module
Output Processing Module