The TCP/IP Guide - Version 3.0 (Contents) ` 1621 _ © 2001-2005 Charles M. Kozierok. All Rights Reserved.
If you were using the program on a directly-connected terminal, you would simply use the
key or keystroke command appropriate to that terminal to interrupt or kill the process and
restart it. Instead, you are using Telnet, so you enter the appropriate keystroke, which gets
converted to the special Telnet Interrupt Process command code (byte value 244, preceded
by the Telnet Interpret As Command code, 255).
Since Telnet uses only a single stream for commands and data, that code is placed into the
TCP data stream to be sent over to the Telnet server. Since you were entering data for a
while, that Telnet Interrupt Process code will be sitting behind a bunch of regular data bytes.
Now, the remote process has stopped reading this data, which means the TCP receive
buffer on the server will start to fill up. The Interrupt Process command will thus remain
stuck in the buffer, waiting to be read. In fact, if the number of data bytes in front of the
command is high enough, the TCP buffer on the server may fill entirely, causing the server
to close the client’s TCP send window. This means the Interrupt Process command will wait
in the client’s outgoing TCP queue and never even be sent to the remote host at all!
Obviously, what we need here is some way to be able to flag the Interrupt Process
command, so that it can be sent to the remote host regardless of the number of data bytes
outstanding in front of it. If you’ve already perused the large section of this Guide devoted to
TCP, you may now be thinking that you have already read about a feature of that protocol
that seems ideally suited for this exact problem… and you’d be correct! The TCP “urgent”
function allows an important piece of data to be marked so that it is given priority over
regular data, a process sometimes called out-of-band signaling (because the signal is
“outside” the normal data stream). Telnet makes use of this feature of TCP to define what it
calls the synch function.
The Synch Function
When needed, as in the example just described, the synch function is invoked by the client
sending the special Telnet Data Mark (DM) protocol command, while instructing its TCP
layer to mark that data “urgent”. The URG bit in the TCP segment carrying this command
causes it to bypass TCP’s normal flow control mechanism so it is sent over to the remote
host. The Telnet server software, seeing the synch in the data stream, then searches
through all of the data in its buffer looking only for Telnet control commands such as
Interrupt Process, Abort Output and Are You There. These commands are then executed
immediately. The server continues to search for important commands up to the point where
the Data Mark command is seen. All intervening data is discarded; it will need to be retrans-
mitted. After the Data Mark is processed, the server returns to normal operation.
It is also possible for the server to use the synch function in communication with the user on
the client device. For example, if the user sends the Abort Output command to the server,
he or she is telling the server to discard all remaining output from the current process. The
server will stop sending that output, and can also use the synch function to clear all
outstanding data that is waiting in buffers to be sent to the client machine (since it causes
data to be discarded as mentioned above).