Operating Systems Lecture Notes
9 April 2012 • Transport Services
Outline
Transport protocols: UDP and TCP.
Transport abstractions and APIs.
TCP
Implementing TCP.
TCP segments and packets.
Flow and congestion control.
Level 4
ISO OSI level 4: transport services.
The transport level ties together individual networks into a single network.
Initially via overlay networks, now more directly.
Uniform addressing, and a small amount of global structure.
Transport Protocols
Transmission control protocol
(
TCP
) and the
user datagram protocol
(
UDP
) are two major transport protocols.
TP4 is ISO’s failed entry.
Most other examples also lost to TCP/IP.
The operating system is responsible for implementing the protocol.
The networking subsystem, in particular.
UDP
UDP provides a few simple end-to-end services:
Per-host multiplexing via 16-bit
port numbers
.
Unreliable datagram delivery.
A
datagram
is a block of data (not as structured as a message).
“Unreliable” means: loss, corruption, duplication, unordered.
TCP
TCP an overtly simpler but covertly more complex protocol.
TCP services include:
Per-host multiplexing over 16-bit port numbers (independent of UDP).
Reliable byte streams.
“Reliable” means: uncorrupted, ordered.
Transport Abstractions
Transport services initially look typical: data gets written, data gets read. But
Different read-write patterns (reliability, network delay).
Complex transport-services characterizations.
Transport services should look like other information-oriented services.
With some control-oriented services too.
A lot like files.
Transport APIs
Transport services should be available through file-like APIs.
And sometimes they are.
Unfortunately, the Sockets API from BSD
Unix
won the race.
The Sockets API is a perfect example of what happens when you violate the YAGNI principle.
Connections
TCP is
connection-oriented
.
A
connection
is a long-term, explicit relation between communicating end-points.
Binding
establishes one end of a connection.
UDP is
connection-less
.
But the end-point terminology carries through.
TCP Connection States
Much complexity (TCP or Sockets) arises from
connection states
.
A rough list of states include:
Bound or unbound: connection end-points assigned or not.
Connected or listening: both end-point bound or not.
Closed: amazingly complex (half-closed, time waiting).
UDP avoids this.
TCP States Illustrated
Implementing TCP
The operating system implements the TCP reliable byte-stream abstraction.
Operating system → networking subsystem → TCP protocol stack.
Byte-stream reliability comes from acknowledgments and timeout-retransmission.
Send data blocks.
Get acknowledgment and move on, or
timeout and retransmit.
Network Management
The TCP protocol stack should also react to network conditions, and conditions at the other end.
Congestion and flow control.
Both are based on varying the block-write characteristics.
Sending rate and, less variably, sending size.
TCP Segments
The data blocks sent and received are called
segments
.
Buffering’s important in TCP.
Assembling data into segments.
Holding segments for retransmission.
Many games are possible by manipulating TCP buffering.
Slow start, Nagle’s algorithm.
TCP Packets
A segment is preceded by a
TCP header
to form a
TCP packet
.
Flow Control
For best throughput, send everything at once.
Receiver hostile, particularly for less capable receivers.
Keep the number of unacknowledged packets at some maximum value, the
window size
.
As packets get acknowledged, shift the window further up the data stream.
This is
window-based flow control
.
Congestion Control
For best throughput, send everything at once.
Network hostile as a global behavior.
Keep the number of unacknowledged packets at the window size.
As packets get acknowledged, send more and increase the window size.
Acknowledgment time-outs reduce the window size.
This is
slow-start congestion control
.
Summary
Transport services are the most convenient (most abstract) of the ISO networking services.
But even then they’re not so great.
Transport services are end-to-end.
TCP and UDP are the best known, most used transport protocols.
TCP: reliable byte streams.
UDP: best-effort datagrams.
References
Transmission Control Protocol
, RFC 793, 1981.
User Datagram Protocol
, RFC 768, by Jon Postel, 1980.
Credits
TCP state diagram.jpg
by
Raul654
under a
Creative Commons
BY SA license
.
Ntwk tcp header123.jpg
by
Gopal Paliwal
under a
Creative Commons
BY SA license
.
This page last modified on 2012 April 11.