ieee80211_rssadapt.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* $OpenBSD: ieee80211_rssadapt.h,v 1.5 2010/07/17 16:25:09 damien Exp $ */
  2. /* $NetBSD: ieee80211_rssadapt.h,v 1.3 2004/05/06 03:03:20 dyoung Exp $ */
  3. /*-
  4. * Copyright (c) 2003, 2004 David Young. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or
  7. * without modification, are permitted provided that the following
  8. * conditions are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above
  12. * copyright notice, this list of conditions and the following
  13. * disclaimer in the documentation and/or other materials provided
  14. * with the distribution.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY David Young ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  18. * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  19. * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL David
  20. * Young BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  21. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
  22. * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  23. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  24. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  25. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  27. * OF SUCH DAMAGE.
  28. */
  29. #ifndef _NET80211_IEEE80211_RSSADAPT_H_
  30. #define _NET80211_IEEE80211_RSSADAPT_H_
  31. /* Data-rate adaptation loosely based on "Link Adaptation Strategy
  32. * for IEEE 802.11 WLAN via Received Signal Strength Measurement"
  33. * by Javier del Prado Pavon and Sunghyun Choi.
  34. */
  35. /* Buckets for frames 0-128 bytes long, 129-1024, 1025-maximum. */
  36. #define IEEE80211_RSSADAPT_BKTS 3
  37. #define IEEE80211_RSSADAPT_BKT0 128
  38. #define IEEE80211_RSSADAPT_BKTPOWER 3 /* 2**_BKTPOWER */
  39. #define ieee80211_rssadapt_thresh_new \
  40. (ieee80211_rssadapt_thresh_denom - ieee80211_rssadapt_thresh_old)
  41. #define ieee80211_rssadapt_decay_new \
  42. (ieee80211_rssadapt_decay_denom - ieee80211_rssadapt_decay_old)
  43. #define ieee80211_rssadapt_avgrssi_new \
  44. (ieee80211_rssadapt_avgrssi_denom - ieee80211_rssadapt_avgrssi_old)
  45. struct ieee80211_rssadapt_expavgctl {
  46. /* RSS threshold decay. */
  47. u_int rc_decay_denom;
  48. u_int rc_decay_old;
  49. /* RSS threshold update. */
  50. u_int rc_thresh_denom;
  51. u_int rc_thresh_old;
  52. /* RSS average update. */
  53. u_int rc_avgrssi_denom;
  54. u_int rc_avgrssi_old;
  55. };
  56. struct ieee80211_rssadapt {
  57. /* exponential average RSSI << 8 */
  58. u_int16_t ra_avg_rssi;
  59. /* Tx failures in this update interval */
  60. u_int32_t ra_nfail;
  61. /* Tx successes in this update interval */
  62. u_int32_t ra_nok;
  63. /* exponential average packets/second */
  64. u_int32_t ra_pktrate;
  65. /* RSSI threshold for each Tx rate */
  66. u_int16_t ra_rate_thresh[IEEE80211_RSSADAPT_BKTS]
  67. [IEEE80211_RATE_SIZE];
  68. struct timeval ra_last_raise;
  69. struct timeval ra_raise_interval;
  70. };
  71. /* Properties of a Tx packet, for link adaptation. */
  72. struct ieee80211_rssdesc {
  73. u_int id_len; /* Tx packet length */
  74. u_int id_rateidx; /* index into ni->ni_rates */
  75. struct ieee80211_node *id_node; /* destination STA MAC */
  76. u_int8_t id_rssi; /* destination STA avg RSS @
  77. * Tx time
  78. */
  79. };
  80. void ieee80211_rssadapt_updatestats(struct ieee80211_rssadapt *);
  81. void ieee80211_rssadapt_input(struct ieee80211com *,
  82. const struct ieee80211_node *, struct ieee80211_rssadapt *, int);
  83. void ieee80211_rssadapt_lower_rate(struct ieee80211com *,
  84. const struct ieee80211_node *, struct ieee80211_rssadapt *,
  85. const struct ieee80211_rssdesc *);
  86. void ieee80211_rssadapt_raise_rate(struct ieee80211com *,
  87. struct ieee80211_rssadapt *, const struct ieee80211_rssdesc *);
  88. int ieee80211_rssadapt_choose(struct ieee80211_rssadapt *,
  89. const struct ieee80211_rateset *, const struct ieee80211_frame *,
  90. u_int, int, const char *, int);
  91. #ifdef IEEE80211_DEBUG
  92. extern int ieee80211_rssadapt_debug;
  93. #endif /* IEEE80211_DEBUG */
  94. #endif /* _NET80211_IEEE80211_RSSADAPT_H_ */