Hello,
iftop is fantastic tool! Thanks for it.
On the other hand, I found little strange when it's scale ends at 977kb
with traffic in the ranges 256+ .. ~1000 kb and then jumps right to
9.54Mb. If someone has 1-1.5Mbit (and I'm one of such), then suddenly
all the graphs become very small. I tried to add more steps and at the
same time move to base 1024.
Attached patch solves these problems. Unfortunately, I had no setup to
test correctness of this patch for speeds above 2Mbps.
--
Aidas Kasparas
IT administrator
GM Consult Group, UAB
--- iftop-0.16.orig/ui.c
+++ iftop-0.16/ui.c
@@ -169,7 +169,7 @@
}
while(1) {
- if(n < size * 1000 || i >= UNIT_DIVISIONS - 1) {
+ if(n < size * 1024 || i >= UNIT_DIVISIONS - 1) {
snprintf(buf, bsize, " %4.0f%s", n / size, bytes ? unit_bytes[i] : unit_bits[i]);
break;
}
@@ -191,19 +191,26 @@
static struct {
int max, interval;
} scale[] = {
- { 64000, 10 }, /* 64 kbit/s */
- { 128000, 10 },
- { 256000, 10 },
- { 1000000, 10 }, /* 1 Mbit/s */
- { 10000000, 10 },
- { 100000000, 100 },
- { 1000000000, 100 } /* 1 Gbit/s */
+ { 64 * 1024, 10 }, /* 64 kbit/s */
+ { 128 * 1024, 10 },
+ { 256 * 1024, 10 },
+ { 512 * 1024, 10 },
+ { 1024 * 1024, 10 }, /* 1 Mbit/s */
+ { 2 * 1024 * 1024, 10 },
+ { 5 * 1024 * 1024, 10 },
+ { 10 * 1024 * 1024, 10 },
+ { 20 * 1024 * 1024, 10 },
+ { 50 * 1024 * 1024, 10 },
+ { 100 * 1024 * 1024, 100 },
+ { 200 * 1024 * 1024, 100 },
+ { 500 * 1024 * 1024, 100 },
+ { 1024 * 1024 * 1024, 100 } /* 1 Gbit/s */
};
static int rateidx = 0, wantbiggerrate;
static int get_bar_interval(float bandwidth) {
int i = 10;
- if(bandwidth > 100000000) {
+ if(bandwidth > 100 * 1024 * 1024) {
i = 100;
}
return i;