[P4-dev] Question about adding routes on a p4 switch-router

David Hancock dhancock at cs.utah.edu
Wed Feb 17 11:35:44 EST 2016


Welcome to the P4 community!  I am a student like yourself, so what I 
say is not authoritative, but I think I can help you.

Hopefully you are using bmv2, the newer "behavioral model" software 
switch.  See https://github.com/p4lang/behavioral-model for a good 
overview.  The concept is that once you get it running, loaded with the 
basic_routing program, you use a separate terminal (NOT in the mininet 
shell, or at least not typically) to connect to bmv2's command line 
interface.  Once connected to the CLI, the "help" command will help you 
explore CLI commands available and how to use them, but spoiler alert, 
you will be most interested in table_add and table_set_default to begin 
with.  You can also quite easily assemble commands in a script, usually 
called "commands.txt" and feed it to the CLI.

Here is a workflow for running basic_routing in mininet and connecting 
to the CLI:

# start mininet simulation '1sw_demo.py' running bmv2 w/ basic_routing:
cd ~/p4factory/targets/basic_routing
p4c-bmv2 --json basic_routing.json p4src/basic_routing.p4
sudo python ~/p4factory/submodules/bm/mininet/1sw_demo.py \
~/p4factory/submodules/bm/targets/simple_switch/simple_switch \
--json ~/p4factory/targets/basic_routing/basic_routing.json

# in a separate terminal, connect to the CLI
cd ~/p4factory/targets/basic_routing
sudo ~/p4factory/submodules/bm/targets/simple_switch/sswitch_CLI 
basic_routing.json 9090

In this case, 9090 was the default thrift port for the switch as 
specified in 1sw_demo.py, but you can specify your own via 
--thrift-port, and note that in many demos the port used is 22222.

To supply a "commands.txt" script to the CLI, just add "< commands.txt" 
to the end of the sswitch_CLI command, e.g.:

sudo ~/p4factory/submodules/bm/targets/simple_switch/sswitch_CLI 
basic_routing.json 9090 < commands.txt

Good luck

On 02/17/2016 03:38 AM, Daniel Fernandes wrote:
> Hello! I'm a computer science student in Portugal. Me and a couple 
> colleagues are doing a project/workshop about SDN's, virtualization, 
> and new innovative ideas/technologies that impact these networks.
> We found out P4 and figured out it was a good subject to work upon, 
> hence we tried downloading and compiling the p4factory and after some 
> troubles with the VM, we managed to get it compiling the basic_router, 
> however, we're facing a problem that we don't know the answer nor we 
> find any details about to do it, which is adding routes to the switch. 
> In the language showcase video, the person shows a script 
> (switch-control.sh) that uses a .txt file as input. I was wondering if 
> I could get any feedback in how to do this, by either commands in the 
> mininet shell, or the script itself.
> Thanks a lot for your help.
> _______________________________________________
> P4-dev mailing list
> P4-dev at lists.p4.org
> http://lists.p4.org/mailman/listinfo/p4-dev_lists.p4.org

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20160217/981bd587/attachment.html>

More information about the P4-dev mailing list