### Example: Start echo server Source: https://s3-docs.fd.io/vpp/26.02/cli-reference/clis/clicmd_src_plugins_hs_apps_builtin_echo.html This example shows how to start an echo server using the 'test echo server' command, specifying the transport protocol and listening address. ```bash test echo server uri tcp://6.0.1.2:1234 ``` -------------------------------- ### Quickstart: Set Interface IP and Bring Up Source: https://s3-docs.fd.io/vpp/26.02/_sources/developer/devicedrivers/af_xdp.rst.txt Configure the IP address and bring the AF_XDP interface up. This is part of the basic setup after creating the AF_XDP interface. ```bash ~# vppctl set int ip addr enp216s0f0/0 1.1.1.1/24 ~# vppctl set int st enp216s0f0/0 up ``` -------------------------------- ### Quickstart: Bring Linux Interface Up and Promiscuous Source: https://s3-docs.fd.io/vpp/26.02/_sources/developer/devicedrivers/af_xdp.rst.txt Bring the Linux kernel interface up and set it to promiscuous mode. This is the initial step in the quickstart guide for AF_XDP driver setup. ```bash ~# ip l set dev enp216s0f0 promisc on up ``` -------------------------------- ### Start VPP Instance Source: https://s3-docs.fd.io/vpp/26.02/_sources/gettingstarted/progressivevpp/runningvpp.rst.txt Launches a VPP instance using a specified startup configuration file. Ensure the configuration file exists and VPP is installed. ```console $ sudo /usr/bin/vpp -c startup1.conf vlib_plugin_early_init:361: plugin path /usr/lib/vpp_plugins:/usr/lib/vpp_plugins load_one_plugin:189: Loaded plugin: abf_plugin.so (ACL based Forwarding) load_one_plugin:189: Loaded plugin: acl_plugin.so (Access Control Lists) load_one_plugin:189: Loaded plugin: avf_plugin.so (Intel Adaptive Virtual Function (AVF) Device Plugin) ......... $ ``` -------------------------------- ### Run Loopback Application Source: https://s3-docs.fd.io/vpp/26.02/interfacing/libmemif/examples_doc.html Start the loopback example application. This application demonstrates zero-copy packet transfer between two memif interfaces. ```bash ./examples/loopback ``` -------------------------------- ### Run DPDK Setup Script Source: https://s3-docs.fd.io/vpp/26.02/usecases/vppcloud/vppinaws.html Execute the DPDK setup script to install the necessary build environment and modules. ```bash $ ./dpdk-setup.sh ``` -------------------------------- ### Launch VPP Instance Source: https://s3-docs.fd.io/vpp/26.02/_sources/interfacing/go/index.rst.txt Start a VPP instance using the specified configuration file. Use the appropriate path depending on whether VPP was built from source or installed from a package. ```bash # If VPP was built from source: /build-root/install-vpp_debug-native/vpp/bin/vpp -c /tmp/startup.conf # If VPP was installed from package: vpp -c /tmp/startup.conf ``` -------------------------------- ### Start Loopback Application Source: https://s3-docs.fd.io/vpp/26.02/_sources/interfacing/libmemif/examples_doc.rst.txt Command to run the loopback example application, which sets up two memif endpoints for zero-copy packet transfer. ```bash ./examples/loopback ``` -------------------------------- ### Install VPP Dependencies Source: https://s3-docs.fd.io/vpp/26.02/developer/build-run-debug/building.html Run this 'make' command to install the necessary dependencies for FD.io VPP. Proxy setup might be required if the download hangs. ```bash $ make install-dep Hit:1 http://us.archive.ubuntu.com/ubuntu xenial InRelease Get:2 http://us.archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB] Get:3 http://security.ubuntu.com/ubuntu xenial-security InRelease [107 kB] Get:4 http://us.archive.ubuntu.com/ubuntu xenial-backports InRelease [107 kB] Get:5 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [803 kB] Get:6 http://us.archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages [732 kB] ... ... Update-alternatives: using /usr/lib/jvm/java-8-openjdk-amd64/bin/jmap to provide /usr/bin/jmap (jmap) in auto mode Setting up default-jdk-headless (2:1.8-56ubuntu2) ... Processing triggers for libc-bin (2.23-0ubuntu3) ... Processing triggers for systemd (229-4ubuntu6) ... Processing triggers for ureadahead (0.100.0-19) ... Processing triggers for ca-certificates (20160104ubuntu1) ... Updating certificates in /etc/ssl/certs... 0 added, 0 removed; done. Running hooks in /etc/ca-certificates/update.d... done. done. ``` -------------------------------- ### Displaying VPP Version with VAT2 Source: https://s3-docs.fd.io/vpp/26.02/_sources/interfacing/vat2/index.rst.txt This example shows how to start VPP and then use VAT2 with the '-d' flag to print debug information and VPP's version. ```console # kill $( pgrep vpp ) # vpp "unix { cli-listen /run/vpp/cli-vpp0.sock log /var/log/vpp/vpp0.log } api-trace { on } statseg { socket-name /run/vpp/statseg-vpp0.sock }" # vat2 -d show_version '{}' ``` -------------------------------- ### Show Default Hardware-Interfaces Example Source: https://s3-docs.fd.io/vpp/26.02/cli-reference/interface/hardware.html Example of how to display default data for all interfaces. ```bash vpp# show hardware-interfaces ``` -------------------------------- ### Install Make Source: https://s3-docs.fd.io/vpp/26.02/_sources/developer/build-run-debug/building.rst.txt Ensure the 'make' utility is installed, as it is required for building VPP. If not present, install it using apt. ```console sudo apt install make ``` -------------------------------- ### Start ICMP Responder Application Source: https://s3-docs.fd.io/vpp/26.02/interfacing/libmemif/examples_doc.html Execute the ICMP responder example application. This application will attempt to connect to VPP in slave mode. ```bash ./examples/icmp_responder ``` -------------------------------- ### Install VPP and Prerequisites Source: https://s3-docs.fd.io/vpp/26.02/_sources/usecases/containers/containerSetup.rst.txt Commands to set up DHCP, install curl, add the VPP repository, update package lists, and install VPP. It also includes a step to modify the VPP startup configuration to disable PCI access. ```console root@cone:/# dhclient root@cone:/# apt-get install -y curl root@cone:/# curl -s https://packagecloud.io/install/repositories/fdio/release/script.deb.sh | sudo bash root@cone:/# apt-get update root@cone:/# apt-get install -y --force-yes vpp root@cone:/# sh -c 'echo "\ndpdk {\n no-pci\n}" >> /etc/vpp/startup.conf' ``` -------------------------------- ### Install Make Utility Source: https://s3-docs.fd.io/vpp/26.02/developer/build-run-debug/building.html Ensure the 'make' utility is installed before proceeding with VPP dependency installation. This command installs 'make' on Ubuntu systems. ```bash $ sudo apt install make ``` -------------------------------- ### Install Dependencies Source: https://s3-docs.fd.io/vpp/26.02/_sources/developer/build-run-debug/code_coverage.rst.txt Run this command to install the necessary packages for code coverage. ```bash make install-deps ``` -------------------------------- ### Show Verbose Hardware-Interfaces Example Source: https://s3-docs.fd.io/vpp/26.02/cli-reference/interface/hardware.html Example of how to display verbose data for an interface by name and software index. ```bash vpp# show hardware-interfaces GigabitEthernet7/0/0 2 verbose ``` -------------------------------- ### Example VPP startup.conf file Source: https://s3-docs.fd.io/vpp/26.02/_sources/configuration/config_getting_started.rst.txt This is a sample startup.conf file demonstrating common configuration sections like 'unix', 'api-trace', and 'dpdk'. Ensure the file path is correctly provided to VPP using the -c option. ```console $ cat /etc/vpp/startup.conf unix { nodaemon log /var/log/vpp/vpp.log full-coredump cli-listen localhost:5002 } api-trace { on } dpdk { dev 0000:03:00.0 } ``` -------------------------------- ### Start VPP Service Source: https://s3-docs.fd.io/vpp/26.02/_sources/usecases/containers/containerSetup.rst.txt Command to start the VPP service within the container after installation and configuration. ```console root@cone:/# service vpp start ``` -------------------------------- ### Quickstart: Set up AF_XDP interface Source: https://s3-docs.fd.io/vpp/26.02/developer/devicedrivers/af_xdp.html Steps to quickly set up an AF_XDP interface: bring up the Linux interface in promiscuous mode, create the AF_XDP interface in VPP, and configure IP addressing and state. ```bash ~# ip l set dev enp216s0f0 promisc on up ``` ```bash ~# vppctl create int af_xdp host-if enp216s0f0 num-rx-queues all ``` ```bash ~# vppctl set int ip addr enp216s0f0/0 1.1.1.1/24 ~# vppctl set int st enp216s0f0/0 up ~# vppctl ping 1.1.1.100 ``` -------------------------------- ### Quickstart: Create AF_XDP Interface Source: https://s3-docs.fd.io/vpp/26.02/_sources/developer/devicedrivers/af_xdp.rst.txt Create an AF_XDP interface using a specified host interface and configuring it to capture all available RX queues. This is a key step in setting up the AF_XDP driver. ```bash ~# vppctl create int af_xdp host-if enp216s0f0 num-rx-queues all ``` -------------------------------- ### Implement Suite Setup Source: https://s3-docs.fd.io/vpp/26.02/developer/extras/kube-test.html Implement the SetupSuite method to initialize pods and configure network settings like MTU and worker counts before tests run. ```go func (s *MySuite) SetupSuite() { s.BaseSuite.SetupSuite() // initialize pods s.Pods.Client = s.getPodsByName("client-generic") s.Pods.Server = s.getPodsByName("server-generic") ... s.SetMtuAndRestart("mtu: 0", "tcp { mtu 8960 }\n cpu { workers 0 }") // Add custom setup code here } ``` -------------------------------- ### Install Stats FUSE Filesystem Source: https://s3-docs.fd.io/vpp/26.02/developer/extras/vpp_stats_fs.html Builds and installs the VPP stats segment FUSE filesystem binary. This is a prerequisite for starting the filesystem. ```makefile make install ``` -------------------------------- ### Verify Libmemif Installation Source: https://s3-docs.fd.io/vpp/26.02/interfacing/libmemif/buildinstructions_doc.html Runs the icmp_responder example application to verify that libmemif has been installed correctly. Use the -? flag to display help information. ```bash ./examples/icmp_responder -? ``` -------------------------------- ### Example VPP Startup Configuration File Source: https://s3-docs.fd.io/vpp/26.02/configuration/config_getting_started.html A sample startup.conf file demonstrating common configuration sections like 'unix', 'api-trace', and 'dpdk'. This file is typically located at /etc/vpp/startup.conf. ```text $ cat /etc/vpp/startup.conf unix { nodaemon log /var/log/vpp/vpp.log full-coredump cli-listen localhost:5002 } api-trace { on } dpdk { dev 0000:03:00.0 } ``` -------------------------------- ### Verify Libmemif Installation Source: https://s3-docs.fd.io/vpp/26.02/_sources/interfacing/libmemif/buildinstructions_doc.rst.txt Verifies the libmemif installation by running an example application. Use the -? flag to display the help message and confirm the application is functional. ```bash ./examples/icmp_responder -? ``` -------------------------------- ### Example Configuration using CLI Source: https://s3-docs.fd.io/vpp/26.02/developer/plugins/dhcp6_pd.html Demonstrates a typical configuration sequence using VPP CLI commands to set up an interface and enable DHCPv6 PD client with a prefix group. ```bash set int state GigabitEthernet0/8/0 up dhcp6 pd client GigabitEthernet0/8/0 prefix group my-dhcp6-pd-group set ip6 address GigabitEthernet0/8/0 prefix group my-dhcp6-pd-group ::7/64 ``` -------------------------------- ### Implement Suite Setup Source: https://s3-docs.fd.io/vpp/26.02/_sources/developer/extras/kube-test.rst.txt Implement the SetupSuite method to initialize pods and configure network settings like MTU and VPP worker count. This method runs once before any tests in the suite. ```go func (s *MySuite) SetupSuite() { s.BaseSuite.SetupSuite() // initialize pods s.Pods.Client = s.getPodsByName("client-generic") s.Pods.Server = s.getPodsByName("server-generic") ... s.SetMtuAndRestart("mtu: 0", "tcp { mtu 8960 }\n cpu { workers 0 }") // Add custom setup code here } ``` -------------------------------- ### Update OS and Install Curl Source: https://s3-docs.fd.io/vpp/26.02/_sources/gettingstarted/installing/ubuntu.rst.txt Run these commands to update and upgrade your Ubuntu OS and install the curl package, which is needed to download the setup script. ```console sudo apt-get update sudo apt-get dist-upgrade -y sudo apt-get install curl ``` -------------------------------- ### Start ICMP Responder Application Source: https://s3-docs.fd.io/vpp/26.02/_sources/interfacing/libmemif/examples_doc.rst.txt Command to run the ICMP responder example application, which acts as a memif slave. ```bash ./examples/icmp_responder ``` -------------------------------- ### Configure VPP Startup Source: https://s3-docs.fd.io/vpp/26.02/_sources/interfacing/go/index.rst.txt Create a VPP startup configuration file. This example configures a socket for CLI listening and disables the DPDK plugin. ```bash mkdir -p /tmp/vpp cat << EOF > /tmp/startup.conf unix {nodaemon cli-listen /tmp/vpp/api.sock} plugins { path /vpp/build-root/install-vpp_debug-native/vpp/lib/x86_64-linux-gnu/vpp_plugins plugin dpdk_plugin.so { disable } } EOF ``` -------------------------------- ### Get Root Privileges Source: https://s3-docs.fd.io/vpp/26.02/usecases/containers/containerCreation.html Obtain root privileges to perform system-level operations required for VPP and container setup. ```bash # sudo bash ``` -------------------------------- ### Install and Initialize LXD Source: https://s3-docs.fd.io/vpp/26.02/_sources/usecases/container_test.rst.txt Install the LXD snap and initialize it. During initialization, create a storage pool named 'vpp' of type 'zfs' or 'files'. ```bash # snap install lxd # lxd init ``` -------------------------------- ### STN Daemon Log Excerpt Source: https://s3-docs.fd.io/vpp/26.02/_sources/usecases/contiv/SINGLE_NIC_SETUP.rst.txt An example of expected log output from the STN daemon, indicating the GRPC server is starting. ```text 2018/02/23 10:08:34 Starting the STN GRPC server at port 50051 ``` -------------------------------- ### Start VPP using a configuration file Source: https://s3-docs.fd.io/vpp/26.02/_sources/configuration/config_getting_started.rst.txt Instruct VPP to load its configuration from a specified file using the -c option. This is the typical method for applying startup configurations. ```console $ sudo /usr/bin/vpp -c /etc/vpp/startup.conf ``` -------------------------------- ### Set up Master Container Image Source: https://s3-docs.fd.io/vpp/26.02/usecases/container_test.html Launch a master container from an Ubuntu 22.04 image, install necessary packages like 'make' and 'ssh', set up the VPP workspace, and install dependencies. Ensure SSH public key authentication is functional. ```bash # lxd launch ubuntu:22.04 respond # lxc exec respond bash respond# cd /scratch/my-vpp-workspace respond# apt-get install make ssh respond# make install-dep respond# exit # lxc stop respond ``` -------------------------------- ### Useful LXC Container Commands Source: https://s3-docs.fd.io/vpp/26.02/usecases/containers/containerCreation.html A collection of common LXC commands for managing containers, including listing, starting, getting info, stopping, and destroying them. ```bash $ sudo lxc-ls --fancy $ sudo lxc-start --name u1 --daemon $ sudo lxc-info --name u1 $ sudo lxc-stop --name u1 $ sudo lxc-destroy --name u1 ``` -------------------------------- ### Start Feature Arc Walk Source: https://s3-docs.fd.io/vpp/26.02/developer/corearchitecture/featurearcs.html In the head-of-arc node, get the arc index and then call vnet_feature_arc_start to initialize packet metadata for walking the feature arc. ```c ip_lookup_main_t *lm = &im->lookup_main; arc = lm->ucast_feature_arc_index; vnet_feature_arc_start (arc, sw_if_index0, &next, b0); ``` -------------------------------- ### Install and Initialize LXD Source: https://s3-docs.fd.io/vpp/26.02/usecases/container_test.html Install the LXD snap package and initialize it. It is recommended to use the snap version for the latest updates. During initialization, accept defaults except for the storage pool, which should be named 'vpp'. ```bash # snap install lxd # lxd init ``` -------------------------------- ### Start and configure VPP initiator Source: https://s3-docs.fd.io/vpp/26.02/_sources/usecases/ikev2/vpp_init_sswan_resp.rst.txt Initializes the VPP instance and configures its network interfaces, IP addresses, and IKEv2 profiles. ```bash sudo /usr/bin/vpp unix { \ cli-listen /tmp/vpp.sock \ gid $(id -g) } \ api-segment { prefix vpp } \ plugins { plugin dpdk_plugin.so { disable } } ``` ```vppcli create host-interface name gw set interface ip addr host-gw 192.168.10.2/24 set interface state host-gw up create host-interface name priv set interface ip addr host-priv 192.168.3.1/24 set interface state host-priv up ikev2 profile add pr1 ikev2 profile set pr1 auth shared-key-mic string Vpp123 ikev2 profile set pr1 id local fqdn roadwarrior.vpp ikev2 profile set pr1 id remote fqdn sswan.vpn.example.com ikev2 profile set pr1 traffic-selector local ip-range 192.168.3.0 - 192.168.3.255 port-range 0 - 65535 protocol 0 ikev2 profile set pr1 traffic-selector remote ip-range 192.168.5.0 - 192.168.5.255 port-range 0 - 65535 protocol 0 ikev2 profile set pr1 responder host-gw 192.168.10.1 ikev2 profile set pr1 ike-crypto-alg aes-gcm-16 256 ike-dh modp-2048 ikev2 profile set pr1 esp-crypto-alg aes-gcm-16 256 create ipip tunnel src 192.168.10.2 dst 192.168.10.1 ikev2 profile set pr1 tunnel ipip0 ip route add 192.168.5.0/24 via 192.168.10.1 ipip0 set interface unnumbered ipip0 use host-gw ``` -------------------------------- ### Example VPP Config Utility Run Source: https://s3-docs.fd.io/vpp/26.02/_sources/developer/extras/vpp_config.rst.txt Demonstrates the interactive prompts and output when running the VPP configuration utility, including system information display. ```console # pip install vpp-config # vpp-config Welcome to the VPP system configuration utility These are the files we will modify: /etc/vpp/startup.conf /etc/sysctl.d/80-vpp.conf /etc/default/grub Before we change them, we'll create working copies in ``/usr/local/vpp/vpp-config/dryrun`` Please inspect them carefully before applying the actual configuration (option 3)! What would you like to do? 1) Show basic system information 2) Dry Run (Will save the configuration files in /usr/local/vpp/vpp-config/dryrun for inspection) and user input in /usr/local/vpp/vpp-config/configs/auto-config.yaml 3) Full configuration (WARNING: This will change the system configuration) 4) Install/Uninstall VPP. 5) Dry Run from /usr/local/vpp/vpp-config/auto-config.yaml (will not ask questions). 6) Install QEMU patch (Needed when running openstack). 9 or q) Quit Command: 1 NODE: DUT1 CPU: Model name: Intel(R) Xeon(R) CPU E5-2667 v3 @ 3.20GHz CPU(s): 32 Thread(s) per core: 2 Core(s) per socket: 8 Socket(s): 2 NUMA node0 CPU(s): 0-7,16-23 NUMA node1 CPU(s): 8-15,24-31 CPU max MHz: 3600.0000 CPU min MHz: 1200.0000 SMT: Enabled VPP Threads: (Name:Cpu Number) Grub Command Line: Current: BOOT_IMAGE=/boot/vmlinuz-4.4.0-96-generic root=UUID=d760b82f-f37b-47e2-9815-db8d479a3557 ro Configured: GRUB_CMDLINE_LINUX_DEFAULT="" Huge Pages: Total System Memory : 65863484 kB Total Free Memory : 41325924 kB Actual Huge Page Total : 8192 Configured Huge Page Total : 1024 Huge Pages Free : 8192 Huge Page Size : 2048 kB Devices: Status: Not Installed What would you like to do? 1) Show basic system information 2) Dry Run (Will save the configuration files in /usr/local/vpp/vpp-config/dryrun for inspection) and user input in /usr/local/vpp/vpp-config/configs/auto-config.yaml 3) Full configuration (WARNING: This will change the system configuration) 4) Install/Uninstall VPP. ``` -------------------------------- ### Iperf3 Bandwidth Test Source: https://s3-docs.fd.io/vpp/26.02/usecases/simpleperf/iperf3.html Measure network bandwidth between two hosts using iperf3. This example shows starting the iperf3 client on NET2S22C05 to connect to the server on CSP2S22C04. ```bash NET2S22C05$ iperf3 -c 10.1.1.2 Connecting to host 10.1.1.2, port 5201 [ 4] local 10.2.2 port 54074 connected to 10.1.1.2 port 5201 [ ID] Interval Transfer Bandwidth Retr Cwnd [ 4] 0.00-1.00 sec 936 MBytes 7.85 Gbits/sec 2120 447 KBytes [ 4] 1.00-2.00 sec 952 MBytes 7.99 Gbits/sec 1491 611 KBytes [ 4] 2.00-3.00 sec 949 MBytes 7.96 Gbits/sec 2309 604 KBytes [ 4] 3.00-4.00 sec 965 MBytes 8.10 Gbits/sec 1786 571 KBytes [ 4] 4.00-5.00 sec 945 MBytes 7.93 Gbits/sec 1984 424 KBytes [ 4] 5.00-6.00 sec 946 MBytes 7.94 Gbits/sec 1764 611 KBytes [ 4] 6.00-7.00 sec 979 MBytes 8.21 Gbits/sec 1499 655 KBytes [ 4] 7.00-8.00 sec 980 MBytes 8.22 Gbits/sec 1182 867 KBytes [ 4] 8.00-9.00 sec 1008 MBytes 8.45 Gbits/sec 945 625 KBytes [ 4] 9.00-10.00 sec 1015 MBytes 8.51 Gbits/sec 1394 611 KBytes - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bandwidth Retr [ 4] 0.00-10.00 sec 9.45 GBytes 8.12 Gbits/sec 16474 sender [ 4] 0.00-10.00 sec 9.44 GBytes 8.11 Gbits/sec receiver iperf Done. ``` -------------------------------- ### Update and Upgrade Ubuntu OS Source: https://s3-docs.fd.io/vpp/26.02/gettingstarted/installing/ubuntu.html Run these commands to update your package list, upgrade existing packages, and install the curl utility, which is needed to download the setup script. ```bash sudo apt-get update sudo apt-get dist-upgrade -y sudo apt-get install curl ``` -------------------------------- ### Implement Suite Setup Method Source: https://s3-docs.fd.io/vpp/26.02/_sources/developer/extras/hs-test.rst.txt The SetupSuite method is executed once before any tests in the suite. It's crucial for configuring the network topology and loading container configurations. ```go func (s *MySuite) SetupSuite() { s.HstSuite.SetupSuite() // Add custom setup code here s.ConfigureNetworkTopology("myNetworkTopology") s.LoadContainerTopology("myContainerTopology") s.Interfaces.Server = s.GetInterfaceByName("interfaceName") s.Containers.ServerVpp = s.GetContainerByName("containerName") ... } ``` -------------------------------- ### Set up .kube Directory Source: https://s3-docs.fd.io/vpp/26.02/_sources/usecases/contiv/MANUAL_INSTALL.rst.txt Configure the .kube directory for a regular user after successful master initialization. ```bash mkdir -p $HOME/.kube sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config sudo chown $(id -u):$(id -g) $HOME/.kube/config ``` -------------------------------- ### Start tx packet capture Source: https://s3-docs.fd.io/vpp/26.02/cli-reference/clis/clicmd_src_vnet.html Initiates a transmission (tx) packet capture. This example sets the buffer depth to 35 packets, specifies the interface, and names the output file. ```cli pcap trace tx max 35 intfc GigabitEthernet0/8/0 file vppTest.pcap ``` -------------------------------- ### Execute Commands on All Containers Source: https://s3-docs.fd.io/vpp/26.02/_sources/usecases/container_test.rst.txt Use the 'lxc-foreach' script to start or stop all containers in the list. The script parses 'lxc info' to get container IP addresses for SSH connections. ```bash $ lxc-foreach start ``` ```bash $ lxc-foreach ssh ``` ```bash #!/bin/bash set -u export containers="respond initiate initiatehost respondhost" if [ x$1 = "x" ] ; then echo missing command exit 1 fi if [ $1 = "ssh" ] ; then for c in $containers do inet=`lxc info $c | grep 10.38.33 | sed "s/.*inet://" | sed "s/\/24.*//" | tr -d " "` if [ x$inet != "x" ] ; then gnome-terminal --title "$c(ssh)" --command "/usr/bin/ssh -Y root@$inet" fi done exit 0 fi for c in $containers do inet=`lxc info $c | grep 10.38.33 | sed "s/.*inet://" | sed "s/\/24.*//" | tr -d " "` if [ x$1 = "xstart" ] ; then echo Starting $c lxc start $c elif [ x$1 = "xstop" ] ; then echo Stopping $c lxc stop $c elif [ x$inet != "x" ] ; then echo lxc $1 $c lxc $1 $c fi done exit 0 ``` -------------------------------- ### Implement Test Setup Source: https://s3-docs.fd.io/vpp/26.02/developer/extras/kube-test.html Implement the SetupTest method to set up the test context before each individual test case is executed. ```go func (s *MySuite) SetupTest() { s.MainContext = context.Background() s.BaseSuite.SetupTest() // Add custom setup code here } ``` -------------------------------- ### Parse HTTP Headers Source: https://s3-docs.fd.io/vpp/26.02/_sources/developer/plugins/http.rst.txt Initializes a header table buffer, reads raw headers from the transport FIFO, and builds a header table for parsing. This example shows how to get the 'Accept' header. ```C #include if (msg.data.headers_len) { http_header_table_t ht = HTTP_HEADER_TABLE_NULL; /* initialize header table buffer */ http_init_header_table_buf (&ht, msg); /* read raw headers into buffer */ rv = svm_fifo_peek (ts->rx_fifo, msg.data.headers_offset, msg.data.headers_len, ht.buf); ASSERT (rv == msg.data.headers_len); /* build header table */ http_build_header_table (&ht, msg); /* get Accept header */ ``` -------------------------------- ### Set up VPP interfaces for testing Source: https://s3-docs.fd.io/vpp/26.02/developer/tests/overview.html The setUpClass method initializes the test environment by creating and configuring VPP interfaces, including setting IP addresses and resolving ARP. ```python @classmethod def setUpClass(self): super(IP4FwdTestCase, self).setUpClass() self.create_pg_interfaces(range(2)) # create pg0 and pg1 for i in self.pg_interfaces: i.admin_up() # put the interface up i.config_ip4() # configure IPv4 address on the interface i.resolve_arp() # resolve ARP, so that we know VPP MAC ``` -------------------------------- ### Start VPP Testbench Containers Source: https://s3-docs.fd.io/vpp/26.02/_sources/usecases/vpp_testbench/labs/intro_to_vpp/index.rst.txt Launches the VPP testbench client and server containers using the 'make start' command. This also creates necessary Docker networks. ```shell vagrant@ubuntu-focal$> make start # Create Docker bridge network. bash -c " . vpp_testbench_helpers.sh; host_only_create_docker_networks; " 6e071e533e239380b2fe92d6e0844c42736ec186226fbb20d89706f9a80f935f # Launch the containers. bash -c " . vpp_testbench_helpers.sh; host_only_run_testbench_client_container vpp-testbench-client:local; host_only_run_testbench_server_container vpp-testbench-server:local; " 720fed0a94fd715694d73a41317f05a3f36860a6d5ae54db2d7cb7f2dcaf7924 ccf166993d09e399f7b10d372c47cc9e72ce6092ef70ea206c699263da844e1b # Entrypoint scripts will bring up the various links. # Use "docker ps" to check status of containers, see if their health # probes are working as expected (i.e. "health"), etc. ``` -------------------------------- ### Example test case for Nginx RPS Source: https://s3-docs.fd.io/vpp/26.02/developer/extras/kube-test.html A Go test case demonstrating deployment of Nginx and Ab pods, configuration of Nginx, and running an ab test to measure RPS. It includes setup, execution, and assertion steps. ```go package main import ( "context" "time" "errors" . "fd.io/kube-test/infra" ) func init(){ RegisterKubeTests(NginxRpsTest) } func NginxRpsTest(s *KubeSuite) { ctx, cancel := context.WithTimeout(s.MainContext, time.Minute*3) defer cancel() // deploy pods defined in kubernetes/pod-definitions-template.yaml s.DeployPod(s.Pods.Nginx) s.DeployPod(s.Pods.Ab) // helper function s.CreateNginxConfig(s.Pods.Nginx) // goroutine to start nginx server go func() { defer GinkgoRecover() out, err := s.Pods.Nginx.Exec(ctx, []string{"/bin/bash", "-c", "nginx -c /nginx.conf"}) if !errors.Is(err, context.Canceled) { AssertNil(err, out) } }() // wait for nginx to start up time.Sleep(time.Second * 2) // run ab out, err = s.Pods.Ab.Exec(ctx, []string{"ab", "-k", "-r", "-n", "1000000", "-c", "1000", "http://" + s.Pods.Nginx.IpAddress + ":8081/64B.json"}) Log(out) AssertNil(err) } ``` -------------------------------- ### Libmemif Example Application Help Source: https://s3-docs.fd.io/vpp/26.02/_sources/interfacing/libmemif/buildinstructions_doc.rst.txt Displays the help information for the icmp_responder example application, showing available options and default values. ```text LIBMEMIF EXAMPLE APP: icmp_responder_example ============================== libmemif version: 4.0, memif version: 2.0 ============================== In this example, memif endpoint connects to an external application. The example application can resolve ARP and reply to ICMPv4 packets. The program will exit once the interface is disconnected. ============================== Usage: icmp_responder [OPTIONS] Options: -r Interface role . Default: slave -s Socket path. Supports abstract socket using @ before the path. Default: /run/vpp/memif.sock -i Interface id. Default: 0 -a IPv4 address. Default: 192.168.1.1 -h Mac address. Default: aa:aa:aa:aa:aa:aa -? Show help and exit. -v Show libmemif and memif version information and exit. ``` -------------------------------- ### Main Entrypoint Function Source: https://s3-docs.fd.io/vpp/26.02/usecases/vpp_testbench/index.html The main function orchestrates the testbench setup. It ensures cleanup via trap, creates the VPP context, initializes the health check responder, starts the web servers in the background, and enters the main worker loop. ```bash function main() { # Make sure we always cleanup. trap context_destroy EXIT # Bring up interfaces. context_create # Enable health check responder. health_check_init & # Bring up test web servers. web_server_vxlan_linux & web_server_vpp_tap & # Enter our worker loop. context_loop } ``` -------------------------------- ### Enable Sample Plugin Source: https://s3-docs.fd.io/vpp/26.02/developer/plugindoc/sample_plugin_doc.html Use this CLI command to enable the sample plugin, specifying the macswap algorithm and an interface name. ```bash sample macswap ``` -------------------------------- ### Install Essential Packages on Ubuntu Source: https://s3-docs.fd.io/vpp/26.02/usecases/vppcloud/vppinaws.html Update and install essential packages required for VPP installation on an Ubuntu 16.04 instance. ```bash $ sudo apt-get update $ sudo apt-get upgrade $ sudo apt-get install build-essential $ sudo apt-get install python-pip $ sudo apt-get install libnuma-dev $ sudo apt-get install make $ sudo apt install libelf-dev ``` -------------------------------- ### Initialize Go Project and Add govpp Dependency Source: https://s3-docs.fd.io/vpp/26.02/_sources/interfacing/go/index.rst.txt Initialize your Go module and add the govpp library as a dependency. This prepares your project to use the GoVPP client. ```bash cd "$HOME/myproject" go mod init mygit.com/myproject go get go.fd.io/govpp@latest ``` -------------------------------- ### Install GDB Package Source: https://s3-docs.fd.io/vpp/26.02/_sources/developer/build-run-debug/running_vpp.rst.txt Installs the GDB debugger package on Debian-based systems. Ensure GDB is installed before running VPP with debugging. ```bash $ sudo apt install gdb ``` -------------------------------- ### Load Startup Configuration from File Source: https://s3-docs.fd.io/vpp/26.02/configuration/reference.html Reads and executes operational configuration commands from a specified file. The 'exec' and 'startup-config' keywords are aliases. ```text startup-config /usr/share/vpp/scripts/interface-up.txt ``` -------------------------------- ### Install STN Daemon Source: https://s3-docs.fd.io/vpp/26.02/_sources/usecases/contiv/SINGLE_NIC_SETUP.rst.txt Installs the STN daemon on nodes with a single NIC. Ensure Docker is installed and configured for shared mounts before running. ```bash bash <(curl -s https://raw.githubusercontent.com/contiv/vpp/master/k8s/stn-install.sh) ``` -------------------------------- ### Run and Configure Initiator VPP Source: https://s3-docs.fd.io/vpp/26.02/_sources/usecases/ikev2/2_vpp.rst.txt Start the VPP initiator instance and configure its network interfaces, IKEv2 profile, and IPsec tunnel. This sets up the client side of the connection. ```bash sudo /usr/bin/vpp unix { \ cli-listen /tmp/vpp_init.sock \ gid $(id -g) } \ api-segment { prefix vpp } \ plugins { plugin dpdk_plugin.so { disable } } ``` ```vppcli create host-interface name ifinit set interface ip addr host-ifinit 192.168.10.1/24 set interface state host-ifinit up create host-interface name client set interface ip addr host-client 192.168.5.1/24 set interface state host-client up ikev2 profile add pr1 ikev2 profile set pr1 auth shared-key-mic string Vpp123 ikev2 profile set pr1 id local ipv4 192.168.10.1 ikev2 profile set pr1 id remote ipv4 192.168.10.2 ikev2 profile set pr1 traffic-selector remote ip-range 192.168.3.0 - 192.168.3.255 port-range 0 - 65535 protocol 0 ikev2 profile set pr1 traffic-selector local ip-range 192.168.5.0 - 192.168.5.255 port-range 0 - 65535 protocol 0 ikev2 profile set pr1 responder host-ifinit 192.168.10.2 ikev2 profile set pr1 ike-crypto-alg aes-gcm-16 256 ike-dh modp-2048 ikev2 profile set pr1 esp-crypto-alg aes-gcm-16 256 create ipip tunnel src 192.168.10.1 dst 192.168.10.2 ikev2 profile set pr1 tunnel ipip0 ip route add 192.168.3.0/24 via 192.168.10.2 ipip0 set interface unnumbered ipip0 use host-ifinit ``` -------------------------------- ### Initialize VPP Testbench Client Container Source: https://s3-docs.fd.io/vpp/26.02/usecases/vpp_testbench/index.html Sets up VXLAN overlay, brings up VPP with specified configurations, and creates VPP-controlled interfaces (memif and tap) bridged together. Ensure necessary environment variables like VXLAN_ID_LINUX, VXLAN_PORT, etc., are set before execution. ```bash #!/bin/bash ################################################################################ # @brief: Launcher/entrypoint script plus helper functions for "client # side" container in the VPP testbench. # @author: Matthew Giassa # @copyright: (C) Cisco 2021. ################################################################################ ################################################################################ # Dependencies. ################################################################################ # Import common settings for server and client. This is supplied via the # Dockerfile build. # shellcheck disable=SC1091 . vpp_testbench_helpers.sh ################################################################################ # Globals. ################################################################################ # VPP instance socket. export VPP_SOCK=/run/vpp/vpp.testbench-client.sock # Alias for vppctl that uses the correct socket name. export VPPCTL="vppctl -s ${VPP_SOCK}" # Our "Docker bridge network". Don't change this value. export NET_IF_DOCKER="eth0" # Name of link associated with our VXLAN. export LINK_VXLAN_LINUX="vxlan-vid-${VXLAN_ID_LINUX}" ################################################################################ # Function definitions. ################################################################################ #------------------------------------------------------------------------------# # @brief: Alias for vppctl (knowing which API socket to use). function vc() { vppctl -s "${VPP_SOCK}" "${@}" } #------------------------------------------------------------------------------# # @brief: Used to initialize/configure the client container once it's up and # running. function context_create() { set -x echo "Running client. Host: $(hostname)" local mtu # Setup VXLAN overlay. ip link add "${LINK_VXLAN_LINUX}" \ type vxlan \ id "${VXLAN_ID_LINUX}" \ dstport "${VXLAN_PORT}" \ local "${CLIENT_BRIDGE_IP_DOCKER}" \ group "${MC_VXLAN_ADDR_LINUX}" \ dev "${NET_IF_DOCKER}" \ ttl 1 ip link set "${LINK_VXLAN_LINUX}" up ip addr add "${CLIENT_VXLAN_IP_LINUX}/${MASK_VXLAN_LINUX}" dev "${LINK_VXLAN_LINUX}" # Get MTU of interface. VXLAN must use a smaller value due to overhead. mtu="$(cat /sys/class/net/${NET_IF_DOCKER}/mtu)" # Decrease VXLAN MTU. This should already be handled for us by iproute2, but # just being cautious. ip link set dev "${LINK_VXLAN_LINUX}" mtu "$((mtu - 50))" # Bring-up VPP and create tap interfaces and VXLAN tunnel. vpp \ unix '{' log /tmp/vpp1.log full-coredump cli-listen ${VPP_SOCK} '}' \ api-segment '{' prefix vpp1 '}' \ api-trace '{' on '}' \ dpdk '{' uio-driver uio_pci_generic no-pci '}' # Wait for VPP to come up. while ! ${VPPCTL} show log; do sleep 1 done # Bring up the memif interface and assign an IP to it. ${VPPCTL} create interface memif id 0 slave sleep 1 ${VPPCTL} set int state memif0/0 up ${VPPCTL} set int ip address memif0/0 "${CLIENT_VPP_MEMIF_IP}/${VPP_MEMIF_NM}" # Create VPP-controlled tap interface bridged to the memif. ${VPPCTL} create tap id 0 host-if-name vpp-tap-0 sleep 1 ${VPPCTL} set interface state tap0 up ip addr add "${CLIENT_VPP_TAP_IP_MEMIF}/${VPP_TAP_NM}" dev vpp-tap-0 ${VPPCTL} set interface l2 bridge tap0 "${VPP_BRIDGE_DOMAIN_TAP}" ${VPPCTL} set interface l2 bridge memif0/0 "${VPP_BRIDGE_DOMAIN_TAP}" } #------------------------------------------------------------------------------# # @brief: Used to shutdown/cleanup the client container. function context_destroy() { # OS will reclaim interfaces and resources when container is terminated. : } #------------------------------------------------------------------------------# # @brief: Client worker loop to keep the container alive. Just idles. function context_loop() { # Sleep indefinitely (to keep container alive for testing). tail -f /dev/null } #------------------------------------------------------------------------------# # @brief: Launches a minimalistic web server via netcat. The Dockerfile # associated with this project is configured to treat the web server # replying with "200 OK" as a sort of simple health probe. function health_check_init() { while true; do echo -e "HTTP/1.1 200 OK\n\nHOST:$(hostname)\nDATE:$(date)" ``` -------------------------------- ### Install VPP Config Utility Source: https://s3-docs.fd.io/vpp/26.02/developer/extras/vpp_config.html Install the VPP configuration utility using pip. This command installs the package and makes the `vpp-config` command available. ```bash # pip install vpp-config ``` -------------------------------- ### Install External Dependencies Source: https://s3-docs.fd.io/vpp/26.02/developer/build-run-debug/building.html Installs VPP external dependencies locally within the VPP tree, not system-wide. This command saves time by installing them efficiently. ```bash $ make install-ext-deps ``` -------------------------------- ### VPP Bonded Interface Configuration Example Source: https://s3-docs.fd.io/vpp/26.02/_sources/developer/extras/vpp_config.rst.txt Illustrates how to configure bonded interfaces in VPP's startup.conf using DPDK virtual devices. Examples show XOR load balancing and active-backup modes, specifying slave interfaces by PCI address. ```diff ## Specify bonded interface and its slaves via PCI addresses ## ## Bonded interface in XOR load balance mode (mode 2) with L3 and L4 headers # vdev eth_bond0,mode=2,slave=0000:02:00.0,slave=0000:03:00.0,xmit_policy=l34 # vdev eth_bond1,mode=2,slave=0000:02:00.1,slave=0000:03:00.1,xmit_policy=l34 ## ## Bonded interface in Active-Back up mode (mode 1) # vdev eth_bond0,mode=1,slave=0000:02:00.0,slave=0000:03:00.0 # vdev eth_bond1,mode=1,slave=0000:02:00.1,slave=0000:03:00.1 ``` -------------------------------- ### Launch VPP with GoVPP Configuration Source: https://s3-docs.fd.io/vpp/26.02/interfacing/go/index.html Configure and launch VPP. This involves creating a startup configuration file to specify the API socket path and load necessary plugins, then starting VPP using the configuration. ```bash mkdir -p /tmp/vpp cat << EOF > /tmp/startup.conf unix {nodaemon cli-listen /tmp/vpp/api.sock} plugins { path /vpp/build-root/install-vpp_debug-native/vpp/lib/x86_64-linux-gnu/vpp_plugins plugin dpdk_plugin.so { disable } } EOF ``` ```bash # If VPP was built from source: /build-root/install-vpp_debug-native/vpp/bin/vpp -c /tmp/startup.conf # If VPP was installed from package: vpp -c /tmp/startup.conf ``` -------------------------------- ### Install Go Binary API Generator Source: https://s3-docs.fd.io/vpp/26.02/_sources/interfacing/go/index.rst.txt Install the binapi-generator tool using 'go install'. This command places the executable in your Go bin directory. ```bash # First install the binary API generator # It will be installed to $GOPATH/bin/binapi-generator # or $HOME/go/bin/binapi-generator go install go.fd.io/govpp/cmd/binapi-generator@latest ``` -------------------------------- ### Build and Install VPP Source: https://s3-docs.fd.io/vpp/26.02/usecases/vppcloud/vppinazure.html Builds VPP using the configured external DPDK and installs it as Debian packages. This process compiles VPP and prepares it for system installation. ```bash make build cd build-root/ make V=0 PLATFORM=vpp TAG=vpp install-deb sudo dpkg -i *.deb ``` -------------------------------- ### Implement Test Setup Source: https://s3-docs.fd.io/vpp/26.02/_sources/developer/extras/kube-test.rst.txt Implement the SetupTest method to set up the test context before each individual test runs. This is where you can initialize background contexts or perform per-test setup. ```go func (s *MySuite) SetupTest() { s.MainContext = context.Background() s.BaseSuite.SetupTest() // Add custom setup code here } ``` -------------------------------- ### Install Build Dependencies Source: https://s3-docs.fd.io/vpp/26.02/_sources/interfacing/libmemif/buildinstructions_doc.rst.txt Installs necessary packages for building libmemif. Ensure you have git, cmake, autoconf, pkg-config, libtool, and related development libraries installed. ```bash sudo apt-get install -y git cmake autoconf pkg_config libtool ``` -------------------------------- ### Install isc-dhcp-server Source: https://s3-docs.fd.io/vpp/26.02/_sources/usecases/container_test.rst.txt Installs the isc-dhcp-server package on Debian-based systems. ```bash sudo apt-get install isc-dhcp-server ```