====== S2OPC - TSN ======
This guide runs the S2OPC OPC UA PubSub sample across a Time-Sensitive
Networking path between two Linux hosts, using the kernel's ETF (Earliest TxTime
First) qdisc for transmit scheduling and IEEE 1588 / IEEE 802.1AS time
synchronisation through linuxptp. Publisher and subscriber are two DUTs
connected peer-to-peer through Intel i210 NICs. Versions used here: RT kernel
5.05, linuxptp v3.1, iproute2 v5.0; the lowest publisher cycle time exercised
was 1 ms.
==== Prerequisite ====
* S2OPC – TSN testing requires 2 DUT’s with below configuration
* **DUT** **H/W****:** i5 Quad core with intel i210 NIC card
* **DUT** **S/W:** Install debian 9.5 or ubuntu on the DUT + RT kernel 5.05
* Enable ETF, CBS, MQPRIO and TAPRIO scheduler in networking options during kernel config
* **[Note]** The DUT hardware configuration is upto the users. If you need steps to setup the DUT with Linux + RT patch[[:os:linux:qsg:rt-patch| follow this QSG]]
==== Dependencies ====
* After installing Debian + RT kernel in the DUT’s, now login
* Follow these [[.build-linux#dependencies|dependencies section]] and install all packages. For TSN demo, PTP and iproute2 package should be installed additionally.
== Linux PTP v3.1 – release installation ==
* Now come back to ** S2OPC/** parent folder and download and install latest PTP stack v3.1 – release
# wget https://github.com/richardcochran/linuxptp/archive/v3.1.tar.gz
# tar -xvf linuxptp-3.1.tar.gz
# cd linuxptp-3.1/
# make
# make install
== Iproute2 v5.0 – release ==
# cd ..
# wget https://github.com/shemminger/iproute2/archive/v5.0.0.tar.gz
# tar -xvzf iproute2-5.0.0.tar.gz
# ./configure
# make
# make install
==== Run S2OPC TSN demo application ====
== Network Architecture ==
* Connect the DUT 1 and 2 i210 NIC in peer to peer (P2P)
* DUT1 is the publisher and DUT2 is the subscriber.
{{:technology:industry40:opcua:s2opc:qsg:b5d2a7d8ffd5c1ea1ee8fa9217ca6f8e.png?547x245}}
== Queuing discipline ==
**On DUT 1 (publisher):** Run the below commands; Replace the IFNAME with the i210 interface name. Use “ifconfig” to find the interface name.
# tc qdisc add dev parent root handle 100 mqprio num_tc 3 map 2 2 1 0 2 2 2 2 2 2 2 2 2 2 2 2 queues 1@0 1@1 2@2 hw 0
# tc qdisc add dev parent 100:1 etf offload clockid CLOCK_TAI delta 150000
== IEEE - 1588 time synchronization ==
Time synchronization is one of the core functionalities of TSN which uses IEEE 1588 in 802.1AS, also known as Precision Time Protocol (PTP).
* ptp4l: Synchronizes the PTP Hardware Clock (PHC) from the i210 NIC
* phc2sys: Synchronizes the PHC and the System clock
In this demo, DUT 1 will act as ptp4l master and DUT 2 as ptp4l slave.
**On DUT 1** **(publisher)****:**
* Run the below PTP4l and PHC2SYS command
''# ptp4l -i -2 -mq''
{{:technology:industry40:opcua:s2opc:qsg:5f6ae5456b0449e8744eb8de9107ce99.png}}
* Open another terminal and run PHC2SYS command
''# phc2sys -s enp1s0 -m -O 0''
{{:technology:industry40:opcua:s2opc:qsg:82c3e6da57e9a5cd4aa150f7e6624f7b.png}}
**On DUT 2** **(subscriber)****:**
* Run the below PTP4l and PHC2SYS command. The slave device report out the time offset calculated from the PTP master.
''# ptp4l -2 -s -i -m''
{{:technology:industry40:opcua:s2opc:qsg:03a38e66646ac79249e504be4f2417cd.png}}
== Compile and run S2OPC Publisher application ==
* Open a new terminal. Clone the S2OPC repository from GitLab
# git clone https://gitlab.com/systerel/S2OPC.git
# cd S2OPC
* Open samples/RT_PubSub/udp_rt_pub.c, modify the ETH_INTERFACE, MCAST_PORT, MCAST_ADDR and CYCLE_TIME flag as per the DUT configuration. The lowest cycle time tested is 1ms i.e 1000000ns
{{:technology:industry40:opcua:s2opc:qsg:f64d42a381b2d6588e098dd8565d3f17.png}}
# ./build.sh
# cd build/bin
# ./udp_rt_pub
**In DUT 2** **(subscriber)****:** For measuring the layer2 network jitter, run the below command
''# tcpdump -c 60000 -i -w tmp.pcap -j adapter_unsynced -tt –time-stamp-precision=nano udp port 4840''
Now, open the trace in wireshark and verify the packet-to-packet jitter.
* You should observe a worstcase network jitter of +/-40 ns with few outliers (approx <0.02%)
To download [[:solutions:qbv-analyser|live analyzer tool]]
To see our test bench [[:solutions:test-rack|results]]
----
For more help with setting up your evaluation and toolkits, contact us at [[adopt.opctsn@aeicor.com?subject=S2OPC - Setting up support|adopt.opctsn@aeicor.com]] \\
You can also reach S2OPC support at [[https://www.s2opc.com|https://www.s2opc.com]]