0% found this document useful (0 votes)
31 views41 pages

Publication 6 17130 1425

The document discusses TCP (Transmission Control Protocol), including its features like process-to-process communication, stream delivery service, connection-oriented service, and reliable service. It describes TCP segments, the three-way handshake for connection establishment and termination, and windows and flow control in TCP.

Uploaded by

jj8183636
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views41 pages

Publication 6 17130 1425

The document discusses TCP (Transmission Control Protocol), including its features like process-to-process communication, stream delivery service, connection-oriented service, and reliable service. It describes TCP segments, the three-way handshake for connection establishment and termination, and windows and flow control in TCP.

Uploaded by

jj8183636
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Transmission Control Protocol

(TCP)

1
Topics Discussed in the Section
 Process-to-Process Communication
 Stream Delivery Service
 Full-Duplex Communication
 Multiplexing and Demultiplexing
 Connection-Oriented Service
 Reliable Service

2
TCP/IP protocol suite

3
Well-Known Ports used by TCP

4
Stream delivery

5
Sending and receiving buffers

Stream of bytes

6
Figure 15.4 TCP segments

Segment N Segment 1
H H

TCP/IP Protocol Suite 7


Topics Discussed in the Section (TCP Features)
 Numbering System
 Flow Control
 Error Control
 Congestion Control

8
Note

The bytes of data being transferred in


each connection are numbered by TCP.

The numbering starts with an arbitrarily


generated number.

9
Example
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:

10
Note

The value in the sequence number


field of a segment defines the number
assigned to the first data byte
contained in that segment.

11
Note

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 12


SEGMENT

Before discussing TCP in more detail, let us discuss


the TCP packets themselves. A packet in TCP is
called a segment.

13
Topics Discussed in the Section
 Format
 Encapsulation

14
TCP segment format

15
Control field

16
Pseudoheader added to the TCP segment

17
Note

The use of the checksum in TCP is


mandatory.

18
Encapsulation

TCP Application-layer data


header

IP
header

Frame
header

TCP payload
IP payload
Data-link layer payload

19
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.
20
Topics Discussed in the Section
 Connection Establishment
 Data Transfer
 Connection Termination
 Connection Reset

21
Connection establishment using three-way handshake

seq: 8000

UAPRS F
SYN
seq: 15000
ack: 8001
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
22
Note

A SYN segment cannot carry data, but it


consumes one sequence number.

23
Note

A SYN + ACK segment cannot carry


data, but does consume one
sequence number.

24
Note

An ACK segment, if carrying no data,


consumes no sequence number.

25
Data Transfer

Connection Termination

26
Connection termination using three-way handshake

27
Note

The FIN segment consumes one


sequence number if it does
not carry data.

28
Note

The FIN + ACK segment consumes one


sequence number if it does
not carry data.

TCP/IP Protocol Suite 29


Half-Close

30
STATE TRANSITION DIAGRAM

To keep track of all the different events happening


during connection establishment, connection
termination, and data transfer, TCP is specified as
the finite state machine.

31
State transition diagram

32
Note

The state marked as ESTBLISHED


in the FSM is in fact two different
sets of states that the client
and server undergo to transfer data.

33
States for TCP

34
WINDOWS IN TCP
Before discussing data transfer in TCP and the issues
such as flow, error, and congestion control, we
describe the windows used in TCP. TCP uses two
windows (send window and receive window) for each
direction of data transfer, which means four windows
for a bidirectional communication. To make the
discussion simple, we make an assumption that
communication is only unidirectional; the bidirectional
communication can be inferred using two
unidirectional communications with piggybacking.

35
Topics Discussed in the Section
 Send Window
 Receive Window

36
Send window in TCP

37
Receive window in TCP

38
FLOW CONTROL

As discussed in Chapter 13, flow control balances


the rate a producer creates data with the rate a
consumer can use the data. TCP separates flow
control from error control. In this section we discuss
flow control, ignoring error control. We temporarily
assume that the logical channel between the sending
and receiving TCP is error-free. Figure 15.24 shows
unidirectional data transfer between a sender and a
receiver; bidirectional data transfer can be deduced
from unidirectional one as.

39
Flow control

Messages Flow control


are pushed
1 5 3 Messages
feedback are pulled

2
Segements are pushed
4
Flow control feedback

40
ERROR CONTROL

TCP is a reliable transport layer protocol. This


means that an application program that delivers a
stream of data to TCP relies on TCP to deliver the
entire stream to the application program on the
other end in order, without error, and without any
part lost or duplicated.
Error control in TCP is achieved through the
use of three tools: checksum, acknowledgment,
and time-out.

41

You might also like