Transport Layer

Download Report

Transcript Transport Layer

Transport Layer

Problems with network layer services

Transport layer services

Addressing

Connection establishment and release

Flow control and buffering

Multiplexing

TCP and UDP

Some performance guidelines
1
Ying-Dar [email protected]
Problems with Network Layer Services

Data corruption (while stored in node memory)

Packet loss (due to node failure)

Duplicate packets (if ACK is lost)

Virtual channel loss

Out of sequence

Congestion
Note: Some of the problems exist also at the link level. The
problems here are end-to-end and more difficult to
resolve due to large delay.
2
Ying-Dar [email protected]
Transport Layer Services

Error, loss, duplicate detection and recovery
(by software checksum and message ID)

Sequencing and flow control
(by sliding window protocol)

Connection establishment and release
(by 3-way handshake)

Multiplexing
(upward or downward)
3
Ying-Dar [email protected]
Primitives of Transport Services
PRIMITIVE
TPDU sent
meaning
LISTEN
CONNECT
SEND
RECEIVE
DISCONNECT
none
CONNECTION REQ
DATA
none
DISCONNECTION REQ
block until some process tries to connect
actively attempt to establish a connection
send data
block until a DATA TPDU arrives
want to release the connection
primitive
meaning
SOCKET
BIND
LISTEN
ACCEPT
CONNECT
SEND
RECEIVE
CLOSE
create a new communication end point
attach a local address to a socket
announce willingness to accept connections
block until a connection attempt arrives
actively attempt to establish a connection
send data
receive data
release the connection
socket primitives for TCP
4
Ying-Dar [email protected]
Addressing


TSAP (Transport Service Access Point) -- e.g. (IP addr, local port) in
Internet
NSAP (Network Service Access Point) -- e.g. IP addr in Internet
Three alternative schemes to address TSAP:
1. stable well-known TSAP addresses for common services
(server processes attach themselves to well-known ports)
2. process server that acts as a proxy for less-heavily used
servers (listens to a set of ports to wait for connection
request, spawns off process to serve the client, goes back
to listen for new requests)
3. name server that new services register to
(listens to a well-known TSAP, responds the TSAP of
requested service)
5
Ying-Dar [email protected]
Connection Establishment and Release


Problems of delayed duplicates
Three-way handshake: both sides do not have to start with
the same sequence number
host 1
host 2
CR (seq=x)
ACK (seq=y, ACK=x)
host 1
host 2
host 1
delayed duplicate
CR (seq=x)
host 2
host 1
DR
ACK (seq=y, ACK=x)
DR
DR
lost
ACK
DATA (seq=x, ACK=y)
ACK
REJECT (ACK=y)
host 2
DR
ACK
lost
normal operation
delayed duplicate
normal operation
6
timeout
release connection
Ying-Dar [email protected]
Flow Control and Buffering



Source buffering (for low-bandwidth bursty traffic) vs.
destination buffering (for high bandwidth smooth traffic)
Two potential bottlenecks:
– receive buffer space
– subnet capacity
Dynamic sliding window flow control:
– measure capacity c TPDUs/sec and cycle
time r
– compute window size as cr
– adjust frequently to track changes in the
carrying capacity and cycle time
7
Ying-Dar [email protected]
Multiplexing
TSAP
layer
4
3
2
1
TSAP
NSAP
NSAP
to router
upward multiplexing
downward multiplexing
8
Ying-Dar [email protected]
TCP (Transmission Control Protocol)
A reliable end-to-end byte stream protocol over an unreliable internetwork

socket, connection, segment

TCP header

TCP connection management

TCP transmission management and silly window
syndrome

TCP dynamic window congestion control

TCP dynamic timer management

UDP: encapsulating raw IP
9
Ying-Dar [email protected]
TCP Socket

socket: IP+port (TSAP)

connection: (socket_source, socket_dest)
full-duplex, point-to-point, byte stream

segment: two limits: 65,535 bytes
network’s MTU (max transfer unit)
10
Ying-Dar [email protected]
TCP Header
32 Bits
URG: urgent data
Source port
Urgent pointer: byte offset
Destination port
PSH: PUSHed data (not to buffer it)
Sequence number
RST: reset a connection
SYN, ACK: (1,0)--connection request
Acknowledgement number
TCP
header
length
U
R
G
A
C
K
P
S
H
R
S
T
S
Y
N
F
I
N
Checksum


(1,1)--connection reply
Window size
FIN: release a connection
Window size: receiver window size
Urgent pointer
Options (0 or more 32-bit words)
 header
Checksum: on header, data, psuedo

Data (optional)
Options: max TCP payload (default
536 bytes)
window scale factor (up to
216)
NAK for selective repeat
11
Ying-Dar [email protected]
TCP Connection Management
(START)
CONNECT/SYN
host 1
CLOSED
host 2
CLOSE/LISTEN/-
SYN (SEQ=x)
SYN/SYN+ACK
SYN
RCVD
SYN (SEQ=y,ACK=x+1)
SYN (SEQ=x+1,ACK=y+1)
CLOSE/FIN
Connection establishment
CLOSE/-
LISTEN
RST/-
SEND/SYN
SYN
SENT
SYN/SYN +ACK (simultaneous open)
(Data transfer stage)
SYN + ACK/ACK
ACK/ESTABLISHED
(step 3 of the threeway handshake)
CLOSE/FIN
FIN/ACK
(Active close)
(Passive
Close)
FIN/ACK CLOSING
FIN
WAIT 1
ACK/-
ACK/-
FIN+ACK/ACK
FIN
WAIT 1
FIN/ACK
(Go back to start)
12
TIMED
WAIT
(Timeout/)
CLOSED
CLOSED
WAIT
CLOSE/FIN
LAST
ACK
ACK/-
Ying-Dar [email protected]
TCP Transmission Management and
Silly Window Syndrome




Example: a TELNET TCP connection to an interactive editor
1. Sourcedest: 21-byte TCP data segment (41-byte IP datagram)
2. Sourcedest: acknowledgement segment (40-byte)
3. Sourcedest: window update segment (40-byte)(after editor reads the byte)
4. Sourcedest: echo segment (41-byte) (after editor processes the byted)
5. Repeat step 1, 162 bytes in 4 segments for each character types!!
Silly window syndrome: frequent but mall window updates
1. sending application to TCP one byte at a time
2. receiving application sucks the data up from TCP one byte at a time
Nagle’s algorithm to solve 1:
When data come into the sender one byte at a time, just send the first byte and buffer all the
rest until the outstanding byte is acked.
Clark’s algorithm to solve 2:
The receiver should not send a window update until it can handle the max segment size it
advitised when conn. was established, or its buffer is half empty, whichever is smaller.
13
Ying-Dar [email protected]
TCP Dynamic Window Congestion Control


Two limits: network capacity  congestion window
receiver capacity  receiver window
#bytes that may be sent: min(congestion window, receiver window)
Dynamic window control:
1. Initialization:
congestion windowone maximum segment
threshold64KB
2. Slow start: exponential up to threshold
congestion windowcongestion window + one max segment
size for each acked segment
(Each successful acked burst doubles congestion window)
3. Congestion avoidance: linearly up to receiver window
congestion windowcongestion window + one max segment size for each
acked burst
14
Ying-Dar [email protected]
TCP Congestion Window
Congestion window (kilobytes)
Timeout
8 44
4 40
36
32
28
24
20
16
12
Threshold
Threshold
2
4
6
8 10 12 14 16 18 20 22 24
Transmission number
15
Ying-Dar [email protected]
TCP Dynamic Timer Management

Retransmission timer:
RTT=RTT + (1-)M
(M: measured round-trip delay, ~7/8)
D=D + (1-) |RTT-M|
Timeout=RTT+4*D

Persistent timer: prevent deadlock due to lost window
update

Keepalive timer: for idle connections, controversial!

Close timer: for timed wait state while closing a connection
double the max packet lifetime (2*120 sec)
16
Ying-Dar [email protected]
Design Guidelines at Transport Layer

CPU speed is more important than network speed

Reduce packet count to reduce software overhead

Minimize context switching

Minimize copying

You can buy more bandwidth but not lower delay

Avoiding congestion is better than recovering from it

Avoid timeouts

Speed up TPDU processing
17
Ying-Dar [email protected]