This tutorial shows how to write a simple network sniffer that can capture an IP packet, parse it and print it on the screen in the human readable form.
Raw sockets - http://docs.python.org/library/socket...
Struct module - http://docs.python.org/library/struct...
IP header - http://www.networksorcery.com/enp/pro...
Regular expressions - http://gskinner.com/RegExr/
Network sniffer code - http://pastebin.com/e8iGvVZR