blob: 8c67c79b1888944890733a5ccc41e7064e66fb3c [file] [log] [blame]
John DeNiscoc4c72d22018-08-16 13:50:02 -04001.. _settingupenvironment:
2
3Setting up your environment
4===========================
5
6All of these exercises are designed to be performed on an Ubuntu 16.04 (Xenial) box.
7
John DeNiscob0464872020-07-28 12:15:16 -04008* If you have an Ubuntu 18.04 box on which you have sudo or root access, you can feel free to use that.
9* If you do not, a Vagrantfile is provided to setup a basic Ubuntu 18.04 box for you in the the steps below.
John DeNiscoc4c72d22018-08-16 13:50:02 -040010
11Install Virtual Box and Vagrant
12-------------------------------
13
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +020014You will need to install Virtual Box and Vagrant.
John DeNiscoc4c72d22018-08-16 13:50:02 -040015
16Create a Vagrant Directory
17---------------------------
18
19To get started create a directory for vagrant
20
21.. code-block:: console
22
23 $ mkdir vpp-tutorial
24 $ cd vpp-tutorial
25
26Create a file called **Vagrantfile** with the following contents:
27
28.. code-block:: ruby
29
30 # -*- mode: ruby -*-
31 # vi: set ft=ruby :
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +020032
John DeNiscoc4c72d22018-08-16 13:50:02 -040033 Vagrant.configure(2) do |config|
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +020034
John DeNiscob0464872020-07-28 12:15:16 -040035 config.vm.box = "bento/ubuntu-18.04"
John DeNiscoc4c72d22018-08-16 13:50:02 -040036 config.vm.box_check_update = false
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +020037
John DeNiscoc4c72d22018-08-16 13:50:02 -040038 vmcpu=(ENV['VPP_VAGRANT_VMCPU'] || 2)
39 vmram=(ENV['VPP_VAGRANT_VMRAM'] || 4096)
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +020040
John DeNiscoc4c72d22018-08-16 13:50:02 -040041 config.ssh.forward_agent = true
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +020042
John DeNiscoc4c72d22018-08-16 13:50:02 -040043 config.vm.provider "virtualbox" do |vb|
44 vb.customize ["modifyvm", :id, "--ioapic", "on"]
45 vb.memory = "#{vmram}"
46 vb.cpus = "#{vmcpu}"
47 #support for the SSE4.x instruction is required in some versions of VB.
48 vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.1", "1"]
49 vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.2", "1"]
50 end
51 end
52
53
54Running Vagrant
55---------------
56
57VPP runs in userspace. In a production environment you will often run it with
58DPDK to connect to real NICs or vhost to connect to VMs.mIn those circumstances
59you usually run a single instance of VPP.
60
61For purposes of this tutorial, it is going to be extremely useful to run multiple
62instances of vpp, and connect them to each other to form a topology. Fortunately,
63VPP supports this.
64
65When running multiple VPP instances, each instance needs to have specified a 'name'
66or 'prefix'. In the example below, the 'name' or 'prefix' is "vpp1". Note that only
67one instance can use the dpdk plugin, since this plugin is trying to acquire a lock
68on a file.
69
70Setting up VPP environment with Vagrant
71---------------------------------------------
72
73After setting up Vagrant, use these commands on your Vagrant directory to boot the VM:
74
75.. code-block:: console
76
77 $ vagrant up
78 $ vagrant ssh
John DeNiscob0464872020-07-28 12:15:16 -040079 $ sudo bash
80 # apt-get update
81 # reboot -n
John DeNiscoc4c72d22018-08-16 13:50:02 -040082 $ # Wait for the VM to reboot
83 $ vagrant ssh
84
85Install VPP
86------------
87
88Now that the VM is updated, we will install the VPP packages.
89
90For more on installing VPP please refer to :ref:`installingVPP`.
91
John DeNiscob0464872020-07-28 12:15:16 -040092For this tutorial we will install VPP by modifying the file
John DeNiscoc4c72d22018-08-16 13:50:02 -040093**/etc/apt/sources.list.d/99fd.io.list**.
94
John DeNiscob0464872020-07-28 12:15:16 -040095We write this file with the following contents:
John DeNiscoc4c72d22018-08-16 13:50:02 -040096
97.. code-block:: console
98
John DeNiscob0464872020-07-28 12:15:16 -040099 $ sudo bash
100 # echo "deb [trusted=yes] https://packagecloud.io/fdio/release/ubuntu bionic main" > /etc/apt/sources.list.d/99fd.io.list
101 #
102
103Get the key.
104
105.. code-block:: console
106
107 # curl -L https://packagecloud.io/fdio/release/gpgkey | sudo apt-key add -
108 #
John DeNiscoc4c72d22018-08-16 13:50:02 -0400109
110Then execute the following commands.
111
112.. code-block:: console
113
John DeNiscoc4c72d22018-08-16 13:50:02 -0400114 # apt-get update
John DeNiscob0464872020-07-28 12:15:16 -0400115 # apt-get install vpp vpp-plugin-core vpp-plugin-dpdk
John DeNiscoc4c72d22018-08-16 13:50:02 -0400116 #
117
118Stop VPP for this tutorial. We will be creating our own instances of VPP.
119
120.. code-block:: console
121
122 # service vpp stop
123 #
124
125
126Create some startup files
127--------------------------
128
129We will create some startup files for the use of this tutorial. Typically you will
130modify the startup.conf file found in /etc/vpp/startup.conf. For more information
Nathan Skrzypczak9ad39c02021-08-19 11:38:06 +0200131on this file refer to :ref:`configuration_reference`.
John DeNiscoc4c72d22018-08-16 13:50:02 -0400132
133When running multiple VPP instances, each instance needs to have
134specified a 'name' or 'prefix'. In the example below, the 'name' or 'prefix'
135is "vpp1". Note that only one instance can use the dpdk plugin, since this
136plugin is trying to acquire a lock on a file. These startup files we create will
137disable the dpdk plugin.
138
139Also in our startup files notice **api-segment**. **api-segment {prefix vpp1}**
140tells FD.io VPP how to name the files in /dev/shm/ for your VPP instance
141differently from the default. **unix {cli-listen /run/vpp/cli-vpp1.sock}**
142tells vpp to use a non-default socket file when being addressed by vppctl.
143
144Now create 2 files named startup1.conf and startup2.conf with the following
145content. These files can be located anywhere. We specify the location when we
146start VPP.
147
148startup1.conf:
149
150.. code-block:: console
151
152 unix {cli-listen /run/vpp/cli-vpp1.sock}
153 api-segment { prefix vpp1 }
154 plugins { plugin dpdk_plugin.so { disable } }
155
156startup2.conf:
157
158.. code-block:: console
159
160 unix {cli-listen /run/vpp/cli-vpp2.sock}
161 api-segment { prefix vpp2 }
162 plugins { plugin dpdk_plugin.so { disable } }