LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices



Reply
 
Search this Thread
Old 02-24-2005, 03:49 AM   #1
AzidStar
Newbie
 
Registered: Jan 2005
Distribution: Fedora Core 3
Posts: 12

Rep: Reputation: 0
How to retrieve number of bytes sent


Helllo everyone.

I was wondering if anyone knew how to retrieve the total amount of data sent on a interface (eth0, ppp0 etc.).
I want to do this from a C-program or perhaps from a shell-script.
The quick and dirty way would be to issue ifconfig and then parse out the data needed from the output.
But this solution does not appeal to me at all. After all ifconfig must be able to this by some means.
Are there some ioctl calls (would be super) that I can make?

Sincerly Kristoffer Nordström

Last edited by AzidStar; 02-24-2005 at 04:09 AM.
 
Old 02-24-2005, 04:31 AM   #2
linuxxed
Member
 
Registered: Feb 2004
Posts: 273

Rep: Reputation: 30
Try ethereal or tcpdump ..
 
Old 02-24-2005, 04:41 AM   #3
AzidStar
Newbie
 
Registered: Jan 2005
Distribution: Fedora Core 3
Posts: 12

Original Poster
Rep: Reputation: 0
Nah .. sorry but ethereal and tcpdump are sniffers that are an "ongoing process" that has to look at all data that comes through.

What I am interrested is just retrieving the actual number of bytes that has been sent/recieved on a specific interface.
If you issue ifconfig you will see at the bottom of an interface:

RX bytes:6234130 (5.9 Mb) TX bytes:6234130 (5.9 Mb)

I'm interrested in the number there of how much data has been sent.
There has to be a low-level system command to be issued, like when I retrieve a IP-adress (netmask, ssid, etc) I just issue a ioctl command.

ioctl(skfd, SIOCGIWESSID, &wrq)

Simillary when ifconfig wants to know how much data has been sent it hasnt been running ethereal the whole time.

Hope I made myself a little bit more clearer.

Sincerly Kristoffer Nordström
 
Old 02-25-2005, 02:48 AM   #4
AzidStar
Newbie
 
Registered: Jan 2005
Distribution: Fedora Core 3
Posts: 12

Original Poster
Rep: Reputation: 0
*bump*
 
Old 02-25-2005, 05:26 AM   #5
linuxxed
Member
 
Registered: Feb 2004
Posts: 273

Rep: Reputation: 30
Quote:
Originally posted by AzidStar
*bump*

Ah . then look at SNMP. If you have net-snmp configured then just snmpwalk it and you should be able to retrieve all the info about the interface real time. I cant remember the exact enterprise.ucdavis..... you'll find it!
 
Old 03-01-2005, 04:25 AM   #6
AzidStar
Newbie
 
Registered: Jan 2005
Distribution: Fedora Core 3
Posts: 12

Original Poster
Rep: Reputation: 0
thnx ... I have worked with snmp before so it shouldnt be to hard to find it in the treestructure.

Sincerly Kristoffer Nordström
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
synaptic bytes mercutio Linux - Software 9 02-10-2006 05:51 PM
TX bytes vs. httpd bytes ovrload Linux - Networking 3 10-12-2005 05:19 PM
How many bytes per inode? theonebeyond Linux - Newbie 2 09-24-2004 03:36 AM
extracting x bytes keyops Programming 4 05-30-2004 05:30 PM
1 block = ? bytes captainstorm Linux - Newbie 2 07-08-2003 11:30 AM


All times are GMT -5. The time now is 01:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration