class TestTapLoop(unittest.TestCase): ''' This unit test creates two TAP devices, configures IP addresses, spawns TapLoop (two threads copying packets between TAP devices), and ARP-ping over that loop. [So L2 works, but I can't make L3 communication (ICMP) work yet over this link.] ''' def setUp(self): self.lhost = '10.10.10.10' self.rhost = '10.10.10.11' self.netmask = '255.255.255.0' self.taploop = TapLoop(remote_address = self.rhost, netmask = self.netmask) def test_it(self): self.taploop.start() time.sleep(0.25) iface = self.taploop.get_iface() ans = srp1(Ether(dst="ff:ff:ff:ff:ff:ff")/ARP(psrc=self.lhost, pdst=self.rhost), filter="arp and arp[7] = 2", iface=iface, timeout=0.5) arpp = ans.getlayer(ARP) self.assertEquals(arpp.psrc, self.rhost) self.assertEquals(arpp.pdst, self.lhost)
def setUp(self): self.lhost = '10.10.10.10' self.rhost = '10.10.10.11' self.netmask = '255.255.255.0' self.taploop = TapLoop(remote_address = self.rhost, netmask = self.netmask)