1 # Copyright (c) 2013 The Chromium OS Authors. All rights reserved. 2 # Use of this source code is governed by a BSD-style license that can be 3 # found in the LICENSE file. 4 5 from autotest_lib.client.common_lib import error 6 from autotest_lib.client.common_lib.cros.network import iw_runner 7 from autotest_lib.client.common_lib.cros.network import xmlrpc_datatypes 8 from autotest_lib.server.cros.network import hostap_config 9 from autotest_lib.server.cros.network import wifi_cell_test_base 10 11 class network_WiFi_ChannelHop(wifi_cell_test_base.WiFiCellTestBase): 12 """Tests roaming when an AP changes channels on an SSID.""" 13 14 version = 1 15 ORIGINAL_FREQUENCY = 2412 16 ORIGINAL_BSSID = "00:01:02:03:04:05" 17 TEST_SSID="HowHeGotInMyPajamasIllNeverKnow" 18 19 def run_once(self): 20 """Test body.""" 21 freq = network_WiFi_ChannelHop.ORIGINAL_FREQUENCY 22 ap_config = hostap_config.HostapConfig( 23 ssid=network_WiFi_ChannelHop.TEST_SSID, 24 frequency=freq, 25 mode=hostap_config.HostapConfig.MODE_11B, 26 bssid=network_WiFi_ChannelHop.ORIGINAL_BSSID) 27 self.context.configure(ap_config) 28 assoc_params = xmlrpc_datatypes.AssociationParameters( 29 ssid=self.context.router.get_ssid()) 30 self.context.assert_connect_wifi(assoc_params) 31 32 self.context.assert_ping_from_dut() 33 self.context.client.check_iw_link_value( 34 iw_runner.IW_LINK_KEY_FREQUENCY, 35 freq) 36 self.context.router.deconfig() 37 38 # This checks both channel jumping on the same BSSID and channel 39 # jumping between BSSIDs, all inside the same SSID. 40 for freq, bssid in ((2437, network_WiFi_ChannelHop.ORIGINAL_BSSID), 41 (2462, network_WiFi_ChannelHop.ORIGINAL_BSSID), 42 (2422, "06:07:08:09:0a:0b"), 43 (2447, "0c:0d:0e:0f:10:11")): 44 # Wait for the disconnect to happen. 45 success, state, elapsed_seconds = \ 46 self.context.client.wait_for_service_states( 47 network_WiFi_ChannelHop.TEST_SSID, 48 ['idle'], 30) 49 50 # Change channels on the AP. This happens in full view of the DUT 51 # and the AP deauths everyone as it exits. 52 ap_config = hostap_config.HostapConfig( 53 ssid=network_WiFi_ChannelHop.TEST_SSID, 54 frequency=freq, 55 mode=hostap_config.HostapConfig.MODE_11B, 56 bssid=bssid) 57 self.context.configure(ap_config) 58 59 # Wait for the DUT to scan and acquire the AP at the new 60 # frequency. 61 success, state, elapsed_seconds = \ 62 self.context.client.wait_for_service_states( 63 network_WiFi_ChannelHop.TEST_SSID, 64 ['ready', 'portal', 'online'], 30) 65 if not success: 66 raise error.TestFail( 67 'Failed to connect to "%s" in %f seconds (state=%s)' % 68 (network_WiFi_ChannelHop.TEST_SSID, elapsed_seconds, 69 state)) 70 71 # Verify that we're connected. 72 self.context.assert_ping_from_dut() 73 74 # Verify that the client switched to new frequency 75 self.context.client.check_iw_link_value( 76 iw_runner.IW_LINK_KEY_FREQUENCY, 77 freq) 78 self.context.router.deconfig() 79