Académique Documents
Professionnel Documents
Culture Documents
Lecture 5
The Transport Layer, Transmission
Control Protocol (TCP), and User
Datagram Protocol (UDP)
Outline
The Transport
p Layer
y
The TCP Protocol
¾ TCP Characteristics
¾ TCP Connection setup
¾ TCP Segments
¾ TCP Sequence Numbers
¾ TCP Sliding Window
¾ Timeouts and Retransmission
¾ (Congestion Control and Avoidance)
The UDP Protocol
2
1
The Transport Layer
What is the transport layer for?
What characteristics might it have?
¾ Reliable delivery
¾ Flow control
¾…
Nick Dave
Transport Layer
D H D H D H
D H Link Layer
2
Layering: The OSI Model
layer-to-layer communication
Application Application
7 7
Presentation Presentation
6 6
Session Session
5 5
Peer-layer communication
Transport Transport
4 Router Router 4
Network Network Network Network
3 3
Link Link Link Link
2 2
Physical Physical Physical Physical
1 1
3
TCP Characteristics
TCP is connection-oriented.
¾ 3-way handshake used for connection setup.
TCP provides a stream-of-bytes service.
TCP is reliable:
¾ Acknowledgements indicate delivery of data.
¾ Checksums are used to detect corrupted data.
¾ Sequence numbers detect missing, or mis-sequenced data.
¾ Corrupted data is retransmitted after a timeout.
¾ Mis-sequenced
q data is re-sequenced.
q
¾ (Window-based) Flow control prevents over-run of receiver.
TCP uses congestion control to share network
capacity among users. We’ll study this in the next
lecture.
7
TCP is connection-oriented
(Active) (Passive) (Active) (Passive)
Client Server Client Server
Syn Fin
Ack
Fin
Ack
4
TCP supports a “stream of
bytes” service
Host A
Host B
TCP Data
Host B
10
5
The TCP Segment Format
IP Data
TCP Data TCP Hdr IP Hdr
0 15 31
Src port Dst port
Sequence #
Src/dst port numbers
Ack Sequence # and IP addresses
TCP Header HLEN RSVD
Flags
SYN Window Size uniquely identify socket
URG
PSH
RST
FIN
ACK
6
and Data + IP
4
(TCP Options)
TCP Data
11
Sequence Numbers
Host A
ISN (initial sequence number)
Sequence TCP
TCP Data
number = 1st HDR
12
6
Initial Sequence Numbers
(Active) (Passive)
Client Server
Syn +ISNA
Ack
Connection Setup
3-way handshake
13
14
7
TCP Sliding Window
Window Size
15
Host B
ACK ACK ACK
(1) RTT > Window size (2) RTT = Window size
16
8
TCP: Retransmission and
Timeouts
Round-trip time (RTT) Retransmission TimeOut (RTO)
Guard
Band
Host A
Estimated RTT
Data1 Data2
ACK ACK
Host B
17
18
9
TCP: Retransmission and Timeouts
There will be some (unknown) distribution Router queues grow when there is more
of RTTs. traffic, until they become unstable.
We are trying to estimate an RTO to As load grows, variance of delay grows
minimize
i i i ththe probability
b bilit of
f a false
f l timeout.
ti t rapidly.
idl
Variance
grows rapidly
with load
variance
19
20
10
TCP: Retransmission and Timeouts
Karn’s Algorithm
Host A Host B Host A Host B
Retransmission Retransmission
Problem:
How can we estimate RTT when packets are retransmitted?
Solution:
On retransmission, don’t update estimated RTT (and double RTO).
21
22
11
User-Datagram Protocol (UDP)
A1 A2 B1 B2
OS
UDP
23
DATA
Why do we have
ha e UDP?
D ?
¾ It is used by applications that don’t need reliable delivery, or
¾ Applications that have their own special needs, such as
streaming of real-time audio/video.
24
12