Vector Packet Processor(VPP)使用简介
  Pq37jUF4UeqZ 2023年11月02日 42 0

Author

Date Aug. 01, 2023

Description VPP的简介以及安装

简介

最早的VPP是由Cisco提出来的,不过现在已经开源了。

FD.io的Vector Packet Processor(VPP)是一个快速、可扩展的2-4层多平台网络协议栈,可以运行多种架构的如x86\ARM\Power架构的Linux用户空间。它期望提供的是可扩展的、开箱即用的交换机或者路由器功能。

VPP是高性能的网络协议栈,可以通过使用插件来扩展功能。DPDK(Data Plane Development Kit)是最常用的数据面插件,为VPP提供了非常重要的功能和驱动。DPDK同样是运行在用户空间,提供高速的包处理函数以及用户空间的驱动。其实就是把数据包从Linux内核态玻璃了出来,DPDK以较小的CPU周期接受和发送数据包。DPDK使用的是用户态poll mode驱动。

VPP支持和OpenStack或者Kubernetes集成。网络管理功能包括配置、计数器、采样等。对于开发者,VPP包含了高性能事件日志以及多样的包跟踪。开发调试功能包含完整的符号表以及大量的一致性检验。

使用VPP的例子很多,例如vSwitches,vRouters,Gateways,Firewalls以及负载均衡等。

VPP向量处理数据包,即以批处理的方式处理,每个批处理叫做向量,一次性可以处理256个之多的数据包,这最大化的使用了缓存命中。而标量处理(顺序处理)的数据包,可能就会超出缓存,造成频繁的缓存换入换出。

VPP平台包含一系列的有向图节点构成,这个有向图称为数据包处理图。每个节点向数据包提供了特定的网络功能,每个有向边指示了下一个处理该数据包的网络功能。对于向量中的所有数据包,只有第一个数据包需要加载CPU指令到内存中。

编译安装VPP

可以查看具体需要安装的版本,我们这里使用23.06。

# The base home directory
cd /usr/local/src
# Get the VPP Sources
git clone https://gerrit.fd.io/r/vpp
cd vpp
git checkout v23.06 # 最新的稳定版本
make install-deps
make build
cd build-root
make install-extra-deps
make pkg-deb
sudo dpkg -i build-root/*.deb

不确定安装的是啥,可以去build-root下看看有哪些deb文件。

配置文件

默认的配置文件安装在了/etc/sysctl.d/80-vpp.conf以及/etc/vpp/startup.conf/startup.conf。 前者是配置DPDK的巨页,后者是配置VPP。

启用巨页,使用

sysctl -p /etc/sysctl.d/80-vpp.conf

VPP配置文件中的我们就在配置文件的注释中写了。

unix {
  nodaemon              # 不在后台运行
  log /tmp/vpp.log      # 日志文件
  full-coredump         # 调试coredump
  interactive           # 启用交互模式,也就是使用CLI
}

api-trace {
  on
}

api-segment {
  gid vpp
}

cpu {
     ## In the VPP there is one main thread and optionally the user can create worker(s)
        ## The main thread and worker thread(s) can be pinned to CPU core(s) manually or automatically

        ## Manual pinning of thread(s) to CPU core(s)

        ## Set logical CPU core where main thread runs
        main-core 1

        ## Set logical CPU core(s) where worker threads are running
        # 使用了4个worker线程,2,3,22,33
        corelist-workers 2-3,22-23
}

dpdk {
        ## Change default settings for all intefaces
        # dev default {
                ## Number of receive queues, enables RSS
                ## Default is 1
                # num-rx-queues 3

                ## Number of transmit queues, Default is equal
                ## to number of worker threads or 1 if no workers treads
                # num-tx-queues 3

                ## Number of descriptors in transmit and receive rings
                ## increasing or reducing number can impact performance
                ## Default is 1024 for both rx and tx
                # num-rx-desc 512
                # num-tx-desc 512

                ## VLAN strip offload mode for interface
                ## Default is off
                # vlan-strip-offload on
        # }

        ## Whitelist specific interface by specifying PCI address
        # 这个记者要使用dev来绑定dpdk接管的网络接口,可以给其一个别名
        # 别名的用途就是不会以路由器接口的名字形式来显示了
        dev 0000:00:09.0 {
                name ens802f0
        }
        dev 0000:00:0a.0 {
                name ens802f1
        }

        ## Whitelist specific interface by specifying PCI address and in
        ## addition specify custom parameters for this interface
        # dev 0000:02:00.1 {
        #       num-rx-queues 2
        # }

        ## Change UIO driver used by VPP, Options are: igb_uio, vfio-pci
        ## and uio_pci_generic (default)
        # uio-driver vfio-pci
}

# Adjusting the plugin path depending on where the VPP plugins are:
# 插件的配置,默认是都启用的,如果不启用还需要配置default为false。
plugins
{
        path /usr/lib/vpp_plugins
}

这并没有结束,还需要进入vppctl进行其它的如ip地址的配置。如果使用linux-cp插件,那么就能把用户空间的接口映射到内核中去,和DPDK KNI有些像。这样就可以使用Linux的命令来操作了。

loopback create-interface
set interface state loop0 up
set interface state ens802f0 up
set interface state ens802f1 up
set interface ip address ens802f0 10.10.1.1/24
set interface ip address ens802f1 10.10.2.1/24

接下来就可以通过ping的方式检查下配置是否成功了。建议拓扑使用至少两台机器(不然你也不会需要这样使用VPP了)。一台配置VPP,一台就是普通的linux。对于普通linux,在测试的时候,还需要配置它的地址。假设我们采用如下的拓扑。csp2s22c03是配置了VPP,另外两台则是普通的Linux机器。那么如果想要csp2s22c04 ping csp2s22c05,那么就需要给csp2s22c04和csp2s22c05分别配置默认路由。

image.png

# csp2s22c04
sudo ip address add 10.10.1.2/24 dev ens802
sudo ip route add 10.10.2.0/24 via 10.10.1.1 dev ens802

# csp2s22c05
sudo ip address add 10.10.2.2/24 dev ens803f0
sudo ip route add 10.10.1.0/24 via 10.10.2.1 dev ens803f0

至于使用iperf3还是其它的测试吞吐,请自行琢磨吧。

参考

  1. What is the Vector Packet Processor (VPP)
  2. What is VPP
  3. Build a Fast Network Stack with Vector Packet Processing (VPP) on an Intel® Architecture Server
【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

Pq37jUF4UeqZ