drew benton made some amazing tutorials about sniffing and he also made great tools to sniff the packets. You can use for example wireshark to sniff packets it's not recommended but it works. You should check out the silkroad development series and read this

article. That will help a lot and you could take a look in some open source projects too see how things work.
I'm sure that people could give you a way better answer than me but I hope this helped a bit.