[P4-dev] Integrating virtualbox with P4 switches

Antonin Bas antonin at barefootnetworks.com
Tue Jul 21 22:01:17 EDT 2015


Hi Sergio,

Sorry for the delay in answering, I've been on vacation :)

I'd like to offer a simpler alternative, with detailed steps. This relies
on creating 1 tap interface per Virtualbox VM and using Virtualbox's
'bridged adapter' networking mode. I deployed this on my machine, so I know
it is working: the p4 switch was receiving packets (but I did not take the
time to configure the match-action tables, so the switch was just dropping
the packets).

These steps assume that you have downloaded p4factory and that you have
compiled a p4switch (like l2_switch or simple_router). Therefore you should
have a 'behavioral-model' executable.
I will assume that you are trying to connect 2 VMs, but it is very easy to
extend this to N VMs.

- create one tap interface per VM:
sudo ip tuntap add mode tap p1tap
sudo ip tuntap add mode tap p2tap

- bring them up:
sudo ip link set p1tap up
sudo ip link set p2tap up

- start the p4-switch and bind the 2 tap interfaces to it:
sudo ./behavioral-model -i p1tap -i p2tap --pd-server 127.0.0.1:22222
--listener 127.0.0.1:11111

- assign the interfaces to each VM:
under the network setting select in "Attached to" "Bridge Adapter" and in
"Name" select the correct tap interface for the VM

And you're done :)

If you try to send traffic, the switch will probably drop the packets
unless you populate the tables. To populate the tables you need to connect
to the PD server (port 22222 as you can tell by the above command). I
suggest using l2_switch as your P4 program (to test your configuration), as
it will simply broadcast packets to all ports (if you configure the
multicast engine correctly, by using the CLI).

Just like LJ's solution, this assumes that you are using Ethernet frames.

Best,

Antonin

On Sun, Jul 19, 2015 at 11:25 AM, LJ Wobker <ljw at barefootnetworks.com>
wrote:

> Sergio-
>
>
>
> This should be possible using virtualbox’s “internal networking” mode.
>
>
>
> See: https://www.virtualbox.org/manual/ch06.html
>
>
>
> Consider a case where you create 4 virtual machines: A,B,C,D.  on vm-A
> we’ll run our p4 switch and create three interfaces on that vm (call them
> A1, A2, A3).  On each of the other vms, just assume we have a single
> interface {interfaces B1, C1, D1}
>
>
>
> Then you should be able to configure three internal networks, one will
> connect A1-B1, one A2-C1, and one A3-D1.  Virtualbox should (I say should
> because I haven’t actually tried this…) then make any frames that leave
> interface A1 appear on B1, A2 onto C1, and so on.  The p4 switch on vm “A”
> can be programmed to do whatever you want to the frames as they transit
> your softswitch.
>
>
>
> To be **really** pedantic about the whole thing, I think that the vbox
> internal networking code is technically already bridging these frames, so
> I’m not sure whether having any non-standard ethernet headers would break
> this type of setup… but if you just want to get a multi-vm environment up
> and running within vbox, I think this will get you started.
>
>
>
> Depending on what you’re trying to accomplish, it **might** be
> easier/more scalable to look at the mininet/docker environment that’s been
> contributed recently.
>
>
>
> From the vbox documentation:  *Internal networks are created
> automatically as needed, i.e. there is no central configuration. Every
> internal network is identified simply by its name. Once there is more than
> one active virtual network card with the same internal network ID, the
> VirtualBox support driver will automatically "wire" the cards and act as a
> network switch. *
>
>
>
>
>
> --lj
>
>
>
>
>
>
>
>
>
>
>
> *From:* P4-dev [mailto:p4-dev-bounces at p4.org] *On Behalf Of *Sergio
> Gutierrez
> *Sent:* Friday, July 17, 2015 9:27 AM
> *To:* p4-dev at p4.org
> *Subject:* [P4-dev] Integrating virtualbox with P4 switches
>
>
>
> Hello all.
>
>
>
> Would it be possible to use a P4 switch to connect virtual machines
> running for example on virtualbox?
>
>
>
> Thanks in advance for the attention.
>
>
>
> --
>
> Sergio Gutiérrez
>
> _______________________________________________
> P4-dev mailing list
> P4-dev at p4.org
> Listinfo - http://mail.p4.org/mailman/listinfo/p4-dev_p4.org
> Archives - http://mail.p4.org/pipermail/p4-dev_p4.org/
>



-- 
Antonin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.p4.org/pipermail/p4-dev_lists.p4.org/attachments/20150721/77bfc13c/attachment-0001.html>


More information about the P4-dev mailing list