Bird Node¶
- Learn more about Bird
The API works when configuring stack: linux_based in trex_cfg and “–bird-server” flag is on when running TRex. Using this API the user can add a veth to the bird namespace in TRex.
The following snippet create 2 bird nodes with ipv4 and ipv6
c = STLClient(verbose_level = 'error')
c.connect()
my_ports = [0, 1]
c.acquire(ports = my_ports)
# move to service mode
c.set_service_mode(ports = my_ports, enabled = True)
# create 2 veth's in bird namespace, each function will block
c.set_bird_node(node_port = 0,
mac = "00:00:00:01:00:07",
ipv4 = "1.1.1.3",
ipv4_subnet = 24,
ipv6_enabled = True,
ipv6_subnet = 124,
vlans = [22], # dot1q is a configuration of veth not namespace
tpids = [0x8100])
c.set_bird_node(node_port = 1,
mac = "00:00:00:01:00:08",
ipv4 = "1.1.2.3",
ipv4_subnet = 24,
ipv6_enabled = True,
ipv6_subnet = 124)
More advanced way to do that:
c = STLClient(verbose_level = 'error')
c.connect()
my_ports = [0, 1]
c.acquire(ports = my_ports)
# move to service mode
c.set_service_mode(ports = my_ports, enabled = True)
# remove all old name spaces from all the ports and set promiscuous mode
c.namespace_remove_all()
c.set_port_attr(promiscuous = True)
cmds = NSCmds()
mac = "00:00:00:01:00:07"
ipv4 = "1.1.1.3"
ipv4_subnet = 24
ipv6_subnet = 24
cmds.add_node(mac, is_bird = True)
cmds.set_ipv4(mac, ipv4, subnet = ipv4_subnet, shared_ns = True)
cmds.set_ipv6(mac, ipv6_enabled, subnet = ipv6_subnet, shared_ns = True)
# start the batch
c.set_namespace_start(node_port, cmds)
# wait for the results
res = c.wait_for_async_results(node_port)
# print the results
print(res)
note: calling “add_node” with is_bird = True and shared_ns = “my-ns” is not allowed, they are mutual exclusive arguments.
Get Stats:
c = STLClient(verbose_level = 'error')
c.connect()
my_ports=[0,1]
c.reset(ports = my_ports)
# get all active nodes on port 0
r = c.set_namespace(0, method = 'get_nodes')
c.set_namespace (0, method='get_nodes_info', macs_list = r)
r = c.set_namespace(0, method = 'counters_get_meta')
r = c.set_namespace(0, method = 'counters_get_values', zeros = True)
build a x bird nodes
def get_mac (prefix,index):
mac="{}:{:02x}:{:02x}".format(prefix,(index>>8)&0xff,(index&0xff))
return mac
def get_ipv4 (prefix,index):
ipv4="{}.{:d}.{:d}".format(prefix,(index>>8)&0xff,(index&0xff))
return ipv4
# build a networks of 00:01:02:03:xx:xx and 1.1.x.x and IPV6 =auto with subnet mask 24 for all
def build_network (size):
cmds = NSCmds()
MAC_PREFIX = "00:01:02:03"
IPV4_PREFIX = "1.1"
ipv4_subnet = 24
ipv6_subnet = 127
for i in range(size):
mac = get_mac(MAC_PREFIX, i + 257 + 1)
ipv4 = get_ipv4(IPV4_PREFIX, 259 + i)
cmds.add_node(mac, is_bird = True)
cmds.set_ipv4(mac, ipv4, subnet = ipv4_subnet, shared_ns = True)
cmds.set_ipv6(mac, ipv6_enabled, subnet = ipv6_subnet, shared_ns = True)
return cmds
From NSCmds class¶
- class trex.common.trex_client.TRexClient(api_ver=None, username='hhaim', server='localhost', sync_port=4501, async_port=4500, verbose_level='error', logger=None, sync_timeout=None, async_timeout=None)[source]¶
TRex abstract client
contains common code between STLClient, ASTFClient and etc.
- set_bird_node(node_port, mac, ipv4=None, ipv4_subnet=None, ipv6_enabled=None, ipv6=None, ipv6_subnet=None, vlans=None, tpids=None, mtu=None)[source]¶
a utility function that works on top of
set_namespace_start()andwait_for_async_results()batch operation API. the function creates a “bird node” using veth’s in bird namespace in trex.usage example:
c.set_bird_node(node_port = 0, mac = "00:00:00:01:00:06", ipv4 = "1.1.1.3", ipv4_subnet = 24, ipv6_enabled = True, ipv6_subnet = 124, vlans = [22], tpids = [0x8100])
- Parameters
- node_port: int
Port id to set the bird node on
- mac: string
Mac address for the new bird node in format xx:xx:xx:xx:xx:xx
- ipv4: string
Ipv4 address for the new bird node
- ipv4_subnet: int
Ipv4 subnet for the new bird node
- ipv6_enabled: bool
True/False if ipv6 enabled on the new node, mandatory for ipv6 config
- ipv6: string
Ipv6 address for the new bird node
- ipv6_subnet: int
Ipv6 subnet for the new bird node
- vlans: list
Array of up to 2 uint16 tags.
- tpids: list
Array of tpidss that correspond to vlans. Default is [0x8100] in case of single VLAN and [0x88a8, 0x8100] in case of QinQ.
- mtu: int
MTU for bird node.
- Raises
TRexErrorin case of any error