---[ Practicing networking with just one machine. ]--- You can use my code at http://netfluke.org/ (redirects to github). Read the pong.py and tcp.py scripts. They make heavy use of Scapy to parse and construct packets. You may find the following links useful: "Cheat sheets:" http://media.packetlife.net/media/library/36/scapy.pdf http://www.packetlevel.ch/html/scapy/docs/scapy_sans.pdf Tutorials: http://wikihead.wordpress.com/2011/01/09/packet-crafting-using-scapy/ http://theitgeekchronicles.files.wordpress.com/2012/05/scapyguide1.pdf I prefer to work with Scapy at command line, trying things out before I commit them to a script. Just run scapy without arguments and use it to capture real packets. Note that Scapy's send and receive functions (e.g., sendp() and sr()) WILL NOT WORK with a TUN/TAP driver. You must use os.read() and os.write() instead. Recall that from the kernel's point of view, sending a packet out of your virtual TAP interface means queuing it to be read by your script that has the TAP device open; whatever your script writes to that device the kernel feeds to the same entry point for all packets coming in from from the outside networks, netif_rx_ni(). So Scapy's sendp() called from your script for your TAP interface would cause the script to send packets back to itself, not to the kernel, which would be pointless. Don't use these, use os.read() instead to get the packets sent by the kernel to your emulated LAN, and os.write() to send the responses from your emulated hosts back to your kernel (and, hence, via the kernel, to your programs such as ping, netcat (nc), browsers, etc.) -----[ TUN/TAP driver]----- On either Linux or OS X you will need the TUN/TAP driver. This driver creates two kinds of devices: those that deal with IP packets _without_ the Ethernet header (TUN) and full Ethernet frames (TAP). We will use TAP exclusively, because we are interested in fully emulating an Ethernet interface and an Ethernet LAN behind it. TUN is mostly useful for building VPNs (e.g., OpenVPN typically uses TUN, not TAP). On Linux, TUN/TAP is already available in most distributions. Load it with "modprobe tun". The actual file lives in /lib/modules/