- Added .show() methods to new router classes to enable inspection of the components as you would a real router. - Removed gateway from the NIC and added default_gateway to Node so that Node has a single default gateway. - Added some routing tests to check that ping can be performed when router between subnets.
21 lines
631 B
Python
21 lines
631 B
Python
from primaite.simulator.network.hardware.base import Link, NIC, Node
|
|
|
|
|
|
def test_link_up():
|
|
"""Tests Nodes, NICs, and Links can all be connected and be in an enabled/up state."""
|
|
node_a = Node(hostname="node_a")
|
|
nic_a = NIC(ip_address="192.168.0.10", subnet_mask="255.255.255.0")
|
|
node_a.connect_nic(nic_a)
|
|
node_a.power_on()
|
|
|
|
node_b = Node(hostname="node_b")
|
|
nic_b = NIC(ip_address="192.168.0.11", subnet_mask="255.255.255.0")
|
|
node_b.connect_nic(nic_b)
|
|
node_b.power_on()
|
|
|
|
link = Link(endpoint_a=nic_a, endpoint_b=nic_b)
|
|
|
|
assert nic_a.enabled
|
|
assert nic_b.enabled
|
|
assert link.is_up
|