Dummynet is an open-source network emulation tool which allows one to emulate various networking properties of a physical link, such as bandwidth capacity, packet losses, delays and queue length. Dummynet can be used to test experimental network protocols in an emulated network environment.
While dummynet had originally been developed for FreeBSD platform, it was later ported to Linux systems as an external kernel module. In this guide, I will describe how to compile and install dummynet kernel module on CentOS. This setup was tested on CentOS 6.2.
To start out, install all necessary prerequisites for building dummynet kernel module.
The next step is to install a matching kernel source on CentOS. You need to use a matching kernel source in order to be able to load dummynet in your kernel. CentOS 6.2 has the following kernel.
Install the matching kernel source, and prepare for building dummynet against the kernel source.
$ echo "%_topdir /tmp/rpmbuild" > ~/.rpmmacros
$ wget http://vault.centos.org/6.2/os/Source/SPackages/kernel-2.6.32-220.el6.src.rpm
$ rpm -i kernel-2.6.32-220.el6.src.rpm 2>&1 | grep -v mockb
$ sudo tar xvfvj /tmp/rpmbuild/SOURCES/linux-2.6.32-220.el6.tar.bz2 -C /usr/src/kernels/
$ cd /usr/src/kernels/2.6.32-220.17.1.el6.x86_64
$ sudo make oldconfig
$ sudo make prepare
$ sudo make scripts
Download the latest dummynet source code, and compile it against the matching kernel source.
$ tar xvjvz ipfw3-20120119.tar.gz
$ cd ipfw3-20120119
$ make KERNELPATH=/usr/src/kernels/2.6.32-220.17.1.el6.x86_64
If build is successful, you will have dummynet kernel module called ipfw_mod.ko created in ipfw3-20120119/dummynet2 directory. Try loading the module.
If successful, finally go ahead and install the dummynet module. Optionally, you can make it automatically loaded upon boot as follows.
$ sudo depmod
$ sudo sh -c 'echo modprobe ipfw_mod >> /etc/rc.modules'
$ sudo chmod +x /etc/rc.modules
Subscribe to Xmodulo
You can have daily Linux tutorials and FAQs delivered to your email inbox. Simply enter your email address below to subscribe to our mailing list. You will receive hands-on guides and carefully written tutorials related to Linux, everything for free.