Layer 2 vs Layer 3: Key Differences Explained

osi model
layer 2
layer 3
network layer
data link

This article compares Layer 2 and Layer 3 of the OSI (Open Systems Interconnection) model, highlighting their differences and functionalities. Layer 2 is known as the Data Link Layer, while Layer 3 is the Network Layer.

The OSI model was developed to define the modes of interconnection between different components in a networking environment. The beauty of the OSI stack is that the physical method of data transport can be designed and developed independently of the protocols and applications running above it.

OSI layers including Layer 2 and Layer 3

Figure 1: OSI Layers

As shown in Figure 1, there are seven layers in the OSI stack. Here’s a quick rundown:

  • Application Layer (Layer 7): Defines message formats and human-machine interfaces.
  • Presentation Layer (Layer 6): Handles coding into 1s and 0s, encryption, and compression.
  • Session Layer (Layer 5): Manages authentication, permissions, and session restoration.
  • Transport Layer (Layer 4): Provides end-to-end error control and reliable data transfer. In the TCP/IP model, it also handles multiplexing and demultiplexing of applications. Notably, Layers 5 and 6 don’t exist in the TCP/IP model.
  • Network Layer (Layer 3): Deals with network addressing, switching, and routing.
  • Data Link Layer (Layer 2): Focuses on error detection and flow control.
  • Physical Layer (Layer 1): Concerns itself with the bit stream, physical medium, and the method of representing bits.

For a deeper dive, you can refer to an article on the basics of OSI and TCPIP layers. Each layer has its own specific functionalities and supports the layer above it. For instance, Layer 1 supports Layer 2, Layer 2 supports Layer 3, and so on. Each layer adds a header to the data it receives from the layer above, except for Layer 2, which adds both a header and a trailer.

Layer 3: Network Layer

Here’s a breakdown of the Network Layer’s key functions:

  • IP Header Addition: It adds an IP header to the data received from the Transport Layer. This header contains crucial information such as the source IP address, destination IP address, and hop count. IP addresses are used for routing the IP packet until it reaches its intended destination.
  • Protocol Identification: The IP header also specifies which Transport Layer protocol (TCP or UDP) is being used, based on the 1-byte Protocol field.
  • Data Integrity: A checksum within the IP header is used for data integrity verification.
  • Examples: IP, IPX
  • Layer 3 Device Behavior: Layer 3 devices, like routers and Layer 3 switches, operate independently of the packet’s content (e.g., FTP, HTTP, SMTP). They simply handle the packet’s origin and destination, forwarding it accordingly.

Let’s explore the functions of the Data Link Layer:

  • Ethernet Header/Trailer Addition: It adds an Ethernet header (containing source MAC address, destination MAC address, and type fields) and a trailer (CRC of 4 bytes) to the Layer 3 packet.
  • Content Agnostic: The Data Link Layer is indifferent to the packet’s content (IP, IPX, Appletalk). It uses MAC addresses for frame delivery and CRC for error checking.
  • Type Field: The type field distinguishes between IP packets (0x800) and ARP packets (0x806).
  • Examples: Token Ring, Ethernet, Frame Relay

Layer 2 vs Layer 3: Feature Comparison

FeaturesOSI Layer 2OSI Layer 3
Major FunctionError Detection, Flow control on physical linkNetwork addressing, routing or switching
DoD modelNetwork AccesInternet
ProtocolsARP, RARPIP, ICMP, IGMP
Devices/Apps.Bridge, Layer 2 SwitchRouter, Firewall, Layer 3 Switch
Unit of DataFramePacket
HeaderEthernet HeaderIP Header
LAN switchingLayer 2 switch does switching and filtering based on MAC address.Layer 3 switch uses IP address.
Understanding the 3G UMTS Protocol Stack

Understanding the 3G UMTS Protocol Stack

Explore the 3G UMTS protocol stack, covering layers like Physical, Data Link (MAC, RLC, PDCP), and Network (RRC, NAS). Learn about functions, components, and how they ensure reliable communication.

3g
umts
protocol stack

Comprehensive Networking Training Course Overview

Explore our detailed networking training course, covering basics to advanced concepts like IP addresses, OSI model, Gigabit Ethernet, and key protocols. Ideal for beginners and experienced professionals.

networking
ethernet
protocols