LinuxQuestions.org
Visit Jeremy's Blog.
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 06-21-2005, 12:25 PM   #1
telemaco
LQ Newbie
 
Registered: Jun 2005
Posts: 4

Rep: Reputation: 0
Port Bandwith


Hi all!
I need to know the bandwith that is being consumed by a specific port.
For instances, if I have Gaim running and I'm sending a file to anyone, let's say that the port I'm using is 5090. So, how can I know how much network traffic is generated every second on that port??

Thank you very much.
 
Old 06-21-2005, 01:09 PM   #2
demian
Member
 
Registered: Apr 2001
Location: Bremen, Germany
Distribution: Debian
Posts: 303

Rep: Reputation: 30
Google for iptables accounting. That'll get you lots of hints on what can be done. The simplest solution I'd say is to use either mrtg or rrdtool in conjunction with an iptables rule that counts the packets. Then all you have to do is to periodically read out the byte counter and store it in an rrd. Check out the rrdtool page. If you need help in setting this up, post back.
 
Old 06-21-2005, 01:42 PM   #3
telemaco
LQ Newbie
 
Registered: Jun 2005
Posts: 4

Original Poster
Rep: Reputation: 0
RE

Thnaks for your answer
It seems to be a good idea. But it assumes that the user of my program have iptables installed and configured in her system, and I know that can be difficult.

I red something about tcpdump. I know how to caputre packages on a given port, but I don't know how to use them to get the bytes/sec rate...
 
Old 06-21-2005, 01:57 PM   #4
demian
Member
 
Registered: Apr 2001
Location: Bremen, Germany
Distribution: Debian
Posts: 303

Rep: Reputation: 30
Re: RE

Quote:
Originally posted by telemaco
...But it assumes that the user of my program have iptables installed and configured in her system, and I know that can be difficult.
Not necessarily. If there's a router the traffic passes through that's where you want to do the traffic monitoring.

Do you want to do long term monitoring or just want to know the throughput on a certain port at the moment? The latter is probably even possible with toys like gkrellm.
 
Old 06-21-2005, 04:52 PM   #5
telemaco
LQ Newbie
 
Registered: Jun 2005
Posts: 4

Original Poster
Rep: Reputation: 0
What I want to to do is the latter you said.
Every second I would like to show the information for each port.
I'm looking gkrellm and it reminds me to superkaramba but with more functionality.
It's quite good, but what I'm looking for is something in command line in order to get the value I want.
Gkrellm has its own GUI and I don't see anywhere the way to run it in comman-line.

What I have exactly i mind is...
From my littel application I make I system call to any other command line application that outputs its data to the standard output (console). Then I would use sed and grep to get the data I'm looking for.
Every second I would do a port measure so, in my application, I could show in my GUI, the program running on that port and the bandwith it is using.


Thanks a lot demian
 
Old 06-21-2005, 05:34 PM   #6
demian
Member
 
Registered: Apr 2001
Location: Bremen, Germany
Distribution: Debian
Posts: 303

Rep: Reputation: 30
Ok then clearly iptables isn't a practical solution to do the accounting. I'd use either libpcap or if you want something more high level check out pmacct. It uses libpcap and allows you to write out packet or byte counters to stdout (or better yet for your purpose: a pipe). It's very felxible and you can grab packets based on source or destination port, mac address, ip address,...
 
Old 06-21-2005, 06:04 PM   #7
telemaco
LQ Newbie
 
Registered: Jun 2005
Posts: 4

Original Poster
Rep: Reputation: 0
Ok, I know about pcap because It was the base of almost every program of network monitoring, but I think is too low level for me.
I will test pmacct tonight and tomorrow I'll tell you about my progress

Thanks a lot
 
Old 06-21-2005, 07:41 PM   #8
born4linux
Senior Member
 
Registered: Sep 2002
Location: Philippines
Distribution: Slackware, RHEL&variants, AIX, SuSE
Posts: 1,127

Rep: Reputation: 49
iptraf -s ethX

the lower part of the screen will show you the rate (in/out) of the port you wan to monitor.

if you want to graph it, check out www.cacti.net - and see if it can handle what you need. i've never tried graphing by port. i only do rrdtool graphing per host just to monitor their b/w usage.

hth.
 
  


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
bandwith control westverg Linux - Networking 4 01-18-2005 01:20 AM
Restricting Bandwith Rizla Linux - Networking 3 12-03-2004 09:15 AM
limiting bandwith for a certain port dadi Linux - Networking 9 06-19-2004 10:16 AM
balance bandwith zaldyd Linux - Networking 5 07-29-2003 11:07 AM
Bandwith Prioritization bretthoward Linux - Networking 0 10-09-2001 01:24 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 08:03 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
Open Source Consulting | Domain Registration