Data Link Control
Data Link Control
Character-oriented
oriented framing was popular when only text was exchanged by the data data-link layers.
The flag could be selected to be any character not used for text communication.
Now, however, we send other types of information such as graphs, audio, and video; any character
used for the flag could also be part of the information. If this happens, the receiver, when it
encounters this pattern in the middle of the data, thinks it ha
hass reached the end of the frame. To fix
this problem, a byte-stuffing
stuffing strategy was added to character
character-oriented
oriented framing.
In byte stuffing (or character stuffing), a special byte is added to the data section of the frame
when there is a character with the sa same
me pattern as the flag. The data section is stuffed with an
extra byte. This byte is
usually called the
escape character (ESC)
and has a predefined bit
pattern. Whenever the
receiver encounters the
ESC character, it
removes it from the
data section and treats
the next character as
data, not as a delimiting
flag. Figure shows the
situation.
Byte stuffing by the escape character allows the presence of the flag in the data section of the
frame, but it creates another problem
problem.. What happens if the text contains one or more escape
characters followed by a byte with the same pattern as the flag? The receiver removes the escape
character, but keeps the next byte, which is incorrectly interpreted as the end of the frameframe. To
solve this problem, the escape characters that are part of the text must also be marked by
another escape character.. In other words, if the escape character is part of the text, an extra one is
added to show that the second one is part of the text.
Character-oriented
nted protocols present another problem in data communications. The universal
coding systems in use today, such as Unicode, have 16-bit and 32-bitbit characters that conflict with
8-bit characters.
2. Bit-Oriented Framing
In bit-oriented framing, the data section of a frame is a sequence of bits to be interpreted by the
upper layer as text, graphic, audio, video, and so on on.. However, in addition to headers (and
possible trailers), we still need a delimiter to separate one frame from the other. Most protocols
use a special 8-bit
bit pattern flag,
01111110, as the delimiter to
define the beginning and the
end of the frame, as shown in
Figure.
This flag can create the same type of problem we saw in the character
character-oriented
oriented protocols. That is, if
the flag pattern appears rs in the data, we need to somehow inform the receiver that this is not the
end of the frame. We do this by stuffing 1 single bit (instead of 1 byte) to prevent the pattern from
looking like a flag. The strategy is called bit stuffing.
Bit stuffing is the process of adding one extra 0 whenever five consecutive 1s follow a 0 in the
data, so that the receiver does not mistake the pattern 0111110 for a flag.
This extra stuffed bit is
eventually removed from
the data by the receiver.
Note that the extra bit is
added after one 0 followed
by five 1s regardless of the
value of the next bit. This
guarantees that the flag field
sequence does not
inadvertently appear in the
frame.
Figure shows bit stuffing at
the sender and bit removal
at the receiver. Note that
even if we have a 0 after five 1s, we still stuff a 0. The 0 will be removed by the receiver. This means
that if the flaglike pattern 01111110 appears in the data, it will change to 011111010 (stuffed) and
is not mistaken for a flag by the receiver. The real fflag
lag 01111110 is not stuffed by the sender and is
recognized by the receiver.
-----------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------
Flow Control, Error Control
One of the responsibilities of the data
data-link control sublayer is flow and error control at the data-
data
link layer.
Flow Control
Whenever an entity produces items and another entity consumes them, there should be a balance
between production and consumption rates. If the items are produced faster than they can be
consumed, the consumer can be overwhelmed and may need to discard some items. If the items
are produced more slowly than they can be consumed, the consumer must wait, and the system
becomes less efficient.
cient. Flow control is related to the first issue. We need to prevent losing the data
items at the consumer site.
In communication at the data data-link
link layer, we are dealing with four entities: network and data-link
data
layers at the sending node and network and data-link link layers at the receiving node. Although we can
have a complex relationship with more than one producer and consumer, consumer we ignore the
relationships between networks and data data-link
link layers and concentrate on the relationship between
two data-link
layers, as shown in
Figure.
The figure shows
that the data-link
layer at the
sending node tries
to push frames toward the data data-link
link layer at the receiving node. If the receiving node cannot
process and deliver the packet to its network at the same rate that the frames arrive, it becomes
overwhelmed with frames. Flow control in this case can be feedback from the receiving node to the
sending node to stop or slow down pushing frames.
Buffers
Although flow control can be implemented in several ways, one of the solutions is normally to
use two buffers; one at the sending data data-link
link layer and the other at the receiving data-link
data
layer.. A buffer is a set of memory locations that can hold packets at the sender and receiver. The
flow control communication can occur by sending signals from the consumer to the producer.
When the buffer of the receiving datadata-link
link layer is full, it informs the sending data-link
data layer to
stop pushing frames.
Error Control
Since the underlying technology at the physical layer is not fully reliable, we need to implement
error control at the data-link link layer to prevent the receiving node from delivering corrupted
packets to its network layer.
Error control at the data-link
link layer is normally very simple and implemented using one of the
following two methods.. In both methods, a CRC is added to the frame header by the sender and
checked by the receiver.
1. In the first method, if the frame is corrupted, it is silently discarded
discarded;; if it is not corrupted, the
packet is delivered to the network layerlayer. This method is used mostly in wired LANs such as
Ethernet.
2. In the second method, if the frame is corrupted, it is silently discarded
discarded; if it is not corrupted, an
acknowledgment is sent (for the purpose of both flow and error control) to the sender sender.
Combination of Flow and Error Control
Flow and error control can be combined. In a simple situation, the acknowledgment that is sent
for flow control can also be used for error control to tell the sender the packet has arrived
uncorrupted. The lack of ackn
acknowledgment
owledgment means that there is a problem in the sent frame. frame A
frame that carries an acknowledgment is normally called an ACK to distinguish it from the data
frame.
--------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------
Connectionless and Connection Oriented
A DLC protocol can be either connectionless or connection
connection-oriented.
Connectionless Protocol
In a connectionless protocol, frames are sent from one node to the next without any relationship
between the frames; each frame is independent
independent.. Note that the term connectionless here does not
mean that there is no physical connection (transmission medium) between the nodes; it means
that there is no connection between frames
frames. The frames are not numbered and there is no sense
of ordering.
Most of the data-link
link protocols for LANs are connectionless protocols.
Connection-Oriented Protocol
In a connection-oriented
iented protocol, a logical connection should first be established between the
two nodes (setup phase).. After all frames that are somehow related to each other are transmitted
(transfer phase), the logical connection is terminated (teardown phase). In this type of
communication, the frames are numbered and sent in order. If they are not received in order, the
receiver needs to wait until all frames belonging to the same set are received and then deliver
them in order to the network layer.
Connection-oriented d protocols are rare in wired LANs, but we can see them in some pointpoint-to-
point protocols, some wireless LANs, and some WANs.
-----------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------
Data link layer protocols (P338)
Traditionally four protocols have been defined for the data data-link layer to deal with flow and error
control: (i) Simple, (ii) Stop-and
and-Wait, (iii) Go-Back-N, and (iv) Selective-Repeat
Repeat. Although the first
two protocols still are used at the data
data-link layer.
The behavior of a data-link-layer
layer protocol can be better shown as a finitee state machine (FSM). An
FSM is thought of as a machine with a finite number of states. The machine is always in one of the
states until an event occurs.
Each event is associated with two reactions
reactions:
o defining the list (possibly empty) of actions to be performed and
o determining the next state (which can be the same as the current state).
One of the states must be defined as the initial state, the state in which the machine sta starts when it
turns on.
-----------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------
Simple Protocol
Our first protocol is a simple protocol with neither flow nor error control
control. We assume that the
receiver can immediately handle any frame it receives. In other words, the receiver can never be
overwhelmed with incoming frames. Figure shows the layout for this protocol.
The data-link
link layer at the sender gets a packet from its network layer, makes a frame out of it, and
sends the frame. The data-link
link layer at the receiver receives a frame from the link, extracts the
packet from the frame, and delivers the packet to its network layer. The datadata-link layers of the
sender and receiver provide transmission services for their network layers.
FSMs (Finite State Machine)
The sender site should not send a frame until its network layer has a message to send. The receiver
site cannot deliver a message to its network layer until a frame arrives. We can show these
requirements using two FSMs. Each FSM has only one state, the ready state. The sending machine
remains in the ready state until a request com
comes
es from the process in the network layer. When this
event occurs, the sending machine encapsulates the message in a frame and sends it to the
receiving machine. The receiving machine remains in the ready state until a frame arrives from the
sending machine.
When this event
occurs, the receiving
machine decapsulates
the message out of the
frame and delivers it to
the process at the
network layer. Figure
shows the FSMs for
the simple protocol.
Example: The following Figure shows an example of communication using this protocol. It is very
simple. The sender sends frames one after another without even thinking about the receiver.
-----------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------
Stop-and-Wait Protocol
Our second protocol is called the Stop-and-Wait protocol, which uses both flow and error control.
In this protocol, the sender sends one frame at a time and waits for an acknowledgment before
sending the next one.
To detect corrupted frames, we need to add a CRC to each data frame frame.. When a frame arrives at
the receiver site, it is checked.
ed. If its CRC is incorrect, the frame is corrupted and silently discarded.
The silence of the receiver is a signal for the sender that a frame was either corrupted or lost.
Every time the sender sends a frame, it starts a timer. If an acknowledgment arriv arrives before the
timer expires, the timer is stopped and the sender sends the next frame (if it has one to send). If
the timer expires, the sender resends the previous frame, assuming that the frame was either lost
or corrupted. This means that the sender nee needs
ds to keep a copy of the frame until its
acknowledgment arrives.. When the corresponding acknowledgment arrives, the sender discards
the copy and sends the next frame if it is ready. Figure shows the outline for the Stop Stop-and-Wait
protocol. Note that only one frame and one acknowledgment can be in the channels at any time.
Problem Example: The first frame is sent and acknowledged. The second frame is sent, but lost.
After time-out,
out, it is resent. The third frame is sent and acknowledged, but the acknowledgment is
lost. The frame is resent. However, there is a problem with this scheme. The ne network layer at the
receiver site receives two copies of the third packet, which is not right. In the next section, we will
see how we can correct this problem using sequence numbers and acknowledgment numbers.
FSMs with Sequence and Acknowledgment Numbers
We saw a problem in Example that needs to be addressed and corrected. Duplicate packets, as
much as corrupted packets, need to be avoided. As an example, assume we are ordering some item
online. If each packet defines tthe
he specification of an item to be ordered, duplicate packets mean
ordering an item more than once.
To correct the problem, we need to add sequence numbers to the data frames and
acknowledgment numbers to the ACK frames. However, numbering in this case is very simple.
-----------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------
Piggybacking
The two protocols we discussed in this section are designed for unidirectional communication, in
which data is flowing only in one direction although the acknowledgment may travel in the other
direction.
Protocols have been designed in the past to allow data to flow in both d directions. However, to
make the communication more efficient, the data in one direction is piggybacked with the
acknowledgment in the other direction
direction.
In other words, when node A is sending data to node B, Node A also acknowledges the data
received from node
ode B. Because piggybacking makes communication at the datalink layer more
complicated, it is not a common practice
practice.
-----------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------
High Level Data Link Control (HDLC)
High-level
level Data Link Control (HDLC) is a bitbit-oriented
oriented protocol for communication over point-to-
point
point and multipoint links.. It implements the Stop-and-Wait protocol. Although this protocol is
more a theoretical issue than practical
practical,, most of the concept defined in this protocol is the basis for
other practical protocols such as PPP or the Ethernet protocol or in wireless LANs.
LANs
Configurations and Transfer Modes
HDLC provides two common transfer modes that can be used sed in different configurations:
1. Normal Response Mode
ode (NRM) and
2. Asynchronous Balanced MMode (ABM).
In normal response mode (NRM), the station configuration is unbalanced. We have one primary
station and multiple secondary stations. A primary station can send commands; a secondary station
can only respond. The NRM is used for both point
point-to-point
point and multipoint links,
lin as shown in Figure.
In Asynchronous Balanced Mode (ABM), the configuration is balanced. The link is point-to-point,
and each station can function as a primary and a secondary (acting as peers), as shown in Figure.
This is the common mode today.
Framing
To provide the flexibility necessary to support all the options possible in the modes and
configurations just described, HDLC defines three types of frames:
o information frames (I-frames)
o supervisory frames (S-frames), and
o unnumbered frames (U-frames).
Each type of frame serves as an envelope for the transmission of a different type of message.
I-frames are used to data-link user data and control information relating to user data
(piggybacking).
S-frames are used only to transport control information.
U-frames are reserved for system management. Information carried by U-frames is intended for
managing the link itself.
Each frame in HDLC may contain up to six fields, as shown in Figure:
o a beginning flag field
o an address field
o a control field
o an information field
o a frame check sequence (FCS) field, and
o an ending flag field.
In multiple-frame transmissions, the ending flag of one frame can serve as the beginning flag of the
next frame.
Let us now discuss the fields and their use in different frame types.
o Flag field. This field contains synchronization pattern 01111110, which identifies both the
beginning and the end of a frame.
o Address field. This field contains the address of the secondary station. If a primary station
created the frame, it contains a to address. If a secondary station creates the frame, it contains
a from address. The address field can be one byte or several bytes long, depending on the
needs of the network.
o Control field. The control field is one or two bytes used for flow and error control.
o Information field. The information field contains the user’s data from the network layer or
management information. Its length can vary from one network to another.
o FCS field. The frame check sequence (FCS) is the HDLC error detection field. It can contain
either a 2- or 4-byte CRC.
The control field determines the type of frame and defines its functionality. So let us discuss the
format of this field in detail. The format is specific for the type of frame, as shown in Figure.
N ARQ to improve the efficiency of the process by informing the sender, before the sender
timer expires, that the last frame is lost or damaged. The value of N(R) is the negative
acknowledgment number.
4. Selective reject (SREJ). If the value of the code subfield is 11, it is an SREJ Sframe. This is a
NAK frame used in Selective Repeat ARQ. Note that the HDLC Protocol uses the term
selective reject instead of selective repeat. The value of N(R) is the negative
acknowledgment number.
Control Field for U-Frames
Unnumbered frames are used to exchange session management and control information between
connected devices.
Unlike S-frames, U-frames contain an information field, but one used for system management
information, not user data.
As with S-frames, however, much of the information carried by
U-frames is contained in codes included in the control field.
U-frame codes are divided into two sections:
o a 2-bit prefix before the P/F bit and
o a 3-bit suffix after the P/F bit. Together, these two segments (5 bits) can be used to create up
to 32 different types of U-frames.
Example 11.5
Figure shows how U-frames can be used
for connection establishment and
connection release. Node A asks for a
connection with a set asynchronous
balanced mode (SABM) frame; node B
gives a positive response with an
unnumbered acknowledgment (UA) frame.
After these two exchanges, data can be
transferred between the two nodes (not
shown in the figure). After data transfer,
node A sends a DISC (disconnect) frame to
release the connection; it is confirmed by
node B responding with a UA (unnumbered
acknowledgment).
-----------------------------------------------------------------------------------------------------------------------------------------------------