A more sophisticated process-process protocol than UDP needs to support
connections as well as reliable, in-order transport of bytes.
The Internet's Transmission Control Protocol (TCP) is the most
commonly used protocol of this type.
End-to-End Issues
TCP, just like point-to-point links, makes use of the sliding window algorithm.
There are some important differences, however.
TCP is not over a dedicated link, but over a network, and there is no dedicated connection between the two hosts.
This means we have to take a telephone-like approach of making a logical connection between the two machines first. Then send data over that connection and finally tear it down.
Another important difference, is that there is more variability in the RTT of packets going between the two hosts than in the point-to-point situation where you have a dedicated line.
This means that the timeout mechanism of the sliding window algorithm needs to be adaptive.
At the transport layer packets are more likely to be out of order than in a point-to-point line.
The maximum time-to-live of a TCP packet is 120 seconds. So TCP needs to be able to handle very late arrive packets.
TCP supports many more kinds of hosts, each with the ability to talk at different rates, so it must support flow control so a fast host can talk to a slow one.
Finally, TCP needs to support many connections from different hosts all using the same network. So it needs to be able to handle congestion of links on the network.
TCP Segment Format
0
4
10
3116
Source Port
Destination Port
SequenceNum
Acknowledgement
HdrLen
0
Flags
AdvertisedWindow
Checksum
UrgPtr
Options (variable)
Data
More Segment Format
TCP packets are called segments.
Source and Destination Ports are as in UDP.
The Acknowledgement, SequenceNum, and AdvertisedWindows fields are all used for the
sliding window algorithm.
The 6-bit Flags field is used to relay control information. The flag bits are
SYN, FIN, RESET, PUSH, URG, ACK.
The first two are for starting/closing a connection
URG signifies that the segment contains urgent data. If it is set, then UrgPtr point
to the first non-urgent data in the segment.
PUSH indicates that the receiving side of a TCP connection should notify the receiving process that a PUSH was done.
RESET indicates that the receiver wants to abort the connection.
Connection Establishment
Before any data is sent a connection between the client (caller) and a server (callee)
needs to be established.
This is done by an algorithm known as a three-way handshake.
To begin a client send a SYN segment to the server stating the initial sequence number it
plans to use. (Flags=SYN, SequenceNum = x)
The server responds with a single segment that both acknowledges the client's sequence number and the states its own beginning sequence number. So it says (Flags =ACK, ACK=x+1) (Flags=SYN, SequenceNum = y). This is called a SYN+ACK.
Finally, the client acknowledges the servers sequence number (Flags=ACK, Ack=y+1).
The sequence number+1 is used above to indicate the next sequence number expected. All earlier numbers are implicitly acknowledged.
Sequence numbers on each side of a connection are selected at random to protect against two incarnations (between same hosts and processes) of the same connection reusing the same sequence number too soon.
More Connection Establishment
Both client and servers make use of timers on each of these messages to figure
out whether or not to start over.
If a client sees a SYN+ACK it assumes the connection is ESTABLISHED.
If the client's final ACK is lost, subsequently sent segments of the client
will each still have the same ACK sequence number, and so can serve as the ACK,
at which point the server views the connection as ESTABLISHED.
The next image illustrates how the set-up can guard against stray segments:
Quiz
Which of the following is true?
IPv6 supports autoconfiguration of local addresses but requires a server like a DHCP server for global addresses.
MPLS can be used to support transport of IP packets across an ATM network.
Ethernet multicast addresses have a bigger address space than IPv4 multicast addresses.
Connection Teardown
For connection teardown both sides of the connection must independently close their half of the connection.
If only one side closes the connection, then this means it has no data to send, but it is still available
to receive data.
In the usual way to close a connection: One of the client or server closes first and sends a FIN, the other side sends an ACK, and the client or server
replies with a FIN/ACK.
It can also happen that you send a FIN and receive a FIN, in which case you can send both an ACK and a FIN/ACK to close the connection.
The book describes these processes in terms of the transition diagrams of the client and server. You should try to work out how the messages sent map to state transitions.