3.7. Data Communication
Once the connection is established data is communicated by the exchange of segments. Because segments may be lost due to errors (checksum test failure), or network congestion, TCP uses retransmission (after a timeout) to ensure delivery of every segment. Duplicate segments may arrive due to network or TCP retransmission. As discussed in the section on sequence numbers the TCP performs certain tests on the sequence and acknowledgment numbers in the segments to verify their acceptability.
The sender of data keeps track of the next sequence number to use in the variable SND.NXT. The receiver of data keeps track of the next sequence number to expect in the variable RCV.NXT. The sender of data keeps track of the oldest unacknowledged sequence number in the variable SND.UNA. If the data flow is momentarily idle and all data sent has been acknowledged then the three variables will be equal.
When the sender creates a segment and transmits it the sender advances SND.NXT. When the receiver accepts a segment it advances RCV.NXT and sends an acknowledgment. When the data sender receives an acknowledgment it advances SND.UNA. The extent to which the values of these variables differ is a measure of the delay in the communication.
Normally the amount by which the variables are advanced is the length of the data in the segment. However, when letters are used there are special provisions for coordination the sequence numbers, the letter boundaries, and the receive buffer boundaries.
End of Letter Sequence Number Adjustments
There is provision in TCP for the receiver of data to optionally communicate to the sender of data on a connection at the time of the connection synchronization the receiver's buffer size. If this is done the receiver must use this fixed size of buffers for the lifetime of the connection. If a buffer size is communicated then there is a coordination between receive buffers, letters, and sequence numbers.
Each time a buffer is completed either due to being filled or due to an end of letter, the sequence number is incremented through the end of that buffer.
That is, whenever an EOL is transmitted, the sender advances its send sequence number, SND.NXT, by an amount sufficient to consume all the unused space in the receiver's buffer. The amount of space consumed in this fashion is subtracted from the send window just as is the space consumed by actual data.
And, whenever an EOL is received, the receiver advances its receive sequence number, RCV.NXT, by an amount sufficient to consume all the unused space in the receiver's buffer. The amount of space consumed in this fashion is subtracted from the receive window just as is the space consumed by actual data.
older sequence numbers newer sequence numbers
| Buffer 1 | Buffer 2
| |
----+-------------------------------+-----------------
XXXXXXXXXXXXXXXXXXXXX+++++++++++
| | |
|<-----SEG.LEN------>| |
| | |
| | |
SEG.SEQ A B
XXX - data octets from segment
+++ - phantom data
<----- sequence space ----->
End of Letter Adjustment
Figure 17.
In the case illustrated above, if the segment does not carry an EOL flag, the next value of SND.NXT or RCV.NXT will be A. If it does carry an EOL flag, the next value will be B.
The exchange of buffer size and sequencing information is done in units of octets. If no buffer size is stated, then the buffer size is assumed to be 1 octet. The receiver tells the sender the size of the buffer in a SYN segment that contains the 16 bit buffer size data in an option field in the TCP header.
Each EOL advances the sequence number (SN) to the next buffer boundary
While LBB < SEG.SEQ+SEG.LEN
Do LBB <- LBB + BS End
SN <- LBB
where LBB is the Last Buffer Beginning, and BS is the buffer size.
The CLOSE user call implies an end of letter, as does the FIN control flag in an incoming segment.
The Communication of Urgent Information
The objective of the TCP urgent mechanism is to allow the sending user to stimulate the receiving user to accept some urgent data and to permit the receiving TCP to indicate to the receiving user when all the currently known urgent data has been received by the user.
This mechanism permits a point in the data stream to be designated as the end of "urgent" information. Whenever this point is in advance of the receive sequence number (RCV.NXT) at the receiving TCP, that TCP should tell the user to go into "urgent mode"; when the receive sequence number catches up to the urgent pointer, the TCP should tell user to go into "normal mode". If the urgent pointer is updated while the user is in "read fast" mode, the update will be invisible to the user.
The method employs a urgent field which is carried in all segments transmitted. The URG control flag indicates that the urgent field is meaningful and should be added to the segment sequence number to yield the urgent pointer. The absence of this flag indicates that the urgent pointer has not changed.
To send an urgent indication the user must also send at least one data octet. If the sending user also indicates end of letter, timely delivery of the urgent information to the destination process is enhanced.
Managing the Window
The window sent in each segment indicates the range of sequence number the sender of the window (the data receiver) is currently prepared to accept. There is an assumption that this is related to the currently available data buffer space available for this connection. The window information is a guideline to be aimed at.
Indicating a large window encourages transmissions. If more data arrives than can be accepted, it will be discarded. This will result in excessive retransmissions, adding unnecessarily to the load on the network and the TCPs. Indicating a small window may restrict the transmission of data to the point of introducing a round trip delay between each new segment transmitted.
The mechanisms provided allow a TCP to advertise a large window and to subsequently advertise a much smaller window without having accepted that much data. This, so called "shrinking the window," is strongly discouraged. The robustness principle dictates that TCPs will not shrink the window themselves, but will be prepared for such behavior on the part of other TCPs.
The sending TCP must be prepared to accept and send at least one octet of new data even if the send window is zero. The sending TCP should regularly retransmit to the receiving TCP even when the window is zero. Two minutes is recommended for the retransmission interval when the window is zero. This retransmission is essential to guarantee that when either TCP has a zero window the re-opening of the window will be reliably reported to the other.
The sending TCP packages the data to be transmitted into segments which fit the current window, and may repackage segments on the retransmission queue. Such repackaging is not required, but may be helpful.
Users must keep reading connections they close for sending until the TCP says no more data.
In a connection with a one-way data flow, the window information will be carried in acknowledgment segments that all have the same sequence number so there will be no way to reorder them if they arrive out of order. This is not a serious problem, but it will allow the window information to be on occasion temporarily based on old reports from the data receiver.