TCNOpen TRDP prototype stack
$Id: NotesOnVLAN.txt 2220 2020-08-28 12:41:50Z bloehr $

*******************************************************************************************************
* Notes on experimental and target-specific options
*******************************************************************************************************

The TCNOpen TRDP stack can be used on any IP-enabled interface from V 1.0 on. However, some settings
like matching QoS values to IP and VLAN priorities have been added later and depend mostly on the
target's VOS implementation (i.e. Operating System and network subsystems). Unfortunately, handling and
configuring of network interfaces is purely standardized in POSIX and as such differs between Linux
versions and distributions.

A limitation for versions up to 2.0.3 apply, VLAN support for the POSIX targets assumes an already
set ingress/egress sbk mapping.

### VLAN (set-up on CentOS8) ###

When using TSN enabled or VLAN tagged interfaces, make sure the kernel module 8021q is active.
On CentOS7/8 e.g.:

    [admin@localhost trdp]$ lsmod | grep -i 8021q
    [admin@localhost trdp]$ modprobe --first-time 8021q
    [admin@localhost trdp]$ lsmod | grep -i 8021q
    8021q                  40960  0
    garp                   16384  1 8021q
    mrp                    20480  1 8021q

Setting up a VLAN tagged NIC (example for VLAN Id = 200)

List the available interfaces:
    [admin@localhost trdp]$ ip addr show
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
        valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host
        valid_lft forever preferred_lft forever
    2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
        link/ether 08:00:27:d6:c5:b8 brd ff:ff:ff:ff:ff:ff
        inet 10.64.8.50/20 brd 10.64.15.255 scope global dynamic noprefixroute enp0s3
        valid_lft 598917sec preferred_lft 598917sec
        inet6 fe80::e07b:425d:7ade:908a/64 scope link noprefixroute
        valid_lft forever preferred_lft forever
    ...

Tag (or map) the VLAN 200 to NIC enp0s3 using the ip command

    [admin@localhost trdp]# sudo ip link add link enp0s3 name enp0s3.200 type vlan id 200
    [admin@localhost trdp]# sudo ip link set dev enp0s3.200 up

Assign an IP address to the tagged interface from their respective VLANs using beneath ip command

    [admin@localhost trdp]# ip addr add 10.0.2.200/18 dev enp0s3.200
    [admin@localhost trdp]# sudo ip link set enp0s3.200 type vlan egress 3:3

### Persistancy (still work in progress) ###

To make tagged interfaces persistent across reboots then use interface ifcfg files and edit interface (enp0s3) file
"/etc/sysconfig/network-scripts/ifcfg-enp0s3" to add the following content:

    Note: Replace the interface name that suits your environment

[admin@localhost trdp]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
    TYPE=Ethernet
    DEVICE=enp0s3
    BOOTPROTO=none
    ONBOOT=yes

Create tagged interface file for VLAN id 200 as “/etc/sysconfig/network-scripts/ifcfg-enp0s3.200” and
    add the following contents to it.

[root@linuxtechi ~]# vi /etc/sysconfig/network-scripts/ifcfg-enp0s3.200
    DEVICE=enp0s3.200
    BOOTPROTO=none
    ONBOOT=yes
    IPADDR=10.0.2.200
    PREFIX=18
    NETWORK=10.0.2.0
    VLAN=yes
