#1800 - Fixed the ping functionality so that it actually checks for replies and returns True if the right number of replies have been received.

- Added the foundations of a Router class along with ACLRule and RouteTableEntry classes.
This commit is contained in:
Chris McCarthy
2023-08-25 09:07:32 +01:00
parent 01e8501bc1
commit c6f71600fc
4 changed files with 134 additions and 8 deletions

View File

@@ -45,7 +45,7 @@ def test_multi_nic():
node_a.ping("192.168.0.11")
node_c.ping("10.0.0.12")
assert node_c.ping("10.0.0.12")
def test_switched_network():
@@ -83,4 +83,4 @@ def test_switched_network():
link_nic_d_switch_2 = Link(endpoint_a=nic_d, endpoint_b=switch_2.switch_ports[2])
link_switch_1_switch_2 = Link(endpoint_a=switch_1.switch_ports[6], endpoint_b=switch_2.switch_ports[6])
pc_a.ping("192.168.0.13")
assert pc_a.ping("192.168.0.13")

View File

@@ -0,0 +1,27 @@
from primaite.simulator.network.hardware.base import Node, NIC, Link
from primaite.simulator.network.hardware.nodes.router import Router
def test_ping_fails_with_no_route():
"""Tests a larges network of Nodes and Switches with one node pinging another."""
pc_a = Node(hostname="pc_a")
nic_a = NIC(ip_address="192.168.0.10", subnet_mask="255.255.255.0", gateway="192.168.0.1")
pc_a.connect_nic(nic_a)
pc_a.power_on()
pc_b = Node(hostname="pc_b")
nic_b = NIC(ip_address="192.168.1.10", subnet_mask="255.255.255.0", gateway="192.168.1.1")
pc_b.connect_nic(nic_b)
pc_b.power_on()
router_1 = Router(hostname="router_1")
router_1.configure_port(1, "192.168.0.1", "255.255.255.0")
router_1.configure_port(2, "192.168.1.1", "255.255.255.0")
router_1.power_on()
router_1.show()
link_nic_a_router_1 = Link(endpoint_a=nic_a, endpoint_b=router_1.ethernet_ports[1])
link_nic_b_router_1 = Link(endpoint_a=nic_b, endpoint_b=router_1.ethernet_ports[2])
router_1.power_on()
#assert pc_a.ping("192.168.1.10")