Option to display packet counts - Frédéric Perrin <fperrin@brocade.com>
Add a "-u unit" CLI option, as well as a "bandwidth-unit" configuration file option. With "-u packets", traffic is accounted using packets per second; the other options are "-u bits" and "-u bytes". "-B" is still recognized as synonym to "-u bytes". The default is "-u bits", keeping the current behaviour of iftop (everything is in bits/s, except the cumulative totals).
This commit is contained in:
24
iftop.c
24
iftop.c
@@ -431,14 +431,22 @@ static void handle_ip_packet(struct ip* iptr, int hw_dir)
|
||||
}
|
||||
|
||||
/* Do accounting. */
|
||||
switch (IP_V(iptr)) {
|
||||
case 4:
|
||||
len = ntohs(iptr->ip_len);
|
||||
break;
|
||||
case 6:
|
||||
len = ntohs(ip6tr->ip6_plen) + 40;
|
||||
default:
|
||||
break;
|
||||
switch (options.bandwidth_unit) {
|
||||
case OPTION_BW_BITS:
|
||||
case OPTION_BW_BYTES:
|
||||
switch (IP_V(iptr)) {
|
||||
case 4:
|
||||
len = ntohs(iptr->ip_len);
|
||||
break;
|
||||
case 6:
|
||||
len = ntohs(ip6tr->ip6_plen) + 40;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case OPTION_BW_PKTS:
|
||||
len = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Update record */
|
||||
|
||||
Reference in New Issue
Block a user