vpp系列3-路由功能

北慕城南 提交于 2020-08-15 13:20:26

前置

上一篇已经讲到如何安装DPDK驱动,如何接管网卡,本篇介绍VPP路由功能,拓扑如下

此处是拿vmware虚拟机来模拟测试的,创建了3台vm,1台安装VPP,另2台作为两边的host使用。由于非物理机器,创建了2个portgroup,每台机器2个网卡,分别连接到对应的portgroup,也即打通了相互之间的链路

创建了3台vm,

VPP安装

vpp安装见上一篇

VPP配置

vpp# set int ip address ethvpp-1 10.10.4.1/24
vpp# set int ip address ethvpp-2 10.10.5.1/24
vpp# set int state ethvpp-1 up
vpp# set int state ethvpp-2 up
vpp# show int address
ethvpp-1 (up):
  L3 10.10.4.1/24
ethvpp-2 (up):
  L3 10.10.5.1/24

IP配置

host1,host2 ip配置

# host1
root@ubuntu:~# cat /etc/netplan/ifcfg-eth0.yaml 

network:
  ethernets:
    eth0:
      match:
        macaddress: 00:50:56:ab:c5:2a
      addresses: ["10.10.4.2/24"]
      dhcp4: no
      dhcp6: no
      
      
      nameservers:
        addresses: ["8.8.8.8"]
  renderer: networkd
  version: 2

# host2
root@ubuntu:~# cat /etc/netplan/ifcfg-eth2.yaml 

network:
  ethernets:
    eth2:
      match:
        macaddress: 00:50:56:ab:ad:ec
      addresses: ["10.10.5.2/24"]
      dhcp4: no
      dhcp6: no
      
      
      nameservers:
        addresses: ["8.8.8.8"]
  renderer: networkd
  version: 2

host分别配置到对端的路由

# host1
ip route add 10.10.5.0/24 via 10.10.4.1

root@ubuntu:~# ip route 
default via 101.251.217.9 dev eth1 proto static 
10.10.4.0/24 dev eth0 proto kernel scope link src 10.10.4.2 
10.10.5.0/24 via 10.10.4.1 dev eth0 
10.240.0.0/16 dev eth2 proto kernel scope link src 10.240.26.2 
101.251.217.8/29 dev eth1 proto kernel scope link src 101.251.217.10 

# host2
ip route add 10.10.4.0/24 via 10.10.5.1

root@ubuntu:~# ip route 
default via 101.251.217.9 dev eth1 proto static 
10.10.4.0/24 via 10.10.5.1 dev eth2 
10.10.5.0/24 dev eth2 proto kernel scope link src 10.10.5.2 
10.241.0.0/16 dev eth0 proto kernel scope link src 10.241.4.3 
101.251.217.8/29 dev eth1 proto kernel scope link src 101.251.217.11 

ping测试

# host1 ping host2
root@ubuntu:~# ping 10.10.5.2
PING 10.10.5.2 (10.10.5.2) 56(84) bytes of data.
64 bytes from 10.10.5.2: icmp_seq=1 ttl=63 time=0.871 ms
64 bytes from 10.10.5.2: icmp_seq=2 ttl=63 time=0.285 ms
^C
--- 10.10.5.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.285/0.578/0.871/0.293 ms


# host2 ping host1
root@ubuntu:~# ping 10.10.4.2
PING 10.10.4.2 (10.10.4.2) 56(84) bytes of data.
64 bytes from 10.10.4.2: icmp_seq=1 ttl=63 time=0.372 ms
64 bytes from 10.10.4.2: icmp_seq=2 ttl=63 time=0.347 ms
^C
--- 10.10.4.2 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.347/0.359/0.372/0.022 ms

性能测试

安装iperf3

apt-get install iperf3

10.10.4.2起server

root@ubuntu:~# iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------

10.10.5.2起client

root@ubuntu:~# iperf3 -u -c 10.10.4.2 -l 64 -b 0M -t 300
Connecting to host 10.10.4.2, port 5201
[  4] local 10.10.5.2 port 53225 connected to 10.10.4.2 port 5201
[ ID] Interval           Transfer     Bandwidth       Total Datagrams
[  4]   0.00-1.00   sec  9.27 MBytes  77.6 Mbits/sec  151880  
[  4]   1.00-2.00   sec  15.8 MBytes   133 Mbits/sec  259300  
[  4]   2.00-3.00   sec  16.0 MBytes   134 Mbits/sec  261750  
[  4]   3.00-4.00   sec  15.7 MBytes   132 Mbits/sec  257070  
[  4]   4.00-5.00   sec  15.9 MBytes   133 Mbits/sec  260030  
[  4]   5.00-6.00   sec  16.3 MBytes   137 Mbits/sec  266760  
[  4]   6.00-7.00   sec  16.5 MBytes   138 Mbits/sec  269830  
[  4]   7.00-8.00   sec  16.4 MBytes   138 Mbits/sec  269460  
[  4]   8.00-9.00   sec  16.3 MBytes   136 Mbits/sec  266790  

包速率查看脚本

root@ubuntu:~# cat pps-test.sh 
#!/bin/bash
  
INTERVAL="1"  # update interval in seconds

if [ -z "$1" ]; then
        echo
        echo usage: $0 [network-interface]
        echo
        echo e.g. $0 eth0
        echo
        echo shows packets-per-second
        exit
fi

IF=$1

while true
do
        R1=`cat /sys/class/net/$1/statistics/rx_packets`
        T1=`cat /sys/class/net/$1/statistics/tx_packets`
        sleep $INTERVAL
        R2=`cat /sys/class/net/$1/statistics/rx_packets`
        T2=`cat /sys/class/net/$1/statistics/tx_packets`
        TXPPS=`expr $T2 - $T1`
        RXPPS=`expr $R2 - $R1`
        echo "TX $1: $TXPPS pkts/s RX $1: $RXPPS pkts/s"
done

查看

root@ubuntu:~# sh pps-test.sh eth0
TX eth0: 0 pkts/s RX eth0: 279610 pkts/s
TX eth0: 0 pkts/s RX eth0: 277033 pkts/s
TX eth0: 0 pkts/s RX eth0: 278330 pkts/s
TX eth0: 0 pkts/s RX eth0: 274191 pkts/s
TX eth0: 0 pkts/s RX eth0: 276321 pkts/s
TX eth0: 0 pkts/s RX eth0: 281361 pkts/s
TX eth0: 0 pkts/s RX eth0: 276660 pkts/s

可见大概在27M左右?这么强?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!