Click to See Complete Forum and Search --> : is there a system call for network statistics?


ovf
01-22-2003, 08:48 PM
I built a GUI for my dialup modem and am using /proc/net/dev to collect network statistics. Is there a better way to do this? The rx/tx statistics displayed by the program seem bursty and I'm thinking this might be caused by the frequency at which /proc/net/dev is updated by the system. Also, I'd like to eliminate the overhead of reading the file.

Thanks

bwkaz
01-23-2003, 11:19 AM
I don't know of any syscall for that kind of thing, but you should probably realize that anything hosted under /proc is not a real file. /proc is a RAM-backed filesystem -- the kernel doesn't "update" anything in there, and there's no latency to read the "files".

What happens is, the kernel driver for the net device "overloads" the open and read syscalls for /proc/net/dev (for example), then when your program calls read() on that file (all the C file input functions boil down to a read() in the end), it just calls the overloaded function in the net driver, which returns the appropriate value(s) from memory.

I don't know why it would seem "bursty", but it's not because the stats updates are being batched together or anything -- they should be re-gathered every time you read from the /proc file, at least from what I understand.

Hmmm.... maybe looking into the kernel net driver for your device would reveal something useful?

ovf
01-23-2003, 09:54 PM
Thanks for the informative reply. It sounds like the program gets the most current information everytime it reads the file so I'll leave it the way it is.

I'm comparing the receive rate displayed by my program against the value displayed by a graphical ftp utility. The rate shown by my program varies between 4kb and 6.5kb per second while the rate displayed by the ftp tool hovers closely around 5kb. Maybe I'll try installing another diaup utility and see how it compares to what I've done.

I hadn't thought about looking at the kernel code. Maybe I'll poke through it.

Thanks again.

bwkaz
01-23-2003, 10:03 PM
The other possibility is, the utility program might be averaging the values that it displays. ;)

Otherwise, it might be doing what Mozilla at least does, and showing the total bandwidth usage over the entire session, which averages stuff out a little differently.