Layer 2 Switch is used in IT technology, ICT, OT, and wireless. How it works. Without a Switch, a LAN network is not possible. This is a device that is used at everywhere like Home, Office, DC, etc. It’s used for connecting multiple LAN devices within a single domain, broadcast domain, or network to access common services or devices like printers, server internet, or intranet.
Before Switch Exits
When I start my journey in IT Industry, usually we had HUB in our offices to connect 4-5 PC and Printer. It was available everywhere easily. We also had Switches and Router as well but very small devices to just connect Internet links etc.
Later on Switches took place of HUB and now it was easy for us to manage and troubleshoot the issues which was not possible in HUB.
We all know Switch also called “Intelligent HUB”, I know its very old. Now we have Smart Switches with Smart Ports.
There are two type of Switches: Layer-2 and Layer-3 and MLS (Multiple layer Switches). But here we only discuss about Layer 2 Switch.
Initially there were 8-Port, 16-Port, 24-Port and 48-Port switch with 10/100 mbps and having 2 or 4 Fiber port with 1Gbps as uplink port.
Now, network Switches have all 48 ports with 1G and having 10G as uplink port. Earlier we need to set the port Mode, speed etc, but now Switches are having smart port, it automatically detects and start communication.
But, with all of these technology upgradations, Do switch behavior, Ways of Working Changed? I don’t think so. As per my understanding Basics can not be changes. Ground rule remain same.
So, let’s discuss that how Layer 2 Switch works. I will try to make it simple to understand.
Here we will discuss below points:
- Why its called Layer 2 Switch?
- Its basic Functions
- How to create tables
Why its called Layer 2 Switch?
Switch works on Layer-2 (Data Link Layer) in OSI Layer and using devices’ MAC addresses to decide where to forward frames, that’s why its called Layer-2 devices.
A Layer 2 switch performs essentially the same function as a transparent bridge; however, a switch can have many ports and can perform hardware-based bridging. Frames are forwarded using specialized hardware, called application-specific integrated circuits (ASIC). This hardware gives switching great scalability, with wire-speed performance, low latency, low cost, and high port density
Switch basic Functions
There are three distinct functions of layer 2 switching (you need to remember these!):
- Address Learning,
- Forward/filter decisions,
- Loop Avoidance.
Let’s understand this with an real-life examples and then will try to correlate it.
Suppose, in a class there are 24 student with one New teacher. All students are have their seat numbers and name. But teacher is not aware that which seat numbers assigned to which name(Student) as he/she interact with them first time.
Now, teacher have notebook of all 24 student and teacher needs to distribute them to all. So, what teacher will do? Teacher took one notebook and broadcast one name” A”. Now Student “A” stand-up and asked yes I am “A” and teacher handover the notebook to Student “A”. Same did for other students.
Also, he/she prepares a table that which student seated on which seat number. Now when He/she again have something for any student, then this time He/she didn’t broadcast the name, He/she just go to that student’s seat number and handover the things to that student.
How Layer-2 Switch Works
Let’s correlate with Switch functions:
Teacher–à Switch
24 Student–à Switch ports
Student seat numbers—-Ports Numbers
Student Names—à Connected Devices Mac address on that Switch port
Now, New Switch doesn’t have any information that Mac address is mapped/connected to with port. So if Switch received any frame, then switch have source Mac, Destination Mac but doesn’t have information that where that particular MAC connected.
So, Switch first time do Broadcast (Same as teacher did) and send the frame to all ports except the port from frame received and will get response from correct ports and frame will deliver. Same will do for all other Ports.
Now Switch will create a MAC address ( Same as teacher did) and note down all Mac address with connected Ports and Vlan details, so next time switch will not broadcast only Unicast.
- Making learning address and creating MAC table is called Address Learning,
- Forward/filter decisions: Forward unicast frame based on MAC address table.
- If multiple connections between switches are created for redundancy purposes, network loops can occur. Spanning Tree Protocol (STP) is used to stop network loops called Loop
Data Flow in Switch
When a frame arrives at a switch port, it is placed into one of the port’s ingress queues. The queues each can contain frames to be forwarded, with each queue having a different priority or service level. The switch port then can be fine-tuned so that important frames get processed and forwarded before less important frames. This can prevent time-critical data from being “lost in the shuffle” during a flurry of incoming traffic.
As the ingress queues are serviced and a frame is pulled off, the switch must figure out not only where to forward the frame, but also whether it should be forwarded and how. Three fundamental decisions must be made: one concerned with finding the egress switch port, and two concerned with forwarding policies. All these decisions are made simultaneously by independent portions of switching hardware and can be described as follows:
Switch Table
¡ L2 forwarding table—The frame’s destination MAC address is used as an index, or key, into the Content Addressable Memory (CAM), or address, table. If the address is found, the egress switch port and the appropriate VLAN ID are read from the table. (If the address is not found, the frame is marked for flooding so that it is forwarded out every switch port in the VLAN.)
¡ Security ACLs—Access control lists (ACL) can be used to identify frames according to their MAC addresses, protocol types (for non-IP frames), IP addresses, protocols, and Layer 4 port numbers. The Ternary Content Addressable Memory (TCAM) contains ACLs in a compiled form so that a decision can be made on whether to forward a frame in a single table lookup.
¡ QoS ACLs—Other ACLs can classify incoming frames according to quality of service (QoS) parameters, to police or control the rate of traffic flows, and to mark QoS parameters in outbound frames. The TCAM also is used to make these decisions in a single table lookup.
Summary:
Devices that forward frames at Layer 2 involve the following functions:
¡ MAC addresses are learned from the incoming frames’ source addresses.
¡ A table of MAC addresses and their associated bridge and switch ports is built and Maintained.
¡ Broadcast and multicast frames are flooded out to all ports (except the one that received the Frame).
¡ Frames destined for unknown locations are flooded out to all ports (except the one that received the frame).
¡ Bridges and switches communicate with each other using the Spanning Tree Protocol to eliminate bridging loops.
Visit to our site : https://www.kbrosistechnologies.com/
Watch more Video https://www.youtube.com/channel/UCpcd6IshE1caAbf9EdJd3gw