views:

245

answers:

2

I want to write a program from scratch to see the sockets activity, what they send, what they receive, etc. I don't want to use a Library because it's more for academic purposes than anything else.

Where should I start?

Just to be clear: my program won't be connecting to anything or creating any socket, it just wants to listen to the activity in a computer.

Any thoughts (in any OS) about where to start will be appreciated.

Thanks in advance.

+2  A: 

Take a look at libpcap/WinPcap.

pingw33n
This would be my suggestion to.Note that under Windows wireless connections are not easily captured, see Q-16 from http://www.winpcap.org/misc/faq.htm, and http://www.cacetech.com/products/airpcap.html
Jamie Love
More than using a Library I want to know if someone has the knowledge of the low-level steps to build something like this.
Franco
Then, read the source code of libcap and see how it works.
bortzmeyer
+1  A: 

You are out of luck as far as portability goes.

ALthough the application APIs are the same or similar for UNIX and WIndows, and, both implentations are historicly based on the same Berkley Sockets BSD code, the operating system architecture and hence the ways you access low level OS fuctions such as network IO are completely different.

Linux has a number of 'network sniffing' tools(tcpdump, ethereal etc.) easily available. Not so sure about windows, MS provides a Network Monitor and there are some tools available -- google 'Sysinternals TDImon' for the MS tools.

James Anderson