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

Lecture 8 - Transport Layer

The document summarizes key concepts about the transport layer from a lecture on computer networks. It discusses: 1) The transport layer provides a transport service between applications running on different hosts, handling segmentation and reassembly of data. 2) There are two main transport protocols - UDP (connectionless) and TCP (connection-oriented). UDP provides a basic transport service with no reliability, while TCP provides reliable, ordered delivery of data. 3) The transport layer multiplexes data from multiple applications onto one network connection using port numbers, and demultiplexes incoming data to the correct application based on port.

Uploaded by

Quân Ht
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)
103 views

Lecture 8 - Transport Layer

The document summarizes key concepts about the transport layer from a lecture on computer networks. It discusses: 1) The transport layer provides a transport service between applications running on different hosts, handling segmentation and reassembly of data. 2) There are two main transport protocols - UDP (connectionless) and TCP (connection-oriented). UDP provides a basic transport service with no reliability, while TCP provides reliable, ordered delivery of data. 3) The transport layer multiplexes data from multiple applications onto one network connection using port numbers, and demultiplexes incoming data to the correct application based on port.

Uploaded by

Quân Ht
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/ 50

Lecture 8:

Transport layer

Reading 6.2, 6.3, 6.4, 6.5


Computer Networks, Tanenbaum

1
Contents

l  Principles of transport layer


l  UDP protocol
l  TCP protocol

2
Transport layer in OSI model
Application Support applications
(HTTP, Mail, …)

Transport Transferring data between applications


(UDP, TCP …)

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

Datalink
(Ethernet, ADSL…)

Physical
(bits…)
3
Principle of transport layer (1) application
transport
network
l  Provide transport means data link
physical
between end applications
l  Sender:
l  Receives data from application
l  Place data in segments and
give to network layer
l  If the data size is too big, it is
divided into many segments
l  Receiver: application
l  Receives segments from transport
network
network layer data link
physical
l  Reconstitute data from
segments and deliver to the
application

4
Principle of transport layer (2)
application
transport
network
l  Transport layer is installed in data link
physical

end systems
network
data link
network
physical
data link
l  Not installed in routers, physical

switches…
network

l  Two kinds of transport layer data link


physicalnetwork

services data link


physical
network

l  Reliable, connection- data link


physical network
application
transport
oriented, e.g TCP data link
physical
network
data link
physical
l  Not reliable, connectionless,
e.g. UDP

5
Why two kinds of service?
l  Requirements from application layer are various
l  Some applications need transport service with 100%
fiability such as mail, web…
l  Should use TCP transport service
l  Some applications need to transmit data as fast as
possible, with some fault tolerance, e.g. VoIP, Video
Streaming
l  Should use UDP transport service

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

7
Functionalities
MUX/DEMUX

8
Mux/Demux

Application
protocols
HTTP FTP Chat HTTP FTP Chat

Transport
Multiplexing Demultiplexing
protocols

Network protocols

9
How does it Mux/Demux?
32 bits
l  How to distinguish source port # dest port #
applications running in the
same hosts? other header fields
l  Use an identifier called port
number (16 bits)
l  Each process is assigned a application
port data
(message)
l  Socket: A pair of IP address
and port
l  Socket identifies an unique TCP/UDP segment format
application process all over the
10
world
Checksum
l  Phát hiện lỗi bit trong các đoạn tin/gói tin
l  Nguyên lý giống như checksum (16 bits) của giao thức
IP
l  Ví dụ:

1 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0
1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1

1 1 0 1 1 1 0 1 1 1 0 1 1 1 0 1 1

Tổng 1 1 0 1 1 1 0 1 1 1 0 1 1 1 1 0 0
Checksum 1 0 1 0 0 0 1 0 0 0 1 0 0 0 0 1 1
11
UDP
User Datagram Protocol

12
“Best effort” protocols
l  Why UDP?
l  No need to establish connection (cause delay)
l  Simple
l  Small header
l  No congestion control à send data as fast as possible

l  Main functionality of UDP?


l  MUX/DEMUX
l  Detect error by checksum

13
Datagram format
l  Data unit in UDP is 32 bits

called datagram source port # dest port #


length checksum

Length of the
datagram in
byte
Application
data
(message)

14
Issues of UDP
l  No congestion control
l  Cause overload of the Internet
l  No reliability
l  Applications have to implement themselves
mechanisms to control errors

15
Error control

16
Error control
l  How to detect error?
l  Checksum
l  How to inform sender?
l  ACK (acknowledgements):
l  NAK (negative acknowledgements): tell sender
that pkt has error
l  Reaction of sender?
l  Retransmit the error packet once received NAK

17
Error control
Sender Receiver

send pkt0 pkt0

pkt1 is
ACK OK
rcv ACK
send pkt1 pkt1
pkt1 is
NAK corrupted

rcv NAK pkt1


resend pkt1

Time Time
18
Error in ACK/NAK
Sender Receiver
l  ACK/ NAK may be
corrupted
pkt0
l  Packet is resent send pkt0
pkt0 is
l  How to solve ACK OK
packet repetition? send
rcv ACK
pkt1 pkt1
l  Use Seq.# pkt1 is
ACK OK

Rcv corrupted pkt1


packet! resend pkt1 rcv pkt1
duplicate,

Time Timediscard it
19
Error control without NAK

Sender Receiver

pkt0
send pkt0

pkt0 is
ACK0
OK
rcv ACK0 pkt1
send pkt1
ACK1 pkt1 is
OK
rcv ACK1 pkt0
send pkt0

ACK1
pkt0 is corrupted

rcv ACK1 pkt0


resend pkt0

20
Time Time
Chanel with error and packet
lost
l  Data and ACK can be lost
l  If no ACK is received?How sender knows and
decides to resend data?
l  Sender should wait for ACK for a certain time.
Timeout!
l  How long should be timeout?
l  At least 1 RTT (Round Trip Time)
l  Need to start a timer each time sending a packet
l  What if packet arrives and ACK is lost?
l  Packet should be numbered.
21
Illustration

22
Illustration

23
Transmission in pipeline

1 data pkt Data pkts

Sender Receiver Sender Receiver

ACK ACKs

24
Comparison of efficiency
stop-and-wait Pipeline
sender sender receiver
0
L/R L/R

RTT RTT

RTT + L / R RTT + L / R

time time
L: Size of data pkt time time
R: Link bandwidth
RTT: Round trip time 3*L/R
Performance =
RTT + L / R
L/R
Performance = 25

RTT + L / R
TCP
Transmission Control Protocol

TCP segment structure


Connection management
Flow control
Congestion control

26
Overview of TCP
l  Connection oriented
l  3 steps hand-shake
l  Data transmission in stream of byte, reliable
l  Use buffer
l  Transmit data in pipeline
l  Increase the performance
l  Flow control
l  Sliding windows
l  Congestion control
l  Detect congestion and solve

27
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 U A P 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)

28
How TCP provide reliable service?
l  In order to assure if data arrives to
destination:
l  Seq. #
l  Ack
l  TCP cycle life:
l  Connection establishing
l  3 steps
l  Data transmission
l  Close connection
29
Acknowledgement in TCP
Seq. #: Host A Host B
l  Index of the first byte
User Seq=4
of the segment in the types
2, ACK
=79, d
ata =
data stream ‘C’ ‘C’
host ACKs
ACK: ’
receipt of
a ta = ‘C ‘C’, echoes
, d
l  The index of the first , A C K=43 back ‘C’
q = 7 9
Se
byte expected to
receive from the host ACKs
other-side receipt Seq=4
of echoed 3, ACK
=80
l  Implicitly to confirm ‘C’
that the ACK senders
have received well
time
previous bytes simple telnet scenario 30
Connection establishing in TCP :
3 steps
l  Bước 1: A sends SYN to B
A B l  Indicate initial value of seq # of
A
l  No data
SYN l  Bước 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
l  Bước 3: A receives SYNACK,
replies ACK, maybe with data.

31
Close connection
l  Step 1: Send FIN to B A B
l  Step 2: B receives FIN, replies
ACK, closes the connection closing
FIN
and sends FIN.
l  Step 3: A receives FIN, replies
ACK
ACK, go to “waiting”. closing
FIN
l  Bước 4: B receives ACK.
close connection
ACK

timed wait
closed

closed
32
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 33
Flow control

34
Flow control(1)
A A B
B

Slow Overload
35
Flow control (2)
l  Control the amount of data to be sent
l  Assure the best efficiency
l  Avoid overloading the receiver.
l  Two windows
l  Rwnd: Receive window on receiver side
l  CWnd: Congestion window on sender side
l  The maximum amount of data to be sent should be
min(Rwnd, Cwnd)

36
Flow control TCP

l  Size of free buffer


= Rwnd
= RcvBuffer-[LastByteRcvd
- LastByteRead]

37
Information exchanged on
Rwnd
A B
l  Receiver inform
regularly to senders
data
the value of Rwnd in
acknowledgment
K ( r wnd = 100
) segments
AC
data

38
Congestion control in TCP

39
Overview of Congestion control
l  When congestion happens?
l  Too many pairs of senders-receivers in the network
l  High traffic
l  Consequence of congestion
l  Packet loss
l  Reduce of throughput, increase of delay
l  Network situation become worst with reliable protocol
such as TCP.
Congestion
occur

40
Principles of congestion control
l  Slow-start
l  Increases the transmission
speed in exponential order cwnd
l  Increase until a threshold 20

l  Congestion avoidance 18
Threshold=16
16
l  Increase the transmission
14
speed in linear order until
12 SS
congestion is detected 10

l  How to detect the 8

congestion? 6

l  By packets lost? 2

41
TCP Slow Start (1)
l  Main idea
l  Initiate cwnd =1 MSS (Maximum segment size)
l  Increase cwnd =+1 MSS after each reception of a
ACK packet from the receiver.
l  Increase slowly but the speed increase in
exponential order
l  Increase until a threshold: ssthresh
l  After that TCP move to congestion avoidance
period
42
TCP Slow Start (2)
Host A Host B

one segm
ent
RTT

two segm
e nts

four segm
e nts

time

43
Congestion avoidance
Host A Host B
l  Main idea
l  Increase cwnd in one segm
ent

RTT
additional order
until cwnd reaches two segm
e nts
to ssthresh
l  After each RTT,
three segm
cwnd =cwnd + 1 ents

MSS

time

44
TCP reaction in congestion
situation (1)
l  Reduce the transmission speed
l  How to detect the congestion?
l  If there are some re-transmits è There might be
congestion
l  When the source node need to re-transmit
data?
l  Timeout!
l  When it receives multiple ACK for the same
segment
45
TCP reaction in congestion
situation(2)
l  When sender reach timeout but still does not receive
ACK for a segment
l  TCP sets ssthresh = ½ current cwnd
l  TCP sets cwnd =1 MSS
l  TCP move to slow start phase

l  If sender receives 3 identical ACK


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

46
Congestion control – illustration
cwnd

22
Timeout
20

18
Threshold is set to half of cwnd (20)
Threshold=16
16 And slow start starts
14
3 ACKs
12 SS
Threshold=10 Threshold is set to half of cwnd (12)
10
AI And additive increase starts
8
SS
AI
6 Threshold=6

4
AI
2

Step
47
Exercise
l  Assume that we need transmit 1 file
l  File size O =100KB over TCP connection
l  S is the size of each TCP segment, S = 536 byte
l  RTT = 100 ms.
l  Assume 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. 48
Solution (cont.)
l  T transmit (W packet) = W * S/R
l  Transmit without waiting:

l  => (W-1)*S/R >= RTT

l  => W >= RTT*R/S +1

l  Time to transmit all data L = L/R + RTT

l  R=100 Mbps
l  W>= 100ms * 100 Mbps/ (536*8) + 1

49
Exercise
l  Assume that we need transmit 1 file
l  File size O =100KB over TCP connection
l  S is the size of each TCP segment, S = 536 byte
l  RTT = 100 ms.
l  Assume that the congestion window of TCP works
according to slow-start mechanism.
l  What is the size of the congestion window when
the whole file is transmited.
l  How much of time is required for transmitting the
file? If R = 10 Mbit/s; R= 100 Mbits/s. 50

You might also like