sander2
Posts: 60
Joined: Wed Jul 04, 2012 2:22 pm

netstat gives "InOctets: -1" after 4.2+GB

Tue Jun 18, 2013 9:24 pm

This looks like a bug in netstat on Raspbian. The problem does not occur on Ubuntu 32-bit (nor 64-bit)

"netstat -s" gives "InOctets: -1" and stays on that value

Code: Select all

pi@raspberrypi ~ $ netstat -s | grep -i octet | grep -vi cast
    InOctets: -1
    OutOctets: 79624814
pi@raspberrypi ~ $
This seems to happen after receiving 4.2GB; see logging below which happened after download a few ISO-images in another terminal. So some kind of 32-bit counter overflow?

FWIW: ifconfig shows " RX bytes:2868081491 (2.6 GiB) TX bytes:52829058 (50.3 MiB)", meaning 4.2 + 2.6 = 6.8GB

Note:
- ifconfig on 32-bit OS is a 32-bit counter.
- netstat seems to be a two's complement 32-bit counter (even on 64-bit Ubuntu), so therefore the negative values before locking on -1

Google seems to only give results with "Client data" ... some kind of reporting data, and ... on armv6l and 3.2.2-kvm-i386

Tips welcome.

Code: Select all

pi@raspberrypi ~ $ netstat -s | grep -i octet | grep -vi cast
    InOctets: 135846329
    OutOctets: 551351
pi@raspberrypi ~ $ 
pi@raspberrypi ~ $ netstat -s | grep -i octet | grep -vi cast
    InOctets: 201321541
    OutOctets: 794419
pi@raspberrypi ~ $ netstat -s | grep -i octet | grep -vi cast
    InOctets: 412541238
    OutOctets: 1825179
pi@raspberrypi ~ $ 
pi@raspberrypi ~ $ netstat -s | grep -i octet | grep -vi cast
    InOctets: 1349541109
    OutOctets: 6815405
pi@raspberrypi ~ $ netstat -s | grep -i octet | grep -vi cast
    InOctets: -2128487815
    OutOctets: 10995377
pi@raspberrypi ~ $ netstat -s | grep -i octet | grep -vi cast
    InOctets: -1124081361
    OutOctets: 15466277
pi@raspberrypi ~ $ netstat -s | grep -i octet | grep -vi cast
    InOctets: -435327466
    OutOctets: 18907355
pi@raspberrypi ~ $ netstat -s | grep -i octet | grep -vi cast
    InOctets: -1
    OutOctets: 25297311
pi@raspberrypi ~ $ 

aaa801
Posts: 428
Joined: Mon Jun 04, 2012 9:06 pm
Location: Berkshire

Re: netstat gives "InOctets: -1" after 4.2+GB

Tue Jun 18, 2013 9:46 pm

Sounds like a overflow to the sign bit,

what does cat /proc/net/netstat
print out ?

Also this will prob fix it
http://net-tools.git.sourceforge.net/gi ... 03eb43e34d

sander2
Posts: 60
Joined: Wed Jul 04, 2012 2:22 pm

Re: netstat gives "InOctets: -1" after 4.2+GB

Tue Jun 18, 2013 10:11 pm

Wow, that looks good: 20768496576, so 20.768.496.576 octes = 20 GB. So it's just a matter of presentation?

Code: Select all

pi@raspberrypi ~ $ cat /proc/net/netstat  | awk '{ print $8 }'  | tail -2
InOctets
20768496576
pi@raspberrypi ~ $ cat /proc/net/netstat  | awk '{ print $8 }'  | tail -2
InOctets
20913680964
pi@raspberrypi ~ $ cat /proc/net/netstat  | awk '{ print $8 }'  | tail -2
InOctets
21758842200
pi@raspberrypi ~ $ 
Do you know the git URL of http://net-tools.git.sourceforge.net/ so that I can do a "git clone ..."?

EDIT: found it:

Code: Select all

git clone git://net-tools.git.sourceforge.net/gitroot/net-tools/net-tools
... I'm now compiling it ...

sander2
Posts: 60
Joined: Wed Jul 04, 2012 2:22 pm

Re: netstat gives "InOctets: -1" after 4.2+GB

Tue Jun 18, 2013 10:45 pm

And ... solved with the the git version of net-tools/netstat:

Code: Select all

pi@raspberrypi ~/git/net-tools $ ./netstat --version
net-tools 2.10-alpha
Fred Baumgarten, Alan Cox, Bernd Eckenfels, Phil Blundell, Tuan Hoang, Brian Micek and others
+NEW_ADDRT +RTF_IRTT +RTF_REJECT +FW_MASQUERADE -I18N
AF: (inet) +UNIX +INET +INET6 +IPX +AX25 +NETROM +X25 +ATALK +ECONET +ROSE -BLUETOOTH
HW:  +ETHER +ARC +SLIP +PPP +TUNNEL -TR +AX25 +NETROM +X25 +FR +ROSE +ASH +SIT +FDDI +HIPPI +HDLC/LAPB +EUI64 
pi@raspberrypi ~/git/net-tools $ 

pi@raspberrypi ~/git/net-tools $ ./netstat -s  | grep -i octet | grep -vi cast
    InOctets: 44243492434
    OutOctets: 216890158
pi@raspberrypi ~/git/net-tools $ ./netstat -s -6 | grep -i octet | grep -vi cast
    Ip6InOctets: 773754535
    Ip6OutOctets: 333902508
pi@raspberrypi ~/git/net-tools $

So: counter is now at 44GB, well above 4.2GB. Great.
And now I wish Raspbian (or Debian?) incorporates this new version of net-tools / netstat into the distribution.
Last edited by sander2 on Wed Jun 19, 2013 6:17 am, edited 1 time in total.

User avatar
rpdom
Posts: 15391
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: netstat gives "InOctets: -1" after 4.2+GB

Wed Jun 19, 2013 4:20 am

sander2 wrote:And now I wish Raspbian (or Debian?) incorporates this new version of net-tools / netstat into the distribution.
It is a known bug, for which a patch is available. However the severity is "normal", so lower importance than all the "release critical" bugs that needed fixing before Debian moved their stable release to Wheezy. I suspect it will get fixed at some point in Jessie.
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=640480

sander2
Posts: 60
Joined: Wed Jul 04, 2012 2:22 pm

Re: netstat gives "InOctets: -1" after 4.2+GB

Wed Jun 19, 2013 6:18 am

Thank you for your help and explanation!

Return to “Raspbian”