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).
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:
crc PROC PRIVATE USES ax cx mov cx,8 ; loop counter .Repeat 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 .Endif rol al,1 ; rotate left by 1 bit .Untilcxz ; decrements cx, loops unless cx==0 ret 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.
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.
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.
At least one frame must be sent in each Transmit State. Every frame must have at least one byte (plus the two CRC bytes).
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:
In this case the receiver should not attempt another interrupt.
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.
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.