Basic three operations of a L2 Switch
For doing the L2 forwarding operation, it basically does the following three things:
1. Address Learning : Building the Address Resolution Logic (ARL) table dynamically (without any configuration) based on the source MAC address of incoming frames.
2. L2 Forwarding : Forwarding incoming frames on to the correct output port by referring to the ARL table and the destination MAC address in the incoming frames.
3. Address Ageing : Timing out outdated/stale entries in the ARL table to facilitate end station movement detection.
These three techniques are explained below:
Address Learning
- Initially the ARL table is empty and the L2 Switch fills this table dynamically by watching frames passing through it.
- When a L2 Switch receives a frame on a port, it looks at the source MAC address field in the frame header. If this MAC address is not present in the ARL table, then it creates a new entry in the table
- Each entry in the ARL table consists of the fields. While the MAC address and port combination indicates that the end station with that specific MAC address is present on that particular port, the time stamp field indicates the time on which the frame was received by the L2 Switch.
- If the next frame comes from the same end station, then the L2 Switch just updates the time stamp field of the already created ARL table entry.
- This process is repeated for frames received from every end station and the ARL table is built by dynamic learning, without any static configuration.
L2 Forwarding
On receiving a frame via. an input port, after updating the ARL table, the next task of the L2 Switch is to forward the frame onto the correct output port on which the frame’s destination end node is present.
To find this out, the L2 Switch does a ARL table lookup to find a matching entry for the destination MAC address of the incoming frame. If a match is found, then the frame is forwarded only to that port, provided that the destination port is different than the one on which the frame arrived. If the destination port is the same port through which the frame was received, then the L2 Switch does not do anything, as it knows that the destination end node would have already received this frame.
- Initially Station A sends a frame to Station B (F1). Since this frame enters the L2 switch via. port 1 and has a source MAC address of 00:00:0A, the L2 switch creates the first entry in the ARL table, learning that the end station A with the MAC address 00:00:0A is present on port A.
- The frame F1 has a destination address of 00:00:0B (of station B). The L2 switch looks for this address in the ARL table. Since the ARL table has only one entry (that of A),the lookup fails. In this case, the frame F1 is sent out of both port 2 and port 3 (flooding).
- When station B receives this frame, it replies to A, by sending back a frame to station A (F2). This frame enters the L2 switch via. port 1 and so the L2 switch creates the second entry in its ARL table (that of station B). Since the frame’s destination is on port 1, the L2 switch detects that both stations A and B are on port 1 and so does not forward the frame F2 onto any other port.
- Similarly, the L2 switch learns the address of stations F and C by looking at the source MAC address fields of frames sent from F-C (F3) and C-F (F4) respectively.
- To facilitate dynamic detection of end station movement and also to remove stale entries (end nodes could have been removed from the network or down) from the ARL table, a time stamp field is maintained for each entry in the ARL table
- As soon as a L2 Switch receives a frame from an end node, as part of updating the ARL table for source learning, one of the task is to update the time stamp field of the entry belonging to the end node, with the current time.
- This way, by looking at the time stamp field of an ARL table entry, at any instant of time, one can find out how old an entry is.
- A background process periodically checks the time stamp field of each entry in the ARL table and removes entries that are old.
- The exact value of the time out varies with implementation and is usually configurable as a parameter.
- If an entry times out, then it has to be learnt again.