def test_it_should_have_ip_addresses_on_if1(self): l = Link('A') m = Link('B') r = TestRouter('TNN', link0=l, ips0=[IPAddress.identify("2001:500:88:200::10"), IPAddress.identify("2001:500:88:200::11"), IPAddress.identify("fe80:500:88:200::10"), IPAddress.identify("192.0.43.10")], link1=m, ips1=[IPAddress.identify("2001:600:88:200::10"), IPAddress.identify("2001:600:88:200::11"), IPAddress.identify("fe80:600:88:200::10"), IPAddress.identify("192.1.43.10")]) self.assertEqual("2001:600:88:200::10", r.ip(1).short_form()) self.assertEqual("2001:600:88:200::10", r.global_ip(1).short_form()) self.assertEqual("2001:600:88:200::11", r.global_ip(1, offset=1).short_form()) self.assertEqual("192.1.43.10", r.ip(1, type='v4').short_form())
def test_it_should_receive_traffic_from_if1(self): l = Link('A') m = Link('B') r = TestRouter('TNN', link0=l, ips0=[IPAddress.identify("2001:500:88:200::10"), IPAddress.identify("2001:500:88:200::11"), IPAddress.identify("fe80:500:88:200::10"), IPAddress.identify("192.0.43.10")], link1=m, ips1=[IPAddress.identify("2001:600:88:200::10"), IPAddress.identify("2001:600:88:200::11"), IPAddress.identify("fe80:600:88:200::10"), IPAddress.identify("192.1.43.10")]) m.accept(IPv6(src="2001:600:88:200::90", dst="2001:600:88:200::10")) self.assertEqual(0, len(r.received())) self.assertEqual(1, len(r.received(1))) self.assertTrue(r.received(1)[0].haslayer(IPv6))
def test_it_should_send_traffic_on_if1(self): l = Link('A') m = Link('B') r = TestRouter('TNN', link0=l, ips0=[IPAddress.identify("2001:500:88:200::10"), IPAddress.identify("2001:500:88:200::11"), IPAddress.identify("fe80:500:88:200::10"), IPAddress.identify("192.0.43.10")], link1=m, ips1=[IPAddress.identify("2001:600:88:200::10"), IPAddress.identify("2001:600:88:200::11"), IPAddress.identify("fe80:600:88:200::10"), IPAddress.identify("192.1.43.10")]) r.send("This is a packet.", iface=1) self.assertEqual(0, len(l.forwarded())) self.assertEqual(1, len(m.forwarded())) self.assertEqual("This is a packet.", m.forwarded()[0])