Commit 0ff85f3a authored by Bruno Randolf's avatar Bruno Randolf

add retry count and reformat main list

parent 57df401c
......@@ -44,9 +44,6 @@ static int win_split;
static int stat_height;
#define STAT_WIDTH 11
/******************* UTIL *******************/
void
......@@ -163,12 +160,15 @@ show_sort_win(void)
/******************* WINDOWS *******************/
#define STAT_WIDTH 11
#define STAT_START 4
static void
update_status_win(struct packet_info* p)
{
int sig, siga, noi, bps, dps, bpsn, usen;
float use;
int max_stat_bar = stat_height - 3;
int sig, siga, noi, bps, dps, pps, rps, bpsn, usen;
float use, rpsp;
int max_stat_bar = stat_height - STAT_START;
struct channel_info* chan = NULL;
if (p != NULL)
......@@ -177,14 +177,16 @@ update_status_win(struct packet_info* p)
wattron(stat_win, WHITE);
mvwvline(stat_win, 0, 0, ACS_VLINE, stat_height);
get_per_second(stats.bytes, stats.duration, &bps, &dps);
get_per_second(stats.bytes, stats.duration, stats.packets, stats.retries,
&bps, &dps, &pps, &rps);
bps *= 8;
bpsn = normalize(bps, 32000000, max_stat_bar); //theoretical: 54000000
use = dps * 1.0 / 10000; /* usec, in percent */
usen = normalize(use, 100, max_stat_bar);
rpsp = rps * 100.0 / pps;
if (p != NULL) {
sig = normalize_db(-p->phy_signal, max_stat_bar);
if (p->phy_noise)
......@@ -209,12 +211,12 @@ update_status_win(struct packet_info* p)
else
mvwprintw(stat_win, 0, 1, "Sig: %5d", p->phy_signal);
signal_average_bar(stat_win, sig, siga, 3, 2, stat_height, 2);
signal_average_bar(stat_win, sig, siga, STAT_START, 2, stat_height, 2);
if (p->phy_noise) {
wattron(stat_win, ALLRED);
mvwvline(stat_win, noi + 3, 2, '=', stat_height - noi);
mvwvline(stat_win, noi + 3, 3, '=', stat_height - noi);
mvwvline(stat_win, noi + STAT_START, 2, '=', stat_height - noi);
mvwvline(stat_win, noi + STAT_START, 3, '=', stat_height - noi);
}
}
......@@ -231,18 +233,21 @@ update_status_win(struct packet_info* p)
mvwvline(stat_win, stat_height - usen, 9, ACS_BLOCK, usen);
wattroff(stat_win, ALLYELLOW);
mvwprintw(stat_win, 3, 1, "Retry: %2.0f%%", rpsp);
wnoutrefresh(stat_win);
}
#define COL_SNR 3
#define COL_RATE COL_SNR + 9
#define COL_PKT 3
#define COL_CHAN COL_PKT + 7
#define COL_SNR COL_CHAN + 3
#define COL_RATE COL_SNR + 3
#define COL_SOURCE COL_RATE + 3
#define COL_STA COL_SOURCE + 18
#define COL_BSSID COL_STA + 2
#define COL_ENC COL_BSSID + 20
#define COL_CHAN COL_ENC + 2
#define COL_IP COL_CHAN + 3
#define COL_IP COL_ENC + 2
static char spin[4] = {'/', '-', '\\', '|'};
......@@ -263,8 +268,11 @@ print_list_line(int line, struct node_info* n)
mvwprintw(list_win, line, 1, "%c", spin[n->pkt_count % 4]);
mvwprintw(list_win, line, COL_SNR, "%2d/%2d/%2d",
p->phy_snr, n->phy_snr_max, ewma_read(&n->phy_snr_avg));
mvwprintw(list_win, line, COL_PKT, "%.0f/%.0f%%",
n->pkt_count * 100.0 / stats.packets,
n->wlan_retries_all * 100.0 / n->pkt_count);
mvwprintw(list_win, line, COL_SNR, "%2d", ewma_read(&n->phy_snr_avg));
if (n->wlan_mode == WLAN_MODE_AP )
mvwprintw(list_win, line, COL_STA,"A");
......@@ -296,6 +304,7 @@ print_list_line(int line, struct node_info* n)
if (n->pkt_types & PKT_TYPE_BATMAN)
wprintw(list_win, " BAT");
wattroff(list_win, A_BOLD);
wattroff(list_win, GREEN);
wattroff(list_win, RED);
......@@ -311,12 +320,13 @@ update_list_win(void)
werase(list_win);
wattron(list_win, WHITE);
box(list_win, 0 , 0);
mvwprintw(list_win, 0, COL_SNR, "SN/MX/AV");
mvwprintw(list_win, 0, COL_PKT, "Pk/Re%%");
mvwprintw(list_win, 0, COL_CHAN, "CH");
mvwprintw(list_win, 0, COL_SNR, "SN");
mvwprintw(list_win, 0, COL_RATE, "RT");
mvwprintw(list_win, 0, COL_SOURCE, "SOURCE");
mvwprintw(list_win, 0, COL_STA, "M");
mvwprintw(list_win, 0, COL_BSSID, "(BSSID)");
mvwprintw(list_win, 0, COL_CHAN, "CH");
mvwprintw(list_win, 0, COL_ENC, "E");
mvwprintw(list_win, 0, COL_IP, "IP/Mesh");
......
......@@ -39,7 +39,7 @@ update_statistics_win(WINDOW *win)
{
int i;
int line;
int bps, dps;
int bps, dps, pps, rps;
float duration;
werase(win);
......@@ -52,17 +52,24 @@ update_statistics_win(WINDOW *win)
return; /* avoid floating point exceptions */
}
mvwprintw(win, 2, 2, "Packets: %d",stats.packets );
mvwprintw(win, 3, 2, "Bytes: %s (%d)", kilo_mega_ize(stats.bytes), stats.bytes );
mvwprintw(win, 4, 2, "Average: ~%d B/Pkt", stats.bytes/stats.packets);
mvwprintw(win, 2, 2, "Packets: %d", stats.packets );
mvwprintw(win, 3, 2, "Bytes: %s (%d)",
kilo_mega_ize(stats.bytes), stats.bytes );
mvwprintw(win, 4, 2, "Average: ~%d B/Pkt", stats.bytes / stats.packets);
get_per_second(stats.bytes, stats.duration, &bps, &dps);
bps = bps * 8;
mvwprintw(win, 2, 40, "Retries: %3.1f%% (%d)",
stats.retries * 100.0 / stats.packets, stats.retries);
get_per_second(stats.bytes, stats.duration, stats.packets, stats.retries,
&bps, &dps, &pps, &rps);
mvwprintw(win, 2, 40, "Total bit/sec: %s (%d)", kilo_mega_ize(bps), bps);
bps = bps * 8;
mvwprintw(win, 3, 40, "Total bit/sec: %s (%d)",
kilo_mega_ize(bps), bps);
wattron(win, A_BOLD);
mvwprintw(win, 3, 40, "Total Usage: %3.1f%% (%d)", dps * 1.0 / 10000, dps ); /* usec in % */
mvwprintw(win, 4, 40, "Total Usage: %3.1f%% (%d)",
dps * 1.0 / 10000, dps ); /* usec in % */
wattroff(win, A_BOLD);
line = 6;
......
......@@ -64,11 +64,13 @@ int spectrum_input(WINDOW *win, int c);
/******************* HELPERS *******************/
void
get_per_second(unsigned int bytes, unsigned int duration, int *bps, int *dps)
get_per_second(unsigned int bytes, unsigned int duration,
unsigned int packets, unsigned int retries,
int *bps, int *dps, int *pps, int *rps)
{
static struct timeval last;
static unsigned long last_bytes, last_dur;
static int last_bps, last_dps;
static unsigned long last_bytes, last_dur, last_pkts, last_retr;
static int last_bps, last_dps, last_pps, last_rps;
float timediff;
/* reacalculate only every second or more */
......@@ -77,12 +79,18 @@ get_per_second(unsigned int bytes, unsigned int duration, int *bps, int *dps)
if (timediff >= 1.0) {
last_dps = (1.0*(duration - last_dur)) / timediff;
last_bps = (1.0*(bytes - last_bytes)) / timediff;
last_pps = (1.0*(packets - last_pkts)) / timediff;
last_rps = (1.0*(retries - last_retr)) / timediff;
last = the_time;
last_dur = duration;
last_bytes = bytes;
last_pkts = packets;
last_retr = retries;
}
*bps = last_bps;
*dps = last_dps;
*pps = last_pps;
*rps = last_rps;
}
......
......@@ -41,7 +41,9 @@ struct packet_info;
struct node_info;
void
get_per_second(unsigned int bytes, unsigned int duration, int *bps, int *dps);
get_per_second(unsigned int bytes, unsigned int duration,
unsigned int packets, unsigned int retries,
int *bps, int *dps, int *pps, int *rps);
void __attribute__ ((format (printf, 4, 5)))
print_centered(WINDOW* win, int line, int cols, const char *fmt, ...);
......
......@@ -143,6 +143,8 @@ update_statistics(struct packet_info* p)
stats.packets++;
stats.bytes += p->wlan_len;
if (p->wlan_retry)
stats.retries++;
if (p->phy_rate > 0 && p->phy_rate < MAX_RATES) {
stats.duration += p->pkt_duration;
......
......@@ -219,6 +219,7 @@ extern struct history hist;
struct statistics {
unsigned long packets;
unsigned long retries;
unsigned long bytes;
unsigned long duration;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment