p4utils.mininetlib.node module

This module is an extension of mininet.node with customized nodes.

class p4utils.mininetlib.node.FRRouter(name, bin_dir='/usr/local/sbin', int_conf=None, conf_dir='./routers', **kwargs)[source]

Bases: mininet.node.Node

FRRouter built as Mininet node.

Parameters:
  • name (str) – name of the router
  • bin_dir (str) – directory that contains the daemons binaries
  • int_conf (str) – path to the router integrated configuration file
  • conf_dir (str) – path to the directory which contains the folder with the configuration files for all the daemons (the folder is named after the router)
  • zebra (bool) – enable Zebra daemon
  • bgpd (bool) – enable BGP protocol
  • ospfd (bool) – enable OSPFv2 (for IPv4) protocol
  • ospf6d (bool) – enable OSPFv3 (for IPv6) protocol
  • ripd (bool) – enable RIP protocol
  • ripngd (bool) – enable RIPng protocol
  • isisd (bool) – enable IS-IS protocol
  • pimd (bool) – enable PIM protocol
  • ldpd (bool) – enable LPD protocol
  • nhrpd (bool) – enable NHRP protocol
  • eigrpd (bool) – enable EIGRP protocol
  • babeld (bool) – enable Babel protocol
  • sharpd (bool) – enable SHARP daemon
  • staticd (bool) – enable STATIC daemon
  • pbrd (bool) – enable Policy Based Routing
  • bfdd (bool) – enable Bidirectional Forwarding Detection
  • fabricd (bool) – enable OpenFabric protocol

Warning

Only the following daemons and protocols are enabled by default:

  • zebra
  • ospfd
  • bgpd
  • staticd

Note

If int_conf is set, the content conf_dir is not considered except for vtysh.conf which is always taken into account. If conf_dir is not specified, then it is assumed to be ./routers, and the folder which contains the configuration files is then ./routers/<name>.

DAEMONS = ['zebra', 'bgpd', 'ospfd', 'ospf6d', 'ripd', 'ripngd', 'isisd', 'pimd', 'ldpd', 'nhrpd', 'eigrpd', 'babeld', 'sharpd', 'staticd', 'pbrd', 'bfdd', 'fabricd'][source]
start()[source]

Starts the FRRouter node.

start_daemon(daemon, *args, **kwargs)[source]

Starts a daemon on the router.

stop(deleteIntfs=False)[source]

Stops FRRouter.

class p4utils.mininetlib.node.P4Host(*args, log_enabled=False, log_dir='/tmp', **kwargs)[source]

Bases: mininet.node.Host

Virtual hosts with custom configuration to work with P4 switches.

config(**params)[source]

Configures host.

describe(sw_addr=None, sw_mac=None)[source]

Describes host.

class p4utils.mininetlib.node.P4RuntimeSwitch(*args, sw_bin='simple_switch_grpc', grpc_port=None, **kwargs)[source]

Bases: p4utils.mininetlib.node.P4Switch

BMv2 switch with gRPC support.

Parameters:
  • name (str) – name of the switch
  • device_id (int) – switch unique id
  • sw_bin (str) – switch binary to execute
  • json_path (str) – path to the P4 compiled JSON configuration
  • thrift_port (int) – Thrift server’s port
  • grpc_port (int) – P4Runtime gRPC server’s port
  • pcap_dump (bool) – whether to save .pcap logs to disk
  • pcap_dir (str) – .pcap files path
  • log_enabled (bool) – whether to save logs to disk
  • log_dir (srt) – log path
  • enable_debugger (bool) – whether to enable debugger
add_target_arguments()[source]

Adds arguments to the simple switch process

describe()[source]

Describes P4RuntimeSwitch.

grpc_listening()[source]

Checks if a grpc process listens on the grpc port.

switch_status()[source]

Checks if all the switch processes have started correctly.

class p4utils.mininetlib.node.P4Switch(name, device_id, sw_bin='simple_switch', json_path=None, thrift_port=None, pcap_dump=False, pcap_dir=None, log_enabled=False, log_dir='/tmp', enable_debugger=False, priority_queues_num=1, **kwargs)[source]

Bases: mininet.node.Switch

P4 virtual switch.

Parameters:
  • name (str) – name of the switch
  • device_id (int) – switch unique id
  • sw_bin (str) – switch binary to execute
  • json_path (str) – path to the P4 compiled JSON configuration
  • thrift_port (int) – Thrift server’s port
  • pcap_dump (bool) – whether to save .pcap logs to disk
  • pcap_dir (str) – .pcap files path
  • log_enabled (bool) – whether to save logs to disk
  • log_dir (srt) – log path
  • enable_debugger (bool) – whether to enable debugger
add_arguments()[source]

Adds arguments to the simple switch process

add_target_arguments()[source]

Adds switch target options

describe()[source]

Describes P4Switch.

set_binary(sw_bin)[source]

Sets switch default binary

set_json(json_path)[source]

Sets the compiled P4 JSON file.

start(controllers=None)[source]

Starts a new P4 switch.

stop(deleteIntfs=True)[source]

Stops the P4 switch.

switch_running()[source]

Checks if the switch process is running.

switch_status()[source]

Checks if all the switch processes have started correctly.

thrift_listening()[source]

Checks if a thrift process listens on the thrift port.

class p4utils.mininetlib.node.Tofino(name, device_id, p4_src, sde, sde_install, cli_port=8000, dr_port_base=8001, log_dir='/tmp', **kwargs)[source]

Bases: mininet.node.Switch

Tofino-model switch.

Parameters:
  • name (str) – name of the switch
  • device_id (int) – switch unique id
  • p4_src (str) – P4 source
  • sde (str) – Tofino SDE path ($SDE)
  • sde_install (str) – Tofino SDE install path ($SDE_INSTALL)
  • cli_port (int) – switch client port
  • dr_port_base (int) – port base for driver connection
  • log_dir (srt) – log path
add_driver_args()[source]

Adds arguments for bf_switchd.

add_ports()[source]

Adds ports to the switch ports configuration file.

add_tofino_args()[source]

Adds arguments for tofino-model.

bin_running()[source]

Checks if the switch binary process has started.

config(**params)[source]

Configures Tofino.

describe()[source]

Describes P4Switch.

driver_running()[source]

Checks if the switch driver process has started.

start(controllers=None)[source]

Starts a new P4 switch.

stop(deleteIntfs=True)[source]

Stops the P4 switch.

switch_running()[source]

Checks if the switch processes have started.