Data Link Layer
1 Data Link Sublayers
2 Access Control Methods
3 Error detection
4 Frame Forwarding Methods
Table of Contents
1. Introduction
o 1.1 Overview of Data Link Layer
o 1.2 Functions and Importance of the Data Link Layer
2. Data Link Sublayers
o 2.1 Logical Link Control (LLC) Sublayer
o 2.2 Media Access Control (MAC) Sublayer
3. Access Control Methods
o 3.1 Random Access Methods
3.1.1 ALOHA (Pure and Slotted)
3.1.2 Carrier Sense Multiple Access (CSMA)
3.1.3 CSMA with Collision Detection (CSMA/CD)
3.1.4 CSMA with Collision Avoidance (CSMA/CA)
o 3.2 Controlled Access Methods
3.2.1 Polling
3.2.2 Token Passing
4. Error Detection
o 4.1 Causes of Errors in Data Transmission
o 4.2 Error Detection Techniques
4.2.1 Parity Checking
4.2.2 Checksum
4.2.3 Cyclic Redundancy Check (CRC)
o 4.3 Error Correction Methods
4.3.1 Hamming Code
4.3.2 Forward Error Correction (FEC)
5. Frame Forwarding Methods
o 5.1 Store-and-Forward Switching
o 5.2 Cut-Through Switching
o 5.3 Fragment-Free Switching
6. Conclusion
o 6.1 Summary of Key Concepts
o 6.2 Future Trends in Data Link Layer Technologies
7. References
Introduction to Data-Link Layer
Overview of Data Link Layer
What is Data Link Layer?
The data link layer is the second layer from the bottom in the Open System
Interconnection network architecture model. It is responsible for the node-to-
node delivery of data within the same local network. Its major role is to
ensure error-free transmission of information. DLL is also responsible for
encoding, decoding, and organizing the outgoing and incoming data.
The Data Link layer transforms a raw transmission facility into a line that
appears free of undetected transmission errors to the network layer and is
responsible for node-to-node delivery. It makes error-free the physical layer
appear to the upper layer (network layer).
This layer is one of the most complicated layers and has complex
functionalities and liabilities. Data link layer hides the details of underlying
hardware and represents itself to upper layer as the medium to
communicate.
Data link layer works between two hosts which are directly connected in
some sense. This direct connection could be point to point or broadcast.
Systems on broadcast network are said to be on same link. The work of data
link layer tends to get more complex when it is dealing with multiple hosts on
single collision domain.
Data link layer is responsible for converting data stream to signals bit by bit
and to send that over the underlying hardware. At the receiving end, Data
link layer picks up data from hardware which are in the form of electrical
signals, assembles them in a recognizable frame format, and hands over to
upper layer.
Design Issues with Data Link Layer
The following are the designed issues with data link layer in the OSI Model:
The issue that arises in the data link layer (and most of the higher
layers as well) is the speed mismatch between sender and receiver.
Some traffic regulation mechanism is often needed to know the exact
available free space, the receiver has at the moment. Frequently, the
flow regulation and error handling are combined in this layer.
Here is an additional issue in the data link layer with broadcast
networks that is how to control access to the shared channel. The
Medium Access Control (MAC), the sub-layer of the data link
layer deals with this problem.
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.
Functions of Data Link Layer
The following are the functions of data link layer in the OSI Model:
1. Framing
The data link layer receives the stream of bits from the network layer divides
into manageable data units called frames. 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.
Different data-link layers have different formats for framing.
Data-link layer takes packets from Network Layer and encapsulates them
into Frames. Then, it sends each frame bit-by-bit on the hardware. At
receiver end, data link layer picks up signals from hardware and assembles
them into frames.
2. Physical Addressing
If frames are to be distributed to different stations on the network. To
define the physical address of the sender (source address) and/or receiver
(destination address) of the frame, the DLL adds a header to the frame.
If the frame is to be sent for a system outside the sender's network. The
receiver's address means the address of the device that connects one
network to the another.
This figure shows the relationship of the Data link layer to the network
and physical layers.
Data-link layer provides layer-2 hardware addressing mechanism.
Hardware address is assumed to be unique on the link. It is encoded into
hardware at the time of manufacturing.
3. Flow Control
Stations on same link may have different speed or capacity. Data-link
layer ensures flow control that enables both machine to exchange data on
same speed.
If the rate at which the data are consumed by the receiver is less than the
rate produced by the sender, the data link layer deals with a flow control
mechanism to prevent overrun the receiver.
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.
4. Error Control
The data link layer also deals with damaged or lost frames. By adding
mechanisms to detect and retransmit lost frames increases reliability. A
trailer added to the end of the frame to achieve error control. Sometimes
signals may have encountered problem in transition and the bits are
flipped.These errors are detected and attempted to recover actual data bits.
It also provides error reporting mechanism to the sender.
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.
5. Access control
When more than two or two devices are connected to the common link,
data link layer protocols are necessary to determine which device has
control over the link at any point of time.
Example: In this figure, a node with physical address 23 sends a frame to
a node with physical address 92. The two nodes connected by a link level.
At the link level this frame contains physical (link) addresses in the
header.
These are the only addresses needed. The remaining header contains
other information that is required at this level. The extra bits needed for
error detection contains by the trailer.
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.
Synchronization
When data frames are sent on the link, both machines must be synchronized
in order to transfer to take place.
Multi-Access
When host on the shared link tries to transfer the data, it has a high
probability of collision. Data-link layer provides mechanism such as CSMA/CD
to equip capability of accessing a shared media among multiple Systems.
Sub-Layers of The Data Link Layer
The data link layer is further divided into two sub-layers, which are as
follows:
Logical Link Control (LLC)
This sublayer of the data link layer deals with multiplexing, the flow of data
among applications and other services, and LLC is responsible for providing
error messages and acknowledgments as well.
Media Access Control (MAC)
MAC sublayer manages the device’s interaction, responsible for addressing
frames, and also controls physical media access. The data link layer receives
the information in the form of packets from the Network layer, it divides
packets into frames and sends those frames bit-by-bit to the underlying
physical layer.
Logical link control (LLC) sub layer
The main functionality of the LLC layer is that it multiplexes the protocols
over the MAC layer while sending and de-multiplex the protocols while
receiving. This layer controls the flow control.
The error-checking of the data link layer is performed by LLC. It can also
track the acknowledgments.
While transmitting data, if LLC detects any frame loss, immediately it sends
back to the source to transmit over again. The LLC layer comes above the
MAC layer and acts as an interface between the upper layers and the MAC
layer.
Medium access control (MAC) sub layer
MAC address is defined and the Media Access Control address. It is a unique
address that is allocated to the NIC of the device. It is used as an address to
transmit data within ethernet or Wi-Fi.
This layer acts as an interface between the physical layer and the LLC layer
in the OSI model. The main responsibility of the MAC layer is that it
encapsulates the frames during transmission so that, whether they are
suitable.
The MAC layer identifies and verifies the address of source stations and
destinations. MAC layer performs multiple access resolution when there are
more data frames.
MAC layer coordinates with the physical layer to seize a shared channel by
using multiple MAC entities to avoid collisions.
Ethernet is an example of a medium that is defined through the MAC
sublayer.
Media access control (MAC) and logical link control (LLC) are the
sublayers of the data link layer (Layer 2) in OSI Reference Model. ‘MAC’ is
also refer to as MAC layer. It use MAC protocols to provides unique
addressing identification and channel access control mechanism for
network nodes to communicate with other nodes across a shared
channel.
MAC describes the process that is employed to control the basis on which
devices can access the shared network. Some level of control is required to
ensure the ability of all devices to access the network within a reasonable
period of time, thereby resulting in acceptable access and response times.
It is also important that some method exists to either detect or avoid data
collisions, which are caused by multiple transmissions being placed on the
shared medium simultaneously. Media Access Control can be
accomplished on either a centralized or decentralized basis, and can be
characterized as either deterministic or non-deterministic in nature.
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.
11.1 DLC SERVICES
Data Link Control (DLC) is the collection of operations that ensures effective
communication among successive nodes, regardless of whether or not the
connection is dedicated or broadcast. Framing, flow control, and error control
are all encompassed in DLC, all of which are imperative for data transfer.
11.1.1 Framing
Data transmission in the physical layer includes the transmission of bits from
sender to receiver with synchronization. Framing of the bits into frames is
needed for the data link layer, however. Framing is needed so that one frame
can be identified from another and typically includes sender and destination
addresses to provide correct communication. Frames are large in size, but it
is better to divide them into smaller ones because a bit error will only affect
one small frame, not the whole message.
Frames may be fixed or variable in length. Fixed-length frames, as in the
case of ATM cells, do not call for special delimiters, for their length can act as
one. Special delimiters are, however, used in variable-size framing. Two main
approaches to this are character-oriented framing and bit-oriented framing.
In character-oriented framing, 8-bit characters (as in the case of ASCII) are
employed. Frames are circumscribed by 1-byte flags, but when the flags are
discovered within the data, byte stuffing is utilized to include an escape
character so that there is no misinterpretation. Bit-oriented framing,
however, uses a unique 8-bit flag pattern (01111110) for frame demarcation.
If this is found in the data, bit stuffing is done by adding a 0 after five
consecutive 1s, in order not to be mistaken as data.
11.1.2 Flow and Error Control
Flow control ensures that data is transmitted at a rate the receiving node can
handle. If the receiving node’s buffer becomes full, it signals the sender to
slow down or stop sending data. This prevents overflow and ensures that the
receiver can process incoming frames without data loss.
Error control is necessary because the physical layer is not fully reliable. A
Cyclic Redundancy Check (CRC) is typically added to the frame header so
that the receiver may check the correctness of the received frame. In case
the frame is correct, it is forwarded to the network layer; otherwise, it is
discarded. In some situations, the receiver also sends an acknowledgment
(ACK) to confirm successful reception and to assist in flow and error control.
When error control and flow control are both used, the ACK not only
acknowledges correct reception but also verifies data integrity so that
transmission errors may be detected by the sender in case the
acknowledgment is not received.
11.1.3 Connectionless and Connection-Oriented
DLC protocols can either be connectionless or connection-oriented. For a
connectionless protocol, frames are sent independently with no relationship
between the frames. Neither numbering nor ordering of frames is done, and
they are processed separately. This is common in LANs.
In a connection-oriented protocol, there must be a logical link prior to the
transfer of data. Frames are assigned numbers and are received in order. If
frames are received out of order, the receiver will wait for the missing frames
so that the data is delivered in the correct order. Connection-oriented
protocols are not as prevalent in LANs but are used in some point-to-point
protocols and WANs.
11.2 DATA-LINK LAYER PROTOCOLS
There have been four traditional data-link layer protocols used for error and
flow control: Simple, Stop-and-Wait, Go-Back-N, and Selective-Repeat. The
latter two are no longer in use, while the former two are still used. A data-link
protocol can be represented as a finite state machine (FSM) made up of
states, events, and actions.
11.2.1 Simple Protocol
The Simple Protocol does not have flow or error control. The receiver is never
blocked from receiving frames. The sender waits for a message from the
network layer, builds a frame, and sends it. The receiver strips off the header
of the frame and delivers the packet to the network layer. The sender and
receiver are always in the ready state except on the occurrence of an event.
11.2.2 Stop-and-Wait Protocol
The Stop-and-Wait Protocol has flow and error control. The sender transmits a
frame, waits for an acknowledgment, and sends the next one. The frame is
discarded if it is lost, and the sender transmits after waiting for a time-out.
The sender retains the copy of the frame until it receives an
acknowledgment. The sender exists in two states: ready (waiting for a
packet) and blocking (waiting for acknowledgment). The receiver has one
state: ready, in which it accepts incoming frames or discards corrupted ones.
Example: If a frame is lost, it is retransmitted upon time-out. Duplication of
packets may be received, which can be avoided by sending sequence and
acknowledgment numbers.
Sequence and Acknowledgment Numbers
To prevent repeating packets, sequence numbers (0, 1, 0, 1.) are employed
in data frames, and acknowledgment numbers (1, 0, 1, 0.) indicate the next
frame in queue. They prevent duplicates or corrupted frames from reaching
the receiver.
11.2.3 Piggybacking
Piggybacking increases efficiency by allowing data in one direction to be
combined with acknowledgment in the opposite direction. While this raises
the level of complexity in communication, it reduces overhead and is
discussed in full in Chapter 23.
11.3 HDLC (High-Level Data Link Control)
HDLC is a bit-oriented point-to-point and multipoint communication protocol.
It uses the Stop-and-Wait protocol and is the foundation of protocols like PPP
and Ethernet.
11.3.1 Configurations and Transfer Modes
There are two modes of HDLC:
Normal Response Mode (NRM): One primary station and a number of
secondary stations. Used in point-to-point and multipoint links.
Asynchronous Balanced Mode (ABM): Both the stations are peer entities in a
point-to-point link.
11.3.2 Framing
Three types of frames are used in HDLC: I-frames, S-frames, and U-frames. A
frame can contain up to six fields:
Flag Field: Marks the start and end of a frame.
Address Field: Identifies sender or receiver.
Control Field: Controls flow and error control.
Information Field: Contains user data or management info.
FCS Field: Error detection field using CRC.
I-frames: Carry user data and control information. S-frames: Carry flow and
error control information, with four subtypes: Receive Ready (RR), Receive
Not Ready (RNR), Reject (REJ), and Selective Reject (SREJ). U-frames: Carry
session management, with control information.
The control segment of every frame identifies its function, e.g., sequence
and acknowledgement numbers to efficiently manage data transport and
errors.
11.4 POINT-TO-POINT PROTOCOL (PPP)
PPP is employed for point-to-point links, such as home to the Internet using
modems and telephone lines. PPP works at the data-link layer, providing
delivery through link negotiation, data transport control, and multiprotocol
support at the network layer. PPP provides optional authentication and
dynamic configuration of the network address and is suitable for temporary
allocation of the IP address. But PPP lacks flow control, low error detection
(with CRC), and no multipoint configurations, so it is less ideal for
complicated configurations.
11.4.1 Services
PPP provides significant features like frame format definition, link
negotiation, and support for carrying more than one network layer besides IP.
PPP provides optional security with authentication and support for Multilink
PPP for multiple links for increased bandwidth. PPP provides dynamic IP
address allocation to dial-in clients to the Internet. PPP does not provide flow
control, employs simple error detection without recovery, and does not
provide advanced addressing for multipoint systems.
11.4.2 Framing
PPP framing is based on bytes and contains flag, address, control, protocol,
payload, and FCS fields. Flag indicates the start and termination of the
frame, and address and control fields contain fixed values. The protocol field
indicates the nature of the data that is being carried, and the payload
contains the data, usually up to 1500 bytes. The FCS field uses CRC as a
method of error checking. Byte stuffing offers an escape mechanism to mark
patterns within data in order to provide proper interpretation of frames.
11.4.3 Transition Phases
A PPP connection traverses the states of a finite state machine. It starts in
the "Dead" state when down, moves to "Establish" for setup and optional
authentication of the link, then to "Open" after setup for data exchange, and
again to the "Terminate" state and "Dead" when closing the physical link.
11.4.4 Multiplexing
PPP utilizes LCP, APs, and NCPs in order to regulate link establishment,
authentication, as well as transmission of network-layer data. Link
establishment, initialization, and deletion are controlled by LCP while APs
(PAP, CHAP) are utilized to authenticate users and the latter provides greater
security. NCPs like IPCP creates links between some network protocols. These
enable PPP to become more flexible on the grounds that they can address
multiple network levels and types of data.
Multilink PPP
Multilink PPP creates numerous physical links for a single logical connection
and therefore offers more bandwidth. There is a common logical frame for
numerous physical frames with the protocol field indicating fragmentation.
This process is more complex since it needs sequence numbers for tracking
data fragments. Multilink PPP offers improved performance since it is suitable
for high-bandwidth use and still offers advantages of PPP.
Media Access Control (MAC)
Media Access Control (MAC) is responsible for managing access to a shared
communication medium between multiple stations, ensuring that stations
take turns transmitting without interfering with each other. This process is
essential for coordinating transmission on multipoint or broadcast links.
Various protocols are designed to handle this access, categorized into
Random Access, Controlled Access, and Channelization protocols.
12.1 Random Access
In random access or contention methods, no station is superior to another,
and each station competes for the shared medium. The stations use
predefined procedures to decide when to transmit, based on the medium's
state (idle or busy). These methods are named "random access" because the
transmission timing is not scheduled, and "contention methods" because
stations must compete for access. When multiple stations transmit at once,
collisions occur, leading to retransmission protocols that resolve these
conflicts.
The protocols such as ALOHA and CSMA (Carrier Sense Multiple Access),
evolved from this basic framework. CSMA/CD (Collision Detection) and
CSMA/CA (Collision Avoidance) are enhancements of CSMA to handle
collisions effectively.
12.1.1 ALOHA
ALOHA was the first random access protocol, developed in the 1970s at the
University of Hawaii. It operates by allowing stations to send data at any
time, but collisions occur when multiple stations transmit simultaneously.
Pure ALOHA, the original version, does not use any method to avoid
collisions. If a station does not receive an acknowledgment for its frame, it
assumes a collision and retransmits the frame after a random backoff period.
The backoff time increases after each retransmission attempt to reduce the
likelihood of subsequent collisions. Pure ALOHA's throughput is limited, with a
maximum success rate of about 18.4% under optimal conditions.
Vulnerable Time
The vulnerable time in pure ALOHA is defined as the time during which a
collision may occur, which is twice the frame transmission time (2 × Tfr).
Slotted ALOHA
Slotted ALOHA improves upon pure ALOHA by dividing time into discrete
slots of Tfr seconds, so stations can only transmit at the beginning of these
slots.
12.1.2 CSMA
To reduce the chance of collision and improve performance, the CSMA
method was developed. In CSMA, each station listens to the medium before
transmitting, following the principle of "sense before transmit" or "listen
before talk." This reduces collisions but does not eliminate them due to
propagation delays. A station might sense the medium as idle, but by the
time it transmits, the first bit from another station may not have reached it
yet, causing a collision.
Vulnerable Time: The vulnerable time for CSMA is the propagation
time (Tp), which is the time it takes for a signal to propagate through
the medium. If a station sends a frame and another station tries to
send during this time, a collision will occur.
Persistence Methods:
o 1-Persistent: After finding the channel idle, the station sends
immediately. This method has the highest chance of collision
because multiple stations may detect the idle channel and send
at the same time.
o Nonpersistent: If the channel is busy, the station waits for a
random time and senses the channel again. This reduces
collisions but wastes time because the channel might remain idle
when stations are ready to send.
o p-Persistent: This method is used when the channel has time
slots. After sensing the channel idle, the station sends with
probability p or waits until the next time slot with probability 1-p.
This method balances collision reduction and efficiency.
12.1.3 CSMA/CD
CSMA/CD enhances CSMA by handling collisions. After sending a frame, the
station monitors the medium to check for success. If a collision occurs, the
station retransmits the frame. CSMA/CD operates by continuously monitoring
the medium during transmission, unlike ALOHA, where the station waits for
acknowledgment after sending the entire frame. Key aspects of CSMA/CD
are:
Minimum Frame Size: To ensure that a station detects a collision
before completing transmission, the frame transmission time (Tfr)
must be at least twice the maximum propagation time (Tp). For a 10
Mbps network with a propagation time of 25.6 μs, the minimum frame
size is 64 bytes.
Throughput: CSMA/CD offers higher throughput than ALOHA. The
maximum throughput depends on the persistence method and the
value of G (the average number of frames sent per time unit).
Traditional Ethernet: Traditional Ethernet uses CSMA/CD with the 1-
persistent method to manage access to the shared medium.
12.1.4 CSMA/CA
CSMA/CA is designed for wireless networks and uses three strategies to avoid
collisions: Interframe Space (IFS), Contention Window, and
Acknowledgments.
Interframe Space (IFS): A station waits a period of time called the
IFS after sensing the channel idle, to avoid collisions from distant
stations that may have started transmitting but whose signals haven’t
reached the station yet.
Contention Window: The station selects a random time slot within a
contention window. If it cannot detect an idle channel, the station will
back off and retry. The size of the contention window increases after
each failed attempt, similar to the p-persistent method.
Acknowledgment: A positive acknowledgment ensures that the data
was successfully received by the destination. This mechanism is crucial
as the station cannot check the arrival of data on its own.
Frame Exchange: The station sends a Request to Send (RTS) frame to
the receiver, waits for a Clear to Send (CTS) frame, then sends the
data. The receiver sends an acknowledgment after receiving the data.
Network Allocation Vector (NAV): The NAV is a timer that helps
stations determine when they are allowed to transmit. When a station
sends an RTS frame, it includes the duration of the transmission, and
other stations adjust their NAV to defer access to the channel.
Hidden-Station Problem: If two stations are out of range of each
other but within range of a third station, they may cause collisions.
Using RTS/CTS frames, the stations can be informed about the ongoing
transmission, avoiding collisions.
Wireless Networks: CSMA/CA is primarily used in wireless networks.
It handles issues like hidden terminals and exposed terminals by
enhancing the protocol with handshakes like RTS and CTS.
12.2 CONTROLLED ACCESS
In controlled access, stations consult one another to determine which station has the right
to send data. A station cannot transmit unless it is authorized by other stations. There are
three methods of controlled access: Reservation, Polling, and Token Passing.
12.2.1 Reservation
In the reservation method, time is divided into intervals, and a reservation frame precedes
the data transmission. The reservation frame contains minislots for each station. A station
can only send data if it has made a reservation in its designated minislot. If a station
makes no reservation, it cannot transmit during that interval. For example, in a system
with five stations and five reservation minislots, only stations that reserve a minislot can
send data in that interval.
12.2.2 Polling
Polling involves one primary station controlling the network, with secondary stations
responding to it. The primary station polls each secondary station in turn to see if it has
data to send. If a secondary station has data, it responds with the data. If not, it sends a
NAK (negative acknowledgment). If the primary station has data to send, it uses a select
frame to initiate communication with the intended secondary station, which responds
with an acknowledgment if it’s ready to receive. If the primary station fails, the system
breaks down.
12.2.3 Token Passing
In token passing, stations form a logical ring, and the station holding the token has the
right to send data. After sending its data, the station releases the token to its successor.
The system avoids conflicts by passing the token around the network. If a station has no
data to send, it simply passes the token. This method requires proper token management
to prevent loss. Stations in a token-passing network may be connected physically in
different topologies, such as a standard ring, dual ring, bus ring, or star ring.
12.3 CHANNELIZATION
Channelization, or channel partitioning, allows stations to share a communication channel
by dividing the bandwidth into smaller portions using time, frequency, or codes. The
main channelization methods are FDMA, TDMA, and CDMA.
12.3.1 FDMA
Frequency-Division Multiple Access (FDMA) divides the available bandwidth into
frequency bands, with each station assigned a specific band. These bands are reserved for
each station throughout the communication. FDMA is effective for continuous data
streams, such as in cellular systems, and requires bandpass filters to avoid interference.
Though similar to Frequency-Division Multiplexing (FDM), FDMA operates at the data
link layer, while FDM is a physical layer technique.
12.3.2 TDMA
Time-Division Multiple Access (TDMA) allocates fixed time slots to each station for
data transmission. Stations transmit during their assigned time slots, and synchronization
between stations is crucial. TDMA works by dividing time into slots and allowing each
station to send data in its assigned slot. It differs from Time-Division Multiplexing
(TDM) in that TDM is used to combine channels into one, whereas TDMA is an access
method allowing stations to share a channel in time.
12.3.3 CDMA
Code-Division Multiple Access (CDMA) allows all stations to transmit simultaneously,
with each station using a unique code to encode its data. The data streams are separated
based on their codes, which are orthogonal to each other, allowing the receiver to isolate
the data from the intended sender. CDMA’s advantage is that multiple stations can
transmit at the same time without interfering with one another, making it ideal for
systems like cellular networks. Each station is assigned a unique code that allows its
transmission to be distinguished from others.
10.1 INTRODUCTION
Error detection and correction are essential in ensuring reliable data
transmission. The primary focus is on identifying and handling errors that
occur when bits are transmitted from one point to another. The transmission
of data is susceptible to interference, which can alter the signals, leading to
errors. These errors can affect the integrity of the data, and error detection
and correction techniques help to minimize the impact of such errors.
10.1.1 Types of Errors
Errors can occur during data transmission due to interference, which can
alter the original signal. There are two primary types of errors: single-bit
errors and burst errors. A single-bit error occurs when only one bit of a data
unit, such as a byte, character, or packet, is flipped, changing its value from
0 to 1 or vice versa. Burst errors, on the other hand, involve multiple bits in
the data unit being altered in a similar manner. Burst errors are more likely to
occur than single-bit errors because the duration of noise interference is
generally longer than the duration of a single bit. The length of the noise and
the data rate determine the number of affected bits. For instance, at a data
rate of 1 kbps, a noise lasting 1/100 second can alter 10 bits, whereas at 1
Mbps, the same noise could alter 10,000 bits.
10.1.2 Redundancy
Redundancy is a fundamental concept in error detection and correction. To
detect or correct errors, additional bits, known as redundant bits, are sent
alongside the actual data. These extra bits are added by the sender and
removed by the receiver. The presence of these redundant bits enables the
receiver to identify whether any errors have occurred in the transmission
and, in some cases, to correct them.
10.1.3 Detection versus Correction
Error detection is simpler than error correction. In detection, the receiver
only needs to determine whether an error has occurred, with a simple "yes"
or "no" answer. The number of corrupted bits does not matter in error
detection. A single-bit error is treated the same as a burst error. Error
correction, however, requires knowing the exact number and location of the
corrupted bits. The larger the data unit, the more difficult the correction
process becomes. For example, if there is one error in an 8-bit data unit,
there are eight possible locations for the error, but if there are two errors, the
number of possibilities increases to 28.
10.1.4 Coding
To implement redundancy, various coding schemes are used. These schemes
add redundant bits to the data, creating a relationship between the
redundant and actual data bits. The receiver checks this relationship to
detect errors. Coding schemes can be classified into two categories: block
coding and convolutional coding. This text focuses on block coding, while
convolutional coding is more complex and beyond the scope of this book.
10.2 BLOCK CODING
Block coding is a method where the message is divided into blocks, each
containing k bits, known as datawords. Redundant bits, r, are added to each
block, creating an n-bit codeword, where n = k + r. The number of possible
datawords is 2^k, and the number of possible codewords is 2^n. Since n is
greater than k, there are more codewords than datawords, and some
codewords are not used. These unused codewords are referred to as invalid
or illegal. The presence of invalid codewords is crucial for error detection, as
any received codeword that is invalid indicates that an error occurred during
transmission.
10.2.1 Error Detection
In block coding, error detection relies on two conditions: the receiver must
have a list of valid codewords, and if the received codeword is invalid, an
error has occurred. When the sender encodes a dataword into a codeword
and sends it, the receiver checks if the received codeword matches any valid
codeword. If it does, the receiver accepts it; if it doesn’t, the codeword is
discarded. However, if the codeword is corrupted but still matches a valid
codeword, the error will go undetected.
For example, if the sender encodes the dataword "01" as "011" and sends it,
the receiver might receive:
1. "011" – a valid codeword, and the dataword "01" is extracted.
2. "111" – an invalid codeword (due to corruption), and it is discarded.
3. "000" – a valid codeword, but the receiver incorrectly extracts the
wrong dataword "00," making the error undetectable.
An error-detecting code can only detect errors for which it is specifically
designed, and other types of errors may remain undetected.
Hamming Distance
The Hamming distance is a central concept in error control coding. It
measures the number of differing bits between two words of the same size.
The Hamming distance between two codewords indicates how many bits
have been altered during transmission. For example, if the codeword
"00000" is sent and "01101" is received, the Hamming distance is 3,
meaning three bits were corrupted. The Hamming distance can be calculated
by applying the XOR operation and counting the number of 1s in the result.
Minimum Hamming Distance for Error Detection
The minimum Hamming distance in a set of codewords is the smallest
distance between any two valid codewords. To detect up to "s" errors, the
minimum Hamming distance must be at least "s + 1". If the distance is less
than this, errors may go undetected. For example, if the minimum Hamming
distance is 2, the system can only detect single-bit errors. If it is 4, it can
detect up to three errors.
Linear Block Codes
Most block codes used in practice are linear block codes. In these codes, the
XOR of two valid codewords results in another valid codeword. Linear block
codes are easier to implement and analyze, making them more widely used.
The minimum Hamming distance for a linear block code can be found by
looking for the non-zero codeword with the fewest number of 1s.
Parity-Check Code
A common error-detecting code is the parity-check code, which is a linear
block code. In this scheme, a k-bit dataword is converted into an n-bit
codeword, where n = k + 1. The extra bit, called the parity bit, ensures that
the total number of 1s in the codeword is even (or sometimes odd,
depending on the implementation). This code has a minimum Hamming
distance of 2, making it capable of detecting single-bit errors.
For example, when sending the dataword "1011," the codeword becomes
"10111," and the receiver checks the parity. If an error occurs, the parity
check will indicate whether the dataword was corrupted.
10.3 CYCLIC CODES
Cyclic codes are a subset of linear block codes that have an additional
property: if a codeword is cyclically shifted, the resulting word is also a valid
codeword. For example, if "1011000" is a codeword, a left cyclic shift of this
codeword results in "0110001," which is also a valid codeword. This property
makes cyclic codes useful for error detection and correction.
10.3.1 Cyclic Redundancy Check
One widely used cyclic code is the Cyclic Redundancy Check (CRC). CRC is
employed in network systems such as LANs and WANs. In a CRC system, the
sender augments the dataword with zeros, then divides it by a predefined
divisor using modulo-2 division. The remainder from this division is appended
to the dataword, forming the codeword. The receiver performs the same
division process on the received codeword. If the remainder (syndrome) is all
zeros, the dataword is accepted. If the syndrome is non-zero, the dataword is
discarded, indicating an error.
The generator in CRC division uses modulo-2 binary division, where the XOR
operation is used instead of traditional addition or subtraction. The specific
divisor used in the CRC process is chosen based on the desired error
detection properties of the system. This process ensures that even if errors
occur during transmission, they can be detected with high reliability.
10.3.3 Cyclic Code Encoder Using Polynomials
In this section, the process of creating a codeword from a dataword using
polynomials is described. Let's break it down:
Dataword Representation: The dataword, which is represented as
1001, can be expressed as the polynomial x3+1x^3 + 1x3+1. The
divisor (generator polynomial) is x3+x+1x^3 + x + 1x3+x+1.
Augmented Dataword: To create the augmented dataword, we left-
shift the dataword 3 bits, which corresponds to multiplying the
dataword by x3x^3x3. This gives us the polynomial x6+x3x^6 +
x^3x6+x3.
Division Process: The division of polynomials involves dividing the
highest degree term of the dividend (the augmented dataword) by the
highest degree term of the divisor (the generator). This division step
continues until the degree of the remainder is less than that of the
divisor. The quotient obtained in each step is used for further
subtraction (using XOR in binary).
Polynomial Representation: The polynomial representation
simplifies the operation of division, making the process more efficient
compared to other methods, as the steps involving all-0s divisors are
eliminated.
The generator polynomial in a cyclic code is essential for defining the
error-detection capabilities of the code.
10.3.4 Cyclic Code Analysis
Cyclic codes can be analyzed using polynomials to understand their error-
detection capabilities. Here's a breakdown:
Received Codeword: If the received codeword is c(x)+e(x)c(x) +
e(x)c(x)+e(x) (where c(x)c(x)c(x) is the sent codeword and e(x)e(x)e(x)
is the error polynomial), the receiver divides the received codeword by
the generator polynomial g(x)g(x)g(x) to find the syndrome
s(x)s(x)s(x).
Error Detection:
1. If s(x)≠0s(x) \neq 0s(x)=0, one or more bits are corrupted.
2. If s(x)=0s(x) = 0s(x)=0, either no bit is corrupted or the decoder
failed to detect errors.
Syndrome Calculation: The syndrome s(x)s(x)s(x) is calculated as
the remainder when dividing the received codeword by the generator
polynomial. If the remainder is zero, the error polynomial is divisible by
g(x)g(x)g(x), and the errors are undetectable.
10.3.6 Other Cyclic Codes
More advanced cyclic codes, such as Reed-Solomon codes, are based on
abstract algebra involving Galois fields. These codes are powerful for both
detection and correction but are beyond the scope of this chapter.
10.3.7 Hardware Implementation
Cyclic codes are suitable for hardware implementation due to the simple
structure of the encoder and decoder. Here's a step-by-step overview of the
hardware process:
Divisor: The divisor is XORed with parts of the dividend during the
division process. The divisor bits are fixed and do not change for
different datawords, which simplifies the hardware design.
Augmented Dataword: The bits of the augmented dataword are
shifted left, and the divisor bits align with the appropriate part of the
dataword.
Remainder Calculation: The remainder is calculated using shift
registers, which store intermediate values of the remainder during the
division process.
The hardware design can be optimized by reducing unnecessary
computations and simplifying the structure, such as using fewer XOR devices
and shift registers.
10.3.5 Advantages of Cyclic Codes
Cyclic codes have several advantages:
Error Detection: They effectively detect single-bit errors, double
errors, odd-number errors, and burst errors.
Efficiency: They are easy to implement in both hardware and software
and are fast in hardware, making them suitable for network protocols.
Robustness: Cyclic codes are robust and can detect errors in various
types of transmission errors, particularly burst errors.
10.4 CHECKSUM
Checksum is an error-detecting technique applied to messages of any length,
primarily used in the network and transport layers of the Internet. At the
source, the message is divided into m-bit units. The sender then creates a
checksum, an extra m-bit unit, and sends it along with the message. At the
destination, the receiver generates a new checksum by combining the
received message and the checksum. If the result is all zeros, the message is
accepted; if not, it is discarded. The checksum can be inserted anywhere in
the message, not necessarily at the end.
10.4.1 Concept
The traditional checksum concept is simple. For example, consider a
message of five 4-bit numbers (7, 11, 12, 0, 6). The sender sends the
message and the sum of these numbers, which is 36. The receiver adds the
numbers and compares the sum with the received checksum. If they match,
no error is detected; otherwise, the message is rejected.
One problem with this method is that the checksum (sum) can exceed the bit
limit. To solve this, one’s complement arithmetic is used, allowing numbers
to be represented with m bits. When the sum exceeds the limit, the excess
bits are wrapped around.
The sender can also complement the sum to create the checksum. In one’s
complement, the complement of a number is obtained by flipping all its bits,
which is equivalent to subtracting it from 2ⁿ - 1. This ensures that if no error
occurs, the sum will result in a “negative zero,” which is all ones in binary.
For instance, if the sum is 6, the checksum would be 9, and the sender sends
(7, 11, 12, 0, 6, 9). If the receiver adds these numbers and gets 15, and then
complements it to zero, the message is verified as correct.
Internet Checksum
The Internet traditionally uses a 16-bit checksum. The procedure involves
five steps: the message is divided into 16-bit words, the checksum is
initialized to zero, all words are added using one’s complement arithmetic,
the sum is complemented, and the checksum is sent with the data. A
flowchart of the algorithm shows how the sum is calculated and overflow bits
are wrapped around. The receiver checks the checksum in a similar process:
if the checksum equals zero, the message is accepted; otherwise, it is
rejected.
However, the traditional checksum method has limitations. If two 16-bit
items are transposed in the message, the checksum cannot detect this error
because the checksum does not account for the position of the data items.
This makes it less reliable than other error detection methods like CRC.
10.4.2 Other Approaches to the Checksum
To overcome the limitations of the traditional checksum, alternative methods
have been developed, such as the Fletcher checksum. The Fletcher
checksum adds weight to each data item based on its position, allowing it to
detect errors that the traditional checksum cannot.
Fletcher Checksum
The Fletcher checksum comes in two versions: 8-bit and 16-bit. The 8-bit
Fletcher checksum is calculated over 8-bit data items, producing a 16-bit
checksum. The algorithm works modulo 256, using two accumulators (L and
R) to add data items and their weights. The 16-bit Fletcher checksum works
similarly but over 16-bit data items, producing a 32-bit checksum and using
modulo 65,536.
Adler Checksum
The Adler checksum is a 32-bit checksum that operates on single bytes
instead of 16-bit words. It uses a prime modulus (65,521) and initializes the
left accumulator (L) to 1. The Adler checksum’s use of a prime number
enhances its error detection capabilities in certain cases. It is similar to the
16-bit Fletcher checksum, but with adjustments to improve detection
accuracy.
10.5 FORWARD ERROR CORRECTION
Forward Error Correction (FEC) is a technique used to correct errors in real-
time multimedia transmission. Unlike error detection and retransmission
methods, which require waiting for lost or corrupted packets to be resent,
FEC allows for immediate error correction or reproduction of the packet. This
is particularly useful in multimedia communications where delays are not
acceptable. Various FEC techniques have been developed to handle such
error corrections, and some of the common methods are discussed below.
10.5.1 Using Hamming Distance
Hamming distance is a measure of the difference between two bit strings,
and it plays a crucial role in error detection and correction. To detect s errors
in a message, the minimum Hamming distance, denoted as d_min, must be
at least s + 1. For error correction, a larger distance is required. Specifically,
to correct t errors, the minimum Hamming distance must be d_min = 2t + 1.
This means that to correct 10 bits in a packet, a minimum Hamming distance
of 21 bits is necessary, which requires a significant number of redundant
bits.
10.5.2 Using XOR
Another method to implement FEC involves using the exclusive OR (XOR)
operation. By applying XOR to multiple data items, we can reconstruct any
missing data by XORing the remaining data items with the result of the XOR
operation. The formula for XORing the data items is as follows:
R = P1 ⊕ P2 ⊕ … ⊕ Pi ⊕ … ⊕ PN → Pi = P1 ⊕ P2 ⊕ … ⊕ R ⊕ … ⊕ PN
This technique allows for dividing a packet into N chunks, and by computing
the XOR of all the chunks, we send N + 1 chunks. If any chunk is lost or
corrupted, it can be reconstructed at the receiver's end. For example, if N =
4, we send 25% more data and can recover the lost chunk if one of the four
chunks is lost. This reduces the need for excessive redundancy while
providing error correction.
10.5.3 Chunk Interleaving
Chunk interleaving is another FEC technique where the data is divided into
small chunks, and some chunks can be missing without significant loss.
Rather than losing an entire packet, allowing a few chunks to be missing is
more acceptable in multimedia communication.
In this method, a packet is divided into several chunks, and these chunks are
combined from multiple packets into one. If a packet is lost, only one chunk
from that packet is missing, which is typically manageable in multimedia
communications. Figure 10.21 illustrates this method, where each packet
carries a chunk from several original packets. If a packet is lost, the loss is
limited to just one chunk, minimizing the impact on the overall transmission.
10.5.4 Combining Hamming Distance and Interleaving
Combining Hamming distance with chunk interleaving enhances the FEC
method by offering stronger error correction, particularly for burst errors. In
this approach, we first create n-bit packets capable of correcting t-bit errors.
Then, the packets are interleaved, with m rows of data sent column by
column. This setup allows the receiver to automatically correct burst errors of
up to m × t-bit errors, making it more robust against consecutive errors and
improving the reliability of data transmission.