cohydra.interface¶
Internal network card.
Classes
The Interface resembles a network card. |
-
class
cohydra.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
= None¶ A unique number identifying the interface.
-
node
= None¶ The node to connect the interface to.
-
ns3_device
= None¶ The ns-3 equivalent of the interface.
-
address
= None¶ The interface’s IP
-
ifname
= None¶ The name of the interface. This will be set by in
Node.add_interface()
.
-
mac_address
= None¶ 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
-
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.
-
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).
Inheritance Diagramm