Sonic-lab

From NesevoWiki
Jump to navigationJump to search

<to be noted that those informations are included into the readme.md file into the archive>

Lab diagram

SONIC LAB.jpg

Lab archive Sonic-lab-20201030.zip

This lab is a forked lab from many found on @, starting from Microsoft one : https://github.com/Azure/SONiC/wiki/SONiC-P4-Software-Switch

The target of this lab is to simulate a simple IP/Fabric in SPINE/LEAF topology. Each Leaf provide local L2 connectivity + L3 gateways to hosts. Flows between hosts from different leaf are L3 routed, in a "node path" LEAF-SPINE-LEAF.

Nothing complicated, but it allows to put a first foot into SONiC world :)

For the moment, as far as we know, MC-LAG + EVPN/VXLAN features are only available on entreprise SONiC versions. Tests to come once physic switches in enterprise version will be available in our lab.

The diagram of the architecture is into the zip file (SONIC_LAB.jpg)

To run the lab you need :

  • to have installed docker by using ./install_docker_ovs.sh
  • to run the ./load_image.sh in order to get the Sonic image

Note : don't change file / folders names of network devices (leafX, spineX)

Once you're ready, please run the lab by launching "./start.sh"

The script :

  • launches the containers without Docket network features
  • create network namespaces
  • build linux bridges to interconnect the containers
  • configure host IPs
  • launch startup sonic scripts into sonic devices
  • once devices started, checks + ping tests are run. If all BGP sessions are ok on spine + all ping are fine, the setup works well.

The "start" script has several comments, perhaps without the right vocabulary, so please be tolerant :)

If you want to stop the lab, please launch "./stop.sh"

Below some useful commands to run for sonic containers :

run ping

sudo docker exec -it <container> ping <ip>

This command triggers ping into the targetted container :

plancastre@dockerhost:~/00.Projects/p4-version-pla$ sudo docker exec -it leaf1 ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1): 56 data bytes
64 bytes from 192.168.1.1: icmp_seq=0 ttl=64 time=0.052 ms
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.034 ms
^C--- 192.168.1.1 ping statistics ---

check bgp sessions

sudo docker exec -it <container> vtysh -c "show ip bgp sum"

This command sollicitates the SONiC shell of the targeted container, in order to print the bgp status. Below, we run it on one spine, you should have 4 sessiosn UP (for the 4 leaves)

plancastre@dockerhost:~/00.Projects/p4-version-pla$ sudo docker exec -it spine1 vtysh -c "show ip bgp sum"
BGP router identifier 10.1.0.1, local AS number 65001
RIB entries 8, using 896 bytes of memory
Peers 4, using 18 KiB of memory
Neighbor        V         AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.1.0.0        4 65101    6409    6411        0    0    0 01:46:46        3
10.1.0.2        4 65102    6406    6410        0    0    0 01:46:44        3
10.1.0.4        4 65103    6407    6410        0    0    0 01:46:44        4
10.1.0.6        4 65104    6406    6412        0    0    0 01:46:46        1
Total number of neighbors 4

check ip route

sudo docker exec -it <container> vtysh -c "show ip route"

This command sollicitates the SONiC shell of the targeted container, in order to print its routing table?

plancastre@dockerhost:~/00.Projects/p4-version-pla$ sudo docker exec -it spine1 vtysh -c "show ip route"
Codes: K - kernel route, C - connected, S - static, R - RIP,
O - OSPF, I - IS-IS, B - BGP, P - PIM, A - Babel,
> - selected route, * - FIB route
C>* 10.1.0.0/31 is directly connected, Vlan11
C>* 10.1.0.2/31 is directly connected, Vlan21
C>* 10.1.0.4/31 is directly connected, Vlan31
C>* 10.1.0.6/31 is directly connected, Vlan41
C>* 127.0.0.0/8 is directly connected, lo
B>* 192.168.1.0/24 [20/0] via 10.1.0.0, Vlan11, 01:47:23
B>* 192.168.2.0/24 [20/0] via 10.1.0.2, Vlan21, 01:47:21
B>* 192.168.3.0/24 [20/0] via 10.1.0.4, Vlan31, 01:47:21
B>* 192.168.4.0/24 [20/0] via 10.1.0.6, Vlan41, 01:47:23

For more commands check SONiC docs : https://github.com/Azure/sonic-utilities/blob/master/doc/Command-Reference.md

To finish, below the output of the start.sh when all goes well

plancastre@dockerhost:~/00.Projects/p4-version-pla$ ./start.sh 
---------------------------------------------------
Creating the containers: starting
---------------------------------------------------
0b4bbb3c6cfc9895466ea13a9e940d1a176d66f45deee9752e9b4732d735bb03
5ca9486baab3e8a5259062167132a944eee717875d3cc1ef29fe490cba3184c1
46c9c09dba27a32715b9fbe0bc434a9284b9d59317d278df693f425cb669f037
898e6afbcb2977115acbba2a69d069796cfd70fb90228b6c18e09ba4584365f7
eb9b3ef6d14784c9ffe4d9d5df3e921a24559889cb8770d226263aad6761182a
ae5f3b2c628da687eaabb331dc2cd989e71bcb386854e7a0be6ec587df99d49a
122197bffd7566a01ce3b6565fdfb6eb893aab7d5236f14e5a9bbbe95037ced2
a604520a080e2a2184598ad1d915c0c182d16e5185033373e95a4772d8978a67
0c49e18d78b2aa7c8ef8e937b60285aa56ec0bf4a8530226285270a085e11d5c
eb66336b8c6bd8333f1f4f685369e6cac973b817c35bb7126ac4d7ba72ef71bf
---------------------------------------------------
Retreiving PID from docker containers
---------------------------------------------------
---------------------------------------------------
Creating network namespaces for containers
---------------------------------------------------
List of created namespaces
ns_host4
ns_host3
ns_host2
ns_host1
ns_spine2
ns_spine1
ns_leaf4
ns_leaf3
ns_leaf2
ns_leaf1
---------------------------------------------------
Creating network connectivity between containers
---------------------------------------------------
---------------------------------------------------
Now assigning IPs to hosts (host1 to host4)
---------------------------------------------------
---------------------------------------------------
Configuration of containers is now finished
---------------------------------------------------
---------------------------------------------------
Now booting switches, please wait 2 minutes for switches to load
---------------------------------------------------
---------------------------------------------------
2 minutes period is finished
---------------------------------------------------
---------------------------------------------------
Now fixing the iptables
---------------------------------------------------
---------------------------------------------------
Backend actions are now finished
---------------------------------------------------
---------------------------------------------------
Now we'll check in 15 sec that BGP peers are all Up
---------------------------------------------------
---------------------------------------------------
SPINE1 check BGP Sessions
---------------------------------------------------
BGP router identifier 10.1.0.1, local AS number 65001
RIB entries 8, using 896 bytes of memory
Peers 4, using 18 KiB of memory
Neighbor        V         AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.1.0.0        4 65101      94      97        0    0    0 00:01:28        4
10.1.0.2        4 65102      95      97        0    0    0 00:01:28        5
10.1.0.4        4 65103      95      97        0    0    0 00:01:28        5
10.1.0.6        4 65104      95      97        0    0    0 00:01:28        5
Total number of neighbors 4
---------------------------------------------------
SPINE2 check BGP Sessions
---------------------------------------------------
BGP router identifier 10.2.0.1, local AS number 65002
RIB entries 8, using 896 bytes of memory
Peers 4, using 18 KiB of memory
Neighbor        V         AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.2.0.0        4 65101      93      96        0    0    0 00:01:29        2
10.2.0.2        4 65102      94     100        0    0    0 00:01:32        1
10.2.0.4        4 65103      94     100        0    0    0 00:01:32        1
10.2.0.6        4 65104      94     100        0    0    0 00:01:32        1
Total number of neighbors 4
---------------------------------------------------
Now if all is ok, we'll do some ping tests
---------------------------------------------------
---------------------------------------------------
host1 ping its gateway
---------------------------------------------------
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=17.6 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=9.14 ms
--- 192.168.1.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 9.145/13.390/17.636/4.247 ms
---------------------------------------------------
host2 ping its gateway
---------------------------------------------------
PING 192.168.2.1 (192.168.2.1) 56(84) bytes of data.
64 bytes from 192.168.2.1: icmp_seq=1 ttl=64 time=23.6 ms
64 bytes from 192.168.2.1: icmp_seq=2 ttl=64 time=6.21 ms
--- 192.168.2.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 6.218/14.950/23.683/8.733 ms
---------------------------------------------------
host3 ping its gateway
---------------------------------------------------
PING 192.168.3.1 (192.168.3.1) 56(84) bytes of data.
64 bytes from 192.168.3.1: icmp_seq=1 ttl=64 time=18.8 ms
64 bytes from 192.168.3.1: icmp_seq=2 ttl=64 time=12.7 ms
--- 192.168.3.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 12.716/15.764/18.812/3.048 ms
---------------------------------------------------
host4 ping its gateway
---------------------------------------------------
PING 192.168.4.1 (192.168.4.1) 56(84) bytes of data.
64 bytes from 192.168.4.1: icmp_seq=1 ttl=64 time=17.7 ms
64 bytes from 192.168.4.1: icmp_seq=2 ttl=64 time=4.46 ms
--- 192.168.4.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 4.464/11.107/17.750/6.643 ms
---------------------------------------------------
host1 sends 3 ping the 3 other hosts
---------------------------------------------------
PING 192.168.2.2 (192.168.2.2) 56(84) bytes of data.
64 bytes from 192.168.2.2: icmp_seq=1 ttl=61 time=16.0 ms
64 bytes from 192.168.2.2: icmp_seq=2 ttl=61 time=19.5 ms
64 bytes from 192.168.2.2: icmp_seq=3 ttl=61 time=16.1 ms
--- 192.168.2.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 16.049/17.253/19.532/1.615 ms
PING 192.168.3.2 (192.168.3.2) 56(84) bytes of data.
64 bytes from 192.168.3.2: icmp_seq=1 ttl=61 time=15.5 ms
64 bytes from 192.168.3.2: icmp_seq=2 ttl=61 time=14.3 ms
64 bytes from 192.168.3.2: icmp_seq=3 ttl=61 time=16.9 ms
--- 192.168.3.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 14.312/15.592/16.939/1.083 ms
PING 192.168.4.2 (192.168.4.2) 56(84) bytes of data.
64 bytes from 192.168.4.2: icmp_seq=1 ttl=61 time=16.0 ms
64 bytes from 192.168.4.2: icmp_seq=2 ttl=61 time=20.7 ms
64 bytes from 192.168.4.2: icmp_seq=3 ttl=61 time=16.8 ms
--- 192.168.4.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 16.048/17.871/20.739/2.058 ms
---------------------------------------------------
host2 sends 3 ping the 3 other hosts
---------------------------------------------------
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=61 time=16.2 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=61 time=16.6 ms
64 bytes from 192.168.1.2: icmp_seq=3 ttl=61 time=16.9 ms
--- 192.168.1.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 16.222/16.583/16.924/0.286 ms
PING 192.168.3.2 (192.168.3.2) 56(84) bytes of data.
64 bytes from 192.168.3.2: icmp_seq=1 ttl=61 time=16.6 ms
64 bytes from 192.168.3.2: icmp_seq=2 ttl=61 time=18.1 ms
64 bytes from 192.168.3.2: icmp_seq=3 ttl=61 time=26.8 ms
--- 192.168.3.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 16.620/20.549/26.887/4.524 ms
PING 192.168.4.2 (192.168.4.2) 56(84) bytes of data.
64 bytes from 192.168.4.2: icmp_seq=1 ttl=61 time=33.8 ms
64 bytes from 192.168.4.2: icmp_seq=2 ttl=61 time=27.7 ms
64 bytes from 192.168.4.2: icmp_seq=3 ttl=61 time=20.2 ms
--- 192.168.4.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 20.216/27.259/33.818/5.566 ms
---------------------------------------------------
host3 sends 3 ping the 3 other hosts
---------------------------------------------------
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=61 time=14.5 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=61 time=19.5 ms
64 bytes from 192.168.1.2: icmp_seq=3 ttl=61 time=15.5 ms
--- 192.168.1.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 14.535/16.549/19.541/2.162 ms
PING 192.168.2.2 (192.168.2.2) 56(84) bytes of data.
64 bytes from 192.168.2.2: icmp_seq=1 ttl=61 time=16.4 ms
64 bytes from 192.168.2.2: icmp_seq=2 ttl=61 time=14.6 ms
64 bytes from 192.168.2.2: icmp_seq=3 ttl=61 time=18.2 ms
--- 192.168.2.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 14.643/16.458/18.278/1.491 ms
PING 192.168.4.2 (192.168.4.2) 56(84) bytes of data.
64 bytes from 192.168.4.2: icmp_seq=1 ttl=61 time=15.3 ms
64 bytes from 192.168.4.2: icmp_seq=2 ttl=61 time=14.1 ms
64 bytes from 192.168.4.2: icmp_seq=3 ttl=61 time=13.1 ms
--- 192.168.4.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 13.171/14.234/15.334/0.883 ms
---------------------------------------------------
host4 sends 3 ping the 3 other hosts
---------------------------------------------------
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=61 time=21.9 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=61 time=21.3 ms
64 bytes from 192.168.1.2: icmp_seq=3 ttl=61 time=14.6 ms
--- 192.168.1.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 14.619/19.284/21.932/3.310 ms
PING 192.168.2.2 (192.168.2.2) 56(84) bytes of data.
64 bytes from 192.168.2.2: icmp_seq=1 ttl=61 time=14.8 ms
64 bytes from 192.168.2.2: icmp_seq=2 ttl=61 time=18.4 ms
64 bytes from 192.168.2.2: icmp_seq=3 ttl=61 time=14.1 ms
--- 192.168.2.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 14.148/15.786/18.409/1.879 ms
PING 192.168.3.2 (192.168.3.2) 56(84) bytes of data.
64 bytes from 192.168.3.2: icmp_seq=1 ttl=61 time=16.2 ms
64 bytes from 192.168.3.2: icmp_seq=2 ttl=61 time=15.1 ms
64 bytes from 192.168.3.2: icmp_seq=3 ttl=61 time=18.9 ms
--- 192.168.3.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2001ms
rtt min/avg/max/mdev = 15.117/16.788/18.962/1.612 ms
---------------------------------------------------
If bot spine have all BGP sessions and all ping succeeded, all works well
Congrats ! please check readme file to find some details
---------------------------------------------------