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

ch3 ResponseCollege

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

ch3 ResponseCollege

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

Communication Networks

W. Tavernier & P. Demeester

Response college
Transportlaag

woensdag 6 oktober 2021


A. Van Maele

Transport Layer 3-1


Part of slides provided by J.F Kurose and K.W. Ross, All Rights Reserved
Transport Services and Protocols
• provide logical communication
between app processes running on
different hosts
• transport protocols run in end
systems
– send side: breaks app
messages into segments,
passes to network layer
– rcv side: reassembles segments
into messages, passes to app
layer
• more than one transport protocol
available to apps
– Internet: TCP and UDP
Transport Layer 3-2
TCP connection for file transfer
0001-1000

TCP for file transfer 1001-2000

2001-3000

3001-4000

<SYN_S> 4001-5000

<ACK of SYN_S,SYN_C>

<ACK of SYN_C>

<bytes 0001-1000>
<ACK bytes 1001-2000 >

<bytes 1001-2000>
<ACK bytes 2001-3000 >

<bytes 2001-3000>

time-out

<bytes 2001-3000>
<ACK bytes 3001-4000 >

<bytes 3001-4000>
Transport Layer 3-3
<ACK bytes 4001-5000 >
UDP for real time audio transfer
0001-1000

1001-2000

2001-3000

3001-4000
UDP real time audio 4001-5000

<bytes 1-1000>

<bytes 1001-2000>

<bytes 2001-3000>

<bytes 3001-4000>

<bytes 4001-5000>

• send as quick as possible


• no extra delay due to acknowledgment
• no retransmissions Transport Layer 3-4
Communication Networks
W. Tavernier & P. Demeester

TCP
(3.5, 3,7)

Transport Layer 3-5


Part of slides provided by J.F Kurose and K.W. Ross, All Rights Reserved
Flow control : example
sender receiver
data to be sent (expressed in MSS) receiver buffer (4 x MSS)
1 2 3 4 5 6 7 8 9 <SYN>

,
send window
A CK , S Y N, MSS=1
<
>
1 2 3 4 5 6 7 8 9 Window=4
<ACK> receive
1 2 3 4 5 6 7 8 9 window
<SEQ=1>
1 2 3 4 5 6 7 8 9
<SEQ=2>
1 2 3 4 5 6 7 8 9
<SEQ=3>
sent, not yet ack’ed
send window
W =1 >
<ACK=4, 2 MSS to
1 2 3 4 5 6 7 8 9 W=1: advertised application
receive window
1 2 3 4 5 6 7 8 9
sent and
acknowledged <SEQ=4>

send window received


W =2 >
<ACK=5, not transferred
1 2 3 4 5 6 7 8 9 to application
zero window <ACK=5, W=0> will stop communication (no more window updates)
Transport Layer 3-6
 regular probing from sender (use persistency timer)
Flow control : sliding window
sender <ACK=4, W=3>

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18

<ACK=3, W=2>

SEND WINDOW =
(advertised) receive window (RcvWindow)
MINUS
number of sent but not yet acknowledged bytes
(LastByteSent – LastByteAcked)

LastByteAcked LastByteSent

allowed to send if :
Transport Layer 3-7
LastByteSent – LastByteAcked < RcvWindow or SndWindow > 0
Impact of congestion

Network congestion (layer 3):


Effective throughput
- limited capacity of routers (L3)
Maximum - traffic load high
capacity
of the network

retransmissions: packet
loss
linear due to buffer overflow
increase
congestion
starts

Traffic offered
to the network

Solution : Congestion Control (in terminals)


layer 4 (TCP) will reduce load offered to L3 (IP)
Transport Layer 3-8
Approaches towards congestion control
Two broad approaches towards congestion control:

End-end congestion Network-assisted


control (TCP approach): congestion control:
• no explicit feedback from • routers provide feedback to
network end systems
• congestion inferred from end- • single bit indicating
system observed loss, delay congestion
• explicit rate sender
• approach taken by TCP should send at

Transport Layer 3-9


Congestion detection (by sender !)
Timeout :
▪ A segment or ACK was dropped due to congestion.
▪ A segment or ACK is experiencing a large delay due to congestion.
▪ A segment or ACK was dropped due to a transmission error
(has nothing to do with congestion and is assumed to be not important ).

TCP solution : slow start + congestion avoidance

Will be updated later …

Transport Layer 3-10


Slow start Will be updated later …

cwnd (# MSS)
cwnd = 1 <SEQ=1(1
)>
18
<ACK=2> 16
cwnd = 2
<SEQ=2(1)> 14
<SEQ=3(1)>
12
<ACK=3>
10
<ACK=4>
cwnd = 4 8
<SEQ=4(1)>
<SEQ=5(1)> 6
<SEQ=6(1)>
<ACK=5> <SEQ=7(1)> 4
<ACK=6>
2
<ACK=7>
<ACK=8> 00
cwnd = 8 1 2 3 4 5
# RTT
<SEQ=8(1)>

... !!! value of

cwnd = 16
<ACK=9>
...
ACK received: CongWin = CongWin + MSS
measured
RTT
Transport Layer 3-11
is varying !!!
Slow start threshold / Congestion avoidance
cwnd = 1 cwnd (# MSS)

18
cwnd = 2
16
14
cwnd = 4 12
10

cwnd = 8 8 Slow
Start
6 Threshol
d
4 (ssthresh
)
2

cwnd = 9 00 1 2 3 4 5
# RTT

slow congestion
start avoidance
cwdn > ssthresh:
Transport Layer 3-12
cwnd = 10 ACK received: CongWin = CongWin + MSS * (MSS/CongWin)
Avoiding congestion (Timeout)

!!! TIMEOUT !!!


ssthresh = cwnd/2
cwdn cwnd = 1 x MSS !!! TIMEOUT !!!
size ssthresh = cwnd/2
cwnd = 1 x MSS
congestion
avoidance
slow
start

slow
start

# RTT
Intial values :
ssthresh = 64 kbyte Note : when cwnd > receive window
cwnd = 1xMSS => normal flow control takes over from congestion control
(based on receive window) Transport Layer 3-13
TCP Connection OPEN
OPEN TCP
connection
(negotiate initial settings)
Client side Server side
<SP=134
00, DP=2

3-way handshake
3, SEQ=
4 432901 (
0), SYN,
MSS=10
24 >

=14 60>
A CK , S YN, MSS
02,
( 0 ) , A CK=44329
=13539 21
Q
3 , DP =1 3400, SE
< S P =2

<S P =1 3 4
0 0 , DP = 2
3 , S E Q =4
432902 (0
), ACK= 1
SP : Source Port number 353 922, A
CK>
DP : Destination Port number
SEQ : SEQuence number
(…) : length data field - most important fields in TCP header are indicated
ACK : ACKnowledgment number - last segment may contain data
SYN : SYN flag set to 1 - if server has no application protocol running at the
ACK : ACK flag set to 1 requested port (DP), it will return the RST = 1 flag (resetLayer
Transport sender)
3-14
MSS : Maximum Segment Size - ISN (Initial Sequence Number): based on timed counter (see notes)
TCP State Transition Diagram
STARTING POINT CLOSED
appl: active open
send: SYN
appl: passive open
send: -
LISTEN SYN_SENT
recv: SYN DATA
send: ACK, SYN TRANSFER recv: ACK, SYN
STATE send: ACK
recv: ACK
SYN_RCVD send: - ESTABLISHED
recv: FIN
send: ACK
appl: close
send: FIN
CLOSE_WAIT
FIN_WAIT_1
recv: ACK, FIN appl: close
PASSIVE
send: ACK send: FIN
ACTIVE CLOSE
recv: ACK CLOSE
send: -
LAST_ACK
recv : ACK
recv: FIN
send : -
send: ACK
wait 2 MSL Transport Layer 3-15
FIN_WAIT_2 TIME_WAIT Maximum segment lifetime
Communication Networks
W. Tavernier & P. Demeester

Response college
Transportlaag (bis)

woensdag 13 oktober 2021


A. Van Maele

Transport Layer 3-16


Part of slides provided by J.F Kurose and K.W. Ross, All Rights Reserved
Ack/retrans/duplicate reception
use of acknowledgements

Sender side Receiver side

<SEQ=145 (20)>

timeout <ACK = 165>


retransmit duplicate
reception
=> discard

<SEQ=145 (20)>

<ACK=165>
<SEQ=165 (30)>

Transport Layer 3-17


Delayed accumulated ack – real life

Sender side A Receiver side B


<SEQ=145 (20)>

<SEQ=165 (20)>

delayed
<ACK=185>
ACK
accumulated ACK
after 2 segments

- ACK number indicates that all bytes before the ACK number have been received correctly
- in practice : if a second segment is received, the accumulated ACK is send immediately

Transport Layer 3-18


TCP ACK generation

Event at Receiver TCP Receiver action


Arrival of in-order segment with Delayed ACK. Wait up to 500ms
expected seq #. All data up to for next segment. If no next segment,
expected seq # already ACKed send ACK

Arrival of in-order segment with Immediately send single accumulated


expected seq #. One other ACK, ACKing both in-order segments
segment has ACK pending

Arrival of out-of-order segment Immediately send duplicate ACK,


higher-than-expect seq. # . indicating seq. # of next expected byte
Gap detected

Arrival of segment that Immediate send ACK, provided that


partially or completely fills gap segment starts at lower end of gap

Transport Layer 3-19


Communication Networks
W. Tavernier & P. Demeester

TCP RTO
(3.5.3)

Transport Layer 3-20


Part of slides provided by J.F Kurose and K.W. Ross, All Rights Reserved
Retransmission timeout
Problem : large variation in round trip time !!!
(LAN <> worldwide Internet)
==> dynamic update of retransmission timeout (RTO)
new old measured [TimeoutInterval]
value value value

RTT = (1-a) RTT + a M ( in general a = 1/8 )


RTT (Round Trip Time)
= exponential weighted moving average (EWMA) [EstimatedRTT]
M = last measured time for an acknowledgment [SampleRTT]

Retransmission Timeout : RTO = RTT + 4 D initial values :


RTO = 3”
D = (1-b) D + b |M-RTT| (mean deviation) [DevRTT] D = 1.5”
RTT = 0”
( typically b = 1/8 to 1/4 )
Exponential back-off : every retransmission of the same segment will double the RTO
(with an upper limit and latching of 64”)
(connection timeout after preconfigured number of retransmissions)
Transport Layer 3-21
(note : the RTT will not be updated based on the measurement of a retransmitted segment)
RTO : Example 2 : oscillation
7 seconds (”)

5
M
4 RTT

3 D
RTO
2

0
1 4 7 10 13 16 19 22 25 28 31 34 37 40 43
Transport Layer 3-22
measurement number
Communication Networks
W. Tavernier & P. Demeester

TCP congestion
avoidance
(3.7)

Transport Layer 3-23


Part of slides provided by J.F Kurose and K.W. Ross, All Rights Reserved
TCP Congestion window : limit send rate

SEND WINDOW :
MINIMUM {receive window,
receive congestion window}
window
MINUS
number of sent but not yet acknowledged bytes

allowed to send if :
LastByteSent – LastByteAcked < min {CongWindow, RcvWindow}
or SndWindow > 0

Flow control (~L4): detection by receiver and control by sender


• receive window (set at receiver side)
Congestion control (~L3): detection and control by sender
• congestion window (set at sender side)

Transport Layer 3-24


Slow start – delayed accum. ACK
cwnd = 1 <SEQ=1(1
)> cwnd (# MSS)

18
<ACK=2> 16
cwnd = 2
<SEQ=2(1)> 14
<SEQ=3(1)>
12
10
<ACK=4>
cwnd = 3 8
<SEQ=4(1)>
<SEQ=5(1)> 6
<SEQ=6(1)>
4
<ACK=6>
2
<ACK=7>

...
<SEQ=7(1)>
cwnd = 5 00 1 2 3 4 5
# RTT

<ACK=9>
<ACK=11>
...
cwnd = 8
Transport Layer 3-25
ACK received: CongWin = CongWin + MSS
Slow start threshold / Congestion avoidance
cwnd (# MSS)
cwnd = 8
18
16
14
cwnd = 9 12
10
8 Slow
Start
6 Threshol
cwnd = 10 d
4 (ssthresh
2 )

00 1 2 3 4 5
# RTT

slow congestion
cwdn > ssthresh: start avoidance
ACK received: CongWin = CongWin + MSS * (MSS/CongWin)
Transport Layer 3-26
Congestion detection (by sender !)
Timeout :
▪ A segment or ACK was dropped due to congestion.
▪ A segment or ACK is experiencing a large delay due to congestion.
▪ A segment or ACK was dropped due to a transmission error
(has nothing to do with congestion and is assumed to be not important ).

TCP solution : slow start + congestion avoidance

• Duplicate acknowledgments (3 or more) :


• One segment was dropped due to congestion.
• Next segments still get through the network
(generating duplicate acknowledgments)
• TCP solution :
fast retransmission (see reliability) + fast recovery

Transport Layer 3-27


Avoid retransmission

Sender side A <ACK=145>


Receiver side B
out of order
<SEQ=165 (20)> immediate ACK

<ACK=145>
<SEQ=145 (20)>
SEQ=165
<ACK=185> waits in
<SEQ=185 (20)> buffer, 145
expected
first

(First) Duplicate ACK


missing segment arrived
(immediate)
accumulated ACK

Different delay for segments


Transport Layer 3-28
=> re-ordered but no need to resend
Fast retransmission

Sender side A
<ACK=145> Receiver side B
<SEQ=145 (20)>
out of order
<SEQ=165 (20)> immediate ACK
3
<SEQ=185 (20)>
duplicated
ACK’s <SEQ=205 (20)>
=> fast <ACK=145>
retransmit <ACK=145>
<ACK=145>

<SEQ=145 (20)>

<ACK=225>

Note : 3 dupl ack :


make distinction with out of order
e.g. 1,3,4,2,5,6,...
timeout
NOT USED missing segment arrived
(immediate)
accumulated ACK Transport Layer 3-29
retransmission much faster than timeout
Avoiding congestion : dupl ack
fast retransmit : acknowledge
first non-ack retransmitted
normal dupl dupl dupl
segment=5 segment=5
ACK=5 ACK=5 ACK=5 ACK=5
ACK=11
(accumulated)

dupl
18 dupl ACK=5

16 ACK=5
Congestion
14 avoidance
ACK=19
cwnd (# MSS)

12
cwnd =
10 sstresh
+ 3 MSS
8
6
cwnd =
4 sstresh
Ssthresh = 1/2 cwnd
2
0
time
Transport Layer 3-30
see notes for detailed explanation
Summary: TCP Congestion Control
New
New ACK!
duplicate ACK
dupACKcount++
ACK!
new ACK
new ACK
.
cwnd = cwnd + MSS (MSS/cwnd)
dupACKcount = 0
cwnd = cwnd+MSS transmit new segment(s), as allowed
dupACKcount = 0
L transmit new segment(s), as allowed
cwnd = 1 MSS
ssthresh = 64 KB cwnd > ssthresh
dupACKcount = 0
slow L congestion
start timeout avoidance
ssthresh = cwnd/2
cwnd = 1 MSS duplicate ACK
timeout dupACKcount = 0 dupACKcount++
ssthresh = cwnd/2 retransmit missing segment
cwnd = 1 MSS
dupACKcount = 0
retransmit missing segment New
timeout
ACK!
ssthresh = cwnd/2
cwnd = 1 New ACK
dupACKcount = 0
retransmit missing segment cwnd = ssthresh dupACKcount == 3
dupACKcount == 3 dupACKcount = 0
ssthresh= cwnd/2 ssthresh= cwnd/2
cwnd = ssthresh + 3 cwnd = ssthresh + 3
retransmit missing segment retransmit missing segment
fast
recovery
duplicate ACK
cwnd = cwnd + MSS
transmit new segment(s), as allowed

Transport Layer 3-31


Communication Networks
W. Tavernier & P. Demeester

Transportlaag –
multiplexing
(3.2)

Transport Layer 3-32


Part of slides provided by J.F Kurose and K.W. Ross, All Rights Reserved
Multiplexing/demultiplexing
Demultiplexing at rcv side: Multiplexing at send side:
gathering data from multiple
delivering received segments
sockets, enveloping data with
to correct socket
header (later used for
demultiplexing)

P1
application SMTP HTTP
Proc 25 80 Proc application
application
2345 transport 4235
transport transport
network
network network
link
link link
physical
physical physical
Server
host 1 host 2
(IP S)
(IP 1) (IP 2)
= socket = process
Transport Layer 3-33
How demultiplexing works
• host receives IP packet
• each packet has source IP
32 bits
address, destination IP address
source port # dest port #
• each packet carries 1
transport-layer segment
• each segment has source, other header fields
destination port number
• host uses IP addresses & port numbers application
to direct segment to appropriate socket data
• Two options: (message)

• connectionless = UDP (e.g. for DNS)


• connection oriented = TCP (e.g. for TCP/UDP segment format

HTTP)
Transport Layer 3-34
Connectionless (de)multiplexing ( UDP)
• Create sockets with port • When host receives UDP
numbers: segment:
DatagramSocket serverSocket1 • checks destination port number
= new DatagramSocket(53); in segment
• directs UDP segment to socket
with that port number
• UDP socket identified by
• IP datagrams (packets) with
two-tuple:
different source IP addresses
(dest IP address, dest port number) and/or source port numbers
directed to same socket on
this destination

Transport Layer 3-35


Connectionless (de)multiplexing
DatagramSocket serverSocket = new DatagramSocket(53);

Proc P1
Proc DNS
DNS
2345 53 4235
UDP

SP: 2345 SP: 4235


DP: 53 DP: 53
AC BC
SP: 53 SP: 53

client DP: 2345 DP: 4235 Client


server
IP: A CA CB IP: B
IP: C

Transport Layer 3-36


Source Port (SP) provides “return address” to DNS deamon, not used by UDP
Connection-oriented (de)mux ( TCP)
• TCP socket identified by 4-tuple:
• Server host may support
– source IP address many simultaneous TCP
– source port number sockets:
– dest IP address – each socket identified by its
– dest port number own 4-tuple

• Web servers have different


• receiver uses all four values tosockets for each to
direct segment connecting
appropriate socket client
– non-persistent HTTP will
have different socket for each
request

Transport Layer 3-37


Connection-oriented (de)mux

P1 HTTP

IP : A, C IP : B, C TCP
Port : 80, 9157 Port : 80, 5775

SP: 80 SP: 80
DP: 9157 DP: 5775
CA CB
SP: 9157 SP: 5775

client DP: 80 DP: 80 Client


http
IP: A AC BC IP:B
server
IP: C

New process started for every new client connecting


Two processes from same client will start two processes at server
(only difference in tuple is port at client)
Transport Layer 3-38
20, 21 : FTP
TCP segment structure 23 : Telnet
25 SMTP
80 : HTTP
0-1023 : reserved
>1023 : ephemeral
(short lived) port

16-bit source port number 16-bit destination port number


32-bit sequence number
32-bit acknowledgement number
4-bit unused U A P R S F 16-bit window size
header (6 bits) R C S S Y I
length G K H T N N
16-bit TCP checksum 16-bit urgent pointer

Options (if any)

Data

Transport Layer 3-39


Use of TCP
Port Protocol Description
7 Echo Sends back what is received
9 Discard Discards what is received
13 Daytime Sends back the time of day
20 FTP data Data channel for FTP
21 FTP control Control channel for FTP (get, put, …)
23 Telnet Default port for telnet application
25 SMTP Used for sending email to a mailserver
53 DNS Domain Name System over TCP
80 HTTP Used in the World Wide Web
109 POPv2 Used for reading email on a mailserver
110 POPv3 Used for reading email on a mailserver
111 SUN RPC Sun’s Remote Procedure Call over TCP
119 NNTP Network News Transfer Protocol (newsgroups)
143 IMAP Used for reading email on a mailserver
161-162 SNMP Simple Network Management Protocol
179 BGP Border Gateway Protocol
194 IRC Internet Relay Chat, a chat service
220 IMAPv3 Used for reading email on a mailserver
515 Print Spooler Used in print servers
666 Doom The popular 3D game by Id Software
6000-6063 X11 The X Window System
Transport Layer 3-40

You might also like