Transmission Control Protocol
TCP/IP Protocol Suite 1
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
TCP SERVICES
•TCP provides process-to-process communication.
•TCP lies between the application layer and the
network layer, and serves as the intermediary
between the application programs and the network
operations.
TCP/IP Protocol Suite 5
Services Provided by TCP:
Process-to-process communication
- using port numbers
Stream delivery service
- delivers data as stream of bytes
Sending and receiving buffers
- uses two buffers, the sending buffer for sending
process and receiving buffer for receiving process
Segments
- unit of data is segment
- groups bytes form segment
TCP/IP Protocol Suite 7
Full duplex communication
- data can flow in both directions
Multiplexing and demultiplexing
- performs multiplexing at sender and
demultiplexing at receiver
Connection oriented service
TCP/IP Protocol Suite 8
TCP/IP protocol suite
TCP/IP Protocol Suite 9
TCP/IP Protocol Suite 10
Stream delivery
TCP/IP Protocol Suite 11
Sending and receiving buffers
Stream of bytes
TCP/IP Protocol Suite 12
TCP segments
Segment N Segment 1
H H
TCP/IP Protocol Suite 13
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.
TCP/IP Protocol Suite 14
Features of TCP
Numbering system
- no field for segment number in header
- sequence number and acknowledgement fields are used
Byte number
- TCP numbers all data bytes that are transmitted in a
connection
Sequence number
- TCP assigns a sequence number to each segment
- number of first byte of data carried in that segment
TCP/IP Protocol Suite 15
Acknowledgement number
- is the number of next byte the receiver expected
to receive.
Flow control
Error control
Congestion control
TCP/IP Protocol Suite 16
Note
The bytes of data being transferred in
each connection are numbered by TCP.
The numbering starts with an arbitrarily
generated number.
TCP/IP Protocol Suite 18
Note
The value in the sequence number
field of a segment defines the number
assigned to the first data byte
contained in that segment.
TCP/IP Protocol Suite 20
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.
TCP/IP Protocol Suite 21
SEGMENT
A packet in TCP is called a segment.
TCP/IP Protocol Suite 22
TCP segment format
TCP/IP Protocol Suite 24
Control field
TCP/IP Protocol Suite 25
Pseudoheader added to the TCP segment
TCP/IP Protocol Suite 26
Note
The use of the checksum in TCP is
mandatory.
TCP/IP Protocol Suite 27
Encapsulation
TCP
Application-layer data
header
IP
header
Frame
header
TCP payload
IP payload
Data-link layer payload
TCP/IP Protocol Suite 28
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.
TCP/IP Protocol Suite 29
Connection establishment using three-way handshake
Passive
Active open
open seq: 8000
UAPRS F
SYN
seq: 15000
Connection ack: 8001
opened nd: 5000
U A P R S F rw
SYN + ACK
seq: 8000
ack: 15001
UAPRS F
rwnd: 10000
ACK
Means “no data” !
seq: 8001 if piggybacking
TCP/IP Protocol Suite 31
A SYN segment cannot carry data, but it
consumes one sequence number.
TCP/IP Protocol Suite 32
A SYN + ACK segment cannot carry
data, but does consume one
sequence number.
TCP/IP Protocol Suite 33
An ACK segment, if carrying no data,
consumes no sequence number.
TCP/IP Protocol Suite 34
Figure 15.10 Data Transfer
seq: 8001
Send
request ack: 15001
UAPRS F
Data Receive
bytes: 8001-9
000
Send seq: 9001
request ack: 15001
UAPRS F
Data Receive
bytes: 9001-1
0000
seq: 15001 Send
ack: 10001 request
UAPRS F
Data
17000
bytes: 15001-
seq: 10000
ack: 17001
UAPRS F
rwnd:10000
Connection Termination
TCP/IP Protocol Suite 35
Figure 15.11 Connection termination using three-way handshake
TCP/IP Protocol Suite 36
Note
The FIN segment consumes one
sequence number if it does
not carry data.
TCP/IP Protocol Suite 37
Note
The FIN + ACK segment consumes one
sequence number if it does
not carry data.
TCP/IP Protocol Suite 38
Figure 15.12 Half-Close
TCP/IP Protocol Suite 39