diff --git a/src/primaite/simulator/network/hardware/nodes/router.py b/src/primaite/simulator/network/hardware/nodes/router.py index 1e3d8022..172cc711 100644 --- a/src/primaite/simulator/network/hardware/nodes/router.py +++ b/src/primaite/simulator/network/hardware/nodes/router.py @@ -590,8 +590,8 @@ class RouterARPCache(ARPCache): self.send_arp_request(route.next_hop_ip_address, ignore_networks=[frame.ip.src_ip_address]) return self.process_arp_packet(from_nic, frame, route_table, is_reattempt=True) else: - pass - # TODO: destination unavailable/No ARP netry found + self.sys_log.info("Ignoring ARP request as destination unavailable/No ARP entry found") + return else: arp_reply = arp_packet.generate_reply(from_nic.mac_address) self.send_arp_reply(arp_reply, from_nic) @@ -797,7 +797,7 @@ class Router(Node): return self.process_frame(frame=frame, from_nic=from_nic, re_attempt=True) if not nic.enabled: - # TODO: Add sys_log here + self.sys_log.info(f"Frame dropped as NIC {nic} is not enabled") return if frame.ip.dst_ip_address in nic.ip_network: @@ -829,7 +829,7 @@ class Router(Node): return self.process_frame(frame=frame, from_nic=from_nic, re_attempt=True) if not nic.enabled: - # TODO: Add sys_log here + self.sys_log.info(f"Frame dropped as NIC {nic} is not enabled") return from_port = self._get_port_of_nic(from_nic) diff --git a/src/primaite/simulator/network/hardware/nodes/switch.py b/src/primaite/simulator/network/hardware/nodes/switch.py index ead857f2..b394bae0 100644 --- a/src/primaite/simulator/network/hardware/nodes/switch.py +++ b/src/primaite/simulator/network/hardware/nodes/switch.py @@ -90,7 +90,7 @@ class Switch(Node): self._add_mac_table_entry(src_mac, incoming_port) outgoing_port = self.mac_address_table.get(dst_mac) - if outgoing_port and dst_mac != "ff:ff:ff:ff:ff:ff": + if outgoing_port and dst_mac.lower() != "ff:ff:ff:ff:ff:ff": outgoing_port.send_frame(frame) else: # If the destination MAC is not in the table, flood to all ports except incoming diff --git a/tests/integration_tests/network/test_routing.py b/tests/integration_tests/network/test_routing.py index 3f636eae..042debca 100644 --- a/tests/integration_tests/network/test_routing.py +++ b/tests/integration_tests/network/test_routing.py @@ -9,6 +9,8 @@ from primaite.simulator.network.hardware.nodes.computer import Computer from primaite.simulator.network.hardware.nodes.router import ACLAction, Router from primaite.simulator.network.transmission.network_layer import IPProtocol from primaite.simulator.network.transmission.transport_layer import Port +from primaite.simulator.system.services.ntp.ntp_client import NTPClient +from primaite.simulator.system.services.ntp.ntp_server import NTPServer @pytest.fixture(scope="function") @@ -143,3 +145,41 @@ def test_with_routes_can_ping(multi_hop_network): ) assert pc_a.ping(pc_b.ethernet_port[1].ip_address) + + +def test_routing_services(multi_hop_network): + pc_a = multi_hop_network.get_node_by_hostname("pc_a") + + pc_b = multi_hop_network.get_node_by_hostname("pc_b") + + pc_a.software_manager.install(NTPClient) + ntp_client = pc_a.software_manager.software["NTPClient"] + ntp_client.start() + + pc_b.software_manager.install(NTPServer) + pc_b.software_manager.software["NTPServer"].start() + + ntp_client.configure(ntp_server_ip_address=pc_b.ethernet_port[1].ip_address) + + router_1: Router = multi_hop_network.get_node_by_hostname("router_1") # noqa + router_2: Router = multi_hop_network.get_node_by_hostname("router_2") # noqa + + router_1.acl.add_rule(action=ACLAction.PERMIT, src_port=Port.NTP, dst_port=Port.NTP, position=21) + router_2.acl.add_rule(action=ACLAction.PERMIT, src_port=Port.NTP, dst_port=Port.NTP, position=21) + + assert ntp_client.time is None + ntp_client.request_time() + assert ntp_client.time is None + + # Configure Route from Router 1 to PC B subnet + router_1.route_table.add_route( + address="192.168.2.0", subnet_mask="255.255.255.0", next_hop_ip_address="192.168.1.2" + ) + + # Configure Route from Router 2 to PC A subnet + router_2.route_table.add_route( + address="192.168.0.2", subnet_mask="255.255.255.0", next_hop_ip_address="192.168.1.1" + ) + + ntp_client.request_time() + assert ntp_client.time is not None