def run_once(self):
     """Body of the test."""
     self.context.client.require_capabilities(
         [site_linux_system.LinuxSystem.CAPABILITY_IBSS])
     self.context.router.require_capabilities(
         [site_linux_system.LinuxSystem.CAPABILITY_IBSS])
     # In the past, we have seen a bug where a previous association on a
     # channel where IBSS was disallowed would prohibit wpa_supplicant
     # from setting the interface to adhoc mode (since the kernel refuses
     # to allow adhoc mode on the previous channel).
     configuration = hostap_config.HostapConfig(
         channel=52, mode=hostap_config.HostapConfig.MODE_11A)
     self.context.configure(configuration)
     assoc_params = xmlrpc_datatypes.AssociationParameters(
         ssid=self.context.router.get_ssid())
     self.context.assert_connect_wifi(assoc_params)
     self.context.client.shill.disconnect(assoc_params.ssid)
     configuration = hostap_config.HostapConfig(
         frequency=2412, mode=hostap_config.HostapConfig.MODE_11B)
     self.context.configure(configuration, is_ibss=True)
     assoc_params = xmlrpc_datatypes.AssociationParameters(
         ssid=self.context.router.get_ssid(),
         discovery_timeout=30,
         association_timeout=30,
         configuration_timeout=30,
         station_type=xmlrpc_datatypes.AssociationParameters.
         STATION_TYPE_IBSS)
     self.context.assert_connect_wifi(assoc_params)
     self.context.assert_ping_from_dut()
     self.context.client.shill.disconnect(assoc_params.ssid)
     self.context.router.deconfig_aps()
 def run_once(self):
     """Test body."""
     wpa_config = xmlrpc_security_types.WPAConfig(
         psk='chromeos',
         wpa_mode=xmlrpc_security_types.WPAConfig.MODE_PURE_WPA,
         wpa_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_CCMP])
     ap_config0 = hostap_config.HostapConfig(
         ssid=self.TEST_SSID,
         frequency=2412,
         mode=hostap_config.HostapConfig.MODE_11G,
         scenario_name='open_network')
     client_config0 = xmlrpc_datatypes.AssociationParameters(
         ssid=self.TEST_SSID)
     ap_config1 = hostap_config.HostapConfig(
         ssid=self.TEST_SSID,
         frequency=2412,
         mode=hostap_config.HostapConfig.MODE_11G,
         security_config=wpa_config,
         scenario_name='wpa_network')
     client_config1 = xmlrpc_datatypes.AssociationParameters(
         ssid=self.TEST_SSID, security_config=wpa_config)
     self.context.configure(ap_config0)
     self.context.configure(ap_config1, multi_interface=True)
     self.context.assert_connect_wifi(client_config0)
     self.context.assert_ping_from_dut(ap_num=0)
     self.context.assert_connect_wifi(client_config1)
     self.context.assert_ping_from_dut(ap_num=1)
예제 #3
0
 def run_once(self):
     """Test body."""
     wpa_config = xmlrpc_security_types.WPAConfig(
             psk='chromeos',
             wpa_mode=xmlrpc_security_types.WPAConfig.MODE_MIXED_WPA,
             wpa_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_TKIP,
                          xmlrpc_security_types.WPAConfig.CIPHER_CCMP],
             wpa2_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_CCMP])
     ap_config = hostap_config.HostapConfig(
                 ssid=self.TEST_SSID,
                 frequency=2412,
                 mode=hostap_config.HostapConfig.MODE_11B,
                 security_config=wpa_config)
     self.context.configure(ap_config)
     assoc_params = xmlrpc_datatypes.AssociationParameters(
             ssid=self.context.router.get_ssid(),
             security_config=wpa_config)
     self.context.assert_connect_wifi(assoc_params)
     self.context.assert_ping_from_dut()
     self.context.client.shill.disconnect(assoc_params.ssid)
     # This deconfig erases the state stored in the router around WPA.
     self.context.router.deconfig()
     # Now we change the same SSID to be an open network.
     ap_config = hostap_config.HostapConfig(
                 ssid=self.TEST_SSID,
                 frequency=2412,
                 mode=hostap_config.HostapConfig.MODE_11B)
     self.context.configure(ap_config)
     assoc_params = xmlrpc_datatypes.AssociationParameters(
             ssid=self.context.router.get_ssid())
     self.context.assert_connect_wifi(assoc_params)
     self.context.assert_ping_from_dut()
     self.context.client.shill.disconnect(assoc_params.ssid)
     self.context.router.deconfig()
예제 #4
0
 def run_once(self):
     """Body of the test."""
     ap_config = hostap_config.HostapConfig(channel=1)
     self.context.configure(ap_config)
     ssid = self.context.router.get_ssid()
     client_config = xmlrpc_datatypes.AssociationParameters(ssid=ssid)
     self.context.assert_connect_wifi(client_config)
     self.context.assert_ping_from_dut()
     # Take down the AP interface, which looks like the AP "disappeared"
     # from the DUT's point of view.  This is also much faster than actually
     # tearing down the AP, which allows us to watch for the client reporting
     # itself as disconnected.
     self.context.router.set_ap_interface_down()
     self._assert_disconnect(ssid)
     self.context.router.deconfig_aps()
     logging.info('Repeating test with a client scan just before AP death.')
     self.context.configure(ap_config)
     ssid = self.context.router.get_ssid()
     client_config = xmlrpc_datatypes.AssociationParameters(ssid=ssid)
     self.context.assert_connect_wifi(client_config)
     self.context.assert_ping_from_dut()
     self.context.client.scan(frequencies=[], ssids=[])
     self.context.router.set_ap_interface_down()
     self._assert_disconnect(ssid)
     self.context.router.deconfig_aps()
    def run_once(self, disconnect_trigger, req_caps=None):
        """Sets up a router, connects to it, pings it and disables it to trigger
        disconnect."""
        configuration = hostap_config.HostapConfig(
            channel=self.INITIAL_CHANNEL,
            mode=hostap_config.HostapConfig.MODE_11A,
            spectrum_mgmt_required=True)
        if req_caps is None:
            req_caps = []
        self.context.router.require_capabilities(req_caps)
        self.context.configure(configuration)

        if site_linux_system.LinuxSystem.CAPABILITY_MULTI_AP in req_caps:
            # prep alternate Access Point
            alt_ap_config = hostap_config.HostapConfig(
                channel=self.ALT_CHANNEL,
                mode=hostap_config.HostapConfig.MODE_11N_MIXED)
            self.context.configure(alt_ap_config, multi_interface=True)
            alt_assoc_params = xmlrpc_datatypes.AssociationParameters()
            alt_assoc_params.ssid = self.context.router.get_ssid(instance=1)

        assoc_params = xmlrpc_datatypes.AssociationParameters()
        assoc_params.ssid = self.context.router.get_ssid(instance=0)
        self.context.assert_connect_wifi(assoc_params)
        self.context.assert_ping_from_dut()

        with self.context.client.assert_disconnect_event():
            if disconnect_trigger == 'AP gone':
                self.context.router.deconfig()
            elif disconnect_trigger == 'deauth client':
                self.context.router.deauth_client(self.context.client.wifi_mac)
            elif disconnect_trigger == 'AP send channel switch':
                for _ in range(self.CHANNEL_SWITCH_ATTEMPTS):
                    self.context.router.send_management_frame_on_ap(
                        'channel_switch', self.ALT_CHANNEL)
                    time.sleep(self.CHANNEL_SWITCH_WAIT_TIME_SEC)
            elif disconnect_trigger == 'switch AP':
                self.context.assert_connect_wifi(alt_assoc_params)
            elif disconnect_trigger == 'disable client wifi':
                self.context.client.set_device_enabled(
                    self.context.client.wifi_if, False)
            else:
                raise error.TestError('unknown test mode: %s' %
                                      disconnect_trigger)
            time.sleep(wifi_client.DISCONNECT_WAIT_TIME_SECONDS)

        disconnect_reasons = self.context.client.get_disconnect_reasons()
        if disconnect_reasons is None or len(disconnect_reasons) == 0:
            raise error.TestFail('supplicant DisconnectReason not logged')
        for entry in disconnect_reasons:
            logging.info("DisconnectReason: %s", entry)
    def run_once(self):
        """Sets up a router, connects to it, pings it."""
        # Setup bridge mode test environments if AP is configured to operate in
        # bridge mode.
        if (apmanager_constants.CONFIG_OPERATION_MODE in self._configurations
                and
                self._configurations[apmanager_constants.CONFIG_OPERATION_MODE]
                == apmanager_constants.OPERATION_MODE_BRIDGE):
            # Setup DHCP server on the other side of the bridge.
            self.context.router.setup_bridge_mode_dhcp_server()
            self._configurations[apmanager_constants.CONFIG_BRIDGE_INTERFACE] =\
                    self.context.router.get_bridge_interface()

        ssid = self.context.router.build_unique_ssid()
        self._configurations[apmanager_constants.CONFIG_SSID] = ssid
        with apmanager_service_provider.ApmanagerServiceProvider(
                self.context.router, self._configurations):
            assoc_params = xmlrpc_datatypes.AssociationParameters()
            assoc_params.ssid = ssid
            self.context.assert_connect_wifi(assoc_params)
            self.context.assert_ping_from_server()
        # AP is terminated, wait for client to become disconnected.
        success, state, elapsed_seconds = \
                self.context.client.wait_for_service_states(
                        ssid, ( 'idle', ), 30)
        if not success:
            raise error.TestFail('Failed to disconnect from %s after AP was '
                                 'terminated for %f seconds (state=%s)' %
                                 (ssid, elapsed_seconds, state))
예제 #7
0
    def test_connect(wifi_context, frequency, expect_connect, hide_ssid):
        """Verifies that a DUT does/does not connect on a particular frequency.

        @param wifi_context: A WiFiTestContextManager.
        @param frequency: int frequency to test.
        @param expect_connect: bool whether or not connection should succeed.
        @param hide_ssid: bool whether or not the AP should hide its SSID.
        @raise error.TestFail if behavior does not match expectation.

        """
        try:
            router_ssid = None
            if hide_ssid:
                pcap_name = '%d_connect_hidden.pcap' % frequency
                test_description = 'hidden'
            else:
                pcap_name = '%d_connect_visible.pcap' % frequency
                test_description = 'visible'
            wifi_context.capture_host.start_capture(frequency,
                                                    filename=pcap_name)
            wifi_context.router.hostap_configure(
                hostap_config.HostapConfig(
                    frequency=frequency,
                    hide_ssid=hide_ssid,
                    mode=hostap_config.HostapConfig.MODE_11N_MIXED))
            router_ssid = wifi_context.router.get_ssid()
            client_conf = xmlrpc_datatypes.AssociationParameters(
                ssid=router_ssid,
                is_hidden=hide_ssid,
                expect_failure=not expect_connect)
            wifi_context.assert_connect_wifi(client_conf, test_description)
        finally:
            if router_ssid:
                wifi_context.client.shill.delete_entries_for_ssid(router_ssid)
            wifi_context.capture_host.stop_capture()
    def run_once(self):
        """Test body.

        Powersave mode takes advantage of DTIM intervals, and so the two
        are intimately tied.  See network_WiFi_DTIMPeriod for a discussion
        of their interaction.

        """
        dtim_val = 5
        configuration = hostap_config.HostapConfig(
            frequency=2437,
            mode=hostap_config.HostapConfig.MODE_11G,
            dtim_period=dtim_val)
        self.context.configure(configuration)
        self.check_powersave(False)
        assoc_params = xmlrpc_datatypes.AssociationParameters()
        assoc_params.ssid = self.context.router.get_ssid()
        self.context.client.powersave_switch(True)
        self.check_powersave(True)
        self.context.assert_connect_wifi(assoc_params)
        self.context.assert_ping_from_dut()
        self.context.assert_ping_from_server()
        self.context.client.shill.disconnect(assoc_params.ssid)
        self.context.client.powersave_switch(False)
        self.check_powersave(False)
        self.context.router.deconfig()
예제 #9
0
 def run_once(self):
     """Test body."""
     wpa_config = xmlrpc_security_types.WPAConfig(
             psk='chromeos',
             wpa_mode=xmlrpc_security_types.WPAConfig.MODE_MIXED_WPA,
             wpa_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_TKIP,
                          xmlrpc_security_types.WPAConfig.CIPHER_CCMP],
             wpa2_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_CCMP],
             wpa_ptk_rekey_period=self.REKEY_PERIOD)
     ap_config = hostap_config.HostapConfig(
                 frequency=2412,
                 mode=hostap_config.HostapConfig.MODE_11N_PURE,
                 security_config=wpa_config)
     # TODO(wiley) This is just until we find the source of these
     #             test failures.
     self.context.router.start_capture(ap_config.frequency)
     self.context.configure(ap_config)
     assoc_params = xmlrpc_datatypes.AssociationParameters(
             ssid=self.context.router.get_ssid(),
             security_config=wpa_config)
     self.context.assert_connect_wifi(assoc_params)
     ping_config = ping_runner.PingConfig(self.context.get_wifi_addr(),
                                          count=self.PING_COUNT,
                                          interval=self.PING_INTERVAL)
     logging.info('Pinging DUT for %d seconds and rekeying '
                  'every %d seconds.',
                  self.PING_COUNT * self.PING_INTERVAL,
                  self.REKEY_PERIOD)
     self.context.assert_ping_from_dut(ping_config=ping_config)
     self.context.client.shill.disconnect(assoc_params.ssid)
     self.context.router.deconfig()
예제 #10
0
 def run_once(self):
     """Test body."""
     ap_config = hostap_config.HostapConfig(channel=1)
     # Set up the router and associate the client with it.
     self.context.configure(ap_config)
     self.context.router.start_capture(
         ap_config.frequency,
         ht_type=ap_config.ht_packet_capture_mode,
         snaplen=packet_capturer.SNAPLEN_WIFI_PROBE_REQUEST)
     assoc_params = xmlrpc_datatypes.AssociationParameters(
         ssid=self.context.router.get_ssid())
     self.context.assert_connect_wifi(assoc_params)
     results = self.context.router.stop_capture()
     if len(results) != 1:
         raise error.TestError('Expected to generate one packet '
                               'capture but got %d instead.' % len(results))
     probe_ssids = tcpdump_analyzer.get_probe_ssids(
         results[0].local_pcap_path,
         probe_sender=self.context.client.wifi_mac)
     expected_ssids = frozenset([self.BROADCAST_SSID])
     permitted_ssids = (expected_ssids
                        | frozenset([self.context.router.get_ssid()]))
     # Verify expected ssids are contained in the probe result
     if expected_ssids - probe_ssids:
         raise error.TestError('Expected SSIDs %s, but got %s' %
                               (expected_ssids, probe_ssids))
     # Verify probe result does not contain any unpermitted ssids
     if probe_ssids - permitted_ssids:
         raise error.TestError('Permitted SSIDs %s, but got %s' %
                               (permitted_ssids, probe_ssids))
예제 #11
0
    def configure_connect_verify_deconfig_wait(self, ssid, freq, mode, bssid):
        """Configure an AP, connect to it, then tear it all down, again.

        This method does the following: configures the AP, connects to it and
        verifies the connection, deconfigures the AP and waits for the
        disconnect to complete.

        @param ssid string SSID for the new connection.
        @param freq int Frequency which the AP is to support.
        @param mode string AP mode from hostap_config.HostapConfig.MODE_*.
        @param bssid string BSSID for the new connection.

        """
        # Change channels on the AP.  This happens in full view of the DUT
        # and the AP deauths everyone as it exits.
        ap_config = hostap_config.HostapConfig(ssid=ssid,
                                               frequency=freq,
                                               mode=mode,
                                               bssid=bssid)
        self.context.configure(ap_config)
        assoc_params = xmlrpc_datatypes.AssociationParameters(
            ssid=self.context.router.get_ssid())
        self.context.assert_connect_wifi(assoc_params)

        self.context.assert_ping_from_dut()  # Verify that we're connected.
        self.context.client.check_iw_link_value(
            iw_runner.IW_LINK_KEY_FREQUENCY,
            freq)  # Verify that the client switched to new frequency

        # Deconfig and wait for the DUT to disconnect and end up at 'idle'.
        self.context.router.deconfig()
        success, state, elapsed_seconds = \
                self.context.client.wait_for_service_states(
                        network_WiFi_SSIDSwitchBack.SSID_1, ['idle'], 30)
    def get_association_parameters(self):
        """
        Creates an AssociationParameters from the configured AP.

        @returns AssociationParameters for the configured AP.

        """
        security_config = None
        if self.ap_spec.security in [
                ap_spec.SECURITY_TYPE_WPAPSK, ap_spec.SECURITY_TYPE_WPA2PSK
        ]:
            # Not all of this is required but doing it just in case.
            security_config = xmlrpc_security_types.WPAConfig(
                psk=self.ap_spec.password,
                wpa_mode=xmlrpc_security_types.WPAConfig.MODE_MIXED_WPA,
                wpa_ciphers=[
                    xmlrpc_security_types.WPAConfig.CIPHER_CCMP,
                    xmlrpc_security_types.WPAConfig.CIPHER_TKIP
                ],
                wpa2_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_CCMP])
        return xmlrpc_datatypes.AssociationParameters(
            ssid=self._ssid,
            security_config=security_config,
            discovery_timeout=45,
            association_timeout=30,
            configuration_timeout=30,
            is_hidden=not self.ap_spec.visible)
예제 #13
0
    def run_once(self):
        """Asserts that WiFi bitrates remain low during the association process.

        Low bitrates mean that data transfer is slow, but reliable.  This is
        important since association usually includes some very time dependent
        configuration state machines and no user expectation of high bandwidth.

        """
        caps = [
            hostap_config.HostapConfig.N_CAPABILITY_GREENFIELD,
            hostap_config.HostapConfig.N_CAPABILITY_HT40
        ]
        g_config = hostap_config.HostapConfig(
            channel=6, mode=hostap_config.HostapConfig.MODE_11G)
        n_config = hostap_config.HostapConfig(
            channel=44,
            mode=hostap_config.HostapConfig.MODE_11N_PURE,
            n_capabilities=caps)
        for ap_config in (g_config, n_config):
            self.context.configure(ap_config)
            self.context.capture_host.start_capture(
                ap_config.frequency, ht_type=ap_config.ht_packet_capture_mode)
            assoc_params = xmlrpc_datatypes.AssociationParameters(
                ssid=self.context.router.get_ssid())
            self.context.assert_connect_wifi(assoc_params)
            self.context.assert_ping_from_dut()
            results = self.context.capture_host.stop_capture()
            if len(results) != 1:
                raise error.TestError('Expected to generate one packet '
                                      'capture but got %d captures instead.' %
                                      len(results))
            self.check_bitrates_in_capture(results[0])
            self.context.client.shill.disconnect(assoc_params.ssid)
            self.context.router.deconfig()
    def run_once(self):
        """Test body."""
        # Configure the AP.
        frequency = 2412
        self.context.configure(hostap_config.HostapConfig(frequency=frequency))
        router_ssid = self.context.router.get_ssid()

        # Connect to the AP.
        self.context.assert_connect_wifi(
            xmlrpc_datatypes.AssociationParameters(ssid=router_ssid))

        # Disable the interface only long enough that we're sure we have
        # disconnected.
        interface = self.context.client.wifi_if
        client = self.context.client
        with InterfaceDisableContext(client, interface):
            success, state, elapsed_seconds = client.wait_for_service_states(
                router_ssid, ('idle', ), 3)
            # We should either be in the 'idle' state or not even know about
            # this service state anymore.  The latter is more likely since
            # the AP's service should lose visibility when the device is
            # disabled.
            if not success and state != 'unknown':
                raise error.TestFail(
                    'Failed to disconnect from "%s" after interface was '
                    'disabled for %f seconds (state=%s)' %
                    (router_ssid, elapsed_seconds, state))

        # Expect that the DUT will re-connect to the AP.
        self.context.wait_for_connection(router_ssid, frequency)
        self.context.router.deconfig()
    def run_once(self):
        """Test body."""
        start_time = time.time()
        for ap_config in self._ap_configs:
            # Set up the router and associate the client with it.
            self.context.configure(ap_config)
            if ap_config.is_11ac and not self.context.client.is_vht_supported(
            ):
                raise error.TestNAError('Client does not have AC support')
            assoc_params = xmlrpc_datatypes.AssociationParameters(
                ssid=self.context.router.get_ssid(),
                security_config=ap_config.security_config)
            self.context.assert_connect_wifi(assoc_params)
            session = netperf_session.NetperfSession(self.context.client,
                                                     self.context.router)

            # Flag a test error if we disconnect for any reason.
            with self.context.client.assert_no_disconnects():
                # Conduct the performance tests while toggling powersave mode.
                for power_save in (True, False):
                    self.do_run(ap_config, session, power_save)

            # Clean up router and client state for the next run.
            self.context.client.shill.disconnect(
                self.context.router.get_ssid())
            self.context.router.deconfig()
        end_time = time.time()
        logging.info('Running time %0.1f seconds.', end_time - start_time)
    def run_once(self):
        """DTIM period test.

        DTIM stands for delivery traffic information message and refers to
        the number of beacons between DTIMS.  For instance, a DTIM period
        of 1 would indicate that every beacon should have a DTIM element.
        The default DTIM period value is 2.

        This flag is used in combination with powersave mode as follows:
        1) A client goes into powersave mode and notifies the router.
        2) While in powersave mode, the client turns off as much as possible;
           the AP is supposed to buffer unicast traffic.
        3) The client wakes up to receive beacons, which may include a DTIM
           notification.
        4) On receiving such a notification, the client should
           stay up to recieve the pending frames.

        """
        dtim_val = 5
        configuration = hostap_config.HostapConfig(
                frequency=2437,
                mode=hostap_config.HostapConfig.MODE_11G,
                dtim_period=dtim_val)
        self.context.configure(configuration)
        assoc_params = xmlrpc_datatypes.AssociationParameters()
        assoc_params.ssid = self.context.router.get_ssid()
        self.context.client.powersave_switch(True)
        self.context.assert_connect_wifi(assoc_params)
        self.context.client.check_iw_link_value(
                iw_runner.IW_LINK_KEY_DTIM_PERIOD,
                dtim_val)
        self.context.assert_ping_from_dut()
        self.context.client.shill.disconnect(assoc_params.ssid)
        self.context.client.powersave_switch(False)
        self.context.router.deconfig()
예제 #17
0
    def run_once(self):
        """Test body."""
        start_time = time.time()
        for ap_config in self._ap_configs:
            # Set up the router and associate the client with it.
            self.context.configure(ap_config)
            # self.context.configure has a similar check - but that one only
            # errors out if the AP *requires* VHT i.e. AP is requesting
            # MODE_11AC_PURE and the client does not support it.
            # For wifi_perf, we don't want to run MODE_11AC_MIXED on the AP if
            # the client does not support VHT, as we are guaranteed to get the
            # same results at 802.11n/HT40 in that case.
            if ap_config.is_11ac and not self.context.client.is_vht_supported(
            ):
                raise error.TestNAError('Client does not have AC support')
            assoc_params = xmlrpc_datatypes.AssociationParameters(
                ssid=self.context.router.get_ssid(),
                security_config=ap_config.security_config)
            self.context.assert_connect_wifi(assoc_params)
            session = netperf_session.NetperfSession(self.context.client,
                                                     self.context.router)

            # Flag a test error if we disconnect for any reason.
            with self.context.client.assert_no_disconnects():
                # Conduct the performance tests while toggling powersave mode.
                for power_save in (True, False):
                    for governor in sorted(set([None, self._governor])):
                        self.do_run(ap_config, session, power_save, governor)

            # Clean up router and client state for the next run.
            self.context.client.shill.disconnect(
                self.context.router.get_ssid())
            self.context.router.deconfig()
        end_time = time.time()
        logging.info('Running time %0.1f seconds.', end_time - start_time)
예제 #18
0
    def run_once(self):
        """
        Test that optional DHCP properties are used in DHCP Request packets.

        The test will temporarily set the DHCPProperty.VendorClass and
        DHCPProperty.Hostname DBus properties for the Manager.  The test
        resets the properties to their original values before completion.
        During the test, the DUT should send packets with the optional DHCP
        property settings in DHCP Requests.  If they are not in the packet,
        the test will fail.

        """

        configuration = hostap_config.HostapConfig(frequency=self.FREQUENCY_MHZ)
        self.context.configure(configuration)

        # set hostname and vendorclass for this test
        client = self.context.client
        with client.set_dhcp_property(self.HOSTNAME_PROPERTY, self.HOSTNAME_VALUE):
            with client.set_dhcp_property(self.VENDORCLASS_PROPERTY,
                                          self.VENDORCLASS_VALUE):
                self.context.capture_host.start_capture(
                        configuration.frequency,
                        ht_type=configuration.ht_packet_capture_mode)
                assoc_params = xmlrpc_datatypes.AssociationParameters()
                assoc_params.ssid = self.context.router.get_ssid(instance=0)
                self.context.assert_connect_wifi(assoc_params)
                self.context.assert_ping_from_dut()
                results = self.context.capture_host.stop_capture()
        if len(results) != 1:
          raise error.TestError('Expected to generate one packet '
                                'capture but got %d captures instead.' %
                                len(results))
        self.assert_hostname_and_vendorclass_are_present(results[0])
예제 #19
0
    def run_once(self):
        """Test body."""
        wpa_config = xmlrpc_security_types.WPAConfig(
                psk='chromeos',
                wpa_mode=xmlrpc_security_types.WPAConfig.MODE_MIXED_WPA,
                wpa_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_TKIP,
                             xmlrpc_security_types.WPAConfig.CIPHER_CCMP],
                wpa2_ciphers=[xmlrpc_security_types.WPAConfig.CIPHER_CCMP],
                use_strict_rekey=True,
                wpa_gtk_rekey_period=self.GTK_REKEY_PERIOD,
                wpa_gmk_rekey_period=self.GMK_REKEY_PERIOD)
        ap_config = hostap_config.HostapConfig(
                frequency=2412,
                mode=hostap_config.HostapConfig.MODE_11G,
                security_config=wpa_config)
        client_conf = xmlrpc_datatypes.AssociationParameters(
                security_config=wpa_config)
        self.context.configure(ap_config)
        client_conf.ssid = self.context.router.get_ssid()
        self.context.assert_connect_wifi(client_conf)
        # Sanity check ourselves with some unicast pings.
        self.context.assert_ping_from_dut()
        # Now check that network traffic goes through.
        if (not self.check_client_can_recv_broadcast_traffic() or
                not self.check_client_can_send_broadcast_traffic()):
            raise error.TestFail('Not all arping passes were successful.')

        self.context.client.shill.disconnect(client_conf.ssid)
        self.context.router.deconfig()
예제 #20
0
    def run_once(self, host):
        """Test body."""
        start_time = time.time()

        # Setup Bluetooth widgets and their binder, but do not yet connect.
        audio_test.audio_test_requirement()
        factory = audio_test.create_remote_facade_factory(
            host, self.resultsdir)
        chameleon_board = host.chameleon
        chameleon_board.reset()
        widget_factory = chameleon_audio_helper.AudioWidgetFactory(
            factory, host)
        source = widget_factory.create_widget(
            chameleon_audio_ids.CrosIds.BLUETOOTH_HEADPHONE)
        bluetooth_widget = widget_factory.create_widget(
            chameleon_audio_ids.PeripheralIds.BLUETOOTH_DATA_RX)
        binder = widget_factory.create_binder(source, bluetooth_widget)
        audio_test_file = 'http://commondatastorage.googleapis.com/' \
                          'chromiumos-test-assets-public/audio_test/' \
                          'chameleon/Headphone/test_256_16.mp3'

        for ap_config in self._ap_configs:
            # Set up the router and associate the client with it.
            self.context.configure(ap_config)
            if ap_config.is_11ac and not self.context.client.is_vht_supported(
            ):
                raise error.TestNAError('Client does not have AC support')
            assoc_params = xmlrpc_datatypes.AssociationParameters(
                ssid=self.context.router.get_ssid(),
                security_config=ap_config.security_config)
            self.context.assert_connect_wifi(assoc_params)
            session = netperf_session.NetperfSession(self.context.client,
                                                     self.context.router)
            session.MEASUREMENT_MAX_SAMPLES = 6.

            # Warmup the wifi path and measure signal.
            session.warmup_stations()
            ap_config_tag = ap_config.perf_loggable_description

            for config in self.NETPERF_CONFIGS:
                self.test_one(session, config, ap_config_tag,
                              'BT_disconnected')
                with chameleon_audio_helper.bind_widgets(binder):
                    self.test_one(session, config, ap_config_tag,
                                  'BT_connected_but_not_streaming')
                    logging.info('Playing an audio test file')
                    browser_facade = factory.create_browser_facade()
                    browser_facade.new_tab(audio_test_file)
                    self.test_one(session, config, ap_config_tag,
                                  'BT_streaming_audiofile')
                self.test_one(session, config, ap_config_tag,
                              'BT_disconnected_again')

            # Clean up router and client state for the next run.
            self.context.client.shill.disconnect(
                self.context.router.get_ssid())
            self.context.router.deconfig()

        end_time = time.time()
        logging.info('Running time %0.1f seconds.', end_time - start_time)
예제 #21
0
    def run_once(self):
        """Test body.

        When fragthreshold is set, packets larger than the threshold are
        broken up by the AP and sent in fragments. The DUT needs to reassemble
        these fragments to reconstruct the original packets before processing
        them.

        """

        # Whirlwind routers don't support fragmentation, and older builds
        # (up to 7849.0.2016_01_20_2103) don't know that they don't, so check
        # here using board name.
        if self.context.router.board == "whirlwind":
            raise error.TestNAError(
                'Whirlwind AP does not support frag threshold')

        configuration = hostap_config.HostapConfig(
            frequency=2437,
            mode=hostap_config.HostapConfig.MODE_11G,
            frag_threshold=256)
        self.context.configure(configuration)
        self.context.capture_host.start_capture(configuration.frequency)
        assoc_params = xmlrpc_datatypes.AssociationParameters()
        assoc_params.ssid = self.context.router.get_ssid()
        self.context.assert_connect_wifi(assoc_params)
        build_config = lambda size: ping_runner.PingConfig(
            self.context.client.wifi_ip, size=size)
        self.context.assert_ping_from_server(ping_config=build_config(256))
        self.context.assert_ping_from_server(ping_config=build_config(512))
        self.context.assert_ping_from_server(ping_config=build_config(1024))
        self.context.assert_ping_from_server(ping_config=build_config(1500))
        self.context.client.shill.disconnect(assoc_params.ssid)
        self.context.router.deconfig()
        self.context.capture_host.stop_capture()
예제 #22
0
    def run_once(self):
        """Test body.

        When fragthreshold is set, packets larger than the threshold are
        broken up by the AP and sent in fragments. The DUT needs to reassemble
        these fragments to reconstruct the original packets before processing
        them.

        """
        configuration = hostap_config.HostapConfig(
            frequency=2437,
            mode=hostap_config.HostapConfig.MODE_11G,
            frag_threshold=256)
        self.context.configure(configuration)
        self.context.router.start_capture(configuration.frequency)
        assoc_params = xmlrpc_datatypes.AssociationParameters()
        assoc_params.ssid = self.context.router.get_ssid()
        self.context.assert_connect_wifi(assoc_params)
        build_config = lambda size: ping_runner.PingConfig(
            self.context.client.wifi_ip, size=size)
        self.context.assert_ping_from_server(ping_config=build_config(256))
        self.context.assert_ping_from_server(ping_config=build_config(512))
        self.context.assert_ping_from_server(ping_config=build_config(1024))
        self.context.assert_ping_from_server(ping_config=build_config(1500))
        self.context.client.shill.disconnect(assoc_params.ssid)
        self.context.router.deconfig()
예제 #23
0
    def _verify_phy_attenuator_correspondence(self, instance):
        """Verify that we cannot connect to a phy when it is attenuated.

        Check that putting maximum attenuation on the attenuators expected
        to gate a particular phy produces the expected result.  We should
        be unable to connect to the corresponding SSID.

        @param instance: int hostapd instance to verify corresponds to
                a particular 2 attenuators.

        """
        logging.info('Verifying attenuator correspondence')
        # Turn up all attenuation.
        self.context.attenuator.set_variable_attenuation(
                attenuator_controller.MAX_VARIABLE_ATTENUATION)
        # Turn down attenuation for phys other than the instance we're
        # interested in.
        for other_instance in [x for x in range(self.num_phys)
                                 if x != instance]:
            other_phy_num = self._get_phy_num_for_instance(other_instance)
            for attenuator_offset in range(ATTENUATORS_PER_PHY):
                attenuator_num = (other_phy_num * ATTENUATORS_PER_PHY +
                                  attenuator_offset)
                self.context.attenuator.set_variable_attenuation(
                        0, attenuator_num=attenuator_num)
                # The other SSID should be available.
                self._debug_phy_attenuator_correspondence(
                    self.context.router.get_ssid(instance=other_instance),
                    self.context.router.get_ssid(instance=instance))
        # We should be unable to connect.
        client_conf = xmlrpc_datatypes.AssociationParameters(
                ssid=self.context.router.get_ssid(instance=instance),
                expect_failure=True)
        self.context.assert_connect_wifi(client_conf)
예제 #24
0
    def run_once(self):
        """Test body."""
        logging.info("- Set up AP, connect.")
        self.context.configure(self._router_conf)

        client_conf = xmlrpc_datatypes.AssociationParameters(
            ssid=self.context.router.get_ssid(),
            security_config=self._router_conf.security_config)
        self.context.assert_connect_wifi(client_conf)
        self.context.assert_ping_from_dut()

        # Suspend the DUT then, locally, wait 15 seconds to make sure the
        # DUT is really asleep before we proceed.  Then, deauth the DUT
        # while it sleeps.
        logging.info("- Suspend & deauthenticate during suspend.")
        self.context.client.do_suspend_bg(20)
        time.sleep(15)
        self.context.router.deauth_client(self.context.client.wifi_mac)

        # If the DUT realizes that it has been deauthed, then it should
        # reassociate quickly and the ping below should succeed.
        logging.info("- Verify that we roam back to same network.")
        self.context.wait_for_connection(client_conf.ssid)

        self.context.router.deconfig()
예제 #25
0
def get_positive_8021x_test_cases(outer_auth_type, inner_auth_type):
    """Return a test case asserting that outer/inner auth works.

    @param inner_auth_type one of
            xmlrpc_security_types.Tunneled1xConfig.LAYER1_TYPE*
    @param inner_auth_type one of
            xmlrpc_security_types.Tunneled1xConfig.LAYER2_TYPE*
    @return list of ap_config, association_params tuples for
            network_WiFi_SimpleConnect.

    """
    eap_config = xmlrpc_security_types.Tunneled1xConfig(
            site_eap_certs.ca_cert_1,
            site_eap_certs.server_cert_1,
            site_eap_certs.server_private_key_1,
            site_eap_certs.ca_cert_1,
            'testuser',
            'password',
            inner_protocol=inner_auth_type,
            outer_protocol=outer_auth_type)
    ap_config = hostap_config.HostapConfig(
            frequency=2412,
            mode=hostap_config.HostapConfig.MODE_11G,
            security_config=eap_config)
    assoc_params = xmlrpc_datatypes.AssociationParameters(
            security_config=eap_config)
    return [(ap_config, assoc_params)]
예제 #26
0
    def run_once(self):
        """Test body."""
        ap_config = hostap_config.HostapConfig(channel=1)

        # Start capture before starting anything else.
        self.context.capture_host.start_capture(
            ap_config.frequency,
            ht_type=ap_config.ht_packet_capture_mode,
            snaplen=packet_capturer.SNAPLEN_WIFI_PROBE_REQUEST)

        # We're looking for the MAC address, so disable randomization.
        with self.context.client.mac_address_randomization(False):
            # Set up the router and associate the client with it.
            self.context.configure(ap_config)
            assoc_params = xmlrpc_datatypes.AssociationParameters(
                ssid=self.context.router.get_ssid())

            self.context.assert_connect_wifi(assoc_params)
            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))
        probe_ssids = tcpdump_analyzer.get_probe_ssids(
            results[0].local_pcap_path,
            probe_sender=self.context.client.wifi_mac)
        # We expect a broadcast probe, but it's not guaranteed.
        expected_ssids = frozenset([self.BROADCAST_SSID])
        permitted_ssids = (expected_ssids
                           | frozenset([self.context.router.get_ssid()]))
        # Verify probe result does not contain any unpermitted ssids
        if probe_ssids - permitted_ssids:
            raise error.TestError('Permitted SSIDs %s, but got %s' %
                                  (permitted_ssids, probe_ssids))
예제 #27
0
    def run_once(self):
        """Body of the test."""

        get_assoc_params = lambda conf: xmlrpc_datatypes.AssociationParameters(
            ssid=self.context.router.get_ssid(instance=0), bgscan_config=conf)
        get_ping_config = lambda period: ping_runner.PingConfig(
            self.context.get_wifi_addr(),
            interval=self.PING_INTERVAL_SECONDS,
            count=int(period / self.PING_INTERVAL_SECONDS))
        self.context.configure(self._config_first_ap)
        bgscan_config = xmlrpc_datatypes.BgscanConfiguration(
            short_interval=self.CONFIGURED_BGSCAN_INTERVAL_SECONDS,
            long_interval=self.CONFIGURED_BGSCAN_INTERVAL_SECONDS,
            method=xmlrpc_datatypes.BgscanConfiguration.SCAN_METHOD_SIMPLE)
        self.context.assert_connect_wifi(get_assoc_params(bgscan_config))
        logging.info('Pinging router with background scans for %d seconds.',
                     self.BGSCAN_SAMPLE_PERIOD_SECONDS)
        result_bgscan = self.context.client.ping(
            get_ping_config(self.BGSCAN_SAMPLE_PERIOD_SECONDS))
        logging.info('Ping statistics with bgscan: %r', result_bgscan)
        # Bring up a second AP, make sure that it shows up in bgscans.
        self._config_second_ap.ssid = self.context.router.get_ssid()
        self.context.configure(self._config_second_ap, multi_interface=True)
        logging.info('Without a ping running, ensure that bgscans succeed.')
        ap_mac = self.context.router.get_hostapd_mac(ap_num=1)
        logging.debug('Looking for BSS %s', ap_mac)
        iw = iw_runner.IwRunner(remote_host=self.context.client.host)

        utils.poll_for_condition(
            condition=lambda: self._find_bss_matching_mac_addr(iw, ap_mac),
            exception=error.TestFail(
                'Background scans should detect new BSSes '
                'within an associated ESS.'),
            timeout=self.BGSCAN_SAMPLE_PERIOD_SECONDS,
            sleep_interval=1)

        self.context.router.deconfig_aps(instance=1)
        self.context.client.shill.disconnect(
            self.context.router.get_ssid(instance=0))
        # Reconfigure AP, so the new bgscan setting can be correctly applied.
        self.context.configure(self._config_first_ap)
        # Gather some statistics about ping latencies without scanning going on.
        self.context.assert_connect_wifi(get_assoc_params(None))
        logging.info('Pinging router without background scans for %d seconds.',
                     self.NO_BGSCAN_SAMPLE_PERIOD_SECONDS)
        result_no_bgscan = self.context.client.ping(
            get_ping_config(self.NO_BGSCAN_SAMPLE_PERIOD_SECONDS))
        logging.info('Ping statistics without bgscan: %r', result_no_bgscan)
        if result_no_bgscan.max_latency > self.THRESHOLD_BASELINE_LATENCY_MS:
            raise error.TestFail('RTT latency is too high even without '
                                 'background scans: %f' %
                                 result_no_bgscan.max_latency)

        if (result_bgscan.max_latency >
                self.LATENCY_MARGIN_MS + result_no_bgscan.avg_latency):
            raise error.TestFail(
                'Significant difference in rtt due to bgscan: '
                '%.1f > %.1f + %d' %
                (result_bgscan.max_latency, result_no_bgscan.avg_latency,
                 self.LATENCY_MARGIN_MS))
 def run_once(self):
     """Test body."""
     ap_configs = [
         hostap_config.HostapConfig(
             ssid='a visible network',
             frequency=2437,
             mode=hostap_config.HostapConfig.MODE_11G),
         hostap_config.HostapConfig(
             hide_ssid=True,
             ssid='a hidden network',
             frequency=2437,
             mode=hostap_config.HostapConfig.MODE_11G)
     ]
     for ap_config in ap_configs:
         self.context.configure(ap_config)
         client_config = xmlrpc_datatypes.AssociationParameters(
             ssid=self.context.router.get_ssid(),
             is_hidden=ap_config.hide_ssid)
         self.context.assert_connect_wifi(client_config)
         self.context.assert_ping_from_dut()
         # Check that shill's opinion of our hidden-ness is correct.
         self.check_hidden(self.context.router.get_ssid(),
                           ap_config.hide_ssid is True)
         self.context.client.shill.disconnect(
             self.context.router.get_ssid())
 def run_once(self):
     """Test body."""
     ap_config = hostap_config.HostapConfig(channel=1, hide_ssid=True)
     # 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=packet_capturer.SNAPLEN_WIFI_PROBE_REQUEST)
     test_ssid = self.context.router.get_ssid()
     assoc_params = xmlrpc_datatypes.AssociationParameters(ssid=test_ssid,
                                                           is_hidden=True)
     self.context.assert_connect_wifi(assoc_params)
     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))
     probe_ssids = tcpdump_analyzer.get_probe_ssids(
         results[0].local_pcap_path,
         probe_sender=self.context.client.wifi_mac)
     if len(probe_ssids) != 2:
         raise error.TestError('Expected exactly two SSIDs, but got %s' %
                               probe_ssids)
     if probe_ssids - {self.BROADCAST_SSID, test_ssid}:
         raise error.TestError('Unexpected probe SSIDs: %s' % probe_ssids)
예제 #30
0
 def run_once(self):
     """Test body."""
     get_client_config = lambda ssid, ap_config: \
             xmlrpc_datatypes.AssociationParameters(
                     ssid=ssid,
                     security_config=ap_config.security_config)
     self.context.configure(self._ap_config0)
     self.context.configure(self._ap_config1, multi_interface=True)
     self.context.assert_connect_wifi(
         get_client_config(self.context.router.get_ssid(instance=0),
                           self._ap_config0))
     self.context.assert_connect_wifi(
         get_client_config(self.context.router.get_ssid(instance=1),
                           self._ap_config1))
     self.context.client.do_suspend_bg(self.SUSPEND_TIME_SECONDS + 5)
     logging.info('Waiting %d seconds for DUT to be fully suspended.',
                  self.SUSPEND_TIME_SECONDS)
     time.sleep(self.SUSPEND_TIME_SECONDS)
     logging.info('Tearing down the most recently connected AP.')
     self.context.router.deconfig_aps(instance=1)
     logging.info('Expect that we connect to our previous connected AP '
                  'on resume.')
     self.context.wait_for_connection(
         self.context.router.get_ssid(instance=0),
         self._ap_config0.frequency)