Data and Computer Communications
Data and Computer Communications
Communications
Chapter 20 – Transport Protocols
Eighth Edition
by William Stallings
Solution: to acknowledge
explicitly the other’s SYN
and seq. number
Three way handshake
Three Way
Handshake:
State
Diagram
Three Way
Handshake:
Examples
Connection Termination
like connection need 3-way handshake
misordered segments could cause:
entity in CLOSE WAIT state sends last data segment,
followed by FIN
FIN arrives before last data segment
receiver accepts FIN, closes connection, loses data
need to associate sequence number with FIN
receiver waits for all segments before FIN
sequence number
Connection Termination
Graceful Close
also have problems with loss of segments
and obsolete segments
need graceful close which will:
send FIN i and receive AN i+1 (close S -> R)
receive FIN j and send AN j+1 (close S <- R)
wait twice maximum expected segment
lifetime
Failure Recovery
after restart all state info is lost
may have half open connection
as side that did not crash still thinks it is connected
close connection using keepalive timer
wait for ACK for (time out) * (number of retries)
when expired, close connection and inform user
send RST i in response to any i segment arriving
user must decide whether to reconnect
have problems with lost or duplicate data
TCP
Transmission Control Protocol (RFC 793)
connection oriented, reliable communication
over reliable and unreliable (inter)networks
two ways of labeling data:
data stream push
user requires transmission of all data up to push flag
receiver will deliver in same manner
avoids waiting for full buffers
urgent data signal
indicates urgent data is upcoming in stream
user decides how to handle it
TCP Services
a complex set of primitives:
incl. passive & active open, active open with
data, send, allocate, close, abort, status
passive open indicates will accept connections
active open with data sends data with open
and parameters:
incl. source port, destination port & address,
timeout, security, data, data length, PUSH &
URGENT flags, send & receive windows,
connection state, amount awaiting ACK
TCP Header
TCP and IP
not all parameters used by TCP are in its
header
TCP passes some parameters down to IP
precedence
normal delay/low delay
normal throughput/high throughput
normal reliability/high reliability
security
min overhead for each PDU is 40 octets
TCP Mechanisms
Connection Establishment
three way handshake
SYN, SYN-ACK, ACK
connection determined by source and
destination sockets (host, port)
can only have a single connection
between any unique pairs of ports
but one port can connect to multiple
different destinations (different ports)
TCP Mechanisms
Data Transfer
data transfer a logical stream of octets
octets numbered modulo 232
flow control uses credit allocation of number of
octets
data buffered at transmitter and receiver
sent when transport entity ready
unless PUSH flag used to force send
can flag data as URGENT, sent immediately
if receive data not for current connection, RST
flag is set on next segment to reset connection
TCP Mechanisms
Connection Termination
graceful close
TCP user issues CLOSE primitive
transport entity sets FIN flag on last segment sent
with last of data
abrupt termination by ABORT primitive
entity abandons all attempts to send or receive data
RST segment transmitted to other end
TCP Implementation Options
TCP standard precisely specifies protocol
have some implementation policy options:
send
deliver
accept
retransmit
acknowledge
implementations may choose alternative
options which may impact performance
Send Policy
if no push or close TCP entity transmits at
its own convenience in credit allocation
data buffered in transmit buffer
may construct segment per batch of data
from user
quick response but higher overheads
may wait for certain amount of data
slower response but lower overheads
Deliver Policy
in absence of push, can deliver data at
own convenience
may deliver from each segment received
higher O/S overheads but more responsive
may buffer data from multiple segments
less O/S overheads but slower
Accept Policy
segments may arrive out of order
in order
only accept segments in order
discard out of order segments
simple implementation, but burdens network
in windows
accept all segments within receive window
reduce transmissions
more complex implementation with buffering
Retransmit Policy
TCP has a queue of segments transmitted
but not acknowledged
will retransmit if not ACKed in given time
first only - single timer, send one segment only
when timer expires, efficient, has delays
batch - single timer, send all segments when
timer expires, has unnecessary transmissions
individual - timer for each segment, complex
effectiveness depends in part on receiver’s
accept policy
Acknowledgement Policy
immediate
send empty ACK for each accepted segment
simple at cost of extra transmissions
cumulative
piggyback ACK on suitable outbound data
segments unless persist timer expires
when send empty ACK
more complex but efficient
Congestion Control
flow control also used for congestion control
recognize increased transit times & dropped
packets
react by reducing flow of data
RFC’s 1122 & 2581 detail extensions
Tahoe, Reno & NewReno implementations
two categories of extensions:
retransmission timer management
window management
Retransmission Timer
Management
static timer likely too long or too short
estimate round trip delay by observing pattern of
delay for recent segments
set time to value a bit greater than estimate
simple average over a number of segments
exponential average using time series (RFC793)
RTT Variance Estimation (Jacobson’s algorithm)
Retransmission Timer (cont)
Simple Average
RTT(i): round-trip time observed for the ith
transmitted segment
ARTT(K): average round-trip time for the
first K segments
1 K 1
ARTT ( K 1)
K 1 i 1
RTT (i ) or
K 1
ARTT ( K 1) ARTT ( K ) RTT ( K 1)
K 1 K 1
Retransmission Timer (cont)
Exponential Average
SRTT: smoothed round-trip time estimate
RTO: retransmission timer
K 1
ADEV ( K ) AERR ( K 1)
K 1 K 1
RTT Variance Estimation (cont)
Jacobson’s Algorithm
Averaging
Jacobson’s
RTO
Calculation
Exponential RTO Backoff
timeout probably due to congestion
dropped packet or long round trip time
hence maintaining RTO is not good idea
better to increase RTO each time a
segment is re-transmitted
RTO = q*RTO
commonly q=2 (binary exponential backoff)
as in ethernet CSMA/CD
Karn’s Algorithm
if segment is re-transmitted, ACK may be for:
first copy of the segment (longer RTT than expected)
second copy
no way to tell
don’t measure RTT for re-transmitted segments
calculate backoff when re-transmission occurs
use backoff RTO until ACK arrives for segment
that has not been re-transmitted
Window Management
slow start
larger windows cause problem on connection created
at start limit TCP to 1 segment
increase when data ACK, exponential growth
dynamic windows sizing on congestion
when a timeout occurs perhaps due to congestion
set slow start threshold to half current congestion
window
set window to 1 and slow start until threshold
beyond threshold, increase window by 1 for each RTT
Window Management
Fast Retransmit
Fast Recovery
retransmit timer rather longer than RTT
if segment lost TCP slow to retransmit
fast retransmit
if receive 4 ACKs for same segment then
immediately retransmit since likely lost
fast recovery
lost segment means some congestion
halve window then increase linearly
avoids slow-start
TCP Congestion Control
Fast retransmit
(Receiver)
Fast Recovery
(Sender cwnd)
Implementation of TCP
Congestion Control Measures
Flow Ctrl vs. Congestion Ctrl
Why Flow Control? Why Congestion Control?
Receiver-based Network-based
window size window size
(rwnd) (cwnd)
只針對「計算機網路」這門課程:
① 有關老師的教學,你覺得哪一些是好的
方式,為什麼?
② 就你的觀察,老師的教學過程中有哪一
些是不合適這門課的,為什麼?
③ 請提供其他可以改進教學的建議。