Stuff related to computer networks.
Because you can't always access real hardware. Plus, sometimes it's safer and faster to experiment in virtualized environment, than to go mess with expensive real routers.
VyOS is an excellent open source Linux-based software router. It supports OSPF, RIP, BGP and many other protocols out-of-the-box and it can be installed on actual computers as well as virtual machines. These guides are based on my own experiments with both VyOS and VC, and are in no way official guides. I use VirtualBox, but these should be applicable to any virtualized (or physical) environment.
- VyOS on VirtualBox, includes generic non-VirtualBox-specific usage tips and hints
These originally were part of the code snippets collection on the programming page, but I split them off to here.
Ethernet/ARP/IPv4/UDP/TCP packet generation and serialization
Some time ago I wrote a tiny network simulator. It could simulate endpoints (PCs) and layer 2 switches. It supported VLANs, ARP, IPv4, UDP and TCP packets and could actually route packets in a switched network. Unfortunately, due to time constraints I was not able to continue the project. The project was also left in a state where I could not release it publicly despite of my original intentions of doing so.
However, I decided to salvage some parts of it. The simulator supported packet capturing. While it didn't simulate actual frames and packets, it could write pcap capture files by simply filling in the missing fields with sane default values. The following file contains some code for writing layer 2 Ethernet frames (with VLAN support) and ARP requests/replies, raw layer 3 IPv4 packets and layer 4 TCP/UDP packets. It also contains some utility code to compute the internet checksums outlined in RFC 1071 that are used in the packet headers.
IPv4 subnet calculators
IPv4 is nearly dead, so the usefulness of these are questionable. Nevertheless, here they are.
I once was required to take an "introduction to programming" class, which was taught in Perl. I wrote this small IPv4 subnet calculator for the exercise. Maybe it will be useful to someone. Might contain bugs, use at your own risk!
Here's a C++ function for the same task. Given any IPv4 address and netmask, it calculates the network, broadcast, first host and last host addresses. Little endian architectures only!