test_ap_qosmap.py 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. # QoS Mapping tests
  2. # Copyright (c) 2013, Jouni Malinen <j@w1.fi>
  3. #
  4. # This software may be distributed under the terms of the BSD license.
  5. # See README for more details.
  6. import time
  7. import subprocess
  8. import logging
  9. logger = logging.getLogger()
  10. import hwsim_utils
  11. import hostapd
  12. from wlantest import Wlantest
  13. def check_qos_map(ap, hapd, dev, sta, dscp, tid, ap_tid=None):
  14. if not ap_tid:
  15. ap_tid = tid
  16. bssid = ap['bssid']
  17. wt = Wlantest()
  18. wt.clear_sta_counters(bssid, sta)
  19. hwsim_utils.test_connectivity(dev, hapd, dscp=dscp, config=False)
  20. time.sleep(0.02)
  21. tx = wt.get_tx_tid(bssid, sta, tid)
  22. if tx == 0:
  23. [ tx, rx ] = wt.get_tid_counters(bssid, sta)
  24. logger.info("Expected TX DSCP " + str(dscp) + " with TID " + str(tid) + " but counters: " + str(tx))
  25. raise Exception("No STA->AP data frame using the expected TID")
  26. rx = wt.get_rx_tid(bssid, sta, ap_tid)
  27. if rx == 0:
  28. [ tx, rx ] = wt.get_tid_counters(bssid, sta)
  29. logger.info("Expected RX DSCP " + str(dscp) + " with TID " + str(ap_tid) + " but counters: " + str(rx))
  30. raise Exception("No AP->STA data frame using the expected TID")
  31. def test_ap_qosmap(dev, apdev):
  32. """QoS mapping"""
  33. drv_flags = dev[0].get_driver_status_field("capa.flags")
  34. if int(drv_flags, 0) & 0x40000000 == 0:
  35. return "skip"
  36. ssid = "test-qosmap"
  37. params = { "ssid": ssid }
  38. params['qos_map_set'] = '53,2,22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,55'
  39. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  40. dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
  41. time.sleep(0.1)
  42. addr = dev[0].p2p_interface_addr()
  43. dev[0].request("DATA_TEST_CONFIG 1")
  44. hapd.request("DATA_TEST_CONFIG 1")
  45. check_qos_map(apdev[0], hapd, dev[0], addr, 53, 2)
  46. check_qos_map(apdev[0], hapd, dev[0], addr, 22, 6)
  47. check_qos_map(apdev[0], hapd, dev[0], addr, 8, 0)
  48. check_qos_map(apdev[0], hapd, dev[0], addr, 15, 0)
  49. check_qos_map(apdev[0], hapd, dev[0], addr, 0, 1)
  50. check_qos_map(apdev[0], hapd, dev[0], addr, 7, 1)
  51. check_qos_map(apdev[0], hapd, dev[0], addr, 16, 3)
  52. check_qos_map(apdev[0], hapd, dev[0], addr, 31, 3)
  53. check_qos_map(apdev[0], hapd, dev[0], addr, 32, 4)
  54. check_qos_map(apdev[0], hapd, dev[0], addr, 39, 4)
  55. check_qos_map(apdev[0], hapd, dev[0], addr, 40, 6)
  56. check_qos_map(apdev[0], hapd, dev[0], addr, 47, 6)
  57. check_qos_map(apdev[0], hapd, dev[0], addr, 48, 7)
  58. check_qos_map(apdev[0], hapd, dev[0], addr, 55, 7)
  59. hapd.request("SET_QOS_MAP_SET 22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,55")
  60. hapd.request("SEND_QOS_MAP_CONF " + dev[0].get_status_field("address"))
  61. check_qos_map(apdev[0], hapd, dev[0], addr, 53, 7)
  62. check_qos_map(apdev[0], hapd, dev[0], addr, 22, 6)
  63. check_qos_map(apdev[0], hapd, dev[0], addr, 48, 7)
  64. check_qos_map(apdev[0], hapd, dev[0], addr, 55, 7)
  65. check_qos_map(apdev[0], hapd, dev[0], addr, 56, 56 >> 3)
  66. check_qos_map(apdev[0], hapd, dev[0], addr, 63, 63 >> 3)
  67. dev[0].request("DATA_TEST_CONFIG 0")
  68. hapd.request("DATA_TEST_CONFIG 0")
  69. def test_ap_qosmap_default(dev, apdev):
  70. """QoS mapping with default values"""
  71. ssid = "test-qosmap-default"
  72. params = { "ssid": ssid }
  73. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  74. dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
  75. addr = dev[0].p2p_interface_addr()
  76. dev[0].request("DATA_TEST_CONFIG 1")
  77. hapd.request("DATA_TEST_CONFIG 1")
  78. for dscp in [ 0, 7, 8, 15, 16, 23, 24, 31, 32, 39, 40, 47, 48, 55, 56, 63]:
  79. check_qos_map(apdev[0], hapd, dev[0], addr, dscp, dscp >> 3)
  80. dev[0].request("DATA_TEST_CONFIG 0")
  81. hapd.request("DATA_TEST_CONFIG 0")
  82. def test_ap_qosmap_default_acm(dev, apdev):
  83. """QoS mapping with default values and ACM=1 for VO/VI"""
  84. ssid = "test-qosmap-default"
  85. params = { "ssid": ssid,
  86. "wmm_ac_bk_aifs": "7",
  87. "wmm_ac_bk_cwmin": "4",
  88. "wmm_ac_bk_cwmax": "10",
  89. "wmm_ac_bk_txop_limit": "0",
  90. "wmm_ac_bk_acm": "0",
  91. "wmm_ac_be_aifs": "3",
  92. "wmm_ac_be_cwmin": "4",
  93. "wmm_ac_be_cwmax": "10",
  94. "wmm_ac_be_txop_limit": "0",
  95. "wmm_ac_be_acm": "0",
  96. "wmm_ac_vi_aifs": "2",
  97. "wmm_ac_vi_cwmin": "3",
  98. "wmm_ac_vi_cwmax": "4",
  99. "wmm_ac_vi_txop_limit": "94",
  100. "wmm_ac_vi_acm": "1",
  101. "wmm_ac_vo_aifs": "2",
  102. "wmm_ac_vo_cwmin": "2",
  103. "wmm_ac_vo_cwmax": "2",
  104. "wmm_ac_vo_txop_limit": "47",
  105. "wmm_ac_vo_acm": "1" }
  106. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  107. dev[0].connect(ssid, key_mgmt="NONE", scan_freq="2412")
  108. addr = dev[0].p2p_interface_addr()
  109. dev[0].request("DATA_TEST_CONFIG 1")
  110. hapd.request("DATA_TEST_CONFIG 1")
  111. for dscp in [ 0, 7, 8, 15, 16, 23, 24, 31, 32, 39, 40, 47, 48, 55, 56, 63]:
  112. ap_tid = dscp >> 3
  113. tid = ap_tid
  114. # downgrade VI/VO to BE
  115. if tid in [ 4, 5, 6, 7 ]:
  116. tid = 3
  117. check_qos_map(apdev[0], hapd, dev[0], addr, dscp, tid, ap_tid)
  118. dev[0].request("DATA_TEST_CONFIG 0")
  119. hapd.request("DATA_TEST_CONFIG 0")
  120. def test_ap_qosmap_invalid(dev, apdev):
  121. """QoS mapping ctrl_iface error handling"""
  122. ssid = "test-qosmap"
  123. params = { "ssid": ssid }
  124. hapd = hostapd.add_ap(apdev[0]['ifname'], params)
  125. if "FAIL" not in hapd.request("SEND_QOS_MAP_CONF 00:11:22:33:44:55"):
  126. raise Exception("Unexpected SEND_QOS_MAP_CONF success")
  127. if "FAIL" not in hapd.request("SET_QOS_MAP_SET "):
  128. raise Exception("Unexpected SET_QOS_MAP_SET success")
  129. if "FAIL" not in hapd.request("SET_QOS_MAP_SET 1,2,3"):
  130. raise Exception("Unexpected SET_QOS_MAP_SET success")
  131. if "FAIL" not in hapd.request("SET_QOS_MAP_SET 1,-2,3"):
  132. raise Exception("Unexpected SET_QOS_MAP_SET success")
  133. if "FAIL" not in hapd.request("SET_QOS_MAP_SET 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59"):
  134. raise Exception("Unexpected SET_QOS_MAP_SET success")
  135. if "FAIL" not in hapd.request("SET_QOS_MAP_SET 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21"):
  136. raise Exception("Unexpected SET_QOS_MAP_SET success")
  137. if "FAIL" in hapd.request("SET_QOS_MAP_SET 22,6,8,15,0,7,255,255,16,31,32,39,255,255,40,47,48,55"):
  138. raise Exception("Unexpected SET_QOS_MAP_SET failure")
  139. if "FAIL" not in hapd.request("SEND_QOS_MAP_CONF 00:11:22:33:44:55"):
  140. raise Exception("Unexpected SEND_QOS_MAP_CONF success")
  141. if "FAIL" not in hapd.request("SEND_QOS_MAP_CONF 00:11:22:33:44"):
  142. raise Exception("Unexpected SEND_QOS_MAP_CONF success")