Collecting data in userland from kernel

ARY ary834 at gmail.com
Thu Mar 3 10:47:11 GMT 2005


Hello hackers,

I am new to FreeBSD but I am familiar with Unix like systems 
in general and Linux in particular.

I am doing a project where-in I need to manipulate a few 
things in the mbuf's of network stack (mainly in TCP) and 
capture per packet statistics. Then the collated data has to 
be passed on to userspace. I have two queries regarding this.

First one is in general abt the method to be followed, I 
have the following ideas Please provide your suggestion on 
them also if you consider some other approach would be 
better then please do suggest.

1. Writing to a virtual device: This looks a very good 
option for me because it is light weight and should be 
straight forward to implement

2. A ring buffer in kernel: Something like libpcap does. 
should be good.

3. Writing to syslogger: not very attractive to me because 
it is mainly a common place for all modules and I dont have 
complete control over it.

4. Writing to a file: I dont think this is feasible because 
it is not appropriate to do costly I/O in kernel mode and 
also it is a cumbersome task.

Your say on the above ???
Any other approach(s) ???? Plzz let me know.

Second, as I said I am a newbie for FreeBSD, can somebody 
please point me to resources/docs for writing a virtual 
device. I read the chapter 13 in the Handbook, but it would 
be helpful if a document provide some info about interacting 
with a device from the kernel.

TIA,

Best Regards,
Amit


More information about the freebsd-hackers mailing list