#2450 remove link refs and put nice naming convention instead
This commit is contained in:
@@ -226,16 +226,16 @@ agents:
|
|||||||
label: LINKS
|
label: LINKS
|
||||||
options:
|
options:
|
||||||
link_references:
|
link_references:
|
||||||
- router_1___switch_1
|
- router_1:eth-1<->switch_1:eth-8
|
||||||
- router_1___switch_2
|
- router_1:eth-2<->switch_2:eth-8
|
||||||
- switch_1___domain_controller
|
- switch_1:eth-1<->domain_controller:eth-1
|
||||||
- switch_1___web_server
|
- switch_1:eth-2<->web_server:eth-1
|
||||||
- switch_1___database_server
|
- switch_1:eth-3<->database_server:eth-1
|
||||||
- switch_1___backup_server
|
- switch_1:eth-4<->backup_server:eth-1
|
||||||
- switch_1___security_suite
|
- switch_1:eth-7<->security_suite:eth-1
|
||||||
- switch_2___client_1
|
- switch_2:eth-1<->client_1:eth-1
|
||||||
- switch_2___client_2
|
- switch_2:eth-2<->client_2:eth-1
|
||||||
- switch_2___security_suite
|
- switch_2:eth-7<->security_suite:eth-2
|
||||||
- type: "NONE"
|
- type: "NONE"
|
||||||
label: ICS
|
label: ICS
|
||||||
options: {}
|
options: {}
|
||||||
@@ -924,56 +924,44 @@ simulation:
|
|||||||
- ref: client_2_dns_client
|
- ref: client_2_dns_client
|
||||||
type: DNSClient
|
type: DNSClient
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
links:
|
links:
|
||||||
- ref: router_1___switch_1
|
- endpoint_a_ref: router_1
|
||||||
endpoint_a_ref: router_1
|
|
||||||
endpoint_a_port: 1
|
endpoint_a_port: 1
|
||||||
endpoint_b_ref: switch_1
|
endpoint_b_ref: switch_1
|
||||||
endpoint_b_port: 8
|
endpoint_b_port: 8
|
||||||
- ref: router_1___switch_2
|
- endpoint_a_ref: router_1
|
||||||
endpoint_a_ref: router_1
|
|
||||||
endpoint_a_port: 2
|
endpoint_a_port: 2
|
||||||
endpoint_b_ref: switch_2
|
endpoint_b_ref: switch_2
|
||||||
endpoint_b_port: 8
|
endpoint_b_port: 8
|
||||||
- ref: switch_1___domain_controller
|
- endpoint_a_ref: switch_1
|
||||||
endpoint_a_ref: switch_1
|
|
||||||
endpoint_a_port: 1
|
endpoint_a_port: 1
|
||||||
endpoint_b_ref: domain_controller
|
endpoint_b_ref: domain_controller
|
||||||
endpoint_b_port: 1
|
endpoint_b_port: 1
|
||||||
- ref: switch_1___web_server
|
- endpoint_a_ref: switch_1
|
||||||
endpoint_a_ref: switch_1
|
|
||||||
endpoint_a_port: 2
|
endpoint_a_port: 2
|
||||||
endpoint_b_ref: web_server
|
endpoint_b_ref: web_server
|
||||||
endpoint_b_port: 1
|
endpoint_b_port: 1
|
||||||
- ref: switch_1___database_server
|
- endpoint_a_ref: switch_1
|
||||||
endpoint_a_ref: switch_1
|
|
||||||
endpoint_a_port: 3
|
endpoint_a_port: 3
|
||||||
endpoint_b_ref: database_server
|
endpoint_b_ref: database_server
|
||||||
endpoint_b_port: 1
|
endpoint_b_port: 1
|
||||||
- ref: switch_1___backup_server
|
- endpoint_a_ref: switch_1
|
||||||
endpoint_a_ref: switch_1
|
|
||||||
endpoint_a_port: 4
|
endpoint_a_port: 4
|
||||||
endpoint_b_ref: backup_server
|
endpoint_b_ref: backup_server
|
||||||
endpoint_b_port: 1
|
endpoint_b_port: 1
|
||||||
- ref: switch_1___security_suite
|
- endpoint_a_ref: switch_1
|
||||||
endpoint_a_ref: switch_1
|
|
||||||
endpoint_a_port: 7
|
endpoint_a_port: 7
|
||||||
endpoint_b_ref: security_suite
|
endpoint_b_ref: security_suite
|
||||||
endpoint_b_port: 1
|
endpoint_b_port: 1
|
||||||
- ref: switch_2___client_1
|
- endpoint_a_ref: switch_2
|
||||||
endpoint_a_ref: switch_2
|
|
||||||
endpoint_a_port: 1
|
endpoint_a_port: 1
|
||||||
endpoint_b_ref: client_1
|
endpoint_b_ref: client_1
|
||||||
endpoint_b_port: 1
|
endpoint_b_port: 1
|
||||||
- ref: switch_2___client_2
|
- endpoint_a_ref: switch_2
|
||||||
endpoint_a_ref: switch_2
|
|
||||||
endpoint_a_port: 2
|
endpoint_a_port: 2
|
||||||
endpoint_b_ref: client_2
|
endpoint_b_ref: client_2
|
||||||
endpoint_b_port: 1
|
endpoint_b_port: 1
|
||||||
- ref: switch_2___security_suite
|
- endpoint_a_ref: switch_2
|
||||||
endpoint_a_ref: switch_2
|
|
||||||
endpoint_a_port: 7
|
endpoint_a_port: 7
|
||||||
endpoint_b_ref: security_suite
|
endpoint_b_ref: security_suite
|
||||||
endpoint_b_port: 2
|
endpoint_b_port: 2
|
||||||
|
|||||||
@@ -228,16 +228,16 @@ agents:
|
|||||||
label: LINKS
|
label: LINKS
|
||||||
options:
|
options:
|
||||||
link_references:
|
link_references:
|
||||||
- router_1___switch_1
|
- router_1:eth-1<->switch_1:eth-8
|
||||||
- router_1___switch_2
|
- router_1:eth-2<->switch_2:eth-8
|
||||||
- switch_1___domain_controller
|
- switch_1:eth-1<->domain_controller:eth-1
|
||||||
- switch_1___web_server
|
- switch_1:eth-2<->web_server:eth-1
|
||||||
- switch_1___database_server
|
- switch_1:eth-3<->database_server:eth-1
|
||||||
- switch_1___backup_server
|
- switch_1:eth-4<->backup_server:eth-1
|
||||||
- switch_1___security_suite
|
- switch_1:eth-7<->security_suite:eth-1
|
||||||
- switch_2___client_1
|
- switch_2:eth-1<->client_1:eth-1
|
||||||
- switch_2___client_2
|
- switch_2:eth-2<->client_2:eth-1
|
||||||
- switch_2___security_suite
|
- switch_2:eth-7<->security_suite:eth-2
|
||||||
- type: "NONE"
|
- type: "NONE"
|
||||||
label: ICS
|
label: ICS
|
||||||
options: {}
|
options: {}
|
||||||
@@ -803,16 +803,16 @@ agents:
|
|||||||
label: LINKS
|
label: LINKS
|
||||||
options:
|
options:
|
||||||
link_references:
|
link_references:
|
||||||
- router_1___switch_1
|
- router_1:eth-1<->switch_1:eth-8
|
||||||
- router_1___switch_2
|
- router_1:eth-2<->switch_2:eth-8
|
||||||
- switch_1___domain_controller
|
- switch_1:eth-1<->domain_controller:eth-1
|
||||||
- switch_1___web_server
|
- switch_1:eth-2<->web_server:eth-1
|
||||||
- switch_1___database_server
|
- switch_1:eth-3<->database_server:eth-1
|
||||||
- switch_1___backup_server
|
- switch_1:eth-4<->backup_server:eth-1
|
||||||
- switch_1___security_suite
|
- switch_1:eth-7<->security_suite:eth-1
|
||||||
- switch_2___client_1
|
- switch_2:eth-1<->client_1:eth-1
|
||||||
- switch_2___client_2
|
- switch_2:eth-2<->client_2:eth-1
|
||||||
- switch_2___security_suite
|
- switch_2:eth-7<->security_suite:eth-2
|
||||||
- type: "NONE"
|
- type: "NONE"
|
||||||
label: ICS
|
label: ICS
|
||||||
options: {}
|
options: {}
|
||||||
@@ -1505,53 +1505,43 @@ simulation:
|
|||||||
|
|
||||||
|
|
||||||
links:
|
links:
|
||||||
- ref: router_1___switch_1
|
- endpoint_a_ref: router_1
|
||||||
endpoint_a_ref: router_1
|
|
||||||
endpoint_a_port: 1
|
endpoint_a_port: 1
|
||||||
endpoint_b_ref: switch_1
|
endpoint_b_ref: switch_1
|
||||||
endpoint_b_port: 8
|
endpoint_b_port: 8
|
||||||
- ref: router_1___switch_2
|
- endpoint_a_ref: router_1
|
||||||
endpoint_a_ref: router_1
|
|
||||||
endpoint_a_port: 2
|
endpoint_a_port: 2
|
||||||
endpoint_b_ref: switch_2
|
endpoint_b_ref: switch_2
|
||||||
endpoint_b_port: 8
|
endpoint_b_port: 8
|
||||||
- ref: switch_1___domain_controller
|
- endpoint_a_ref: switch_1
|
||||||
endpoint_a_ref: switch_1
|
|
||||||
endpoint_a_port: 1
|
endpoint_a_port: 1
|
||||||
endpoint_b_ref: domain_controller
|
endpoint_b_ref: domain_controller
|
||||||
endpoint_b_port: 1
|
endpoint_b_port: 1
|
||||||
- ref: switch_1___web_server
|
- endpoint_a_ref: switch_1
|
||||||
endpoint_a_ref: switch_1
|
|
||||||
endpoint_a_port: 2
|
endpoint_a_port: 2
|
||||||
endpoint_b_ref: web_server
|
endpoint_b_ref: web_server
|
||||||
endpoint_b_port: 1
|
endpoint_b_port: 1
|
||||||
- ref: switch_1___database_server
|
- endpoint_a_ref: switch_1
|
||||||
endpoint_a_ref: switch_1
|
|
||||||
endpoint_a_port: 3
|
endpoint_a_port: 3
|
||||||
endpoint_b_ref: database_server
|
endpoint_b_ref: database_server
|
||||||
endpoint_b_port: 1
|
endpoint_b_port: 1
|
||||||
- ref: switch_1___backup_server
|
- endpoint_a_ref: switch_1
|
||||||
endpoint_a_ref: switch_1
|
|
||||||
endpoint_a_port: 4
|
endpoint_a_port: 4
|
||||||
endpoint_b_ref: backup_server
|
endpoint_b_ref: backup_server
|
||||||
endpoint_b_port: 1
|
endpoint_b_port: 1
|
||||||
- ref: switch_1___security_suite
|
- endpoint_a_ref: switch_1
|
||||||
endpoint_a_ref: switch_1
|
|
||||||
endpoint_a_port: 7
|
endpoint_a_port: 7
|
||||||
endpoint_b_ref: security_suite
|
endpoint_b_ref: security_suite
|
||||||
endpoint_b_port: 1
|
endpoint_b_port: 1
|
||||||
- ref: switch_2___client_1
|
- endpoint_a_ref: switch_2
|
||||||
endpoint_a_ref: switch_2
|
|
||||||
endpoint_a_port: 1
|
endpoint_a_port: 1
|
||||||
endpoint_b_ref: client_1
|
endpoint_b_ref: client_1
|
||||||
endpoint_b_port: 1
|
endpoint_b_port: 1
|
||||||
- ref: switch_2___client_2
|
- endpoint_a_ref: switch_2
|
||||||
endpoint_a_ref: switch_2
|
|
||||||
endpoint_a_port: 2
|
endpoint_a_port: 2
|
||||||
endpoint_b_ref: client_2
|
endpoint_b_ref: client_2
|
||||||
endpoint_b_port: 1
|
endpoint_b_port: 1
|
||||||
- ref: switch_2___security_suite
|
- endpoint_a_ref: switch_2
|
||||||
endpoint_a_ref: switch_2
|
|
||||||
endpoint_a_port: 7
|
endpoint_a_port: 7
|
||||||
endpoint_b_ref: security_suite
|
endpoint_b_ref: security_suite
|
||||||
endpoint_b_port: 2
|
endpoint_b_port: 2
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class LinkObservation(AbstractObservation, identifier="LINK"):
|
|||||||
:return: Constructed link observation instance.
|
:return: Constructed link observation instance.
|
||||||
:rtype: LinkObservation
|
:rtype: LinkObservation
|
||||||
"""
|
"""
|
||||||
link_reference = game.ref_map_links[config.link_reference]
|
link_reference = config.link_reference
|
||||||
if parent_where == []:
|
if parent_where == []:
|
||||||
where = ["network", "links", link_reference]
|
where = ["network", "links", link_reference]
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -111,9 +111,6 @@ class PrimaiteGame:
|
|||||||
self.ref_map_applications: Dict[str, str] = {}
|
self.ref_map_applications: Dict[str, str] = {}
|
||||||
"""Mapping from human-readable application reference to application object. Used for parsing config files."""
|
"""Mapping from human-readable application reference to application object. Used for parsing config files."""
|
||||||
|
|
||||||
self.ref_map_links: Dict[str, str] = {}
|
|
||||||
"""Mapping from human-readable link reference to link object. Used when parsing config files."""
|
|
||||||
|
|
||||||
self.save_step_metadata: bool = False
|
self.save_step_metadata: bool = False
|
||||||
"""Whether to save the RL agents' action, environment state, and other data at every single step."""
|
"""Whether to save the RL agents' action, environment state, and other data at every single step."""
|
||||||
|
|
||||||
@@ -409,8 +406,7 @@ class PrimaiteGame:
|
|||||||
endpoint_b = node_b.network_interface[link_cfg["endpoint_b_port"]]
|
endpoint_b = node_b.network_interface[link_cfg["endpoint_b_port"]]
|
||||||
else:
|
else:
|
||||||
endpoint_b = node_b.network_interface[link_cfg["endpoint_b_port"]]
|
endpoint_b = node_b.network_interface[link_cfg["endpoint_b_port"]]
|
||||||
new_link = net.connect(endpoint_a=endpoint_a, endpoint_b=endpoint_b)
|
net.connect(endpoint_a=endpoint_a, endpoint_b=endpoint_b)
|
||||||
game.ref_map_links[link_cfg["ref"]] = new_link.uuid
|
|
||||||
|
|
||||||
# 3. create agents
|
# 3. create agents
|
||||||
agents_cfg = cfg.get("agents", [])
|
agents_cfg = cfg.get("agents", [])
|
||||||
|
|||||||
@@ -225,18 +225,19 @@ class Network(SimComponent):
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
# Update the links one-by-one. The key is a 4-tuple of `hostname_a, port_a, hostname_b, port_b`
|
# Update the links one-by-one. The key is a 4-tuple of `hostname_a, port_a, hostname_b, port_b`
|
||||||
for uuid, link in self.links.items():
|
for _, link in self.links.items():
|
||||||
node_a = link.endpoint_a._connected_node
|
node_a = link.endpoint_a._connected_node
|
||||||
node_b = link.endpoint_b._connected_node
|
node_b = link.endpoint_b._connected_node
|
||||||
hostname_a = node_a.hostname if node_a else None
|
hostname_a = node_a.hostname if node_a else None
|
||||||
hostname_b = node_b.hostname if node_b else None
|
hostname_b = node_b.hostname if node_b else None
|
||||||
port_a = link.endpoint_a.port_num
|
port_a = link.endpoint_a.port_num
|
||||||
port_b = link.endpoint_b.port_num
|
port_b = link.endpoint_b.port_num
|
||||||
state["links"][uuid] = link.describe_state()
|
link_key = f"{hostname_a}:eth-{port_a}<->{hostname_b}:eth-{port_b}"
|
||||||
state["links"][uuid]["hostname_a"] = hostname_a
|
state["links"][link_key] = link.describe_state()
|
||||||
state["links"][uuid]["hostname_b"] = hostname_b
|
state["links"][link_key]["hostname_a"] = hostname_a
|
||||||
state["links"][uuid]["port_a"] = port_a
|
state["links"][link_key]["hostname_b"] = hostname_b
|
||||||
state["links"][uuid]["port_b"] = port_b
|
state["links"][link_key]["port_a"] = port_a
|
||||||
|
state["links"][link_key]["port_b"] = port_b
|
||||||
|
|
||||||
return state
|
return state
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user