Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,9 @@ if test "x$enable_ip6" = xyes; then
EXTRA_DRIVER_OBJS="ip6address.o ip6flowid.o ip6table.o $EXTRA_DRIVER_OBJS"
EXTRA_TOOL_OBJS="ip6address.o $EXTRA_TOOL_OBJS"
fi
if test "x$enable_wifi" = xyes; then
EXTRA_DRIVER_OBJS="radiotap.o $EXTRA_DRIVER_OBJS"
fi
AC_SUBST(EXTRA_DRIVER_OBJS)
AC_SUBST(EXTRA_TOOL_OBJS)

Expand Down
1 change: 1 addition & 0 deletions elements/userlevel/fromdevice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
# include <features.h>
# include <linux/if_packet.h>
# include <net/ethernet.h>
# include <linux/sockios.h>
#endif

CLICK_DECLS
Expand Down
10 changes: 10 additions & 0 deletions elements/userlevel/rawsocket.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
*/

#include <click/config.h>
#include <sys/types.h>
#include "rawsocket.hh"
#include <click/nameinfo.hh>
#include <click/error.hh>
Expand All @@ -43,6 +44,15 @@

#include "fakepcap.hh"

#if FROMDEVICE_ALLOW_LINUX
# include <sys/socket.h>
# include <net/if.h>
# include <features.h>
# include <linux/if_packet.h>
# include <net/ethernet.h>
# include <linux/sockios.h>
#endif

CLICK_DECLS

RawSocket::RawSocket()
Expand Down
5 changes: 5 additions & 0 deletions elements/userlevel/rawsocket.hh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
#include <click/task.hh>
#include <click/timer.hh>
#include <click/notifier.hh>

#ifdef __linux__
# define FROMDEVICE_ALLOW_LINUX 1
#endif

CLICK_DECLS

/*
Expand Down
2 changes: 1 addition & 1 deletion elements/wifi/athdescdecap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ AthdescDecap::simple_action(Packet *p)
eh->power = desc->xmit_power;
eh->rssi = desc->ack_sig_strength;
eh->rate = ratecode_to_dot11(desc->xmit_rate0);
eh->retries = desc->data_fail_count;
eh->max_tries = desc->data_fail_count;
if (desc->excessive_retries)
eh->flags |= WIFI_EXTRA_TX_FAIL;
}
Expand Down
4 changes: 2 additions & 2 deletions elements/wifi/autoratefallback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ AutoRateFallback::process_feedback(Packet *p_in)

if (used_alt_rate || !success) {
/* step down 1 or 2 rates */
int down = eh->retries / 2;
int down = eh->max_tries / 2;
if (down > 0) {
down--;
}
Expand Down Expand Up @@ -137,7 +137,7 @@ AutoRateFallback::process_feedback(Packet *p_in)
}
nfo->_wentup = false;

if (eh->retries == 0) {
if (eh->max_tries == 0) {
nfo->_successes++;
} else {
nfo->_successes = 0;
Expand Down
83 changes: 58 additions & 25 deletions elements/wifi/bitrate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,34 @@
#include "bitrate.hh"
#include <clicknet/wifi.h>

// MCS data rates (kbps)
static const uint32_t mcs_rate_lookup[16] =
{
6500, 13000, 19500, 26000, 39000, 52000, 58500, 65000,
13000, 26000, 39000, 52000, 78000, 104000, 117000, 130000
};

unsigned
calc_transmit_time(int rate, int length)
{
unsigned t_plcp_header = 96;
if (rate == 2) {
t_plcp_header = 192;
} else if (!is_b_rate(rate)) {
t_plcp_header = 20;
}
return (2 * (t_plcp_header + ((length * 8))))/ rate;
unsigned t_plcp_header = 0;
if (is_b_rate(rate)) {
t_plcp_header = (rate == 2) ? WIFI_PLCP_HEADER_LONG_B : WIFI_PLCP_HEADER_SHORT_B;
} else {
t_plcp_header = WIFI_PLCP_HEADER_A;
}
return (2 * length * 8) / rate + t_plcp_header;
}

unsigned
calc_backoff(int rate, int t)
{
int t_slot = is_b_rate(rate) ? WIFI_SLOT_B : WIFI_SLOT_A;
int cw = WIFI_CW_MIN;

int cw = is_b_rate(rate) ? WIFI_CW_MIN_B : WIFI_CW_MIN;
int cw_max = is_b_rate(rate) ? WIFI_CW_MAX_B : WIFI_CW_MAX;
/* there is backoff, even for the first packet */
for (int x = 0; x < t; x++) {
cw = WIFI_MIN(WIFI_CW_MAX, (cw + 1) * 2);
cw = WIFI_MIN(cw_max, (cw + 1) * 2);
}
return t_slot * cw / 2;
}
Expand All @@ -34,22 +40,12 @@ calc_usecs_wifi_packet_tries(int length, int rate, int try0, int tryN)
if (!rate || !length || try0 > tryN) {
return 99999;
}

/* pg 205 ieee.802.11.pdf */
unsigned t_slot = 20;
unsigned t_ack = 304; // 192 + 14*8/1
unsigned t_difs = 50;
unsigned t_sifs = 10;


if (!is_b_rate(rate)) {
/* with 802.11g, things are at 6 mbit/s */
t_slot = 9;
t_sifs = 9;
t_difs = 28;
t_ack = 30;
unsigned t_ack = WIFI_ACK_A;
unsigned t_sifs = WIFI_SIFS_A;
if (is_b_rate(rate)) {
t_ack = WIFI_ACK_B;
t_sifs = WIFI_SIFS_B;
}

int tt = 0;
for (int x = try0; x <= tryN; x++) {
tt += calc_backoff(rate, x) + calc_transmit_time(rate, length) +
Expand All @@ -64,4 +60,41 @@ calc_usecs_wifi_packet(int length, int rate, int retries)
return calc_usecs_wifi_packet_tries(length, rate, 0, retries);
}

unsigned
calc_transmit_time_ht(int rate, int length)
{
return (1000 * length * 8) / mcs_rate_lookup[rate] + WIFI_PLCP_HEADER_N;
}

unsigned
calc_backoff_ht(int, int t)
{
int cw = WIFI_CW_MIN;
/* there is backoff, even for the first packet */
for (int x = 0; x < t; x++) {
cw = WIFI_MIN(WIFI_CW_MAX, (cw + 1) * 2);
}
return WIFI_SLOT_N * cw / 2;
}

unsigned
calc_usecs_wifi_packet_tries_ht(int length, int rate, int try0, int tryN)
{
if (rate < 0 || !length || try0 > tryN) {
return 99999;
}
int tt = 0;
for (int x = try0; x <= tryN; x++) {
tt += calc_backoff_ht(rate, x) + calc_transmit_time_ht(rate, length) +
WIFI_SIFS_N + WIFI_ACK_N;
}
return tt;
}

unsigned
calc_usecs_wifi_packet_ht(int length, int rate, int retries)
{
return calc_usecs_wifi_packet_tries_ht(length, rate, 0, retries);
}

ELEMENT_PROVIDES(bitrate)
12 changes: 12 additions & 0 deletions elements/wifi/bitrate.hh
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,16 @@ extern unsigned calc_usecs_wifi_packet(int length,

extern unsigned calc_transmit_time(int rate, int length);

extern unsigned calc_usecs_wifi_packet_tries_ht(int length,
int rate,
int try0, int tryN);

extern unsigned calc_backoff_ht(int rate, int t);

extern unsigned calc_usecs_wifi_packet_ht(int length,
int rate, int retries);


extern unsigned calc_transmit_time_ht(int rate, int length);

#endif /* _BITRATE_H_ */
2 changes: 1 addition & 1 deletion elements/wifi/madwifirate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ MadwifiRate::process_feedback(Packet *p_in)

if (success && (!_alt_rate || !used_alt_rate)) {
nfo->_successes++;
nfo->_retries += ceh->retries;
nfo->_retries += (ceh->max_tries - 1);
} else {
nfo->_failures++;
nfo->_retries += 4;
Expand Down
13 changes: 7 additions & 6 deletions elements/wifi/printtxfeedback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,16 @@ PrintTXFeedback::simple_action(Packet *p)
sa << " " << dst;
sa << " flags " << (int) ceh->flags;
sa << " rate " << (int) ceh->rate;
sa << " max_retries " << (int) ceh->max_tries;
sa << " alt_rate " << (int) ceh->rate1;
sa << " alt_retries " << (int) ceh->max_tries1;
sa << " retries " << (int) ceh->retries;
sa << " virt_col " << (int) ceh->virt_col;
sa << " tries " << (int) ceh->max_tries;
sa << " rate1 " << (int) ceh->rate1;
sa << " tries1 " << (int) ceh->max_tries1;
sa << " rate2 " << (int) ceh->rate2;
sa << " tries2 " << (int) ceh->max_tries2;
sa << " rate3 " << (int) ceh->rate3;
sa << " tries3 " << (int) ceh->max_tries3;

click_chatter("%s\n", sa.c_str());


return p;
}

Expand Down
25 changes: 16 additions & 9 deletions elements/wifi/printwifi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -327,22 +327,29 @@ PrintWifi::simple_action(Packet *p)
len = sprintf(sa.reserve(9), "%4d | ", p->length());
sa.adjust_length(len);

if (ceh->rate == 11) {
sa << " 5.5";
if (ceh->flags & WIFI_EXTRA_MCS) {
len = sprintf(sa.reserve(2), "%2d", ceh->rate);
sa.adjust_length(len);
sa << "HT ";
} else {
len = sprintf(sa.reserve(2), "%2d", ceh->rate/2);
sa.adjust_length(len);
if (ceh->rate == 11) {
sa << " 5.5";
} else {
len = sprintf(sa.reserve(2), "%2d", ceh->rate/2);
sa.adjust_length(len);
}
sa << "Mb ";
}
sa << "Mb ";

len = sprintf(sa.reserve(9), "+%2d/", ceh->rssi);
sa.adjust_length(len);
int8_t rssi;
memcpy(&rssi, &ceh->rssi, 1);

len = sprintf(sa.reserve(9), "%2d | ", ceh->silence);
len = sprintf(sa.reserve(9), "%2ddB ", rssi);
sa.adjust_length(len);




switch (wh->i_fc[1] & WIFI_FC1_DIR_MASK) {
case WIFI_FC1_DIR_NODS:
dst = EtherAddress(wh->i_addr1);
Expand Down Expand Up @@ -540,7 +547,7 @@ PrintWifi::simple_action(Packet *p)
sa << " ] ";

if (ceh->flags & WIFI_EXTRA_TX) {
sa << " retries " << (int) ceh->retries;
sa << " tries " << (int) ceh->max_tries;
}

done:
Expand Down
2 changes: 1 addition & 1 deletion elements/wifi/probetxrate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ ProbeTXRate::process_feedback(Packet *p_in) {
EtherAddress dst = EtherAddress(dst_ptr);
struct click_wifi_extra *ceh = WIFI_EXTRA_ANNO(p_in);
bool success = !(ceh->flags & WIFI_EXTRA_TX_FAIL);
int retries = ceh->retries;
int retries = ceh->max_tries;

Timestamp now = Timestamp::now();

Expand Down
Loading