TL;DR ‐ I put together a setup to measure the performance of IP aliasing in Linux. As the numbers at the bottom of the post describe, observed throughput increases as the number of aliases increase. WTF?
For a couple of months I have been putting together some fancy hacks using IP aliasing feature in Linux, that is, associating more than one IP address to a network interface. The limits of IP aliasing are endless...
$ sudo ifconfig eth0 192.168.1.1 netmask 255.255.0.0 $ for I in `seq 0 254`; do sudo ifconfig eth0:$I 192.168.2.$I; done
But obviously there is a price (overhead) to pay for this at kernel level. To shed some more light into the problem at hand, for experimentation purpose, I setup a simple network as follows.
First, I setup two identical Linux boxes with gigabit ethernet cards (RTL-8169 Gigabit Ethernet [10ec:8169] rev 10) connected through a Huawei gigabit switch. (Cable is CAT6 262M of length 1 meter.) Then, I started creating iperf instances binded to particular IP aliased interfaces. That is, first iperf instance is bind to
eth1:1, second is bind to
eth1:2, and so on. In other words,
Nth iperf instance is bind to
To ease the workflow, I put together a
server.sh script as follows.
server.sh, I'll be able to start as many iperf instances (and necessary IP aliases for them) as I want. Next, I write
client.sh as follows.
Then the workflow becomes relatively simple.
server$ ./server.sh eth1:%d 192.168.2.%d 32 client$ ./client.sh 192.168.2.%d 32 30
While going this further, nobody could stop me from writing a Gnuplot script to visualize these results.
Ok, too much talk so far. Let's get to results. (Timeout is set to 60 seconds.)
As the numbers suggest, Linux IP aliasing does a fairly good job that the overhead imposed by the aliases are nearly negligible. (At least I hope that is something I succeeded in measuring.) But the strange thing is, there is an improvement in the throughput as the number of network interfaces increase. What might be the explanation of this observation? Is my setup mistaken? I will be happy to hear your ideas.