← Back to OSI Overview

🔗 OSI Layer 2: Data Link Layer

Layer 2 (Data Link) Technologies

The Data Link Layer is responsible for reliable node-to-node delivery of frames over a physical link. It provides MAC addressing, frame formatting, error detection, and media access control for direct neighbors.

The Critical Role: While the Physical Layer (1) moves raw bits, Layer 2 creates reliable frames between directly connected devices using MAC addresses and error checking.

💻

Node A

AA:BB:CC:DD:EE:01
Ready
🖥️

Node B

FF:EE:DD:CC:BB:02
Listening

Data Link Protocol Information

Select a protocol and click "Protocol Details" to learn more.

🎯 Primary Functions

  • Framing: Encapsulating network data into frames
  • Physical Addressing: MAC addresses for local delivery
  • Error Detection: Detecting transmission errors
  • Flow Control: Managing data flow between nodes
  • Access Control: Coordinating access to shared media

🔧 Key Characteristics

  • MAC Addresses: 48-bit hardware addresses (AA:BB:CC:DD:EE:FF)
  • Frame Check Sequence: Error detection using CRC
  • CSMA/CD: Collision detection in Ethernet
  • Switching: Learning MAC addresses for forwarding
  • VLANs: Virtual separation of network segments

🌐 Data Link Layer Protocols & Technologies

Ethernet (IEEE 802.3)

Wired LAN standard using CSMA/CD for media access control

Ethernet II: Dst: ff:ff:ff:ff:ff:ff Src: aa:bb:cc:dd:ee:01
Most common LAN technology - frames with MAC addresses
Wi-Fi (IEEE 802.11)

Wireless LAN using CSMA/CA for collision avoidance

802.11 Data: STA → AP → Router (3 address fields)
Wireless networking with association and authentication
PPP (Point-to-Point)

Serial link protocol for dial-up, DSL, and WAN connections

PPP: [Flag] [Address] [Control] [Protocol] [Data] [FCS]
Encapsulation with authentication and multi-protocol support
ARP (Address Resolution)

Maps IP addresses to MAC addresses for local delivery

ARP Request: Who has 192.168.1.1? Tell 192.168.1.100
Layer 2/3 bridge - essential for Ethernet/IP communication

🖼️ Ethernet Frame Structure

Understanding how data is encapsulated at Layer 2:

Ethernet II Frame Format
Preamble
7 bytes
SFD
1 byte
Dest MAC
6 bytes
Src MAC
6 bytes
Type/Length
2 bytes
Payload
46-1500 bytes
FCS
4 bytes

Field Descriptions:

  • Preamble & SFD: Synchronisation pattern (10101010...10101011)
  • Destination MAC: Hardware address of receiving device
  • Source MAC: Hardware address of sending device
  • Type/Length: Protocol type (0x0800 = IPv4) or frame length
  • Payload: Actual data from upper layer (minimum 46 bytes)
  • FCS: Frame Check Sequence for error detection (CRC-32)

🏷️ MAC Address Deep Dive

MAC Address Format

AA:BB:CC:DD:EE:FF
│└─ Device Specific (24 bits)
└── Vendor OUI (24 bits)

48-bit address: 24-bit Organizationally Unique Identifier + 24-bit device identifier

Special MAC Addresses

  • Broadcast: FF:FF:FF:FF:FF:FF
  • Multicast: 01:xx:xx:xx:xx:xx
  • Unicast: 00:xx:xx:xx:xx:xx
  • Local Admin: x2:xx:xx:xx:xx:xx

Common Vendor OUIs:

OUI Vendor Example MAC
00:1B:44 Cisco Systems 00:1B:44:AA:BB:CC
00:50:56 VMware 00:50:56:11:22:33
AC:BC:32 Apple AC:BC:32:44:55:66

🔍 Real-World Example: Ethernet Switching

Scenario: Three computers connected to an Ethernet switch

Step 1: MAC Learning

When PC-A (00:11:22:33:44:AA) sends a frame:

Switch learns: MAC 00:11:22:33:44:AA is on Port 1
MAC Table: 00:11:22:33:44:AA → Port 1

Step 2: Frame Forwarding

PC-A sends frame to PC-B (00:11:22:33:44:BB):

Ethernet: Dst=00:11:22:33:44:BB Src=00:11:22:33:44:AA
Switch: MAC 00:11:22:33:44:BB not in table → FLOOD to all ports

Step 3: Return Path Learning

PC-B responds, switch learns its location:

Switch learns: MAC 00:11:22:33:44:BB is on Port 2
MAC Table: 00:11:22:33:44:AA → Port 1, 00:11:22:33:44:BB → Port 2
Future frames between A↔B: direct port forwarding (no flooding)

🛠️ Troubleshooting Data Link Issues

🚨 Common Layer 2 Problems

  • Frame errors (CRC/FCS failures)
  • MAC address table overflow
  • Broadcast storms
  • VLAN misconfigurations
  • Spanning Tree Protocol loops
  • Duplex mismatches

🔧 Layer 2 Diagnostic Tools

  • Switch MAC address tables
  • Port statistics (errors, collisions)
  • Spanning Tree Protocol status
  • VLAN configuration verification
  • Protocol analyzers (Wireshark)
  • Network topology discovery

Common Wireshark Filters for Layer 2 Analysis:

eth.addr == aa:bb:cc:dd:ee:ff # Filter by MAC address
eth.dst == ff:ff:ff:ff:ff:ff # Show broadcast frames
arp # Show ARP traffic
eth.type == 0x8100 # Show VLAN tagged frames
eth.fcs_bad == 1 # Show frames with bad FCS

🎓 Teaching Analogy: Hotel Mail System

Think of the Data Link Layer like a hotel's internal mail system:

Just like hotel mail only works within the building, Layer 2 only works within the local network segment!

📚 Key Learning Points

← Return to OSI Overview