hdlc protocol
hdlc protocol
hdlc protocol
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
HDLC PROTOCOL<br />
Michel GARDIE<br />
INT/LOR/RIP October 15, 2007
The version of this document is temporary. There are still several mistakes. I'm sorry for that.<br />
email: michel.gardie@int-edu.eu<br />
© 1985 FRANCE TELECOM INT/DIT/TI<br />
© 1992 INT/DSR/TI<br />
© 1994 INT/LOR/AIGRI<br />
© 2000 GET/INT/LOR/RIP<br />
© 2001 GET/INT/LOR/RIP<br />
© 2005 GET/INT/LOR/RIP<br />
© 2006 GET/INT/LOR/RIP<br />
© 2007 GET/INT/LOR/RIP<br />
Generated with OpenOffice.org 2.3 under Fedora 5<br />
Tous droits réservés. Aucune partie de ce document ne peut être reproduite ou transmise sous quelque forme ou par<br />
quelque procédé que ce soit (machine électronique ou mécanique, photocopie, enregistrement, photographie ou tout<br />
autre) sans le consentement écrit préalable de l’auteur ou de ses ayant-droits.<br />
GET/INT/LOR/RIP 2 of 33 October 15, 2007
HDLC<br />
ISO 3309 Data communication – High-level data link control procedures –<br />
Frame structure.<br />
ISO 4335 Data communication – High-level data link control procedures –<br />
Elements of procedure.<br />
ISO 6256<br />
Data communication – HDLC unbalanced classes of procedures.<br />
ISO 8885<br />
Information processing systems – Data communication -- Highlevel<br />
data link control procedures – General purpose XID frame<br />
information field content and format.<br />
ISO/IEC 13239<br />
Information technology – Telecommunications and information<br />
exchange between systems – High-level data link control<br />
(HDLC) procedures. 2002. (Revises 3309, 4335, 6256, 8885)<br />
HDLC is used in X.25 networks, has been adapted to create the PPP <strong>protocol</strong> (Internet), or the<br />
LAPDm <strong>protocol</strong> (data link layer on the GSM radio interface).<br />
GET/INT/LOR/RIP 3 of 33 October 15, 2007
HIGH-LEVEL DATA LINK CONTROL<br />
HDLC<br />
Overview<br />
●<br />
●<br />
●<br />
●<br />
●<br />
Synchronous<br />
Bit-oriented<br />
Full-duplex<br />
Transparent<br />
Point-to-point or multipoint links<br />
Features<br />
●<br />
●<br />
One frame structure<br />
Several elements of procedure<br />
GET/INT/LOR/RIP 4 of 33 October 15, 2007
FRAME STRUCTURE<br />
Definition<br />
Data and control information are transmitted within a single structure: the frame<br />
Frame structure<br />
Flag<br />
01111110<br />
Address<br />
8 bits<br />
Control<br />
8 bits<br />
Information<br />
0 ≤ n < ∞ bits<br />
FCS<br />
16 bits<br />
Flag<br />
01111110<br />
flag:<br />
address:<br />
control:<br />
information:<br />
FCS:<br />
sequence for synchronization and delimitation<br />
address of the secondary station<br />
controls the <strong>protocol</strong> behavior<br />
user data field<br />
frame check sequence<br />
GET/INT/LOR/RIP 5 of 33 October 15, 2007
FRAME FIELDS<br />
Flag<br />
●<br />
delimitation<br />
<br />
<br />
start of frame<br />
end of frame<br />
●<br />
●<br />
synchronization<br />
inter-frame filling<br />
Address<br />
●<br />
Address of the secondary station<br />
a secondary station receives command frames<br />
Control<br />
●<br />
●<br />
●<br />
●<br />
identifies the different frames<br />
numbers the information frames<br />
acknowledges the information frames<br />
supervises the data link<br />
GET/INT/LOR/RIP 6 of 33 October 15, 2007
FRAME FIELDS<br />
Information field<br />
●<br />
●<br />
●<br />
optional<br />
sequence of n bits<br />
user defined<br />
FCS<br />
●<br />
●<br />
allows detection of transmission errors<br />
cyclic redundancy check<br />
● polynomial: x 16 + x 12 + x 5 + 1<br />
GET/INT/LOR/RIP 7 of 33 October 15, 2007
FRAME CHARACTERISTICS<br />
Transparency<br />
●<br />
●<br />
Allows to transmit any bit pattern<br />
Principle (between two [non included] flags)<br />
<br />
<br />
Emission: inserts 1 "zero" after 5 consecutive "ones"<br />
Reception: suppresses every "zero" following 5 consecutive "ones"<br />
Frame inter-filling<br />
●<br />
●<br />
Maintains the synchronization<br />
Continuous emission of flags<br />
Frame abandon<br />
●<br />
Forces the receiver to ignore a frame<br />
● Sequence of M bits: M ≥ 7<br />
GET/INT/LOR/RIP 8 of 33 October 15, 2007
TRANSPARENCY<br />
The aim of transparency is to transmit any bit pattern between two flags.<br />
HDLC uses a special bit pattern (01111110) as a delimiter. This special pattern is<br />
called a flag.<br />
A receiver enters the reception state (and remains in this state) when it receives any<br />
bit pattern different from the delimitation pattern. It quits the reception state when it<br />
detects a new flag.<br />
However, the delimitation pattern can be found anywhere between two real flags:<br />
● it can be an ASCII character (tilde; "~") whose binary coding is 01111110<br />
● it can be the association of two adjacent bytes giving the illusion of a flag.<br />
For instance, let us consider the two following bytes: 10010011 and 11110011. When<br />
these byte are put together, we obtain the following binary stream:<br />
1001001111110011 where a "flag" seems to appear.<br />
We absolutely must remove these pseudo-flags when sending a frame. On the<br />
reception side, we will have to restore the original bit stream.<br />
The principle to do that is simple, and is applied only between two flags.<br />
On the sender side, we systematically add one "0" after five consecutive "1"s.<br />
On the receiver side, each time we receive five consecutive "1"s, we apply the<br />
following algorithm:<br />
1. if the next bit is a "0", this bit is immediately and systematically removed<br />
2. if the next bit is a "1", there are two possibilities:<br />
a) the next bit after this "1" is a "0": we are detecting a real flag. This is the<br />
end of the frame;<br />
b) the next bit after this "1" is still a "1": we are detecting an abandon<br />
sequence. The frame must be discarded.<br />
GET/INT/LOR/RIP 9 of 33 October 15, 2007
FRAME CHARACTERISTICS<br />
Invalid frames<br />
●<br />
Frame too short: less than 32 bits<br />
● Frame too Long 1<br />
Extensions<br />
●<br />
●<br />
Address field (2 or 3 bytes)<br />
Control field (2 bytes)<br />
1<br />
Example: the final flag has not been detected by the receiver, and its reception buffer is full.<br />
GET/INT/LOR/RIP 10 of 33 October 15, 2007
ELEMENTS OF PROCEDURE<br />
The elements of procedure define how to use the basic element of the <strong>protocol</strong>: the<br />
frame.<br />
The rest of this document presents the following points:<br />
●<br />
the different types of frame<br />
<br />
<br />
<br />
information<br />
supervision<br />
unnumbered<br />
●<br />
●<br />
●<br />
the rules of restart<br />
the transmission controls<br />
the "command" and "response" frames<br />
GET/INT/LOR/RIP 11 of 33 October 15, 2007
FRAME TYPES<br />
F A C Info FCS F<br />
8 7 6 5 4 3 2 1<br />
N(R) P/F N(S) 0<br />
N(R)<br />
P/F<br />
S<br />
S<br />
0<br />
1<br />
U U U P/F U U<br />
1<br />
1<br />
N(S)<br />
N(R)<br />
SS<br />
UUUUU<br />
P/F<br />
number of the sent frame<br />
number of the next expected frame<br />
bits defining the supervision functions<br />
bits defining the extra functions<br />
P (poll) = request of an explicit response<br />
F (final) = indication of an explicit response<br />
GET/INT/LOR/RIP 12 of 33 October 15, 2007
FRAME TYPES<br />
Information<br />
●<br />
The information field is not empty and its content is defined by the user.<br />
● The frame numbers are modulo 8 2<br />
<br />
<br />
N(S) number of the sent frame<br />
N(R) number of the next expected frame<br />
Supervision<br />
●<br />
No information field<br />
●<br />
Number transmitted by the frame: N(R)<br />
●<br />
This type of frame is used to:<br />
<br />
<br />
<br />
acknowledge information frames<br />
reject information frames<br />
specify the state of the receiving station<br />
2<br />
It is possible to use a modulus of 128. This is negotiated when establishing the connection.<br />
GET/INT/LOR/RIP 13 of 33 October 15, 2007
FRAME TYPES<br />
Unnumbered<br />
●<br />
●<br />
●<br />
No information field<br />
No frame number<br />
Basic control of the data link<br />
<br />
<br />
<br />
<br />
initialization (connection)<br />
connection reject<br />
disconnection<br />
indication of <strong>protocol</strong> errors<br />
GET/INT/LOR/RIP 14 of 33 October 15, 2007
SUPERVISION FUNCTIONS<br />
F A C Info FCS F<br />
8 7 6 5 4 3 2 1<br />
N(R) P/F S S 0 1<br />
S 4, S 3 = 0,0 RR Receiver Ready<br />
S 4, S 3 = 1,0 REJ Reject<br />
S 4, S 3 = 0,1 RNR Receiver Not Ready<br />
S 4, S 3 = 1,1 SREJ Selective Reject<br />
GET/INT/LOR/RIP 15 of 33 October 15, 2007
SUPERVISION FRAMES<br />
All the frames below acknowledge information frames whose number is less or equal<br />
to N(R) – 1 (modulo n).<br />
RR<br />
RECEIVER READY<br />
●<br />
●<br />
The receiver is ready to process new information frames.<br />
The previous received information frames have been correctly processed and<br />
their content has been delivered to the user.<br />
REJ<br />
REJECT<br />
●<br />
The receiver requests the retransmission of all information frames starting from<br />
the number N(R).<br />
GET/INT/LOR/RIP 16 of 33 October 15, 2007
SUPERVISION FRAMES<br />
RNR<br />
RECEIVER NOT READY<br />
●<br />
●<br />
The receiver temporarily cannot receive extra information frames.<br />
The previous frames (up to N(R) - 1) were correctly received but their content<br />
could not be delivered to the user.<br />
SREJ<br />
SELECTIVE REJECT<br />
●<br />
●<br />
●<br />
The receiver requests the retransmission of the information frame whose<br />
number is N(R).<br />
The next received frames (after N(R)) have been correctly received, and have<br />
been stored; the content of these frames has not been delivered to the user.<br />
The use of this supervision frame is optional.<br />
GET/INT/LOR/RIP 17 of 33 October 15, 2007
EXTRA FUNCTIONS<br />
FORMAT OF THE CONTROL FIELD OF THE UNNUMBERED FRAMES<br />
The table below only gives the most common frames.<br />
Table 1: Bits of the control field<br />
8 7 6 5 4 3 2 1 Meaning<br />
0 0 0 P/F 1 1 1 1<br />
SARM<br />
Set Asynchronous Response Mode<br />
0 0 1 P/F 1 1 1 1<br />
SABM<br />
Set Asynchronous Balanced Mode<br />
0 1 0 P/F 0 0 1 1<br />
DISC<br />
Disconnect<br />
0 1 1 P/F 0 0 1 1<br />
UA<br />
Unnumbered Acknowledgment<br />
0 0 0 P/F 1 1 1 1<br />
DM<br />
Disconnected Mode<br />
1 0 0 P/F 0 1 1 1<br />
CMDR / FRMR<br />
Command Reject / Frame Reject<br />
The CMDR / FRMR frames contain an information field explaining the reason of the reject.<br />
GET/INT/LOR/RIP 18 of 33 October 15, 2007
EXTRA FUNCTIONS<br />
LAPB (LINK ACCESS PROTOCOL BALANCED)<br />
SABM<br />
●<br />
●<br />
●<br />
●<br />
●<br />
Frame nature: command.<br />
Select the balanced mode (LAPB).<br />
The stations can both manage the data link.<br />
The acceptation of the connection is done with a UA frame.<br />
The rejection of the connection is done with a DM frame.<br />
DISC<br />
●<br />
●<br />
●<br />
Frame nature: command.<br />
Generates the logical disconnection of the data link between two stations.<br />
The receiving station must answer with a UA.<br />
GET/INT/LOR/RIP 19 of 33 October 15, 2007
EXTRA FUNCTIONS<br />
UA<br />
●<br />
●<br />
Frame nature: response.<br />
Accepts a command.<br />
FRMR<br />
●<br />
●<br />
Frame nature: response.<br />
Rejects a command:<br />
<br />
<br />
after an error;<br />
if the requested command is not implemented.<br />
DM<br />
●<br />
●<br />
Frame nature: response.<br />
Two functions:<br />
<br />
<br />
Indicates that a station is not logically connected.<br />
Rejects a command<br />
GET/INT/LOR/RIP 20 of 33 October 15, 2007
RULES OF RESTART<br />
Some error conditions or abnormal behavior may occur. The rules of restart resolve<br />
these problems.<br />
OVERFLOW<br />
●<br />
●<br />
A station, which cannot receive any more information frames, sends a RNR<br />
frame with N(R) indicating the first unaccepted frame.<br />
The station sends a RR frame as soon as it is ready again to receive new<br />
information frames.<br />
TRANSMISSION ERROR<br />
●<br />
●<br />
Any frame, whose FCS computation indicates a transmission error, must be<br />
discarded.<br />
No other specific action should be undertaken by the receiver.<br />
WRONG N(S) (REJ VERSION)<br />
●<br />
●<br />
Any information frame whose N(S) does not contain the expected value must<br />
be discarded; the next frames must be ignored too.<br />
The station receiving such a frame must then send a REJ frame with N(R)<br />
indicating the expected frame number.<br />
GET/INT/LOR/RIP 21 of 33 October 15, 2007
RULES OF RESTART<br />
WRONG N(S) (SREJ VERSION)<br />
●<br />
●<br />
Any information frame whose N(S) does not contain the expected value must<br />
be discarded. The eventual next information frames should be stored.<br />
A station receiving such a frame must then send a SREJ frame with N(R)<br />
indicating the expected frame number.<br />
COMMAND REJECT<br />
●<br />
After receiving a CMDR / FRMR frame, the data link is supposed to be<br />
disconnected.<br />
RESET<br />
●<br />
●<br />
●<br />
Clears a data link.<br />
The SABM and UA frames are exchanged without prior disconnection.<br />
The N(S) and N(R) counters are reset; the pending information frames are<br />
discarded.<br />
GET/INT/LOR/RIP 22 of 33 October 15, 2007
RULES OF RESTART<br />
RESTART AFTER TIME-OUT<br />
●<br />
●<br />
A station which does not receive any acknowledgment before T1 seconds, must<br />
retransmit the first unacknowledged information frame. The P/F bit of this<br />
information frame must be set.<br />
The station can then resume the transmission after the reception of an<br />
acknowledgment with the P/F bit set.<br />
BIT P/F<br />
●<br />
A station which receives a command frame with the P/F 3 bit set, must send a<br />
response frame with the P/F 4 bit also set.<br />
3<br />
The P/F bit is called P (Poll) in a command frame (e.g. Information frames)<br />
4<br />
The P/F bit is called F (Final) in a response frame (e.g. RR, RNR or REJ frames)<br />
GET/INT/LOR/RIP 23 of 33 October 15, 2007
TRANSMISSION CONTROL<br />
OVERVIEW<br />
Any transmission occurs between a PRIMARY and a SECONDARY.<br />
The primary station controls the data link.<br />
The secondary station is tied to the primary station.<br />
STATION<br />
A station may be composed of:<br />
●<br />
●<br />
●<br />
a primary<br />
a secondary<br />
a primary and a secondary<br />
GET/INT/LOR/RIP 24 of 33 October 15, 2007
ADDRESS FIELD<br />
The address field is used to make a distinction between the command and the<br />
response frames.<br />
CODING OF THE ADDRESS FIELD IN THE X.25 PROTOCOL<br />
There are only two values with the following coding:<br />
Address<br />
Bit number<br />
1 2 3 4 5 6 7 8<br />
hexadecimal<br />
A 0 0 0 0 0 0 1 1 03<br />
B 0 0 0 0 0 0 0 1 01<br />
The use of these values is explained below:<br />
Sender ►<br />
Frame nature Network<br />
DTE<br />
▼<br />
Command A B<br />
Response B A<br />
GET/INT/LOR/RIP 25 of 33 October 15, 2007
FLOW CONTROL<br />
The flow control is used to regulate the information flow between stations.<br />
✔<br />
The mechanism used is a window.<br />
✔<br />
A station can send up to W information frames before receiving any<br />
acknowledgment.<br />
✔<br />
The window is closed if the station has sent W frames and did not receive any<br />
acknowledgment.<br />
✔<br />
A station cannot send other information frames if its window is closed.<br />
✔<br />
The receiver can acknowledge one, several, or all the information frames<br />
previously received.<br />
✔<br />
When a station acknowledges some informations frames, it opens more or less the<br />
window of its peer.<br />
GET/INT/LOR/RIP 26 of 33 October 15, 2007
FLOW CONTROL<br />
DTE<br />
W = 3<br />
NETWORK<br />
DLDTreq<br />
I 0,0<br />
DLDTreq<br />
DLDTind<br />
I 0,0<br />
DLDTreq<br />
I 0,0<br />
DLDTind<br />
DLDTreq<br />
RR 2<br />
DLDTind<br />
I 0,0<br />
DLDTind<br />
RR 2<br />
W = 3 the window size is 3.<br />
DLDTreq :<br />
DLDTind :<br />
I,0,2 :<br />
RR,2 :<br />
primitive of service sent by the user of the level 2 (DTE side): DLDTreq = Data Link Data request.<br />
primitive of service sent by the user of the level 2 (network side): DLDTind = Data Link Data indication.<br />
information frame, N(R)=0, N(S)=2<br />
supervision frame RR, N(R)=2<br />
GET/INT/LOR/RIP 27 of 33 October 15, 2007
LIST OF SOME PARAMETERS USED AT THE FRAME LEVEL<br />
TIMER T1<br />
●<br />
●<br />
On timeout of this timer, the first unacknowledged information frame must be<br />
sent again.<br />
Standard values:<br />
<br />
T1 = 100, 200, 400, 800, 1600, 2500 ms<br />
TIMER T2<br />
●<br />
Maximum time that a receiver can wait to acknowledge an information frame.<br />
N2<br />
●<br />
●<br />
Maximum number of retransmission of the same information frame.<br />
If this value is reached, the link is considered to be out-of-order.<br />
● Standard value: 10<br />
N1<br />
●<br />
Maximum size of an information frame.<br />
GET/INT/LOR/RIP 28 of 33 October 15, 2007
EXCHANGE MODES<br />
DEFINITIONS<br />
INFORMATION<br />
SOURCE<br />
ACKNOWLEDGMENT<br />
DESTINATION<br />
COMMAND<br />
PRIMARY<br />
RESPONSE<br />
SECONDARY<br />
PRIMARY<br />
SOURCE<br />
SELECTING<br />
ACCEPTANCE<br />
INFORMATION<br />
ACKNOWLEDGMENT<br />
SECONDARY<br />
DESTINATION<br />
PRIMARY<br />
DESTINATION<br />
POLLING<br />
ACCEPTANCE<br />
INFORMATION<br />
ACKNOWLEDGMENT<br />
SECONDARY<br />
SOURCE<br />
GET/INT/LOR/RIP 29 of 33 October 15, 2007
EXCHANGE MODES<br />
ASYMMETRIC POINT-TO-POINT<br />
Station A<br />
Station B<br />
PRIMARY<br />
SECONDARY<br />
SOURCE<br />
I<br />
SEL<br />
POLL<br />
I<br />
ACK<br />
I<br />
DEST.<br />
ACK<br />
DEST.<br />
I<br />
I<br />
I<br />
SOURCE<br />
This mode is typically intended for multi-point links. Asymmetric point-to-point link<br />
is an adaptation of multi-point links.<br />
The information frames can be either "command" frames, or "response" frames.<br />
This mode is selected with the command frame "SNRM (Set Normal Response<br />
Mode)".<br />
GET/INT/LOR/RIP 30 of 33 October 15, 2007
EXCHANGE MODES<br />
SYMMETRIC POINT-TO-POINT<br />
Station A<br />
Station B<br />
PRIMARY<br />
I<br />
I<br />
I<br />
SECONDARY<br />
SOURCE<br />
ACK<br />
DEST.<br />
SECONDARY<br />
ACK<br />
PRIMARY<br />
DEST.<br />
I<br />
I<br />
I<br />
SOURCE<br />
This mode is selected with the command frame "SARM (Set Asynchronous Response<br />
Mode)".<br />
The information frames are always "command" frames.<br />
The supervisions frames (RR, RNR, REJ...) are generally "response" frames.<br />
GET/INT/LOR/RIP 31 of 33 October 15, 2007
EXCHANGE MODE<br />
BALANCED POINT-TO-POINT<br />
Station A<br />
Station B<br />
SOURCE<br />
DEST.<br />
Combined station<br />
Combined station<br />
DEST.<br />
SOURCE<br />
In this mode, the concepts of "primary" and "secondary" are replaced by the concept<br />
of "combined station".<br />
The command frames (INFO, SABM, DISC...) always carry the address of the remote<br />
station.<br />
The response frames (RR, RNR, UA, DM....) always carry the address of the local<br />
station.<br />
This mode is selected with the command frame "SABM (Set Asynchronous Balanced<br />
Mode)".<br />
GET/INT/LOR/RIP 32 of 33 October 15, 2007
CREDITS<br />
This document was written with OpenOffice.org 2.3 (http://www.openoffice.org).<br />
Different fonts were used:<br />
Font name Web site Sample (12pt)<br />
Calisto MT http://netsourcesfr.free.fr/Polices_C.htm The quick brown fox jumps over<br />
the lazy dog<br />
Daniel http://www.dafont.com The quick brown fox jumps<br />
over the lazy dog<br />
Goodfish http://www.dafont.com The quick brown fox jumps over the lazy<br />
dog<br />
Morpheus http://www.dafont.com The quick brown fox jumps over<br />
the lazy dog<br />
Times New Roman http://www.myfonts.com (not free) The quick brown fox jumps over<br />
the lazy dog<br />
GET/INT/LOR/RIP 33 of 33 October 15, 2007