test_ap_vht.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. # Test cases for VHT operations with hostapd
  2. # Copyright (c) 2014, Qualcomm Atheros, Inc.
  3. # Copyright (c) 2013, Intel Corporation
  4. #
  5. # This software may be distributed under the terms of the BSD license.
  6. # See README for more details.
  7. import logging
  8. logger = logging.getLogger()
  9. import subprocess, time
  10. import hwsim_utils
  11. import hostapd
  12. def vht_supported():
  13. cmd = subprocess.Popen(["iw", "reg", "get"], stdout=subprocess.PIPE)
  14. reg = cmd.stdout.read()
  15. if "@ 80)" in reg or "@ 160)" in reg:
  16. return True
  17. return False
  18. def test_ap_vht80(dev, apdev):
  19. """VHT with 80 MHz channel width"""
  20. try:
  21. params = { "ssid": "vht",
  22. "country_code": "FI",
  23. "hw_mode": "a",
  24. "channel": "36",
  25. "ht_capab": "[HT40+]",
  26. "ieee80211n": "1",
  27. "ieee80211ac": "1",
  28. "vht_oper_chwidth": "1",
  29. "vht_oper_centr_freq_seg0_idx": "42" }
  30. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  31. dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
  32. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  33. except Exception, e:
  34. if isinstance(e, Exception) and str(e) == "AP startup failed":
  35. if not vht_supported():
  36. logger.info("80 MHz channel not supported in regulatory information")
  37. return "skip"
  38. raise
  39. finally:
  40. subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
  41. def test_ap_vht80_params(dev, apdev):
  42. """VHT with 80 MHz channel width and number of optional features enabled"""
  43. try:
  44. params = { "ssid": "vht",
  45. "country_code": "FI",
  46. "hw_mode": "a",
  47. "channel": "36",
  48. "ht_capab": "[HT40+][SHORT-GI-40][DSS_CCK-40]",
  49. "ieee80211n": "1",
  50. "ieee80211ac": "1",
  51. "vht_oper_chwidth": "1",
  52. "vht_capab": "[MAX-MPDU-11454][RXLDPC][SHORT-GI-80][TX-STBC-2BY1][RX-STBC-1][MAX-A-MPDU-LEN-EXP0]",
  53. "vht_oper_centr_freq_seg0_idx": "42",
  54. "require_vht": "1" }
  55. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  56. dev[1].connect("vht", key_mgmt="NONE", scan_freq="5180",
  57. disable_vht="1", wait_connect=False)
  58. dev[0].connect("vht", key_mgmt="NONE", scan_freq="5180")
  59. ev = dev[1].wait_event(["CTRL-EVENT-ASSOC-REJECT"])
  60. if ev is None:
  61. raise Exception("Association rejection timed out")
  62. if "status_code=104" not in ev:
  63. raise Exception("Unexpected rejection status code")
  64. dev[1].request("DISCONNECT")
  65. hwsim_utils.test_connectivity(dev[0].ifname, apdev[0]['ifname'])
  66. except Exception, e:
  67. if isinstance(e, Exception) and str(e) == "AP startup failed":
  68. if not vht_supported():
  69. logger.info("80 MHz channel not supported in regulatory information")
  70. return "skip"
  71. raise
  72. finally:
  73. subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
  74. def test_ap_vht_20(devs, apdevs):
  75. dev = devs[0]
  76. ap = apdevs[0]
  77. try:
  78. params = { "ssid": "test-vht20",
  79. "country_code": "DE",
  80. "hw_mode": "a",
  81. "channel": "36",
  82. "ieee80211n": "1",
  83. "ieee80211ac": "1",
  84. "ht_capab": "",
  85. "vht_capab": "",
  86. "vht_oper_chwidth": "0",
  87. "vht_oper_centr_freq_seg0_idx": "0",
  88. "require_vht": "1",
  89. }
  90. hostapd.add_ap(ap['ifname'], params)
  91. dev.connect("test-vht20", scan_freq="5180", key_mgmt="NONE")
  92. hwsim_utils.test_connectivity(dev.ifname, ap['ifname'])
  93. finally:
  94. subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])