ch3 ResponseCollege
ch3 ResponseCollege
Response college
Transportlaag
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>
TCP
(3.5, 3,7)
,
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>
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
retransmissions: packet
loss
linear due to buffer overflow
increase
congestion
starts
Traffic offered
to the network
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)>
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)
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)
<SEQ=145 (20)>
<SEQ=145 (20)>
<ACK=165>
<SEQ=165 (30)>
<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
TCP RTO
(3.5.3)
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)
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
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 ).
<ACK=145>
<SEQ=145 (20)>
SEQ=165
<ACK=185> waits in
<SEQ=185 (20)> buffer, 145
expected
first
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>
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
Transportlaag –
multiplexing
(3.2)
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)
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
Proc P1
Proc DNS
DNS
2345 53 4235
UDP
P1 HTTP
IP : A, C IP : B, C TCP
Port : 80, 9157 Port : 80, 5775
SP: 80 SP: 80
DP: 9157 DP: 5775
CA CB
SP: 9157 SP: 5775
Data