#2457 - Commit before switching branches to review

This commit is contained in:
Charlie Crane
2024-05-03 08:35:24 +01:00
parent 4763344835
commit 4cd15a39aa
3 changed files with 9 additions and 1 deletions

View File

@@ -368,6 +368,7 @@ simulation:
endpoint_a_port: 1
endpoint_b_hostname: switch_1
endpoint_b_port: 1
bandwidth: 200
- endpoint_a_hostname: pc_2
endpoint_a_port: 1
endpoint_b_hostname: switch_1

View File

@@ -406,9 +406,15 @@ class PrimaiteGame:
new_node.shut_down_duration = int(node_cfg.get("shut_down_duration", 3))
# 2. create links between nodes
# TODO: Pull from link_cfg the 'bandwidth' of that link
for link_cfg in links_cfg:
node_a = net.get_node_by_hostname(link_cfg["endpoint_a_hostname"])
node_b = net.get_node_by_hostname(link_cfg["endpoint_b_hostname"])
print(link_cfg)
try:
bandwidth = link_cfg["bandwidth"]
except Exception:
bandwidth = 100
if isinstance(node_a, Switch):
endpoint_a = node_a.network_interface[link_cfg["endpoint_a_port"]]
@@ -418,7 +424,7 @@ class PrimaiteGame:
endpoint_b = node_b.network_interface[link_cfg["endpoint_b_port"]]
else:
endpoint_b = node_b.network_interface[link_cfg["endpoint_b_port"]]
net.connect(endpoint_a=endpoint_a, endpoint_b=endpoint_b)
net.connect(endpoint_a=endpoint_a, endpoint_b=endpoint_b, bandwidth=bandwidth)
# 3. create agents
agents_cfg = cfg.get("agents", [])

View File

@@ -315,4 +315,5 @@ def basic_lan_network_example() -> Network:
def multi_lan_internet_network_example() -> Network:
"""Get Multi-LAN with Internet example network."""
path = PRIMAITE_PATHS.user_config_path / "example_config" / "multi_lan_internet_network_example.yaml"
print(path)
return _get_example_network(path)