Computer Networks 2
Computer Networks 2
UNIT-3
Let's delve into Framing and Flow Control Mechanisms, which are crucial
functions of the Data Link Layer (Layer 2)in the OSI model. These
mechanisms ensure reliable and efficient data transfer between two directly
connected nodes.
Framing
Flow Control is a data link layer function that coordinates the amount of data
a sender can transmit before receiving an acknowledgment from the receiver.
Its main purpose is to prevent a fast sender from overwhelming a slow
receiver, leading to buffer overflow and frame loss at the receiver's end.
Essentially, flow control ensures that the receiver has enough buffer space
and processing capability to handle the incoming data.
Here are the main flow control mechanisms, often combined with error
control (forming ARQ protocols):
1. Stop-and-Wait Protocol (Simplest ARQ)
● The sender transmits one frame and then stops and waits for an
Concept:
acknowledgment (ACK) from the receiver before sending the next
frame.
● Working:
○ Sender sends Frame i.
○ Sender starts a timer.
○ Receiver receives Frame i. If it's valid, the receiver sends ACK
i+1 (acknowledging i and indicating it expects i+1 next).
○ Sender receives ACK i+1. If it's valid and the timer hasn't
expired, the sender stops the timer and sends Frame i+1.
○ Error Handling (Timeouts & Sequence Numbers):
■ If the sender's timer expires before receiving an ACK, it
assumes the frame or the ACK was lost/corrupted and
retransmits Frame i.
■ To handle duplicate frames (e.g., if the ACK was lost and
the sender retransmitted), frames are given alternating
sequence numbers (e.g., 0 and 1). The receiver expects
frames in sequence. If it receives a duplicate (same
sequence number as the last successfully received frame), it
discards it and re-sends the ACK.
● Advantages: Simple to implement.
● Disadvantages:
○ Very Inefficient: Throughput is extremely low, especially over
long distances (high propagation delay) or high bandwidth links,
because the sender spends most of its time waiting.
○ Low Link Utilization: The channel is idle while the sender waits
for an ACK.
2. Sliding Window Protocols
Errors in data transmission occur when bits are altered during transit. These
alterations can be caused by various factors like noise, interference, signal
attenuation, or faulty hardware.
1. Single-Bit Error:
○ Description: Only one bit in the data unit (frame/packet) is
flipped from 0 to 1 or 1 to 0.
○ Example: Sent 00100010, Received 00101010 (the 4th bit
from left changed).
○ Cause: Often caused by random noise spikes or brief signal
interruptions.
○ Detection: Relatively easy to detect using simple parity checks,
checksums, or CRCs.
2. Multiple-Bit Error:
○ Description: Two or more non-consecutive bits in a data unit are
flipped.
Error correction goes beyond merely detecting errors; it aims to identify the
exact location of the corrupted bit(s) and then flip them back to their original
state, thus recovering the original data without retransmission. This requires
more redundancy than just error detection.
There are two main approaches to error correction:
1. Backward Error Correction (BEC) / ARQ (Automatic Repeat
Request):
○ Concept: This is the most common approach in computer
networks. The receiver detects an error (using CRC, checksum,
parity check, etc.) and then sends a negative acknowledgment
(NAK) or simply does not send an acknowledgment (ACK) for
the corrupted frame. This signals the sender to retransmit the
entire data unit.
○ Mechanism: This is what we discussed with Stop-and-Wait, Go-
Back-N, and Selective Reject ARQ protocols. The error detection
mechanism is paired with a retransmission strategy.
○ Advantages:
■ Simpler to implement compared to FEC.
■ Guarantees perfect data recovery (assuming retransmission
is possible).
○ Disadvantages:
■ Introduces latency due to retransmissions.
■ Wastes bandwidth if retransmissions are frequent (noisy
channels).
■ Not suitable for real-time applications (e.g., live
video/audio streaming) where delays are unacceptable.
○ Usage: Common in reliable protocols like TCP, file transfers,
and most data link layer protocols where retransmission is
feasible.
2. Forward Error Correction (FEC):
○ Concept: The sender adds enough redundant information (error-
correcting codes) to the original data such that the receiver can
detect and correct a certain number of errors without requiring
retransmission. The receiver has the intelligence and redundant
bits to fix the errors itself.
○ Mechanism:
■ Encoding: At the sender, data bits are passed through an
encoder that adds redundant bits based on a specific
algorithm (e.g., Hamming codes, Reed-Solomon codes,
convolutional codes). The original data is transformed into
a longer codeword.
■ Decoding: At the receiver, the entire received codeword is
passed through a decoder. If errors occur within the
correction capabilities of the code, the decoder can identify
the corrupted bits and reverse them to reconstruct the
original data.
○ Advantages:
■ No retransmission needed, which means no additional
latency or bandwidth consumption due to errors.
■ Ideal for real-time applications (streaming, voice over IP)
and one-way communication links (e.g., satellite
communication, deep space probes) where retransmission
is impossible or impractical.
○ Disadvantages:
■ Adds significant overhead (more redundant bits must be
sent), reducing the effective data rate.
■ More complex to design and implement.
■ Can only correct errors up to a certain limit; if too many
errors occur, it may fail, requiring a higher-layer
retransmission or data loss.
○ Usage: Used in mobile communications (cellular networks),
satellite communications, deep-space communication, digital
broadcasting (DVB), and storage systems (e.g., RAID, memory
error correction in RAM - ECC RAM).
Example of an FEC code: Hamming Code Hamming codes are a family of
linear error-correcting codes capable of detecting up to two simultaneous bit
errors and correcting single-bit errors. They work by strategically placing
parity bits within the data block, allowing the receiver to not only detect an
error but also identify its exact position.
In summary, error detection focuses on knowing if an error occurred, while
error correction aims to fix the error. ARQ (BEC) is a common error control
strategy that relies on error detection and retransmission, whereas FEC
embeds enough redundancy to allow direct correction at the receiver. The
choice between these methods depends on the characteristics of the
communication channel and the requirements of the application (e.g., latency
tolerance, bandwidth availability).
Let's explore Carrier Sense Multiple Access (CSMA) protocols, focusing
on CSMA/CD, and then two important Data Link Layer protocols: HDLC
and PPP. These are crucial for understanding how devices share a common
medium and how data is reliably transported over point-to-point links.
CSMA (Carrier Sense Multiple Access)
CSMA is a Media Access Control (MAC) protocol that defines how devices
share a single transmission medium (like an Ethernet cable in older networks
or a radio frequency in wireless networks). The core principle of CSMA is
"listen before you speak."
Core Idea: Before transmitting data, a station (device) first listens to the
transmission medium to check if it's currently busy (i.e., if another station is
transmitting).
Mechanism:
1. Carrier Sense: A station listens for a "carrier" signal on the shared
medium. If a carrier is detected, it means the medium is busy.
2. Multiple Access: If the medium is idle, the station can then attempt to
transmit its data. Multiple stations can access the medium.
Problem with Pure CSMA: Collisions Even with carrier sensing, collisions
can still occur. This happens if two or more stations sense the medium as idle
simultaneously (due to propagation delay, where a signal hasn't yet reached
all parts of the network) and begin transmitting at roughly the same time.
When two or more signals overlap on the shared medium, the data becomes
corrupted – a collision.
Different CSMA variants exist based on how they react to a busy medium:
● 1-persistent CSMA: If the medium is idle, transmit with probability 1.
If busy, keep listening and transmit immediately when idle. (High
collision probability)
● Non-persistent CSMA: If the medium is idle, transmit. If busy, wait a
random amount of time and then sense again. (Lower utilization, but
fewer collisions)
● p-persistent CSMA: (For slotted channels) If idle, transmit with
probability p. With probability 1-p, defer to the next slot. If busy,
defer to the next slot.
CSMA/CD (Carrier Sense Multiple Access with Collision Detection)
PPP is another data link layer protocol primarily used for establishing a
direct connection between two nodes (e.g., a home computer connecting to an
ISP via dial-up, DSL, or cable modem, or two routers connecting over a
WAN link). It's a byte-oriented protocol, meaning it operates on bytes rather
than individual bits.
Key Features and Components:
PPP is more than just a framing protocol; it's a suite of protocols that
provides three main components:
1. HDLC-like Framing:
○ PPP uses a framing method very similar to HDLC, with a flag
byte 01111110 (0x7E) to delimit frames.
○ It uses byte stuffing (or character stuffing) to ensure data
transparency. If the flag byte (0x7E) appears in the data, it's
replaced by a two-byte sequence (0x7D 0x5E). If the escape
byte (0x7D) appears, it's replaced by (0x7D 0x5D).
○ Includes a Protocol field (unique to PPP) that indicates the
network layer protocol being encapsulated (e.g., 0x0021 for IP,
0x8021 for IPv6CP, 0xC021 for LCP). This is a significant
improvement over standard HDLC, which typically assumed a
single higher-layer protocol.
○ Includes an FCS (Frame Check Sequence) for error detection
(CRC).
2. Link Control Protocol (LCP):
○ Responsible for establishing, configuring, testing, maintaining,
and terminating the data link connection.
○ LCP negotiates various link options between the two
communicating devices, such as:
■ Maximum Receive Unit (MRU): Maximum payload size
allowed in a frame.
■ Authentication Protocol: Negotiates which authentication
method (PAP, CHAP, EAP) to use.
■ Compression: Negotiates data compression algorithms.
■ Error Detection: Negotiates the use of magic numbers for
loop detection.
■ Link quality monitoring.
3. Network Control Protocols (NCPs):
○ A family of protocols, one for each network layer protocol that
PPP supports (e.g., IP, IPX, AppleTalk).
○ NCPs are responsible for configuring the network layer
parameters for the specific protocol once the LCP link is
established.
○ IP Control Protocol (IPCP): The most common NCP. It's used
to configure TCP/IP parameters for the connection, such as
assigning IP addresses (often dynamically), DNS server
addresses, etc.
○ IPv6 Control Protocol (IPv6CP): For configuring IPv6
parameters.
Advantages of PPP over HDLC (for dial-up/WAN links):
● Multi-protocol Support: PPP's Protocol field allows it to encapsulate
and multiplex different network layer protocols simultaneously over the
same link (e.g., IP and IPX). Standard HDLC typically supports only
one.
● Authentication: PPP supports robust authentication mechanisms
(PAP, CHAP, EAP) to verify the identity of the connecting peer, which
is crucial for ISP connections. HDLC does not have built-in
authentication.
● Compression: PPP can negotiate and use data compression algorithms,
improving throughput over slower links.
● Link Quality Monitoring: LCP provides mechanisms to monitor the
quality of the link.
● Flexibility: PPP is a very flexible and extensible protocol, allowing
new features to be added through LCP and NCP negotiations.
Usage:
● Dial-up Internet Access: Historically, the most common use for
connecting modems to ISPs.
● DSL and Cable Modems: PPP over Ethernet (PPPoE) is widely used
by DSL and some cable modem providers to establish connections and
authenticate users.
● VPNs: Often used as the underlying data link layer protocol for some
VPN solutions (e.g., PPTP - Point-to-Point Tunneling Protocol).
● WAN Links: Used to encapsulate IP packets over synchronous and
asynchronous serial WAN links.
In summary, CSMA and CSMA/CD are MAC protocols for shared media.
HDLC and PPP are data link layer protocols primarily for point-to-point
serial links, with PPP offering more advanced features like multi-protocol
support, authentication, and negotiation capabilities, making it more suitable
for modern WAN and Internet access scenarios.