NetworkEmulator#
- class wattson.cosimulation.simulators.network.network_emulator.NetworkEmulator(**kwargs)#
Bases:
SimulatorMethods
add_hostAdds the given WattsonNetworkInterface to the specified node
add_linkadd_nat_to_management_networkAdds a WattsonNetworkNode to the network emulation
add_routeradd_switchattach_to_internetStart a command-line-interface to interact with the network emulator :return:
connect_interfacesconnect_nodesconnect_to_management_networkCount the number of hops between the node and the target node.
Start services attached to network nodes :return:
enable_management_networkSearches for a node with the given (non-prefixed) ID and returns the node.
Searches for a node with the given display name.
Searches for all nodes with the given IP address and returns the nodes.
find_nodes_by_rolefind_nodes_in_subnetfind_routersget_all_networksget_controllersget_domain_nameget_entitiesget_entityget_free_link_idget_graphget_hostget_hostsget_interfaceget_interfacesget_linksget_management_ipsget_management_natget_management_switchget_name_serversget_namespaceget_next_management_ipget_nodeget_node_interfaces_dictget_node_root_folderget_nodesget_primary_ipsget_routerget_routersReturns a set of node identifiers that the simulation control server waits for to be connected.
get_simulator_typeget_switchget_switchesget_unused_ipHandles the given WattsonQuery and provides an optional response.
Checks whether the physical simulator handles specific SimulationControlQueries.
Checks whether the given entity exists within the internal network graph.
has_interfaceLoads the network scenario defined in the given scenario path.
on_entity_changeon_entity_removeon_entity_starton_entity_stopon_topology_changeOpen a (local) browser for this node if possible
remove_hostremove_interfaceremove_linkremove_noderemove_switchReplaces an existing node with a new one, moving all interfaces from the original node to the new node while preserving links
Sets the ConfigurationStore for this Simulator to use
Starts the simulator / emulator.
Stops the simulator / emulator.
- __init__(**kwargs)#
- add_interface(node: str | WattsonNetworkNode, interface: WattsonNetworkInterface) WattsonNetworkInterface#
Adds the given WattsonNetworkInterface to the specified node
- Parameters:
node (Union[str, WattsonNetworkNode]) – The node to add the interface to, either an ID or the node instance
interface (WattsonNetworkInterface) – The interface instance
- 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:
- 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:
- 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:
original_node (WattsonNetworkNode) – The node to be replaced
new_node (WattsonNetworkNode) – The new node to replace the existing one.
- Returns:
The newly inserted node
- Return type:
- 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: