In this document we show how to build a VM with all the necessary dependencies and software to test and develop P4 applications.
RECOMMENDED: We provide an OVA image that can be simply imported to VirtualBox.
NOT RECOMMENDED: If you don't want to use a VM and you already have ubuntu 16.04 installed natively in your laptop you can also install the software manually. For that you can have a look at bin directory. However you do it at your own risk and we will not be able to help you if something goes wrong during the installation.
The VM is based on a Ubuntu 16.04.05 and after building it contains:
- The suite of P4 Tools (p4lang, p4utils, etc)
- Text editors with p4 highlighting (sublime, atom, emacs, vim)
- Wireshark
- Mininet network emulator
In order to build the VM you need to install the following software:
Add Vagrant guest additions plugin for better guest/host support.
vagrant plugin install vagrant-vbguest
The VM is configured to have 4 GB of RAM, 3 CPUS, and 64 GB of dynamic hard disk. To modify that you can edit the Vagrantfile before building. If needed (hopefully not), you can add more disk space to you virtual machine by following the steps shown in this Tutorial.
vagrant up
Note: the first time you do
vagrant up
the vm will be built which can take ~1h even with a good internet connection. Once the VM is built you should reboot it to get the graphical interface.
vagrant status
-- outputs status of the vagrant machinevagrant resume
-- resume a suspended machine (vagrant up works just fine for this as well)vagrant provision
-- forces reprovisioning of the vagrant machinevagrant reload
-- restarts vagrant machine, loads new Vagrantfile configurationvagrant reload --provision
-- restart the virtual machine and force provisioningvagrant halt
-- stops the vagrant machinevagrant suspend
-- suspends a virtual machine (remembers state)vagrant destroy
-- stops and deletes all traces of the vagrant machine
If you built the VM with vagrant you can ssh into it by running:
vagrant ssh
By default vagrant ssh
will login as vagrant
user, however you need to switch ** the user p4
** in order to be able to use the software.
You can achieve this in multiple ways:
-
Modify the
ssh
settings of vagrant. See ssh_settings. -
Use the following command to login with the user
p4
:
ssh p4@localhost -p 2223 #default port we use to forward SSH from host to guest
password: p4
- Use
vagrant ssh
to login with the uservagrant
, then switch to userp4
:
vagrant@p4:~$ su p4
The VM comes with two users, vagrant
and p4
, for both the password is the same than the user name. Always use the user p4
.
Building the vagrant image can take some time. If you want to have an already built VM you can download the Open Virtual Appliance (OVA) package and import it with a x86 software virtualizer that supports the format (this has been tested with VirtualBox only).
Pre-built OVA package: ova
Note: During the course we might need to update the OVA package.
In case you want to use an already existing VM or you just want to manually install all the dependencies and required software to run virtual networks with p4 switches, you can have a look at the install scripts used by the Vagrant setup.
If you are using Ubuntu 16.04.5, you can simply copy all the scripts in /bin
to your machine/VM and run then run the root-bootstrap.sh
script. However,
before doing that you will have to copy all the files in ./vm_files
to your home directory, and edit all the lines in the scripts that try to use them. Finally, run
the boostrap script:
sudo root-bootstrap.sh
run this command in the terminal:
sudo dpkg-reconfigure keyboard-configuration
When you do the first vagrant up
the ubuntu VM first runs apt-get update
which for some reason does not work with some old vagrant boxes
if you happen
to ran into that problem try to update your boxes with vagrant box update
.