This data link protocol provides a reliable connection between two hosts. The hosts are identified by an IP and port number (i.e., this protocol uses the UDP protocol to deliver the frames). A protocol is specified by the services it provides and the messages that are exchanged by the two entities that implement the protocol. The messages are specified by their format, and how they are exchanged (i.e., the receipt of message A implies replying with message B). Additionally, the important state of the software that implements the protocol can also be part of its specification.
This protocol is specified by first describing the services it provides and the interface to those services. The main state elements maintained by the protocol entity is then discussed, followed by a description of the messages (frames) that are exchanged to implement the services.
The main service provided is guaranteed data deliver. The ability to reset the link is also provided to handle initialization of the link and error recover.
The interface is currently not specified, however you are free to come up with your own.
The main state of a link is given by two variables, one that keeps track of the sequence number of the next outgoing data frame, and the second the keeps track of the expected sequence number of the next incoming data frame. These variables are referred to as the NextOutgoingFrame and the NextFrameExpected. In order for the link state to be meaningful, the protocol entities handling the connection must exist. When the entities are created, the NextOutgoingFrame and NextFrameExpected are initially set to 0.
The entity that implements the protocol can also be in a VALID or INVALID state. The entity is in a VALID state when it is first created, and remains in the VALID state as long as no errors occur. An error occurs when an attempt to reset the link fails or an attempt to transfer data fails. The entity's state is changed to VALID if an attempt to reset the link succeeds. When the entity is in the INVALID state, only the reset link service request is honoured.
The protocol entities will also maintain additional state, but that state is only relevant to the implementation and not the specification.
| Byte Offset | Field Name | Description |
|---|---|---|
| 0 | Destination | the IP number and port number of the destination host |
| 6 | Source | the IP number and port number of the source host |
| 12 | Flag | a byte indicate the contents of the frame, see below |
| 13 | SequenceNo | an 8-bit sequence number for the current frame |
| 14 | AcknowledgementNo | an 8-bit acknowledgement number |
| 15 | DataLen | the data length in bytes is given by a 16-bit unsigned integer |
| 16 | Data | 0 to 1024 bytes of payload data |
The following sections expand on the format and description of a data link frame.
The destination address is given by a 4 byte IP number in network byte order, followed by a 2 byte port number in network byte order. Since the frame is sent by a UDP service, including the source address is redundant. However it provides the ability to first sent the frame to a different host, that then forwards the frame to its destination. The intermediary host can be used to trace the exchange of frames.
The source address is given by a 4 byte IP number in network byte order, followed by a 2 byte port number in network byte order. The source, while normally redundant is provided to allow for an intermediary host.
The format and description of the flag byte is given in
the following table:
| Bit Offset | Flag Bit Name | Description |
|---|---|---|
| 0 | RESET | When set to 1, that state of the connection must be reset. |
| 1 | DATA_VALID | Indicates that the frame contains data when set to 1. |
| 2 | ACK_VALID | Indicates that the frame's acknowledgment field is valid when set to 1. If the RESET bit is also set, then the frame is acknowledging a reset of the link. |
If the timer expires before receipt of the "RESET ACK" frame, the "RESET" frame is retransmitted and the timer restarted. A "RESET" frame should only be resent three times. After four attempts the entity's state is set to INVALID.
If the timer expires before the receipt of an "ACK" frame, the "DATA" frame is resent, and the 1 second timer restarted. A "DATA" frame can only be resent a maximum of 3 times. After four attempts the entity's state is set to INVALID, and the copied frame is freed.
This section provides example traces of messages exchanged between to peer entities in accomplishing a series of service requests.
The following table shows the messages exchanges for host A resetting the link and then requesting three data transfers to host B.
| Service Request | Direction | Dest | Source | Flag | SeqNo | AckNo | DataLen |
|---|---|---|---|---|---|---|---|
| A: reset link | A -> B | B:2000 | A:2200 | R-- | 0 | 0 | 0 |
| B -> A | A:2200 | B:2000 | R-A | 0 | 0 | 0 | |
| A: send data | A -> B | B:2000 | A:2200 | -D- | 0 | 0 | 47 |
| B -> A | A:2200 | B:2000 | --A | 0 | 0 | 0 | |
| A: send data | A -> B | B:2000 | A:2200 | -D- | 1 | 0 | 49 |
| B -> A | A:2200 | B:2000 | --A | 0 | 1 | 0 | |
| A: send data | A -> B | B:2000 | A:2200 | -D- | 2 | 0 | 43 |
| B -> A | A:2200 | B:2000 | --A | 0 | 2 | 0 |
The next exchange shows the result of B resetting the link, A sending data, B sending data twice, and lastly A sending data.
| Service Request | Direction | Dest | Source | Flag | SeqNo | AckNo | DataLen |
|---|---|---|---|---|---|---|---|
| B: reset link | B -> A | A:2200 | B:2000 | R-- | 0 | 0 | 0 |
| A -> B | B:2000 | A:2200 | R-A | 0 | 0 | 0 | |
| A: send data | A -> B | B:2000 | A:2200 | -D- | 0 | 0 | 47 |
| B -> A | A:2200 | B:2000 | --A | 0 | 0 | 0 | |
| B: send data | B -> A | A:2200 | B:2000 | -D- | 0 | 0 | 49 |
| A -> B | B:2000 | A:2200 | --A | 1 | 0 | 0 | |
| B: send data | B -> A | A:2200 | B:2000 | -D- | 1 | 0 | 43 |
| A -> B | B:2000 | A:2200 | --A | 1 | 1 | 0 | |
| A: send data | A -> B | B:2000 | A:2200 | -D- | 1 | 1 | 43 |
| B -> A | A:2200 | B:2000 | --A | 2 | 1 | 0 |
The following table depicts the exchange in the which a data frame is lost, and retransmitted, then a successful data transmission and finally a transmission involving the lost of an acknowledgement frame.
| Service Request | Direction | Dest | Source | Flag | SeqNo | AckNo | DataLen |
|---|---|---|---|---|---|---|---|
| A: send data data lost resent |
A -> B | B:2000 | A:2200 | --D | 89 | 34 | 19 |
| A -> B | B:2000 | A:2200 | --D | 89 | 34 | 19 | |
| B -> A | A:2200 | B:2000 | --A | 34 | 89 | 0 | |
| A: send data | A -> B | B:2000 | A:2200 | -D- | 90 | 34 | 174 |
| B -> A | A:2200 | B:2000 | --A | 34 | 90 | 0 | |
| A: send data lost ack resent |
A -> B | B:2000 | A:2200 | -D- | 91 | 34 | 49 |
| B -> A | A:2200 | B:2000 | --A | 34 | 91 | 0 | |
| A -> B | B:2000 | A:2200 | -D- | 91 | 34 | 49 | |
| B -> A | A:2200 | B:2000 | --A | 34 | 91 | 0 |