The Async Protocol

This stop-and-wait Data Link protocol assures reliable transparent file transfer over the public telephone network. It is for use between two ends connected by a full-duplex asynchronous serial channel.

The ends exchange files alternately. Data format is 8-bit bytes without parity, blocked into frames by the Transport Layer. Error correction is by the retransmission of frames received with incorrect 16-bit Cyclic Redundancy Checkword (CRC).

Cyclic Redundancy Checkword

To calculate the CRC for a frame, first clear the CRC then feed the frame byte by byte into the generator. The following MASM procedure feeds the byte in AL into the CRC in DX:

	mov	cx,8		; loop counter
	mov	ah,al
	and	ah,80h
	xor	dh,ah
	shl	dx,1		; shift left by 1 bit (into Carry flag)
  .If		CARRY?
	xor	dx,08005h	; Generating Polynomial x**16+x**15+x**2+1
	rol	al,1		; rotate left by 1 bit
 .Untilcxz			; decrements cx, loops unless cx==0
crc	ENDP

The transmitter sends the high byte of the calculated CRC first.

The receiver accepts the received frame if and only if the final calculated value (including the received CRC) is zero.

Protocol Syntax

  1. Initialization
    IF you will transmit first THEN set TxEnable=TRUE ELSE set TxEnable=FALSE.

    The caller normally sets TxEnable=TRUE and the called end normally sets TxEnable=FALSE.

    When the Physical Layer has connected with the other end, both ends enter Receive State at step 2 but the called end may remain silent or may emit spurious signals such as BLACK$ until the caller's opening RED$ is detected.

  2. Receive State (receive a file)
    Send RED$ every two seconds (approximately) until a burst of two or more bytes is received into FRAME$.

    A burst ends when no byte has been received for time t, where t exceeds any arbitrary delay in the physical channel (such as that caused by interrupt masking). For PC implementations timing is necessarily rather coarse: setting t=3 clock ticks equates to a value which varies randomly between 110 and 165msec, which should be ample. At high connection speeds there is some loss of bandwidth whilst timing out the burst but this idle time may be largely eliminated if the Transport Layer negotiates a maximum frame size (thus avoiding the need to time out the burst once a received frame has reached maximum size.

  3. IF at least three bytes were received and the CRC computes to zero THEN a frame has been received:
    1. Add FRAME$ (excluding the CRC) to the received file
    2. Swap RED$ with GREEN$
    3. Set TxEnable=TRUE
    4. Go to step 2
    ELSE IF FRAME$=RED$ AND TxEnable=TRUE THEN the other end is now in Receive State:
    1. Close the received file
    2. IF you wish to send a file, enter Transmit State at step 4
      ELSE disconnect and go to step 1 for the next session
    ELSE an error has occurred: go to step 2.
  4. Transmit State (send a file)
    Set TxEnable=FALSE.
  5. IF you have more data to send THEN:
    1. Move the next frame into FRAME$
    2. Append two CRC bytes to FRAME$
    ELSE you have reached end-of-file: enter Receive State at step 2.

    At least one frame must be sent in each Transmit State. Every frame must have at least one byte (plus the two CRC bytes).

  6. Send FRAME$ and discard any characters already received.
  7. Wait indefinitely for the next character.
  8. Wait indefinitely for the next character and move the two characters most recently received into REPLY$.
    IF REPLY$=GREEN$ THEN the frame was correctly received:
    1. Swap RED$ with GREEN$
    2. Go to step 5
    ELSE IF REPLY$=RED$ THEN the other end detected an error: go to step 6.
    ELSE an error occurred: repeat step 8.

Reverse Interrupt (The WHITE Option)

Reverse Interupt (RVI) is available to the receiving end and is normally used to stop the sending of an unwanted file.

However, if sending is to be resumed after the interrupt please be sure that at least one further frame remains to be sent.

At step 2 the receiving end may attempt to interrupt the transmitter by sending WHITE$ instead of RED$ (provided that at the step 3 immediately preceding it received FRAME$ with the correct CRC).

At step 8 IF the transmitter encounters REPLY$=WHITE$ THEN:

  1. Swap RED$ with GREEN$
  2. IF you elect to relinquish Transmit State THEN go to step 2
    ELSE go to step 5 ignoring the interrupt attempt

    In this case the receiver should not attempt another interrupt.

TTD and WAK (Transport Layer delays)

Temporary Text Delay (TTD) arises when the Transport Layer transmitter does not have a frame ready to send. TTD is implemented implicitly by the indefinite repetition of RED$ at step 2.

Wait Acknowledge (WAK) arises when the Transport Layer receiver is not ready to accept a frame. WAK is implemented implicitly by the indefinite waits at steps 7 and 8.

Reset (The BLACK Option)

If either end encounters a situation it cannot handle, it may abort the session by disconnecting. Assuming the Physical Layer handles the disconnection on loss of remote carrier, the persistence of the remote modem's carrier signal assures any TTD or WAK delay is real. Nevertheless, you should disconnect after any extended failure to exchange valid data. Rather than define formal limits on retry attempts or waits, this is left to the discretion of the implementer.

In case the transmitter's Physical Layer cannot sense loss of remote carrier, Reset is available to the receiving end to indicate it has aborted the previous session.

At step 2 the receiving end may indicate it has reset (through step 1) by sending BLACK$.

At step 8 IF the transmitter encounters REPLY$=BLACK$ THEN abort the current session and go to step 1 for the next session.

The Protocol Handbook