The term Layer 2 is adopted from the Open System Interconnect (OSI) model, which is a reference model for explaining and describing network communications. It is the process of using devices and MAC addresses on a LAN to segment a network. Switches and bridges are mostly used for Layer 2 switching. They help to break up large size collision domain into separate smaller ones.
Layer 2 CISCO switches are similar to bridges. They interconnect networks at layer 2, mostly at the MAC sub-layer, and operate as bridges. It builds tables for the transfer of frames among systems.
Layer 2 ethernet switches are faster compared to routers, as they do not take much time for evaluation at the network layer header information. Instead, they should look at the frame's hardware addresses, which helps you decide what action needs to take like forward, flood, or drop it.
A Layer 3 switch is a switch that performs routing functions in addition to switching. A client computer needs a default gateway for layer 3 connectivity to any remote subnets.
This type of layer helps you to combine the functionality of a switch and a router. It acts as a switch to connect devices that are on the same subnet or virtual LAN.
This type of CISCO network switches support routing protocols. It helps to inspect incoming packets and makes routing decisions based on the source and destination addresses. That is how layer 3 switch acts as both for switch and a router.
How Layer 2 Switching works?
Here is an example of a network where a switch is connected to four host devices known as D1, D2, D3, and D4.
D1 wants to send a data packet to D2 for the first time.
D1 knows the IP address of D2 as they are communicating for the first time. However, it does not know the MAC (hardware) address of the recipient host.
Thus D1 uses an ARP to discover the MAC address of D2.
The Layer switch sends the ARP request to all the ports that exclude the port on which D1 is connected.
D2, when receives the ARP request, replies to the ARP response message with its MAC address. D2 also gathers the MAC address of D1.
Here, with the help of the above-given messages, switch learns which MAC addresses are assigned to which ports.
Similarly, D2 also sends its MAC address in the ARP message,the switch now takes the MAC address of D2 and banks it into the MAC address table.
It also stores the MAC address of D1 in the address table as it was sent by D1 to switch with the ARP request message.
So, whenever D1 wants to send any data to D2, the switch will check the table and forward it to the other destination port of D2.
Similarly, the Layer Switch will keep on maintaining the hardware address of each connecting host.
Functions of layer 2 switching
Here are important functions of Layer 2 switching:
MAC addresses are known from all the incoming frames source addresses.
Bridges and switches communicate with each other using the STP to remove bridging loops.
Frames designed for unknown locations are overflowed out to all ports except the one that received the frame.
It performs the same function as a transparent bridge.
Frames are forwarded using specialized hardware, which is known as Application-Specific Integrated Circuits (ASIC).
Layer-2 switches also perform the switching function to re-arrange the data frames from the source to its destination network.
Layer-2 Switch splits a complicated LAN (local area network) into small VLAN networks.
Functions of layer 3 switching
Here are important functions of Layer 3 switching:
Define paths based on logical addressing
Run layer three checksums
Process and respond to any option information
Allows you to update simple Network Management
Information Base (MIB) information
Applications of Layer-2 Switches
Here are some important applications of Layer 2 switches.
You can send a data frame from the source to the destination that is situated in the same VLAN without being physically connected.
Servers of IT companies can be put centrally at one place. The clients located at some other locations can access the data link layer without latency, which saves the server cost and time.
Companies also used it for internal communications by configuring the hosts on the same VLAN by using Layer 2 switches without any internet connection.
Software professionals also use these switches for sharing their tools by keeping them centrally at one server location.
Difference between Layer 2 and Layer 3 Switches
Here are some important difference between Layer 2 and Layer 3 switching:
Layer 2 switching is used to reduce traffic on the local network.
It is mostly used to Implement VLAN.
In Layer 2, switching packets are rerouted from the source to the destination port.
In Layer 3 switching, switches use a little time to check data packets before finding the best available route to direct data packets to the destination port.
Layer 2 uses the Address Resolution Protocol (ARP) to discover other devices' MAC addresses.
Layer 3 devices utilize IP addresses for routing within Virtual LANs (VLANs).
Layer 2 switch comes with a little tendency of switching packets from one port to another.
Layer 3 switching helps devices to communicate outside the networks as well.
Layer 2 switch does simple switching by finding and maintain a table of MAC addresses.
Layer 3 switch is a specialized device that is designed for routing of data packets through IP addresses.
Layer 2 vs. Layer 3 Switch
Layer 2 Switch
Layer 3 Switch
Mac address only
Supports higher routing such as static routing and dynamic routing,
VLAN Tagging Based on IP Address
Pure Layer 2 domain
Aggregate multiple access switches
Advantage of Layer2 Switching
Here are the pros/benefits of Layer2 Switching switches:
Helps to forward packets based on unique MAC addresses
Does not offer any setup or management
It can be quickly deployed at a lower cost
L2 switches flow accounting capabilities
Low latency and improved security
Advantage of Layer3 Switching
Here are the pros/benefits of Layer3 Switching:
L3 support routing between virtual LANs.
Improve fault isolation.
Provide ease of security management.
Reduce broadcast traffic volumes.
Ease the configuration process for VLANs, as a separate router is not needed between each VLAN.
Separate routing tables, and as a result, segregate traffic better.
Offers flow accounting and high-speed scalability.
Lower network latency as a packet that does not make extra hops to go through a router.
Limitation of Layer2 Switching
Here are the cons/drawback of Layer2 switching:
The layer 2 switches must break up the collision domains correctly.
It does not break up broadcast domains by default.
L2 switches does not allow you to implement any intelligence while forwarding packets.
Does not helps you to perform switching or IP address-based routing.
Never given guarantee required bandwidth to VoIP users
Limitation of Layer3 Switching
Here are the cons/drawbacks of Layer2 switching:
The cost of the L3 switch is quite high compared to the Layer 2 switch.
Layer 3 switch does not offer WAN functionality.
Multiple tenants and virtualization.
Does not offer any functionality.
Layer2 is the process of using devices and MAC addresses on a LAN to segment a network.
A Layer 3 switch is a switch that performs routing functions in addition to switching.
Layer 2 switches perform the switching function to re-arrange the data frames from the source to its destination network.
Layer 3 switches define paths based on logical addressing.
Layer 2 switches are used to reduce traffic on the local network, whereas Layer 3 switches mostly used to Implement VLAN.
The advantage of Layer 2 switches is that it helps to forward packets based on unique MAC addresses
The advantage of Layer 3 switches offers flow accounting and high-speed scalability.
The main drawback of Layer 2 switches is that it does not allow you to implement any intelligence while forwarding packets.
The main drawback of the Layer 3 switch does not offer WAN functionality.