Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
4 views16 pages

Unit 3

Chapter 9 introduces the data-link layer, which facilitates node-to-node communication in networks by encapsulating and decapsulating data packets as they traverse through routers and links. It outlines the services provided by the data-link layer, including framing, flow control, error control, and congestion control, and distinguishes between point-to-point and broadcast links. Additionally, it discusses link-layer addressing, emphasizing the need for link-layer addresses to manage data transmission effectively across different network segments.

Uploaded by

navyashreehegde6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views16 pages

Unit 3

Chapter 9 introduces the data-link layer, which facilitates node-to-node communication in networks by encapsulating and decapsulating data packets as they traverse through routers and links. It outlines the services provided by the data-link layer, including framing, flow control, error control, and congestion control, and distinguishes between point-to-point and broadcast links. Additionally, it discusses link-layer addressing, emphasizing the need for link-layer addresses to manage data transmission effectively across different network segments.

Uploaded by

navyashreehegde6
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

CHAPTER 9 INTRODUCTION TO DATA-LINK LAYER 239

and so on. Finally, the data-link layer at router R7 communicates with the data-link
layer at Bob’s computer. Only one data-link layer is involved at the source or the desti-
nation, but two data-link layers are involved at each router. The reason is that Alice’s
and Bob’s computers are each connected to a single network, but each router takes
input from one network and sends output to another network. Note that although
switches are also involved in the data-link-layer communication, for simplicity we have
not shown them in the figure.

9.1.1 Nodes and Links


Communication at the data-link layer is node-to-node. A data unit from one point in the
Internet needs to pass through many networks (LANs and WANs) to reach another
point. Theses LANs and WANs are connected by routers. It is customary to refer to the
two end hosts and the routers as nodes and the networks in between as links. Figure 9.2
is a simple representation of links and nodes when the path of the data unit is only six
nodes.

Figure 9.2 Nodes and Links

Point-to-point Point-to-point
network network

LAN LAN LAN

a. A small part of the Internet

Link Link Link Link Link

Node Node Node Node Node Node


b. Nodes and links

The first node is the source host; the last node is the destination host. The other
four nodes are four routers. The first, the third, and the fifth links represent the three
LANs; the second and the fourth links represent the two WANs.

9.1.2 Services
The data-link layer is located between the physical and the network layers. The data-
link layer provides services to the network layer; it receives services from the physical
layer. Let us discuss services provided by the data-link layer.
The duty scope of the data-link layer is node-to-node. When a packet is travelling
in the Internet, the data-link layer of a node (host or router) is responsible for delivering
a datagram to the next node in the path. For this purpose, the data-link layer of the
sending node needs to encapsulate the datagram received from the network in a frame,
and the data-link layer of the receiving node needs to decapsulate the datagram from
the frame. In other words, the data-link layer of the source host needs only to
240 PART III DATA-LINK LAYER

encapsulate, the data-link layer of the destination host needs to decapsulate, but each
intermediate node needs to both encapsulate and decapsulate. One may ask why we
need encapsulation and decapsulation at each intermediate node. The reason is that
each link may be using a different protocol with a different frame format. Even if one
link and the next are using the same protocol, encapsulation and decapsulation are
needed because the link-layer addresses are normally different. An analogy may help in
this case. Assume a person needs to travel from her home to her friend’s home in
another city. The traveller can use three transportation tools. She can take a taxi to go to
the train station in her own city, then travel on the train from her own city to the city
where her friend lives, and finally reach her friend’s home using another taxi. Here we
have a source node, a destination node, and two intermediate nodes. The traveller needs
to get into the taxi at the source node, get out of the taxi and get into the train at the first
intermediate node (train station in the city where she lives), get out of the train and get
into another taxi at the second intermediate node (train station in the city where her
friend lives), and finally get out of the taxi when she arrives at her destination. A kind
of encapsulation occurs at the source node, encapsulation and decapsulation occur at
the intermediate nodes, and decapsulation occurs at the destination node. Our traveller
is the same, but she uses three transporting tools to reach the destination.
Figure 9.3 shows the encapsulation and decapsulation at the data-link layer. For
simplicity, we have assumed that we have only one router between the source and des-
tination. The datagram received by the data-link layer of the source host is encapsulated
in a frame. The frame is logically transported from the source host to the router. The
frame is decapsulated at the data-link layer of the router and encapsulated at another
frame. The new frame is logically transported from the router to the destination host.
Note that, although we have shown only two data-link layers at the router, the router
actually has three data-link layers because it is connected to three physical links.

Figure 9.3 A communication with only three nodes

Actual link
Legend 2 Data-link header
Logical link

Datagram Datagram Datagram

Data link 2 Datagram Data link Data link 2 Datagram Data link

Frame: type 1 Frame: type 2

Link: of type 1 Link: of type 2


Source Destination
To another link

With the contents of the above figure in mind, we can list the services provided by
a data-link layer as shown below.
CHAPTER 9 INTRODUCTION TO DATA-LINK LAYER 241

Framing
Definitely, the first service provided by the data-link layer is framing. The data-link
layer at each node needs to encapsulate the datagram (packet received from the network
layer) in a frame before sending it to the next node. The node also needs to decapsulate
the datagram from the frame received on the logical channel. Although we have shown
only a header for a frame, we will see in future chapters that a frame may have both a
header and a trailer. Different data-link layers have different formats for framing.

A packet at the data-link layer is normally called a frame.

Flow Control
Whenever we have a producer and a consumer, we need to think about flow control. If
the producer produces items that cannot be consumed, accumulation of items occurs.
The sending data-link layer at the end of a link is a producer of frames; the receiving
data-link layer at the other end of a link is a consumer. If the rate of produced frames is
higher than the rate of consumed frames, frames at the receiving end need to be buff-
ered while waiting to be consumed (processed). Definitely, we cannot have an unlim-
ited buffer size at the receiving side. We have two choices. The first choice is to let the
receiving data-link layer drop the frames if its buffer is full. The second choice is to let
the receiving data-link layer send a feedback to the sending data-link layer to ask it to
stop or slow down. Different data-link-layer protocols use different strategies for flow
control. Since flow control also occurs at the transport layer, with a higher degree of
importance, we discuss this issue in Chapter 23 when we talk about the transport layer.
Error Control
At the sending node, a frame in a data-link layer needs to be changed to bits, trans-
formed to electromagnetic signals, and transmitted through the transmission media. At
the receiving node, electromagnetic signals are received, transformed to bits, and put
together to create a frame. Since electromagnetic signals are susceptible to error, a
frame is susceptible to error. The error needs first to be detected. After detection, it
needs to be either corrected at the receiver node or discarded and retransmitted by the
sending node. Since error detection and correction is an issue in every layer (node-to-
node or host-to-host), we have dedicated all of Chapter 10 to this issue.
Congestion Control
Although a link may be congested with frames, which may result in frame loss, most
data-link-layer protocols do not directly use a congestion control to alleviate congestion,
although some wide-area networks do. In general, congestion control is considered an
issue in the network layer or the transport layer because of its end-to-end nature. We will
discuss congestion control in the network layer and the transport layer in later chapters.

9.1.3 Two Categories of Links


Although two nodes are physically connected by a transmission medium such as cable
or air, we need to remember that the data-link layer controls how the medium is used.
We can have a data-link layer that uses the whole capacity of the medium; we can also
242 PART III DATA-LINK LAYER

have a data-link layer that uses only part of the capacity of the link. In other words, we
can have a point-to-point link or a broadcast link. In a point-to-point link, the link is
dedicated to the two devices; in a broadcast link, the link is shared between several
pairs of devices. For example, when two friends use the traditional home phones to
chat, they are using a point-to-point link; when the same two friends use their cellular
phones, they are using a broadcast link (the air is shared among many cell phone users).

9.1.4 Two Sublayers


To better understand the functionality of and the services provided by the link layer, we
can divide the data-link layer into two sublayers: data link control (DLC) and media
access control (MAC). This is not unusual because, as we will see in later chapters, LAN
protocols actually use the same strategy. The data link control sublayer deals with all
issues common to both point-to-point and broadcast links; the media access control sub-
layer deals only with issues specific to broadcast links. In other words, we separate these
two types of links at the data-link layer, as shown in Figure 9.4.

Figure 9.4 Dividing the data-link layer into two sublayers


Data-link layer

Data-link layer

Data link control sublayer Data link control sublayer

Media access control sublayer

a. Data-link layer of a broadcast link b. Data-link layer of a point-to-point link

We discuss the DLC and MAC sublayers later, each in a separate chapter. In addi-
tion, we discuss the issue of error detection and correction, a duty of the data-link and
other layers, also in a separate chapter.

9.2 LINK-LAYER ADDRESSING


The next issue we need to discuss about the data-link layer is the link-layer addresses.
In Chapter 18, we will discuss IP addresses as the identifiers at the network layer that
define the exact points in the Internet where the source and destination hosts are con-
nected. However, in a connectionless internetwork such as the Internet we cannot make
a datagram reach its destination using only IP addresses. The reason is that each data-
gram in the Internet, from the same source host to the same destination host, may take a
different path. The source and destination IP addresses define the two ends but cannot
define which links the datagram should pass through.
We need to remember that the IP addresses in a datagram should not be changed. If
the destination IP address in a datagram changes, the packet never reaches its
destination; if the source IP address in a datagram changes, the destination host or a
router can never communicate with the source if a response needs to be sent back or an
error needs to be reported back to the source (see ICMP in Chapter 19).
CHAPTER 9 INTRODUCTION TO DATA-LINK LAYER 243

The above discussion shows that we need another addressing mechanism in a con-
nectionless internetwork: the link-layer addresses of the two nodes. A link-layer
address is sometimes called a link address, sometimes a physical address, and some-
times a MAC address. We use these terms interchangeably in this book.
Since a link is controlled at the data-link layer, the addresses need to belong to the
data-link layer. When a datagram passes from the network layer to the data-link layer,
the datagram will be encapsulated in a frame and two data-link addresses are added to
the frame header. These two addresses are changed every time the frame moves from
one link to another. Figure 9.5 demonstrates the concept in a small internet.

Figure 9.5 IP addresses and link-layer addresses in a small internet

To another
link
N3 L3

Frame
Alice L2 L1 N1 N8 Data N2 L2 R1 N 4 L4
N1 L1

Link 1

Data
Order of addresses
N: IP address

Frame
IP addresses: source-destination

N1 N8
Legend
L: Link-layer address Link-layer address: destination-source

L4
Link 3

L5
N 8 L8 R2
N7 L7 N5 L5

Link 2
L8 L7 N1 N 8 Data
Bob
Frame
N6 L6
To another
network

In the internet in Figure 9.5, we have three links and two routers. We also have
shown only two hosts: Alice (source) and Bob (destination). For each host, we have
shown two addresses, the IP addresses (N) and the link-layer addresses (L). Note
that a router has as many pairs of addresses as the number of links the router is con-
nected to. We have shown three frames, one in each link. Each frame carries the
same datagram with the same source and destination addresses (N1 and N8), but the
link-layer addresses of the frame change from link to link. In link 1, the link-layer
addresses are L1 and L2. In link 2, they are L4 and L5. In link 3, they are L7 and L8.
Note that the IP addresses and the link-layer addresses are not in the same order. For
IP addresses, the source address comes before the destination address; for link-layer
addresses, the destination address comes before the source. The datagrams and
244 PART III DATA-LINK LAYER

frames are designed in this way, and we follow the design. We may raise several
questions:
❑ If the IP address of a router does not appear in any datagram sent from a source to a
destination, why do we need to assign IP addresses to routers? The answer is that in
some protocols a router may act as a sender or receiver of a datagram. For example,
in routing protocols we will discuss in Chapters 20 and 21, a router is a sender or a
receiver of a message. The communications in these protocols are between routers.
❑ Why do we need more than one IP address in a router, one for each interface? The
answer is that an interface is a connection of a router to a link. We will see that an
IP address defines a point in the Internet at which a device is connected. A router
with n interfaces is connected to the Internet at n points. This is the situation of a
house at the corner of a street with two gates; each gate has the address related to
the corresponding street.
❑ How are the source and destination IP addresses in a packet determined? The
answer is that the host should know its own IP address, which becomes the source
IP address in the packet. As we will discuss in Chapter 26, the application layer
uses the services of DNS to find the destination address of the packet and passes it
to the network layer to be inserted in the packet.
❑ How are the source and destination link-layer addresses determined for each link?
Again, each hop (router or host) should know its own link-layer address, as we dis-
cuss later in the chapter. The destination link-layer address is determined by using
the Address Resolution Protocol, which we discuss shortly.
❑ What is the size of link-layer addresses? The answer is that it depends on the protocol
used by the link. Although we have only one IP protocol for the whole Internet, we
may be using different data-link protocols in different links. This means that we can
define the size of the address when we discuss different link-layer protocols.
9.2.1 Three Types of addresses
Some link-layer protocols define three types of addresses: unicast, multicast, and
broadcast.
Unicast Address
Each host or each interface of a router is assigned a unicast address. Unicasting means
one-to-one communication. A frame with a unicast address destination is destined only
for one entity in the link.
Example 9.1
As we will see in Chapter 13, the unicast link-layer addresses in the most common LAN, Ether-
net, are 48 bits (six bytes) that are presented as 12 hexadecimal digits separated by colons; for
example, the following is a link-layer address of a computer.
A3:34:45:11:92:F1

Multicast Address
Some link-layer protocols define multicast addresses. Multicasting means one-to-many
communication. However, the jurisdiction is local (inside the link).
294 PART III DATA-LINK LAYER

11.1 DLC SERVICES


The data link control (DLC) deals with procedures for communication between two
adjacent nodes—node-to-node communication—no matter whether the link is dedi-
cated or broadcast. Data link control functions include framing and flow and error
control. In this section, we first discuss framing, or how to organize the bits that are
carried by the physical layer. We then discuss flow and error control.
11.1.1 Framing
Data transmission in the physical layer means moving bits in the form of a signal from
the source to the destination. The physical layer provides bit synchronization to ensure
that the sender and receiver use the same bit durations and timing. We discussed the
physical layer in Part II of the book.
The data-link layer, on the other hand, needs to pack bits into frames, so that each
frame is distinguishable from another. 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. In addition, each envelope defines
the sender and receiver addresses, which is necessary since the postal system is a many-
to-many carrier facility.
Framing in the data-link layer separates a message from one source to a destination
by adding a sender address and a destination address. The destination address defines
where the packet is to go; the sender address helps the recipient acknowledge the
receipt.
Although the whole message could be packed in one frame, that is not normally
done. One reason is that a frame can be very large, making flow and error control very
inefficient. When a message is carried in one very large frame, even a single-bit error
would require the retransmission of the whole frame. When a message is divided into
smaller frames, a single-bit error affects only that small frame.
Frame Size
Frames can be of fixed or variable size. In fixed-size framing, there is no need for defin-
ing the boundaries of the frames; the size itself can be used as a delimiter. An example
of this type of framing is the ATM WAN, which uses frames of fixed size called cells.
We discuss ATM in Chapter 14.
Our main discussion in this chapter concerns variable-size framing, prevalent in
local-area networks. In variable-size framing, we need a way to define the end of one
frame and the beginning of the next. Historically, two approaches were used for this
purpose: a character-oriented approach and a bit-oriented approach.
Character-Oriented Framing
In character-oriented (or byte-oriented) framing, data to be carried are 8-bit characters
from a coding system such as ASCII (see Appendix A). The header, which normally
carries the source and destination addresses and other control information, and the
trailer, which carries error detection redundant bits, are also multiples of 8 bits. To
separate one frame from the next, an 8-bit (1-byte) flag is added at the beginning and the
end of a frame. The flag, composed of protocol-dependent special characters, signals the
CHAPTER 11 DATA LINK CONTROL (DLC) 295

start or end of a frame. Figure 11.1 shows the format of a frame in a character-oriented
protocol.

Figure 11.1 A frame in a character-oriented protocol

Data from upper layer


Variable number of characters
Flag Header ••• Trailer Flag

Character-oriented framing was popular when only text was exchanged by the
data-link layers. The flag could be selected to be any character not used for text com-
munication. 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
has reached the end of the frame. To fix this problem, a byte-stuffing strategy was
added to character-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 same
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 11.2 shows the situation.

Figure 11.2 Byte stuffing and unstuffing

Data from upper layer


Flag ESC

Sent frame Stuffed


Flag Header ESC Flag ESC ESC Trailer Flag

Extra Extra
byte byte

Flag Header ESC Flag ESC ESC Trailer Flag

Received frame Unstuffed


Flag ESC
Data to upper layer

Byte stuffing is the process of adding one extra byte whenever


there is a flag or escape character in the text.

Byte stuffing by the escape character allows the presence of the flag in the data
section of the frame, but it creates another problem. What happens if the text contains
one or more escape characters followed by a byte with the same pattern as the flag? The
296 PART III DATA-LINK LAYER

receiver removes the escape character, but keeps the next byte, which is incorrectly
interpreted as the end of the frame. 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 protocols present another problem in data communications.
The universal coding systems in use today, such as Unicode, have 16-bit and 32-bit
characters that conflict with 8-bit characters. We can say that, in general, the tendency
is moving toward the bit-oriented protocols that we discuss next.
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. 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 pattern flag, 01111110, as the delimiter to define the begin-
ning and the end of the frame, as shown in Figure 11.3.

Figure 11.3 A frame in a bit-oriented protocol

Data from upper layer


Flag Variable number of bits Flag
01111110 Header 01111010110 • • • 11011110 Trailer 01111110

This flag can create the same type of problem we saw in the character-oriented
protocols. That is, if the flag pattern appears 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. In bit stuffing, if a 0 and five consecutive 1 bits are encountered, an extra
0 is added. 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.

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.

Figure 11.4 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 flag
01111110 is not stuffed by the sender and is recognized by the receiver.
CHAPTER 11 DATA LINK CONTROL (DLC) 297

Figure 11.4 Bit stuffing and unstuffing

Data from upper layer


0001111111001111101000

Stuffed
Frame sent
Flag Header 000111110110011111001000 Trailer Flag

Two extra
Frame received bits
Flag Header 000111110110011111001000 Trailer Flag

Unstuffed

0001111111001111101000
Data to upper layer

11.1.2 Flow and Error Control


We briefly defined flow and error control in Chapter 9; we elaborate on these two
issues here. One of the responsibilities of the data-link control sublayer is flow and
error control at the 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 con-
sumer must wait, and the system becomes less efficient. 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-link layer, we are dealing with four entities: network
and data-link layers at the sending node and network and data-link layers at the receiv-
ing node. Although we can have a complex relationship with more than one producer
and consumer (as we will see in Chapter 23), we ignore the relationships between net-
works and data-link layers and concentrate on the relationship between two data-link
layers, as shown in Figure 11.5.

Figure 11.5 Flow control at the data-link layer

Sending node Receiving node


Data-link Frames are pushed Data-link
Producer Producer
layer layer

Flow control
298 PART III DATA-LINK LAYER

The figure shows that the data-link layer at the sending node tries to push frames
toward the data-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 nor-
mally to use two buffers; one at the sending data-link layer and the other at the receiv-
ing data-link 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 data-link layer is
full, it informs the sending data-link layer to stop pushing frames.

Example 11.1
The above discussion requires that the consumers communicate with the producers on two
occasions: when the buffer is full and when there are vacancies. If the two parties use a buffer
with only one slot, the communication can be easier. Assume that each data-link layer uses one
single memory slot to hold a frame. When this single slot in the receiving data-link layer is
empty, it sends a note to the network layer to send the next frame.

Error Control
Since the underlying technology at the physical layer is not fully reliable, we need to
implement error control at the data-link layer to prevent the receiving node from deliver-
ing corrupted packets to its network layer. Error control at the data-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.
❑ In the first method, if the frame is corrupted, it is silently discarded; if it is not cor-
rupted, the packet is delivered to the network layer. This method is used mostly in
wired LANs such as Ethernet.
❑ In the second method, if the frame is corrupted, it is silently discarded; if it is not
corrupted, an acknowledgment is sent (for the purpose of both flow and error con-
trol) to the 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 acknowledgment means that there is a problem in the
sent frame. We show this situation when we discuss some simple protocols in the next
section. A frame that carries an acknowledgment is normally called an ACK to distin-
guish it from the data frame.

11.1.3 Connectionless and Connection-Oriented


A DLC protocol can be either connectionless or connection-oriented. We will discuss
this issue very briefly here, but we return to this topic in the network and transport
layer.
CHAPTER 11 DATA LINK CONTROL (DLC) 299

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. Note that the term connec-
tionless here does not mean that there is no physical connection (transmission medium)
between the nodes; it means that there is no connection between frames. The frames are
not numbered and there is no sense of ordering. Most of the data-link protocols for
LANs are connectionless protocols.
Connection-Oriented Protocol
In a connection-oriented 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 protocols are rare in wired LANs, but we can see them in some point-to-point
protocols, some wireless LANs, and some WANs.

11.2 DATA-LINK LAYER PROTOCOLS


Traditionally four protocols have been defined for the data-link layer to deal with flow
and error control: Simple, Stop-and-Wait, Go-Back-N, and Selective-Repeat. Although
the first two protocols still are used at the data-link layer, the last two have disap-
peared. We therefore briefly discuss the first two protocols in this chapter, in which we
need to understand some wired and wireless LANs. We postpone the discussion of all
four, in full detail, to Chapter 23, where we discuss the transport layer.
The behavior of a data-link-layer protocol can be better shown as a finite 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 associ-
ated with two reactions: defining the list (possibly empty) of actions to be performed
and 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 starts when it
turns on. In Figure 11.6, we show an example of a machine using FSM. We have used
rounded-corner rectangles to show states, colored text to show events, and regular black
text to show actions. A horizontal line is used to separate the event from the actions,
although later we replace the horizontal line with a slash. The arrow shows the move-
ment to the next state.
The figure shows a machine with three states. There are only three possible events
and three possible actions. The machine starts in state I. If event 1 occurs, the machine
performs actions 1 and 2 and moves to state II. When the machine is in state II, two
events may occur. If event 1 occurs, the machine performs action 3 and remains in the
same state, state II. If event 3 occurs, the machine performs no action, but move to
state I.
300 PART III DATA-LINK LAYER

Figure 11.6 Connectionless and connection-oriented service represented as FSMs

Event 1
Note: Action 1.
The colored Action 2.
arrow shows the
starting state.
State I State II Event 2
Action 3.

Event 3

11.2.1 Simple Protocol


Our first protocol is a simple protocol with neither flow nor error 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 11.7 shows the layout for this
protocol.

Figure 11.7 Simple protocol

Frame
Network Network

Data-link Data-link
Logical link
Sending node Receiving node

The data-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 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 data-link layers of the sender and receiver provide transmission services for
their network layers.
FSMs
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 comes 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 11.8 shows the FSMs for the sim-
ple protocol. We’ll see more in Chapter 23, which uses this protocol.
CHAPTER 11 DATA LINK CONTROL (DLC) 301

Figure 11.8 FSMs for the simple protocol

Packet came from network layer. Frame arrived.


Make a frame and send it. Deliver the packet to network layer.

Ready Ready
Start Start

Sending node Receiving node

Example 11.2
Figure 11.9 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.

Figure 11.9 Flow diagram for Example 11.2

Sending node Receiving node


Network Data-link Data-link Network

Packet
Frame
Packet
Packet
Frame
Packet

Time Time Time Time

11.2.2 Stop-and-Wait Protocol


Our second protocol is called the Stop-and-Wait protocol, which uses both flow and
error control. We show a primitive version of this protocol here, but we discuss the
more sophisticated version in Chapter 23 when we have learned about sliding windows.
In this protocol, the sender sends one frame at a time and waits for an acknowledg-
ment before sending the next one. To detect corrupted frames, we need to add a CRC
(see Chapter 10) to each data frame. When a frame arrives at the receiver site, it is
checked. 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 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 needs to keep
a copy of the frame until its acknowledgment arrives. When the corresponding
302 PART III DATA-LINK LAYER

acknowledgment arrives, the sender discards the copy and sends the next frame if it is
ready. Figure 11.10 shows the outline for the Stop-and-Wait protocol. Note that only
one frame and one acknowledgment can be in the channels at any time.

Figure 11.10 Stop-and-Wait protocol

Sending node Frame ACK Receiving node


Network Network
CRC CRC

Data-link Data-link

Logical link (duplex)


Timer

FSMs
Figure 11.11 shows the FSMs for our primitive Stop-and-Wait protocol.

Figure 11.11 FSM for the Stop-and-Wait protocol

Sending node
Packet came from network layer.
Make a frame, save a copy, and send the frame. Time-out.
Start the timer. Resend the saved frame.
Restart the timer.
Ready Blocking

Corrupted ACK arrived.


Start Error-free ACK arrived. Discard the ACK.
Stop the timer.
Discard the saved frame.

Receiving node

Corrupted frame arrived.


Error-free frame arrived.
Discard the frame.
Extract and deliver the packet to network layer.
Ready Send ACK.
Start

We describe the sender and receiver states below.


Sender States
The sender is initially in the ready state, but it can move between the ready and block-
ing state.
CHAPTER 11 DATA LINK CONTROL (DLC) 303

❑ Ready State. When the sender is in this state, it is only waiting for a packet from
the network layer. If a packet comes from the network layer, the sender creates a
frame, saves a copy of the frame, starts the only timer and sends the frame. The
sender then moves to the blocking state.
❑ Blocking State. When the sender is in this state, three events can occur:
a. If a time-out occurs, the sender resends the saved copy of the frame and restarts
the timer.
b. If a corrupted ACK arrives, it is discarded.
c. If an error-free ACK arrives, the sender stops the timer and discards the saved
copy of the frame. It then moves to the ready state.
Receiver
The receiver is always in the ready state. Two events may occur:
a. If an error-free frame arrives, the message in the frame is delivered to the net-
work layer and an ACK is sent.
b. If a corrupted frame arrives, the frame is discarded.

Example 11.3
Figure 11.12 shows an example. The first frame is sent and acknowledged. The second frame is
sent, but lost. After time-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
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 acknowl-
edgment numbers.
Sequence and Acknowledgment Numbers
We saw a problem in Example 11.3 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 the specification of an item to be ordered, duplicate packets
mean ordering an item more than once. To correct the problem in Example 11.3, we need to add
sequence numbers to the data frames and acknowledgment numbers to the ACK frames. How-
ever, numbering in this case is very simple. Sequence numbers are 0, 1, 0, 1, 0, 1, . . . ; the
acknowledgment numbers can also be 1, 0, 1, 0, 1, 0, … In other words, the sequence numbers
start with 0, the acknowledgment numbers start with 1. An acknowledgment number always
defines the sequence number of the next frame to receive.

Example 11.4
Figure 11.13 shows how adding sequence numbers and acknowledgment numbers can prevent
duplicates. The first frame is sent and acknowledged. The second frame is sent, but lost. After
time-out, it is resent. The third frame is sent and acknowledged, but the acknowledgment is lost.
The frame is resent.

FSMs with Sequence and Acknowledgment Numbers


We can change the FSM in Figure 11.11 to include the sequence and acknowledgment
numbers, but we leave this as a problem at the end of the chapter.

You might also like