8/3/2019 Hdlc Final
1/13
Communication Protocols:
Introduction:A communications protocol is a formal description of digital message formats and the rules for
exchanging those messages in or between computing systems and in telecommunications.
Protocols may include signaling, authentication and error detection and correction capabilities. A protocol
defines the syntax, semantics, and synchronization of communication, and the specified behavior is
typically independent of how it is to be implemented. A protocol can therefore be implemented as
hardware or software or both. In computer science the word algorithm is a synonym for the word
procedure so a protocol is to communications what an algorithm is to mathematics.
Communicating systems use well-defined formats for exchanging messages. Each message has an exact
meaning intended to provoke a defined response of the receiver. A protocol therefore describes the
syntax, semantics, and synchronization of communication. A programming language describes the same
for computations, so there is a close analogy between protocols and programming languages: protocols
are to communications what programming languages are to computations. (A less technical reader mightappreciate this similar analogy: protocols are to communications what grammar is to writing.)
The communications protocols in use on the Internet are designed to function in very complex and diversesettings. To ease design, communications protocols are structured using a layering scheme as a basis.
Instead of using a single universal protocol to handle all transmission tasks, a set of cooperating protocols
fitting the layering scheme is used. The layering scheme in use on the Internet is called the TCP/IP model.
The actual protocols are collectively called the Internet protocol suite. The group responsible for thisdesign is called the Internet Engineering Task Force (IETF).
The information exchanged between devices on a network or other communications medium is governed
by rules or conventions that can be set out in a technical specification called a communication protocol
standard. The nature of the communication, the actual data exchanged and any state-dependent behaviors
are defined by the specification. Communicating systems have to communicate with each other using
shared transmission media, because there is no common memory. Transmission is not necessarily reliable
and can involve different hardware and operating systems on different systems.
To implement a networking protocol, the protocol software modules are interfaced with a frameworkimplemented on the machine's operating system. This framework implements the networking
functionality of the operating system. The best known frameworks are the TCP/IP model and the OSI
model.
In communications, message values are transferred using transmission media. By analogy, the equivalent
of a store would be a collection of transmission media, instead of a collection of memory locations. A
valid assignment in a protocol (as an analog of programming language) could be Ethernet:='message' ,
meaning a message is to be broadcast on the local Ethernet.
On a transmission medium there can be many receivers. For instance a mac-address identifies an ether
network card on the transmission medium (the 'ether'). In our imaginary protocol, the assignment
Ethernet[mac-address]:=message value could therefore make sense.
Basic requirements of protocols:Messages are sent and received on communicating systems to establish communications. Protocols should
therefore specify rules governing the transmission. In general, much of the following should be addressed.
Data formats for data exchange. Digital message bit strings are exchanged. The bit strings are dividedin fields and each field carries information relevant to the protocol. Conceptually the bit string is divided
into two parts called the header area and the data area. The actual message is stored in the data area, so
the header area contains the fields with more relevance to the protocol. Bit strings longer than the
maximum transmission unit (MTU) are divided in pieces of appropriate size.
8/3/2019 Hdlc Final
2/13
Address formats for data exchange. Addresses are used to identify both the sender and the intended
receiver(s). The addresses are stored in the header area of the bitstrings, allowing the receivers to
determine whether the bitstrings are intended for themselves and should be processed or should be
ignored. A connection between a sender and a receiver can be identified using an address pair (sender
address, receiver address). Usually some address values have special meanings. An all-1s address could
be taken to mean an addressing of all stations on the network, so sending to this address would result in a
broadcast on the local network. The rules describing the meanings of the address value are collectivelycalled an addressing scheme.
Address mapping. Sometimes protocols need to map addresses of one scheme on addresses of another
scheme. For instance to translate a logical IP address specified by the application to an Ethernet hardware
address. This is referred to as address mapping.
Routing. When systems are not directly connected, intermediary systems along the route to the intended
receiver(s) need to forward messages on behalf of the sender. On the Internet, the networks are connected
using routers. This way of connecting networks is called internetworking.
Detection of transmission errors is necessary on networks which cannot guarantee error-free operation.
In a common approach, CRCs of the data area are added to the end of packets, making it possible for the
receiver to detect differences caused by errors. The receiver rejects the packets on CRC differences and
arranges somehow for retransmission.
Acknowledgements of correct reception of packets is required for connection oriented communication.Acknowledgements are sent from receivers back to their respective senders.
Loss of information - timeouts and retries. Packets may be lost on the network or suffer from long
delays. To cope with this, under some protocols, a sender may expect an acknowledgement of correct
reception from the receiver within a certain amount of time. On timeouts, the sender must assume thepacket was not received and retransmit it. In case of a permanently broken link, the retransmission has no
effect so the number of retransmissions is limited. Exceeding the retry limit is considered an error.
Direction of information flow needs to be addressed if transmissions can only occur in one direction at
a time as on half-duplex links. This is known as Media Access Control. Arrangements have to be made to
accommodate the case when two parties want to gain control at the same time.
Sequence control. We have seen that long bitstrings are divided in pieces, that are send on the network
individually. The pieces may get lost or delayed or take different routes to their destination on some types
of networks. As a result pieces may arrive out of sequence. Retransmissions can result duplicate pieces.By marking the pieces with sequence information at the sender, the receiver can determine what was lost
or duplicated, ask for necessary retransmissions and reassemble the original message.
Flow controlis needed when the sender transmits faster than the receiver or intermediate network
equipment can process the transmissions. Flow control can be implemented by messaging from receiver
to sender.
Getting the data across a network is only part of the problem for a protocol. The data received has to be
evaluated in the context of the progress of the conversation, so a protocol has to specify rules describing
the context. These kind of rules are said to express the syntax of the communications. Other rules
determine whether the data is meaningful for the context in which the exchange takes place. These kind of
rules are said to express the semantics of the communications. Both intuitive descriptions as well as moreformal specifications in the form of finite state machine models are used to describe the expected
interactions of the protocol. Formal ways for describing the syntax of the communications are Abstract
Syntax Notation One (a ISO standard) or Augmented Backus-Naur form (a IETF standard).
Protocol designCommunicating systems operate in parallel. The programming tools and techniques for dealing withparallel processes are collectively called concurrent programming. Concurrent programming only deals
with the synchronization of communication. The syntax and semantics of the communication governed by
8/3/2019 Hdlc Final
3/13
a low-level protocol usually have modest complexity, so they can be coded with relative ease. High-level
protocols with relatively large complexity could however merit the implementation of language
interpreters. An example of the latter case is the HTML language.
Concurrent programming has traditionally been a topic in operating systems theorie texts. Formal
verification seems indispensable, because concurrent programs are notorious for the hidden and
sophisticated bugs they contain. A mathematical approach to the study of concurrency and
communication is referred to as Communicating Sequential Processes (CSP). Concurrency can also bemodelled using finite state machines like Mealy- and Moore machines. Mealy- and Moore machines are
in use as design tools in digital electronics systems, which we encounter in the form of hardware used in
telecommunications or electronic devices in general.
This kind of design can be a bit of a challenge to say the least, so it is important to keep things simple. For
the Internet protocols, in particular and in retrospect, this meant a basis for protocol design was needed to
allow decomposition of protocols into much simpler, cooperating protocols
The OSI ModelThe Open Systems Interconnection (OSI) is a seven-layer protocol stack model used as a reference
throughout the computer industry. The ISO was developed as a functional reference model only. One
must note that some well known protocols such as TCP/IP and Signaling System 7 (SS7) were developedbefore the OSI model, and therefore do not exactly align with the defined OSI boundaries, where protocol
stacks like IBMs SNA have a very close relationship. However, when used as a reference, the OSI modelgives us a general idea of what to expect from the various layers of a given protocol stack.
OSI Stack Protocol Model;
8/3/2019 Hdlc Final
4/13
HDLC Protocol:HDLC (High Level Data Link Control) is one of the most common data link layer (layer 2) protocols.
Many other common layer 2 protocols are heavily based on HDLC, particularly its framing structure. The
HDLC protocol is defined by ISO for use on both point-to-point and multipoint (multidrop) data links. It
supports full duplex transparent-mode operation and is now extensively used in both multipoint and
computer networks.
The rule of HDLC is to ensure that the data has been received without any loss or errors and in the correct
order. HDLC has a flow control function which ensures that the data is transmitted as fast as the receiver
can receive it.
High-level Data Link Control (HDLC) is an enhanced derivative of SDLC from IBM. HDLC is the
default serial link protocol for Cisco routers. Nearly all other routers on the market use PPP for link
control. HDLC is a Data Link layer protocol. These protocols allow computers on either end of a physical
connection (end stations) to communicate.
There are two distinct HDLC implementations: HDLC NRM (also known as SDLC) and HDLC Link
Access Procedure Balanced (LAPB), the later is a more popular implementation. HDLC is usually usedby X.25.
LAPB is a bit-oriented synchronous protocol that provides complete data transparency in a full-duplex
point-to-point operation. It supports a peer-to-peer link in that neither end of the link plays the role of the
permanent master station. HDLC NRM, on the other hand, has a permanent primary station with one or
more secondary stations.
HDLC LAPB is a very efficient protocol, which requires a minimum of overhead to ensure flow control,
error detection and recovery. If data is flowing in both directions (full duplex), the data frames themselves
carry all the information required to ensure data integrity.
The concept of a frame window is used to send multiple frames before receiving confirmation that the
first frame has been correctly been received. This means that data can continue to flow in situations where
there may be long "turn-around" time lags without stopping to wait for an acknowledgement. This kind of
situation occurs, for instance in satellite communication.
Types of HDLC Stations:
PrimaryPrimary stations manage the connection to all secondary sessions by sending commands. Primary
stations open and close connections and poll remote stations for data, or availability. Primary stations
are used primarilly in multi-point networks or with mainframe applications where the mainframe is
the primary station. The primary station uses unbalanced mode to communicate with the secondary
stations. The primary station is responsible for all error detection, line control and data flow control.
SecondarySecondary machines respond to commands sent from the Primary. Secondary stations are
usually terminals attatched to mainframes. Communication between secondary stations and
primary stations is in unbalanced mode. The secondary station can only respond to the primary
station and only when signaled to do so by the primary station.
CombinedCombined stations can establish and tear down their own connections. A combined station has the
capabilities of both primary and secondary stations. These station types are usually used in point-to-pointserial links such as a V.35 link to a CSU/DSU or between routers connected by a T1 or frame relay.
Communication between two combined stations is in balanced mode.
8/3/2019 Hdlc Final
5/13
Configurations of HDLC:HDLC also defines three types of configurations for the three types of stations. The word configuration
refers to the relationship between the hardware devices on a link. Following are the three configurations
defined by HDLC:
Unbalanced Configuration Balanced Configuration Symmetrical ConfigurationUnbalanced ConfigurationThe unbalanced configuration in an HDLC link consists of a primary station and one or more secondary
stations. The unbalanced condition arises because one station controls the other stations. In an unbalanced
configuration, any of the following can be used:
Full-Duplex or Half-Duplex operation Point to Point or Multi-point networksAn example of an unbalanced configuration can be found below in Fig
Balanced ConfigurationThe balanced configuration in an HDLC link consists of two or more combined stations. Each of the
stations has equal and complimentary responsibility compared to each other. Balanced configurations can
use only the following:
Full - Duplex or Half - Duplex operation Point to Point networks
An example of a balanced configuration can be found below in Fig
8/3/2019 Hdlc Final
6/13
Symmetrical ConfigurationThis third type of configuration is not widely in use today. It consists of two independent point-
to-point, unbalanced station configurations as shown in Fig.In this configuration, each station has a
primary and secondary status. Each station is logically considered as two stations.
HDLC Operation Modes;HDLC has three operational modes:
1. Normal Response Mode (NRM)Normal Response Mode is used in unbalanced configurations, a configuration is which there is only one
primary, controlling station. In this mode, slave stations (or secondary) can only transmit when specially
instructed by the master (primary station). The link may be point-to-point or multipoint. In the latter case
only one primary station is allowed.
2. Asynchronous Response Mode (ARM)Asynchronous Response Mode is used in unbalanced configurations. It allows a secondary station to
initiate a transmission without receiving permission from the primary station. This mode is normally used
with point-to-point configurations and full duplex links and allows the secondary station to send framesasynchronously with respect to the primary station.
3. Asynchronous Balanced Mode (ABM)The Asynchronous Balanced Mode (ABM) is used mainly on full duplex point-to-point links for
computer to computer communications and for connections between a computer and a packed switched
data network, in this case each station has an equal status and performs the role of both primary and
secondary functions. This mode is used in the protocol set known as X.25.
HDLC Non-Operational Modes;HDLC also defines three non-operational modes. These three non-operational modes are:
Normal Disconnected Mode (NDM) Asynchronous Disconnected Mode (ADM) Initialization Mode (IM)The two disconnected modes (NDM and ADM) differ from the operational modes in that the secondary
station is logically disconnected from the link (note the secondary station is not physically disconnected
from the link). The IM mode is different from the operations modes in that the secondary station's data
link control program is in need of regeneration or it is in need of an exchange of parameters to be used in
an operational mode.
Protocol Structure - HDLC: High Level Data Link Control
Frame FormatThe standards frame of the HDLC protocol handles both data and control messages.
It has the following format:
Flag Address Control Information FCS Flag
1 Byte 1-2 Bytes 1 Byte variable 2 Bytes 1 Byte
8/3/2019 Hdlc Final
7/13
The Flag fieldEvery frame on the link must begin and end with a flag sequence field (F). Stations attached to the data
link must continually listen for a flag sequence. The flag sequence is an octet looking like 01111110.
Flags are continuously transmitted on the link between frames to keep the link active. Two other bit
sequences are used in HDLC as signals for the stations on the link. These two bit sequences are:
Seven 1's, but less than 15 signal an abort signal. The stations on the link know there is a problemon the link.
15 or more 1's indicate that the channel is in an idle state.
The time between the transmissions of actual frames is called the interframe time fill. The interframe
time fill is accomplished by transmitting continuous flags between frames. The flags may be in 8 bit
multiples.
HDLC is a code-transparent protocol. It does not rely on a specific code for interpretation of line control.
This means that if a bit at position N in an octet has a specific meaning, regardless of the other bits in the
same octet. If an octet has a bit sequence of 01111110, but is not a flag field, HLDC uses a technique
called bit-stuffing to differentiate this bit sequence from a flag field as we have discussed in the previous
lesson.
At the receiving end, the receiving station inspects the incoming frame. If it detects 5 consecutive 1's itlooks at the next bit. If it is a 0, it pulls it out. If it is a 1, it looks at the 8th bit. If the 8th bit is a 0, it
knows an abort or idle signal has been sent. It then proceeds to inspect the following bits to determine
appropriate action. This is the manner in which HDLC achieves code-transparency. HDLC is notconcerned with any specific bit code inside the data stream. It is only concerned with keeping flags
unique.
Address fieldThe address of the secondary station which is sending the frame or the destination of the frame sent by the
primary station. The address field contains Service Access Point (6bits), a Command/Response bit to
indicate whether the frame relates to information frames (I-frames) being sent from the node or received
by the node, and an address extension bit which is usually set to true to indicate that the address is of
length one byte. When set to false it indicates an additional byte follows. The address field may beextended to more than one byte by agreement between the involved parties.
Control field :It identifies the type of the frame. In addition, it includes sequence numbers, control features and error
tracking according to the frame type.
Information field Data is transmitted in the information field, which can vary in length depending upon the protocol using
the frame. Layer 3 frames are carried in the information field.
FCS The Frame Check Sequence (FCS) is in most cases - 16 bit wide and serves for errors detection, the
generator polynomial used is normally CRC-CCITT: x^16+x^12+x^5+1 .HDLC uses zero insertion/deletion process (commonly known as bit stuffing) to ensure that the bit pattern
of the delimiter flag does not occur in the fields between flags. The HDLC frame is synchronous and
therefore relies on the physical layer to provide method of clocking and synchronizing the transmission
and reception of frames.
Field Name Size(in bits)
Flag Field( F ) 8 bits
Address Field( A ) 8 bits
8/3/2019 Hdlc Final
8/13
Control Field( C ) 8 or 16 bits
Information Field( I ) OR Data Variable; Not used in some frames
Frame Check Sequence( FCS ) 16 or 32 bits
Closing Flag Field( F ) 8 bits
Categories of Frames;There are three categories of frames:
Information framestransport data across the link and may encapsulate the higher layers of the OSIarchitecture.
Supervisory framesperform the flow control and error recovery functions. Unnumbered framesprovide the link initialization and termination.
In the HDLC protocol three classes of frames are used:
1. Unnumbered framesUnnumbered frames are used for link management. . SNRM and SABM frames, for example, are used
both to set up logical link between the primary and the secondary station and to inform the secondary
station of the mode of operation to be used. A logical link is subsequently cleared by the primary station
sending a DISC frame. The UA frame is used as an acknowledgment to the other frames in this class.
8/3/2019 Hdlc Final
9/13
Unnumbered Format Commands and responses (U-Frame)The unnumbered format commands and responses are used to extend the number of data link control
functions. The unnumbered format frames have 5 modifier bits, which allow for up to 32 additionalcommands and 32 additional response functions. Below, 13 command functions, and 8 response functions
are described.
Set Normal Response Mode (SNRM) places the secondary station into NRM. NRM does not allow thesecondary station to send any unsolicited frames. Hence the primary station has control of the link.
Set Asynchronous Response Mode (SARM) allows a secondary station to transmit frames without a
poll from the primary station.
Set Asynchronous Balanced Mode (SABM) sets the operational mode of the link to ABM.
Disconnect (DISC) places the secondary station in to a disconnected mode.
Set Normal Response Mode Extended (SNRME) increases the size of the control field to 2 octets
instead of one in NRM. This is used for extended sequencing. The same applies for SARMEand SABME.
Set Initialization Mode (SIM) is used to cause the secondary station to initiate a station-specific
procedure(s) to initialize its data link level control functions.Unnumbered Poll (UP) polls a station without regard to sequencing or acknowledgment.
Unnumbered Information (UI) is used to send information to a secondary station.
Exchange Identification (XID) is used to cause the secondary station to identify itself and provide the
primary station identifications characteristics of itself.
Reset (RSET) is used to reset the receive state variable in the addressed station.
Test (TEST) is used to cause the addressed secondary station to respond with a TEST response at the
first response opportunity. It performs a basic test of the data link control.
Unnumbered Acknowledgment (UA) is used by the secondary station to acknowledge the receipt and
acceptance of an SNRM, SARM, SABM, SNRME, SARME, SABME, RSET, SIM, orDISCcommands.
Disconnected Mode (DM) is transmitted from a secondary station to indicate it is in disconnected
mode(non-operational mode.)
Request Initialization Mode (RIM) is a request from a secondary station for initialization to a primary
station. Once the secondary station sends RIM, it can only respond to SIM, DSIC, TEST or XID
commands.
Request Disconnect (RD) is sent by the secondary station to inform the primary station that it wishes to
disconnect from the link and go into a non-operational mode(NDM or ADM).
Frame Reject (FRMR) is used by the secondary station in an operation mode to report that a condition
has occurred in transmission of a frame and retransmission of the frame will not correct the condition.
8/3/2019 Hdlc Final
10/13
2. Information framesInformation frames are those who carry the actual data. The Information frames can be used to piggyback
acknowledgment information relating to the flow of Information frames in the reverse direction when the
link is being operated in ABM or ARM.
3. Supervisory framesSupervisory frames are use for error and flow control. They contain, send and receive sequence numbers.
There are four types of supervisory frames but only RR and RNR are used in both NRM and ABM. These
frames are used both to indicate the willingness of a secondary station to receive an information frame
from the primary station, and for acknowledgment purposes. REJ and SREJ frames are used only in ABM
which permits simultaneous two-way communication across a point to point link. The two frames areused to indicate to the other station that a sequence error has occurred, that is an information frame
containing an out of sequence N(s) has been received. The SREJ frame is used with a selective repeat
transmission procedure, whereas the REJ frame is used with a go back N procedure.
Supervisory Format commands and responses are as follows:
Receive Ready (RR) is used by the primary or secondary station to indicate that it is ready to receive an
information frame and/or acknowledge previously received frames.
Receive Not Ready (RNR) is used to indicate that the primary or secondary station is not ready to
receive any information frames or acknowledgments.
Reject (REJ) is used to request the retransmission of frames.
Selective Reject (SREJ) is used by a station to request retransmission of specific frames. An SREJ must
be transmitted for each erroneous frame; each frame is treated as a separate error. Only one SREJ can
remain outstanding on the link at any one time.
In a Nutshell;
Information Transfer Information Transfer
Format Commands Format ResponsesI - Information I - Information
Supervisory Format Supervisory Format
Commands ResponsesRR - Receive ready RR - Receive ready
RNR - Receive not ready RNR - Receive not ready
REJ - Reject REJ - Reject
SREJ - Selective reject SREJ - Selective reject
Unnumbered Format Unnumbered Format
8/3/2019 Hdlc Final
11/13
Commands CommandsSNRM - Set Normal Response Mode UA - Unnumbered Acknowledgm
SARM - Set Asynchronous Response Mode DM - Disconnected Mode
SABM - Set Asynchronous Balanced Mode RIM - Request Initialization Mod
DISC - Disconnect RD - Request Disconnect
SNRME - Set Normal Response Mode Extended UI - Unnumbered Information
SARME - Set Asynchronous Response Mode Extended XID - Exchange IdentificationSABME - Set Asynchronous Balanced Mode Extended FRMR - Frame Reject
SIM - Set Initialization Mode TEST - Test
UP - Unnumbered Poll
UI - Unnumbered Information
XID - Exchange identificationRSET - Reset
TEST - Test
The Poll/Final Bit (P/F)The 5th bit position in the control field is called the poll/final bit, or P/F bit. It can only be recognized
when it is set to 1. If it is set to 0, it is ignored. The poll/final bit is used to provide dialogue between theprimary station and secondary station. The primary station uses P=1 to acquire a status response from the
secondary station. The P bit signifies a poll. The secondary station responds to the P bit by transmitting a
data or status frame to the primary station with the P/F bit set to F=1. The F bit can also be used to signal
the end of a transmission from the secondary station under Normal Response Mode.
Protocol Operation
The two basic functions in the protocol are link management and data transfer (which includes error and
flow control).
Link management
Prior to any kind of transmission (either between two stations connected by a point to point link or
between a primary and secondary station connected with a multidrop link) a logical connection between
the two communication parties must be established.
A logical connection between the two communication parties is accomplished by the exchange of two
unnumbered frames. The procedure for setting a logical connection (In a multidrop link) is given below:
The SNRM is first sent by the primary station with the poll bit set to 1 and the address of the appropriate
secondary in the address field. The secondary responds with a UA frame with the final bit set and its own
address in the address field. After all the data has been transferred, the link is cleared by the primary
sending a DISC frame and the secondary responding with a UA.
8/3/2019 Hdlc Final
12/13
Data transfer
In NRM all data (information frames) istransferred under the control of the primarystation. The unnumbered poll frame with the
P bit set to 1 is normally used by the primary
to poll a secondary. If the secondary has no
data to transmit, it returns an RNR frame
with the F bit set. If data is waiting, ittransmits the data, typically as a sequence of
information frames.
The two most important aspects associated with the data transfer phase are error control and flow control.
Essentially, error control uses a continuous RQ procedure with either a selective repeat or a go back N
transmission strategy, while flow controls based on a window mechanism.
TransparencyThe flag sequence must never occur within the content of a frame otherwise it could be confused with an
intentionally sent flag. A technique known as 0-bit insertion is used to prevent random data synthesising a
flag. The technique is said to make HDLC transparent, since any stream of bits may be present between
the open and closing flag of a frame. The transparency is achieved by encoding the data by inserting a 0-
bit after any sequence of 5 consecutive 1's within the payload, as shown:
Insertion of a "zero-bit" into the content of a frame to ensure transparency
Bit stuffing and removal
8/3/2019 Hdlc Final
13/13
FSM of Transparency: