Testing Layer 2 Switch - A Comprehensive Guide using Ostinato

Ostinato Team bio photo By Ostinato Team

A layer 2 switch forwards frames between hosts using the Mac addresses in the Ethernet/802.3 header fields and procedures defined in the IEEE 802.1D standard.

These procedures include Mac learning, flooding, forwarding and aging.

In this guide, we will use Ostinato to test the basic functionality of a layer 2 switch.

Since layer 2 switches only look at the Mac addresses in the Ethernet header, the test streams that we will create will be 802.3 raw frames where the EtherType field contains the frame length instead of a type indicating the next layer protocol. You can create Ethernet/IP streams as well, but the IP addrsses in the packet are don’t care for the purpose of this test.

Topology

We will use the below simple topology to test the functionality of a layer 2 switch - the device under test (DUT).

L2 Switch Test Topology

Test Procedures

Mac learning

Let’s first create a test stream.

Create a new stream and select Mac | 802.3 Raw protocols

A 802.3 stream to test L2 Switch

Next, set the source and destination Mac addresses. Set the mode to Fixed and provide any values for the Mac addresses. (Make sure that LSB of the first octet is 0 so that it is a valid unicast Mac address.)

Test Mac addresses

Click on Apply.

Apply to activate test stream

Once the stream is created, to test learning -

  1. Clear the Mac Table in the L2 Switch
  2. Send the stream from Ostinato to the L2 Switch
  3. Verify that the stream is received on the other port
  4. Verify that the source Mac address of the stream is learnt and present in the Mac Table of the L2 Switch

Learning at scale

To scale this test, you can set the source Mac address mode to Increment or Decrement with the desired count value.

Generate traffic with different source mac addresses

Verify that ALL the Mac addresses are learnt and present in the Mac Table of the L2 Switch.

You can set the stream rate to different rates and verify the Mac address learning rate of the L2 Switch.

🔥 Remember to clear the Mac Table in the L2 Switch every time before running a learning test.

Flooding

When the L2 switch receives a frame with a destination Mac address that is not in its Mac Table, it floods the frame to all ports except the port from which the frame was received. This is also known as unknown unicast flooding.

A L2 switch will also flood broadcast and multicast frames - popularly called BUM (Broadcast, Unknown Unicast and Multicast) traffic. If IGMP/MLD snooping is enabled, the L2 switch will only forward the multicast frames to the ports that have joined the relevant group.

Back to flooding.

The test procedure is similar to the learning test above.

To test that the frames are being flooded, you will need to connect 3 or more ports from the switch to Ostinato. Then you can use the Ostinato Port Stats Window to verify that the frames are being flooded to the other ports, but NOT to the TX port.

L2 Mac flooding

Alternatively, if you don’t have enough Ostinato test ports, you can look at the L2 Switch interface statistics to verify that the frames are being flooded to all ports except the TX port.

🔥 Remember to clear the Mac Table in the L2 Switch every time before running a flooding test.

Flooding is typically an expensive operation for the L2 switch. You can test the flooding rate of the L2 switch by setting the stream rate to increasingly higher values and observing the rate at which the L2 switch can forward the frames. Some switches may have configurable limits for BUM traffic to prevent network storms.

See our network storm control guide for more details on this.

Unicast Forwarding

Once a mac address is learnt, the L2 switch will forward the frames with that Mac address to the corresponding port.

To verify this, create two Ostinato streams - one on each port with the source and destination Mac addresses swapped.

Mac addresses in Test Stream on first port

Src/Dst Mac addresses swapped on second port

To test forwarding

  1. Clear the Mac Table in the L2 Switch
  2. Send the stream from port1 to port2
  3. Verify that the stream’s source Mac address is learnt on port1
  4. Send the stream from port2 to port1
  5. Verify that this stream is not forwarded to any other ports (i.e. it is not being flooded)

You can send frames at different sizes and rates to verify the L2 switch’s unicast forwarding performance.

If you want to do a standard performance test, check out our Perf Bench add-on for Ostinato.

Broadcast and Multicast Forwarding

See Flooding above.

Mac Aging

Because the L2 switch dynamically learns the Mac addresses of the hosts, it needs to periodically remove the Mac addresses that are no longer being used actively for forwarding. This is achieved using a mac address aging procedure.

Note that as long as you are sending traffic for a particular destination Mac address, the Mac address will not be aged out of the Mac Table.

Aging time is typically around 5 mins by default, but can be configured to a different value. The actual time for a particular Mac address may not be exactly the same as the configured aging time because of the aging algorithm used by the L2 switch. See your switch’s documentation for more details.

You should verify both - Mac address with active traffic is not aged out and inactive Mac addresses are aged out after the aging time.

VLANs and QinQ

To test layer 2 VLANs and QinQ, you can use the same test streams as above, but with the addition of VLAN tags in the streams.

Test L2 stream with a VLAN

Test L2 stream with QinQ (dual tagged vlan)

Layer 2 overlays

Although this guide uses a simple layer 2 topology, the same test procedures are applicable to Layer 2 overlays such as VXLAN, NVGRE, GENEVE, L2VPN, EVPN, etc. and Ostinato can be used to test these as well using this guide.

The test topology is similar except that you have a L2 overlay network under test rather than a single L2 switch.

L2 overlay network test topology