Quiz 2

Data Link & Physical Layers — Ethernet, MAC, Error Detection

771 words
4 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# Data Link & Physical Layers — Ethernet, MAC, Error Detection ## 🎯 Learning Objectives - Explain CSMA/CD and how Ethernet handles collisions - Calculate CRC checksums - Understand MAC addressing and frame structure - Describe physical layer encoding and modulation * * * ## 1. Data Link Layer ### 1.1 Functions Func...

Data Link & Physical Layers — Ethernet, MAC, Error Detection

🎯 Learning Objectives

  • Explain CSMA/CD and how Ethernet handles collisions
  • Calculate CRC checksums
  • Understand MAC addressing and frame structure
  • Describe physical layer encoding and modulation

1.1 Functions

FunctionDescription
FramingEncapsulate network layer packets into frames
Error detectionCRC, checksum to detect transmission errors
Flow controlPrevent fast sender from overwhelming slow receiver
Medium accessControl who transmits on shared medium (CSMA/CD, CSMA/CA)

1.2 Ethernet Frame

pseudo
  Bytes: 7      1       6        6       2      46-1500     4
        ┌──────┬──────┬────────┬──────┬──────┬──────────┬──────┐
        │Preamble│SFD  │  Dest  │ Src  │ Type │  Payload  │  FCS │
        │       │     │  MAC   │ MAC  │      │  (IP pkt) │ (CRC)│
        └──────┴──────┴────────┴──────┴──────┴──────────┴──────┘
FieldSizeDescription
Preamble7 bytesSynchronization pattern (101010...10)
SFD1 byteStart Frame Delimiter (10101011)
Destination MAC6 bytesReceiver's MAC address
Source MAC6 bytesSender's MAC address
Type/Length2 bytesProtocol type (0x0800 = IPv4)
Payload46-1500 bytesIP packet (with padding)
FCS4 bytesCRC-32 checksum

2. MAC Addressing

2.1 MAC Address Format

A MAC address is 48 bits, usually written as 6 hex octets: AA:BB:CC:DD:EE:FF
BitsMeaning
Bit 0 (I/G)0 = unicast, 1 = multicast/broadcast
Bit 1 (G/L)0 = globally unique (OUI), 1 = locally administered
Bits 2-23OUI (Organizationally Unique Identifier)
Bits 24-47NIC-specific (assigned by manufacturer)

2.2 Special MAC Addresses

AddressTypePurpose
FF:FF:FF:FF:FF:FFBroadcastSend to all devices on LAN
01:80:C2:00:00:00MulticastSpanning Tree Protocol
33:33:00:00:00:01MulticastIPv6 neighbor discovery

3. CSMA/CD (Carrier Sense Multiple Access with Collision Detection)

3.1 Algorithm

(Diagram)

3.2 Exponential Backoff

After collision nn, wait k \times \text{slot_time} where kk is randomly chosen from [0,2n1][0, 2^n - 1]. Example:
Collision #Range of kPossible Wait (slot_times)
1[0,1]0 or 1
2[0,3]0, 1, 2, or 3
3[0,7]0-7
16AbortFrame transmission failed

4. Error Detection: CRC

4.1 Intuition

CRC treats data as a binary polynomial, divides by a generator polynomial, and appends the remainder. The receiver performs the same division — non-zero remainder means error.

4.2 CRC Calculation Example

Data: 101101 (binary) Generator (divisor): 1101 (x³ + x² + 1) Step 1: Append (generator_bits - 1) = 3 zeros: 101101000 Step 2: Binary division (XOR, no carry):
pseudo
        110101 (quotient)
1101 ) 101101000
       1101
       ----
        1100
        1101
        ----
         0110
         0000
         ----
          1100
          1101
          ----
           0100
           0000
           ----
            1000
            1101
            ----
             101 (remainder = CRC)
Step 3: Transmit data + CRC: 101101101 Receiver: Divides 101101101 by 1101. Remainder = 0 → no error detected.

4.3 CRC Properties

CRC TypePolynomialDetects
CRC-1 (parity)x + 1Odd number of bit flips
CRC-8x⁸ + x² + x + 1All ≤8-bit bursts, 99.6% of longer
CRC-16-IBMx¹⁶ + x¹⁵ + x² + 1All ≤16-bit bursts, 99.997%
CRC-32 (Ethernet)x³² + x²⁶ + x²³ + ...All ≤32-bit bursts, >99.9999%

5. Physical Layer

5.1 Signal Encoding

SchemeBits per BaudExample
NRZ10=V, 1=+V
NRZI10=no change, 1=toggle
Manchester10=low→high, 1=high→low
4B/5B + MLT-34 bits in 5 bauds100BASE-TX (Fast Ethernet)

5.2 Common Ethernet Standards

StandardSpeedCableMax Distance
10BASE-T10 MbpsCat 3100m
100BASE-TX100 MbpsCat 5100m
1000BASE-T1 GbpsCat 5e100m
10GBASE-T10 GbpsCat 6a100m
40GBASE-SR440 GbpsMMF (fiber)150m

6. 📝 Practice Questions

Q1: Calculate CRC for data 110101 with generator 1001.
Answer: Data: 110101000. Divide by 1001. Remainder = 011. Transmitted: 110101011.
Verification: Receiver divides 110101011 by 1001 → remainder 0. Q2: What happens when two Ethernet frames collide?
Answer: Both senders detect the collision (voltage spike), transmit a 32-bit jam signal, and each waits a random time (exponential backoff: wait 0 or 1 slot times for first collision, 0-3 for second, etc.). After 16 failed attempts, the frame is discarded. Q3: How does a switch learn which MAC address is on which port?
Answer: The switch maintains a MAC address table. When it receives a frame, it records the source MAC and incoming port. Initially empty, it learns addresses as traffic flows. Unicast frames to unknown destinations are flooded to all ports except the source. Q4: What is the minimum Ethernet frame size and why?
Answer: Minimum payload is 46 bytes (total frame = 64 bytes including header). This ensures that collisions are detected before transmission completes — the transmission time must exceed twice the propagation delay (slot time). Q5: Compare a hub, switch, and router.
Answer: Hub (Layer 1): repeats signals to all ports, collision domain = all ports. Switch (Layer 2): forwards frames based on MAC address, each port is its own collision domain. Router (Layer 3): forwards packets based on IP address, connects different networks, broadcasts are not forwarded.

6. 🔗 Cross-References

Document outline

Keep your place and jump directly to a heading.

Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.