如何在配置较低的虚拟机上编译并运行支持bird的trex

  • 增加swapfile
sudo /sbin/mkswap /dev/sdb1
sudo mkswap /dev/sdb1
  • build trex support dpdk and bird
sudo apt-get install -y autoconf flex bison binutils g++ zlib1g-dev make
git clone https://github.com/cisco-system-traffic-generator/trex-core.git
cd trex-core/linux_dpdk
./b configure --with-bird
./b build --with-bird
  • 运行trex

配置巨页内存, 配置文件80-vpp.conf

# Number of 2MB hugepages desired
vm.nr_hugepages=1024

# Must be greater than or equal to (2 * vm.nr_hugepages).
vm.max_map_count=3096

# All groups allowed to access hugepages
vm.hugetlb_shm_group=0

# Shared Memory Max must be greater or equal to the total size of hugepages.
# For 2MB pages, TotalHugepageSize = vm.nr_hugepages * 2 * 1024 * 1024
# If the existing kernel.shmmax setting  (cat /proc/sys/kernel/shmmax)
# is greater than the calculated TotalHugepageSize then set this parameter
# to current shmmax value.
kernel.shmmax=2147483648

生成trex_cfg.yaml文件

sudo ./dpdk_setup_ports.py -c 02:00.0 02:00.1 -o /etc/trex_cfg.yaml
### Config file generated by dpdk_setup_ports.py ###

- version: 2
  interfaces: ['02:02.0', '02:03.0']
  low_end: true
  stack: linux_based
  port_info:
      - ip: 192.168.33.18
        default_gw: 192.168.33.1
      - ip: 192.168.34.18
        default_gw: 192.168.34.1

  platform:
      master_thread_id: 0
      latency_thread_id: 1
      dual_if:
        - socket: 0
          threads: [2,3]

low_end 解决虚拟机上运行配置低的问题

stack 解决bird运行的问题, 默认是legacy方式 bird不支持

trex的配置文件的参数可以参考文件platform_cfg.cpp

  • 运行带bird服务的trex
cd scripts
sudo ./t-rex-64 -i --bird
  • 问题
  1. 不能运行起来,问题如下。
WARNING: tried to configure 2048 hugepages for socket 0, but result is: 1667
Starting Scapy server.................... Scapy server is started
The ports are bound/configured.
Starting  TRex v2.95 please wait  ...
EAL: Failed to create shared memory!
EAL: FATAL: Cannot init memory
EAL: Cannot init memory
 You might need to run ./trex-cfg  once
EAL: Error - exiting with code: 1
  Cause: Invalid EAL arguments
Killing Scapy server... Scapy server is killed

内存太小,没招,加内存

  1. ubuntu 20.04中无法通过lsmod找到vfio-pci模块?

由于vfio-pci被集成到内核里,可通过如下的方式查看是否加载

# cat /lib/modules/$(uname -r)/modules.builtin | grep vfio

kernel/drivers/vfio/vfio.ko
kernel/drivers/vfio/vfio_virqfd.ko
kernel/drivers/vfio/vfio_iommu_type1.ko
kernel/drivers/vfio/pci/vfio-pci.ko
posted @ 2022-03-01 10:21  staylight  阅读(409)  评论(1编辑  收藏  举报