How to setup and generate HSR/PRP traffic on Linux

Ostinato Team bio photo By Ostinato Team

Linux includes support for both HSR (High-availability Seamless Redundancy) and PRP (Parallel Redundancy Protocol) industrial-ethernet protocols.

HSR/PRP have their own interface type on Linux.

Since Ostinato can generate traffic on any OS supported network interface, we can use it to generate HSR/PRP traffic on Linux.

🙋‍♂️ Not using Linux?
You can still generate HSR/PRP traffic using Ostinato custom protocol user-script.

In this blog post, we first show you how to configure HSR/PRP interface on Linux.

📌 Please note you will need to be root or use sudo to run all these commands.

HSR/PRP kernel module

HSR/PRP support in Linux is provided by the hsr.ko kernel module. To start with check if the kernel module is already loaded -

lsmod | grep hsr

If the above command returns an empty output, it means the module is not loaded and you need to load the module manually -

modprobe hsr

Repeat the lsmod command above to verify that the module has been loaded successfully.

The hsr module does not have any module parameters as of date.

HSR Interface

Use the ip utility to create the HSR interface -

ip link add dev hsr0 type hsr slave1 enp0s8 slave2 enp0s9 version 1 proto 0
ip link set hsr0 up

The slave1 and slave2 parameters specify the DANH interfaces.

The version parameter specifies the HSR version to use. The current version is 1.

The proto parameter specifies whether to use HSR or PRP. 0 is for HSR (also the default value, so you can omit it).

You need to explicitly enable the HSR interface.

Use ip link show to verify that the HSR interface has been created successfully and is up-

$ ip link show
. . .
7: hsr0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1494 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:eb:72:4d brd ff:ff:ff:ff:ff:ff

Post creation, you can query the properties of the HSR interface using the -d option of the ip show utility -

$ ip -d link show hsr0
7: hsr0: <BROADCAST,MULTICAST,PROMISC,UP,LOWER_UP> mtu 1494 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:eb:72:4d brd ff:ff:ff:ff:ff:ff promiscuity 1 minmtu 0 maxmtu 1500
    hsr slave1 enp0s8 slave2 enp0s9 sequence 65377 supervision 01:15:4e:00:01:00 proto 0 addrgenmode eui64 numtxqueues 1 numrxqueues 1 gso_max_size 65536 gso_max_segs 65535

PRP Interface

The comamnd to create a PRP interface is exactly same as the HSR interface - you just need to specify the proto parameter as 1 instead of 0.

ip link add dev prp0 type hsr slave1 enp0s8 slave2 enp0s9 version 1 proto 1
ip link set prp0 up

HSR/PRP Test topology

HSR DANH nodes are connected in a ring topology while PRP DANH nodes are connected to two different network segments. See PRP and HSR overview for more details.

HSR/PRP traffic with Ostinato

Once created, the HSR/PRP interface will be listed in Ostinato. You can use it as any other ethernet interface. Any packets sent on the HSR/PRP interface will automatically have the HSR header (or PRP trailer) added to it by Linux when going out of the physical interface.

If you don’t see the hsr0/prp0 interface in Ostinato, please restart the Ostinato Drone agent (The Drone agent reads the list of interfaces only once when it starts, so any subsequently created interfaces require Drone to be restarted).

Also, note that only admin-enabled interfaces are visible and accessible to Ostinato.

Just select the hsr0/prp0 interface and create a standard ethernet stream without the HSR header or PRP trailer. When you transmit the stream, the HSR/PRP header will be added by Linux. You can verify this by capturing the traffic on the slave1 and slave2 interfaces and viewing it in Wireshark.

Here are some Wireshark screenshots showing HSR and PRP traffic generated using Ostinato.

HSR traffic on Linux


PRP traffic on Linux

Ostinato Port stats for HSR/PRP interfaces

Ostinato HSR/PRP port stats

Packets transmitted on the HSR/PRP interface will be sent on both slave interfaces, so

  • When sending traffic on the HSR/PRP interface, the TX stats will increment on the HSR/PRP interface and both slave interfaces
  • RX traffic will also typically be received on both slave interfaces (unless there’s a fault in the network)
  • Supervision frames are sent every 2s, so the TX stats will include these frames as well on the HSR/PRP interface and the slave interfaces
  • To view only the data traffic and not the supervision frames, you can capture the traffic and filter out the supervision frames in Wireshark
    • For HSR: hsr.type != 0x88fb
    • For PRP: prp && eth.type != 0x88fb