public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* low overhead packet capturing on linux
@ 2010-12-01  0:28 Thomas Fjellstrom
  2010-12-01  9:21 ` Alexander Clouter
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Thomas Fjellstrom @ 2010-12-01  0:28 UTC (permalink / raw)
  To: LKML

I'm working on a little tool to monitor and measure bandwidth use on a vm 
host, down to keeping track of all guest and host bandwidth, including, 
eventually per layer7 protocol use.

Right now I have a pretty simple setup, I setup an AF_PACKET socket, select on 
it, and read data as it comes in. Obviously, this has a fatal flaw. It takes up 
a rather large amount of cpu time just to capture the packets. On a GbE 
interface, it uses up easily 60-80% cpu (on a 2.6Ghz amd phenom II cpu core) 
just to capture the packets, trying to do anything fancy with them will likely 
cause the kernel to drop some packets.

So what I'm looking for is a very low overhead way to capture packets. I've 
come up with a few ideas, some of which I have no idea if they'd even work.

One idea that came to mind (that doesn't entirely look possible) is using 
splice or vmsplice to get me as little copying as is necessary from the net 
device to my own chunk of memory. Even better if it can be a circular queue of 
sorts. I'd probably use one thread to just sit on the socket and manage the 
packets, and a second thread to actually do the accounting on the incoming 
packets.

Anyone have any pointers or tips for me?

-- 
Thomas Fjellstrom
thomas@fjellstrom.ca

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-12-02 14:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-01  0:28 low overhead packet capturing on linux Thomas Fjellstrom
2010-12-01  9:21 ` Alexander Clouter
2010-12-01 10:18   ` Thomas Fjellstrom
2010-12-01 12:19 ` Pekka Pietikainen
2010-12-01 20:28   ` Thomas Fjellstrom
2010-12-02 14:49 ` Henrique de Moraes Holschuh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox