Data Link Layer Fundamentals: MAC, LLC, and Ethernet
Classified in Computers
Written on in English with a size of 8.44 KB
Data Link Layer Fundamentals
1. MAC vs. LLC Sublayers: Motivation
The Data Link Layer (Layer 2) is crucial for connecting to upper layers and managing device communication within a local network. It employs specific addressing schemes to identify devices and uses frames to group bits for transmission. This layer is divided into two sublayers:
- Logical Link Control (LLC):
- Establishes the connection with upper layers, integrating with network layer protocols.
- Identifies the network layer protocol (e.g., IPv4, IPv6) for the encapsulated packet.
- Remains independent of the physical equipment, providing a consistent interface to the network layer.
- Media Access Control (MAC):
- Responsible for bringing data onto and off the physical media.
- Handles data encapsulation, which includes:
- Frame delimitation (marking the beginning and end of a frame).
- Physical addressing (MAC addresses for source and destination).
- Error detection (e.g., using Frame Check Sequence).
- Manages medium access control, which involves:
- Controlling the placement of data frames onto and off the network medium.
- Recovering from media access conflicts (e.g., collisions).
2. Ethernet Frame Fields and Padding
The standard Ethernet frame structure includes several key fields:
- Preamble (7 bytes): Synchronizes the receiving network interface card (NIC) with the incoming frame.
- Start of Frame Delimiter (SFD) (1 byte): Signals the beginning of the actual frame.
- Destination MAC Address (6 bytes): Identifies the recipient device.
- Source MAC Address (6 bytes): Identifies the sending device.
- Length/Type (2 bytes): Indicates either the length of the data field or the type of the encapsulated protocol.
- Data and Padding (46-1500 bytes): Contains the actual network layer packet (e.g., IP packet). If the data is less than 46 bytes, padding bytes are added to meet the minimum frame size requirement.
- Frame Check Sequence (FCS) (4 bytes): Used for error detection, ensuring data integrity during transmission.
Motivation for Padding Field: Ethernet frames have a minimum size requirement (64 bytes including header and FCS). If the data payload is smaller than 46 bytes, padding is added to ensure the frame meets this minimum length. This is crucial for proper collision detection in half-duplex Ethernet networks.
3. Unicast, Multicast, and Broadcast MAC Addresses
Ethernet at Layer 2 utilizes different types of MAC addresses for various communication patterns:
- Unicast:
- A unique MAC address used when sending a frame from a single source device to a single destination device.
- Frames addressed to a unicast MAC address are processed only by the device with that specific address.
- Broadcast:
- A special MAC address (
FF:FF:FF:FF:FF:FF
) used to send a frame to all devices within the same local network segment. - All devices on the segment will receive and process broadcast frames.
- A special MAC address (
- Multicast:
- Allows sending a frame to a specific group of devices.
- Multicast MAC addresses represent a group and can only be used as the destination address of a frame.
- Devices configured to be part of a specific multicast group will process frames sent to that group's address.
4. CSMA, CSMA/CD, CSMA/CA, Latency, Bit Time, and Interframe Gap
Computers using Ethernet on shared media employ distributed coordination schemes to manage access:
- Carrier Sense Multiple Access (CSMA):
- A fundamental protocol where devices "listen" for electrical activity (carrier sense) on the cable before transmitting.
- If the medium is busy, the device waits.
- CSMA/Collision Detection (CSMA/CD):
- An extension of CSMA used in wired Ethernet networks.
- Devices continue to listen while transmitting to detect collisions.
- If a collision is detected, transmission is aborted, and packets are retransmitted after a random back-off period.
- CSMA/Collision Avoidance (CSMA/CA):
- Used primarily in wireless networks (Wi-Fi) where collision detection is difficult.
- Devices attempt to avoid collisions by using techniques like Request to Send (RTS) / Clear to Send (CTS) or by waiting for a random back-off time before transmitting.
Key Timing Concepts:
- Latency:
- The amount of time it takes for an electrical signal to travel from one point to another.
- Each network device (e.g., hub, repeater) in the signal path adds latency as it processes and forwards bits.
- Bit Time:
- The period required for a single bit to be placed onto and detected in the network medium.
- It's the inverse of the bit rate.
- Interframe Gap (IFG):
- A mandatory idle period (96 bit times for Ethernet) that must exist between consecutive Ethernet frames.
- This space allows network devices to process the previous frame and prepare for the next, preventing collisions and ensuring proper frame separation.
5. Advantages of Switches Over Hubs
Network devices like hubs and switches play different roles in network connectivity, with switches offering significant advantages:
- Hubs (Disadvantages):
- Operate as multi-port repeaters, forwarding all incoming traffic to all other ports.
- Increase network collisions because all devices share the same collision domain.
- Introduce higher latency due to collision handling and retransmissions.
- Offer poor scalability; as more devices are added, the shared bandwidth decreases, leading to performance degradation.
- Switches (Advantages):
- Provide dedicated bandwidth to each port, effectively creating separate collision domains for each connected device.
- Offer a collision-free environment, significantly improving network performance.
- Support full-duplex operation, meaning devices can send and receive data simultaneously on the same port.
- Improve network scalability and efficiency by intelligently forwarding frames only to the intended destination port based on MAC addresses.
6. Switch Operation: Learning, Flooding, and Forwarding
Network switches operate intelligently by building and maintaining a MAC address table to efficiently forward frames:
- Learning:
- When a switch receives a frame, it examines the source MAC address and the port on which the frame arrived.
- It then adds or updates this MAC address-to-port mapping in its MAC address table (also known as a CAM table).
- This dynamic process allows the switch to learn the location of devices on its network.
- Updating (Aging):
- MAC addresses acquired through the learning process have a timestamp.
- If a MAC address entry is not used for a certain period (its aging time expires), it is removed from the table. This ensures the table remains current and accurate.
- Flooding:
- If a switch receives a frame with a destination MAC address that is not found in its MAC address table, it "floods" the frame.
- This means the frame is sent out of all ports except the port from which it was received.
- This ensures the frame reaches its destination if the destination is unknown or if it's a broadcast/multicast frame (unless specific multicast handling is configured).
- Selective Forwarding (Known Unicast Forwarding):
- When the switch receives a frame and its destination MAC address is found in the MAC address table, the switch forwards the frame only out of the specific port associated with that destination MAC address.
- This intelligent forwarding prevents unnecessary traffic on other ports, optimizing network performance and security.