1# Copyright 2019 - The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15from acts import utils 16 17from acts.controllers.ap_lib import hostapd_config 18from acts.controllers.ap_lib import hostapd_constants 19from acts.controllers.ap_lib import hostapd_utils 20 21 22def asus_rtac66u(iface_wlan_2g=None, 23 iface_wlan_5g=None, 24 channel=None, 25 security=None, 26 ssid=None): 27 # TODO(b/143104825): Permit RIFS once it is supported 28 # TODO(b/144446076): Address non-whirlwind hardware capabilities. 29 """A simulated implementation of an Asus RTAC66U AP. 30 Args: 31 iface_wlan_2g: The 2.4Ghz interface of the test AP. 32 iface_wlan_5g: The 5Ghz interface of the test AP. 33 channel: What channel to use. 34 security: A security profile. Must be none or WPA2 as this is what is 35 supported by the RTAC66U. 36 ssid: Network name 37 Returns: 38 A hostapd config 39 Differences from real RTAC66U: 40 2.4 GHz: 41 Rates: 42 RTAC66U: 43 Supported: 1, 2, 5.5, 11, 18, 24, 36, 54 44 Extended: 6, 9, 12, 48 45 Simulated: 46 Supported: 1, 2, 5.5, 11, 6, 9, 12, 18 47 Extended: 24, 36, 48, 54 48 HT Capab: 49 Info 50 RTAC66U: Green Field supported 51 Simulated: Green Field not supported on Whirlwind. 52 5GHz: 53 VHT Capab: 54 RTAC66U: 55 SU Beamformer Supported, 56 SU Beamformee Supported, 57 Beamformee STS Capability: 3, 58 Number of Sounding Dimensions: 3, 59 VHT Link Adaptation: Both 60 Simulated: 61 Above are not supported on Whirlwind. 62 VHT Operation Info: 63 RTAC66U: Basic MCS Map (0x0000) 64 Simulated: Basic MCS Map (0xfffc) 65 VHT Tx Power Envelope: 66 RTAC66U: Local Max Tx Pwr Constraint: 1.0 dBm 67 Simulated: Local Max Tx Pwr Constraint: 23.0 dBm 68 Both: 69 HT Capab: 70 A-MPDU 71 RTAC66U: MPDU Density 4 72 Simulated: MPDU Density 8 73 HT Info: 74 RTAC66U: RIFS Permitted 75 Simulated: RIFS Prohibited 76 """ 77 # Verify interface and security 78 hostapd_utils.verify_interface(iface_wlan_2g, 79 hostapd_constants.INTERFACE_2G_LIST) 80 hostapd_utils.verify_interface(iface_wlan_5g, 81 hostapd_constants.INTERFACE_5G_LIST) 82 hostapd_utils.verify_security_mode(security, 83 [None, hostapd_constants.WPA2]) 84 if security: 85 hostapd_utils.verify_cipher(security, 86 [hostapd_constants.WPA2_DEFAULT_CIPER]) 87 88 # Common Parameters 89 rates = hostapd_constants.CCK_AND_OFDM_DATA_RATES 90 vht_channel_width = 20 91 n_capabilities = [ 92 hostapd_constants.N_CAPABILITY_LDPC, 93 hostapd_constants.N_CAPABILITY_TX_STBC, 94 hostapd_constants.N_CAPABILITY_RX_STBC1, 95 hostapd_constants.N_CAPABILITY_MAX_AMSDU_7935, 96 hostapd_constants.N_CAPABILITY_DSSS_CCK_40, 97 hostapd_constants.N_CAPABILITY_SGI20 98 ] 99 # WPS IE 100 # Broadcom IE 101 vendor_elements = { 102 'vendor_elements': 103 'dd310050f204104a00011010440001021047001093689729d373c26cb1563c6c570f33' 104 'd7103c0001031049000600372a000120' 105 'dd090010180200001c0000' 106 } 107 108 # 2.4GHz 109 if channel <= 11: 110 interface = iface_wlan_2g 111 rates.update(hostapd_constants.CCK_AND_OFDM_BASIC_RATES) 112 mode = hostapd_constants.MODE_11N_MIXED 113 ac_capabilities = None 114 115 # 5GHz 116 else: 117 interface = iface_wlan_5g 118 rates.update(hostapd_constants.OFDM_ONLY_BASIC_RATES) 119 mode = hostapd_constants.MODE_11AC_MIXED 120 ac_capabilities = [ 121 hostapd_constants.AC_CAPABILITY_RXLDPC, 122 hostapd_constants.AC_CAPABILITY_SHORT_GI_80, 123 hostapd_constants.AC_CAPABILITY_TX_STBC_2BY1, 124 hostapd_constants.AC_CAPABILITY_RX_STBC_1, 125 hostapd_constants.AC_CAPABILITY_MAX_MPDU_11454, 126 hostapd_constants.AC_CAPABILITY_MAX_A_MPDU_LEN_EXP7 127 ] 128 129 additional_params = utils.merge_dicts(rates, vendor_elements, 130 hostapd_constants.UAPSD_ENABLED) 131 132 config = hostapd_config.HostapdConfig( 133 ssid=ssid, 134 channel=channel, 135 hidden=False, 136 security=security, 137 interface=interface, 138 mode=mode, 139 force_wmm=True, 140 beacon_interval=100, 141 dtim_period=3, 142 short_preamble=False, 143 n_capabilities=n_capabilities, 144 ac_capabilities=ac_capabilities, 145 vht_channel_width=vht_channel_width, 146 additional_parameters=additional_params) 147 148 return config 149 150 151def asus_rtac86u(iface_wlan_2g=None, 152 iface_wlan_5g=None, 153 channel=None, 154 security=None, 155 ssid=None): 156 """A simulated implementation of an Asus RTAC86U AP. 157 Args: 158 iface_wlan_2g: The 2.4Ghz interface of the test AP. 159 iface_wlan_5g: The 5Ghz interface of the test AP. 160 channel: What channel to use. 161 security: A security profile. Must be none or WPA2 as this is what is 162 supported by the RTAC86U. 163 ssid: Network name 164 Returns: 165 A hostapd config 166 Differences from real RTAC86U: 167 2.4GHz: 168 Rates: 169 RTAC86U: 170 Supported: 1, 2, 5.5, 11, 18, 24, 36, 54 171 Extended: 6, 9, 12, 48 172 Simulated: 173 Supported: 1, 2, 5.5, 11, 6, 9, 12, 18 174 Extended: 24, 36, 48, 54 175 5GHz: 176 Country Code: 177 Simulated: Has two country code IEs, one that matches 178 the actual, and another explicit IE that was required for 179 hostapd's 802.11d to work. 180 Both: 181 RSN Capabilities (w/ WPA2): 182 RTAC86U: 183 RSN PTKSA Replay Counter Capab: 16 184 Simulated: 185 RSN PTKSA Replay Counter Capab: 1 186 """ 187 # Verify interface and security 188 hostapd_utils.verify_interface(iface_wlan_2g, 189 hostapd_constants.INTERFACE_2G_LIST) 190 hostapd_utils.verify_interface(iface_wlan_5g, 191 hostapd_constants.INTERFACE_5G_LIST) 192 hostapd_utils.verify_security_mode(security, 193 [None, hostapd_constants.WPA2]) 194 if security: 195 hostapd_utils.verify_cipher(security, 196 [hostapd_constants.WPA2_DEFAULT_CIPER]) 197 198 # Common Parameters 199 rates = hostapd_constants.CCK_AND_OFDM_DATA_RATES 200 qbss = {'bss_load_update_period': 50, 'chan_util_avg_period': 600} 201 202 # 2.4GHz 203 if channel <= 11: 204 interface = iface_wlan_2g 205 mode = hostapd_constants.MODE_11G 206 rates.update(hostapd_constants.CCK_AND_OFDM_BASIC_RATES) 207 spectrum_mgmt = False 208 # Measurement Pilot Transmission IE 209 vendor_elements = {'vendor_elements': '42020000'} 210 211 # 5GHz 212 else: 213 interface = iface_wlan_5g 214 mode = hostapd_constants.MODE_11A 215 rates.update(hostapd_constants.OFDM_ONLY_BASIC_RATES) 216 spectrum_mgmt = True, 217 # Country Information IE (w/ individual channel info) 218 # TPC Report Transmit Power IE 219 # Measurement Pilot Transmission IE 220 vendor_elements = { 221 'vendor_elements': 222 '074255532024011e28011e2c011e30011e34011e38011e3c011e40011e64011e' 223 '68011e6c011e70011e74011e84011e88011e8c011e95011e99011e9d011ea1011e' 224 'a5011e' 225 '23021300' 226 '42020000' 227 } 228 229 additional_params = utils.merge_dicts(rates, qbss, vendor_elements) 230 231 config = hostapd_config.HostapdConfig( 232 ssid=ssid, 233 channel=channel, 234 hidden=False, 235 security=security, 236 interface=interface, 237 mode=mode, 238 force_wmm=False, 239 beacon_interval=100, 240 dtim_period=3, 241 short_preamble=False, 242 spectrum_mgmt_required=spectrum_mgmt, 243 additional_parameters=additional_params) 244 return config 245 246 247def asus_rtac5300(iface_wlan_2g=None, 248 iface_wlan_5g=None, 249 channel=None, 250 security=None, 251 ssid=None): 252 # TODO(b/143104825): Permit RIFS once it is supported 253 # TODO(b/144446076): Address non-whirlwind hardware capabilities. 254 """A simulated implementation of an Asus RTAC5300 AP. 255 Args: 256 iface_wlan_2g: The 2.4Ghz interface of the test AP. 257 iface_wlan_5g: The 5Ghz interface of the test AP. 258 channel: What channel to use. 259 security: A security profile. Must be none or WPA2 as this is what is 260 supported by the RTAC5300. 261 ssid: Network name 262 Returns: 263 A hostapd config 264 Differences from real RTAC5300: 265 2.4GHz: 266 Rates: 267 RTAC86U: 268 Supported: 1, 2, 5.5, 11, 18, 24, 36, 54 269 Extended: 6, 9, 12, 48 270 Simulated: 271 Supported: 1, 2, 5.5, 11, 6, 9, 12, 18 272 Extended: 24, 36, 48, 54 273 5GHz: 274 VHT Capab: 275 RTAC5300: 276 SU Beamformer Supported, 277 SU Beamformee Supported, 278 Beamformee STS Capability: 4, 279 Number of Sounding Dimensions: 4, 280 MU Beamformer Supported, 281 VHT Link Adaptation: Both 282 Simulated: 283 Above are not supported on Whirlwind. 284 VHT Operation Info: 285 RTAC5300: Basic MCS Map (0x0000) 286 Simulated: Basic MCS Map (0xfffc) 287 VHT Tx Power Envelope: 288 RTAC5300: Local Max Tx Pwr Constraint: 1.0 dBm 289 Simulated: Local Max Tx Pwr Constraint: 23.0 dBm 290 Both: 291 HT Capab: 292 A-MPDU 293 RTAC5300: MPDU Density 4 294 Simulated: MPDU Density 8 295 HT Info: 296 RTAC5300: RIFS Permitted 297 Simulated: RIFS Prohibited 298 """ 299 # Verify interface and security 300 hostapd_utils.verify_interface(iface_wlan_2g, 301 hostapd_constants.INTERFACE_2G_LIST) 302 hostapd_utils.verify_interface(iface_wlan_5g, 303 hostapd_constants.INTERFACE_5G_LIST) 304 hostapd_utils.verify_security_mode(security, 305 [None, hostapd_constants.WPA2]) 306 if security: 307 hostapd_utils.verify_cipher(security, 308 [hostapd_constants.WPA2_DEFAULT_CIPER]) 309 310 # Common Parameters 311 rates = hostapd_constants.CCK_AND_OFDM_DATA_RATES 312 vht_channel_width = 20 313 qbss = {'bss_load_update_period': 50, 'chan_util_avg_period': 600} 314 n_capabilities = [ 315 hostapd_constants.N_CAPABILITY_LDPC, 316 hostapd_constants.N_CAPABILITY_TX_STBC, 317 hostapd_constants.N_CAPABILITY_RX_STBC1, 318 hostapd_constants.N_CAPABILITY_SGI20 319 ] 320 321 # Broadcom IE 322 vendor_elements = {'vendor_elements': 'dd090010180200009c0000'} 323 324 # 2.4GHz 325 if channel <= 11: 326 interface = iface_wlan_2g 327 rates.update(hostapd_constants.CCK_AND_OFDM_BASIC_RATES) 328 mode = hostapd_constants.MODE_11N_MIXED 329 # AsusTek IE 330 # Epigram 2.4GHz IE 331 vendor_elements['vendor_elements'] += 'dd25f832e4010101020100031411b5' \ 332 '2fd437509c30b3d7f5cf5754fb125aed3b8507045aed3b85' \ 333 'dd1e00904c0418bf0cb2798b0faaff0000aaff0000c0050001000000c3020002' 334 ac_capabilities = None 335 336 # 5GHz 337 else: 338 interface = iface_wlan_5g 339 rates.update(hostapd_constants.OFDM_ONLY_BASIC_RATES) 340 mode = hostapd_constants.MODE_11AC_MIXED 341 # Epigram 5GHz IE 342 vendor_elements['vendor_elements'] += 'dd0500904c0410' 343 ac_capabilities = [ 344 hostapd_constants.AC_CAPABILITY_RXLDPC, 345 hostapd_constants.AC_CAPABILITY_SHORT_GI_80, 346 hostapd_constants.AC_CAPABILITY_TX_STBC_2BY1, 347 hostapd_constants.AC_CAPABILITY_RX_STBC_1, 348 hostapd_constants.AC_CAPABILITY_MAX_MPDU_11454, 349 hostapd_constants.AC_CAPABILITY_MAX_A_MPDU_LEN_EXP7 350 ] 351 352 additional_params = utils.merge_dicts(rates, qbss, vendor_elements, 353 hostapd_constants.UAPSD_ENABLED) 354 355 config = hostapd_config.HostapdConfig( 356 ssid=ssid, 357 channel=channel, 358 hidden=False, 359 security=security, 360 interface=interface, 361 mode=mode, 362 force_wmm=True, 363 beacon_interval=100, 364 dtim_period=3, 365 short_preamble=False, 366 n_capabilities=n_capabilities, 367 ac_capabilities=ac_capabilities, 368 vht_channel_width=vht_channel_width, 369 additional_parameters=additional_params) 370 return config 371 372 373def asus_rtn56u(iface_wlan_2g=None, 374 iface_wlan_5g=None, 375 channel=None, 376 security=None, 377 ssid=None): 378 """A simulated implementation of an Asus RTN56U AP. 379 Args: 380 iface_wlan_2g: The 2.4Ghz interface of the test AP. 381 iface_wlan_5g: The 5Ghz interface of the test AP. 382 channel: What channel to use. 383 security: A security profile. Must be none or WPA2 as this is what is 384 supported by the RTN56U. 385 ssid: Network name 386 Returns: 387 A hostapd config 388 Differences from real RTN56U: 389 2.4GHz: 390 Rates: 391 RTN56U: 392 Supported: 1, 2, 5.5, 11, 18, 24, 36, 54 393 Extended: 6, 9, 12, 48 394 Simulated: 395 Supported: 1, 2, 5.5, 11, 6, 9, 12, 18 396 Extended: 24, 36, 48, 54 397 Both: 398 Fixed Parameters: 399 RTN56U: APSD Implemented 400 Simulated: APSD Not Implemented 401 HT Capab: 402 A-MPDU 403 RTN56U: MPDU Density 4 404 Simulated: MPDU Density 8 405 RSN Capabilities (w/ WPA2): 406 RTN56U: 407 RSN PTKSA Replay Counter Capab: 1 408 Simulated: 409 RSN PTKSA Replay Counter Capab: 16 410 """ 411 # Verify interface and security 412 hostapd_utils.verify_interface(iface_wlan_2g, 413 hostapd_constants.INTERFACE_2G_LIST) 414 hostapd_utils.verify_interface(iface_wlan_5g, 415 hostapd_constants.INTERFACE_5G_LIST) 416 hostapd_utils.verify_security_mode(security, 417 [None, hostapd_constants.WPA2]) 418 if security: 419 hostapd_utils.verify_cipher(security, 420 [hostapd_constants.WPA2_DEFAULT_CIPER]) 421 422 # Common Parameters 423 rates = hostapd_constants.CCK_AND_OFDM_DATA_RATES 424 qbss = {'bss_load_update_period': 50, 'chan_util_avg_period': 600} 425 n_capabilities = [ 426 hostapd_constants.N_CAPABILITY_SGI20, 427 hostapd_constants.N_CAPABILITY_SGI40, 428 hostapd_constants.N_CAPABILITY_TX_STBC, 429 hostapd_constants.N_CAPABILITY_RX_STBC1 430 ] 431 432 # 2.4GHz 433 if channel <= 11: 434 interface = iface_wlan_2g 435 rates.update(hostapd_constants.CCK_AND_OFDM_BASIC_RATES) 436 # Ralink Technology IE 437 # US Country Code IE 438 # AP Channel Report IEs (2) 439 # WPS IE 440 vendor_elements = { 441 'vendor_elements': 442 'dd07000c4307000000' 443 '0706555320010b14' 444 '33082001020304050607' 445 '33082105060708090a0b' 446 'dd270050f204104a000110104400010210470010bc329e001dd811b286011c872c' 447 'd33448103c000101' 448 } 449 450 # 5GHz 451 else: 452 interface = iface_wlan_5g 453 rates.update(hostapd_constants.OFDM_ONLY_BASIC_RATES) 454 # Ralink Technology IE 455 # US Country Code IE 456 vendor_elements = { 457 'vendor_elements': 'dd07000c4307000000' 458 '0706555320010b14' 459 } 460 461 additional_params = utils.merge_dicts(rates, vendor_elements, qbss, 462 hostapd_constants.UAPSD_ENABLED) 463 464 config = hostapd_config.HostapdConfig( 465 ssid=ssid, 466 channel=channel, 467 hidden=False, 468 security=security, 469 interface=interface, 470 mode=hostapd_constants.MODE_11N_MIXED, 471 force_wmm=True, 472 beacon_interval=100, 473 dtim_period=1, 474 short_preamble=False, 475 n_capabilities=n_capabilities, 476 additional_parameters=additional_params) 477 478 return config 479 480 481def asus_rtn66u(iface_wlan_2g=None, 482 iface_wlan_5g=None, 483 channel=None, 484 security=None, 485 ssid=None): 486 # TODO(b/143104825): Permit RIFS once it is supported 487 """A simulated implementation of an Asus RTN66U AP. 488 Args: 489 iface_wlan_2g: The 2.4Ghz interface of the test AP. 490 iface_wlan_5g: The 5Ghz interface of the test AP. 491 channel: What channel to use. 492 security: A security profile. Must be none or WPA2 as this is what is 493 supported by the RTN66U. 494 ssid: Network name 495 Returns: 496 A hostapd config 497 Differences from real RTN66U: 498 2.4GHz: 499 Rates: 500 RTN66U: 501 Supported: 1, 2, 5.5, 11, 18, 24, 36, 54 502 Extended: 6, 9, 12, 48 503 Simulated: 504 Supported: 1, 2, 5.5, 11, 6, 9, 12, 18 505 Extended: 24, 36, 48, 54 506 Both: 507 HT Info: 508 RTN66U: RIFS Permitted 509 Simulated: RIFS Prohibited 510 HT Capab: 511 Info: 512 RTN66U: Green Field supported 513 Simulated: Green Field not supported on Whirlwind. 514 A-MPDU 515 RTN66U: MPDU Density 4 516 Simulated: MPDU Density 8 517 """ 518 # Verify interface and security 519 hostapd_utils.verify_interface(iface_wlan_2g, 520 hostapd_constants.INTERFACE_2G_LIST) 521 hostapd_utils.verify_interface(iface_wlan_5g, 522 hostapd_constants.INTERFACE_5G_LIST) 523 hostapd_utils.verify_security_mode(security, 524 [None, hostapd_constants.WPA2]) 525 if security: 526 hostapd_utils.verify_cipher(security, 527 [hostapd_constants.WPA2_DEFAULT_CIPER]) 528 529 # Common Parameters 530 rates = hostapd_constants.CCK_AND_OFDM_DATA_RATES 531 n_capabilities = [ 532 hostapd_constants.N_CAPABILITY_LDPC, 533 hostapd_constants.N_CAPABILITY_SGI20, 534 hostapd_constants.N_CAPABILITY_TX_STBC, 535 hostapd_constants.N_CAPABILITY_RX_STBC1, 536 hostapd_constants.N_CAPABILITY_MAX_AMSDU_7935 537 ] 538 # Broadcom IE 539 vendor_elements = {'vendor_elements': 'dd090010180200001c0000'} 540 541 # 2.4GHz 542 if channel <= 11: 543 interface = iface_wlan_2g 544 rates.update(hostapd_constants.CCK_AND_OFDM_BASIC_RATES) 545 n_capabilities.append(hostapd_constants.N_CAPABILITY_DSSS_CCK_40) 546 547 # 5GHz 548 else: 549 interface = iface_wlan_5g 550 rates.update(hostapd_constants.OFDM_ONLY_BASIC_RATES) 551 552 additional_params = utils.merge_dicts(rates, vendor_elements, 553 hostapd_constants.UAPSD_ENABLED) 554 555 config = hostapd_config.HostapdConfig( 556 ssid=ssid, 557 channel=channel, 558 hidden=False, 559 security=security, 560 interface=interface, 561 mode=hostapd_constants.MODE_11N_MIXED, 562 force_wmm=True, 563 beacon_interval=100, 564 dtim_period=3, 565 short_preamble=False, 566 n_capabilities=n_capabilities, 567 additional_parameters=additional_params) 568 569 return config