Write a Linux packet sniffer from scratch: PF_PACKET socket and promiscuous mode
organicprogrammer.com