[PATCH v3 26/26] tests: remote, add test_ap_open.py

Janusz Dziedzic janusz.dziedzic at tieto.com
Wed Feb 17 04:14:29 PST 2016


Add TP/ping test cases for AP open.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic at tieto.com>
---
 tests/remote/run-tests.py    |   5 +-
 tests/remote/test_ap_open.py | 663 +++++++++++++++++++++++++++++++++++++++++++
 tests/remote/utils.py        | 314 ++++++++++++++++++++
 3 files changed, 980 insertions(+), 2 deletions(-)
 create mode 100644 tests/remote/test_ap_open.py
 create mode 100644 tests/remote/utils.py

diff --git a/tests/remote/run-tests.py b/tests/remote/run-tests.py
index 2a3649b..41beacb 100755
--- a/tests/remote/run-tests.py
+++ b/tests/remote/run-tests.py
@@ -24,9 +24,10 @@ import wpaspy
 setup_params = {"setup_hw" : "./tests/setup_hw.sh",
                 "hostapd" : "./tests/hostapd",
                 "wpa_supplicant" : "./tests/wpa_supplicant",
-                "iperf" : "iperf3",
+                "iperf" : "iperf",
                 "country" : "PL",
-                "log_dir" : "/tmp/"}
+                "log_dir" : "/tmp/",
+                "ipv4_test_net" : "192.168.12.0"}
 
 devices = [{"hostname": "192.168.254.58", "ifname" : "wlan0", "port": "9877", "name" : "t2-ath9k", "flags" : "AP_HT40 STA_HT40"},
            {"hostname": "192.168.254.58", "ifname" : "wlan1", "port": "9877", "name" : "t2-ath10k", "flags" : "AP_VHT80"},
diff --git a/tests/remote/test_ap_open.py b/tests/remote/test_ap_open.py
new file mode 100644
index 0000000..551cd4f
--- /dev/null
+++ b/tests/remote/test_ap_open.py
@@ -0,0 +1,663 @@
+import wpaspy
+from wpasupplicant import WpaSupplicant
+import hostapd
+import utils
+import time
+import traceback
+
+import logging
+logger = logging.getLogger()
+
+def run_ap_sta(devices, duts, setup_params, ref, dut):
+    ref_dev = utils.get_device(devices, name=ref, flags="STA_VHT80")
+    dut_dev = utils.get_dut(duts, dut)
+
+    if ref_dev is None:
+        raise Exception("Could not get reference device")
+
+    if dut_dev is None:
+        raise Exception("Could not get DUT device")
+
+    ap, ap_log = utils.run_hostapd(dut_dev, setup_params)
+    sta, sta_log = utils.run_wpasupplicant(ref_dev, setup_params)
+    return sta, ap, sta_log, ap_log
+
+def run_tp_test(server, client, l3="ipv4", iperf="iperf", l4="tcp", test_time="10", parallel="5",
+                qos="be", bw="30M", ifname=None, port="5001"):
+    client_res = []
+    server_res = []
+
+    server_ip = utils.get_ip(server, l3)
+    time.sleep(1)
+    server_thread, client_thread = utils.iperf_run(server, client, server_ip, client_res, server_res,
+                                                   l3=l3, iperf=iperf, l4=l4, test_time=test_time,
+                                                   parallel=parallel, qos=qos, bw=bw, ifname=ifname,
+                                                   port=port)
+    utils.iperf_wait(server, client, server_thread, client_thread, iperf=iperf, timeout=int(test_time) + 10)
+
+    if client_res[0] != 0:
+        raise Exception(iperf + " client: " + client_res[1])
+    if server_res[0] != 0:
+        raise Exception(iperf + " server: " + server_res[1])
+    if client_res[1] is None:
+        raise Exception(iperf + " client result issue")
+    if server_res[1] is None:
+        raise Exception(iperf + " server result issue")
+
+    if iperf == "iperf":
+          result = server_res[1]
+    if iperf == "iperf3":
+          result = client_res[1]
+
+    speed = utils.get_iperf_speed(result)
+    return speed
+
+def get_ap_params(channel="1", bw="HT20", country="US"):
+    ssid = "test_" + channel + "_" + bw
+
+    if int(channel) > 14:
+        hw_mode = "a"
+    else:
+        hw_mode = "g"
+
+    ieee80211n = "0"
+    ieee80211ac = "0"
+    ht_capab = "[]"
+    wmm_enabled = "1"
+    vht_oper_chwidth ="0"
+    vht_oper_centr_freq_seg0_idx = "0"
+
+    if bw == "b_only":
+        hw_mode = "b"
+        wmm_enabled = "0"
+    elif bw == "g_only":
+        hw_mode = "g"
+        wmm_enabled = "0"
+    elif bw == "g_only_wmm":
+        hw_mode = "g"
+    elif bw == "a_only":
+        hw_mode = "a"
+        wmm_enabled = "0"
+    elif bw == "a_only_wmm":
+        hw_mode = "a"
+    elif bw == "HT20":
+        ieee80211n = "1"
+    elif bw == "HT40+":
+        ieee80211n = "1"
+        ht_capab = "[HT40+]"
+    elif bw == "HT40-":
+        ieee80211n = "1"
+        ht_capab = "[HT40-]"
+    elif bw == "VHT80":
+        ieee80211n = "1"
+        ieee80211ac = "1"
+        ht_capab = "[HT40+]"
+        vht_oper_chwidth = "1"
+        vht_oper_centr_freq_seg0_idx = str(int(channel) + 6)
+
+    params = {"ssid" : ssid,
+              "hw_mode" : hw_mode,
+              "channel" : channel,
+              "ht_capab" : ht_capab,
+              "ieee80211n" : ieee80211n,
+              "ieee80211ac" : ieee80211ac,
+              "country_code": country,
+              "wmm_enabled" : wmm_enabled,
+              "vht_oper_chwidth": vht_oper_chwidth,
+              "vht_oper_centr_freq_seg0_idx": vht_oper_centr_freq_seg0_idx}
+
+    return params
+
+def get_iperf_bw(bw, parallel, spacial_streams=2):
+    if bw == "b_only":
+        max_tp = 11
+    elif bw == "g_only" or bw == "g_only_wmm" or bw == "a_only" or bw == "a_only_wmm":
+        max_tp = 54
+    elif bw == "HT20":
+        max_tp = 72 * spacial_streams
+    elif bw == "HT40+" or bw == "HT40-":
+        max_tp = 150 * spacial_streams
+    elif bw == "VHT80":
+        max_tp = 433 * spacial_streams
+    else:
+        max_tp = 150
+
+    max_tp = 1.1 * max_tp
+
+    return str(int(max_tp/int(parallel))) + "M"
+
+def ap_open(devices, duts, setup_params, ref=None, dut=None, test_type="ping_ipv4",
+            channel="1", bw="HT20", country=None, test_time="30", parallel="5", qos="be"):
+    try:
+        sta = None
+        ap = None
+        hapd = None
+        wpas = None
+        sta_log = None
+        ap_log = None
+
+        local_log_dir = setup_params['local_log_dir']
+
+        # setup country code
+        if country is None:
+            try:
+                country = setup_params['country']
+            except:
+                country = "00"
+
+        # run hostapd/wpa_supplicant
+        sta, ap, sta_log, ap_log = run_ap_sta(devices, duts, setup_params, ref, dut)
+        ap_params = get_ap_params(channel, bw, country)
+        iperf_bw = get_iperf_bw(bw, parallel)
+
+        # setup AP/STA
+        hapd = hostapd.add_ap(ap.ifname, ap_params, hostname = ap.host, port = ap.port)
+        freq = hapd.get_status_field("freq")
+        wpas = WpaSupplicant(hostname = sta.host, global_iface="udp", global_port = sta.port)
+        wpas.interface_add(sta.ifname)
+        wpas.connect(ap_params['ssid'], key_mgmt="NONE", scan_freq=freq)
+        ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5)
+        if ev is None:
+            raise Exception("No connection event received from hostapd")
+
+        # setup ip network
+        ap.execute("ifconfig " + ap.ifname + " " + utils.get_ipv4_addr(setup_params, 1))
+        sta.execute("ifconfig " + sta.ifname + " " + utils.get_ipv4_addr(setup_params, 2))
+
+        # dispatch test_type
+        if test_type == "ipv4_tcp_download":
+            speed = run_tp_test(ap, sta, "ipv4", setup_params['iperf'], l4="tcp",
+                                test_time=test_time, parallel=parallel, qos=qos, bw=iperf_bw)
+            append = speed
+        elif test_type == "ipv4_tcp_upload":
+            speed = run_tp_test(sta, ap, "ipv4", setup_params['iperf'], l4="tcp",
+                                test_time=test_time, parallel=parallel, qos=qos, bw=iperf_bw)
+            append = speed
+        elif test_type == "ipv6_tcp_download":
+            speed = run_tp_test(ap, sta, "ipv6", setup_params['iperf'], l4="tcp",
+                                test_time=test_time, parallel=parallel, qos=qos, bw=iperf_bw)
+            append = speed
+        elif test_type == "ipv6_tcp_upload":
+            speed = run_tp_test(sta, ap, "ipv6", setup_params['iperf'], l4="tcp",
+                                test_time=test_time, parallel=parallel, qos=qos, bw=iperf_bw)
+            append = speed
+        elif test_type == "ipv4_udp_download":
+            speed = run_tp_test(ap, sta, "ipv4", setup_params['iperf'], l4="udp",
+                                test_time=test_time, parallel=parallel, qos=qos, bw=iperf_bw)
+            append = speed
+        elif test_type == "ipv4_udp_upload":
+            speed = run_tp_test(sta, ap, "ipv4", setup_params['iperf'], l4="udp",
+                                test_time=test_time, parallel=parallel, qos=qos, bw=iperf_bw)
+            append = speed
+        elif test_type == "ipv6_udp_download":
+            speed = run_tp_test(ap, sta, "ipv6", setup_params['iperf'], l4="udp",
+                                test_time=test_time, parallel=parallel, qos=qos, bw=iperf_bw)
+            append = speed
+        elif test_type == "ipv6_udp_upload":
+            speed = run_tp_test(sta, ap, "ipv6", setup_params['iperf'], l4="udp",
+                                test_time=test_time, parallel=parallel, qos=qos, bw=iperf_bw)
+            append = speed
+        elif test_type == "ipv4_ping":
+            ap_sta, sta_ap = utils.check_connectivity(ap, sta, "ipv4")
+            append = "packet_loss: " + ap_sta + ", " + sta_ap
+        elif test_type == "ipv6_ping":
+            ap_sta, sta_ap = utils.check_connectivity(ap, sta, "ipv6")
+            append = "packet_loss: " + ap_sta + ", " + sta_ap
+        else:
+            raise Exception("Unknown ap_open test_type:", test_type)
+
+        wpas.request("DISCONNECT")
+        ev = hapd.wait_event([ "AP-STA-DISCONNECTED" ], timeout=5)
+        if ev is None:
+            raise Exception("No disconnection event received from hostapd")
+
+        sta.execute("ifconfig " + sta.ifname + " 0.0.0.0")
+        ap.execute("ifconfig " + ap.ifname + " 0.0.0.0")
+
+        wpas.interface_remove(sta.ifname)
+        wpas.terminate()
+
+        hapd.close_ctrl()
+        hostapd.remove_bss(ap.ifname, ap.host, ap.port)
+        hostapd.terminate(ap.host, ap.port)
+
+        if sta_log is not None:
+#            sta.local_execute("scp root@[" + sta.host + "]:" + sta_log + " " + local_log_dir)
+            sta.execute("rm " + sta_log)
+        if ap_log is not None:
+#            ap.local_execute("scp root@[" + ap.host + "]:" + ap_log + " " + local_log_dir)
+            ap.execute("rm " + ap_log)
+
+        return 0, append
+    except:
+        logger.info(traceback.format_exc())
+        if wpas is not None:
+            try:
+                wpas.interface_remove(sta.ifname)
+                wpas.terminate()
+            except:
+                pass
+        if hapd is not None:
+            try:
+                hapd.close_ctrl()
+                hostapd.remove_bss(ap.ifname, ap.host, ap.port)
+                hostapd.terminate(ap.host, ap.port)
+            except:
+                pass
+        if sta is not None:
+            sta.execute("ifconfig " + sta.ifname + " 0.0.0.0")
+            sta.execute("killall wpa_supplicant")
+            sta.execute("killall iperf")
+            if sta_log is not None:
+                sta.local_execute("scp root@[" + sta.host + "]:" + sta_log + " " + local_log_dir)
+                sta.execute("rm " + sta_log)
+        if ap is not None:
+            ap.execute("ifconfig " + ap.ifname + " 0.0.0.0")
+            ap.execute("killall hostapd")
+            ap.execute("killall iperf")
+            if ap_log is not None:
+                ap.local_execute("scp root@[" + ap.host + "]:" + ap_log + " " + local_log_dir)
+                ap.execute("rm " + ap_log)
+        raise
+
+# basic ping
+def test_ap_open_ipv4_ping(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration IPv4 ping"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_ping")
+
+def test_ap_open_ipv6_ping(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration IPv6"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_ping")
+
+
+# B-only
+def test_ap_open_2412_b_only_ipv4_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2412 B-only IPv4 udp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_upload", channel="1", bw="b_only")
+
+def test_ap_open_2412_b_only_ipv4_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2412 B-only IPv4 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_download", channel="1", bw="b_only")
+
+def test_ap_open_2412_b_only_ipv4_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2412 B-only IPv4 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_upload", channel="1", bw="b_only")
+
+def test_ap_open_2412_b_only_ipv4_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2412 B-only IPv4 tcp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_download", channel="1", bw="b_only")
+
+def test_ap_open_2412_b_only_ipv6_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2412 B-only IPv6 udp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_upload", channel="1", bw="b_only")
+
+def test_ap_open_2412_b_only_ipv6_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2412 B-only IPv6 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_download", channel="1", bw="b_only")
+
+def test_ap_open_2412_b_only_ipv6_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2412 B-only IPv6 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_upload", channel="1", bw="b_only")
+
+def test_ap_open_2412_b_only_ipv6_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2412 B-only IPv6 tcp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_download", channel="1", bw="b_only")
+def test_ap_open_all_chan_b_only_ipv4_ping(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration all channels B-only IPv4 ping"""
+    try:
+        country = setup_params['country']
+    except:
+        country = "US"
+
+    chan = 1
+    append = country + " "
+    while chan < 15:
+        try:
+            status, buf = ap_open(devices, duts, setup_params, ref, dut, "ipv4_ping", channel=str(chan),
+                                  bw="b_only", country = country)
+            if status is 0:
+                append = append + str(chan) + ": OK "
+            else:
+                append = append + str(chan) + ": FAILED <" + buf + ">"
+        except:
+            append = append + str(chan) + ": FAILED "
+        chan = chan + 1
+
+    return 0, append
+
+
+# G-only
+def test_ap_open_2462_g_only_ipv4_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 G-only IPv4 udp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_upload", channel="11", bw="g_only")
+
+def test_ap_open_2462_g_only_ipv4_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 G-only IPv4 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_download", channel="11", bw="g_only")
+
+def test_ap_open_2462_g_only_ipv4_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 G-only IPv4 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_upload", channel="11", bw="g_only")
+
+def test_ap_open_2462_g_only_ipv4_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 G-only IPv4 tcp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_download", channel="11", bw="g_only")
+
+def test_ap_open_2462_g_only_ipv6_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 G-only IPv6 udp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_upload", channel="11", bw="g_only")
+
+def test_ap_open_2462_g_only_ipv6_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 G-only IPv6 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_download", channel="11", bw="g_only")
+
+def test_ap_open_2462_g_only_ipv6_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 G-only IPv6 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_upload", channel="11", bw="g_only")
+
+def test_ap_open_2462_g_only_ipv6_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 G-only IPv6 tcp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_download", channel="11", bw="g_only")
+
+# G-only + WMM
+def test_ap_open_2412_g_only_wmm_ipv4_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 G-only WMM IPv4 udp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_upload", channel="1", bw="g_only_wmm")
+
+def test_ap_open_2412_g_only_wmm_ipv4_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 G-only WMM IPv4 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_download", channel="1", bw="g_only_wmm")
+
+def test_ap_open_2412_g_only_wmm_ipv4_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 G-only WMM IPv4 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_upload", channel="1", bw="g_only_wmm")
+
+def test_ap_open_2412_g_only_wmm_ipv4_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 G-only WMM IPv4 tcp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_download", channel="1", bw="g_only_wmm")
+
+def test_ap_open_2412_g_only_wmm_ipv6_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 G-only WMM IPv6 udp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_upload", channel="1", bw="g_only_wmm")
+
+def test_ap_open_2412_g_only_wmm_ipv6_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 G-only WMM IPv6 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_download", channel="1", bw="g_only_wmm")
+
+def test_ap_open_2412_g_only_wmm_ipv6_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 G-only WMM IPv6 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_upload", channel="1", bw="g_only_wmm")
+
+def test_ap_open_2412_g_only_wmm_ipv6_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 G-only WMM IPv6 tcp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_download", channel="1", bw="g_only_wmm")
+
+
+# A-only
+def test_ap_open_5180_a_only_ipv4_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 A-only IPv4 udp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_upload", channel="36", bw="a_only")
+
+def test_ap_open_5180_a_only_ipv4_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 A-only IPv4 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_download", channel="36", bw="a_only")
+
+def test_ap_open_5180_a_only_ipv4_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 A-only IPv4 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_upload", channel="36", bw="a_only")
+
+def test_ap_open_5180_a_only_ipv4_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 A-only IPv4 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_download", channel="36", bw="a_only")
+
+def test_ap_open_5180_a_only_ipv6_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 A-only IPv6 udp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_upload", channel="36", bw="a_only")
+
+def test_ap_open_5180_a_only_ipv6_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 A-only IPv6 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_download", channel="36", bw="a_only")
+
+def test_ap_open_5180_a_only_ipv6_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 A-only IPv6 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_upload", channel="36", bw="a_only")
+
+def test_ap_open_5180_a_only_ipv6_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 A-only IPv6 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_download", channel="36", bw="a_only")
+
+
+# A-only + WMM
+def test_ap_open_5180_a_only_wmm_ipv4_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 A-only WMM IPv4 udp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_upload", channel="36", bw="a_only_wmm")
+
+def test_ap_open_5180_a_only_wmm_ipv4_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 A-only WMM IPv4 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_download", channel="36", bw="a_only_wmm")
+
+def test_ap_open_5180_a_only_wmm_ipv4_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 A-only WMM IPv4 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_upload", channel="36", bw="a_only_wmm")
+
+def test_ap_open_5180_a_only_wmm_ipv4_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 A-only WMM IPv4 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_download", channel="36", bw="a_only_wmm")
+
+def test_ap_open_5180_a_only_wmm_ipv6_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 A-only WMM IPv6 udp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_upload", channel="36", bw="a_only_wmm")
+
+def test_ap_open_5180_a_only_wmm_ipv6_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 A-only WMM IPv6 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_download", channel="36", bw="a_only_wmm")
+
+def test_ap_open_5180_a_only_wmm_ipv6_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 A-only WMM IPv6 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_upload", channel="36", bw="a_only_wmm")
+
+def test_ap_open_5180_a_only_wmm_ipv6_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 A-only WMM IPv6 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_download", channel="36", bw="a_only_wmm")
+
+
+# HT20 - 2G
+def test_ap_open_2437_HT20_ipv4_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2437 HT20 IPv4 tcp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_download", channel="6", bw="HT20")
+
+def test_ap_open_2437_HT20_ipv4_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2437 HT20 IPv4 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_upload", channel="6", bw="HT20")
+
+def test_ap_open_2437_HT20_ipv4_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2437 HT20 IPv4 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_download", channel="6", bw="HT20")
+
+def test_ap_open_2437_HT20_ipv4_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2437 HT20 IPv4 dup upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_upload", channel="6", bw="HT20")
+
+def test_ap_open_2437_HT20_ipv6_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2437 HT20 IPv6 tcp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_download", channel="6", bw="HT20")
+
+def test_ap_open_2437_HT20_ipv6_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2437 HT20 IPv6 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_upload", channel="6", bw="HT20")
+
+def test_ap_open_2437_HT20_ipv6_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2437 HT20 IPv6 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_download", channel="6", bw="HT20")
+
+def test_ap_open_2437_HT20_ipv6_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2437 HT20 IPv6 dup upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_upload", channel="6", bw="HT20")
+
+
+# HT40- 2G
+def test_ap_open_2462_HT40_ipv4_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 HT40- IPv4 tcp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_download", channel="11", bw="HT40-")
+
+def test_ap_open_2462_HT40_ipv4_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 HT40- IPv4 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_upload", channel="11", bw="HT40-")
+
+def test_ap_open_2462_HT40_ipv4_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 HT40- IPv4 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_download", channel="11", bw="HT40-")
+
+def test_ap_open_2462_HT40_ipv4_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 HT40- IPv4 udp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_upload", channel="11", bw="HT40-")
+
+def test_ap_open_2462_HT40_ipv6_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 HT40- IPv6 tcp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_download", channel="11", bw="HT40-")
+
+def test_ap_open_2462_HT40_ipv6_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 HT40- IPv6 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_upload", channel="11", bw="HT40-")
+
+def test_ap_open_2462_HT40_ipv6_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 HT40- IPv6 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_download", channel="11", bw="HT40-")
+
+def test_ap_open_2462_HT40_ipv6_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2462 HT40- IPv6 udp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_upload", channel="11", bw="HT40-")
+
+
+# HT40+ 2G
+def test_ap_open_2412_HT40_ipv4_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2412 HT40+ IPv4 tcp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_download", channel="1", bw="HT40+")
+
+def test_ap_open_2412_HT40_ipv4_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2412 HT40+ IPv4 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_upload", channel="1", bw="HT40+")
+
+def test_ap_open_2412_HT40_ipv4_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2412 HT40+ IPv4 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_download", channel="1", bw="HT40+")
+
+def test_ap_open_2412_HT40_ipv4_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2412 HT40+ IPv4 udp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_upload", channel="1", bw="HT40+")
+
+def test_ap_open_2412_HT40_ipv6_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2412 HT40+ IPv6 tcp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_download", channel="1", bw="HT40+")
+
+def test_ap_open_2412_HT40_ipv6_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2412 HT40+ IPv6 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_upload", channel="1", bw="HT40+")
+
+def test_ap_open_2412_HT40_ipv6_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2412 HT40+ IPv6 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_download", channel="1", bw="HT40+")
+
+def test_ap_open_2412_HT40_ipv6_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 2412 HT40+ IPv6 udp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_upload", channel="1", bw="HT40+")
+
+
+# HT20 - 5G
+def test_ap_open_5180_HT20_ipv4_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 HT20 IPv4 udp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_upload", channel="40", bw="HT20")
+
+def test_ap_open_5180_HT20_ipv4_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 HT20 IPv4 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_upload", channel="40", bw="HT20")
+
+def test_ap_open_5180_HT20_ipv4_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 HT20 IPv4 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_upload", channel="40", bw="HT20")
+
+def test_ap_open_5180_HT20_ipv4_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 HT20 IPv4 tcp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_upload", channel="40", bw="HT20")
+
+def test_ap_open_5180_HT20_ipv6_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 HT20 IPv6 udp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_upload", channel="40", bw="HT20")
+
+def test_ap_open_5180_HT20_ipv6_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 HT20 IPv6 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_upload", channel="40", bw="HT20")
+
+def test_ap_open_5180_HT20_ipv6_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 HT20 IPv6 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_upload", channel="40", bw="HT20")
+
+def test_ap_open_5180_HT20_ipv6_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 HT20 IPv6 tcp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_upload", channel="40", bw="HT20")
+
+# HT40+ 5G
+def test_ap_open_5180_HT40_ipv4_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 HT40 IPv4 udp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_upload", channel="36", bw="HT40+")
+
+def test_ap_open_5180_HT40_ipv4_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 HT40 IPv4 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_upload", channel="36", bw="HT40+")
+
+def test_ap_open_5180_HT40_ipv4_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 HT40 IPv4 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_upload", channel="36", bw="HT40+")
+
+def test_ap_open_5180_HT40_ipv4_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 HT40 IPv4 tcp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_upload", channel="36", bw="HT40+")
+
+def test_ap_open_5180_HT40_ipv6_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 HT40 IPv6 udp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_upload", channel="36", bw="HT40+")
+
+def test_ap_open_5180_HT40_ipv6_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 HT40 IPv6 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_upload", channel="36", bw="HT40+")
+
+def test_ap_open_5180_HT40_ipv6_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 HT40 IPv6 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_upload", channel="36", bw="HT40+")
+
+def test_ap_open_5180_HT40_ipv6_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 HT40 IPv6 tcp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_upload", channel="36", bw="HT40+")
+
+# VHT80
+def test_ap_open_5180_VHT80_ipv4_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 VHT80 IPv4 tcp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_download", channel="36", bw="VHT80")
+
+def test_ap_open_5180_VHT80_ipv4_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 VHT80 IPv4 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_tcp_upload", channel="36", bw="VHT80")
+
+def test_ap_open_5180_VHT80_ipv4_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 VHT80 IPv4 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_download", channel="36", bw="VHT80")
+
+def test_ap_open_5180_VHT80_ipv4_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 VHT80 IPv4 udp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv4_udp_upload", channel="36", bw="VHT80")
+
+def test_ap_open_5180_VHT80_ipv6_tcp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 VHT80 IPv6 tcp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_download", channel="36", bw="VHT80")
+
+def test_ap_open_5180_VHT80_ipv6_tcp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 VHT80 IPv6 tcp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_tcp_upload", channel="36", bw="VHT80")
+
+def test_ap_open_5180_VHT80_ipv6_udp_download(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 VHT80 IPv6 udp download"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_download", channel="36", bw="VHT80")
+
+def test_ap_open_5180_VHT80_ipv6_udp_upload(devices, duts, setup_params, ref=None, dut=None):
+    """AP with open mode (no security) configuration 5180 VHT80 IPv6 udp upload"""
+    return ap_open(devices, duts, setup_params, ref, dut, "ipv6_udp_upload", channel="36", bw="VHT80")
diff --git a/tests/remote/utils.py b/tests/remote/utils.py
new file mode 100644
index 0000000..ffdffcc
--- /dev/null
+++ b/tests/remote/utils.py
@@ -0,0 +1,314 @@
+import time
+import wpaspy
+
+def get_device(devices, name=None, flags=None):
+    if name is None and flags is None:
+        return devices[0]
+    for device in devices:
+        if device['name'] == name:
+            return device
+    for device in devices:
+        try:
+            device_flags = device['flags']
+            if device_flags.find(flags) != -1:
+                return device
+        except:
+            pass
+    return None
+
+def get_dut(duts, name=None):
+    if name is None:
+        return duts[0]
+    for dut in duts:
+        if dut['name'] == name:
+            return dut
+    return None
+
+def run_hostapd(dev, setup_params):
+    log_file = None
+    host = wpaspy.Host(host = dev['hostname'],
+                       ifname = dev['ifname'],
+                       port = dev['port'],
+                       name = dev['name'])
+    try:
+        setup_hw = setup_params['setup_hw']
+        host.execute(setup_hw + " -I " + dev['ifname'])
+    except:
+        pass
+
+    try:
+        tc_name = setup_params['tc_name']
+        log_dir = setup_params['log_dir']
+        log_file = log_dir + tc_name + "_hostapd_" + host.name + "_" + host.ifname + ".log"
+        host.execute("rm " + log_file)
+        log = " -f " + log_file
+    except:
+        log = ""
+
+    status, buf = host.execute(setup_params['hostapd'] + " -B -ddt -g udp:" + host.port + log)
+    if status != 0:
+        raise Exception("Could not run hostapd: " + buf)
+
+    return host, log_file
+
+def run_wpasupplicant(dev, setup_params):
+    log_file = None
+    host = wpaspy.Host(host = dev['hostname'],
+                       ifname = dev['ifname'],
+                       port = dev['port'],
+                       name = dev['name'])
+    try:
+        setup_hw = setup_params['setup_hw']
+        host.execute(setup_hw + " -I " + dev['ifname'])
+    except:
+        pass
+
+    try:
+        tc_name = setup_params['tc_name']
+        log_dir = setup_params['log_dir']
+        log_file = log_dir + tc_name + "_wpa_supplicant_" + host.name + "_" + host.ifname + ".log"
+        host.execute("rm " + log_file)
+        log = " -f " + log_file
+    except:
+        log = ""
+
+    status, buf = host.execute(setup_params['wpa_supplicant'] + " -B -g udp:" + host.port + log)
+    if status != 0:
+        raise Exception("Could not run wpa_supplicant: " + buf)
+
+    return host, log_file
+
+def get_ping_packet_loss(ping_res):
+    loss_line = ""
+    lines = ping_res.splitlines()
+    for line in lines:
+        if line.find("packet loss") != -1:
+            loss_line = line
+            break;
+
+    if loss_line == "":
+        return "100%"
+
+    sections = loss_line.split(",")
+
+    for section in sections:
+        if section.find("packet loss") != -1:
+            words = section.split()
+            return words[0]
+
+    return "100%"
+
+
+def get_ipv4(client, ifname=None):
+    if ifname is None:
+        ifname = client.ifname
+    status, buf = client.execute("ifconfig " + ifname)
+    lines = buf.splitlines()
+
+    for line in lines:
+        res = line.find("inet addr:")
+        if res != -1:
+            break
+
+    if res != -1:
+        words = line.split()
+        addr = words[1].split(":")
+        return addr[1]
+
+    return "unknown"
+
+def get_ipv6(client, ifname=None):
+    res = -1
+    if ifname is None:
+        ifname = client.ifname
+    status, buf = client.execute("ifconfig " + ifname)
+    lines = buf.splitlines()
+
+    for line in lines:
+        res = line.find("Scope:Link")
+        if res != -1:
+            break
+
+    if res != -1:
+        words = line.split()
+        if words[0] == "inet6" and words[1] == "addr:":
+            addr_mask = words[2]
+            addr = addr_mask.split("/")
+            return addr[0]
+
+    return "unknown"
+
+def get_ip(client, addr_type="ipv6", iface=None):
+    if addr_type == "ipv6":
+        return get_ipv6(client, iface)
+    elif addr_type == "ipv4":
+        return get_ipv4(client, iface)
+    else:
+        return "unknown addr_type: " + addr_type
+
+def ping_run(host, ip, result, ifname=None, addr_type="ipv4", deadline="5"):
+    ping = "ping"
+    if ifname is None:
+       ifname = host.ifname
+    if addr_type is "ipv6":
+        ping = "ping6"
+    ping = ping + " -w 5" + " -I " + ifname + " " + ip
+
+    thread = host.execute_run(ping, result)
+    return thread
+
+def ping_wait(host, thread, timeout=None):
+    host.wait_execute_complete(thread, timeout)
+    if thread.isAlive():
+        raise Exception("ping thread still alive")
+
+def check_connectivity(a, b, addr_type = "ipv4", deadline="5"):
+    addr_a = get_ip(a, addr_type)
+    addr_b = get_ip(b, addr_type)
+
+    if addr_type == "ipv4":
+        ping = "ping"
+    else:
+        ping = "ping6"
+
+    status, buf = a.execute(ping + " -w " + deadline + " -I " + a.ifname + " " + addr_b)
+    if status != 0:
+        raise Exception("ping " + a.ifname + " >> " + b.ifname)
+
+    a_b = get_ping_packet_loss(buf)
+
+    status, buf = b.execute(ping + " -w " + deadline + " -I " + b.ifname + " " + addr_a)
+    if status != 0:
+        raise Exception("ping " + b.ifname + " >> " + a.ifname)
+
+    b_a = get_ping_packet_loss(buf)
+
+    if int(a_b[:-1]) > 40:
+        raise Exception("Too high packet lost: " + a_b)
+
+    if int(b_a[:-1]) > 40:
+        raise Exception("Too high packet lost: " + b_a)
+
+    return a_b, b_a
+
+def get_iperf_speed(iperf_res, pattern="Mbits/sec"):
+    lines = iperf_res.splitlines()
+    sum_line = ""
+    last_line = ""
+    count = 0
+    res = -1
+
+    # first find last SUM line
+    for line in lines:
+        res  = line.find("[SUM]")
+        if res != -1:
+            sum_line = line
+
+    # next check SUM status
+    if sum_line != "":
+        words = sum_line.split()
+        for word in words:
+            res = word.find(pattern)
+            if res != -1:
+                return words[count - 1] + " " + pattern
+            count = count + 1
+
+    # no SUM - one thread - find last line
+    for line in lines:
+        res = line.find(pattern)
+        if res != -1:
+            last_line = line
+
+    if last_line == "":
+        return "0 " + pattern
+
+    count = 0
+    words = last_line.split()
+    for word in words:
+        res = word.find(pattern)
+        if res != -1:
+            return words[count - 1] + " " + pattern
+            break;
+        count = count + 1
+    return "0 " + pattern
+
+def ac_to_iperf_ac(qos):
+    if qos == "be":
+        qos_param = "-S 0x00"
+    elif qos == "bk":
+        qos_param = "-S 0x20"
+    elif qos == "vi":
+        qos_param = "-S 0xA0"
+    elif qos == "vo":
+        qos_param = "-S 0xE0"
+    else:
+        qos_param = "-S 0x00"
+    return qos_param
+
+def iperf_run(server, client, server_ip, client_res, server_res,
+              l4="udp", bw="30M", test_time="30", parallel="5",
+              qos="be", param=" -i 5 ", ifname=None, l3="ipv4",
+              port="5001", iperf="iperf"):
+    if ifname == None:
+        ifname = client.ifname
+
+    if iperf == "iperf":
+        iperf_server = iperf
+    elif iperf == "iperf3":
+        iperf_server = iperf + " -1"
+
+    if l3 == "ipv4":
+        iperf_client = iperf + " -c " + server_ip + " -p " + port
+        iperf_server = iperf_server + " -p " + port
+    elif l3 == "ipv6":
+        iperf_client = iperf + " -V -c " + server_ip + "%" + ifname + " -p " + port
+        iperf_server = iperf_server + " -V -p " + port
+    else:
+        return -1, -1
+
+    iperf_server = iperf_server + " -s -f m " + param
+    iperf_client = iperf_client + " -f m -t " + test_time
+
+    if parallel != "1":
+        iperf_client = iperf_client + " -P" + parallel
+
+    if l4 == "udp":
+        if iperf is not "iperf3":
+            iperf_server = iperf_server + " -u"
+        iperf_client = iperf_client + " -u -b " + bw
+
+    qos_param = ac_to_iperf_ac(qos)
+    iperf_client = iperf_client + " " + qos_param
+
+    server_thread = server.execute_run(iperf_server, server_res)
+    time.sleep(1)
+    client_thread = client.execute_run(iperf_client, client_res)
+
+    return server_thread, client_thread
+
+def iperf_wait(server, client, server_thread, client_thread, timeout=None, iperf="iperf"):
+    client.wait_execute_complete(client_thread, timeout)
+    if client_thread.isAlive():
+        raise Exception("iperf client thread still alive")
+
+    server.wait_execute_complete(server_thread, 5)
+    if server_thread.isAlive():
+        server.execute("killall -s INT " + iperf)
+        time.sleep(1)
+
+    server.wait_execute_complete(server_thread, 5)
+    if server_thread.isAlive():
+        raise Execption("iperf server thread still alive")
+
+    return
+
+def get_ipv4_addr(setup_params, number):
+    try:
+        ipv4_base = setup_params['ipv4_test_net']
+    except:
+        ipv4_base = "172.16.12.0"
+
+    parts = ipv4_base.split('.')
+    ipv4 = parts[0] + "." + parts[1] + "." + parts[2] + "." + str(number)
+
+    return ipv4
-- 
1.9.1




More information about the Hostap mailing list