Data Comm Chap 3
Data Comm Chap 3
NETWORKING
Presented by:
Dr. Sachin Agrawal
ECE Department
Outline
• Introduction
The data link layer is Layer 2 in the Open Systems Interconnection (OSI)
architecture model for a set of telecommunication protocols.
Data bits are encoded, decoded and organized in the data link layer, before they are
transported as frames between two adjacent nodes on the same LAN or WAN.
The data link layer also determines how devices recover from collisions that may
occur when nodes attempt to send frames at the same time.
1
2. Data Link Layer Design Issues
The data link layer uses the services of the physical layer to send and receive bits over
communication channels. It has a number of functions, including:
3. Regulating the flow of data so that slow receivers are not swamped by fast senders
To accomplish these goals, the data link layer takes the packets it gets from the
network layer and encapsulates them into frames for transmission. Each frame
contains a frame header, a payload field for holding the packet, and a frame trailer
2
2. Data Link Layer Design Issues
2.1 Services Provided to the Network Layer
3
2. Data Link Layer Design Issues
2.2 Framing
Framing: The data link layer divides the raw bit stream into frames, adding a
checksum to detect transmission errors. It ensures that the receiver can identify the
start and end of each frame.
Byte Count: A field in the header specifies the number of bytes in the frame. However,
errors in the byte count can cause synchronization issues, making this method less
reliable.
Flag Bytes with Byte Stuffing: Frames start and end with special flag bytes. If the
flag byte appears in the data, an escape (ESC) byte is inserted to distinguish it. This
method helps maintain synchronization.
Flag Bits with Bit Stuffing: Used at the bit level, it adds a '0' bit after every five
consecutive '1' bits in the data to prevent confusion with the flag pattern used for
4
frame boundaries.
Physical Layer Coding Violations: Some protocols, like Ethernet, use a preamble—a
2. Data Link Layer Design Issues
2.3 Error Control:
The next issue in the data link layer is error control. The error may have happened
during the transmission.
The errored frames are dropped by the receiver and acknowledgement are not sent.
The Acknowledgment (ACK) used for reliable delivery. If frame or ACK is lost, no ACK is
sent to sender. In this case Sender uses timer to react with average round trip time
(RTT) to retransmit the frame.
If ACK is lost, receiver receives multiple copies of same frame. To identify multiple
copies and remove the duplicated copies of the frame, sequence number is used in the
frames.
5
2. Data Link Layer Design Issues
2.4 Flow Control:
Flow control is a technique that allows two stations working at different speeds to
communicate with each other. It is a set of measures taken to regulate the amount of
data that a sender sends so that a fast sender does not overwhelm a slow receiver.
In data link layer, flow control restricts the number of frames the sender can send
before it waits for an acknowledgment from the receiver. Two approaches are
commonly used.
• Feedback based Flow Control - the sender sends frames after it has received
acknowledgments from the user. This is used in the data link layer.
• Rate based Flow Control - These protocols have built in mechanisms to restrict the
rate of transmission of data without requiring acknowledgment from the receiver. Used
in the network layer and the transport layer.
6
3. Error Detection and Correction
3.1 Introduction
Networks must be able to transfer data from one device to another with acceptable
accuracy. For most applications, a system must guarantee that the data received are
identical to the data transmitted.
Any time data are transmitted from one node to the next, they can become corrupted in
passage.
Many factors can alter one or more bits of a message. Some applications require a
mechanism for detecting and correcting errors.
Some applications can tolerate a small level of error. For example, random errors in
audio or video transmissions may be tolerable, but when we transfer text, we expect a
very high level of accuracy.
7
3. Error Detection and Correction
3.1 Introduction
Types of Error:
1. Single-bit error: In a single-bit error, only 1 bit in the data unit has changed.
Single-bit errors are the least likely type of error in serial data transmission.
Coding
Coding Redundancy is achieved through various coding schemes. The sender adds
redundant bits through a process that creates a relationship between the redundant
bits and the actual data bits. The receiver checks the relationships between the two
sets of bits to detect or correct the errors. The ratio of redundant bits to the data bits
and the robustness of the process are important factors in any coding scheme. 10
3. Error Detection and Correction
3.2 Block Coding
Block coding is a method used in error detection and correction, where a message is
divided into blocks of k bits, known as datawords. To each dataword, r redundant bits
are added, creating a longer block of n = k + r bits, called a codeword. The redundant
bits are added to enable the detection and correction of errors during transmission. In
block coding, the encoding process is one-to-one, meaning the same dataword always
corresponds to the same codeword.
Key Concepts:
1. Datawords and Codewords:
A dataword consists of k bits, which represent the original message.
A codeword is an n-bit sequence (where n = k + r) that includes k data bits and r
redundant bits.
2. Possible Combinations:
With k bits, we can have 2𝑘 possible datawords.
With n bits, we can create 2𝑛 possible codewords. 11
Since n > k, the number of possible codewords is larger than the number of datawords,
meaning some codewords are unused and referred to as invalid or illegal codewords.
3. Error Detection and Correction
3.2 Block Coding
3. Error Detection:
Block coding allows the detection of errors by checking whether the received codeword
is valid. Two conditions must be met for error detection:
The receiver must have a list of valid codewords.
If the received codeword does not match any valid codeword, it is identified as
invalid and discarded. However, block coding typically detects only single-bit errors. If
more bits are corrupted, the received codeword might still match a valid one, causing
undetected errors.
4. Error Correction:
Error correction is more complex than detection. The receiver must determine which
valid codeword was sent. More redundant bits are needed for correction than for
detection. In error correction, the receiver can correct errors by comparing the
received codeword to the valid codewords and selecting the one closest to the received
word.
12
3. Error Detection and Correction
3.2 Block Coding
5. Hamming Distance:
The Hamming distance between two words is the number of differing bits. It helps
quantify the ability to detect and correct errors.
The minimum Hamming distance (dmin) in a code is the smallest Hamming
distance between any pair of valid codewords.
A higher dmin means better error detection and correction capabilities.
The Hamming distance can easily be found if we apply the XOR operation on the two
words and count the number of Is in the result.
Assume the sender encodes the dataword 01 as 011 and sends it to the receiver.
Consider the following cases:
1. The receiver receives 01l. It is a valid codeword. The receiver extracts the dataword
01 from it.
2. The codeword is corrupted during transmission, and 111 is received (the leftmost bit
is corrupted). This is not a valid codeword and is discarded.
3. The codeword is corrupted during transmission, and 000 is received (the right 14 two
bits are corrupted). This is a valid codeword. The receiver incorrectly extracts the
dataword 00. Two corrupted bits have made the error undetectable.
3. Error Detection and Correction
3.3 Linear Block Codes
Linear Block Codes are a specific class of block codes used for error detection and
correction, and they have a structure that makes them easier to implement and
analyze compared to nonlinear codes. The key feature of linear block codes is that
the exclusive OR (XOR) operation (or addition modulo-2) between any two valid
codewords produces another valid codeword.
Key Concepts:
1. Linear Block Code Definition:
A block code is considered linear if the XOR of any two valid codewords
results in another valid codeword. This property makes linear block codes easier to
analyze.
These codes form a subgroup under addition (XOR operation).
The minimum Hamming distance is dmin = 2, which allows the detection of a single-
bit error, but it cannot correct any errors.
The parity bit is computed by performing the XOR of all bits in the dataword,
ensuring that the resulting codeword has an even number of 1s.
Example: For a dataword of 1011, the parity bit would be 1, making the codeword
10111.
16
3. Error Detection and Correction
3.3 Linear Block Codes
4. Hamming Codes:
Hamming codes are a more advanced type of linear block code that can correct a
single-bit error or detect two-bit errors.
These codes have dmin = 3, which allows them to detect up to two errors or correct
one error.
Parity-check bits are strategically placed to ensure that any single-bit error produces
a unique syndrome, enabling the system to identify the erroneous bit and correct it.
17
3. Error Detection and Correction
3.3 Linear Block Codes
Example:
For example, if m = 3, then n = 7 and k = 4. This is a Hamming code C(7, 4) with
dmin =3.
18
3. Error Detection and Correction
3.3 Linear Block Codes
19
3. Error Detection and Correction
3.4 Cyclic Codes
Cyclic Codes are a subclass of linear block codes with a special property: any cyclic
shift of a valid codeword results in another valid codeword. These codes are widely
used in communication systems due to their easy implementation using shift
registers.
Key Concepts:
1. Definition:
In a cyclic code, if you take a valid codeword and cyclically shift its bits
(move the bits around in a circle, where the last bit moves to the front), the result
will be another valid codeword.
This cyclic property allows for easier error detection and correction using
algebraic structures like polynomials and division.
20
3. Error Detection and Correction
3.4 Cyclic Codes
2. Representation Using Polynomials:
A key feature of cyclic codes is that they can be represented as polynomials. Each
codeword is viewed as a polynomial where the coefficients are the bits of the
codeword (1 or 0).
For example, the codeword 1011 can be represented as the polynomial 𝑥 3+𝑥+1.
3. Generator Polynomial:
Each cyclic code has a generator polynomial. This polynomial is used to generate all
valid codewords in the code. The length of the codeword 𝑛 and the number of data
bits 𝑘 determine the generator polynomial.
21
Key Concepts:
1. Basic Idea:
The checksum is calculated by dividing the data into fixed-size chunks, typically 16-
bit or 32-bit words, summing them, and then using the ones' complement of the
result as the checksum. This checksum is sent along with the data.
At the receiver end, the same division and summation process is performed. The
received checksum is added to this result, and if no errors occurred, the result
should be all ones (in the case of ones' complement arithmetic).
23
3. Error Detection and Correction
3.5 Checksum
2. Process of Checksum Calculation:
At the Sender:
Break the data into equal-size segments (e.g., 16 bits each).Sum these
segments using binary addition.
Take the ones' complement of the sum (invert all bits). This is the checksum.
Append the checksum to the data and send it.
At the Receiver:
The receiver breaks the received data (including the checksum) into equal-
sized segments.
It sums all the segments, including the checksum.
If the result is all ones, the data is considered error-free; otherwise, an error
has occurred.
24
3. Error Detection and Correction
3.5 Checksum
3. Example:
Suppose we are transmitting three 16-bit words: 10011001 10101011, 11001100
01110001, and 00110011 11000011. The sender sums these binary numbers, takes
the ones' complement of the sum, and appends it to the data.
The receiver performs the same summation with the received data (including the
checksum). If the sum results in all ones (in binary), the transmission is error-free.
4. Internet Checksum:
The Internet checksum is a specific type of checksum used in the IP, TCP, and UDP
protocols. The Internet checksum treats the data as 16-bit words, sums them using
ones' complement arithmetic, and sends the ones' complement of the sum as the
checksum.
This method is simple but not as robust as CRC, and it is typically used to detect
25
accidental errors in packets.
3. Error Detection and Correction
3.5 Checksum
Advantages of Checksum:
Simplicity and ease of implementation in software.
Suitable for detecting random errors in the transmission of data.
Fast error detection, although not as reliable as CRC for burst errors.
Disadvantages of Checksum:
Not as powerful as cyclic codes or CRC in detecting certain types of errors,
such as burst errors or errors involving multiple bits.
Data Link Control (DLC) refers to the protocols and mechanisms in the data link
layer of the OSI model that manage the reliable communication between two
adjacent nodes in a network. DLC ensures that data transmitted over a physical link
is correctly framed, error-free, and appropriately sequenced. It plays a critical role
in node-to-node communication, whether the link is dedicated (point-to-point) or
shared (broadcast).
DLC converts streams of bits into structured frames, making it possible for the
receiver to distinguish individual messages.
Each frame contains source and destination addresses to identify the sender and
receiver, along with error detection codes. 27
4. Data Link Control and Protocols
4.1 Data Link Control
Frames can be fixed-size or variable-size, and the approach for delimiting frames
varies:
Character-Oriented Framing: Uses special byte sequences as flags to mark
frame boundaries. An escape character is used to differentiate data from control
information.
Bit-Oriented Framing: Uses a special bit pattern (e.g., 01111110) as a flag
for the frame's start and end. To prevent flag patterns within the data, bit stuffing is
used, where extra bits are inserted and later removed.
2. Flow Control:
This ensures that the sender doesn't overwhelm the receiver with data, by
maintaining balance between the production of frames by the sender and their
consumption by the receiver.
A buffer system is typically employed, where the receiver signals the sender to pause
28
transmission if the buffer is full.
4. Data Link Control and Protocols
4.1 Data Link Control
3. Error Control:
DLC handles errors in the physical transmission by using techniques like CRC (Cyclic
Redundancy Check) for error detection.
29
4. Data Link Control and Protocols
4.2 Data Link Control Protocols
A DLC protocol can be either connectionless or connection-oriented.
1. 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
connectionless here does not mean that there is no physical connection (transmission
medium) between the nodes; it means that there is no connection between frames.
The frames are not numbered and there is no sense of ordering. Most of the data-link
protocols for LANs are connectionless protocols.
2. 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 30
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
5. Example Data Link Control Protocol
An example of a Data Link Control (DLC) protocol is the High-Level Data Link
Control (HDLC) protocol, a widely used protocol for managing communication
between network nodes at the data link layer. HDLC is a bit-oriented protocol that
ensures reliable and organized data transfer, making it a good example to illustrate
how data link control operates.
3. Error Control: HDLC employs error detection and recovery mechanisms, such as
Cyclic Redundancy Check (CRC), to ensure that errors introduced during
transmission are detected. If an error is found, the frame is discarded, and the
sender retransmits it.
2. Data Transmission: Once the link is established, I-frames are sent to transmit
data. Sequence numbers in the control field track the frames.
3. Flow Control: The receiver can use S-frames to inform the sender to pause
transmission if its buffer is full.
4. Error Control: The receiver checks the FCS in each frame. If an error is
detected, the receiver discards the frame and requests a retransmission.
34
5. Example Data Link Control Protocol
Use Cases of HDLC:
HDLC is used in various communication systems, including:
35
Thank You