3.0 Data Link Layer
Overview and Position in OSI Model
The Data Link Layer is the second layer in the OSI model, situated above the Physical Layer and below the Network Layer. Its primary responsibility is to get packets from one hop to the next across a single network link. It takes the raw bit stream from the Physical Layer and transforms it into frames.
Core Functions of the Data Link Layer
Function | Purpose | Key Mechanisms |
---|---|---|
Framing | Bundle bits into logical units (frames) | Flag, Header, Data Payload, Trailer |
Flow Control | Regulate transmission rate between sender/receiver | Receiver signaling, Window management |
Error Control | Detect and correct transmission errors | Error detection codes, Retransmissions |
Access Control | Manage shared medium access | CSMA, Collision detection/avoidance |
Framing Details
- Purpose: Ensure reliable transmission and perform limited error detection/recovery within the link
- Frame Structure:
- Flag: Marking the start and end
- Header: Control information like addresses (MAC addresses)
- Data Payload: From the upper layer
- Trailer: Error detection/correction codes
- Addressing: Uses MAC addresses (Physical Addresses) to identify devices within the local network
Automatic Repeat reQuest (ARQ) Protocols
ARQ protocols handle transmission errors and control flow through acknowledgements and retransmissions.
Protocol Comparison Table
Protocol Type | Window Size | Error Handling | Performance | Complexity |
---|---|---|---|---|
Stop-and-Wait ARQ | 1 frame | Retransmit on timeout/NAK | Low (waiting overhead) | Simple |
Go-Back-N | N frames | Retransmit lost frame + all subsequent | Medium (bulk retransmission) | Medium |
Selective Repeat | N frames | Retransmit only lost frames | High (selective retransmission) | Complex |
Stop-and-Wait ARQ
- Sender transmits one frame and waits for acknowledgement (ACK)
- Only after receiving positive ACK does sender transmit next frame
- If frame or ACK is lost/corrupted, sender retransmits after timeout
- Provides implicit flow control
Sliding Window Protocols
Both Go-Back-N and Selective Repeat allow multiple frames transmission within a "window" before waiting for acknowledgements. They manage synchronization under conditions of premature timeouts, garbled frames, and lost frames.
Go-Back-N Protocol
- Error Response: Receiver discards lost/erroneous frame AND all subsequent frames
- Sender Action: Retransmits lost frame and all frames sent after it within current window
- Window Impact: Larger window = more frames to retransmit on error
Selective Repeat Protocol
- Error Response: Receiver discards only the specific bad frame, buffers subsequent correct frames
- Sender Action: Retransmits ONLY the lost frame
- Window Impact: Larger window = more buffering required at receiver
Performance Calculation Example
Scenario: 1000-byte frames, 1 Mbps link, 10ms propagation delay, 0.1% frame error rate
Stop-and-Wait Efficiency: * Transmission time (Tt) = 1000 × 8 / 1, 000, 000 = 8ms * Round-trip time (RTT) = 2 × 10ms = 20ms * Total time per frame = Tt + RTT = 28ms * Efficiency = Tt / (Tt + RTT) = 8/28 = 28.6%
Go-Back-N with Window Size 7: * Can send 7 frames before waiting for ACK * If error occurs at frame 4, must retransmit frames 4-7 * Efficiency improves but decreases with error rate
Access Control Protocols
These protocols determine how multiple stations access a shared medium without interference.
Protocol Comparison and Evolution
Protocol | Environment | Collision Strategy | Detection Method | Recovery Mechanism |
---|---|---|---|---|
CSMA | Any | Listen before transmit | Carrier sensing | Defer transmission |
CSMA/CD | Wired (Ethernet) | Detect during transmission | Simultaneous monitoring | Stop + random backoff |
CSMA/CA | Wireless (802.11) | Avoid before transmission | RTS/CTS control frames | Backoff + retry |
Protocol Details
Carrier Sense Multiple Access (CSMA)
- Stations listen (sense carrier) to channel before transmitting
- If channel busy, defer transmission
- Limitation: Cannot detect collisions during transmission
CSMA with Collision Detection (CSMA/CD)
- Usage: Wired Ethernet networks
- Process: Sense channel → Transmit if free → Simultaneously listen for collisions
- On Collision: Stop transmitting + back off for random period + reattempt
- Advantage: Quick collision detection and recovery
CSMA with Collision Avoidance (CSMA/CA)
- Usage: Wireless networks (IEEE 802.11)
- Reason: Collision detection difficult in wireless environments
- Method: Use control frames (RTS/CTS) to avoid collisions before transmitting
- Process: Back off after busy channel or perceived collision
Collision Domain Analysis Example
Scenario: 10 stations on shared Ethernet segment
Without Switches (Single Collision Domain): * All 10 stations compete for same medium * Higher collision probability as traffic increases * Performance degrades with more active stations
With Switch (Separate Collision Domains): * Each port creates separate collision domain * Station-to-switch links become point-to-point * Eliminates collisions between different ports
Data Link Layer Architecture
Sublayer Organization
Sublayer | Primary Functions | Key Protocols/Standards |
---|---|---|
Logical Link Control (LLC) | Flow control, Error control | Stop-and-Wait, Go-Back-N, Selective Repeat |
Media Access Control (MAC) | Channel access management | CSMA/CD, CSMA/CA, Token Ring |
The Data Link Layer is divided into two conceptual sublayers: * Logical Link Control (LLC): Handles flow control and error control functions * Media Access Control (MAC): Manages station access to shared communication channel
Protocol Complexity Levels
Service Type Classification
Complexity Level | Direction | Connection | Acknowledgment | Error Handling | Use Cases |
---|---|---|---|---|---|
Simplex Connectionless | One-way | None | None | Upper layer | Simple sensors, broadcasts |
Half-Duplex Connectionless | Two-way alternating | None | Per frame | Timeout + retransmission | Point-to-point links |
Full-Duplex Connection-Oriented | Simultaneous two-way | Established | Sequence-based | In-order delivery | Reliable data transfer |
Detailed Service Descriptions
Simplex Connectionless
- Data Flow: Only in one direction
- Acknowledgment: Sender sends frames without waiting for ACKs
- Error Handling: No error handling by this layer (delegated to upper layers)
Half-Duplex Connectionless (Acknowledged Connectionless)
- Data Flow: Both directions but only one at a time (half-duplex)
- Acknowledgment: Each frame is acknowledged
- Error Handling: Uses timeouts and retransmissions for lost/garbled frames
Full-Duplex Connection-Oriented (Acknowledged Connected Service)
- Data Flow: Both directions simultaneously (full-duplex)
- Connection: Logical connection is established
- Reliability: Frames are numbered and delivered reliably in order
Conceptual Example: University Network Scenario
Problem Setup
A university has 3 buildings connected via Ethernet switches, with wireless access points in each building.
Network Components: * Building A: 50 wired stations + 1 wireless AP (30 wireless clients) * Building B: 30 wired stations + 1 wireless AP (20 wireless clients)
* Building C: 20 wired stations + 1 wireless AP (15 wireless clients)
Data Link Layer Analysis
Wired Network (CSMA/CD): * Each switch port = separate collision domain * No collisions between buildings (switched infrastructure) * Full-duplex links between switches
Wireless Network (CSMA/CA): * Each AP creates one collision domain for its wireless clients * RTS/CTS mechanism for hidden terminal problem * Half-duplex shared medium within each wireless cell
Frame Processing Example:
Station A1 → Station B5:
1. A1 creates frame with MAC addresses (A1_MAC → B5_MAC)
2. Frame sent to Switch A via CSMA/CD
3. Switch A learns A1_MAC location, forwards to Building B
4. Switch B delivers frame to B5 port
5. B5 receives frame, sends ACK back through same path
Performance Calculation: * Wired throughput: Near line rate (minimal collisions) * Wireless throughput: ~50% of nominal rate (CSMA/CA overhead) * Inter-building latency: Switch processing + propagation delay