NetworkNode#

class wattson.cosimulation.simulators.network.components.interface.network_node.NetworkNode#

Bases: NetworkEntity, ABC

Methods

add_interface

Adds an Interface and links it to this node.

add_role

add_service

Adds a service to this node.

clear_mirrors

Clear all existing mirror ports at this node

delete_role

disable_mirror

Disable mirroring output to the given interface

enable_mirror

Enable network mirroring at this node and use the given interface as mirror port

exec

file_get_contents

Returns the contents of a file on the file system of this node.

file_put_contents

Writes the given content string to the file on the file system of this node specified by path.

get_config

get_hostname

get_interface

get_interfaces

get_ip_addresses

Returns a list of all IP addresses of this node.

get_management_interface

get_management_ip_address_string

Returns the IP address of the management interface of this node, if it exists.

get_neighbors

get_prefix

get_primary_ip_address_string

Returns the IP address of the first non-management interface of this node, if it exists.

get_role

get_roles

get_service

get_service_by_name

get_services

get_subnets

has_ip

Checks whether this node has an interface with the given IP address

has_role

has_service

has_services

Returns True iff the node's configuration already has a service section :return:

has_subnet

Checks whether this node has an interface that belongs to the given subnet.

interface_down

Set an interface down

interface_flush_ip

Flush (remove) the IP address of an interface

interface_set_ip

Set the IP address for an interface

interface_set_mac

Set the MAC / hardware address for the given interface

interface_up

Set an interface up

interfaces_list_existing

Returns a list of actual interfaces existing on the node.

is_not_pure_management_node

Returns whether this node has any interface that is not a management interface.

is_pure_management_node

Returns whether this node is reachable, but only reachable via the management network.

prefix_id

start_pcap

Start a packet capture on this node for the given interface.

start_service

start_services

stop_pcap

Stops a packet capture on this node for the given interface.

stop_service

stop_services

Attributes

node_id

id

abstract add_interface(interface: NetworkInterface)#

Adds an Interface and links it to this node.

Parameters:

interface ('NetworkInterface') – The interface instance

abstract add_service(service: WattsonServiceInterface)#

Adds a service to this node. This does not start the service.

Parameters:

service (WattsonServiceInterface) – The service to add to this node.

clear_mirrors() bool#

Clear all existing mirror ports at this node

Returns:

Whether the action has been successfully performed

Return type:

bool

disable_mirror(interface: NetworkInterface) bool#

Disable mirroring output to the given interface

Parameters:

interface ('NetworkInterface') – The interface used as mirror port

Returns:

Whether the action has been successfully performed

Return type:

bool

enable_mirror(interface: NetworkInterface) bool#

Enable network mirroring at this node and use the given interface as mirror port

Parameters:

interface ('NetworkInterface') – The interface to use as mirror port

Returns:

Whether the action has been successfully performed

Return type:

bool

file_get_contents(path: Path) str | None#

Returns the contents of a file on the file system of this node.

Parameters:

path (Path) – The path of the file to read.

Returns:

The contents of the file or None if the file does not exist or is not readable.

Return type:

Optional[str]

file_put_contents(path: Path, contents: str) Tuple[bool, Path | None]#

Writes the given content string to the file on the file system of this node specified by path. Returns whether the operation succeeded.

Parameters:
  • path (Path) – The path of the file to write to.

  • contents (str) – The contents of the file to write.

Returns:

Whether the operation succeeded and the potentially transformed path of the target file.

Return type:

Tuple[bool,Optional[Path]]

get_ip_addresses() List[str]#

Returns a list of all IP addresses of this node. Each IP is formatted as a string, indicating the IP itself in decimal notation and the prefix length. E.g.: 192.168.0.1/24 :return: A list of (formatted) IP addresses.

get_management_ip_address_string(with_subnet_length: bool = True) str | None#

Returns the IP address of the management interface of this node, if it exists. Otherwise, None is returned. :return: The node’s management IP address, or None

Parameters:

with_subnet_length (bool, optional) – (Default value = True)

get_primary_ip_address_string(with_subnet_length: bool = True) str | None#

Returns the IP address of the first non-management interface of this node, if it exists. Otherwise, None is returned. :return: The node’s first non-management IP address, or None

Parameters:

with_subnet_length (bool, optional) – (Default value = True)

has_ip(ip: IPv4Address | str) bool#

Checks whether this node has an interface with the given IP address

Parameters:

ip (Union[ipaddress.IPv4Address, str]) – The IP address to check for

Returns:

True iff any interface of this node has the given IP address

Return type:

bool

has_services() bool#

Returns True iff the node’s configuration already has a service section :return:

has_subnet(subnet: IPv4Network) bool#

Checks whether this node has an interface that belongs to the given subnet.

Parameters:

subnet (ipaddress.IPv4Network) – The subnet to check for

Returns:

Whether this node lies within the given subnet

Return type:

bool

interface_down(interface: NetworkInterface) bool#

Set an interface down

Parameters:

interface ('NetworkInterface') – The interface to set down

Returns:

Whether the action has been successfully performed

Return type:

bool

interface_flush_ip(interface: NetworkInterface) bool#

Flush (remove) the IP address of an interface

Parameters:

interface ('NetworkInterface') – The interface to flush the IP address of

Returns:

Whether the action has been successfully performed

Return type:

bool

interface_set_ip(interface: NetworkInterface) bool#

Set the IP address for an interface

Parameters:

interface ('NetworkInterface') – The interface to set the IP address of

Returns:

Whether the action has been successfully performed

Return type:

bool

interface_set_mac(interface: NetworkInterface) bool#

Set the MAC / hardware address for the given interface

Parameters:

interface ('NetworkInterface') – The interface to set the MAC address for

Returns:

Whether the action has been successfully performed

Return type:

bool

interface_up(interface: NetworkInterface) bool#

Set an interface up

Parameters:

interface ('NetworkInterface') – The interface to set up

Returns:

Whether the action has been successfully performed

Return type:

bool

interfaces_list_existing() List[Dict]#

Returns a list of actual interfaces existing on the node. Each interface information consists of the interface’s name, its hardware address, ip addresses, and potential statistics.

Returns:

A list of dictionaries containing interface information

Return type:

List[Dict]

is_not_pure_management_node() bool#

Returns whether this node has any interface that is not a management interface.

is_pure_management_node() bool#

Returns whether this node is reachable, but only reachable via the management network. Nodes without interfaces are NOT pure management nodes

Returns:

If the node is a pure management node

Return type:

bool

abstract start_pcap(interface: NetworkInterface | None = None) List[WattsonServiceInterface]#

Start a packet capture on this node for the given interface. If the interface is None, all packets for all interfaces are captured.

Parameters:

interface (Optional['NetworkInterface'], optional) – (Optional) interface to start the PCAP for (Default value = None)

Returns:

A list of services that represent the packet capturing processes.

Return type:

List[‘WattsonServiceInterface’]

abstract stop_pcap(interface: NetworkInterface | None = None)#

Stops a packet capture on this node for the given interface. If the interface is None, packet captures for all interfaces are stopped.

Parameters:

interface (Optional['NetworkInterface'], optional) – (Optional) interface to stop the PCAP (Default value = None)