Unit 2: Physical and Data Link Layers

CSE306 — Computer Networks 10 min read

I. Orientation — Layered Communication

Data communication is the exchange of information between devices through a transmission medium. The physical layer carries raw bits as signals, while the data link layer organizes those bits into frames and provides dependable node-to-node delivery.

  • Core components:
    • Sender: Device that originates data.
    • Receiver: Device that accepts data.
    • Message: Information being communicated, such as text, audio, or video.
    • Medium: Physical or wireless path followed by the signal.
    • Protocol: Rules governing representation, timing, delivery, and interpretation.
  • Physical layer role: Defines signal encoding, bit rate, connectors, frequencies, media, and transmission modes.
  • Data link layer role: Performs framing, addressing, flow control, medium access, and error control between directly connected nodes.
  • Delivery requirements: An effective system aims for correct destination delivery, accuracy, acceptable delay, and low variation in packet delay called jitter.
  • Layer relationship: The data link layer supplies frames to the physical layer, which converts frame bits into electrical, optical, or electromagnetic signals.

II. Data Communication Fundamentals — Information, Signals, and Transfer

A. Basics of Data Communications

Data communication depends on representing information as signals and coordinating how those signals travel between endpoints.

  • Data and signals: Data is meaningful information; a signal is the electrical, optical, or electromagnetic representation used to carry it.
    • Analog signal: Varies continuously over time and amplitude.
    • Digital signal: Uses discrete levels, commonly representing binary 0 and 1.
  • Signal characteristics:
    • Amplitude: Signal strength, measured in volts for an electrical signal.
    • Frequency: Cycles completed per second, measured in hertz (Hz).
    • Phase: Position of a waveform relative to a time reference, measured in degrees or radians.
  • Transmission modes:
    1. Simplex: Communication travels in one direction only, as in a keyboard sending input.
    2. Half-duplex: Both devices transmit, but not simultaneously, as with walkie-talkies.
    3. Full-duplex: Both devices transmit simultaneously, as in a telephone call.
  • Connection organization:
    • Point-to-point: A dedicated link joins exactly two devices.
    • Multipoint: Several devices share one link.
  • Bit rate and baud rate: Bit rate is bits transmitted per second (bps); baud rate is signal units transmitted per second. If each signal element represents r bits:
TEXT
Bit rate = Baud rate × r
  • Protocols: Syntax defines message format, semantics defines field meaning, and timing defines transmission order and speed.

III. Wired Channels — Signals Through Physical Paths

A. Guided Transmission Media

Guided media confine signals to a solid path, producing predictable propagation and physical security.

  • Twisted-pair cable: Two insulated copper wires are twisted to reduce electromagnetic interference and crosstalk.
    • UTP: Unshielded twisted pair is inexpensive and widely used in Ethernet and telephone networks.
    • STP: Shielded twisted pair adds metallic shielding but costs more and requires proper grounding.
    • Connector: Ethernet twisted-pair links commonly use an 8P8C modular connector, often called RJ45.
  • Coaxial cable: A central conductor, dielectric insulation, metallic shield, and outer jacket provide better noise resistance than twisted pair.
    • Applications: Cable television, broadband access, and legacy Ethernet.
    • Impedance: Common systems use approximately 50 Ω or 75 Ω cable, depending on application.
  • Optical fiber: Light pulses travel through a glass or plastic core using total internal reflection.
    1. Single-mode fiber: Has a narrow core and supports long-distance, high-bandwidth links with little modal dispersion.
    2. Multimode fiber: Has a wider core, permits multiple light paths, and suits shorter distances.
  • Comparison: Fiber offers the greatest bandwidth, low attenuation, and immunity to electromagnetic interference; copper is generally cheaper and easier to terminate.
  • Limitations: Guided media require physical installation, can be damaged by cuts or bending, and may be costly across difficult terrain.

IV. Wireless Channels — Propagation Without Conductors

A. Unguided Transmission Media

Unguided media transmit electromagnetic waves through air, vacuum, or space without a physical conductor.

  • Radio waves: Often propagate in many directions and can penetrate buildings, supporting broadcasting, mobile communication, and wireless networking.
  • Microwaves: Usually provide directional, line-of-sight communication at higher frequencies.
    • Terrestrial microwave: Uses aligned antennas and repeaters because Earth’s curvature limits range.
    • Satellite microwave: Uses an orbiting satellite as a relay between ground stations; geostationary distance introduces noticeable delay.
  • Infrared: Supports short-range, line-of-sight or reflected communication but generally does not pass through walls.
  • Propagation methods:
    • Ground propagation: Lower-frequency waves follow Earth’s surface.
    • Sky propagation: Waves are refracted back toward Earth by the ionosphere.
    • Line-of-sight propagation: High-frequency signals travel mainly along a direct path.
  • Advantages: Wireless links enable mobility, rapid deployment, broadcasting, and coverage where cabling is impractical.
  • Limitations: Interference, obstacles, shared spectrum, interception, weather, and regulatory frequency allocations affect performance.

V. Signal Quality — Limits on Reliable Communication

A. Transmission Impairments and Performance

Transmission quality declines when a received signal differs from the signal originally sent.

  • Attenuation: Signal energy decreases with distance and is commonly expressed in decibels:
TEXT
dB = 10 log10(Pout / Pin)
  • Pin is input power and Pout is output power.
  • A negative result represents power loss; amplifiers or repeaters compensate for it.
    • Distortion: Frequency components propagate at different speeds or experience different attenuation, changing the signal’s shape.
    • Noise:
  • Thermal noise: Random electron motion in conductive material.
  • Induced noise: Interference from motors, power lines, or appliances.
  • Crosstalk: Unwanted coupling between nearby channels.
  • Impulse noise: Brief high-energy spikes that can corrupt multiple bits.
    • Bandwidth: The frequency range a channel passes, measured in hertz; greater usable bandwidth generally permits a higher data rate.
    • Throughput: The actual delivered data rate, usually below nominal bandwidth because of headers, contention, errors, and congestion.
    • Latency:
TEXT
Total delay = Transmission + Propagation + Processing + Queuing
  • Transmission delay equals frame size in bits divided by link rate in bps.
  • Propagation delay equals distance divided by propagation speed.
    • Shannon capacity:
TEXT
C = B log2(1 + S/N)
  • C is maximum theoretical capacity in bps, B is bandwidth in Hz, and S/N is the linear signal-to-noise ratio.

VI. Link-Level Communication — Reliable Frame Exchange

A. Elementary Data Link Protocols

Elementary protocols show how framing, flow control, acknowledgements, and retransmission create reliable communication over one link.

  • Unrestricted simplex protocol: Assumes perfect transmission, an always-ready receiver, and one-way data flow; the sender transmits frames continuously.
  • Simplex stop-and-wait protocol: The sender transmits one frame and waits until the receiver indicates readiness, preventing receiver-buffer overflow.
  • Stop-and-wait ARQ: Adds automatic repeat request for unreliable channels.
    • The sender starts a timer after transmitting.
    • The receiver returns an acknowledgement (ACK) for a valid frame.
    • A timeout or negative acknowledgement causes retransmission.
  • Sequence numbers: Alternating 0 and 1 distinguish a new frame from a duplicate created when an acknowledgement is lost.
  • Framing: The link layer marks frame boundaries using length fields, byte stuffing, bit stuffing, or coding violations.
  • Flow versus error control: Flow control protects a slow receiver; error control handles damaged, lost, or duplicated frames.
  • Efficiency limitation: Stop-and-wait wastes capacity on links with large propagation delay because only one frame can remain unacknowledged.

VII. Error Control — Identifying and Repairing Corruption

A. Error Detection and Correction

Error control adds redundancy so a receiver can detect corruption and, in some schemes, reconstruct the original data.

  • Error types:
    • Single-bit error: Exactly one bit changes value.
    • Burst error: Two or more bits within a span are affected, although every bit in that span need not change.
  • Redundancy: The sender computes check bits from the data; the receiver recomputes or verifies them.
  • Detection: Parity, checksum, and CRC reveal likely corruption but normally require retransmission to recover.
  • Forward error correction: The receiver corrects errors directly using sufficient redundant information, useful where retransmission is expensive.
  • Code distance: Hamming distance is the number of differing bit positions between two codewords.
  • Capability rules: A code with minimum distance dmin can detect up to dmin − 1 errors and correct up to:
TEXT
t = floor((dmin − 1) / 2)
  • Trade-off: More redundancy improves protection but consumes bandwidth and processing time.

VIII. Distance-Based Coding — Single-Bit Error Correction

A. Hamming code

Hamming code places parity bits at selected positions so the receiver can locate and correct a single-bit error.

  • Parity positions: Redundant bits occupy positions 1, 2, 4, 8, ...; data bits occupy all remaining positions.
  • Required redundancy: For m data bits and r parity bits:
TEXT
2^r ≥ m + r + 1
  • The right side represents all bit-error positions plus the no-error state.
    • Parity coverage: Parity bit at position 2^k checks positions whose binary position number contains 1 in bit k.
    • Syndrome: The receiver repeats parity checks and combines failed-check values; a nonzero syndrome gives the erroneous bit position.
    • Worked example: For m = 4, choose r = 3 because 2^3 = 8 ≥ 4 + 3 + 1. The resulting seven-bit Hamming code has parity at positions 1, 2, and 4.
    • Capability: Standard Hamming code corrects one-bit errors. Adding an overall parity bit produces SECDED: single-error correction and double-error detection.

IX. Polynomial Error Detection — Strong Burst Protection

A. CRC

A cyclic redundancy check treats a bit sequence as a polynomial and appends the remainder from modulo-2 division.

  • Generator: Sender and receiver agree on a generator polynomial G(x) with degree r.
  • Encoding: Append r zeros to data D, divide by G using XOR arithmetic, and replace those zeros with the r-bit remainder R.
TEXT
Transmitted frame T = D × 2^r XOR R
  • Verification: The receiver divides T by the same generator; a zero remainder indicates that no detectable error occurred.
  • Modulo-2 arithmetic: Addition and subtraction both use XOR, with no carries or borrows.
  • Detection strength: A suitable generator detects all single-bit errors, many multiple-bit errors, and every burst error shorter than or equal to r bits.
  • Limitation: CRC detects rather than repairs corruption; recovery generally relies on retransmission.

X. Bit-Count Protection — Simple Error Detection

A. Parity

Parity adds one bit so the number of 1 bits follows an agreed even or odd rule.

  • Even parity: The parity bit makes the total number of 1s even.
  • Odd parity: The parity bit makes the total number of 1s odd.
  • Example: Data 1011001 contains four 1s, so its even-parity bit is 0 and its odd-parity bit is 1.
  • Detection ability: Single parity detects every odd number of bit changes.
  • Limitation: An even number of changed bits preserves parity and may pass undetected.
  • Two-dimensional parity: Arranging data in rows and columns and adding parity to both dimensions improves burst-error detection and may identify a single erroneous position.
  • Use: Parity is inexpensive in hardware and suitable where low overhead matters more than strong protection.

XI. Word-Based Error Detection — End-Around-Carry Verification

A. Checksum

A checksum divides data into fixed-size words, adds them, and transmits the complement of the resulting sum.

  • Sender operation:
    1. Split the message into n-bit words.
    2. Add them using one’s-complement arithmetic.
    3. Wrap any carry beyond n bits around to the least significant bit.
    4. Complement the final sum to form the checksum.
  • Receiver operation: Add all received words and the checksum using the same arithmetic; an all-1 result indicates acceptance.
  • Internet checksum: Internet protocols traditionally use 16-bit words and a 16-bit one’s-complement checksum.
  • Strength: Checksums detect many common bit errors and are efficient in software.
  • Limitation: Some compensating changes can preserve the sum, making checksums weaker against structured corruption than a well-designed CRC.
  • Comparison: Parity provides minimal protection, checksums suit word-oriented software processing, and CRC provides stronger detection for frames and burst errors.