logo
Computer Networks

03. Data Link Layer

1. Functions

  • Framing: Divides bit streams into frames for management and error detection
  • Error control: Error detection (parity check, CRC), error correction (Hamming code)
  • Flow control: Prevents sender from sending too fast, commonly uses sliding window
  • Reliable transmission: Acknowledgment and retransmission mechanisms
  • Media access control: Rules for accessing shared channels among multiple stations

2. Framing

  • Byte count, character stuffing, bit stuffing, violation method

3. Error Control

  • Error detection codes: Parity check, Cyclic Redundancy Check (CRC)
  • Error correction codes: Hamming code

4. Flow Control and Reliable Transmission

  • Stop-and-wait protocol: Waits for acknowledgment after sending each frame
  • Sliding window protocol: Allows multiple unacknowledged frames (GBN, SR)
  • GBN (Go-Back-N): Retransmits the errored frame and all subsequent frames
  • SR (Selective Repeat): Only retransmits the errored frame

5. Media Access Control

  • Channel division: Frequency/Time/Wavelength/Code Division Multiplexing (FDM/TDM/WDM/CDM)
  • Random access: ALOHA, CSMA, CSMA/CD (Ethernet), CSMA/CA (wireless)
  • Polling: Token ring

6. Local Area Networks (LAN)

  • Ethernet (IEEE 802.3): CSMA/CD, MAC address, frame structure
  • Wireless LAN (IEEE 802.11): CSMA/CA
  • Token ring: Token passing

7. Wide Area Networks (WAN)

  • PPP protocol: Point-to-point link, simple frame structure
  • HDLC protocol: High-level Data Link Control, bit-oriented, supports point-to-point and multipoint
  • Bridge: Connects two LANs, forwards frames
  • Switch: Multi-port bridge, forwards based on MAC address

Exercises

  1. Briefly describe the main functions of the data link layer.
  2. What media access control method does Ethernet use? What is its basic principle?
  3. What is the difference between the sliding window protocol and the stop-and-wait protocol?
  4. What is the basic idea of CRC error detection?
  5. What are the similarities and differences between PPP and HDLC protocols?
  6. What is the difference between a switch and a bridge?
Reference Answers

1. Main Functions

Framing, error control, flow control, reliable transmission, media access control


2. Ethernet Media Access Control

CSMA/CD, Carrier Sense Multiple Access with Collision Detection: listen to the channel first, retransmit after detecting a collision


3. Sliding Window vs. Stop-and-Wait

Sliding window allows multiple unacknowledged frames, improving efficiency; stop-and-wait sends only one frame at a time


4. CRC Error Detection

Uses a generator polynomial to divide the data polynomial, the remainder is used as the check code


5. PPP vs. HDLC

PPP is simple, byte-oriented, point-to-point; HDLC is complex, bit-oriented, supports multipoint


6. Switch vs. Bridge

A switch is a multi-port bridge, more efficient forwarding, supports more devices