class TestNetworkTestCase(unittest.TestCase): def setUp(self): self.n = TestNetwork(TestNetworkConfiguration()) self.n._TestNetwork__taps[0].unbind() self.n._TestNetwork__taps[1].unbind() self.n.node(1).if0.ips.append(IPAddress.identify("2001:500:88:200::10")) self.n.node(1).if0.ips.append(IPAddress.identify("fe80:500:88:200::10")) self.n.node(2).if0.ips.append(IPAddress.identify("2001:600:88:200::10")) self.n.node(2).if0.ips.append(IPAddress.identify("fe80:600:88:200::10")) self.n.node(3).if0.ips.append(IPAddress.identify("2001:600:88:200::11")) self.n.node(3).if0.ips.append(IPAddress.identify("fe80:600:88:200::11")) self.n.node(4).if0.ips.append(IPAddress.identify("2001:700:88:200::10")) self.n.node(4).if0.ips.append(IPAddress.identify("fe80:700:88:200::10")) self.n.router(1).if0.ips.append(IPAddress.identify("2001:600:88:200::1")) self.n.router(1).if0.ips.append(IPAddress.identify("fe80:600:88:200::1")) self.n.router(1).if1.ips.append(IPAddress.identify("2001:500:88:200::1")) self.n.router(1).if1.ips.append(IPAddress.identify("fe80:500:88:200::1")) self.n.router(1)._TestRouter__forwards_to_0.append(Network("2001:0600:0088:0200::/64")) self.n.router(1)._TestRouter__forwards_to_1.append(Network("2001:0500:0088:0200::/64")) self.n.router(2).if0.ips.append(IPAddress.identify("2001:600:88:200::2")) self.n.router(2).if0.ips.append(IPAddress.identify("fe80:600:88:200::2")) self.n.router(2).if1.ips.append(IPAddress.identify("2001:500:88:200::2")) self.n.router(2).if1.ips.append(IPAddress.identify("fe80:500:88:200::2")) self.n.router(3).if0.ips.append(IPAddress.identify("2001:600:88:200::3")) self.n.router(3).if0.ips.append(IPAddress.identify("fe80:600:88:200::3")) self.n.router(3).if1.ips.append(IPAddress.identify("2001:500:88:200::3")) self.n.router(3).if1.ips.append(IPAddress.identify("fe80:500:88:200::3")) self.ethx_s = MockInterface("if0", "00:b0:d0:86:bb:f7") self.ethx_t = TargetInterface( ips=[IPAddress.identify("2001:500:88:200::20"), IPAddress.identify("fe80:500:88:200::20")], link_addr="00:b0:d0:bb:cc:ff", ) self.ethx = Tap(self.n.link(2), self.ethx_s, self.ethx_t) self.ethy_s = MockInterface("if1", "00:b0:e0:86:bb:f7") self.ethy_t = TargetInterface( ips=[IPAddress.identify("2001:600:88:200::20"), IPAddress.identify("fe80:600:88:200::20")], link_addr="00:b0:e0:bb:cc:ff", ) self.ethy = Tap(self.n.link(3), self.ethy_s, self.ethy_t) def test_it_should_deliver_a_packet_from_tn1_on_ethx(self): self.n.node(1).send( IPv6(src=str(self.n.node(1).global_ip()), dst=str(self.ethx_t.global_ip())) / ICMPv6EchoRequest() ) self.assertEqual(1, len(self.ethx_s.sent)) p = self.ethx_s.sent[0] self.assertTrue(p.haslayer(Ether)) self.assertEqual("00:b0:d0:86:bb:f7", p.getlayer(Ether).src) self.assertEqual("00:b0:d0:bb:cc:ff", p.getlayer(Ether).dst) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.n.node(1).global_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.ethx_t.global_ip().short_form(), p.getlayer(IPv6).dst) self.assertTrue(self.ethx_s.sent[0].haslayer(ICMPv6EchoRequest)) def test_it_should_deliver_a_link_local_packet_from_tn1_to_ethx(self): self.n.node(1).send( IPv6(src=str(self.n.node(1).link_local_ip()), dst=str(self.ethx_t.link_local_ip())) / ICMPv6EchoRequest() ) self.assertEqual(1, len(self.ethx_s.sent)) p = self.ethx_s.sent[0] self.assertTrue(p.haslayer(Ether)) self.assertEqual("00:b0:d0:86:bb:f7", p.getlayer(Ether).src) self.assertEqual("00:b0:d0:bb:cc:ff", p.getlayer(Ether).dst) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.n.node(1).link_local_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.ethx_t.link_local_ip().short_form(), p.getlayer(IPv6).dst) self.assertTrue(self.ethx_s.sent[0].haslayer(ICMPv6EchoRequest)) def test_it_should_not_deliver_a_packet_from_tn1_on_ethy(self): self.n.node(1).send( IPv6(src=str(self.n.node(1).link_local_ip()), dst=str(self.ethx_t.link_local_ip())) / ICMPv6EchoRequest() ) self.assertEqual(0, len(self.ethy_s.sent)) def test_it_should_deliver_a_packet_from_tn2_on_ethx(self): self.n.node(2).send( IPv6(src=str(self.n.node(2).global_ip()), dst=str(self.ethx_t.global_ip())) / ICMPv6EchoRequest() ) self.assertEqual(1, len(self.ethx_s.sent)) p = self.ethx_s.sent[0] self.assertTrue(p.haslayer(Ether)) self.assertEqual("00:b0:d0:86:bb:f7", p.getlayer(Ether).src) self.assertEqual("00:b0:d0:bb:cc:ff", p.getlayer(Ether).dst) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.n.node(2).global_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.ethx_t.global_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_not_deliver_a_link_local_packet_from_tn2_on_ethx(self): self.n.node(2).send( IPv6(src=str(self.n.node(2).link_local_ip()), dst=str(self.ethx_t.link_local_ip())) / ICMPv6EchoRequest() ) self.assertEqual(0, len(self.ethx_s.sent)) def test_it_should_not_deliver_a_packet_from_tn2_on_ethy(self): self.n.node(2).send( IPv6(src=str(self.n.node(2).link_local_ip()), dst=str(self.ethx_t.link_local_ip())) / ICMPv6EchoRequest() ) self.assertEqual(0, len(self.ethy_s.sent)) def test_it_should_deliver_a_packet_from_tn3_on_ethx(self): self.n.node(3).send( IPv6(src=str(self.n.node(3).global_ip()), dst=str(self.ethx_t.global_ip())) / ICMPv6EchoRequest() ) self.assertEqual(1, len(self.ethx_s.sent)) p = self.ethx_s.sent[0] self.assertTrue(p.haslayer(Ether)) self.assertEqual("00:b0:d0:86:bb:f7", p.getlayer(Ether).src) self.assertEqual("00:b0:d0:bb:cc:ff", p.getlayer(Ether).dst) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.n.node(3).global_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.ethx_t.global_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_not_deliver_a_link_local_packet_from_tn3_on_ethx(self): self.n.node(3).send( IPv6(src=str(self.n.node(3).link_local_ip()), dst=str(self.ethx_t.link_local_ip())) / ICMPv6EchoRequest() ) self.assertEqual(0, len(self.ethx_s.sent)) def test_it_should_not_deliver_a_packet_from_tn3_on_ethy(self): self.n.node(3).send( IPv6(src=str(self.n.node(3).link_local_ip()), dst=str(self.ethx_t.link_local_ip())) / ICMPv6EchoRequest() ) self.assertEqual(0, len(self.ethy_s.sent)) def test_it_should_deliver_a_packet_from_tn4_on_ethy(self): self.n.node(4).send( IPv6(src=str(self.n.node(4).global_ip()), dst=str(self.ethy_t.global_ip())) / ICMPv6EchoRequest() ) self.assertEqual(1, len(self.ethy_s.sent)) p = self.ethy_s.sent[0] self.assertTrue(p.haslayer(Ether)) self.assertEqual("00:b0:e0:86:bb:f7", p.getlayer(Ether).src) self.assertEqual("00:b0:e0:bb:cc:ff", p.getlayer(Ether).dst) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.n.node(4).global_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.ethy_t.global_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_deliver_a_link_local_packet_from_tn4_on_ethy(self): self.n.node(4).send( IPv6(src=str(self.n.node(4).link_local_ip()), dst=str(self.ethy_t.link_local_ip())) / ICMPv6EchoRequest() ) self.assertEqual(1, len(self.ethy_s.sent)) p = self.ethy_s.sent[0] self.assertTrue(p.haslayer(Ether)) self.assertEqual("00:b0:e0:86:bb:f7", p.getlayer(Ether).src) self.assertEqual("00:b0:e0:bb:cc:ff", p.getlayer(Ether).dst) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.n.node(4).link_local_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.ethy_t.link_local_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_not_deliver_a_packet_from_tn4_on_ethx(self): self.n.node(4).send( IPv6(src=str(self.n.node(4).global_ip()), dst=str(self.ethy_t.global_ip())) / ICMPv6EchoRequest() ) self.assertEqual(0, len(self.ethx_s.sent)) def test_it_should_deliver_a_packet_from_tr1_on_ethx(self): self.n.router(1).send( IPv6(src=str(self.n.router(1).global_ip()), dst=str(self.ethx_t.global_ip())) / ICMPv6EchoRequest(), iface=1 ) self.assertEqual(1, len(self.ethx_s.sent)) p = self.ethx_s.sent[0] self.assertTrue(p.haslayer(Ether)) self.assertEqual("00:b0:d0:86:bb:f7", p.getlayer(Ether).src) self.assertEqual("00:b0:d0:bb:cc:ff", p.getlayer(Ether).dst) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.n.router(1).global_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.ethx_t.global_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_deliver_a_link_local_packet_from_tr1_on_ethx(self): self.n.router(1).send( IPv6(src=str(self.n.router(1).link_local_ip()), dst=str(self.ethx_t.link_local_ip())) / ICMPv6EchoRequest(), iface=1, ) self.assertEqual(1, len(self.ethx_s.sent)) p = self.ethx_s.sent[0] self.assertTrue(p.haslayer(Ether)) self.assertEqual("00:b0:d0:86:bb:f7", p.getlayer(Ether).src) self.assertEqual("00:b0:d0:bb:cc:ff", p.getlayer(Ether).dst) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.n.router(1).link_local_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.ethx_t.link_local_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_not_deliver_a_packet_from_tr1_if0_to_ethx(self): self.n.router(1).send( IPv6(src=str(self.n.router(1).global_ip()), dst=str(self.ethx_t.global_ip())) / ICMPv6EchoRequest(), iface=0 ) self.assertEqual(0, len(self.ethx_s.sent)) def test_it_should_not_deliver_a_packet_from_tr1_on_ethy(self): self.n.router(1).send( IPv6(src=str(self.n.router(1).link_local_ip(iface=1)), dst=str(self.ethx_t.link_local_ip())) / ICMPv6EchoRequest(), iface=1, ) self.assertEqual(0, len(self.ethy_s.sent)) def test_it_should_deliver_a_packet_from_tr2_on_ethx(self): self.n.router(2).send( IPv6(src=str(self.n.router(2).link_local_ip(iface=1)), dst=str(self.ethx_t.link_local_ip())) / ICMPv6EchoRequest(), iface=1, ) self.assertEqual(0, len(self.ethy_s.sent)) def test_it_should_deliver_a_packet_from_tr3_on_ethx(self): self.n.router(3).send( IPv6(src=str(self.n.router(3).link_local_ip(iface=1)), dst=str(self.ethx_t.link_local_ip())) / ICMPv6EchoRequest(), iface=1, ) self.assertEqual(1, len(self.ethx_s.sent)) def test_it_should_deliver_a_packet_from_ethx_to_tn1(self): self.ethx_s.accept( IPv6(src=str(self.ethx_t.global_ip()), dst=str(self.n.node(1).global_ip())) / ICMPv6EchoReply() ) self.assertEqual(1, len(self.n.node(1).received())) p = self.n.node(1).received()[0] self.assertFalse(p.haslayer(Ether)) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.ethx_t.global_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.n.node(1).global_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_deliver_a_link_local_packet_from_ethx_to_tn1(self): self.ethx_s.accept( IPv6(src=str(self.ethx_t.link_local_ip()), dst=str(self.n.node(1).link_local_ip())) / ICMPv6EchoReply() ) self.assertEqual(1, len(self.n.node(1).received())) p = self.n.node(1).received()[0] self.assertFalse(p.haslayer(Ether)) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.ethx_t.link_local_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.n.node(1).link_local_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_not_deliver_a_packet_from_ethy_to_tn1(self): self.ethy_s.accept( IPv6(src=str(self.ethx_t.global_ip()), dst=str(self.n.node(1).global_ip())) / ICMPv6EchoReply() ) self.assertEqual(0, len(self.n.node(1).received())) def test_it_should_deliver_a_packet_from_ethx_to_tn2(self): self.ethx_s.accept( IPv6(src=str(self.ethx_t.global_ip()), dst=str(self.n.node(2).global_ip())) / ICMPv6EchoReply() ) self.assertEqual(1, len(self.n.node(2).received())) p = self.n.node(2).received()[0] self.assertFalse(p.haslayer(Ether)) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.ethx_t.global_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.n.node(2).global_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_not_deliver_a_link_local_packet_from_ethx_to_tn2(self): self.ethx_s.accept( IPv6(src=str(self.ethx_t.link_local_ip()), dst=str(self.n.node(2).link_local_ip())) / ICMPv6EchoReply() ) self.assertEqual(0, len(self.n.node(2).received())) def test_it_should_not_deliver_a_packet_from_ethy_to_tn2(self): self.ethy_s.accept( IPv6(src=str(self.ethx_t.global_ip()), dst=str(self.n.node(2).global_ip())) / ICMPv6EchoReply() ) self.assertEqual(0, len(self.n.node(2).received())) def test_it_should_deliver_a_packet_from_ethx_to_tn3(self): self.ethx_s.accept( IPv6(src=str(self.ethx_t.global_ip()), dst=str(self.n.node(3).global_ip())) / ICMPv6EchoReply() ) self.assertEqual(1, len(self.n.node(3).received())) p = self.n.node(3).received()[0] self.assertFalse(p.haslayer(Ether)) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.ethx_t.global_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.n.node(3).global_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_not_deliver_a_link_local_packet_from_ethx_to_tn3(self): self.ethx_s.accept( IPv6(src=str(self.ethx_t.link_local_ip()), dst=str(self.n.node(3).link_local_ip())) / ICMPv6EchoReply() ) self.assertEqual(0, len(self.n.node(3).received())) def test_it_should_not_deliver_a_packet_from_ethy_to_tn3(self): self.ethy_s.accept( IPv6(src=str(self.ethx_t.global_ip()), dst=str(self.n.node(3).global_ip())) / ICMPv6EchoReply() ) self.assertEqual(0, len(self.n.node(3).received())) def test_it_should_deliver_a_packet_from_ethy_to_tn4(self): self.ethy_s.accept( IPv6(src=str(self.ethy_t.global_ip()), dst=str(self.n.node(4).global_ip())) / ICMPv6EchoReply() ) self.assertEqual(1, len(self.n.node(4).received())) p = self.n.node(4).received()[0] self.assertFalse(p.haslayer(Ether)) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.ethy_t.global_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.n.node(4).global_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_deliver_a_link_local_packet_from_ethy_to_tn4(self): self.ethy_s.accept( IPv6(src=str(self.ethy_t.link_local_ip()), dst=str(self.n.node(4).link_local_ip())) / ICMPv6EchoReply() ) self.assertEqual(1, len(self.n.node(4).received())) p = self.n.node(4).received()[0] self.assertFalse(p.haslayer(Ether)) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.ethy_t.link_local_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.n.node(4).link_local_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_not_deliver_a_packet_from_ethx_to_tn4(self): self.ethx_s.accept( IPv6(src=str(self.ethy_t.global_ip()), dst=str(self.n.node(4).global_ip())) / ICMPv6EchoReply() ) self.assertEqual(0, len(self.n.node(4).received())) def test_it_should_deliver_a_packet_from_ethx_to_tr1(self): self.ethx_s.accept( IPv6(src=str(self.ethx_t.global_ip()), dst=str(self.n.router(1).global_ip(iface=1))) / ICMPv6EchoReply() ) self.assertEqual(1, len(self.n.router(1).received(iface=1))) p = self.n.router(1).received(iface=1)[0] self.assertFalse(p.haslayer(Ether)) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.ethx_t.global_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.n.router(1).global_ip(iface=1).short_form(), p.getlayer(IPv6).dst) def test_it_should_deliver_a_link_local_packet_from_ethx_to_tr1(self): self.ethx_s.accept( IPv6(src=str(self.ethx_t.link_local_ip()), dst=str(self.n.router(1).link_local_ip(iface=1))) / ICMPv6EchoReply() ) self.assertEqual(1, len(self.n.router(1).received(iface=1))) p = self.n.router(1).received(iface=1)[0] self.assertFalse(p.haslayer(Ether)) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.ethx_t.link_local_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.n.router(1).link_local_ip(iface=1).short_form(), p.getlayer(IPv6).dst) def test_it_should_not_deliver_a_packet_from_ethy_to_tr1(self): self.ethy_s.accept( IPv6(src=str(self.ethx_t.global_ip()), dst=str(self.n.router(1).global_ip(iface=1))) / ICMPv6EchoReply() ) self.assertEqual(0, len(self.n.router(1).received())) def test_it_should_deliver_a_packet_from_ethx_to_tr2(self): self.ethx_s.accept( IPv6(src=str(self.ethx_t.global_ip()), dst=str(self.n.router(2).global_ip(iface=1))) / ICMPv6EchoReply() ) self.assertEqual(1, len(self.n.router(2).received(iface=1))) def test_it_should_deliver_a_packet_from_ethx_to_tr3(self): self.ethx_s.accept( IPv6(src=str(self.ethx_t.global_ip()), dst=str(self.n.router(3).global_ip(iface=1))) / ICMPv6EchoReply() ) self.assertEqual(1, len(self.n.router(3).received(iface=1)))
class ComplianceTestTestCase(unittest.TestCase): def setUp(self): self.test_network = TestNetwork(TestNetworkConfiguration()) # replace the network taps with mocked taps, referencing mocked network # and target interfaces self.test_network._TestNetwork__taps[0].unbind() self.test_network._TestNetwork__taps[1].unbind() self.t1 = self.test_network._TestNetwork__taps[0] = MockTap(self.test_network.link(2), MockInterface('if0', 'be:ef:ca:fe:09:01'), MockTargetInterface(ips=["2001:800:88:200::50", "fe80::50"], ll_protocol='Ethernet', link_addr='be:ef:ba:be:09:01')) self.t2 = self.test_network._TestNetwork__taps[1] = MockTap(self.test_network.link(3), MockInterface('if1', 'be:ef:ca:fe:09:02'), MockTargetInterface(ips=["2001:900:88:200::50", "fe80::51"], ll_protocol='Ethernet', link_addr='be:ef:ba:be:09:02')) # grab references to the target interfaces and internal nodes for easy # reference throughout a test case self.ifx = self.test_network.tap(1).target_iface self.ify = self.test_network.tap(2).target_iface self.tn1 = self.test_network.node(1) self.tn2 = self.test_network.node(2) self.tn3 = self.test_network.node(3) self.tn4 = self.test_network.node(4) self.tr1 = self.test_network.router(1) # TODO: tr2 and tr3 def _received_on_tn1(iface=0, src=None, dst=None, lbda=None, seq=None, type=None, timeout=5): return self.tn1.iface(iface).received(src=src, dst=dst == None and self.tn1.ip(iface=iface, offset='*', scope='*', type='*') or dst, lbda=lbda, seq=None, type=type) def _received_on_tn2(iface=0, src=None, dst=None, lbda=None, seq=None, type=None, timeout=5): return self.tn2.iface(iface).received(src=src, dst=dst == None and self.tn2.ip(iface=iface, offset='*', scope='*', type='*') or dst, lbda=lbda, seq=None, type=type) def _received_on_tn3(iface=0, src=None, dst=None, lbda=None, seq=None, type=None, timeout=5): return self.tn3.iface(iface).received(src=src, dst=dst == None and self.tn3.ip(iface=iface, offset='*', scope='*', type='*') or dst, lbda=lbda, seq=None, type=type) def _received_on_tn4(iface=0, src=None, dst=None, lbda=None, seq=None, type=None, timeout=5): return self.tn4.iface(iface).received(src=src, dst=dst == None and self.tn4.ip(iface=iface, offset='*', scope='*', type='*') or dst, lbda=lbda, seq=None, type=type) # override the #received() method on each of the TRs and TNs, to remove # the delay introduced self.tn1.received = _received_on_tn1 self.tn2.received = _received_on_tn2 self.tn3.received = _received_on_tn3 self.tn4.received = _received_on_tn4 self.ui = MockCallbacks(None) self.ui.test_network = self.test_network def assertCheckFails(self, outcome): messages = (not outcome.message == None and " Said: " + str(outcome.message) or "") if outcome.result_string() == "Error": messages += "\n" + outcome.backtrace self.assertEqual(False, outcome.result, "Expected compliance test to FAIL. Got: " + outcome.result_string() + "." + messages) def assertCheckPasses(self, outcome): messages = (not outcome.message == None and " Said: " + str(outcome.message) or "") if outcome.result_string() == "Error": messages += "\n" + outcome.backtrace self.assertEqual(True, outcome.result, "Expected compliance test to PASS. Got: " + outcome.result_string() + "." + messages) def break_checksum(self, packet): b = IPv6(packet.build()) if b.haslayer(ICMPv6EchoReply): b.getlayer(ICMPv6EchoReply).cksum = None elif b.haslayer(ICMPv6EchoRequest): b.getlayer(ICMPv6EchoRequest).cksum = None return b def get_outcome(self, test_case): return self.prepare(test_case).run_case() def prepare(self, test_case): c = test_case(self.test_network, self.ui) c.send_on_set_up = self.send_on_set_up return c def send_on_set_up(self): self.ui.wait(0)
class ComplianceTestTestCase(unittest.TestCase): def setUp(self): self.test_network = TestNetwork(TestNetworkConfiguration()) # replace the network taps with mocked taps, referencing mocked network # and target interfaces self.test_network._TestNetwork__taps[0].unbind() self.test_network._TestNetwork__taps[1].unbind() self.t1 = self.test_network._TestNetwork__taps[0] = MockTap( self.test_network.link(2), MockInterface('if0', 'be:ef:ca:fe:09:01'), MockTargetInterface(ips=["2001:800:88:200::50", "fe80::50"], ll_protocol='Ethernet', link_addr='be:ef:ba:be:09:01')) self.t2 = self.test_network._TestNetwork__taps[1] = MockTap( self.test_network.link(3), MockInterface('if1', 'be:ef:ca:fe:09:02'), MockTargetInterface(ips=["2001:900:88:200::50", "fe80::51"], ll_protocol='Ethernet', link_addr='be:ef:ba:be:09:02')) # grab references to the target interfaces and internal nodes for easy # reference throughout a test case self.ifx = self.test_network.tap(1).target_iface self.ify = self.test_network.tap(2).target_iface self.tn1 = self.test_network.node(1) self.tn2 = self.test_network.node(2) self.tn3 = self.test_network.node(3) self.tn4 = self.test_network.node(4) self.tr1 = self.test_network.router(1) # TODO: tr2 and tr3 def _received_on_tn1(iface=0, src=None, dst=None, lbda=None, seq=None, type=None, timeout=5): return self.tn1.iface(iface).received( src=src, dst=dst == None and self.tn1.ip(iface=iface, offset='*', scope='*', type='*') or dst, lbda=lbda, seq=None, type=type) def _received_on_tn2(iface=0, src=None, dst=None, lbda=None, seq=None, type=None, timeout=5): return self.tn2.iface(iface).received( src=src, dst=dst == None and self.tn2.ip(iface=iface, offset='*', scope='*', type='*') or dst, lbda=lbda, seq=None, type=type) def _received_on_tn3(iface=0, src=None, dst=None, lbda=None, seq=None, type=None, timeout=5): return self.tn3.iface(iface).received( src=src, dst=dst == None and self.tn3.ip(iface=iface, offset='*', scope='*', type='*') or dst, lbda=lbda, seq=None, type=type) def _received_on_tn4(iface=0, src=None, dst=None, lbda=None, seq=None, type=None, timeout=5): return self.tn4.iface(iface).received( src=src, dst=dst == None and self.tn4.ip(iface=iface, offset='*', scope='*', type='*') or dst, lbda=lbda, seq=None, type=type) # override the #received() method on each of the TRs and TNs, to remove # the delay introduced self.tn1.received = _received_on_tn1 self.tn2.received = _received_on_tn2 self.tn3.received = _received_on_tn3 self.tn4.received = _received_on_tn4 self.ui = MockCallbacks(None) self.ui.test_network = self.test_network def assertCheckFails(self, outcome): messages = (not outcome.message == None and " Said: " + str(outcome.message) or "") if outcome.result_string() == "Error": messages += "\n" + outcome.backtrace self.assertEqual( False, outcome.result, "Expected compliance test to FAIL. Got: " + outcome.result_string() + "." + messages) def assertCheckPasses(self, outcome): messages = (not outcome.message == None and " Said: " + str(outcome.message) or "") if outcome.result_string() == "Error": messages += "\n" + outcome.backtrace self.assertEqual( True, outcome.result, "Expected compliance test to PASS. Got: " + outcome.result_string() + "." + messages) def break_checksum(self, packet): b = IPv6(packet.build()) if b.haslayer(ICMPv6EchoReply): b.getlayer(ICMPv6EchoReply).cksum = None elif b.haslayer(ICMPv6EchoRequest): b.getlayer(ICMPv6EchoRequest).cksum = None return b def get_outcome(self, test_case): return self.prepare(test_case).run_case() def prepare(self, test_case): c = test_case(self.test_network, self.ui) c.send_on_set_up = self.send_on_set_up return c def send_on_set_up(self): self.ui.wait(0)
class TestNetworkTestCase(unittest.TestCase): def setUp(self): self.n = TestNetwork(TestNetworkConfiguration()) self.n._TestNetwork__taps[0].unbind() self.n._TestNetwork__taps[1].unbind() self.n.node(1).if0.ips.append(IPAddress.identify("2001:500:88:200::10")) self.n.node(1).if0.ips.append(IPAddress.identify("fe80:500:88:200::10")) self.n.node(2).if0.ips.append(IPAddress.identify("2001:600:88:200::10")) self.n.node(2).if0.ips.append(IPAddress.identify("fe80:600:88:200::10")) self.n.node(3).if0.ips.append(IPAddress.identify("2001:600:88:200::11")) self.n.node(3).if0.ips.append(IPAddress.identify("fe80:600:88:200::11")) self.n.node(4).if0.ips.append(IPAddress.identify("2001:700:88:200::10")) self.n.node(4).if0.ips.append(IPAddress.identify("fe80:700:88:200::10")) self.n.router(1).if0.ips.append(IPAddress.identify("2001:600:88:200::1")) self.n.router(1).if0.ips.append(IPAddress.identify("fe80:600:88:200::1")) self.n.router(1).if1.ips.append(IPAddress.identify("2001:500:88:200::1")) self.n.router(1).if1.ips.append(IPAddress.identify("fe80:500:88:200::1")) self.n.router(1)._TestRouter__forwards_to_0.append(Network("2001:0600:0088:0200::/64")) self.n.router(1)._TestRouter__forwards_to_1.append(Network("2001:0500:0088:0200::/64")) self.n.router(2).if0.ips.append(IPAddress.identify("2001:600:88:200::2")) self.n.router(2).if0.ips.append(IPAddress.identify("fe80:600:88:200::2")) self.n.router(2).if1.ips.append(IPAddress.identify("2001:500:88:200::2")) self.n.router(2).if1.ips.append(IPAddress.identify("fe80:500:88:200::2")) self.n.router(3).if0.ips.append(IPAddress.identify("2001:600:88:200::3")) self.n.router(3).if0.ips.append(IPAddress.identify("fe80:600:88:200::3")) self.n.router(3).if1.ips.append(IPAddress.identify("2001:500:88:200::3")) self.n.router(3).if1.ips.append(IPAddress.identify("fe80:500:88:200::3")) self.ethx_s = MockInterface('if0', '00:b0:d0:86:bb:f7') self.ethx_t = TargetInterface(ips=[IPAddress.identify("2001:500:88:200::20"), IPAddress.identify("fe80:500:88:200::20")], link_addr="00:b0:d0:bb:cc:ff") self.ethx = Tap(self.n.link(2), self.ethx_s, self.ethx_t) self.ethy_s = MockInterface('if1', '00:b0:e0:86:bb:f7') self.ethy_t = TargetInterface(ips=[IPAddress.identify("2001:600:88:200::20"), IPAddress.identify("fe80:600:88:200::20")], link_addr="00:b0:e0:bb:cc:ff") self.ethy = Tap(self.n.link(3), self.ethy_s, self.ethy_t) def test_it_should_deliver_a_packet_from_tn1_on_ethx(self): self.n.node(1).send(IPv6(src=str(self.n.node(1).global_ip()), dst=str(self.ethx_t.global_ip()))/ICMPv6EchoRequest()) self.assertEqual(1, len(self.ethx_s.sent)) p = self.ethx_s.sent[0] self.assertTrue(p.haslayer(Ether)) self.assertEqual('00:b0:d0:86:bb:f7', p.getlayer(Ether).src) self.assertEqual('00:b0:d0:bb:cc:ff', p.getlayer(Ether).dst) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.n.node(1).global_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.ethx_t.global_ip().short_form(), p.getlayer(IPv6).dst) self.assertTrue(self.ethx_s.sent[0].haslayer(ICMPv6EchoRequest)) def test_it_should_deliver_a_link_local_packet_from_tn1_to_ethx(self): self.n.node(1).send(IPv6(src=str(self.n.node(1).link_local_ip()), dst=str(self.ethx_t.link_local_ip()))/ICMPv6EchoRequest()) self.assertEqual(1, len(self.ethx_s.sent)) p = self.ethx_s.sent[0] self.assertTrue(p.haslayer(Ether)) self.assertEqual('00:b0:d0:86:bb:f7', p.getlayer(Ether).src) self.assertEqual('00:b0:d0:bb:cc:ff', p.getlayer(Ether).dst) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.n.node(1).link_local_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.ethx_t.link_local_ip().short_form(), p.getlayer(IPv6).dst) self.assertTrue(self.ethx_s.sent[0].haslayer(ICMPv6EchoRequest)) def test_it_should_not_deliver_a_packet_from_tn1_on_ethy(self): self.n.node(1).send(IPv6(src=str(self.n.node(1).link_local_ip()), dst=str(self.ethx_t.link_local_ip()))/ICMPv6EchoRequest()) self.assertEqual(0, len(self.ethy_s.sent)) def test_it_should_deliver_a_packet_from_tn2_on_ethx(self): self.n.node(2).send(IPv6(src=str(self.n.node(2).global_ip()), dst=str(self.ethx_t.global_ip()))/ICMPv6EchoRequest()) self.assertEqual(1, len(self.ethx_s.sent)) p = self.ethx_s.sent[0] self.assertTrue(p.haslayer(Ether)) self.assertEqual('00:b0:d0:86:bb:f7', p.getlayer(Ether).src) self.assertEqual('00:b0:d0:bb:cc:ff', p.getlayer(Ether).dst) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.n.node(2).global_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.ethx_t.global_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_not_deliver_a_link_local_packet_from_tn2_on_ethx(self): self.n.node(2).send(IPv6(src=str(self.n.node(2).link_local_ip()), dst=str(self.ethx_t.link_local_ip()))/ICMPv6EchoRequest()) self.assertEqual(0, len(self.ethx_s.sent)) def test_it_should_not_deliver_a_packet_from_tn2_on_ethy(self): self.n.node(2).send(IPv6(src=str(self.n.node(2).link_local_ip()), dst=str(self.ethx_t.link_local_ip()))/ICMPv6EchoRequest()) self.assertEqual(0, len(self.ethy_s.sent)) def test_it_should_deliver_a_packet_from_tn3_on_ethx(self): self.n.node(3).send(IPv6(src=str(self.n.node(3).global_ip()), dst=str(self.ethx_t.global_ip()))/ICMPv6EchoRequest()) self.assertEqual(1, len(self.ethx_s.sent)) p = self.ethx_s.sent[0] self.assertTrue(p.haslayer(Ether)) self.assertEqual('00:b0:d0:86:bb:f7', p.getlayer(Ether).src) self.assertEqual('00:b0:d0:bb:cc:ff', p.getlayer(Ether).dst) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.n.node(3).global_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.ethx_t.global_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_not_deliver_a_link_local_packet_from_tn3_on_ethx(self): self.n.node(3).send(IPv6(src=str(self.n.node(3).link_local_ip()), dst=str(self.ethx_t.link_local_ip()))/ICMPv6EchoRequest()) self.assertEqual(0, len(self.ethx_s.sent)) def test_it_should_not_deliver_a_packet_from_tn3_on_ethy(self): self.n.node(3).send(IPv6(src=str(self.n.node(3).link_local_ip()), dst=str(self.ethx_t.link_local_ip()))/ICMPv6EchoRequest()) self.assertEqual(0, len(self.ethy_s.sent)) def test_it_should_deliver_a_packet_from_tn4_on_ethy(self): self.n.node(4).send(IPv6(src=str(self.n.node(4).global_ip()), dst=str(self.ethy_t.global_ip()))/ICMPv6EchoRequest()) self.assertEqual(1, len(self.ethy_s.sent)) p = self.ethy_s.sent[0] self.assertTrue(p.haslayer(Ether)) self.assertEqual('00:b0:e0:86:bb:f7', p.getlayer(Ether).src) self.assertEqual('00:b0:e0:bb:cc:ff', p.getlayer(Ether).dst) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.n.node(4).global_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.ethy_t.global_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_deliver_a_link_local_packet_from_tn4_on_ethy(self): self.n.node(4).send(IPv6(src=str(self.n.node(4).link_local_ip()), dst=str(self.ethy_t.link_local_ip()))/ICMPv6EchoRequest()) self.assertEqual(1, len(self.ethy_s.sent)) p = self.ethy_s.sent[0] self.assertTrue(p.haslayer(Ether)) self.assertEqual('00:b0:e0:86:bb:f7', p.getlayer(Ether).src) self.assertEqual('00:b0:e0:bb:cc:ff', p.getlayer(Ether).dst) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.n.node(4).link_local_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.ethy_t.link_local_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_not_deliver_a_packet_from_tn4_on_ethx(self): self.n.node(4).send(IPv6(src=str(self.n.node(4).global_ip()), dst=str(self.ethy_t.global_ip()))/ICMPv6EchoRequest()) self.assertEqual(0, len(self.ethx_s.sent)) def test_it_should_deliver_a_packet_from_tr1_on_ethx(self): self.n.router(1).send(IPv6(src=str(self.n.router(1).global_ip()), dst=str(self.ethx_t.global_ip()))/ICMPv6EchoRequest(), iface=1) self.assertEqual(1, len(self.ethx_s.sent)) p = self.ethx_s.sent[0] self.assertTrue(p.haslayer(Ether)) self.assertEqual('00:b0:d0:86:bb:f7', p.getlayer(Ether).src) self.assertEqual('00:b0:d0:bb:cc:ff', p.getlayer(Ether).dst) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.n.router(1).global_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.ethx_t.global_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_deliver_a_link_local_packet_from_tr1_on_ethx(self): self.n.router(1).send(IPv6(src=str(self.n.router(1).link_local_ip()), dst=str(self.ethx_t.link_local_ip()))/ICMPv6EchoRequest(), iface=1) self.assertEqual(1, len(self.ethx_s.sent)) p = self.ethx_s.sent[0] self.assertTrue(p.haslayer(Ether)) self.assertEqual('00:b0:d0:86:bb:f7', p.getlayer(Ether).src) self.assertEqual('00:b0:d0:bb:cc:ff', p.getlayer(Ether).dst) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.n.router(1).link_local_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.ethx_t.link_local_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_not_deliver_a_packet_from_tr1_if0_to_ethx(self): self.n.router(1).send(IPv6(src=str(self.n.router(1).global_ip()), dst=str(self.ethx_t.global_ip()))/ICMPv6EchoRequest(), iface=0) self.assertEqual(0, len(self.ethx_s.sent)) def test_it_should_not_deliver_a_packet_from_tr1_on_ethy(self): self.n.router(1).send(IPv6(src=str(self.n.router(1).link_local_ip(iface=1)), dst=str(self.ethx_t.link_local_ip()))/ICMPv6EchoRequest(), iface=1) self.assertEqual(0, len(self.ethy_s.sent)) def test_it_should_deliver_a_packet_from_tr2_on_ethx(self): self.n.router(2).send(IPv6(src=str(self.n.router(2).link_local_ip(iface=1)), dst=str(self.ethx_t.link_local_ip()))/ICMPv6EchoRequest(), iface=1) self.assertEqual(0, len(self.ethy_s.sent)) def test_it_should_deliver_a_packet_from_tr3_on_ethx(self): self.n.router(3).send(IPv6(src=str(self.n.router(3).link_local_ip(iface=1)), dst=str(self.ethx_t.link_local_ip()))/ICMPv6EchoRequest(), iface=1) self.assertEqual(1, len(self.ethx_s.sent)) def test_it_should_deliver_a_packet_from_ethx_to_tn1(self): self.ethx_s.accept(IPv6(src=str(self.ethx_t.global_ip()), dst=str(self.n.node(1).global_ip()))/ICMPv6EchoReply()) self.assertEqual(1, len(self.n.node(1).received())) p = self.n.node(1).received()[0] self.assertFalse(p.haslayer(Ether)) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.ethx_t.global_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.n.node(1).global_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_deliver_a_link_local_packet_from_ethx_to_tn1(self): self.ethx_s.accept(IPv6(src=str(self.ethx_t.link_local_ip()), dst=str(self.n.node(1).link_local_ip()))/ICMPv6EchoReply()) self.assertEqual(1, len(self.n.node(1).received())) p = self.n.node(1).received()[0] self.assertFalse(p.haslayer(Ether)) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.ethx_t.link_local_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.n.node(1).link_local_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_not_deliver_a_packet_from_ethy_to_tn1(self): self.ethy_s.accept(IPv6(src=str(self.ethx_t.global_ip()), dst=str(self.n.node(1).global_ip()))/ICMPv6EchoReply()) self.assertEqual(0, len(self.n.node(1).received())) def test_it_should_deliver_a_packet_from_ethx_to_tn2(self): self.ethx_s.accept(IPv6(src=str(self.ethx_t.global_ip()), dst=str(self.n.node(2).global_ip()))/ICMPv6EchoReply()) self.assertEqual(1, len(self.n.node(2).received())) p = self.n.node(2).received()[0] self.assertFalse(p.haslayer(Ether)) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.ethx_t.global_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.n.node(2).global_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_not_deliver_a_link_local_packet_from_ethx_to_tn2(self): self.ethx_s.accept(IPv6(src=str(self.ethx_t.link_local_ip()), dst=str(self.n.node(2).link_local_ip()))/ICMPv6EchoReply()) self.assertEqual(0, len(self.n.node(2).received())) def test_it_should_not_deliver_a_packet_from_ethy_to_tn2(self): self.ethy_s.accept(IPv6(src=str(self.ethx_t.global_ip()), dst=str(self.n.node(2).global_ip()))/ICMPv6EchoReply()) self.assertEqual(0, len(self.n.node(2).received())) def test_it_should_deliver_a_packet_from_ethx_to_tn3(self): self.ethx_s.accept(IPv6(src=str(self.ethx_t.global_ip()), dst=str(self.n.node(3).global_ip()))/ICMPv6EchoReply()) self.assertEqual(1, len(self.n.node(3).received())) p = self.n.node(3).received()[0] self.assertFalse(p.haslayer(Ether)) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.ethx_t.global_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.n.node(3).global_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_not_deliver_a_link_local_packet_from_ethx_to_tn3(self): self.ethx_s.accept(IPv6(src=str(self.ethx_t.link_local_ip()), dst=str(self.n.node(3).link_local_ip()))/ICMPv6EchoReply()) self.assertEqual(0, len(self.n.node(3).received())) def test_it_should_not_deliver_a_packet_from_ethy_to_tn3(self): self.ethy_s.accept(IPv6(src=str(self.ethx_t.global_ip()), dst=str(self.n.node(3).global_ip()))/ICMPv6EchoReply()) self.assertEqual(0, len(self.n.node(3).received())) def test_it_should_deliver_a_packet_from_ethy_to_tn4(self): self.ethy_s.accept(IPv6(src=str(self.ethy_t.global_ip()), dst=str(self.n.node(4).global_ip()))/ICMPv6EchoReply()) self.assertEqual(1, len(self.n.node(4).received())) p = self.n.node(4).received()[0] self.assertFalse(p.haslayer(Ether)) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.ethy_t.global_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.n.node(4).global_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_deliver_a_link_local_packet_from_ethy_to_tn4(self): self.ethy_s.accept(IPv6(src=str(self.ethy_t.link_local_ip()), dst=str(self.n.node(4).link_local_ip()))/ICMPv6EchoReply()) self.assertEqual(1, len(self.n.node(4).received())) p = self.n.node(4).received()[0] self.assertFalse(p.haslayer(Ether)) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.ethy_t.link_local_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.n.node(4).link_local_ip().short_form(), p.getlayer(IPv6).dst) def test_it_should_not_deliver_a_packet_from_ethx_to_tn4(self): self.ethx_s.accept(IPv6(src=str(self.ethy_t.global_ip()), dst=str(self.n.node(4).global_ip()))/ICMPv6EchoReply()) self.assertEqual(0, len(self.n.node(4).received())) def test_it_should_deliver_a_packet_from_ethx_to_tr1(self): self.ethx_s.accept(IPv6(src=str(self.ethx_t.global_ip()), dst=str(self.n.router(1).global_ip(iface=1)))/ICMPv6EchoReply()) self.assertEqual(1, len(self.n.router(1).received(iface=1))) p = self.n.router(1).received(iface=1)[0] self.assertFalse(p.haslayer(Ether)) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.ethx_t.global_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.n.router(1).global_ip(iface=1).short_form(), p.getlayer(IPv6).dst) def test_it_should_deliver_a_link_local_packet_from_ethx_to_tr1(self): self.ethx_s.accept(IPv6(src=str(self.ethx_t.link_local_ip()), dst=str(self.n.router(1).link_local_ip(iface=1)))/ICMPv6EchoReply()) self.assertEqual(1, len(self.n.router(1).received(iface=1))) p = self.n.router(1).received(iface=1)[0] self.assertFalse(p.haslayer(Ether)) self.assertTrue(p.haslayer(IPv6)) self.assertEqual(self.ethx_t.link_local_ip().short_form(), p.getlayer(IPv6).src) self.assertEqual(self.n.router(1).link_local_ip(iface=1).short_form(), p.getlayer(IPv6).dst) def test_it_should_not_deliver_a_packet_from_ethy_to_tr1(self): self.ethy_s.accept(IPv6(src=str(self.ethx_t.global_ip()), dst=str(self.n.router(1).global_ip(iface=1)))/ICMPv6EchoReply()) self.assertEqual(0, len(self.n.router(1).received())) def test_it_should_deliver_a_packet_from_ethx_to_tr2(self): self.ethx_s.accept(IPv6(src=str(self.ethx_t.global_ip()), dst=str(self.n.router(2).global_ip(iface=1)))/ICMPv6EchoReply()) self.assertEqual(1, len(self.n.router(2).received(iface=1))) def test_it_should_deliver_a_packet_from_ethx_to_tr3(self): self.ethx_s.accept(IPv6(src=str(self.ethx_t.global_ip()), dst=str(self.n.router(3).global_ip(iface=1)))/ICMPv6EchoReply()) self.assertEqual(1, len(self.n.router(3).received(iface=1)))