diff --git a/tests/port/arp.py b/tests/port/arp.py new file mode 100644 index 0000000..1fffee8 --- /dev/null +++ b/tests/port/arp.py @@ -0,0 +1,53 @@ + +import unittest + +from dsatest.bench import bench + +class TestArp(unittest.TestCase): + + + def setUp(self): + links = bench.links + if len(links) == 0: + self.skipTest("Empty link list") + + for i, l in enumerate(links, start=1): + l.host_if.flushAddresses() + l.target_if.flushAddresses() + + def tearDown(self): + pass + + def test_port_arp(self): + links = bench.links + + for i, l in enumerate(links, start=1): + host_addr = "192.168.10.{}/24".format(str(i * 2)) + target_addr = "192.168.10.{}/24".format(str(i * 2 + 1)) + + l.host_if.addAddress(host_addr) + l.target_if.addAddress(target_addr) + + host_addr = "192.168.10.{}".format(str(i * 2)) + target_addr = "192.168.10.{}".format(str(i * 2 + 1)) + + l.host_if.ping(target_addr, count=1, deadline=10) + + """ + Ask the host about the target IP address + """ + reply = l.host_if.arp.get(target_addr)[0] + if reply.interface != l.host_if.name: + raise ValueError("Interface mismatch. Got {}, expected {}". + format(reply.interface, l.host_if.name)) + """ + Ask the target about the host IP address + """ + reply = l.target_if.arp.get(host_addr)[0] + + if reply.interface != l.target_if.name: + raise ValueError("Interface mismatch. Got {}, expected {}". + format(reply.interface, l.target_if.name)) + + l.host_if.flushAddresses() + l.target_if.flushAddresses()