HDLC

HDLC

1.1 Introduction The data link layer is the second layer in the OSI seven-layer model and its protocols define rules for the orderly exchange of data ...

617KB Sizes 287 Downloads 344 Views

1.1 Introduction The data link layer is the second layer in the OSI seven-layer model and its protocols define rules for the orderly exchange of data information between two adjacent nodes connected by a data link. Final framing, flow control between nodes, and error detection and correction are added at this layer. In previous chapters the data link layer was discussed in a practical manner. It is a use protocol as it provides a model for interfacing to a serial bus. The two types of protocol are: 9 9

Asynchronous protocol. Synchronous protocol.

Asynchronous communications uses start-stop method of communication where characters are sent between nodes, as illustrated in Figure I. 1. Special characters are used to control the data flow. Typical flow control characters are End of Transmission (EOT), Acknowledgement (ACK), Start of Transmission (STX) and Negative Acknowledgement (NACK). Synchronous communications involves the transmission of frames of bits with start and end bit characters to delimit the frame. The two of the most popular are IBM's synchronous data link communication (SDLC) and high-level data link control (HDLC). Many network data link layers are based upon these standards, examples include the LLC layer in IEE 802.x LAN standards and LAPB in the X.25 packet switching standard. Synchronous communications normally uses a bit-oriented protocol (BOP), where data is sent one bit at a time. The data link control information is interpreted on a bit-by-bit basis rather than with unique data link control characters.

Figure 1.1 Asynchronous and synchronous communications

Computer busses

570

HDLC is a standard developed by the ISO to provide a basis for the data link layer for point-to-point and multi-drop connections. It can transfer data either in a simplex, half-duplex, or full-duplex mode. Frames are generally limited to 256 bytes in length and a single control field performs most data link control functions.

1.2 HDLC protocol In HDLC, a node is either defined as a primary station or a secondary station. A primary station controls the flow of information and issues commands to secondary stations. The secondary station then sends back responses to the primary. A primary station with one or more secondary stations is known as unbalanced configuration. HDLC allows for point-to-point and multi-drop. In point-to-point communications a primary station communicates with a single secondary station. For multi-drop, one primary station communications with many secondary stations. In point-to-point communications it is possible for a station be operate as a primary and a secondary station. At any time, one of the stations can be a primary and the other the secondary. Thus, commands and responses flow back and forth over the transmission link. This is known as a balanced configuration, or combined stations.

L 2.1

HDL C modes of operation

HDLC has three modes of operation. Unbalanced configurations can use the normal response mode (NRM). Secondary stations can only transmit when specifically instructed by the primary station. When used as a point-to-point or multi-drop configuration only one primary station is used. Figure 1.2 shows a multi-drop NRM configuration. Unbalanced configurations can also use the asynchronous response mode (ARM). It differs from NRM in that the secondary is allowed to communicate with the primary without receiving permission from the primary. Secondary station

1

l, IiI

Commands Primary I~ station I Responses Normal response mode (NRM)

j' Figure 1.2

Commands Primary/ I~ ~ IPrimary/ I~ Secondary ~ ~ iSecondary ~ t _ Z ~ J Responses I~n_...~.J Asynchronous balanced mode (ABM) Secondary station N

NRM and ABM mode

Microsoft Windows

571

In asynchronous balanced mode (ABM) all stations have the same priority and can perform the functions of a primary and secondary station.

L2.2 HDLC frame format HDLC frames are delimited by the bit sequence 01111110. Figure 1.3 shows the standard format of the HDLC frame, the 5 fields are the: 9 9 9 9 9

Flag field. Address field. Control field. Information field. Frame check sequence (FCS) field.

Figure 1.3

HDLC frame structure

L2.3 Information field The information fields contain data, such as OSI level 3, and above, information. It contains an integer number of bytes and thus the number of bits contained is always a multiple of eight. The receiver determines the number of bytes in the data because it can detect the start and end flag. By this method, it also finds the FCS field. Note that the number of characters in the information can be zero as not all frames contain data.

L2.4 Flag field A unique flag sequence, 0 z z z z z l 0 (or 7Eh), delimits the start and end of the frame. As this sequence could occur anywhere within the frame a technique called bit-insertion is used to stop this happening except at the start and end of the frame.

L2.5 Address field The address field is used to address connected stations an, in basic addressing, it contains an 8-bit address. It can also be extended, using extended addressing, to give any multiple of 8 bits. When it is 8 bits wide it can address up to 254 different nodes, as illustrated in Figure 1.4. Two special addresses are o o o o o o o o and 111 z z 11 z. The o o o o o o o o address defines the null or void address and the 11 z 1111 z broadcasts a message to all secondaries. The other 254 addresses are used to address secondary nodes individually.

Computer busses

572

Figure 1.4 HDLC addressing range If there are a large number of secondary stations then extended address can be used to extend the address field indefinitely. A 0 in the first bit of the address field allows a continuation of the address, or a 1 ends it. For example: XXXXXXXl

L2.6

XXXXXXXO

XXXXXXXO

XXXXXXXO

Control field

The control field can either be 8 or 16 bits wide. It is used to identify the frame type and can also contain flow control information. The first two bits of the control field define the frame type, as shown in Figure 1.5. There are three types of frames, these are: 9 9 9

Information frames. Supervisory frames. Unnumbered frames.

When sent from the primary the P/F bit indicates that it is polling the secondary station. In an unbalanced mode, a secondary station cannot transmit frames unless the primary sets the poll bit. When sending frames from the secondary, the p / r bit indicates whether the frame is the last of the message, or not. Thus if the P/F bit is set by the primary it is a poll bit (p), if it is set by the secondary it is a final bit (r). The following sections describe 8-bit control fields. Sixteen-bit control fields are similar but reserve a 7-bit field for the frame counter variables m (R) and m ( S ). Information frame An information frame contains sequenced data and is identified by a 0 in the first bit position of the control field. The 3-bit variable N (R) is used to confirm the number of transmitted frames received correctly and N(S) is used to number an information frame. The first frame transmitted is numbered 0 as (000), the next as 1 (001), until the eighth which is numbered 111. The sequence then starts back at 0 again and this gives a sliding window of eight frames.

Microsoft Windows

573

Figure 1.5

Format.of an 8-bit control field

Supervisory frame Supervisory flames contain flow control data. They confirm or reject previously received information flames and also can indicate whether a station is ready to receive flames. The N(S) field is used with the S bits to acknowledge, or reject, previously transmitted flames. Responses from the receiver are set in the S field, these are receiver ready (RR), ready not to receive (RNR), reject (REJ) and selectively reject (SREJ). Table 1.1 gives the format of these bits. RR informs the receiver that it acknowledges the flames sent up to m (R). RNR tells the transmitter that the receiver cannot receive any more flames at the present time (RR will cancel this). It also acknowledges flames up to m (R). The REJ control rejects all flames after m (R). The transmitter must then send flames starting at m (R). Table 1.1

0 1 0 1

0 0 1 1

Supervisory bits

Receiver ready (RR) Receiver not ready (RNR) Reject (REJ) Selectively reject (SREJ)

Unnumbered frame If the first two bits of the control field are l's then it is an unnumbered flame. Apart from the p / y flag the other bits are used to send unnumbered commands. When sending commands, the p / v flag is a poll bit (asking for a response), and for responses it is a flag bit (end of response). The available commands are SARM (set asynchronous response mode), SNRM (set normal response mode), SABM (set asynchronous balance mode), RSET (reset), FRMR (flame reject) and Disconnect (DISC). The available responses are UA (unnumbered acknowledge), CMDR (command reject), FRMR (flame reject) and DM (disconnect mode). Bit definitions for some of these are:

574

Computer busses

SABM UA

llllPll0 II00FII0

DM FRMR

111IF000

DISC

ll00P010

IIIOF001

1.2. 7 Frame check sequence field The frame check sequence (FCS) field contains an error detection code based on cyclic redundancy check (CRC) polynomials. It is used to check the address, control and information fields, as previously illustrated in Figure 1.2. HDLC uses a polynomial specified by CCITT V.41, which is G(x) - x 16 + x 12 + x 5 + x 1 . This is also known as CRC-16 or CRC-CCITT.

1.3 Transparency The flag sequence 0111111 o can occur anywhere in the frame. To prevent this a transparency mechanism called zero-bit insertion or zero stuffing is used. There are two main rules that are applied, these are" 9 9

In the transmitter, a 0 is automatically inserted after five consecutive l's, except when the flag occurs. At the receiver, when five consecutive l's are received and the next bit is a 0 then the 0 is deleted and removed. If it is a 1 then it must be a valid flag.

In the following example a flag sequence appears in the data stream where it is not supposed to (spaces have been inserted around it). Notice that the transmitter detects five l's in a row and inserts a 0 to break them up. Message: Sent:

00111O001010O0

01111110

01011111

00111O001OlO00

011111010

010111110111101Ol01

IIIi010101

1.4 Flow control Supervisory frames (s [] ) send flow control information to acknowledge the reception of data frames or to reject frames. Unnumbered frames ( u [ ] ) set up the link between a primary and a secondary, by the primary sending commands and the secondary replying with responses. Information frames (z [] ) contain data.

L4.1

Link connection

Figure 1.6 shows how a primary station (node A) sets up a connection with a secondary station (node B) in NRM (normal response mode). In this mode one or many secondary stations can exist. First the primary station requests a link by sending an unnumbered frame with: node B's address (ADDR_B), the set normal response mode (SNRM) command and with poll flag set ( p : l ) , that is, U [ S N R M , A B B R B, P:l]. If the addressed secondary wishes to make a connection then it replies back with an unnumbered flame containing: its own address

Microsoft Windows

5 75

(ADDR_B), the unnumbered acknowledge (UA) response and the final bit set (F=I), i.e. u [UA, ABBR_B, F=I]. The secondary sends back its own address because many secondaries can exist and it thus identifies which station has responded. There is no need to send the primary station address as only one primary exists. Once the link is set up data can flow between the nodes. To disconnect the link, the primary station sends an unnumbered frame with: node B's address (ADDR_B), the disconnect (DISC) command and the poll flag set (p=l), that is, U[DISC,ABBR B , P = I ] . If the addressed secondary accepts the disconnection then it replies back with an unnumbered frame containing: its own address (ADDR_B), the unnumbered acknowledge (UA) response and the final bit set (F=I), i.e. u [UA,ABBR B, F=I]. When two stations act as both primaries and secondaries then they use the asynchronous balanced mode (ABM). Each station has the same priority and can perform the functions of a primary and secondary station. Figure 1.7 shows a typical connection. The ABM mode is set up initially using the SABM command (u [SABM, ABBR B, P=l] ). The connection between node A and node B is then similar to the NRM but, as node B operates as a primary station, it can send a disconnect command to node A (u [DISC,ABBR B, P=l] ). The SABM, SARM and SNRM modes set up communications using an 8-bit control field. Three other commands exist which set up a 16-bit control field, these are SABME (set asynchronous balanced mode extended), SARME and SNRME. The format of the 16-bit control field is given in Figure 1.8. m

Figure 1.6 Connection between a primary and secondary in NRM

Figure 1.7 Connection between a primary/secondary in SABM

576

Computer busses

Figure 1.8 Extended control field. Figure 1.9 shows an example conversation between a sending station (node A) and a receiving station (node B). Initially three information frames are sent numbered 2, 3 and 4 (I [N (S)=2], I [N (S)=3] and I [N (S)=4, P=l] ). The last ofthese frames has the poll bit set, which indicates to node B that node A wishes it to respond, either to acknowledge or reject previously unacknowledged frames. Node B does this by sending back a supervisory frame (s [RR, N (R) =5] ) with the receiver ready (RR) acknowledgement. This informs node A that node B expects to receive frame number 5 next. Thus it has acknowledged all frames up to and including frame 4. In the example in Figure 1.9 an error has occurred in the reception of frame 5. The recipient informs the sender by sending a supervisory flame with a reject flow command (s [REJ, N (R) = 5 ] ). After the sender receives this it resends each flame after and including frame 5. If the receiver does not want to communicate, at the present, it sends a receiver not ready flow command. For example s [RNR, N (R)=5] tells the transmitter to stop sending data, at the present. It also informs the sender that all flames up to flame 5 have been accepted. The sender will transmit flames once it has received a receiver ready flame from the receiver. Figure 1.9 shows an example of data flow in only the one direction. With ABM both stations can transmit and receive data. Thus each flame sent contains receive and send counter values. When stations send information flames the previously received flames can be acknowledged, or rejected, by piggy-backing the receive counter value. In Figure 1.10, node A sends three information frames with I [N ( S ) = 0 , N (R) - 0 ] , I [N ( S ) = 1 , N (R) - 0 ], and I [N (S) =2, N (R) =0]. The last flame informs node B that node A expects to receive frame 0 next. Node B then sends flame 0 and acknowledges the reception of all flames up to, and including flame 2 with I IN (S)=0 ,N (R)=3], and so on.

1.5 Derivatives of HDLC There are many derivatives of HDLC, including:

Microsoft Windows 9 9 9 9

577

LAPB (link access procedure balanced) is used in X.25 packet switched networks; LAPM(link access procedure for modems) is used in error correction modems; LLC (logical link control) is used in Ethernet and Token Ring networks; LAPD (link access procedure D-channel) is used in Integrated Services Digital Networks (ISDNs).

Figure 1.10 Exampleflow with piggy-backed acknowledgement