0% found this document useful (0 votes)
12 views

Chapter 5 - Transport Layer

Uploaded by

haosana04
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Chapter 5 - Transport Layer

Uploaded by

haosana04
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 38

Lecture 8:

Transport layer
Reading 6.2, 6.3, 6.4, 6.5
Computer Networks, Tanenbaum

1
Contents

lPrinciples of transport layer


lUDP protocol
lTCP protocol

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

2
Transport layer in OSI model

Application Support applications


(HTTP, Mail, …)

Transport Transferring data between


(UDP, TCP …) applications/processes

Network
Routing and forwarding data between
(IP, ICMP…) hosts
Datalink
(Ethernet, ADSL…)

Physical
(bits…)

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

3
Principle of transport layer (1)

application
lGet applications/processes to transport
network
communicate to each other data link
physical

lSender:
l Receives data from application

log
ica
l Place data in segments and give

l
en
to network layer

d-
en
l If the data size is too big, it is

d
tra
divided into many segments

ns
po
lReceiver:

rt
l Receives segments from application
network layer transport
network
l Reconstitute data from data link

segments and deliver to the


physical

application

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

4
Principle of transport layer (2)

application
transport

• Transport layer is installed in network


data link

end systems
physical
network
data link

log
network

• Not installed in routers,


physical
data link

ica
physical

switches…

l en
d-
en
• Two kinds of transport layer

d
network

tra
data link

services

ns
physicalnetwork

po
data link

rt
physical
• Reliable, connection-oriented, network
data link
e.g TCP physical network
data link
application
transport
network
• Not reliable, connectionless, physical data link
physical

e.g. UDP

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

5
Why two kinds of service?

• Requirements from application layer are various


• Some applications need transport service with
100% fiability such as mail, web…
• Should use TCP transport service
• Some applications need to transmit data as fast as
possible, with some fault tolerance, e.g. VoIP,
Video Streaming
• Should use UDP transport service

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

6
Applications and transport services

Application Application protocols


Transport protocols
e-mail SMTP TCP
remote terminal access Telnet TCP
Web HTTP TCP
file transfer FTP TCP
streaming multimedia Specific protocols TCP or UDP
(e.g. RealNetworks)
Internet telephony Specific protocols
(e.g., Vonage,Dialpad) Usually UDP

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

7
Functionalities
MUX/DEMUX

8
Mux/Demux

Application
protocols
HTTP FTP Chat HTTP FTP Chat

Transport
Multiplexing Demultiplexing
protocols

Network protocols

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

9
How does it Mux/Demux?

32 bits
lHow to distinguish source port # dest port #
applications running in the
same hosts? other header fields
lUse an identifier called port
number (16 bits)
lEach process is assigned a port
application
lSocket: A pair of IP address data
and port (message)
lSocket identifies an unique
application process all over the
world TCP/UDP segment format

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

10
UDP
User Datagram Protocol

11
“Best effort” protocols

lWhy UDP?
lNo need to establish connection (cause delay)
lSimple
lSmall header
lNo congestion control à send data as fast as possible

l Main functionality of UDP?


l MUX/DEMUX
l Detect error by checksum

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

12
Datagram format

lData unit in UDP is 32 bits


called datagram source port # dest port #
length checksum

Length of the
datagram in
byte
Application
data
(message)

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

13
Issues of UDP

• No congestion control
• Cause overload of the Internet
• No reliability
• Applications have to implement themselves
mechanisms to control errors

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

14
TCP
Transmission Control Protocol
TCP segment structure

Connection management

Flow control

Congestion control

15
Overview of TCP

lConnection oriented
l3 steps hand-shake
lData transmission in stream of byte, reliable
lUse buffer
lTransmit data in pipeline
lIncrease the performance
lFlow control
lSliding windows
lCongestion control
lDetect congestion and solve

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

16
TCP segment

32 bits
URG: urgent data - For reliable
source port # dest port #
transmission
sequence number
ACK: ACK #
acknowledgement number
head not
PSH: data needs to len used
UAP R S F Receive window
-For flow control
be sent immediately checksum Urg data pnter -with sliding window
RST, SYN, FIN: Options (variable length)
Flag for special
segment
application
data
(variable length)

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

17
How TCP provide reliable service?

lIn order to assure if data arrives to destination:


lSeq. #
lAck
lTCP cycle life:
lConnection establishing
l 3 steps
lData transmission
lClose connection

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

18
Acknowledgement in TCP

Seq. #:
lIndex of the first byte Host A Host B
of the segment in the
data stream User Seq=4
2, ACK
types =79, d
ata =
ACK: ‘Hello’ ‘Hello

host ACKs
lThe index of the first ’
receipt of
rld
byte expected to data = ‘WoHello’, Send back
47, back ‘World’
receive from the 79, ACK=
Seq=
other-side
lImplicitly to confirm host ACKs
that the ACK senders receipt Seq=?
of send , ACK=
have received well ‘Bye’
?

previous bytes

time
TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG
simple telnet scenario
School of Information and Communication Technology
Before this transmission: A has sent 41 bytes to B,
and B has sent 78 bytes to A 19
Connection establishing in TCP : 3 steps

lStep 1: A sends SYN to B


A B l Indicate initial value of seq # of
A
l No data
SYN lStep 2: B receives SYN, replies
by SYNACK
ACK/SYN l B initiates the buffer on its side
l Indicate initial value of seq. # of
ACK
B
lStep 3: A receives SYNACK,
replies ACK, maybe with data.

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

20
Close connection

• Step 1: Send FIN to B A B


• Step 2: B receives FIN, replies
ACK, closes the connection and closing
FIN
sends FIN.
• Step 3: A receives FIN, replies
ACK
ACK, go to “waiting”. closing
FIN
• Step 4: B receives ACK. close
connection
ACK

timed wait
closed

closed
TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG
School of Information and Communication Technology

21
Symplified life cycle of TCP

Client application
Initiates a TCP connection Server application
Creates a listen socket
CLOSED
Wait 30 sec. Receive ACK
CLOSED
Send nothing
Send SYN

TIME_WAIT SYN_SENT LAST_ACK LISTEN

Receive FIN Receive SYN/ACK Receive SYN


Send ACK Send ACK Send FIN Send SYN/ACK

FIN_WAIT_2 ESTABLISHED CLOSE_WAIT SYN_RCVD

Send FIN
Receive ACK
Send nothing Receive FIN Receive ACK
FIN_WAIT_1 Send ACK ESTABLISHED Send nothing

Client application
Initiates close connection

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

22
Flow control in TCP

23
Flow control(1)

A A B
B

Slow Overload
TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG
School of Information and Communication Technology

24
Flow control (2)

lControl the amount of data to be sent


lAssure the best efficiency
lAvoid overloading the receiver.
lTCP uses sliding window for flow control
lTwo windows
lRwnd: Receive window on receiver side
lCWnd: Congestion window on sender side
lThe maximum amount of data to be sent should be
min(Rwnd, Cwnd)

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

25
Flow control TCP

lSize of free buffer


= Rwnd
= RcvBuffer-[LastByteRcvd
- LastByteRead]

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

26
Information exchanged on Rwnd

A B
l Receiver inform
regularly to senders
data
the value of Rwnd in
acknowledgment
wnd = 100) segments
ACK (r
data

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

27
Congestion control in TCP

28
Overview of Congestion control

lWhen congestion happens?


lToo many pairs of senders-receivers in the network
lHigh traffic
lConsequence of congestion
lPacket loss
lReduce of throughput, increase of delay
lNetwork situation become worst with reliable protocol
such as TCP.

Congestion
occur

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

29
Principles of congestion control

lSlow-start
lIncreases the transmission
speed in exponential order cwnd

lIncrease until a threshold 20

lCongestion avoidance 18
Threshold=16
lIncrease the transmission
16

speed in linear order until 14

congestion is detected 12 SS
10

lHow to detect the 8

congestion? 6

lBy packets lost? 4

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

30
TCP Slow Start (1)

• Main idea
• Cwnd: congestion window = data size that source can send to
destination without waiting for ACK
• Rwnd (sliding windows in flow control): maximum data size to be
sent without ACK according to flow control
• Actual data size can be sent without ACK = min (Cwnd, Rwnd)
• Initiate cwnd =1 MSS (Maximum segment size)
• Increase cwnd =+1 MSS after each reception of a ACK packet
from the receiver.
• Increase slowly but the speed increase in exponential order
• Increase until a threshold: ssthresh
• After that TCP move to congestion avoidance period

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

31
TCP Slow Start (2)

Host A Host B

one segm
ent
RTT

two segme
nts

four segm
ents

time

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

32
Congestion avoidance

Host A Host B
• Main idea
• Increase cwnd in one segm
ent
additional order

RTT
until cwnd reaches
two segme
to congestion nts

• After each RTT, cwnd


=cwnd + 1 MSS three segm
ents

time

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

33
TCP reaction in congestion situation (1)

• Reduce the transmission speed


• How to detect the congestion?
• If there are some re-transmits è There might be
congestion
• When the source node need to re-transmit
data?
• Timeout!
• When it receives multiple ACK for the same
segment

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

34
TCP reaction in congestion situation(2)

• When sender reach timeout but still does not


receive ACK for a segment
• TCP sets ssthresh = ½ current cwnd
• TCP sets cwnd =1 MSS
• TCP move to slow start phase

• If sender receives 3 identical ACK


• TCP sets ssthresh = ½ current cwnd
• TCP move to “congestion avoidance”

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

35
Congestion control – illustration

cwnd

22
Timeout
20

18
Threshold=16 Threshold is set to half of cwnd (20)
16 And slow start starts
14
Congestion 3 ACKs
12 Slow avoidance
start Threshold=10 Threshold is set to half of cwnd (12)
10
And additive increase starts
8
Slow start
6 Congestion Threshold=6
avoidance
4
Congestion
2 avoidance

Step

36
TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG
School of Information and Communication Technology
Exercise

lAssume that we need transmit 1 file


lFile size O =100KB over TCP connection
lS is the size of each TCP segment, S = 536 byte
lRTT = 100 ms.
lAssume that the congestion window size of
TCP is fixed with value W.
What is the minimum transmission time? If the
transmission speed is
l R = 10 Mbit/s;
l R= 100 Mbits/s.

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

37
Exercise

• Assume that we need transmit 1 file


• File size O =100KB over TCP connection
• S is the size of each TCP segment, S = 536 byte
• RTT = 100 ms.
• Assume that the congestion window of TCP works
according to slow-start mechanism (ssthreshold =
infinity).
• What is the size of the congestion window when the
whole file is transmitted.
• How much of time is required for transmitting the file?
If R = 10 Mbit/s; R= 100 Mbits/s.

TRƯỜNG CÔNG NGHỆ THÔNG TIN VÀ TRUYỀN THÔNG


School of Information and Communication Technology

39

You might also like