Skip to content

Instantly share code, notes, and snippets.

@changtimwu
Last active March 19, 2021 09:25
Show Gist options
  • Select an option

  • Save changtimwu/38e0960e760c27b20002 to your computer and use it in GitHub Desktop.

Select an option

Save changtimwu/38e0960e760c27b20002 to your computer and use it in GitHub Desktop.

Study the Protocol High-availability Seamless Redundancy Protocol (HSR)

HSR is a Layer 2 redundancy protocol for Ethernet. HSR adds a header to each frame, and duplicates the frame, sending it along two directions of a ring. Nodes in the ring pass the frame along the ring, using the header to discard duplicates.

Example traffic

Ethernet II, Src: ZurichUn_15:77:84 (00:15:12:15:77:84), Dst: IntelCor_5c:22:42 (00:1b:21:5c:22:42) ... High-availability Seamless Redundancy (IEC62439 Part 3 Chapter 5) 0001 .... .... .... = Path: 1 000. .... .... .... = Network id: 0 ...1 .... .... .... = Lane id: Lane B (1) LSDU size: 52 [correct] Sequence number: 6679 Type: ARP (0x0806) Address Resolution Protocol (reply) ... Wireshark

The HSR dissector is fully functional. Supervision frames have the same format as in the related Parallel Redundancy Protocol, so they share a common dissector. The HSR dissector only handles the actual HSR header.

Example capture file

SampleCaptures/HSR-simple-supervision-and-1vdan-appearing.pcap External links

HSR Wikipedia article. Discussion


quite a lot running processes

 2139 ?        Ss     0:00 /bin/sh -e /usr/sbin/lcd-manager --daemon
 2237 ?        Ss     0:00 /usr/sbin/fcmd -l /usr/lib/fcmd -f -d /etc/fcmd -r
 2243 ?        Ssl    0:00 /usr/sbin/interface_manager -f -m switching_module ip_module ether
 2251 ?        Ssl    0:00 /usr/sbin/xr7_monitor -f
 2258 ?        Rs    12:15 /usr/sbin/flx_redundancy_supervision -f
 2264 ?        Ss     0:00 /usr/sbin/xr7_fwud -f -p dpd.ctrl
 2270 ?        Ss     0:00 /usr/sbin/xr7ptp -f
 2280 ?        Ssl    0:00 /usr/sbin/host_clock_adj -f

fcm related programs

root@xr7:/etc/rc2.d# ldd /usr/bin/fcm_manager 
    libc.so.6 => /lib/arm-linux-gnueabi/libc.so.6 (0x76dbd000)
    /lib/ld-linux.so.3 (0x76ef9000)

root@xr7:/etc/rc2.d# ldd /usr/sbin/fcmd
    libfcmd.so.0 => /usr/lib/libfcmd.so.0 (0x76f26000)
    libxml2.so.2 => /usr/lib/arm-linux-gnueabi/libxml2.so.2 (0x76df4000)
    libc.so.6 => /lib/arm-linux-gnueabi/libc.so.6 (0x76cbd000)
    libxslt.so.1 => /usr/lib/arm-linux-gnueabi/libxslt.so.1 (0x76c7d000)
    librt.so.1 => /lib/arm-linux-gnueabi/librt.so.1 (0x76c6e000)
    libdl.so.2 => /lib/arm-linux-gnueabi/libdl.so.2 (0x76c63000)
    libz.so.1 => /lib/arm-linux-gnueabi/libz.so.1 (0x76c45000)
    liblzma.so.5 => /lib/arm-linux-gnueabi/liblzma.so.5 (0x76c1c000)
    libm.so.6 => /lib/arm-linux-gnueabi/libm.so.6 (0x76b73000)
    /lib/ld-linux.so.3 (0x76f4b000)
    libpthread.so.0 => /lib/arm-linux-gnueabi/libpthread.so.0 (0x76b53000)
    libgcc_s.so.1 => /lib/arm-linux-gnueabi/libgcc_s.so.1 (0x76b29000)

command arguments

root@xr7:/etc/rc2.d# fcm_manager -h
fcm_manager [-q] -h [-r <file>] [-n <node>] [-w <file>] -s
	-r	Send contents of <file>
	-n	Send to <node>
	-w	Write reply to <file>
	-s	Use SSL
	-q	Quiet (use first)
	-h	This help

root@xr7:/etc/rc2.d# fcmd -h
fcmd [-d <dir>] [-c <file>] [-h] -f
	-d <dir>	Use config dir <dir>
	-l <dir>	Use library dir <dir>
	-c <file>	fcmd config file
	-f 		fork as daemon
	-r 		validate also replies
	-h		This help
Signals
	USR1		Enable logging debug messages


  • config file and current config
root@xr7:/etc/rc2.d# ls /etc/fcmd/
XMLSchema.xsd		       ip				  switching_module.xsd
catalog.xml		       ip_module.xsd			  sync
clk_config.xsd		       managers.conf			  sync_module.xsd
clk_config_order.xslt	       netconf.xsd			  sync_order.xslt
config_order.xslt	       ptp_common.xsd			  sync_status.xsd
ethernet		       ptp_config.xsd			  vlan
ethernet_module.xsd	       ptp_config_order.xslt		  vlan_config.xsd
flexibilis_common.xsd	       redundancy_supervision		  vlan_module.xsd
flexibilis_config.xsd	       redundancy_supervision_module.xsd  xml.xsd
flexibilis_config_default.xsd  redundancy_supervision_status.xsd  xr7_fwud
flexibilis_config_order.xslt   routing				  xr7_monitor
fwud_config.xsd		       routing_module.xsd		  xr7_monitor_module.xsd
fwud_module.xsd		       switching			  xr7_monitor_status.xsd
root@xr7:/etc/rc2.d# ls /etc/fcmd/switching/
candidate  factory  rollback  running  startup

ls -al /var/run/fcmd/     
total 0
drwxr-xr-x 10 root root 200 Jan  1 02:00 .
drwxr-xr-x 10 root root 400 Jan  1 02:00 ..
drwxr-xr-x  5 root root 100 Jan  1 02:00 ethernet
drwxr-xr-x  5 root root 100 Jan  1 02:00 ip
drwxr-xr-x  5 root root 100 Jan  1 02:00 redundancy_supervision
drwxr-xr-x  5 root root 100 Jan  1 02:00 routing
drwxr-xr-x  5 root root 100 Jan  1 02:00 switching
drwxr-xr-x  5 root root 100 Jan  1 02:00 sync
drwxr-xr-x  5 root root 100 Jan  1 02:00 vlan
drwxr-xr-x  5 root root 100 Jan  1 02:00 xr7_fwud


start up scripts

root@xr7:/etc/rc2.d# ls
README	     S02cron	     S03xr7-system   S80fcmd		    S99xr7-boot-finished
S01bootlogs  S02virtual-xr7  S04lcd-manager  S82xr7ptp
S01motd      S03rc.local     S16ssh	     S85flx-host-clock-adj
S01rsyslog   S03rmnologin    S75sudo	     S92tomcat7

quite a lot sockets

root@xr7:/etc/init.d# netstat --all --program        
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 localhost:5454          *:*                     LISTEN      2237/fcmd       
tcp        0      0 *:ssh                   *:*                     LISTEN      2160/sshd       
tcp        0      0 localhost:8005          *:*                     LISTEN      2313/java       
tcp        0      0 192.168.7.2:ssh         192.168.7.111:57801     ESTABLISHED 2514/0          
tcp        0      0 localhost:5454          localhost:39742         ESTABLISHED 2237/fcmd       
tcp        0      0 localhost:39742         localhost:5454          ESTABLISHED 2313/java       
tcp6       0      0 [::]:http               [::]:*                  LISTEN      2313/java       
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      2160/sshd       
tcp6       0      0 [::]:https              [::]:*                  LISTEN      2313/java       
getnameinfo failed
getnameinfo failed
tcp6       0      0 [UNKNOWN]:https         [UNKNOWN]:58201         ESTABLISHED 2313/java       
getnameinfo failed
getnameinfo failed
tcp6       0      0 [UNKNOWN]:https         [UNKNOWN]:58179         TIME_WAIT   -               
getnameinfo failed
getnameinfo failed
tcp6       0      0 [UNKNOWN]:https         [UNKNOWN]:58180         TIME_WAIT   -               
getnameinfo failed
getnameinfo failed
tcp6       0      0 [UNKNOWN]:https         [UNKNOWN]:58178         TIME_WAIT   -               
getnameinfo failed
getnameinfo failed
tcp6       0      0 [UNKNOWN]:https         [UNKNOWN]:58198         ESTABLISHED 2313/java       
getnameinfo failed
getnameinfo failed
tcp6       0      0 [UNKNOWN]:https         [UNKNOWN]:58166         TIME_WAIT   -               
getnameinfo failed
getnameinfo failed
tcp6       0      0 [UNKNOWN]:https         [UNKNOWN]:58200         ESTABLISHED 2313/java       
getnameinfo failed
getnameinfo failed
tcp6       0      0 [UNKNOWN]:https         [UNKNOWN]:58202         ESTABLISHED 2313/java       
getnameinfo failed
getnameinfo failed
tcp6       0      0 [UNKNOWN]:https         [UNKNOWN]:58190         ESTABLISHED 2313/java       
getnameinfo failed
getnameinfo failed
tcp6       0      0 [UNKNOWN]:https         [UNKNOWN]:58181         TIME_WAIT   -               
getnameinfo failed
getnameinfo failed
tcp6       0      0 [UNKNOWN]:https         [UNKNOWN]:58199         ESTABLISHED 2313/java       
udp        0      0 *:319                   *:*                                 2270/xr7ptp     
udp        0      0 *:320                   *:*                                 2270/xr7ptp     

check linux domain socket

Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   PID/Program name    Path
unix  7      [ ]         DGRAM                    806      1976/rsyslogd       /dev/log
unix  2      [ ACC ]     SEQPACKET  LISTENING     3749     2237/fcmd           @fcm_socket
unix  2      [ ACC ]     SEQPACKET  LISTENING     244      660/udevd           /run/udev/control
unix  3      [ ]         SEQPACKET  CONNECTED     3851     2243/interface_mana 
unix  3      [ ]         SEQPACKET  CONNECTED     4275     2237/fcmd           @fcm_socket
unix  3      [ ]         SEQPACKET  CONNECTED     3848     2237/fcmd           @fcm_socket
unix  3      [ ]         SEQPACKET  CONNECTED     3831     2243/interface_mana 
unix  3      [ ]         DGRAM                    2966     660/udevd           
unix  3      [ ]         SEQPACKET  CONNECTED     4273     2264/xr7_fwud       
unix  2      [ ]         DGRAM                    4257     2251/xr7_monitor    
unix  3      [ ]         SEQPACKET  CONNECTED     3885     2270/xr7ptp         
unix  3      [ ]         SEQPACKET  CONNECTED     3832     2237/fcmd           @fcm_socket
unix  3      [ ]         DGRAM                    2965     660/udevd           
unix  3      [ ]         SEQPACKET  CONNECTED     4274     2264/xr7_fwud       
unix  3      [ ]         SEQPACKET  CONNECTED     3843     2237/fcmd           @fcm_socket
unix  3      [ ]         SEQPACKET  CONNECTED     3856     2237/fcmd           @fcm_socket
unix  2      [ ]         DGRAM                    3894     2258/flx_redundancy 
unix  3      [ ]         SEQPACKET  CONNECTED     4272     2264/xr7_fwud       
unix  3      [ ]         SEQPACKET  CONNECTED     4285     2237/fcmd           @fcm_socket
unix  2      [ ]         DGRAM                    3952     2514/0              
unix  2      [ ]         DGRAM                    4312     2270/xr7ptp         
unix  3      [ ]         SEQPACKET  CONNECTED     3842     2243/interface_mana 
unix  3      [ ]         SEQPACKET  CONNECTED     4252     2243/interface_mana 
unix  3      [ ]         SEQPACKET  CONNECTED     3867     2258/flx_redundancy 
unix  3      [ ]         SEQPACKET  CONNECTED     3852     2237/fcmd           @fcm_socket
unix  2      [ ]         DGRAM                    3830     2243/interface_mana 
unix  3      [ ]         SEQPACKET  CONNECTED     4259     2251/xr7_monitor    
unix  3      [ ]         SEQPACKET  CONNECTED     3847     2243/interface_mana 
unix  3      [ ]         SEQPACKET  CONNECTED     3864     2237/fcmd           @fcm_socket
unix  3      [ ]         SEQPACKET  CONNECTED     4268     2237/fcmd           @fcm_soc

  • total files
root@xr7:~# ls /proc/driver/flx_frs/
device00_adapter_registers  device00_ipo_registers   device00_vlan_config_registers
device00_common_registers   device00_port_registers  statistic_device00
root@xr7:~# ls /proc/driver/flx_time/
component_00_registers

  • /proc/driver/flx_frs/device00_adapter_registers
Adapter registers of device 0	   (REG):	PORT0	PORT1	PORT2	PORT3

ID				(0x0000):	0x0000	0x01b2	0x01b2	0x01b2
Link status			(0x0001):	0x4000	0x0001	0x0000	0x0001
GMII transmit clock		(0x0002):	  -   	  -   	  -   	  -   
PCS control			(0x0020):	  -   	0x1140	0x1140	0x1140
PCS status			(0x0021):	  -   	0x00ad	0x0089	0x00ad
PCS dev_ability			(0x0024):	  -   	0x4020	0x0020	0x4020
PCS partner_ability		(0x0025):	  -   	0x4020	0x0000	0x4020
PCS if_mode			(0x0034):	  -   	0x0000	0x0000	0x0000

  • /proc/driver/flx_frs/device00_common_registers
Common Registers of device 0:
FRS ID0				(0x0000): 0x0000
FRS ID1				(0x0001): 0x4000
FRS configuration ID		(0x0002):    206
FRS configuration SVN ID	(0x0003):  38661
FRS body SVN version		(0x0004):  38631
FRS General			(0x0008): 0x1602
FRS FRS_REG_CMEM_FILL_LEVEL	(0x000a):      0
FRS FRS_REG_DMEM_FILL_LEVEL	(0x000b):    119
FRS FRS_REG_SEQ_MEM_FILL_LEVEL	(0x000c):    248
FRS FRS_REG_SEQ_MEM_DEALLOC_ERR	(0x000c):      0
FRS Aging			(0x0010): 0x0103
FRS AGING_BASE_TIME_LO		(0x0011): 0xa11f
FRS AGING_BASE_TIME_HI		(0x0012): 0x0007
FRS_REG_AUTH_STATUS		(0x0013): 0x006f
FRS_REG_TS_CTRL_TX		(0x0014): 0x0000
FRS_REG_TS_CTRL_RX		(0x0015): 0x000f
FRS_REG_INTMASK			(0x0016): 0x0003
FRS_REG_INTSTAT			(0x0017): 0x0000

FRS_TX_TS_0 [s ns]	 (0x1002 0x1000): 0x00000000 0x00000000
FRS_TX_TS_1 [s ns]	 (0x1042 0x1040): 0x00000000 0x00000000
FRS_TX_TS_2 [s ns]	 (0x1082 0x1080): 0x00000000 0x00000000
FRS_TX_TS_3 [s ns]	 (0x10c2 0x10c0): 0x00000000 0x00000000

FRS_RX_TS_0 [s ns]	 (0x1102 0x1100): 0x000001ba 0x04ddcb30
FRS_RX_TS_1 [s ns]	 (0x1142 0x1140): 0x000001ba 0x15191018
FRS_RX_TS_2 [s ns]	 (0x1182 0x1180): 0x000001b9 0x3567e880
FRS_RX_TS_3 [s ns]	 (0x11c2 0x11c0): 0x000001ba 0x04ca1068

  • /proc/driver/flx_frs/device00_ipo_registers
IPO registers of device 0	(REG):		PORT0	PORT1	PORT2	PORT3

ETH_ADDR_CFG( 0)		(0x4000):	0x00c1	0x00c1	0x00c1	0x00c1
PORT_REG_ETH_ADDR_FWD_ALLOW	(0x4001):	0x0006	0x0007	0x0007	0x0000
PORT_REG_ETH_ADDR_FWD_MIRROR	(0x4002):	0x0000	0x0001	0x0001	0x0001
PORT_REG_ETH_ADDR_0		(0x4004):	0x1501	0x1501	0x1501	0x1501
PORT_REG_ETH_ADDR_1		(0x4005):	0x004e	0x004e	0x004e	0x004e
PORT_REG_ETH_ADDR_2		(0x4006):	0x0001	0x0001	0x0001	0x0001

ETH_ADDR_CFG( 1)		(0x4010):	0x0000	0x20c1	0x20c1	0x20c1
PORT_REG_ETH_ADDR_FWD_ALLOW	(0x4011):	0x0000	0xffff	0xffff	0xffff
PORT_REG_ETH_ADDR_FWD_MIRROR	(0x4012):	0x0000	0x0001	0x0001	0x0001
PORT_REG_ETH_ADDR_0		(0x4014):	0x0000	0x1b01	0x1b01	0x1b01
PORT_REG_ETH_ADDR_1		(0x4015):	0x0000	0x0019	0x0019	0x0019
PORT_REG_ETH_ADDR_2		(0x4016):	0x0000	0x0000	0x0000	0x0000

ETH_ADDR_CFG( 2)		(0x4020):	0x0cc1	0x00c1	0x00c1	0x00c1
PORT_REG_ETH_ADDR_FWD_ALLOW	(0x4021):	0xffff	0x0001	0x0001	0x0001
PORT_REG_ETH_ADDR_FWD_MIRROR	(0x4022):	0x0000	0x0001	0x0001	0x0001
PORT_REG_ETH_ADDR_0		(0x4024):	0x8001	0x8001	0x8001	0x8001
PORT_REG_ETH_ADDR_1		(0x4025):	0x00c2	0x00c2	0x00c2	0x00c2
PORT_REG_ETH_ADDR_2		(0x4026):	0x0e00	0x0e00	0x0e00	0x0e00

ETH_ADDR_CFG( 3)		(0x4030):	0x0000	0x0000	0x0000	0x0000
PORT_REG_ETH_ADDR_FWD_ALLOW	(0x4031):	0x0000	0x0000	0x0000	0x0000
PORT_REG_ETH_ADDR_FWD_MIRROR	(0x4032):	0x0000	0x0000	0x0000	0x0000
PORT_REG_ETH_ADDR_0		(0x4034):	0x0000	0x0000	0x0000	0x0000
PORT_REG_ETH_ADDR_1		(0x4035):	0x0000	0x0000	0x0000	0x0000
PORT_REG_ETH_ADDR_2		(0x4036):	0x0000	0x0000	0x0000	0x0000

port registers

* _/proc/driver/flx_frs/device00_port_registers_

Port registers of device 0 (REG): PORT0 PORT1 PORT2 PORT3

State (0x0000): 0x0204 0x0120 0x0002 0x0120 VLAN (0x0008): 0x8fff 0x8fff 0x8fff 0x8fff VLAN0_MAP (0x0009): 0x0000 0x0000 0x0000 0x0000 FWD_PORT_MASK (0x000a): 0x0000 0x0000 0x0000 0x0000 VLAN_PRIO (0x000b): 0xfa50 0xfa50 0xfa50 0xfa50 HSR_PORT_CFG (0x1000): 0x0000 0x0001 0x0401 0x0000 PORT_REG_PTP_DELAY_SN (0x2000): 0x0000 0x0000 0x0000 0x0000 PORT_REG_PTP_DELAY_NSL (0x2001): 0x0000 0x01c9 0x0000 0x0000 PORT_REG_PTP_DELAY_NSH (0x2002): 0x0000 0x0000 0x0000 0x0000


-----

* _/proc/driver/flx_frs/device00_vlan_config_registers_

VLAN config Registers of device 0: FRS VLAN(0) (0x2000): 0x000f FRS VLAN(1) (0x2001): 0x000f FRS VLAN(2) (0x2002): 0x000f FRS VLAN(3) (0x2003): 0x000f FRS VLAN(4) (0x2004): 0x000f FRS VLAN(5) (0x2005): 0x000f FRS VLAN(6) (0x2006): 0x000f FRS VLAN(7) (0x2007): 0x000f FRS VLAN(8) (0x2008): 0x000f FRS VLAN(9) (0x2009): 0x000f FRS VLAN(10) (0x200a): 0x000f FRS VLAN(11) (0x200b): 0x000f


-----

* _/proc/driver/flx_frs/statistic_device00_

Statistic of device 0: RX tstamp: 0x0000079a TX tstamp: 0x00000000 RX error: 0x00000000 Congested: 0x00000000

Port statistics (REG): PORT0 PORT1 PORT2 PORT3

RX good octets (0x3100): 0x00000077 0x00000158 0x00000000 0x00000000 RX bad octets (0x3102): 0x00000000 0x00000000 0x00000000 0x00000000 RX unicast frames (0x3104): 0x00000001 0x00000002 0x00000000 0x00000000 RX broadcast frames (0x3106): 0x00000000 0x00000000 0x00000000 0x00000000 RX multicast frames (0x3108): 0x00000000 0x00000002 0x00000000 0x00000000 RX undersize frames (0x310a): 0x00000000 0x00000000 0x00000000 0x00000000 RX fragment frames (0x310c): 0x00000000 0x00000000 0x00000000 0x00000000 RX oversize frames (0x310e): 0x00000000 0x00000000 0x00000000 0x00000000 RX error frames (0x3112): 0x00000000 0x00000000 0x00000000 0x00000000 RX CRC error frames (0x3114): 0x00000000 0x00000000 0x00000000 0x00000000

RX good HSR/PRP frames (0x3122): 0x00000000 0x00000002 0x00000000 0x00000000 RX PRP wrong LAN frames (0x3124): 0x00000000 0x00000000 0x00000000 0x00000000 RX HSR/PRP duplicate drop (0x3126): 0x00000000 0x00000000 0x00000000 0x00000000

TX octets (0x3140): 0x000000be 0x000000c4 0x00000000 0x00000000 TX unicast frames (0x3142): 0x00000002 0x00000001 0x00000000 0x00000000 TX broadcast frames (0x3144): 0x00000000 0x00000000 0x00000000 0x00000000 TX multicast frames (0x3146): 0x00000000 0x00000001 0x00000000 0x00000000

TX HSR/PRP frames (0x3148): 0x00000000 0x00000001 0x00000000 0x00000000

TX priority queue full drop (0x3160): 0x00000000 0x00000000 0x00000000 0x00000000


-----

* libraries build procedure
``` sh 
> source build.env
> cd flx_fes_lib
> make
> cd ..;cd flx_packet_if
> make
> cd ..;cd flx_frtc_clock_if
> make
> cd flx_redundancy_supervision
> DISABLE_NETCONF_API=y make
  • binary list. Copy them to the target
    • flx_frtc_clock_if/lib/libclock_if.so
    • flx_fes_lib/lib/libflx_fes.so
    • flx_redundancy_supervision/lib/libpacket_lib.so
    • flx_redundancy_supervision/lib/libsupervision_lib.so
    • flx_packet_if/lib/libpacket_if.so
    • flx_redundancy_supervision/bin/flx_redundancy_supervision

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment