Title: Transport Protocols:
1- Transport Protocols
- UDP and TCP
2Expected Properties
- Guaranteed message delivery
- Message order preservation
- No duplication of messages
- Support for arbitrarily large messages
- Support for sender/receiver synchronization
- Receiver based flow control
- Support multiple application processes per host
3Relationship with other layers
What are the expectations of the functionality
provided by underlying layers?
Application
Add to the functionality provided by Transport
Higher layers
Transport
Provides end-to-end features
Network
May drop, reorder, or duplicate messages. May
introduce arbitrarily long delays. May
limit the size of messages to a maximum value.
4Transport Algorithms
- Simple asynchronous demultiplexing service
Reliable byte-stream service
Request/reply service
5Simple Asynchronous DemultiplexingUDP
UDP PDU format
6Reliable Byte Stream TCP
- Use the concept of ports to demultiplex streams
to the same host. - Guarantees reliable, in-order delivery of a
stream of bytes without duplication. - Implements flow-control allowing the receiver to
throttle the volume of data transmitted by the
sender.
Question What is the difference between
flow-control and congestion-control?
7Segment Format
- TCP is a byte-oriented protocol.
Question What are the performance considerations
that drive the implementation of such a protocol?
8TCP Header Fields
- Acknowledgement, SequenceNum, AdvertiseWindow
for TCP sliding window algorithm - UrgPtr field indicates where the non-urgent data
begins
9TCP Header Fields (2)
- 6-bits flags (in this order from low to high)
- URG signifies that this segment contains urgent
data - ACK is set when Acknowledgment is valid
- PUSH signifies that the sender invoked the push
operation - RESET signifies to abort the connection
- SYN, FIN used in establishing and terminating a
TCP connection
10TCP Connection Establishment
Three-Way Handshake
11Socket Functions
socket()
TCP Server
bind()
TCP Client
socket()
listen()
accept()
connect()
TCP 3-way handshake
block until connection from client
data (request)
write()
read()
process request
data (reply)
write()
read()
end-of-file notification
read()
close()
close()
12State Transition Diagram
Question How do your implement such a complex
protocol?
Question How do you verify that your
implementation conforms to the specifications?
Note Arcs are labeled with event/action.
13Sliding Window
- TCPs sliding window algorithm
- Guarantees reliable delivery.
- Guarantees in-order delivery.
- Enforces flow control.
- Look again at the TCP segment header
The receiver tells the sender the number of
unacknowledged bytes of data it will allow (based
on buffer size).
14 Flow Control
LastByteAcked lt LastByteSent
LastByteRead lt NextByteExpected
NextByteExpected lt LastByteRcvd1
LastByteSent lt LastByteWritten
LastByteRcvd LastByteRead lt MaxRcvBuffer
LastByteSent-LastByteAcked lt AdvertisedWindow
AdvertisedWindow MaxRcvBuffer
((NextByteExpected-1)-LastByteRead)
EffectiveWindowAdvertisedWindow-
(LastByteSent-LastByteAcked)
LastByteWritten LastByteAcked lt MaxSendBuffer
15When The Window Hits Zero
- If the AdvertisedWindow reaches zero, the sender
is not permitted to send any more data. - TCP always sends a segment in response to a
received data segment with the latest values for
Acknowledge and AdvertisedWindow. The receiver
doesnt, however, send a non-data segment with
AdvertisedWindow.
Question How does would the sender learn that
the AdvertisedWindow has become greater than zero?
16Senders Probe
- The sender persistently in sending a segment with
1 byte of data every so often to trigger the
AdvertisedWindow to be sent. - The sender initiates actions! This is true in
many applications, not just networking (e.g. in
load sharing, sender-initiated vs. receiver
initiated). - This is often called smart sender/dumb receiver
rule, an important protocol design rule.
17Window Sequence Wraparound
- Currently the sequence number is 32 bits
- Theoretically this number can wrap around if a
connection stays long and plenty of data to
transfer - But MSL (Maximum Segment Lifetime) is currently
set to be 120 second. So as long as the sequence
number cant be consumed in this period of time,
we are safe. - How fast the 32-bit sequence number can be
consumed?
18Time until 32-bit sequence number space wrap
around
19Keeping the pipe full
- 16-bit AdvertisedWindow can specify at most 64
Kbytes widow. Is this enough to keep the pipe
full? - Use delay X bandwidth product, assume a 100-ms
RTT, currently we cant even serve T3 network
when the traffic is two-way (see next page for a
table)
20Required window size for 100-ms RTT
21Triggering Transmission
- Question How should TCP decide to send a
segment? - (You can answer this ignoring flow control for
now.)
Sending application
- As soon as MSS (maximum segment size) bytes have
been collected from sender. - Whenever the sending application explicitly
requests it (push). - Whenever a timer fires and then however many
bytes have been buffered so far are sent.
TCP
22Maximum Segment Size (MSS)
Rule of thumb Usually set to the size of the
largest segment TCP can send without causing the
local IP to fragment.
IP header
TCP header
MSS sizeof(MTU) - sizeof(IP header)
sizeof(TCP header)
MTU of the directly connected network
23Aggressive Send
- Now, consider what happens in the presence of
flow control - AdvertisedWindow0, so the sender is accumulating
bytes to send. - ACK arrives and AdvertisedWindowMSS/2.
- Question Should the sender go ahead and send
MSS/2 or wait for AdvertisedWindow to increase
all the way to MSS?
24Silly Window Syndrome
- Consequence of aggressively taking advantage of
any available window. Think of the TCP stream as
a conveyor belt
full data containers
empty data containers (ACKs)
If the sender fills an empty container as soon as
it arrives, the any small container introduced
into the system remains indefinitely it is
immediately filled and emptied in each end.
25Nagles Algorithm
- Goal Make the sender application wait long
enough so that small containers are coalesced
into larger ones, but not so much that
interactive applications will suffer.
Algorithm when (application has data to send)
if (available datagtMSS) (AdvertisedWindowgtMS
S) send full segment else if (unACKed data
in transit) buffer the new data until an ACK
arrives else send all the new data
immediately
PS On by default on a TCP socket option
TCP_NODELAY turns it off.