#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

@@ -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")