tests: Connection during large packet loss
[mech_eap.git] / tests / hwsim / test_ap_open.py
1 # Open mode AP tests
2 # Copyright (c) 2014, Qualcomm Atheros, Inc.
3 #
4 # This software may be distributed under the terms of the BSD license.
5 # See README for more details.
6
7 import hostapd
8 import hwsim_utils
9
10 def test_ap_open(dev, apdev):
11     """AP with open mode (no security) configuration"""
12     hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" })
13     dev[0].connect("open", key_mgmt="NONE", scan_freq="2412")
14     hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
15     ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5)
16     if ev is None:
17         raise Exception("No connection event received from hostapd")
18     dev[0].request("DISCONNECT")
19     ev = hapd.wait_event([ "AP-STA-DISCONNECTED" ], timeout=5)
20     if ev is None:
21         raise Exception("No disconnection event received from hostapd")
22
23 def test_ap_open_packet_loss(dev, apdev):
24     """AP with open mode configuration and large packet loss"""
25     params = { "ssid": "open",
26                "ignore_probe_probability": "0.5",
27                "ignore_auth_probability": "0.5",
28                "ignore_assoc_probability": "0.5",
29                "ignore_reassoc_probability": "0.5" }
30     hapd = hostapd.add_ap(apdev[0]['ifname'], params)
31     for i in range(0, 3):
32         dev[i].connect("open", key_mgmt="NONE", scan_freq="2412",
33                        wait_connect=False)
34     for i in range(0, 3):
35         ev = dev[i].wait_event(["CTRL-EVENT-CONNECTED"], timeout=20)
36         if ev is None:
37             raise Exception("Association with the AP timed out")