4. Asynchronous HDLC
This section summarizes the use of HDLC with 8-bit asynchronous links.
Flag Sequence
The Flag Sequence indicates the beginning or end of a frame. The octet stream is examined on an octet-by-octet basis for the value 01111110 (hexadecimal 0x7e).
Transparency
An octet stuffing procedure is used. The Control Escape octet is defined as binary 01111101 (hexadecimal 0x7d) where the bit positions are numbered 87654321 (not 76543210, BEWARE).
Each end of the link maintains two Async-Control-Character-Maps. The receiving ACCM is 32 bits, but the sending ACCM may be up to 256 bits. This results in four distinct ACCMs, two in each direction of the link.
The default receiving ACCM is 0xffffffff. The default sending ACCM is 0xffffffff, plus the Control Escape and Flag Sequence characters themselves, plus whatever other outgoing characters are known to be intercepted.
After FCS computation, the transmitter examines the entire frame between the two Flag Sequences. Each Flag Sequence, Control Escape octet, and octet with value less than hexadecimal 0x20 which is flagged in the sending Async-Control-Character-Map, is replaced by a two octet sequence consisting of the Control Escape octet and the original octet with bit 6 complemented (exclusive-or'd with hexadecimal 0x20).
Prior to FCS computation, the receiver examines the entire frame between the two Flag Sequences. Each octet with value less than hexadecimal 0x20 is checked. If it is flagged in the receiving Async-Control-Character-Map, it is simply removed (it may have been inserted by intervening data communications equipment). For each Control Escape octet, that octet is also removed, but bit 6 of the following octet is complemented, unless it is the Flag Sequence.
Note: The inclusion of all octets less than hexadecimal 0x20 allows all ASCII control characters [8] excluding DEL (Delete) to be transparently communicated through all known data communications equipment.
The transmitter may also send octets with value in the range 0x40 through 0xff (except 0x5e) in Control Escape format. Since these octet values are not negotiable, this does not solve the problem of receivers which cannot handle all non-control characters. Also, since the technique does not affect the 8th bit, this does not solve problems for communications links that can send only 7-bit characters.
A few examples may make this more clear. Packet data is transmitted on the link as follows:
0x7e is encoded as 0x7d, 0x5e. 0x7d is encoded as 0x7d, 0x5d.
0x01 is encoded as 0x7d, 0x21.
Some modems with software flow control may intercept outgoing DC1 and DC3 ignoring the 8th (parity) bit. This data would be transmitted on the link as follows:
0x11 is encoded as 0x7d, 0x31. 0x13 is encoded as 0x7d, 0x33.
0x91 is encoded as 0x7d, 0xb1. 0x93 is encoded as 0x7d, 0xb3.
Aborting a Transmission
On asynchronous links, frames may be aborted by transmitting a "0" stop bit where a "1" bit is expected (framing error) or by transmitting a Control Escape octet followed immediately by a closing Flag Sequence.
Time Fill
For asynchronous links, inter-octet and inter-frame time fill MUST be accomplished by transmitting continuous "1" bits (mark-hold state).
Inter-frame time fill can be viewed as extended inter-octet time fill. Doing so can save one octet for every frame, decreasing delay and increasing bandwidth. This is possible since a Flag Sequence may serve as both a frame close and a frame begin. After having received any frame, an idle receiver will always be in a frame begin state.
Robust transmitters should avoid using this trick over-zealously, since the price for decreased delay is decreased reliability. Noisy links may cause the receiver to receive garbage characters and interpret them as part of an incoming frame. If the transmitter does not send a new opening Flag Sequence before sending the next frame, then that frame will be appended to the noise characters causing an invalid frame (with high reliability). It is suggested that implementations will achieve the best results by always sending an opening Flag Sequence if the new frame is not back-to-back with the last. Transmitters SHOULD send an open Flag Sequence whenever "appreciable time" has elapsed after the prior closing Flag Sequence. The maximum value for "appreciable time" is likely to be no greater than the typing rate of a slow typist, say 1 second.
Encoding
All octets are transmitted with one start bit, eight bits of data,
and one stop bit. There is no provision for seven bit asynchronous links.