Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 36

TCP/IP

Transmission Control Protocol / Internet Protocol


IP Datagram Format

2 07/11/24
 20 bytes ≤ Header Size < = 60 bytes
 20 bytes ≤ Total Length < 216 65536 bytes

3 07/11/24
The Transmission Control Protocol
(TCP)

Application Services (Telnet,


FTP, e-mail, WWW)

Reliable Stream Unreliable Transport


Service (UDP)
Transport (TCP)

Connectionless Packet Delivery Service


(IP)
TCP
Transmission Control Protocol
TCP is an transport layer protocol over IP.
TCP provides:
Connection-oriented
Reliable
Full-duplex
Byte-Stream
Buffering
TCP is responsible for buffering data and determining when
it is time to send a datagram.

TCP Ports
Interprocess communication via TCP is achieved with the
use of ports.
TCP Segments
The chunk of data that TCP asks IP to deliver is called a
TCP segment.

Each segment contains:


data bytes
control information that identifies the data bytes
TCP Segment Format

TCP Header
Transmission Control Protocol
(TCP)
Flag Description

URG The value of the urgent pointer field is valid.

ACK The value of the acknowledgment field is valid.

PSH Push the data.

RST The connection must be reset.

SYN Synchronize sequence numbers during connection.

FIN Terminate the connection.


Example 1
Imagine a TCP connection is transferring a file of 6000 bytes.
The first byte is numbered 10,010. What are the sequence
numbers for each segment if data are sent in five segments
with the first four segments carrying 1000 bytes and the last
segment carrying 2000 bytes?

Solution
The following shows the sequence number for each segment:
Segment 1 ==> sequence number: 10,010 (range: 10,010 to 11,009)
Segment 2 ==> sequence number: 11,010 (range: 11,010 to 12,009)
Segment 3 ==> sequence number: 12,010 (range: 12,010 to 13,009)
Segment 4 ==> sequence number: 13,010 (range: 13,010 to 14,009)
Segment 5 ==> sequence number: 14,010 (range: 14,010 to 16,009)
Transmission Control Protocol
(TCP)

Sequence number defines number of first data


byte contained in that segment. The numbering
starts with randomly generated number.

Acknowledgment field defines number of next


byte a party expects to receive.
TCP Connection Establishment
A server accepts a connection.
Must be looking for new connections!
A client requests a connection.
Must know where the server is!

Its an TCP 3-way handshake


Client Server
SYN
SYN 1
ISN=X
ISN=X

SYN
SYN 2
ISN=Y
ISN=YACK=X+1
ACK=X+1

3
ACK=Y+1
ACK=Y+1
Transmission Control Protocol
(TCP)

Three-step Connection Establishment


TCP Connection Termination
Either end of the connection can initiate termination.
A FIN is sent, which means the application is done
sending data.
The FIN is ACK’d.
The other end must now send a FIN.
That FIN must be ACK’d.
App1 App2
FIN
FIN 1
SN=X
SN=X

2
ACK=X+1
ACK=X+1

...
FIN
FIN 3
SN=Y
SN=Y

ACK=Y+1 4
ACK=Y+1
Transmission Control Protocol
(TCP)

Four-step Connection Release


Why 3-Way?
Why is the third message necessary?

HINTS:
TCP is a reliable service.
IP delivers each TCP segment.
IP is not reliable.
Providing Reliability with
Acknowledgments and Retransmissions

Sende Network Receiver


r 1
Send packet
Receive packet
1
Send ACK 1

Receive ACK
1
Send packet 2
Receive packet
2
Send ACK 2

Receive ACK
2
Packet Loss

Sende Network Receiver


r 1
Send packet

(Timeout)
Send packet 1
Receive packet
1
Send ACK 1

Receive ACK
1
ACK Loss

Sende Network Receiver


r 1
Send packet
Receive packet
1
Send ACK 1

(Timeout)
Send packet 1
Receive packet
1 (Discard)
Send ACK 1

Receive ACK
1
ACK Delayed

Sende Network Receiver


r 1
Send packet
Receive packet
1
Send ACK 1
(Timeout)
Send packet 1

Receive ACK Receive packet


1 1 (Discard)
Send ACK 1

Receive ACK
(Discard) 1
A Problem

A simple positive acknowledgment protocol wastes a


substantial amount of network bandwidth because it
must delay sending a new packet until it receives an
acknowledgment for the previous packet.
A Solution

Sende Network Receiver


r
1

ACK1
3

ACK2

ACK3
Sliding Windows(Sender)
window

1 2 3 4 5 6 7 8 9 10

All packets inside the window can be transmitted

When an acknowledgment for packet 1 is received


the window slides to the right and allows the
transmission of packet 9:

1 2 3 4 5 6 7 8 9 10
Sliding Windows (Sender cont)
1 2 3 4 5 6 7 8 9 10

Conceptually partitions the packets into three


classes:
Transmitted and acknowledged packets (outside and left
of sliding window)
Packets being transmitted (inside the window)
Packets waiting to be transmitted (outside and right of
sliding window)
Sliding Windows (Sender cont)
Only unacknowledged packets are retransmitted
Keep separate timer for each packet
Performance:
Depends on the window size and the speed of the
underlying network
Note: sliding window protocol with window size = 1 is
the same as the simple positive acknowledgment
protocol we saw earlier
Sliding Windows (Reciever)
Receiver must keep a sliding window as well:
window

1 2 3 4 5 6 7 8 9 10

After packet 1 is received and acknowledged:

1 2 3 4 5 6 7 8 9 10
Ideal Sliding Window Performance

Sende Network Receiver


r
TCP - Efficient Transmission
Uses a specialized sliding window mechanism
 Multiple segments can be sent before an
acknowledgment arrives
Efficient transmission
Allows receiver to restrict transmission until it has
sufficient buffer space to accommodate more data.
Flow control
Flow Control

31 07/11/24
TCP Sliding Windows - Flow Control
Each window can vary in size over time
 The size of the window can be increased or decreased by the
destination.
 Each ACK contains a window advisement
 Specifies how many additional data the receiver is willing to
accept
 Sender increases or decreases sending window sized based on the
receiver’s advise
Provides end-to-end flow control
TCP Sliding Windows -
Flow Control Example

Receives an ACK 4 with window advisement = 7

1 2 3 4 5 6 7 8 9 10 11 12 13 14

Sender transmits 4 octets

1 2 3 4 5 6 7 8 9 10 11 12 13 14

Receives an ACK 8 with window advisement = 4

1 2 3 4 5 6 7 8 9 10 11 12 13 14
Error Control

34 07/11/24
Error Control Mechanisms
 Checksum (to check for corrupted segment)
 Acknowledgment (to confirm receipt of data segment)
 Retransmission (when packet lost, corrupted or
delayed)
 Out-of-Order Segments (store until missing packet
arrvies)

35 07/11/24
User Datagram protocol

You might also like