Last Part of Datalink Layer
Last Part of Datalink Layer
Data can be corrupted during transmission. Some applications require that errors be detected and
corrected. Whenever bits flow from one point to another, they are subject to unpredictable
changes because of interference. Thus, we say that error had occurred. There are two types of
error: single-bit error and burst error. In a single-bit error, only 1 bit in the data unit has changed
whereas, in burst error means that 2 or more bits in the data unit have changed as shown in Fig
2.13.
Block Coding: In block coding, we divide our message into blocks, each of k bits, called
datawords. We add r redundant bits to each block to make the length n = k + r. The resulting n-
bit blocks are called codewords as shown in Fig 2.14.
An error-detecting code can detect only the types of errors for which it is designed; other types
of errors may remain undetected. Fig 2.15 shows the process of error detection in block coding.
Once an error has been detected, it has to be corrected. Fig 2.16 shows the process of error
correction.
One of the central concepts in coding for error control is the idea of the Hamming Distance. The
Hamming distance between two words is the number of differences between corresponding bits.
The minimum Hamming distance is the smallest Hamming distance between all possible pairs in
a set of words.
· To guarantee the detection of up to s errors in all cases, the minimum Hamming distance
in a block code must be dmin = s + 1.
· To guarantee correction of up to t errors in all cases, the minimum Hamming distance in
a block code must be dmin = 2t + 1.
Linear Block Codes: Almost all block codes used today belong to a subset called linear block
codes. A linear block code is a code in which the exclusive OR (addition modulo-2) of two valid
codewords creates another valid codeword. A single parity-check code is of linear block code. A
simple parity-check code is a single-bit error-detecting code in which n = k + 1 with dmin = 2.A
simple parity-check code can detect an odd number of errors as shown in Fig 2.17.
Cyclic Codes: Cyclic codes are special linear block codes with one extra property. In a cyclic
code, if a codeword is cyclically shifted (rotated), the result is another codeword as shown in Fig
2.18.
In cyclic code, concept of long division has been used. The divisor in a cyclic code is normally
called the generator polynomial or simply the generator as shown in Fig 2.19.
The data link layer needs to pack bits into frames, so that each frame is distinguishable from
another.
2.3.1 Framing
Our postal system practices a type of framing. The simple act of inserting a letter into an
envelope separates one piece of information from another; the envelope serves as the delimiter.
There are two types of framing namely fixed size framing and variable size framing. In fixed size
framing, we send fixed size of frames so there is no need to specify the boundaries of the frame.
In variable size framing, size of frame is not fixed rather it is variable so we need to define
boundaries of frame i.e ending of one frame and beginning of next frame. Thus, we use two
techniques namely character oriented and bit oriented. In character oriented, we use the concept
of byte stuffing as shown in Fig. 2.20. Byte stuffing is the process of adding 1 extra byte
whenever there is a flag or escape character in the text.
2.3.2 Flow
The most important responsibilities of the data link layer are flow control and error control.
Collectively, these functions are known as data link control.
Flow control refers to a set of procedures used to restrict the amount of data that the sender can
send before waiting for acknowledgment.
Error control in the data link layer is based on automatic repeat request, which is the
retransmission of data.
The data link layer can combine framing, flow control, and error control to achieve the delivery
of data from one node to another. The protocols are normally implemented in software by using
one of the common programming languages. Protocols can be broadly classified into two
categories as shown in Fig.2.22: Noiseless channel and Noisy Channel.
Fig 2.22 Type of Protocols
There is a difference between the protocols in real networks. All the protocols we discuss are
unidirectional in the sense that the data frames.travel from one node, called the sender, to another
node, called the receiver. Although special frames, called acknowledgment (ACK) and negative
acknowledgment (NAK) can flow in the opposite direction for flow and error control purposes,
data flow in only one direction. In a real-life network, the data link protocols are implemented as
bidirectional; data flow in both directions. In these protocols the flow and error control
information such as ACKs and NAKs is included in the data frames in a technique called
piggybacking.
Noiseless protocols takes channel as an ideal one in which no frames are lost, duplicated, or
corrupted. There are two types of protocols used for noiseless channels namely simplest and stop
& wait protocol. The first is a protocol that does not use flow control; the second is the one that
does. Of course, neither has error control because we have assumed that the channel is a perfect
noiseless channel.
Simplest protocol: is one that has no flow or error control. In simplest protocol, data frames are
sent continuously, there is no concept of acknowledgement as shown in Fig 2.23. The data link
layer at the sender site gets data from its network layer, makes a frame out of the data, and sends
it. The data link layer at the receiver site receives a frame from its physical layer, extracts data
from the frame, and delivers the data to its network layer.
Fig 2.23 The design of the simplest protocol with no flow or error control
Flow diagram has been shown in Fig 2.24. The sender sends a sequence of frames without even
thinking about the receiver. To send three frames, three events occur at the sender site and three
events at the receiver site.
Stop & Wait Protocol: If data frames arrive at the receiver site faster than they can be processed,
the frames must be stored until their use. Normally, the receiver does not have enough storage
space, especially if it is receiving data from many sources. This may result in either the
discarding of frames or denial of service. To prevent the receiver from becoming overwhelmed
with frames, we somehow need to tell the sender to slow down. There must be feedback from the
receiver to the sender. Thus, in stop and wait protocol, one frame is sent at a time and it waits for
acknowledgement of that frame. Once it receives acknowledgement, sender sends another frame
as shown in Fig. 2.25.
Flow diagram has been shown in Fig 2.26. The sender sends one frame and waits for feedback
from the receiver. When the ACK arrives, the sender sends the next frame. Note that sending two
frames in the protocol involves the sender in four events and the receiver in two events.
Although the Stop-and-Wait Protocol gives us an idea of how to add flow control to its
predecessor, noiseless channels are nonexistent. We can ignore the error or we need to add error
control to our protocols. There are three protocols used in case of noisy channels namely: stop &
wait automatic repeat request, go-back- n automatic repeat request and selective automatic repeat
request.
Stop & Wait Automatic Repeat Request (ARQ): Our first protocol, called the Stop-and-Wait
Automatic Repeat Request (Stop and Wait ARQ), adds a simple error control mechanism to the
Stop-and-Wait Protocol as shown in Fig. 2.27. To detect and correct corrupted frames, we need
to add redundancy bits to our data frame. When the frame arrives at the receiver site, it is
checked and if it is corrupted, it is silently discarded. The detection of errors in this protocol is
manifested by the silence of the receiver. Lost frames are more difficult to handle than corrupted
ones. In our previous protocols, there was no way to identify a frame. The received frame could
be the correct one, or a duplicate, or a frame out of order. The solution is to number the frames.
When the receiver receives a data frame that is out of order, this means that frames were either
lost or duplicated. The completed and lost frames need to be resent in this protocol. If the
receiver does not respond when there is an error, how can the sender know which frame to
resend? To remedy this problem, the sender keeps a copy of the sent frame. At the same time, it
starts a timer. If the timer expires and there is no ACK for the sent frame, the frame is resent, the
copy is held, and the timer is restarted. Since the protocol uses the stop-and-wait mechanism,
there is only one specific frame that needs an ACK even though several copies of the same frame
can be in the network.
This protocol makes use of sliding window at sender and at receiver site. The send window is an
abstract concept defining an imaginary box of size 2m − 1 with three variables: Sf, Sn, and Ssize.
The send window can slide one or more slots when a valid acknowledgment arrives as shown in
Fig.2.29.
Fig 2.29 Send window (a) before and (b) after sliding
The receive window is an abstract concept defining an imaginary box of size 1 with one single
variable Rn. The window slides when a correct frame has arrived; sliding occurs one slot at a
time as shown in Fig. 2.30.
Fig 2.30 Receive window (a) before and (b) after sliding
Selective Repeat Automatic Repeat Request: Go-back-n ARQ simplifies the process at the
receiver site. The receiver keeps track of only one variable, and there is no need to buffer out-of-
order frames; they are simply discarded. However, this protocol is very inefficient for a noisy
link. In a noisy link a frame has a higher probability of damage, which means the resending of
multiple frames. This resending uses up the bandwidth and slows down the transmission. For
noisy links, there is another mechanism that does not resend N frames when just one frame is
damaged; only the damaged frame is resent. This mechanism is called Selective Repeat ARQ as
shown in Fig. 2.31. It is more efficient for noisy links, but the processing at the receiver is more
complex.
Fig 2.31 Selective Repeat Automatic Repeat Request
2.5 HDLC
High-level Data Link Control (HDLC) is a bit-oriented protocol for communication over point-
to-point and multipoint links. It implements the ARQ mechanisms. HDLC provides two common
transfer modes that can be used in different configurations: normal response mode (NRM) and
asynchronous balanced mode (ABM). HDLC frame format has been shown in Fig.2.32.
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-to-point and multiple-point links as
shown in Fig.2.33.
Fig 2.33 Normal Response Mode
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 as shown in Fig 2.34.
Although HDLC is a general protocol that can be used for both point-to-point and multipoint
configurations, one of the most common protocols for point-to-point access is the Point-to-Point
Protocol (PPP). Today, millions of Internet users who need to connect their home computers to
the server of an Internet service provider use PPP. The majority of these users have a traditional
modem; they are connected to the Internet through a telephone line, which provides the services
of the physical layer. But to control and manage the transfer of data, there is a need for a point-
to-point protocol at the data link layer. PPP is by far the most common. PPR frame format has
been shown in Fig. 2.35.
On the other hand, to keep PPP simple, several services are missing:
· PPP does not provide flow control. A sender can send several frames one after another
with no concern about overwhelming the receiver.
· PPP has a very simple mechanism for error control. A CRC field is used to detect errors.
If the frame is corrupted, it is silently discarded; the upper-layer protocol needs to take
care of the problem. Lack of error control and sequence numbering may cause a packet to
be received out of order.
· PPP does not provide a sophisticated addressing mechanism to handle frames in a
multipoint configuration.