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