Esempio n. 1
0
    def run(self, client):
        """
        Create a NetperfRunner, run netperf between DUT and work_client.

        @param client: WiFiClient object representing the DUT

        """
        with netperf_runner.NetperfRunner(
                client, self.work_client, self._config) as netperf:
            ping_config = ping_runner.PingConfig(
                    self.work_client.wifi_ip, count=10)
            # pinging work client to ensure we have a connection
            logging.info('work client ip: %s', self.work_client.wifi_ip)
            ping_result = client.ping(ping_config)

            result = netperf.run(self._config)
            logging.info('Netperf Result: %s', result)

        if result is None:
            raise error.TestError('Failed to create NetperfResult')

        if result.duration_seconds < self._config.test_time:
            raise error.TestFail(
                    'Netperf duration too short: %0.2f < %0.2f' %
                    (result.duration_seconds, self._config.test_time))

        # TODO: Convert this limit to a perf metric crbug.com/348780
        if result.throughput <self.NETPERF_MIN_THROUGHPUT:
            raise error.TestFail(
                    'Netperf throughput too low: %0.2f < %0.2f' %
                    (result.throughput, self.NETPERF_MIN_THROUGHPUT))
Esempio n. 2
0
    def run(self, config):
        """Measure the average and standard deviation of a netperf test.

        @param config: NetperfConfig object.

        """
        logging.info('Performing %s measurements in netperf session.',
                     config.human_readable_tag)
        history = []
        none_count = 0
        final_result = None
        with netperf_runner.NetperfRunner(self._client_proxy,
                                          self._server_proxy,
                                          config) as runner:
            while len(history) + none_count < self.MEASUREMENT_MAX_SAMPLES:
                result = runner.run(ignore_failures=self._ignore_failures)
                if result is None:
                    none_count += 1
                    continue

                history.append(result)
                if len(history) < self.MEASUREMENT_MIN_SAMPLES:
                    continue

                final_result = self._from_samples(history)
                if final_result.all_deviations_less_than_fraction(
                        self.MAX_DEVIATION_FRACTION):
                    break

        if final_result is None:
            final_result = self._from_samples(history)
        logging.info('Took averaged measurement %r.', final_result)
        return history or None
    def run_once(self):
        """Test body."""
        if utils.host_could_be_in_afe(self.context.client.host.hostname):
            # Just abort the test if we're in the lab and not on a
            # machine known to be conducted. The performance
            # requirements of this test are hard to meet, without
            # strong multi-path effects. (Our conducted setups are
            # designed to provide strong multi-path.)
            if not self.context.client.conductive:
                raise error.TestNAError(
                    'This test requires a great RF environment.')
        else:
            logging.error('Unable to determine if DUT has conducted '
                          'connection to AP. Treat any TestFail with '
                          'skepticism.')

        caps = [
            hostap_config.HostapConfig.N_CAPABILITY_GREENFIELD,
            hostap_config.HostapConfig.N_CAPABILITY_HT40
        ]
        mode_11n = hostap_config.HostapConfig.MODE_11N_PURE
        get_config = lambda channel: hostap_config.HostapConfig(
            channel=channel, mode=mode_11n, n_capabilities=caps)
        netperf_config = netperf_runner.NetperfConfig(
            netperf_runner.NetperfConfig.TEST_TYPE_UDP_STREAM)
        for i, ap_config in enumerate([get_config(1), get_config(157)]):
            # Set up the router and associate the client with it.
            self.context.configure(ap_config)
            self.context.capture_host.start_capture(
                ap_config.frequency,
                ht_type=ap_config.ht_packet_capture_mode,
                snaplen=self.TEST_SNAPLEN)
            assoc_params = xmlrpc_datatypes.AssociationParameters(
                ssid=self.context.router.get_ssid())
            self.context.assert_connect_wifi(assoc_params)
            with netperf_runner.NetperfRunner(self.context.client,
                                              self.context.router,
                                              netperf_config) as runner:
                runner.run()
            results = self.context.capture_host.stop_capture()
            if len(results) != 1:
                raise error.TestError('Expected to generate one packet '
                                      'capture but got %d instead.' %
                                      len(results))

            # The device should sense that it is in a clean RF environment and
            # use the highest index to achieve maximal throughput.
            max_mcs_index = self.get_highest_mcs_rate(ap_config.frequency)
            self.check_bitrates_in_capture(results[0], max_mcs_index)
            # Clean up router and client state for the next run.
            self.context.client.shill.disconnect(
                self.context.router.get_ssid())
            self.context.router.deconfig()
Esempio n. 4
0
    def warmup_wifi_part(self, warmup_client=True):
        """Warm up a rate controller on the client or server.

        WiFi "warms up" in that rate controllers dynamically adjust to
        environmental conditions by increasing symbol rates until loss is
        observed.  This manifests as initially slow data transfer rates that
        get better over time.

        We'll say that a rate controller is warmed up if a small sample of
        WARMUP_WINDOW_SIZE throughput measurements has an average throughput
        within a standard deviation of the previous WARMUP_WINDOW_SIZE samples.

        @param warmup_client: bool True iff we should warmup the client rate
                controller.  Otherwise we warm up the server rate controller.

        """
        if warmup_client:
            # We say a station is warm if the TX throughput is maximized.
            # Each station only controls its own transmission TX rate.
            logging.info('Warming up the client WiFi rate controller.')
            test_type = netperf_runner.NetperfConfig.TEST_TYPE_TCP_STREAM
        else:
            logging.info('Warming up the server WiFi rate controller.')
            test_type = netperf_runner.NetperfConfig.TEST_TYPE_TCP_MAERTS
        config = netperf_runner.NetperfConfig(
            test_type, test_time=self.WARMUP_SAMPLE_TIME_SECONDS)
        warmup_history = []
        with netperf_runner.NetperfRunner(self._client_proxy,
                                          self._server_proxy,
                                          config) as runner:
            while len(warmup_history) < self.WARMUP_MAX_SAMPLES:
                warmup_history.append(runner.run())
                if len(warmup_history) > 2 * self.WARMUP_WINDOW_SIZE:
                    # Grab 2 * WARMUP_WINDOW_SIZE samples, divided into the most
                    # recent chunk and the chunk before that.
                    start = -2 * self.WARMUP_WINDOW_SIZE
                    middle = -self.WARMUP_WINDOW_SIZE
                    past_result = self._from_samples(
                        warmup_history[start:middle])
                    recent_result = self._from_samples(warmup_history[middle:])
                    if recent_result.throughput < (past_result.throughput +
                                                   past_result.throughput_dev):
                        logging.info('Rate controller is warmed.')
                        return
            else:
                logging.warning('Did not completely warmup the WiFi part.')