The Gleneden Protocol

This specification describes my MS-DOS implementation of the Gleneden Proposal, a 1984 attempt to agree a common communication protocol between pharmaceutical wholesalers and retailers in the United Kingdom.

Structure

Gleneden is a protocol for transmitting data in blocks with error-checking and recovery procedures. It is a half-duplex protocol in that one end is normally transmitting data and the other is receiving. A special control sequence (line bidding) is used to reverse the direction of transmission. The protocol transfers seven bit ASCII characters with even or space parity (in space parity the parity bit is always 0) aggregated into data blocks by the Transport Layer and it uses the following set of control characters:

Control Characters

NameHexUsage
STX02Marks the start of data in a block.
ETX03Marks the end of data in a block.

Data blocks ending with ETX are considered as end-of-file records.

EOT04End of Transmission.
ENQ05Enquiry.
ETB17Marks the end of a data block that is not the end of a file.
NAK15Negative Acknowledgment of a block.
US1FUnit Separator.
CR0DCarriage Return.
ACK010 30Positive Acknowledgement of an even numbered block.
ACK110 31Positive Acknowledgement of an odd numbered block.

Data Block Format

Data may be sent in non-transparent mode only. In non-transparent mode, the special characters STX, ETX, ETB, US and CR must not occur as part of the data to be transmitted.

Each data block is formatted as follows:

<STX> <data - any length including 0> <ETB or ETX> <US> <BCC> <CR>

The <BCC> is a single byte block check character. The <BCC> is calculated as the Exclusive-OR of all the 7-bit characters in the block from the character after the <STX> up to and including the <US> and is transmitted with the appropriate parity.

The <US> and the <CR> are legacy characters inserted to defeat idiosyncrasies within defunct proprietary operating systems.

Link Control

Stations are considered to be in one of three states: line bid, transmit, or receive. Sessions always begin in line bid state from which one end exits to transmit state, the other to receive state. At the end of transmission from the station in transmit state, line bid state is re-entered and the station which was in receive state now bids for transmit state (line turn-around).

The end which has transmit state has complete control of the line. The receive state end only sends messages in reply to data or link control messages from the transmit end. Normal processing consists of the transmit end sending a message and the receive end sending a reply. The transmit end allows the receive end three seconds from sending the message to getting a valid reply. Seven attempts are made to get a successful exchange, then the call is abandoned.

In line bid state, neither end controls the line. Either end may attempt to assume transmit state by sending ENQ. To resolve this conflict, one end (initially the calling one in switched networks) is designated as a master and the other end as a secondary station. Master stations exit only to transmit state. When a secondary station receives an ENQ it responds with AK0 and enters receive state. Up to fifteen bid tries are allowed before abandoning the line.

Link Control Messages

<ENQ>In line bid state:Represents a request by the sending end to enter the transmit state.
In transmit state:Requests the receiving end to repeat its last response to the transmitting end.
In receive mode:Never sent.
<AK0>In line bid stateThe sending end is ready to enter receive state.
In transmit stateNever used.
In receive stateAn acknowledge of the last even numbered data block received.

The initial line bid <ENQ> is considered as message number 0.

<AK1>In line bid stateNever used.
In transmit stateNever used.
In receive stateAn acknowledge of the last odd numbered data block received.
<NAK>In line bid stateNever used.
In transmit stateNever used.
In receive stateRejects the last data block received. This message is only sent once for each data block received. A subsequent ENQ from the transmitting end is responded to by repeating the appropriate AK0 or AK1 for the last good data block.
<EOT>In line bid stateMay be sent by the end that last had transmit status. It indicates that that end has completed transmitting and is expecting the end that was receiving to begin bidding for the line by sending ENQ.
In transmit stateIndicates that the sending end has completed transmission of all its data and is ready to enter line bid state. This only applies if the last data block sent ended with an ETX and not an ETB. ETX is an end-of-file mark and it is assumed that the line will only turn around at the end of files. If the last data block sent ended with an ETB, this indicates an unrecoverable error and the session should be abandoned. A transmitting station which has just gained transmit state from a line bid may send an EOT if it has no data to send.
In receive modeNever used.

Line Bid - Master Station

Set Retry Count = 15, Timeout = 3 seconds.

Send ENQ.

ResponseAction
AK0Enter Transmit State
ACK NUL (06 00hex)Enter Transmit State.

GO.EXE supports other Data Link Protocols that open the Line Bid with ENQ and is consequently unable to determine (at your first Line Bid) that you intend to use Gleneden. Therefore, GO.EXE will respond with ACK NUL (06 00hex)as an alias for ACK0 (10 30hex) until it establishes (from your first transmitted block) that you are using Gleneden.

Others (including no reply)Decrement retry count and go again.

Line Bid - Secondary Station

Set Retry Count = 15, Timeout = 3 seconds.

Send ENQ.

ResponseAction
ENQSend AK0, enter Receive State
Others (including no reply)Decrement retry count and try again

Transmit State:

Set Retry Count = 7, Timeout = 3 seconds.

Expected Ack = ACK1.

  1. Send the next Data Block.
    ResponseAction
    ACK0/ACK1If this is expected Ack, toggle expected Ack and prepare to send the next data block.
    If this is the wrong Ack and the last transmission was a data block: fatal error (the receiver is out of step with the transmitter).
    If this is the wrong Ack and the last transmission was ENQ, the receiver did not see the last data block: decrement error count and re-send data.
    NAKDecrement error count and re-send data.
    Other response (including no response)Send ENQ, decrement retry count and get reply again.
  2. If all data is sent:
    Send EOT.
    ResponseAction
    ENQEnter Line Bid - the receiver has seen the EOT and is bidding to transmit.
    Other (including no response)Decrement retry count and re-send EOT.

Receive State:

Set Retry Count = 7, Timeout = 3 seconds.

Current Ack = AK0

Get a message.

MessageAction
EOTIf last data received ended in ETX or if no data has been sent, enter Line Bid. If last data ended in ETB, fatal error.
Data blockToggle current Ack and send it.
ENQSend current Ack.
Garbled dataSend NAK, decrement retry count.
No responseDecrement retry count, send nothing.

The Protocol Handbook