0% found this document useful (0 votes)
125 views26 pages

Chapter 3 Outline: 3.5 Connection-Oriented Transport: TCP

The document outlines topics related to transport layer services and protocols in computer networking. Section 3.1 discusses transport layer services, while sections 3.2-3.4 cover concepts like multiplexing, demultiplexing, connectionless transport using UDP, and principles of reliable data transfer. Sections 3.5-3.7 focus on the connection-oriented transport protocol TCP, including its segment structure, reliable data transfer using mechanisms like cumulative acknowledgments and retransmissions, and congestion control principles.

Uploaded by

JUNJIE HU
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
125 views26 pages

Chapter 3 Outline: 3.5 Connection-Oriented Transport: TCP

The document outlines topics related to transport layer services and protocols in computer networking. Section 3.1 discusses transport layer services, while sections 3.2-3.4 cover concepts like multiplexing, demultiplexing, connectionless transport using UDP, and principles of reliable data transfer. Sections 3.5-3.7 focus on the connection-oriented transport protocol TCP, including its segment structure, reliable data transfer using mechanisms like cumulative acknowledgments and retransmissions, and congestion control principles.

Uploaded by

JUNJIE HU
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 26

Chapter 3 outline

 3.1 Transport-layer  3.5 Connection-oriented


services transport: TCP
 3.2 Multiplexing and  segment structure
demultiplexing  reliable data transfer
flow control
 3.3 Connectionless

connection management
transport: UDP 

 3.6 Principles of
 3.4 Principles of
reliable data transfer congestion control
 3.7 TCP congestion
control

Transport Layer 3-1


TCP: Overview RFCs: 793, 1122, 1323, 2018, 2581

 point-to-point:  full duplex data:


 one sender, one receiver  bi-directional data flow

 reliable, in-order byte in same connection


 MSS: maximum segment
steam:
size
 no “message boundaries”
 connection-oriented:
 pipelined:
 handshaking (exchange
 TCP congestion and flow
of control msgs) init’s
control set window size sender, receiver state
 send & receive buffers before data exchange
 flow controlled:
 sender will not
application application
writes data reads data
socket socket

overwhelm receiver
door door
TCP TCP
send buffer receive buffer
segment

Transport Layer 3-2


TCP segment structure
32 bits
URG: urgent data counting
(generally not used) source port # dest port #
by bytes
sequence number of data
ACK: ACK #
valid acknowledgement number (not segments!)
head not
PSH: push data now len used
UA P R S F Receive window
(generally not used) # bytes
checksum Urg data pnter
rcvr willing
RST, SYN, FIN: to accept
Options (variable length)
connection estab
(setup, teardown
commands)
application
Internet data
checksum (variable length)
(as in UDP)

Transport Layer 3-3


TCP seq. #’s and ACKs
Seq. #’s:
Host A Host B
 byte stream
“number” of first User
types
byte in segment’s ‘C’
data host ACKs
receipt of
ACKs: ‘C’, echoes
 seq # of next byte back ‘C’
expected from
other side host ACKs
 cumulative ACK receipt
of echoed
Q: how receiver handles ‘C’
out-of-order segments
 A: TCP spec doesn’t
time
say, - up to
simple telnet scenario
implementor
Transport Layer 3-4
TCP Round Trip Time and Timeout
Q: how to set TCP Q: how to estimate RTT?
timeout value?  SampleRTT: measured time from
 longer than RTT segment transmission until ACK
 but RTT varies
receipt
 ignore retransmissions
 too short: premature
timeout  SampleRTT will vary, want
 unnecessary
estimated RTT “smoother”
retransmissions  average several recent

 too long: slow reaction


measurements, not just
to segment loss current SampleRTT

Transport Layer 3-5


TCP Round Trip Time and Timeout
EstimatedRTT = (1- )*EstimatedRTT + *SampleRTT

 Exponential weighted moving average


 influence of past sample decreases exponentially fast
 typical value:  = 0.125

Transport Layer 3-6


Example RTT estimation:
RTT: gaia.cs.umass.edu to fantasia.eurecom.fr

350

300

250
RTT (milliseconds)

200

150

100
1 8 15 22 29 36 43 50 57 64 71 78 85 92 99 106
time (seconnds)

SampleRTT Estimated RTT

Transport Layer 3-7


TCP Round Trip Time and Timeout
Setting the timeout
 EstimtedRTT plus “safety margin”
 large variation in EstimatedRTT -> larger safety margin
 first estimate of how much SampleRTT deviates from
EstimatedRTT:

DevRTT = (1-)*DevRTT +
*|SampleRTT-EstimatedRTT|

(typically,  = 0.25)

Then set timeout interval:

TimeoutInterval = EstimatedRTT + 4*DevRTT

Transport Layer 3-8


Chapter 3 outline
 3.1 Transport-layer  3.5 Connection-oriented
services transport: TCP
 3.2 Multiplexing and  segment structure
demultiplexing  reliable data transfer
flow control
 3.3 Connectionless

connection management
transport: UDP 

 3.6 Principles of
 3.4 Principles of
reliable data transfer congestion control
 3.7 TCP congestion
control

Transport Layer 3-9


TCP reliable data transfer
 TCP creates rdt  Retransmissions are
service on top of IP’s triggered by:
unreliable service  timeout events
 Pipelined segments  duplicate acks
 Cumulative acks  Initially consider
 TCP uses single
simplified TCP sender:
ignore duplicate acks
retransmission timer 
 ignore flow control,
congestion control

Transport Layer 3-10


TCP sender events:
data rcvd from app: timeout:
 Create segment with  retransmit segment
seq # that caused timeout
 seq # is byte-stream  restart timer
number of first data Ack rcvd:
byte in segment  If acknowledges
 start timer if not previously unacked
already running (think segments
of timer as for oldest  update what is known to
unacked segment) be acked
 expiration interval:  start timer if there are
TimeOutInterval outstanding segments

Transport Layer 3-11


NextSeqNum = InitialSeqNum
SendBase = InitialSeqNum

loop (forever) { TCP


sender
switch(event)

event: data received from application above


create TCP segment with sequence number NextSeqNum (simplified)
if (timer currently not running)
start timer
pass segment to IP Comment:
NextSeqNum = NextSeqNum + length(data)
• SendBase-1: last
event: timer timeout cumulatively
retransmit not-yet-acknowledged segment with ack’ed byte
smallest sequence number Example:
start timer • SendBase-1 = 71;
y= 73, so the rcvr
event: ACK received, with ACK field value of y wants 73+ ;
if (y > SendBase) { y > SendBase, so
SendBase = y
that new data is
if (there are currently not-yet-acknowledged segments)
start timer acked
}

} /* end of loop forever */


Transport Layer 3-12
TCP: retransmission scenarios
Host A Host B Host A Host B

Seq=92 timeout
timeout

X
loss

Sendbase
= 100

Seq=92 timeout
SendBase
= 120

SendBase
= 100 SendBase
= 120 premature timeout
time time
lost ACK scenario
Transport Layer 3-13
TCP retransmission scenarios (more)
Host A Host B
timeout

X
loss

SendBase
= 120

time
Cumulative ACK scenario

Transport Layer 3-14


TCP ACK generation [RFC 1122, RFC 2581]

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 cumulative


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-15


Fast Retransmit
 Time-out period often  If sender receives 3
relatively long: ACKs for the same
 long delay before data, it supposes that
resending lost packet segment after ACKed
 Detect lost segments data was lost:
via duplicate ACKs.  fast retransmit: resend
 Sender often sends segment before timer
many segments back-to- expires
back
 If segment is lost,
there will likely be many
duplicate ACKs.

Transport Layer 3-16


Host A Host B

X
timeout

time

Figure 3.37 Resending a segment after triple duplicate ACK Layer


Transport 3-17
Fast retransmit algorithm:

event: ACK received, with ACK field value of y


if (y > SendBase) {
SendBase = y
if (there are currently not-yet-acknowledged segments)
start timer
}
else {
increment count of dup ACKs received for y
if (count of dup ACKs received for y = 3) {
resend segment with sequence number y
}

a duplicate ACK for fast retransmit


already ACKed segment

Transport Layer 3-18


Chapter 3 outline
 3.1 Transport-layer  3.5 Connection-oriented
services transport: TCP
 3.2 Multiplexing and  segment structure
demultiplexing  reliable data transfer
flow control
 3.3 Connectionless

connection management
transport: UDP 

 3.6 Principles of
 3.4 Principles of
reliable data transfer congestion control
 3.7 TCP congestion
control

Transport Layer 3-19


TCP Flow Control
flow control
sender won’t overflow
 receive side of TCP receiver’s buffer by
connection has a transmitting too much,
receive buffer: too fast

 speed-matching
service: matching the
send rate to the
receiving app’s drain
rate
 app process may be
slow at reading from
buffer
Transport Layer 3-20
TCP Flow control: how it works
 Rcvr advertises spare
room by including value
of RcvWindow in
segments
 Sender limits unACKed
(Suppose TCP receiver data to RcvWindow
discards out-of-order  guarantees receive
segments) buffer doesn’t overflow
 spare room in buffer
= RcvWindow
= RcvBuffer-[LastByteRcvd -
LastByteRead]

Transport Layer 3-21


Chapter 3 outline
 3.1 Transport-layer  3.5 Connection-oriented
services transport: TCP
 3.2 Multiplexing and  segment structure
demultiplexing  reliable data transfer
flow control
 3.3 Connectionless

connection management
transport: UDP 

 3.6 Principles of
 3.4 Principles of
reliable data transfer congestion control
 3.7 TCP congestion
control

Transport Layer 3-22


TCP Connection Management
Recall: TCP sender, receiver Three way handshake:
establish “connection”
before exchanging data Step 1: client host sends TCP
segments SYN segment to server
 initialize TCP variables:  specifies initial seq #

 seq. #s  no data

 buffers, flow control Step 2: server host receives


info (e.g. RcvWindow) SYN, replies with SYNACK
 client: connection initiator segment
Socket clientSocket = new
 server allocates buffers
Socket("hostname","port
 specifies server initial
number");
seq. #
 server: contacted by client
Socket connectionSocket =
Step 3: client receives SYNACK,
welcomeSocket.accept(); replies with ACK segment,
which may contain data

Transport Layer 3-23


TCP Connection Management (cont.)

Closing a connection: client server

close
client closes socket:
clientSocket.close();

Step 1: client end system close


sends TCP FIN control
segment to server

timed wait
Step 2: server receives
FIN, replies with ACK.
Closes connection, sends
FIN. closed

Transport Layer 3-24


TCP Connection Management (cont.)

Step 3: client receives FIN, client server


replies with ACK. closing
 Enters “timed wait” -
will respond with ACK
to received FINs
closing
Step 4: server, receives
ACK. Connection closed.

timed wait
Note: with small
closed
modification, can handle
simultaneous FINs.
closed

Transport Layer 3-25


TCP Connection Management (cont)

TCP server
lifecycle

TCP client
lifecycle

Transport Layer 3-26

You might also like