NetworkEmulator#

class wattson.cosimulation.simulators.network.network_emulator.NetworkEmulator(**kwargs)#

Bases: Simulator

Methods

__init__

add_host

add_interface

Adds the given WattsonNetworkInterface to the specified node

add_link

add_nat_to_management_network

add_node

Adds a WattsonNetworkNode to the network emulation

add_router

add_switch

attach_to_internet

cli

Start a command-line-interface to interact with the network emulator :return:

connect_interfaces

connect_nodes

connect_to_management_network

count_hops

Count the number of hops between the node and the target node.

deploy_services

Start services attached to network nodes :return:

enable_management_network

find_node_by_id

Searches for a node with the given (non-prefixed) ID and returns the node.

find_node_by_name

Searches for a node with the given display name.

find_nodes_by_ip_address

Searches for all nodes with the given IP address and returns the nodes.

find_nodes_by_role

find_nodes_in_subnet

find_routers

get_all_networks

get_controllers

get_domain_name

get_entities

get_entity

get_free_link_id

get_graph

get_host

get_hosts

get_interface

get_interfaces

get_links

get_management_ips

get_management_nat

get_management_switch

get_name_servers

get_namespace

get_next_management_ip

get_node

get_node_interfaces_dict

get_node_root_folder

get_nodes

get_primary_ips

get_router

get_routers

get_simulation_control_clients

Returns a set of node identifiers that the simulation control server waits for to be connected.

get_simulator_type

get_switch

get_switches

get_unused_ip

handle_simulation_control_query

Handles the given WattsonQuery and provides an optional response.

handles_simulation_query_type

Checks whether the physical simulator handles specific SimulationControlQueries.

has_entity

Checks whether the given entity exists within the internal network graph.

has_interface

load_scenario

Loads the network scenario defined in the given scenario path.

on_entity_change

on_entity_remove

on_entity_start

on_entity_stop

on_topology_change

open_browser

Open a (local) browser for this node if possible

remove_host

remove_interface

remove_link

remove_node

remove_switch

replace_node

Replaces an existing node with a new one, moving all interfaces from the original node to the new node while preserving links

set_configuration_store

Sets the ConfigurationStore for this Simulator to use

start

Starts the simulator / emulator.

stop

Stops the simulator / emulator.

__init__(**kwargs)#
add_interface(node: str | WattsonNetworkNode, interface: WattsonNetworkInterface) WattsonNetworkInterface#

Adds the given WattsonNetworkInterface to the specified node

Parameters:
add_node(node: WattsonNetworkNode) WattsonNetworkNode#

Adds a WattsonNetworkNode to the network emulation

Parameters:

node (WattsonNetworkNode) – The network node to add

abstract cli()#

Start a command-line-interface to interact with the network emulator :return:

count_hops(node: WattsonNetworkNode, target_node: WattsonNetworkNode, allowed_subnets: Set[IPv4Network] | None) int#

Count the number of hops between the node and the target node. Optionally restrict the result path to nodes within the given set of allowed subnets.

Parameters:
  • node (WattsonNetworkNode) – The source node

  • target_node (WattsonNetworkNode) – The target node

  • allowed_subnets (Optional[Set[ipaddress.IPv4Network]]) – The optional set of allowed subnets

Returns:

The number of hops (i.e., number of links) between the node and the target node. Returns -1 if no path exists.

Return type:

int

abstract deploy_services()#

Start services attached to network nodes :return:

find_node_by_id(node_id: str) WattsonNetworkNode#

Searches for a node with the given (non-prefixed) ID and returns the node.

Parameters:

node_id (str) – The id of the node to search for

Returns:

The node with the given Id

Return type:

WattsonNetworkNode

Raises:

NetworkNodeNotFoundException – if no node with the given ID is found

find_node_by_name(node_name: str) WattsonNetworkNode#

Searches for a node with the given display name.

Parameters:

node_name (str) – The name to search for

Returns:

The (first) the node with the given display name

Return type:

WattsonNetworkNode

Raises:

NetworkNodeNotFoundException – if no node with the given name is found

find_nodes_by_ip_address(ip_address: str | IPv4Address) List[WattsonNetworkNode]#

Searches for all nodes with the given IP address and returns the nodes.

Parameters:

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

Returns:

A list of nodes with the given IP address

Return type:

List[WattsonNetworkNode]

get_simulation_control_clients() Set[str]#

Returns a set of node identifiers that the simulation control server waits for to be connected.

handle_simulation_control_query(query: WattsonQuery) WattsonResponse | None#

Handles the given WattsonQuery and provides an optional response. If the query type is not supported, this should raise an InvalidSimulationControlQueryException.

Parameters:

query (WattsonQuery) –

handles_simulation_query_type(query: WattsonQuery | Type[WattsonQuery]) bool#

Checks whether the physical simulator handles specific SimulationControlQueries.

Parameters:

query (Union[WattsonQuery, Type[WattsonQuery]]) – The query instance or class to be checked.

Returns:

Whether this simulator can handle this query type

Return type:

bool

has_entity(entity: str | WattsonNetworkEntity) bool#

Checks whether the given entity exists within the internal network graph.

Parameters:

entity (Union[str, WattsonNetworkEntity]) – The WattsonNetworkEntity or its unique entity_id

Returns:

True iff the entity has a corresponding node in the graph

Return type:

bool

load_scenario(scenario_path: Path)#

Loads the network scenario defined in the given scenario path.

Parameters:

scenario_path (Path) – The path to the scenario configuration

open_browser(node: WattsonNetworkNode) bool#

Open a (local) browser for this node if possible

Parameters:

node (WattsonNetworkNode) – The node to open a browser for

Returns:

Whether a browser could be opened

Return type:

bool

replace_node(original_node: WattsonNetworkNode, new_node: WattsonNetworkNode) WattsonNetworkNode#

Replaces an existing node with a new one, moving all interfaces from the original node to the new node while preserving links

Parameters:
Returns:

The newly inserted node

Return type:

WattsonNetworkNode

set_configuration_store(configuration_store: ConfigurationStore | None)#

Sets the ConfigurationStore for this Simulator to use

Parameters:

configuration_store (Optional[ConfigurationStore]) –

start()#

Starts the simulator / emulator. :return:

stop()#

Stops the simulator / emulator. :return: