marvis.interface

Internal network card.

Classes

Interface

The Interface resembles a network card.


class marvis.interface.Interface(node, ns3_device, address, mac_address=None)[source]

Bases: object

The Interface resembles a network card.

Warning: The interface is controlled by the a Channel. Do not instantiate an Interface by yourself.

Parameters
  • node (Node) – The node to connect the interface to.

  • ns3_device – The ns-3 equivalent of the interface.

  • address (str) – An IP address.

  • mac_address (str) – An MAC address. If None, a random MAC address will be assigned internally. Warning: You may need to set the MAC address in order to reach your nodes correctly. If you have any constraints on MAC addresses used externally, set it here.

number

A unique number identifying the interface.

node

The node to connect the interface to.

ns3_device

The ns-3 equivalent of the interface.

address

The interface’s IP

ifname

The name of the interface. This will be set by in Node.add_interface().

mac_address

The MAC address of this interface.

property bridge_name

Return a unique name for a bridge.

Returns

A bridge name.

Return type

str

property tap_name

Return a unqiue name for a tap.

Returns

A tap name.

Return type

str

property veth_name

Return a unique name for an VETH pair.

Returns

A VETH name.

Return type

str

property pcap_file_name

Return the name for the PCAP log file.

Returns

A PCAP log file name.

Return type

str

setup_bridge()[source]

Setup a bridge for adding a tap later on.

remove_bridge()[source]

Destroy the bridge.

connect_tap_to_bridge(bridge_name=None, tap_mode='ConfigureLocal')[source]

Connect a ns-3 tap device to the bridge.

Parameters
  • bridge_name (str) – The bridge to connect the tap (and ns-3) device to.

  • tap_mode (str) – The ns-3 mode for the tap bridge. Either ConfigureLocal or UseLocal.

disconnect_tap_from_bridge()[source]

Disconnect the (tap) interface and delete it.

setup_veth_pair(peer)[source]

Setup a VETH pair for containers.

This function also connects the external site of the pair to the bridge.

Parameters

peer (dict) – Options for the internal side of the VETH pair. This can e.g. contain the network namespace (see DockerNode for example).

remove_veth_pair()[source]

Disconnect the veth pair and delete it.

setup_veth_container_end(ifname)[source]

Setup the VETH in a container.

Parameters

ifname (str) – The interface name within the container.

Inheritance Diagramm

Inheritance diagram of marvis.interface