Layer 2 Unlocked: How the Data Link Layer Powers Your Network

The Data Link layer is most critical layer in the OSI model. Everything above this layer depends on device to device link communication which this layer provides. Whenever you are sending or receiving the data from the internet, data link layer is supporting that transfer. This layer provides a significant amount of functionality.


Datalink layer runs over layer 1. It needs a functional layer 1, which is common through out the OSI model. Layer 2 works on top of different types of Layer 1 infrastructure like copper, cable or wifi network. There are different layer 2 protocols for different situations. Let’s concentrate on Ethernet which is most common network type seen in the office and home.

What is a Frame?

Layer 2 introduces the concepts of Frames. Frames are used to send information over a layer 2 network. Layer 2 also introduces a unique hardware address known as MAC address for every device on network. MAC address is a 48 bit hexadecimal address like 14-5A-FC-89-11-D9. MAC address is a hardware address owned by network interface on each device.

The mac address is made of two parts, OUI(Organizationally Unique Identifier) and NIC (Network interface controller).

A frame which is the thing Layer 2 uses for communication is a container of sorts. It has a few different components.

Components of Frame

The first part is PREAMBLE or Start Form Delimiter (SFD). The function of this is to let devices know that this is the start of the Frame.

Next part is the destination and source MAC address. The frame can be sent to specific device by using the device MAC address or it can be sent to all the devices using all F’s on the local network. This is know as broadcast.

ET or Ether type is the next component in the Frame which is used to determine which layer 3 protocol is used to putting the data inside the Frame. Common example would be IP or commonly known as Internet protocol.

Source and destination MAC address along with ET are know as MAC header.

After the header is PAYLOAD which is 46 - 1500 BYTES. It contains the data which the Frame is transferring. The ET contains the information about the destination along with protocol used.

The ET is received at destination and extracted. The ET determines which layer 3 protocol receives the message at destination.

At the end of the frame is FCS or Frame check sequence which is used to determine any error in the Frame. It’s a simple CRS check which allows the destination to check if any data corruption has occurred or not.

The layer 2 Frame are generated at the source side and used by layer 1 to transfer the information to destination on layer 1, and passed on the software at layer 2 at destination. Followed by transfer to layer 3 to interpret the data.

Data Collision

If the data is transmitted using just the layer 1, there are chance of data collision as the devices present on both sides of communication can send the data at same time.

But Layer 2 prevents this collision of data by detecting the carrier, if there is a carrier already in use, the device on other side will wait till the data is not transmitted completely.

CSMA/CD stands for Carrier Sense Multiple Access with Collision Detection, and it’s a protocol used in the Data Link Layer (Layer 2) of the OSI model for collision detection.

  • Carrier Sense (CS): A device listens to the network to check if any other device is transmitting data. If the channel is free, it proceeds to send data.

  • Multiple Access (MA): Multiple devices can access the network and share the same transmission medium.

  • Collision Detection (CD): While transmitting, devices monitor the network for collisions (when two devices transmit simultaneously). If a collision occurs, they stop transmitting and follow a backoff algorithm before retrying.

Layer 1 and Layer 2 Device

Hub is a layer 1 device and Switch is a layer 2 device.

A switch is like an intelligent traffic cop, directing data precisely where it needs to go, while a hub is like a megaphone, shouting data to everyone, whether they need it or not.

That’s why hubs are pretty much obsolete today, and switches dominate modern networks.

Layer 2 benefits

  • Identifiable devices - Layer 2 introduces hardware addressing (MAC addresses), so devices have unique identifiers for more precise communication.

  • Media access control - Device can share access to physical media avoiding cross talk collisions.

  • Collison detection -Layer 2 switches use MAC addresses to forward frames only to the intended device, reducing collisions

  • Unicast communication

  • Broadcast communication

Summary:

  • Layer 2 of the OSI model, the Data Link Layer, offers significant improvements over Layer 1.

  • It offers the concept of Frames and uses MAC address for data transfer.

  • Organizes bits into frames, making data transmission more manageable.

0
Subscribe to my newsletter

Read articles from vikram chaudhary directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

vikram chaudhary
vikram chaudhary