diff options
author | jerry <jerrypcchen@google.com> | 2019-05-08 03:08:46 -0700 |
---|---|---|
committer | Tina Lu <lutina@google.com> | 2019-06-28 09:42:45 +0000 |
commit | fabf324026c1445e308f4eb1a6fde78bdb57fe7d (patch) | |
tree | 8db035d114d32f0d150a6e1d07fb5edddd1cbfd6 | |
parent | 65b69a8ebf59fe86a840dc53e8301f5352f56076 (diff) | |
download | platform_tools_test_connectivity-fabf324026c1445e308f4eb1a6fde78bdb57fe7d.tar.gz platform_tools_test_connectivity-fabf324026c1445e308f4eb1a6fde78bdb57fe7d.tar.bz2 platform_tools_test_connectivity-fabf324026c1445e308f4eb1a6fde78bdb57fe7d.zip |
Add bandwidth to capture VHT channel am: b48d4600ca am: 7a8d8dd596
am: 2faf2af985
Bug: 130260093
Change-Id: I456d838a743f2db781b8b25f5dda6aae8e11bb0e
Merge In: 59d96b32983af307dbd298d41a90c4656485951b
-rwxr-xr-x | acts/framework/acts/controllers/ap_lib/hostapd_constants.py | 9 | ||||
-rwxr-xr-x | acts/framework/acts/controllers/packet_capture.py | 30 |
2 files changed, 33 insertions, 6 deletions
diff --git a/acts/framework/acts/controllers/ap_lib/hostapd_constants.py b/acts/framework/acts/controllers/ap_lib/hostapd_constants.py index a5e3b2dcc0..f453250f77 100755 --- a/acts/framework/acts/controllers/ap_lib/hostapd_constants.py +++ b/acts/framework/acts/controllers/ap_lib/hostapd_constants.py @@ -22,7 +22,7 @@ WEP = 0 WPA1 = 1 WPA2 = 2 MIXED = 3 -ENT = 4 # get the correct constant +ENT = 4 # get the correct constant MAX_WPA_PSK_LENGTH = 64 MIN_WPA_PSK_LENGTH = 8 WPA_STRICT_REKEY = 1 @@ -117,6 +117,7 @@ CHANNEL_MAP = { 5805: 161, 5825: 165 } +FREQUENCY_MAP = {v: k for k, v in CHANNEL_MAP.items()} MODE_11A = 'a' MODE_11B = 'b' @@ -225,6 +226,12 @@ VHT_CHANNEL_WIDTH_80 = 1 VHT_CHANNEL_WIDTH_160 = 2 VHT_CHANNEL_WIDTH_80_80 = 3 +VHT_CHANNEL = { + 40: VHT_CHANNEL_WIDTH_40, + 80: VHT_CHANNEL_WIDTH_80, + 160: VHT_CHANNEL_WIDTH_160 +} + # This is a loose merging of the rules for US and EU regulatory # domains as taken from IEEE Std 802.11-2012 Appendix E. For instance, # we tolerate HT40 in channels 149-161 (not allowed in EU), but also diff --git a/acts/framework/acts/controllers/packet_capture.py b/acts/framework/acts/controllers/packet_capture.py index d1085f63c8..828c2fe5a1 100755 --- a/acts/framework/acts/controllers/packet_capture.py +++ b/acts/framework/acts/controllers/packet_capture.py @@ -17,11 +17,16 @@ from acts import logger from acts.controllers.ap_lib.hostapd_constants import AP_DEFAULT_CHANNEL_2G from acts.controllers.ap_lib.hostapd_constants import AP_DEFAULT_CHANNEL_5G +from acts.controllers.ap_lib.hostapd_constants import CHANNEL_MAP +from acts.controllers.ap_lib.hostapd_constants import FREQUENCY_MAP +from acts.controllers.ap_lib.hostapd_constants import CENTER_CHANNEL_MAP +from acts.controllers.ap_lib.hostapd_constants import VHT_CHANNEL from acts.controllers.utils_lib.ssh import connection from acts.controllers.utils_lib.ssh import formatter from acts.controllers.utils_lib.ssh import settings from acts.libs.logging import log_stream from acts.libs.proc.process import Process +from acts import asserts import logging import os @@ -37,7 +42,7 @@ FREQUENCY = 'frequency' LEVEL = 'level' MON_2G = 'mon0' MON_5G = 'mon1' -BAND_IFACE = {'2G' : MON_2G, '5G': MON_5G} +BAND_IFACE = {'2G': MON_2G, '5G': MON_5G} SCAN_IFACE = 'wlan2' SCAN_TIMEOUT = 60 SEP = ':' @@ -188,28 +193,43 @@ class PacketCapture(object): for network in found_networks: if network[SSID] == ssid: return True - time.sleep(3) # sleep before next scan + time.sleep(3) # sleep before next scan return False - def configure_monitor_mode(self, band, channel): + def configure_monitor_mode(self, band, channel, bandwidth=20): """Configure monitor mode. Args: band: band to configure monitor mode for. channel: channel to set for the interface. + bandwidth : bandwidth for VHT channel as 40,80,160 Returns: True if configure successful. False if not successful. """ + band = band.upper() if band not in BAND_IFACE: self.log.error('Invalid band. Must be 2g/2G or 5g/5G') return False iface = BAND_IFACE[band] - self.ssh.run('iw dev %s set channel %s' % - (iface, channel), ignore_status=True) + if bandwidth == 20: + self.ssh.run('iw dev %s set channel %s' % + (iface, channel), ignore_status=True) + else: + center_freq = None + for i, j in CENTER_CHANNEL_MAP[VHT_CHANNEL[bandwidth]]["channels"]: + if channel in range(i, j + 1): + center_freq = (FREQUENCY_MAP[i] + FREQUENCY_MAP[j]) / 2 + break + asserts.assert_true(center_freq, + "No match channel in VHT channel list.") + self.ssh.run('iw dev %s set freq %s %s %s' % + (iface, FREQUENCY_MAP[channel], + bandwidth, center_freq), ignore_status=True) + result = self.ssh.run('iw dev %s info' % iface, ignore_status=True) if result.stderr or 'channel %s' % channel not in result.stdout: self.log.error("Failed to configure monitor mode for %s" % band) |