What is layer 2 networking- Data Link Layer

July 21, 2023

Layer 2 networking, also known as the Data Link layer, is the second layer in the OSI (Open Systems Interconnection) model and the TCP/IP protocol suite. It is a crucial component of computer networking that primarily deals with establishing and maintaining reliable communication between adjacent network devices within the same local network.

 

Data Link Layer Overview:

The Data Link layer is an essential component of the OSI model, enabling reliable communication between adjacent network devices within the same local network. It serves as a bridge connecting the physical layer (Layer 1) and the network layer (Layer 3) above it.

 

Sub-Layers: LLC and MAC: 

Within the Data Link layer, two distinct sub-layers exist. The Logical Link Control (LLC) sub-layer handles flow control, error checking, and synchronization, ensuring data integrity during transmission. On the other hand, the Media Access Control (MAC) sub-layer is responsible for managing access to the physical transmission medium and handling frame delivery between devices.

 

MAC Address:

A MAC address, or Media Access Control address, is a unique identifier assigned to each network interface card (NIC). Comprising 48 bits (12 hexadecimal digits), the MAC address is expressed as six pairs of characters. The first six characters represent the Organizationally Unique Identifier (OUI), identifying the NIC's manufacturer. The remaining characters, assigned by the vendor, uniquely identify every NIC they produce.

 

MAC Addresses Representation Formats:

MAC addresses are commonly represented in three different formats. Vendors like Cisco often use the period-separated hexadecimal format, such as "0a34.2f34.56a2." Linux and UNIX systems, on the other hand, prefer the colon-hexadecimal format, as seen in "90:fd:61:ed:28:84." Meanwhile, Windows operating systems typically adopt the hyphen-hexadecimal format, like "C0-3e-ba-50-e3-of." Each of these representations serves the same purpose of uniquely identifying network interface cards (NICs) and facilitating communication within networks.

 

Data encapsulation:

Data encapsulation is a crucial process that takes place in the data link layer, where data is packaged into a frame using both a header and a trailer. This frame forms the unit of data transmission within the local network.

 

Data Encapsulation Process:

  1. The user's message passes through the application layer, presentation layer, and session layer, preparing the data for transmission.
  2. At the transport layer, the data is divided into smaller units known as Protocol Data Units (PDUs). In this layer, the PDU is referred to as a "Segment." The transport layer also adds a header to the segment, which includes important information such as the port numbers for the source and destination, depending on the protocol being used (TCP or UDP).
  3. Moving on to the network layer, the segment is now known as a "Packet." The network layer adds another header to the packet, containing the source and destination IP addresses. This information is essential for routing the packet through the network.
  4. Next, the packet enters the data link layer, where it receives the final piece of encapsulation. The data link layer adds the MAC address to the packet, transforming it into a "Frame." The frame now includes the MAC addresses of both the source and destination devices.
  5. Finally, the frame is ready to be transmitted and is injected into the communication media, such as Ethernet cables or wireless signals, for delivery to the intended recipient.

Throughout this process, the MAC address remains stored in the header of the frame, and encapsulation occurs sequentially as the data moves down the layers from the application layer to the data link layer.

 

ARP (Address Resolution Protocol):

ARP is the protocol that is responsible for finding the MAC addresses of computers. When a computer wants to send data to another device within the same network, its operating system already knows the source IP address and source MAC address. However, determining the destination MAC address is essential for successful communication. While the destination IP address can be resolved using the DNS (Domain Name System) protocol, ARP comes into play to find the corresponding destination MAC address.

 

Switches in Layer 2 Networking:

A switch operates as a Layer 2 device, enabling devices within the LAN to communicate directly with each other. By storing MAC addresses and their corresponding ports in a table known as Content Addressable Memory (CAM), switches create a map of the network. This map ensures that data packets are forwarded to the appropriate destination without causing collisions, optimizing network performance.

 

ARP Traffic and MAC Addresses in LAN Networks:

ARP traffic consists of various types of messages containing different MAC addresses, and every operating system in a LAN maintains an ARP table, which is a mapping of IP addresses and their corresponding MAC addresses.

When a sender wishes to communicate with a destination IP address within the LAN, it first checks the ARP table to find the associated MAC address. If the mapping is not present, the operating system initiates an ARP broadcast message, asking the entire network for the owner of that IP address.

 

Broadcasting ARP Requests:

The ARP broadcast message is sent in a broadcast frame, which means it is received by all hosts within the LAN. The broadcast contains the IP address for which the MAC address is needed. The host that matches the requested IP address responds with a unicast reply, sending its MAC address directly to the sender. This allows the sender to update its ARP table with the correct IP-to-MAC mapping for future communications.

 

Different Types of MAC Addresses: 

In LAN networks, two main types of MAC addresses are used:

Unicast MAC Address: This is a unique address used when a frame is sent from a single transmitting device to a specific destination device.

Broadcast MAC Address: Displayed as hexadecimal FF-FF-FF-FF-FF-FF, this address is used in ARP broadcast messages. All hosts on the network receive the broadcast ARP request, and only the intended target responds with a unicast reply. Other hosts silently discard the packet.

 

Conclusion:

Layer 2 networking is the foundation for seamless and fast communication within local networks. By grasping the fundamentals of the Data Link layer, MAC addresses, switches, and ARP, network administrators and IT professionals can build robust and optimized LAN environments that support efficient data transfer and reliable connectivity for all connected devices.

Stay Tuned

The best articles, links, and news delivered once a week to your inbox.

DMCA.com Protection Status