Protocol Operation: Connection Record and Closing
3.2.4 Connection Record
The variables that define the state of a connection are stored in a connection record maintained for each connection. The following describes some of the variables that would be stored in a typical RDP connection record. It is not intended to be an implementation specification nor is it a complete description. The purpose of naming and describing some of the connection record fields is to simplify the description of RDP protocol operation, particularly event processing.
The connection record fields and their descriptions follow:
STATE
The current state of the connection. Legal values are OPEN, LISTEN, CLOSED, SYN-SENT, SYN-RCVD, and CLOSE-WAIT.
Send Sequence Number Variables:
SND.NXT
The sequence number of the next segment that is to be sent.
SND.UNA
The sequence number of the oldest unacknowledged segment.
SND.MAX
The maximum number of outstanding (unacknowledged) segments that can be sent. The sender should not send more than this number of segments without getting an acknowledgement.
SND.ISS
The initial send sequence number. This is the sequence number that was sent in the SYN segment.
Receive Sequence Number Variables:
RCV.CUR
The sequence number of the last segment received correctly and in sequence.
RCV.MAX
The maximum number of segments that can be buffered for this connection.
RCV.IRS
The initial receive sequence number. This is the sequence number of the SYN segment that established this connection.
RCVDSEQNO[n]
The array of sequence numbers of segments that have been received and acknowledged out of sequence.
Other Variables:
CLOSEWAIT
A timer used to time out the CLOSE-WAIT state.
SBUF.MAX
The largest possible segment (in octets) that can legally be sent. This variable is specified by the foreign host in the SYN segment during connection establishment.
RBUF.MAX
The largest possible segment (in octets) that can be received. This variable is specified by the user when the connection is opened. The variable is sent to the foreign host in the SYN segment.
Variables from Current Segment:
SEG.SEQ
The sequence number of the segment currently being processed.
SEG.ACK
The acknowledgement sequence number in the segment currently being processed.
SEG.MAX
The maximum number of outstanding segments the receiver is willing to hold, as specified in the SYN segment that established the connection.
SEG.BMAX
The maximum segment size (in octets) accepted by the foreign host on a connection, as specified in the SYN segment that established the connection.
3.2.5 Closing a Connection
The closing of a connection can be initiated by a Close request from the user process or by receipt of an RST segment from the other end of the connection. In the case of the Close request, RDP will send an RST segment to the other side of the connection and then enter the CLOSE-WAIT state for a period of time. While in the CLOSE-WAIT state, RDP will discard segments received from the other side of the connection. When the time-out period expires, the connection record is deallocated and the connection ceases to exist. This simple connection closing facility requires that users determine that all data has been reliably delivered before requesting a close of the connection.
3.2.6 Detecting an Half-Open Connection
If one side of a connection crashes, the connection may be left with the other side still active. This situation is termed to be an half-open connection. For many cases, the active RDP will eventually detect the half-open connection and reset. Two examples of recovery from half-open connections are provided in sections 5.7 and 5.8. Recovery is usually achieved by user activity or by the crashed host's attempts to re-establish the connection.
However, there are cases where recovery is not possible without action by the RDP itself. For example, if all connection blocks are in use, attempts to re-establish a broken connection will be rejected. In this case, the RDP may attempt to free resources by verifying that connections are fully open. It does this by sending a NUL segment to each of the other RDPs. An acknowledgement indicates the connection is still open and valid.
To minimize network overhead, verification of connections should only be done when necessary to prevent a deadlock situation. Only inactive connections should be verified. An inactive connection is defined to be a connection that has no outstanding unacknowledged segments, has no segments in the user input or output queues, and that has not had any traffic for some period of time.