class TestEthernetTrafficGenerator(unittest.TestCase): def setUp(self): # create connection between wifi nodes self.ap = AP(interface=INTERFACE_AP) self.ap.start() self.ap.start_dump() self.sta = STA(interface=INTERFACE_STA) self.sta.start_dump() self.sta.connect_to(ssid=self.ap.config['ssid']) # create traffic STA->AP try: self.gen = EthernetTrafficGenerator( drone_hostname=DRONE_HOST, drone_ifname=self.sta.get_interface(), src_mac=self.sta.get_mac_addr(), dest_mac=self.ap.get_mac_addr(), ) except ConnectionRefusedException: self.sta.stop() self.ap.stop() raise ConnectionRefusedException def tearDown(self): self.gen.stop() self.sta.stop() self.ap.stop() def test_traffic_gen(self): self.gen.add_stream(frame_len=1500, num_packets=1000, packets_per_sec=0) self.gen.start() time.sleep(50)
class TestMonitor(unittest.TestCase): def setUp(self): self.ap = AP(interface=INTERFACE_AP) self.ap.start() self.sta = STA(interface=INTERFACE_STA) def tearDown(self): self.sta.stop() self.ap.stop() def test_monitors(self): def cnt_monitors(moni_names): monitors_found = 0 ifconfig_stdout = subprocess.check_output(["ifconfig", "-a"]).decode('UTF-8') for line in ifconfig_stdout.split('\n'): for ifname in moni_names: if ifname in line: monitors_found += 1 return monitors_found self.ap.attach_monitor() self.sta.attach_monitor() moni_names = [self.ap.monitor_ifname, self.sta.monitor_ifname] self.assertEqual(cnt_monitors(moni_names), 2) self.ap.remove_monitor() self.sta.remove_monitor() self.assertEqual(cnt_monitors(moni_names), 0)
class TestStation(unittest.TestCase): def setUp(self): self.ap = AP(interface=INTERFACE_AP) self.ap.start() def tearDown(self): self.sta.disconnect() self.ap.stop() def test_connection(self): self.sta = STA(interface=INTERFACE_STA) self.sta.connect_to(ssid=self.ap.config['ssid']) station_dump = self.sta.get_station_dump() self.assertNotEqual(station_dump, '')
def setUp(self): # create connection between wifi nodes self.ap = AP(interface=INTERFACE_AP) self.ap.start() self.ap.start_dump() self.sta = STA(interface=INTERFACE_STA) self.sta.start_dump() self.sta.connect_to(ssid=self.ap.config['ssid']) # create traffic STA->AP try: self.gen = EthernetTrafficGenerator( drone_hostname=DRONE_HOST, drone_ifname=self.sta.get_interface(), src_mac=self.sta.get_mac_addr(), dest_mac=self.ap.get_mac_addr(), ) except ConnectionRefusedException: self.sta.stop() self.ap.stop() raise ConnectionRefusedException
class TestPacketCapture(unittest.TestCase): def setUp(self): self.ap = AP(interface=INTERFACE_AP) self.ap.start() self.sta = STA(interface=INTERFACE_STA) def tearDown(self): self.sta.stop() self.ap.stop() def test_capture(self): self.ap.start_dump() self.sta.start_dump() self.sta.connect_to(ssid=self.ap.config['ssid']) time.sleep(10) # capture packets for 10s self.assertTrue(os.path.isfile(self.ap.dump_filename)) self.assertTrue(os.path.isfile(self.sta.dump_filename)) self.ap.delete_dump() self.sta.delete_dump()
class TestAP(unittest.TestCase): def setUp(self): self.ap = AP(interface=INTERFACE_AP) def tearDown(self): self.ap.stop() def test_start_stop(self): self.assertEqual(self.ap._pid, -1) self.ap.start() self.assertNotEqual(self.ap._pid, -1) time.sleep(1) self.ap.stop() self.assertEqual(self.ap._pid, -1)
def setUp(self): self.ap = AP(interface=INTERFACE_AP) self.ap.start() self.sta = STA(interface=INTERFACE_STA)
def setUp(self): self.ap = AP(interface=INTERFACE_AP)