Skip to content

SONiC P4 Software Switch

svc-acs edited this page Mar 2, 2017 · 27 revisions

#What is SONiC-P4 Software Switch

SONiC-P4 is a software switch that runs on the P4-emulated software switch ASIC developed by Barefoot. It uses the SAI.P4 to program the P4-emulated switch ASIC to emulate the data plane behavior. On top of that, it runs the real SONiC network stack. The current SONiC-P4 is released as a docker image. You can run it anywhere that docker runs -- inside a bare-metal Linux/Windows machine, inside your favorite virtual machine, or inside your favorite cloud environment. However, because of this choice, we build the various SONiC modules in a single docker image, instead of having them as their own docker image. We find this a very useful tool for developing and testing upper layer features.

#How to use SONiC-P4 Software Switch

  1. In the following, we explain the usage of SONiC-P4 software switch with a very simple testbed.

Topology:

host1 (Ubuntu, 192.168.1.2/24) <--> test1 (sonic) <--> test2 (sonic) <--> host2 (Ubuntu, 192.168.2.2/24)

test1 and test2 are two SONiC-P4 switches in two different BGP AS, peering with each other. Test1 announces 192.168.1.0/24, test2 announces 192.168.2.0/24

  1. On a Ubuntu server, download necessary files Here. Unzip the file.

  2. Run ./install_docker_ovs.sh to install docker and open-vswitch.

  3. Run ./start.sh to setup the two switches and hosts. You should see the four dockers when finish.

lgh@acs-p4:~/sonic$ docker ps
CONTAINER ID        IMAGE                                                   COMMAND             CREATED             STATUS              PORTS               NAMES
cbe8c3da3c1f        ubuntu:14.04                                            "/bin/bash"         4 minutes ago       Up 3 minutes                            host2
9a210bf85bd2        ubuntu:14.04                                            "/bin/bash"         4 minutes ago       Up 4 minutes                            host1
72a4520b2e12        sonicp4-microsoft.azurecr.io/docker-sonic-p4:20170215   "/bin/bash"         4 minutes ago       Up 4 minutes                            test2
7a2c46fed63f        sonicp4-microsoft.azurecr.io/docker-sonic-p4:20170215   "/bin/bash"         4 minutes ago       Up 4 minutes                            test1
  1. Run ./test.sh after ~30 seconds bootup time.
lgh@acs-p4:~/sonic$ ./test.sh                 
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=62 time=9.81 ms
64 bytes from 192.168.2.2: icmp_seq=2 ttl=62 time=14.9 ms
64 bytes from 192.168.2.2: icmp_seq=3 ttl=62 time=8.42 ms
64 bytes from 192.168.2.2: icmp_seq=4 ttl=62 time=14.7 ms
  1. run ./stop.sh to cleanup.
Clone this wiki locally