Exemple #1
0
    def run_iperf_single_ndp_aware_only(self, use_ib, results):
        """Measure iperf performance on a single NDP, with Aware enabled and no
    infrastructure connection - i.e. device is not associated to an AP.

    Args:
      use_ib: True to use in-band discovery, False to use out-of-band discovery.
      results: Dictionary into which to place test results.
    """
        init_dut = self.android_devices[0]
        resp_dut = self.android_devices[1]

        if use_ib:
            # note: Publisher = Responder, Subscribe = Initiator
            (resp_req_key, init_req_key, resp_aware_if, init_aware_if,
             resp_ipv6, init_ipv6) = autils.create_ib_ndp(
                 resp_dut, init_dut,
                 autils.create_discovery_config(
                     self.SERVICE_NAME, aconsts.PUBLISH_TYPE_UNSOLICITED),
                 autils.create_discovery_config(
                     self.SERVICE_NAME, aconsts.SUBSCRIBE_TYPE_PASSIVE),
                 self.device_startup_offset)
        else:
            (init_req_key, resp_req_key, init_aware_if, resp_aware_if,
             init_ipv6, resp_ipv6) = autils.create_oob_ndp(init_dut, resp_dut)
        self.log.info("Interface names: I=%s, R=%s", init_aware_if,
                      resp_aware_if)
        self.log.info("Interface addresses (IPv6): I=%s, R=%s", init_ipv6,
                      resp_ipv6)

        # Run iperf3
        result, data = init_dut.run_iperf_server("-D")
        asserts.assert_true(result, "Can't start iperf3 server")

        result, data = resp_dut.run_iperf_client(
            "%s%%%s" % (init_ipv6, resp_aware_if), "-6 -J")
        self.log.debug(data)
        asserts.assert_true(result,
                            "Failure starting/running iperf3 in client mode")
        self.log.debug(pprint.pformat(data))

        # clean-up
        resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
        init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)

        # Collect results
        data_json = json.loads("".join(data))
        if "error" in data_json:
            asserts.fail("iperf run failed: %s" % data_json["error"],
                         extras=data_json)
        results["tx_rate"] = data_json["end"]["sum_sent"]["bits_per_second"]
        results["rx_rate"] = data_json["end"]["sum_received"][
            "bits_per_second"]
        self.log.info("iPerf3: Sent = %d bps Received = %d bps",
                      results["tx_rate"], results["rx_rate"])
Exemple #2
0
    def run_infra_assoc_oob_ndp_stress(self, with_ndp_traffic):
        """Validates that Wi-Fi Aware NDP does not interfere with infrastructure
    (AP) association.

    Test assumes (and verifies) that device is already associated to an AP.

    Args:
      with_ndp_traffic: True to run traffic over the NDP.
    """
        init_dut = self.android_devices[0]
        resp_dut = self.android_devices[1]

        # check that associated and start tracking
        init_dut.droid.wifiStartTrackingStateChange()
        resp_dut.droid.wifiStartTrackingStateChange()
        asserts.assert_true(self.is_associated(init_dut),
                            "DUT is not associated to an AP!")
        asserts.assert_true(self.is_associated(resp_dut),
                            "DUT is not associated to an AP!")

        # set up NDP
        (init_req_key, resp_req_key, init_aware_if, resp_aware_if, init_ipv6,
         resp_ipv6) = autils.create_oob_ndp(init_dut, resp_dut)
        self.log.info("Interface names: I=%s, R=%s", init_aware_if,
                      resp_aware_if)
        self.log.info("Interface addresses (IPv6): I=%s, R=%s", init_ipv6,
                      resp_ipv6)

        # wait for any disassociation change events
        q = queue.Queue()
        init_thread = threading.Thread(target=self.wait_for_disassociation,
                                       args=(q, init_dut))
        resp_thread = threading.Thread(target=self.wait_for_disassociation,
                                       args=(q, resp_dut))

        init_thread.start()
        resp_thread.start()

        any_disassociations = False
        try:
            q.get(True, self.TEST_DURATION_SECONDS)
            any_disassociations = True  # only happens on any disassociation
        except queue.Empty:
            pass
        finally:
            # TODO: no way to terminate thread (so even if we fast fail we still have
            # to wait for the full timeout.
            init_dut.droid.wifiStopTrackingStateChange()
            resp_dut.droid.wifiStopTrackingStateChange()

        asserts.assert_false(any_disassociations,
                             "Wi-Fi disassociated during test run")
Exemple #3
0
    def test_ping6_oob(self):
        """Validate that ping6 works correctly on an NDP created using OOB (out-of
    band) discovery"""
        init_dut = self.android_devices[0]
        resp_dut = self.android_devices[1]

        # create NDP
        (init_req_key, resp_req_key, init_aware_if, resp_aware_if, init_ipv6,
         resp_ipv6) = autils.create_oob_ndp(init_dut, resp_dut)
        self.log.info("Interface names: I=%s, R=%s", init_aware_if,
                      resp_aware_if)
        self.log.info("Interface addresses (IPv6): I=%s, R=%s", init_ipv6,
                      resp_ipv6)

        # run ping6
        self.run_ping6(init_dut, resp_ipv6, init_aware_if)
        self.run_ping6(resp_dut, init_ipv6, resp_aware_if)

        # clean-up
        resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
        init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
Exemple #4
0
    def test_nsd_oob(self):
        """Validate that NSD (mDNS) works correctly on an NDP created using OOB
    (out-of band) discovery"""
        init_dut = self.android_devices[0]
        resp_dut = self.android_devices[1]

        # create NDP
        (init_req_key, resp_req_key, init_aware_if, resp_aware_if, init_ipv6,
         resp_ipv6) = autils.create_oob_ndp(init_dut, resp_dut)
        self.log.info("Interface names: I=%s, R=%s", init_aware_if,
                      resp_aware_if)
        self.log.info("Interface addresses (IPv6): I=%s, R=%s", init_ipv6,
                      resp_ipv6)

        # run NSD
        nsd_service_info = {
            "serviceInfoServiceName": "sl4aTestAwareNsd",
            "serviceInfoServiceType": "_simple-tx-rx._tcp.",
            "serviceInfoPort": 2257
        }
        nsd_reg = None
        nsd_discovery = None
        try:
            # Initiator registers an NSD service
            nsd_reg = init_dut.droid.nsdRegisterService(nsd_service_info)
            event_nsd = autils.wait_for_event_with_keys(
                init_dut, nconsts.REG_LISTENER_EVENT, autils.EVENT_TIMEOUT,
                (nconsts.REG_LISTENER_CALLBACK,
                 nconsts.REG_LISTENER_EVENT_ON_SERVICE_REGISTERED))
            self.log.info("Initiator %s: %s",
                          nconsts.REG_LISTENER_EVENT_ON_SERVICE_REGISTERED,
                          event_nsd["data"])

            # Responder starts an NSD discovery
            nsd_discovery = resp_dut.droid.nsdDiscoverServices(
                nsd_service_info[nconsts.NSD_SERVICE_INFO_SERVICE_TYPE])
            event_nsd = autils.wait_for_event_with_keys(
                resp_dut, nconsts.DISCOVERY_LISTENER_EVENT,
                autils.EVENT_TIMEOUT,
                (nconsts.DISCOVERY_LISTENER_DATA_CALLBACK,
                 nconsts.DISCOVERY_LISTENER_EVENT_ON_SERVICE_FOUND))
            self.log.info("Responder %s: %s",
                          nconsts.DISCOVERY_LISTENER_EVENT_ON_SERVICE_FOUND,
                          event_nsd["data"])

            # Responder resolves IP address of Initiator from NSD service discovery
            resp_dut.droid.nsdResolveService(event_nsd["data"])
            event_nsd = autils.wait_for_event_with_keys(
                resp_dut, nconsts.RESOLVE_LISTENER_EVENT, autils.EVENT_TIMEOUT,
                (nconsts.RESOLVE_LISTENER_DATA_CALLBACK,
                 nconsts.RESOLVE_LISTENER_EVENT_ON_SERVICE_RESOLVED))
            self.log.info("Responder %s: %s",
                          nconsts.RESOLVE_LISTENER_EVENT_ON_SERVICE_RESOLVED,
                          event_nsd["data"])

            # mDNS returns first character as '/' - strip
            # out to get clean IPv6
            init_ipv6_nsd = event_nsd["data"][
                nconsts.NSD_SERVICE_INFO_HOST][1:]

            asserts.assert_equal(
                init_ipv6, init_ipv6_nsd,
                "Initiator's IPv6 address obtained through NSD doesn't match!?"
            )
        finally:
            # Stop NSD
            if nsd_reg is not None:
                init_dut.droid.nsdUnregisterService(nsd_reg)
            if nsd_discovery is not None:
                resp_dut.droid.nsdStopServiceDiscovery(nsd_discovery)

        # clean-up
        resp_dut.droid.connectivityUnregisterNetworkCallback(resp_req_key)
        init_dut.droid.connectivityUnregisterNetworkCallback(init_req_key)
    def test_ping6_oob_max_ndp(self):
        """Validate that ping6 works correctly on multiple NDPs brought up
    concurrently. Uses the capability of the device to determine the max
    number of NDPs to set up.

    Note: the test requires MAX_NDP + 1 devices to be validated. If these are
    not available the test will fail."""
        dut = self.android_devices[0]

        # get max NDP: using first available device (assumes all devices are the
        # same)
        max_ndp = dut.aware_capabilities[aconsts.CAP_MAX_NDP_SESSIONS]
        asserts.assert_true(
            len(self.android_devices) > max_ndp,
            'Needed %d devices to run the test, have %d' %
            (max_ndp + 1, len(self.android_devices)))

        # create all NDPs
        dut_aware_if = None
        dut_ipv6 = None
        peers_aware_ifs = []
        peers_ipv6s = []
        dut_requests = []
        peers_requests = []
        for i in range(max_ndp):
            (init_req_key, resp_req_key, init_aware_if, resp_aware_if,
             init_ipv6,
             resp_ipv6) = autils.create_oob_ndp(dut,
                                                self.android_devices[i + 1])
            self.log.info("Interface names: I=%s, R=%s", init_aware_if,
                          resp_aware_if)
            self.log.info("Interface addresses (IPv6): I=%s, R=%s", init_ipv6,
                          resp_ipv6)

            dut_requests.append(init_req_key)
            peers_requests.append(resp_req_key)
            if dut_aware_if is None:
                dut_aware_if = init_aware_if
            else:
                asserts.assert_equal(
                    dut_aware_if, init_aware_if,
                    "DUT (Initiator) interface changed on subsequent NDPs!?")
            if dut_ipv6 is None:
                dut_ipv6 = init_ipv6
            else:
                asserts.assert_equal(
                    dut_ipv6, init_ipv6,
                    "DUT (Initiator) IPv6 changed on subsequent NDPs!?")
            peers_aware_ifs.append(resp_aware_if)
            peers_ipv6s.append(resp_ipv6)

        # run ping6
        for i in range(max_ndp):
            self.run_ping6(dut, peers_ipv6s[i], dut_aware_if)
            self.run_ping6(self.android_devices[i + 1], dut_ipv6,
                           peers_aware_ifs[i])

        # cleanup
        for i in range(max_ndp):
            dut.droid.connectivityUnregisterNetworkCallback(dut_requests[i])
            self.android_devices[
                i + 1].droid.connectivityUnregisterNetworkCallback(
                    peers_requests[i])
    def run_iperf_max_ndp_aware_only(self, results):
        """Measure iperf performance on the max number of concurrent OOB NDPs, with
    Aware enabled and no infrastructure connection - i.e. device is not
    associated to an AP.

    Note: the test requires MAX_NDP + 1 devices to be validated. If these are
    not available the test will fail.

    Args:
      results: Dictionary into which to place test results.
    """
        dut = self.android_devices[0]

        # get max NDP: using first available device (assumes all devices are the
        # same)
        max_ndp = dut.aware_capabilities[aconsts.CAP_MAX_NDP_SESSIONS]
        asserts.assert_true(
            len(self.android_devices) > max_ndp,
            'Needed %d devices to run the test, have %d' %
            (max_ndp + 1, len(self.android_devices)))

        # create all NDPs
        dut_aware_if = None
        dut_ipv6 = None
        peers_aware_ifs = []
        peers_ipv6s = []
        dut_requests = []
        peers_requests = []
        for i in range(max_ndp):
            (init_req_key, resp_req_key, init_aware_if, resp_aware_if,
             init_ipv6,
             resp_ipv6) = autils.create_oob_ndp(dut,
                                                self.android_devices[i + 1])
            self.log.info("Interface names: I=%s, R=%s", init_aware_if,
                          resp_aware_if)
            self.log.info("Interface addresses (IPv6): I=%s, R=%s", init_ipv6,
                          resp_ipv6)

            dut_requests.append(init_req_key)
            peers_requests.append(resp_req_key)
            if dut_aware_if is None:
                dut_aware_if = init_aware_if
            else:
                asserts.assert_equal(
                    dut_aware_if, init_aware_if,
                    "DUT (Initiator) interface changed on subsequent NDPs!?")
            if dut_ipv6 is None:
                dut_ipv6 = init_ipv6
            else:
                asserts.assert_equal(
                    dut_ipv6, init_ipv6,
                    "DUT (Initiator) IPv6 changed on subsequent NDPs!?")
            peers_aware_ifs.append(resp_aware_if)
            peers_ipv6s.append(resp_ipv6)

        # create threads, start them, and wait for all to finish
        base_port = 5000
        q = queue.Queue()
        threads = []
        for i in range(max_ndp):
            threads.append(
                threading.Thread(target=self.run_iperf,
                                 args=(q, dut, self.android_devices[i + 1],
                                       peers_aware_ifs[i], dut_ipv6,
                                       base_port + i)))

        for thread in threads:
            thread.start()

        for thread in threads:
            thread.join()

        # cleanup
        for i in range(max_ndp):
            dut.droid.connectivityUnregisterNetworkCallback(dut_requests[i])
            self.android_devices[
                i + 1].droid.connectivityUnregisterNetworkCallback(
                    peers_requests[i])

        # collect data
        for i in range(max_ndp):
            results[i] = {}
            result, data = q.get()
            asserts.assert_true(
                result, "Failure starting/running iperf3 in client mode")
            self.log.debug(pprint.pformat(data))
            data_json = json.loads("".join(data))
            if "error" in data_json:
                asserts.fail("iperf run failed: %s" % data_json["error"],
                             extras=data_json)
            results[i]["tx_rate"] = data_json["end"]["sum_sent"][
                "bits_per_second"]
            results[i]["rx_rate"] = data_json["end"]["sum_received"][
                "bits_per_second"]
            self.log.info("iPerf3: Sent = %d bps Received = %d bps",
                          results[i]["tx_rate"], results[i]["rx_rate"])