trex-bird使用过程解析

  • trex-bird原理

image

TRex-Bird架构图

trex 结合bird服务是采用linux上的veth及网络命名空间的技术: bird运行在trex-a-bird-ns 网络namespace里,创建veth虚接口对bird-0-0-T和bird-0-0-L;

veth接口对bird-0-0-L接口在trex-a-bird-ns空间,另外一端接口bird-0-0-T在linux默认网络空间上,birde在trex-a-bird-ns网络命名空间里发送数据报文会到bird-0-0-T接口上,trex将接口bird-0-0-T上接收到的数据通过dpdk接口发送出去

  • 网络拓扑图

@~J O)47VY4(L~V{P86 @OI

TRex-Bird验证拓扑图
  • trex 配置文件
### 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]
  • 运行trex-bird
$sudo ./t-rex-64 -i --bird-server --software -c 2
  • 运行trex-console
trex>service -a
trex(service)>portattr --prom on --mult on

trex(service)>plugins load bird

trex>portattr -a
Port Status

     port       |          0           |          1
----------------+----------------------+---------------------
driver          |     net_e1000_em     |     net_e1000_em
description     |       Unknown        |       Unknown
link status     |          UP          |          UP
link speed      |        1 Gb/s        |        1 Gb/s
port status     |         IDLE         |         IDLE
promiscuous     |         off          |         off
multicast       |          on          |          on
flow ctrl       |         none         |         none
vxlan fs        |          -           |          -
--              |                      |
layer mode      |         IPv4         |         IPv4
src IPv4        |    192.168.33.18     |    192.168.34.18
IPv6            |         off          |         off
src MAC         |  00:0c:29:1a:48:84   |  00:0c:29:1a:48:8e
---             |                      |
Destination     |     192.168.33.1     |     192.168.34.1
ARP Resolution  |  00:50:56:c0:00:01   |  00:50:56:c0:00:02
----            |                      |
VLAN            |          -           |          -
-----           |                      |
PCI Address     |     0000:02:02.0     |     0000:02:03.0
NUMA Node       |          0           |          0
RX Filter Mode  |    hardware match    |    hardware match
RX Queueing     |         off          |         off
Grat ARP        |         off          |         off
------          |                      |

trex(service)>plugins bird add_node -p 0 --mac 00:0c:29:1a:48:83 --ipv4 192.168.33.19 --ipv4-subnet 24

trex(service)>plugins bird show_nodes -p 0

Setting port 0 in with namespace configuration               [SUCCESS]


wait_for_async_results                                       [SUCCESS]


Setting port 0 in with namespace configuration               [SUCCESS]


wait_for_async_results                                       [SUCCESS]

Bird Nodes Information

    Node MAC      |   ipv4 address    |    ipv4 subnet    |   ipv6 enabled    |   ipv6 address    |    ipv6 subnet    |       vlans       |       tpids
------------------+-------------------+-------------------+-------------------+-------------------+-------------------+-------------------+------------------
00:0c:29:1a:48:83 |   192.168.33.19   |        24         |       False       |         -         |         -         |         -         |         -


trex(service)>plugins bird add_node -p 1 --mac 00:0c:29:1a:48:8f --ipv4 192.168.34.19 --ipv4-subnet 24

Setting port 1 in with namespace configuration               [SUCCESS]


wait_for_async_results                                       [SUCCESS]


Applying attributes on port(s) [0, 1]:                       [SUCCESS]


Setting port 1 in with namespace configuration               [SUCCESS]


wait_for_async_results                                       [SUCCESS]

trex(service)>plugins bird show_nodes -p 1

Setting port 1 in with namespace configuration               [SUCCESS]


wait_for_async_results                                       [SUCCESS]


Setting port 1 in with namespace configuration               [SUCCESS]


wait_for_async_results                                       [SUCCESS]

Bird Nodes Information

    Node MAC      |   ipv4 address    |    ipv4 subnet    |   ipv6 enabled    |   ipv6 address    |    ipv6 subnet    |       vlans       |       tpids
------------------+-------------------+-------------------+-------------------+-------------------+-------------------+-------------------+------------------
00:0c:29:1a:48:8f |   192.168.34.19   |        24         |       False       |         -         |         -         |         -         |         -

参考linux主机环境:

$ sudo ip netns ls
trex-a-0-0 (id: 1)
trex-a-1-0 (id: 0)
trex-a-bird-ns (id: 2)

$ifconfig
bird-0-0-T: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9280
        ether be:b3:0b:ec:c1:10  txqueuelen 1000  (Ethernet)
        RX packets 14  bytes 684 (684.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 137  bytes 23834 (23.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

bird-1-0-T: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9280
        ether c6:9c:ab:55:df:6d  txqueuelen 1000  (Ethernet)
        RX packets 4  bytes 232 (232.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 121  bytes 20593 (20.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.210.198  netmask 255.255.255.0  broadcast 192.168.210.255
        inet6 fe80::20c:29ff:fe1a:487a  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:1a:48:7a  txqueuelen 1000  (Ethernet)
        RX packets 237834  bytes 168717112 (168.7 MB)
        RX errors 0  dropped 24158  overruns 0  frame 0
        TX packets 147862  bytes 45169033 (45.1 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 129061  bytes 21420353 (21.4 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 129061  bytes 21420353 (21.4 MB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

trex-a-0-0-T: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9280
        ether e2:18:e9:38:9a:74  txqueuelen 1000  (Ethernet)
        RX packets 24  bytes 1896 (1.8 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 85  bytes 6334 (6.3 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

trex-a-1-0-T: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 9280
        ether 12:54:67:6a:54:f2  txqueuelen 1000  (Ethernet)
        RX packets 4537  bytes 458248 (458.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1671  bytes 176128 (176.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

加载bird配置

trex(service)>plugins bird set_config -f bird/cfg/bgp.conf -r bird/cfg/ipv4_routes.conf
Bird configuration result: Configured successfully
trex(service)>plugins bird show_config
router id 100.100.100.100;

protocol device {
    scan time 1;
}

protocol bgp my_bgp1 {
    local 192.168.33.19 as 65000;  # put your local ip and as number here
    neighbor 192.168.34.19 as 65000;  # put your dut ip and as number here
    ipv4 {
        import all;
        export all;
    };
}

# Running a second BGP instance in another interface.
protocol bgp my_bgp2 {
    local 192.168.34.19 as 65000;
    neighbor 192.168.33.19 as 65000;
    ipv4 {
        import all;
        export all;
    };
}

protocol static {
    ipv4 {
        import all;
        export all;
    };

    route 42.42.42.0/32 via 192.168.33.3;
    route 42.42.42.1/32 via 192.168.33.3;
    route 42.42.42.2/32 via 192.168.33.3;
    route 42.42.42.3/32 via 192.168.33.3;
    route 42.42.42.4/32 via 192.168.33.3;
    route 42.42.42.5/32 via 192.168.33.3;
    route 42.42.42.6/32 via 192.168.33.3;
    route 42.42.42.7/32 via 192.168.33.3;
    route 42.42.42.8/32 via 192.168.33.3;
    route 42.42.42.9/32 via 192.168.33.3;
    route 42.42.42.10/32 via 192.168.33.3;
}

查看状态

trex(service)>plugins bird show_protocols
Name       Proto      Table      State  Since         Info
device1    Device     ---        up     03:01:16.681
my_bgp1    BGP        ---        start  03:32:42.051  Connect
my_bgp2    BGP        ---        start  03:32:42.051  Connect
static1    Static     master4    up     03:01:16.681
posted @ 2022-03-04 09:32  staylight  阅读(377)  评论(0编辑  收藏  举报