-
Notifications
You must be signed in to change notification settings - Fork 83
/
Copy pathautoratefallback.hh
129 lines (94 loc) · 2.57 KB
/
autoratefallback.hh
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#ifndef CLICK_AUTORATEFALLBACK_HH
#define CLICK_AUTORATEFALLBACK_HH
#include <click/element.hh>
#include <click/etheraddress.hh>
#include <click/bighashmap.hh>
#include <click/glue.hh>
CLICK_DECLS
/*
=c
AutoRateFallback([, I<KEYWORDS>])
=s Wifi
ARF wireless bit-rate selection algorithm
=d
AutoRateFallback is based on the algorithm presented in
"WaveLAN-II: A High-Performance Wireless LAN for the
Unliscensed Band" by Ad Kamerman and Leo Monteban
Automatically determine the txrate for a give ethernet address.
=a SetTXRate, FilterTX
*/
class AutoRateFallback : public Element { public:
AutoRateFallback() CLICK_COLD;
~AutoRateFallback() CLICK_COLD;
const char *class_name() const override { return "AutoRateFallback"; }
const char *port_count() const override { return "2/0-2"; }
const char *processing() const override { return "ah/a"; }
const char *flow_code() const override { return "#/#"; }
int configure(Vector<String> &, ErrorHandler *) CLICK_COLD;
bool can_live_reconfigure() const { return true; }
void push (int, Packet *);
Packet *pull(int);
void add_handlers() CLICK_COLD;
static String static_print_stats(Element *e, void *);
String print_rates();
EtherAddress _bcast;
void assign_rate(Packet *);
void process_feedback(Packet *);
int _stepup;
int _stepdown;
bool _debug;
unsigned _offset;
unsigned _packet_size_threshold;
struct DstInfo {
public:
EtherAddress _eth;
Vector<int> _rates;
int _current_index;
int _successes;
int _stepup;
bool _wentup;
DstInfo() {
}
DstInfo(EtherAddress eth) {
_eth = eth;
}
int rate_index(int rate) {
int ndx = 0;
for (int x = 0; x < _rates.size(); x++) {
if (rate == _rates[x]) {
ndx = x;
break;
}
}
return (ndx == _rates.size()) ? -1 : ndx;
}
int pick_rate() {
if (_rates.size() == 0) {
click_chatter("no rates to pick from for %s\n",
_eth.unparse().c_str());
return 2;
}
if (_current_index > 0 && _current_index < _rates.size()) {
return _rates[_current_index];
}
return _rates[0];
}
int pick_alt_rate() {
if (_rates.size() == 0) {
click_chatter("no rates to pick from for %s\n",
_eth.unparse().c_str());
return 2;
}
return _rates[_current_index <= 0 ? 0 : _current_index - 1];
}
};
typedef HashMap<EtherAddress, DstInfo> NeighborTable;
typedef NeighborTable::const_iterator NIter;
NeighborTable _neighbors;
AvailableRates *_rtable;
bool _alt_rate;
bool _active;
bool _adaptive_stepup;
};
CLICK_ENDDECLS
#endif