#2257: temporarily commit changes - added startup and shut down durations to node config + adding routes

This commit is contained in:
Czar Echavez
2024-02-13 13:02:24 +00:00
parent f4369a4fff
commit b277034e8b
4 changed files with 105 additions and 37 deletions

View File

@@ -9,26 +9,26 @@
# . -------------- -------------- -------------- .
# . | client_1 |------| switch_1 |------| router_1 | .
# . -------------- -------------- -------------- .
# . (Computer) | .
# ......................................................|.....................
# |
# |
# ......................................................|.....................
# . | .
# . DMZ Network | .
# . | .
# . -------------- -------------- -------------- .
# . | client_2 |------| switch_2 |------| router_2 | .
# . -------------- -------------- -------------- .
# . (Computer) | .
# ......................................................|.....................
# |
# External Network |
# |
# |
# ----------------------- -------------- ---------------------
# | external_computer |------| switch_3 |------| external_server |
# ----------------------- -------------- ---------------------
# . (Computer) | .
# ........................................................|.....................
# |
# |
# ........................................................|.....................
# . | .
# . DMZ Network | .
# . | .
# . ---------------- -------------- -------------- .
# . | dmz_server |------| switch_2 |------| router_2 | .
# . ---------------- -------------- -------------- .
# . (Computer) | .
# ........................................................|...................
# |
# External Network |
# |
# |
# ----------------------- -------------- ---------------------
# | external_computer |------| switch_3 |------| external_server |
# ----------------------- -------------- ---------------------
#
training_config:
rl_framework: SB3
@@ -63,7 +63,7 @@ game:
- UDP
agents:
- ref: client_2_green_user
- ref: client_1_green_user
team: GREEN
type: GreenWebBrowsingAgent
observation_space:
@@ -74,7 +74,7 @@ agents:
- type: NODE_APPLICATION_EXECUTE
options:
nodes:
- node_name: client_2
- node_name: client_1
applications:
- application_name: WebBrowser
max_folders_per_node: 1
@@ -102,17 +102,23 @@ simulation:
ip_address: 192.168.0.10
subnet_mask: 255.255.255.0
default_gateway: 192.168.0.1
dns_server: 192.168.20.10
dns_server: 192.168.20.11
start_up_duration: 0
shut_down_duration: 0
- ref: switch_1
type: switch
hostname: switch_1
num_ports: 8
start_up_duration: 0
shut_down_duration: 0
- ref: router_1
type: router
hostname: router_1
num_ports: 5
start_up_duration: 0
shut_down_duration: 0
ports:
1:
ip_address: 192.168.0.1
@@ -128,24 +134,43 @@ simulation:
23:
action: PERMIT
protocol: ICMP
routes:
- address: 192.168.10.10
subnet_mask: 255.255.255.0
next_hop_ip_address: 192.168.11.1
metric: 0
- address: 192.168.20.10
subnet_mask: 255.255.255.0
next_hop_ip_address: 192.168.11.1
metric: 0
- address: 192.168.20.11
subnet_mask: 255.255.255.0
next_hop_ip_address: 192.168.11.1
metric: 0
- ref: client_2
type: computer
hostname: client_2
- ref: dmz_server
type: server
hostname: dmz_server
ip_address: 192.168.10.10
subnet_mask: 255.255.255.0
default_gateway: 192.168.10.1
dns_server: 192.168.20.10
dns_server: 192.168.20.11
start_up_duration: 0
shut_down_duration: 0
- ref: switch_2
type: switch
hostname: switch_2
num_ports: 8
start_up_duration: 0
shut_down_duration: 0
- ref: router_2
type: router
hostname: router_2
num_ports: 5
start_up_duration: 0
shut_down_duration: 0
ports:
1:
ip_address: 192.168.10.1
@@ -164,11 +189,18 @@ simulation:
23:
action: PERMIT
protocol: ICMP
routes:
- address: 192.168.0.10
subnet_mask: 255.255.255.0
next_hop_ip_address: 192.168.1.1
metric: 0
- ref: switch_3
type: switch
hostname: switch_3
num_ports: 8
start_up_duration: 0
shut_down_duration: 0
- ref: external_computer
type: computer
@@ -176,14 +208,18 @@ simulation:
ip_address: 192.168.20.10
subnet_mask: 255.255.255.0
default_gateway: 192.168.20.1
dns_server: 192.168.20.10
dns_server: 192.168.20.11
start_up_duration: 0
shut_down_duration: 0
- ref: external_server
type: server
hostname: external_server
ip_address: 192.168.20.10
ip_address: 192.168.20.11
subnet_mask: 255.255.255.0
default_gateway: 192.168.20.1
start_up_duration: 0
shut_down_duration: 0
services:
- ref: domain_controller_dns_server
type: DNSServer
@@ -208,8 +244,8 @@ simulation:
endpoint_a_port: 1
endpoint_b_ref: switch_2
endpoint_b_port: 8
- ref: client_2___switch_2
endpoint_a_ref: client_2
- ref: dmz_server___switch_2
endpoint_a_ref: dmz_server
endpoint_a_port: 1
endpoint_b_ref: switch_2
endpoint_b_port: 1

View File

@@ -5,6 +5,9 @@ import yaml
from primaite.game.game import PrimaiteGame
from primaite.simulator.network.container import Network
from primaite.simulator.network.hardware.nodes.host.computer import Computer
from primaite.simulator.network.hardware.nodes.host.server import Server
from primaite.simulator.network.hardware.nodes.network.router import Router
from tests import TEST_ASSETS_ROOT
DMZ_NETWORK = TEST_ASSETS_ROOT / "configs/dmz_network.yaml"
@@ -27,12 +30,27 @@ def test_dmz_config():
assert len(network.nodes) == 9 # 9 nodes in network
assert len(network.routers) == 2 # 2 routers in network
assert len(network.switches) == 3 # 3 switches in network
assert len(network.servers) == 1 # 1 server in network
assert len(network.servers) == 2 # 2 servers in network
def test_router_routes_are_correctly_added():
"""Test that makes sure that router routes have been added from the configuration file."""
pass
game = load_config(DMZ_NETWORK)
network: Network = game.simulation.network
router_1: Router = network.get_node_by_hostname("router_1")
client_1: Computer = network.get_node_by_hostname("client_1")
dmz_server: Server = network.get_node_by_hostname("dmz_server")
external_computer: Computer = network.get_node_by_hostname("external_computer")
external_server: Server = network.get_node_by_hostname("external_server")
# test that client_1 has a route to the DMZ and external nodes - they are on a second router
# there should be a route to the dmz server
assert router_1.route_table.find_best_route(dmz_server.network_interface[1].ip_address)
# ping DMZ server
# assert client_1.ping(dmz_server.network_interface[1].ip_address)
def test_firewall_node_added_to_network():