twIP (pronounced “twip” and short for tweet IP) runs as a process under a *nix-like system, but could also be run on a standalone (OS-less) device, as long as there is a device driver for some networking hardware. The underlying system must provide a way to receive and send raw data packets. Operating systems such as FreeBSD (and others) provide a very nice mechanism called the tun/tap device, where a special file (/dev/tun0) is connected to a network interface (tun0) so that packets sent over the interface can be read from the file, and packets written to the file appear as packets on the network interface. By setting up the IP address of the network interface, routing IP packets to the user program is a breeze.

twIP is a really, really tiny IP stack, written in 139 bytes of C code – small enough to fit in a Twitter message. Ok, so it is very far away from a real IP stack, but it can do the first task of an IP stack: respond to pings. The entire source code for version 1.1 can be found this tweet (139 characters long – version 1.0 in this tweet, 128 characters long).

More twIP info and source code