|
||||||||
|
|
#1
|
|
hello ... this is rakesh ..... i am new to socket programming ..... i
just want to know wheather if we could get statistics related to a particular port using socket programming in C? statistics in the sense .... no of packets transmitted,received etc ..... or is there any file in linux( i use fedora) which gives this kind of information? .... thanks in advance !!! rak.dontmess@gmail.com |
|
#2
|
|||
|
|||
|
On Feb 12, 2:09 pm, rak.dontm...@gmail.com wrote:
> hello ... this is rakesh ..... i am new to socket programming ..... i > just want to know wheather if we could get statistics related to a > particular port using socket programming in C? statistics in the > sense .... no of packets transmitted,received etc ..... or is there > any file in linux( i use fedora) which gives this kind of > information? .... thanks in advance !!! Why not use the "/sbin/ifconfig" file? As in... struct FILE *Stats = popen("/sbin/ifconfig eth0","r"); if (Stats) { char buff[256]; while (fgets(buff, sizeof(buff), Stats) != EOF) fputs(buff,stdout); pclose(Stats); } |
|
#3
|
|||
|
|||
|
(E-Mail Removed) wrote:
> hello ... this is rakesh ..... i am new to socket programming > ..... i just want to know wheather if we could get statistics > related to a particular port using socket programming in C? > statistics in the sense .... no of packets transmitted,received etc > ..... or is there any file in linux( i use fedora) which gives this > kind of information? .... thanks in advance !!! The closest you can get IIRC is what is reported by a TCP_INFO getsockopt(), which is described in the manpage for tcp under linux. It is decidedly non-portable. That of course won't do anything for UDP, or DCCP or SCTP etc etc. And it is very specific to the Linux stack - it may not be there on other stacks. There might be some way using netfilter (?) to gather those stats, but I'm not sufficiently familiar with how one uses that to say. rick jones -- portable adj, code that compiles under more than one compiler these opinions are mine, all mine; HP might not want them anyway... ![]() feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH... |
|
#4
|
|||
|
|||
|
Lew Pitcher <(E-Mail Removed)> wrote:
> On Feb 12, 2:09 pm, rak.dontm...@gmail.com wrote: > > hello ... this is rakesh ..... i am new to socket programming ..... i > > just want to know wheather if we could get statistics related to a > > particular port using socket programming in C? statistics in the > > sense .... no of packets transmitted,received etc ..... or is there > > any file in linux( i use fedora) which gives this kind of > > information? .... thanks in advance !!! > Why not use the "/sbin/ifconfig" file? As in... > struct FILE *Stats = popen("/sbin/ifconfig eth0","r"); > if (Stats) > { > char buff[256]; > while (fgets(buff, sizeof(buff), Stats) != EOF) > fputs(buff,stdout); > pclose(Stats); > } That would give the count of everything that went through the interface, not just that for the OP's port of interest. Now, if he "knew" that his was the only active sockets application using that interface it would give him what he wants, but I doubt that will ever be the case. rick jones -- web2.0 n, the dot.com reunion tour... these opinions are mine, all mine; HP might not want them anyway... ![]() feel free to post, OR email to rick.jones2 in hp.com but NOT BOTH... |
|
#5
|
|||
|
|||
|
On Feb 12, 11:09 am, rak.dontm...@gmail.com wrote:
> hello ... this is rakesh ..... i am new to socket programming ..... i > just want to know wheather if we could get statistics related to a > particular port using socket programming in C? statistics in the > sense .... no of packets transmitted,received etc ..... or is there > any file in linux( i use fedora) which gives this kind of > information? .... thanks in advance !!! This is one thing I really like about FreeBSD and really miss about Linux. FreeBSD has some great ways to track flows passing through it and track traffic by destination and by port. I know of no good ways to do this on Linux. I would be very interested in possible ways to do this because I have been forced to use FreeBSD for several firewalls where I would prefer Linux because I can't get good statistics on traffic by destination host and/or by flow. HTB also can't easily regulate traffic by host unless you reserve bandwidth for every single host. That's awkward when you have tens of thousands of hosts. DS |
![]() |
| Tags |
| programming, socket |
| Thread Tools | |
| Display Modes | |
|
|