From owner-freebsd-hackers@FreeBSD.ORG Thu Mar 3 10:47:11 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 6340916A4CE for ; Thu, 3 Mar 2005 10:47:11 +0000 (GMT) Received: from msg-mx0.usc.edu (msg-mx0.usc.edu [128.125.137.5]) by mx1.FreeBSD.org (Postfix) with ESMTP id 3CD0643D2F for ; Thu, 3 Mar 2005 10:47:11 +0000 (GMT) (envelope-from ary834@gmail.com) Received: from [192.168.0.109] ([24.30.100.180]) by msg-mx0.usc.edu (Sun Java System Messaging Server 6.1 HotFix 0.08 (built Dec 8 2004)) with ESMTPA id <0ICR004X5VAM6X30@msg-mx0.usc.edu> for freebsd-hackers@freebsd.org; Thu, 03 Mar 2005 02:47:11 -0800 (PST) Date: Thu, 03 Mar 2005 02:47:10 -0800 From: ARY Sender: amitky@usc.edu To: freebsd-hackers@freebsd.org Message-id: <4226EB2E.7080507@gmail.com> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7BIT X-Accept-Language: en-us, en User-Agent: Mozilla Thunderbird 0.9 (X11/20041103) Subject: Collecting data in userland from kernel X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 03 Mar 2005 10:47:11 -0000 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