Traffic Class Sample Application


The TC sample application for Zephyr sets up two virtual LAN networks and starts to send prioritized UDP packets from one VLAN network to the other. The use of VLAN network is optional but as VLAN defines priorities to network traffic, it is convenient to use that concept here. The application also enables net-shell and allows user to view VLAN settings.

The source code for this sample application can be found at: samples/net/traffic_class.


Building and Running

A good way to run this TC application is with QEMU as described in Networking with QEMU. Currently only one VLAN network (tag) is supported when Zephyr is run inside QEMU. If you’re using a FRDM-K64F board, then multiple VLAN networks can be configured. Note that VLAN is only supported for boards that have ethernet port.

Follow these steps to build the TC sample application:

# On Linux/macOS
cd $ZEPHYR_BASE/samples/net/traffic_class
mkdir build && cd build
# On Windows
cd %ZEPHYR_BASE%\samples\net\traffic_class
mkdir build & cd build
cmake -GNinja -DBOARD=<board to use> -DCONF_FILE=prj.conf ..

The default configuration file prj.conf creates two virtual LAN networks with these settings:

  • VLAN tag 100: IPv4 and IPv6 2001:db8:100::1
  • VLAN tag 200: IPv4 and IPv6 2001:db8:200::1

Setting up Linux Host

The samples/net/vlan/ provides a script that can be executed on the Linux host. It creates two VLANs on the Linux host and creates routes to Zephyr.

If everything is configured correctly, you will be able to successfully execute the following commands on the Linux host.

ping -c 1 2001:db8:100::1
ping -c 1
ping -c 1 2001:db8:200::1
ping -c 1

Running echo-server in Linux Host

There is one useful testing scenario that can be used with Linux host. Here traffic-class application is run in QEMU and echo-server is run in Linux host.

In a terminal window:

$ sudo ./echo-server -i tap0

Then you can run traffic-class application in QEMU as described above.