Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
problem with bytes counter in ifconfig
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
phoenix_me
Apprentice
Apprentice


Joined: 24 Dec 2003
Posts: 281
Location: Lubliniec

PostPosted: Mon Mar 05, 2007 10:12 am    Post subject: problem with bytes counter in ifconfig Reply with quote

The best way to see my problem is to look at below example.
Especially look at RX bytes on eth0.

Code:
EdGeeV ~ # ifconfig
eth0      Link encap:Ethernet  HWaddr 00:50:8D:F9:06:39
          inet addr:10.10.1.20  Bcast:10.10.1.255  Mask:255.255.255.0
          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4393550 errors:0 dropped:0 overruns:0 frame:0
          TX packets:3712019 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3752774910 (3578.9 Mb)  TX bytes:763029006 (727.6 Mb)
          Interrupt:10 Base address:0x2000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:200 (200.0 b)  TX bytes:200 (200.0 b)

and then, after the counter is (probably) more than 4GB it looks like taht

Code:
EdGeeV ~ # ifconfig
eth0      Link encap:Ethernet  HWaddr 00:50:8D:F9:06:39
          inet addr:10.10.1.20  Bcast:10.10.1.255  Mask:255.255.255.0
          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5315621 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4546719 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:99996333 (95.3 Mb)  TX bytes:911026661 (868.8 Mb)
          Interrupt:10 Base address:0x2000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:4 errors:0 dropped:0 overruns:0 frame:0
          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:200 (200.0 b)  TX bytes:200 (200.0 b)


The RX bytes counter is reseted and count the bytes again from zero. Is it a bug in ifconfig or maybe it is a different problem, not related to ifconfig?.

Any help will be appreciated as always. :)
_________________
phoenix
___
myslenie ma przyszlosc
___
Back to top
View user's profile Send private message
mjrosenb
Tux's lil' helper
Tux's lil' helper


Joined: 12 Jun 2006
Posts: 115
Location: CMU

PostPosted: Mon Mar 05, 2007 11:24 am    Post subject: Reply with quote

it's a problem with x86. All of the older x86 hardware uses 32 bit integers for everything, which gives a maximum value of 2^32-1 = 4,294,967,295 = 4GB
If I'm not mistaken, it's something that is defined within the kernel, so the two best options are to re-write the proper kernel modules, or write a script that will monitor eth0 and find out when it's rolled over.
_________________
I'll be mjrosenb on #${COMPUTER_RELATED_SUBJECT}
1x i386 laptop w/ Gentoo
4x i386 desktop w/ Gentoo
2x dual proc i386 w/dragonfly bsd
1x x86-64 desktop w/ Gentoo
1x i386 desktop w/ FreeBSD
1x alpha workstation w/ Gentoo
looking for more
Back to top
View user's profile Send private message
phoenix_me
Apprentice
Apprentice


Joined: 24 Dec 2003
Posts: 281
Location: Lubliniec

PostPosted: Mon Mar 05, 2007 1:47 pm    Post subject: Reply with quote

mjrosenb wrote:
it's a problem with x86. All of the older x86 hardware uses 32 bit integers for everything, which gives a maximum value of 2^32-1 = 4,294,967,295 = 4GB
If I'm not mistaken, it's something that is defined within the kernel, so the two best options are to re-write the proper kernel modules, or write a script that will monitor eth0 and find out when it's rolled over.


I can't agree with you. You can use integers bigger than 2^32-1. For example GCC ( >3.3.5) can use integers which are 64bit long (long long int) - which gives you 18 446 744 073 709 551 615 (unsigned).
So it is rather problem with implementation of 'ifconfig' which maybe use long int (32bit) for the representation of bits counter. If so - then the author of ifconfig should change it :).
_________________
phoenix
___
myslenie ma przyszlosc
___
Back to top
View user's profile Send private message
mjrosenb
Tux's lil' helper
Tux's lil' helper


Joined: 12 Jun 2006
Posts: 115
Location: CMU

PostPosted: Wed Mar 07, 2007 10:48 am    Post subject: Reply with quote

Gcc supports long long, but the support is entirely in software. I would call the long long a poor hack, and something that's not exactly suitable to be in the kernel (not that the kernel is by any means good). Back to the other point that I was attempting to make. The limitation is in the kernel, not in ifconfig
at least in the e100 driver (/usr/src/linux/drivers/net/e100.c) they have the struct that's exported to /sys/class/net/eth1/statistics.

struct stats {
u32 tx_good_frames, tx_max_collisions, tx_late_collisions,
tx_underruns, tx_lost_crs, tx_deferred, tx_single_collisions,
tx_multiple_collisions, tx_total_collisions;
u32 rx_good_frames, rx_crc_errors, rx_alignment_errors,
rx_resource_errors, rx_overrun_errors, rx_cdt_errors,
rx_short_frame_errors;
u32 fc_xmt_pause, fc_rcv_pause, fc_rcv_unsupported;
u16 xmt_tco_frames, rcv_tco_frames;
u32 complete;
};
You can try changing the corresponding line in your driver, but since all of the accesor functions deal with ints, you'll most likely run into the same problem.
_________________
I'll be mjrosenb on #${COMPUTER_RELATED_SUBJECT}
1x i386 laptop w/ Gentoo
4x i386 desktop w/ Gentoo
2x dual proc i386 w/dragonfly bsd
1x x86-64 desktop w/ Gentoo
1x i386 desktop w/ FreeBSD
1x alpha workstation w/ Gentoo
looking for more
Back to top
View user's profile Send private message
dj_farid
l33t
l33t


Joined: 14 Jun 2004
Posts: 613

PostPosted: Sat May 03, 2008 12:53 pm    Post subject: Reply with quote

I found this thread while wondering the same thing. ( knew that I had downloaded more than 4 gigs, but the counter showed something else).

Is there a way to get better statistics that shows the real world numbers?
There is probably a script that gets the numbers from /proc/net/dev and keeps track of the resets every 4 GB...
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum