Before you start
Information these days spends much of its time encapsulated in packets, flowing through pipes known as networks. In this tutorial, we will be capturing those packets as they flow, and the platform on which we will be capturing them is Linux.
Most network applications -- from Virtual Private Networks (VPNs) to routers to sniffers -- have some sort of packet capturing mechanism. So anyone involved with writing such software can benefit from this tutorial.
Because several of the packet filtering mechanisms we will examine are kernel modules, we will also briefly cover those, as well as kernel compilation.
We will also review some of the mechanisms that were unsuccessful for me: I could get only a copy of the packet instead of intercepting the original. This discussion can not only save you the trouble of duplicating my efforts, but can also be useful for network applications like sniffers.
Apart from a general familiarity with the different packet capturing mechanisms including firewall hooks, divert socket, and netfilter; readers will also gain knowledge about Linux networking and the TCP/IP stack. There is even some source code to get you started.
This tutorial is best suited to readers with some experience with system programming, Linux networking, and Linux kernel modules. However, this tutorial aims to keep concepts as simple as possible and to give detailed explanations where appropriate.

