electronic computer
Chapter Eight
The Transport Layer
*
Objectives
- Take a look at some other forms of logical addressing.
- Examine the process of encapsulation.
- Take a closer look at flow control.
- Examine error correction/detection in detail.
- See how the Transport layer controls congestion on the network.
*
The Transport Layer
- The responsibilities of the Transport Layer are:
- Handle end-to-end addressing
- Repackage long message into smaller segments for transmission
- At the receiving end, rebuild packets into the original message
- Monitor flow control of data
- Handle end-to-end error detection and recovery
- Handle congestion control on the network
*
The Transport Layer
- Why do we need transport layer?
- Network layer is focused on the routers. It provides logical communication between hosts.
- Transport layer runs on end-user devices. It provides logical communication between processes
Household analogy:
12 kids sending letters
to 12 kids
processes = kids
app messages = letters
in envelopes
hosts = houses
transport protocol =
John and Bill
network
-
layer protocol
= postal service
*
Addressing in the Transport Layer
- Ports and sockets can tell the OS what data is intended for what applications.
- Ports are 16-bit numbers that identify applications or processes.
- Sockets are a logical address consisting of a combination of a port and an IP address.
*
Ports
- Well-known ports
- Assigned by Internet Assigned Number Authority (IANA)
- Occupy ports 0 through 1023
- Ephemeral ports
- Used by the client software to establish a link between applications
- Generally assigned by the application when it launches
*
Some Commonly Used Ports
Port
Protocol
20
FTP, File Transfer Protocol, data
21
FTP, File Transfer Protocol, control
23
Telnet
25
SMTP, Simple Mail Transfer Protocol
80
HTTP, HyperText Transfer Protocol
109
POP, Post Office Protocol, version 2
110
POP, Post Office Protocol, version 3
666
Doom, ID software
*
Transport Layer Connections
- Connectionless connections
- No virtual connection is created.
- Data is basically thrown out onto the wire and the transmitting workstation assumes it will arrive safely.
- The UDP is an example of a connectionless service
- Connection-oriented connections
- A virtual connection is created.
- For every packet transmitted, either an ACK or a NACK must be returned.
- The TCP is an example of connection-oriented service
*
UDP
- often used for streaming multimedia apps
loss tolerant
rate sensitive
- other UDP uses
DNS
source port #
dest port #
32 bits
data
UDP segment format
length
checksum
Length, in
bytes of UDP
segment,
including
header
*
The Real-Time Transport Protocol
- RFC 1889
- Basic function of RTP is to Multiplex several real-time data streams onto a single UDP stream
- (a) The position of RTP in the protocol stack. (b) Packet nesting.
*
TCP segment structure
source port #
dest port #
32 bits
application
data
(variable length)
sequence number
acknowledgement number
Receive window
Urg
data
pnter
checksum
F
S
R
P
A
U
head
len
not
used
Options (variable length)
source port #
dest port #
32 bits
application
data
(variable length)
sequence number
acknowledgement number
Receive window
Urg
data
pnter
checksum
F
S
R
P
A
U
head
len
not
used
Options (variable length)
URG: urgent data
(generally not used)
ACK: ACK #
valid
PSH: push data now
(generally not used)
RST, SYN, FIN:
Connection’
estab
(setup, teardown
commands)
# bytes
rcvr
willing
to accept
counting
by bytes
of data
(not segments!)
Internet
checksum
(as in UDP)
*
TCP segment structure
- A 32-bit sequence number keeps packets in order.
- A 32-bit acknowledgement number is used to verify the packet.
- 4-bit Header Length – Indicate the size of the entire TCP header the receiver
- URG – 0 or 1. When set to 1, this bit indicate the urgent pointer field is valid and should be considered.
- ACK – 0 or 1. When set to 1, this bit indicates that acknowledgement number field is valid and being used
*
TCP segment structure
- A window sized field dictates how many packets will be sent before waiting for ACKS.
- PSH – 0 or 1. When set to 1, this bit tells the receiver to pass all data received at the point to the receiving application immediately.
- RST – 0 or 1. This bit indicates an error condition has been detected and notify the receiver to reset the connection
*
TCP segment structure
- SYN – 0 or 1. This bit synchronizes the sequence numbers in order to establish a connection
- 16 bit TCP checksum – ensure that the TCP header has not been modified in transmit
- 16-bit Urgent Pointer – This pointer is added to the sequence number field to yield the sequence number of urgent data.
*
Flow Control
- Buffer overflow
- Memory fills; transmission stops
- Stop and wait
- Send a frame and wait for the reply
- Neither methods very useful for busy networks
- Rarely used
socket
door
TCP
send buffer
TCP
receive buffer
socket
door
segment
application
writes data
application
reads data
*
Advanced Flow Control
- Static window
- A fixed number of frames are transmitted.
- The transmitting station waits for the replies.
- No adjustments in transmission speed can be made.
- Sliding window
- It starts with a higher number of frames.
- As failures occur, the number of frames transmitted drops.
- If a frame is dropped, that frame and all frames following it will get retransmitted.
*
MORE Flow Control
- Selectively repeat
- A number of frames are transmitted.
- If a failure occurs, only the bad packets need to be transmitted.
*
MORE Flow Control
- Go Back N
- It is similar to sliding window except that a single ACK is sent for all frames in a window.
- If a failure occurs, the protocol counts back the correct number of frames and retransmits all.
*
Error Control in Transport
- The error correction in Data Link was bit-level error correction.
- If user data was corrupted, the error was detected and, if possible, fixed.
- Transport layer error correction is end-to-end.
- There may have error during encapsulation
- If a packet is lost or corrupted, the error is fixed.
*
Error Control in Transport
- Packet level errors can include packet loss, packet corruption, and packet duplication. The network uses
- three-way handshake
- sequence number
- time-out for each packet
*
TCP Connection Establishment
- Recall: TCP sender, receiver establish connection before exchanging data segments
- initialize TCP variables:
- seq. #s
- buffers, flow control info (e.g. RcvWindow)
Three way handshake:
Step 1:
client host sends TCP
SYN segment to server
specifies initial
seq
#
no data
Step 2:
server host receives
SYN, replies with SYNACK
segment
server allocates buffers
specifies server initial
seq. #
Step 3:
client receives SYNACK,
replies with ACK segment,
which may contain data
*
TCP Connection Establishment
- (a) TCP connection establishment in the normal case.
- (b) Call collision. – only one connection is established
*
TCP Connection Close
- Closing a connection:
- Step 1: client end system sends TCP FIN control segment to server
- Step 2: server receives FIN, replies with ACK. Closes connection, sends FIN.
- Step 3: client receives FIN, replies with ACK.
- Step 4: server, receives ACK. Connection closed.
client
FIN
server
ACK
ACK
FIN
close
close
closed
timed wait
client
FIN
server
ACK
ACK
FIN
close
close
closed
timed wait
*
Principles of Congestion Control
- Congestion:
- informally: too many sources sending too much data too fast for network to handle
- different from flow control!
- manifestations:
- lost packets (buffer overflow at routers)
- long delays (queueing in router buffers)
- a top-10 problem!
*
Congestion Control
- (a) A fast network feeding a low capacity receiver.
- (b) A slow network feeding a high-capacity receiver.
*
Congestion Control
- No single device can control overall network congestion.
- Therefore, Transport does what it can to make sure THIS DEVICE does not contribute to congestion.
- Connections requiring excessive retransmission of data are dropped.
*
Approaches towards congestion control
- End-end congestion control:
- no explicit feedback from network
- congestion inferred from end-system observed loss, delay
- approach taken by TCP
- Network-assisted congestion control:
- routers provide feedback to end systems
- single bit indicating congestion (SNA, DECbit, TCP/IP ECN, ATM)
- explicit rate sender should send at
Two broad approaches towards congestion control:
*
TCP Congestion Control
- Slow start (Jacobson 1998)
- Start with the maximum segment size
- If this is acknowledge then double the window size
- Send two maximum segemnt size
- Repeat
- When the CongWin = threshold, increase linearly.
- Threshold = 1/2 of CongWin value before timeout.
- Initially 64KB in addition to receiver flow control and congestion control window
- When timeout occur
- reduce threshold to half of the congestion window
- Congestion window is reset to 1 segment
*
Slow Start
- When connection begins, increase rate exponentially until threshold:
- double CongWin every RTT
- done by incrementing CongWin for every ACK received
- Summary: initial rate is slow but ramps up exponentially fast
Host A
one segment
RTT
Host B
time
time
two segments
four segments
*
TCP Congestion Control (2)
- An example of the Internet congestion algorithm.
*
Summary: TCP Congestion Control
- When CongWin is below Threshold, sender in slow-start phase, window grows exponentially.
- When CongWin is above Threshold, sender is in congestion-avoidance phase, window grows linearly.
- When timeout occurs, Threshold set to CongWin/2 and CongWin is set to 1 MSS.
*
TCP Round Trip Time and Timeout
- Q: how to set TCP timeout value?
- longer than RTT
- but RTT varies
- too short: premature timeout
- unnecessary retransmissions
- too long: slow reaction to segment loss
- Q: how to estimate RTT?
- SampleRTT: measured time from segment transmission until ACK receipt
- ignore retransmissions
- SampleRTT will vary, want estimated RTT smoother
- average several recent measurements, not just current SampleRTT
*
TCP Timer Management
- Variable Retransmission based on RTT
- Timeout based on Round Trip Time (RTT)
- RTT = αRTT + (1-α)M
- M is the time the ack received
- α is smoothing factor typically 7/8
- A better estimate
- Timeout = RTT + 4xD
- D = αD + (1-α)|RTT-M|
- Karn’s Algorithm
- Do not use RTT if retransmission happens
- Time out is doubled on every failure
*
Example RTT estimation:
RTT: gaia.cs.umass.edu to fantasia.eurecom.fr
100
150
200
250
300
350
1
8
15
22
29
36
43
50
57
64
71
78
85
92
99
106
time (seconnds)
RTT (milliseconds)
SampleRTT
Estimated RTT
*