I'm wondering how to go about monitoring network traffic on my Mac. Like the way activity monitor does it, showing the bytes / packets in and out.
I know it's a bit vague, but I'm unsure of the best place to start.
EDIT: I forgot to mention, I'm wanting to do this in code, not use an existing piece of software.