ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
there are two counts associated with any route, reference count and usage count,
everytime the packet uses a route, the usage count is incremented.
reference count is just to see how many connections (or transactions) are using that route. Usage count can be seen using the route -nC command, this is to see the route cache...
--iptraf is a utility that shows how many packets and bytes have left that interface,
i am not sure if there is any direct api that can give you this statistic...because netstat causes a read on the proc filesystem that contains these statistics...
you can write your own system call that can parse the whole of route cache and print the counts (these are in a structure called rtable, defined in net/route.h)..
it is not very difficult, infact, you can use a lot of kernel code to see how to write a call that can take the src and destination ips and give their statistics , by looking in the hash table (route cache)..
CORRECTION : the structure is that contains refcnt and use is not rtable but one it usesdst_entry (in net/dst.h). I apologise for the error.
yeah, you can use the routing sockets for this purposes...damn, how could i forget that...., this function uses a structure rta_cacheinfo, that is filled in by the kernel using a function called inet_rtm_getroute(), which in turn uses the function rt_fill_info() to get the job done, the fields in the
would be the ones you are interested in...