ifconfig byte count limit?

Associate
Joined
24 Jun 2007
Posts
1,869
Location
Landan.
I've just found something curious - ifconfig seems to go all the way around the clock when measuring transfers:

Code:
lm@box:/root$ ifconfig
eth0      Link encap:Ethernet  HWaddr 00:11:11:82:9e:8c
          inet addr:192.168.69.10  Bcast:192.168.69.255  Mask:255.255.255.0
          inet6 addr: fe80::211:11ff:fe82:9e8c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:509501903 errors:0 dropped:0 overruns:0 frame:0
          TX packets:489548401 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          [B]RX bytes:3277153981 (3.2 GB)  TX bytes:1777891207 (1.7 GB)[/B]
          Interrupt:16
Then no more than 10 mins later:

Code:
root@box:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:11:11:82:9e:8c
          inet addr:192.168.69.10  Bcast:192.168.69.255  Mask:255.255.255.0
          inet6 addr: fe80::211:11ff:fe82:9e8c/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:510523358 errors:0 dropped:0 overruns:0 frame:0
          TX packets:490088329 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
         [B] RX bytes:524151589 (524.1 MB)  TX bytes:1821727108 (1.8 GB)[/B]
          Interrupt:16

What the hells going on? :p
 
Are you on x86?

My x64 box does > 4gb.
Code:
[jack@tmain ~]$ ifconfig eth0
          RX bytes:8881205138 (8469.7 Mb)  TX bytes:316939370 (302.2 Mb)
At a guess I would say it could be architecture related, with a 2^32 limit on x86 systems. (Could be very wrong though :p)

If you want a permanent counter, I would make a script to extract the value to a file or a bash variable and do the maths when it resets, and cron job it for once a minute.

Ah, I did think it might be related to that. It seems a bit silly though, why would it not just store the value as a string and update that? That is, the string/int 4001MB is not 4GB in size :D

Also gave some thought to a script, but it's too late for me to work the logic out. Here's where I'm at in pseudocode-BASH:

Code:
!/bin/bash (haven't got a hash key - Mac :o)
totalcount=`cat /opt/ifcount/totalcount`
lastcount=`cat /opt/ifcount/lastcount`
count=`ifconfig | awk {operation}`
if [ count < lastcount ]
then
    newcount = $totalcount + $lastcount
    echo $newcount > /opt/ifcount/totalcount
    echo $count > /opt/ifcount/lastcount
else
    echo $count > /opt/ifcount/lastcount
fi

Thing is, I'd have to run it every 10s or similar, otherwise potentially a lot of data could get 'lost', depends on what the performance impact was of running such a small shell script.

Thanks for the reply :)
 
Back
Top Bottom