-
Notifications
You must be signed in to change notification settings - Fork 1.1k
SONiC P4 Software Switch
#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
- 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) <--> switch1 (SONiC) <--> switch2 (SONiC) <--> host2 (Ubuntu, 192.168.2.2/24)
switch1 and switch2 are two SONiC-P4 switches in two different BGP AS, peering with each other. Test1 announces 192.168.1.0/24, switch2 announces 192.168.2.0/24
-
On a Ubuntu server, download necessary files Here. Unzip the file and go to the
sonic/
directory. -
Run
./install_docker_ovs.sh
to install docker and open-vswitch. -
Run
./load_image.sh
to load the SONiC-P4 image. Currently, we specify loading build 278. You may specify other builds later than 278 if needed. -
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
db924306352f ubuntu:14.04 "/bin/bash" 2 minutes ago Up 2 minutes
host2
ae5e987dee8c ubuntu:14.04 "/bin/bash" 2 minutes ago Up 2 minutes
host1
aed19d76cd3a docker-sonic-p4:latest "/bin/bash" 2 minutes ago Up 2 minutes
switch2
680f95a83512 docker-sonic-p4:latest "/bin/bash" 2 minutes ago Up 2 minutes
switch1
- Wait for ~30 seconds of bootup time. Then run
./test.sh
, which pings host2 from host1.
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
- Check BGP on switch1
lgh@acs-p4:~/sonic$ docker exec -it switch1 bash
root@switch1:/# vtysh -c "show ip bgp sum"
BGP router identifier 192.168.1.1, local AS number 10001
RIB entries 3, using 336 bytes of memory
Peers 1, using 4568 bytes of memory
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
10.0.0.1 4 10002 1993 1996 0 0 0 00:33:12 1
Total number of neighbors 1
- run
./stop.sh
to cleanup.
-
For Users
-
For Developers
-
Subgroups/Working Groups
-
Presentations
-
Join Us