Simulation Using Multiple IP Addresses
If you test a server application that makes use of the client's
IP addresses you have to be able to send requests using different
source IP addresses. This can be done using one of:
On a modern Linux machine we recommend using the Any-IP support.
To be able to use different source IP addresses most network
tasks (including the HTTP tasks) allow setting the local IP
address. There is also a set of tasks, the IP Pool tasks, to
manage a pool of IP-addresses per PureLoad worker to make sure
that parallel threads do not use the same IP address at the same
How to configure virtual addresses is platform dependent and
requires general knowledge on how your network is configured. If
you want to create many virtual addresses in bulk and keep the
addresses permanently, you need to consult your OS documentation.
Still, this section gives you an overview on how this is done for
a few different Operation Systems.
The procedure to configure virtual IP addresses under Windows 10
as follows. This can only be performed by a user with
You may have to re-start the system to ensure that the changes
To configure virtual IP addresses in Linux, you use the ifconfig
command with super user privilege.
For example if you network interface is eth0 and the primary IP
address is 192.168.2.1 you use ifconfig as follows:
|ifconfig eth0:1 192.168.2.2 netmask 255.255.255.0 up
ifconfig eth0:2 192.168.2.3 netmask 255.255.255.0 up
This adds two virtual interfaces with IP address 192.168.2.2 and
192.168.2.3. The interface number must be unique for each
interface (for example eth0:1, eth0:2 etc).
Any-IP is the capability to receive packets and establish
incoming connections on IP addresses not explicitly configured on
the host. This allows the host to be configured to respond to any
address in a specified range as if it were local, without actually
needing to configure the address on an interface.
Using Any-IP also requires the socket option IP_TRANSPARENT to be
set for all new sockets created.
IP_TRANSPARENT socket option is not supported by Java and requires a native library in order to work.
The IpSocketInitTask requires the native libpuresock.so library in order to set IP_TRANSPARENT.
A pre-built binary of libpuresock.so is included and will work on
most x86_64 based Linux systems.
If the pre-built binary does not work, a manual compilation and installation is required (see below).
The native library is bundled with PureLoad in C source format in
the PURELOAD-HOME/native/src/puresock directory:
Makefile make build script
puresock.c native library C source
Use 'make' build script to compile and install the native
%> make install
install libpuresock.so ../../../lib
For manual installation, copy libpuresock.so to
The library should be installed on all servers used (i.e all load servers).
Now we can configure a host to respond and send from any IP
address using "ip route add local" command.
For example, to configure a host to respond to any address in 192.168.0/24 as a local address we can do:
|ip route add local 192.168.0/24 dev lo|
Example using IPv6 address 2001:1b70:4292:2B0:9:80::/96:
|ip -6 route add local 2001:1b70:4292:2B0:9:80::/96 dev lo|
Now we can set the source IP address to any address in the
192.168.0/24 and the host is reachable by any 192.168.0/24 address
when received on any host interface.
In addition this requires that routing be set up as expected.
If the real IP address of the host in our example is 10.20.30.40 and is reachable through eth0 on the receiving side, a route must also be added there on the receving side:
|ip route add 192.168.0/24 via 10.20.30.40 dev eth0|
Similar for IPv6, with a real IP address of 2001:0db8:0:f101::1:
|ip -6 route add 2001:1b70:4292:2B0:9:80::/96 via 2001:0db8:0:f101::1 dev eth0|
In addition if we will be generating many connections we
typically want to use IpSocketOptionsTask to set SO_REUSEADDR
A typical scenario looks something like:
The Init sequence is here used to set socket options, Init the
pool of IP addresses, get an IP address and init HTTP using the
assigned IP address.
The first IpSocketInitTask is used to set the SO_REUSEADDR and IP_TRANSPARENT socket option. Next we use the IPPoolInitTask we initialize a pool of source IP addresses to be used: 192.168.0/24. I.e 254 IP addresses starting with 192.168.0.1 up to 192.168.0.254:
The PoolGetTask is used to get an IP address from the pool and assign to a variable (local-ip):
The assigned variable is then used by the HttpInitTask to specify the local (source) address to be used by all HTTP tasks:
After this we can execute any number of HTTP tasks in the "Execute HTTP" sequence.
Finally we must make sure to return the used IP address to the IP
Make sure that the "CleanUp" sequence has Condition "Always"
selected to make sure it's executed even if any previous tasks
For more information about the IP pool tasks, see the section below.
The IPPoolInitTask is only executed once per load test session and creates the pool with addresses.
The pool can be initialized in two ways:
An example where the pool is initiated from a range:
The range creates IP addresses 188.8.131.52 to 184.108.40.206,
excluding all addresses ending with 0. The "Shuffle" option is
used to ensure that the generated numbers are not stored in the
The range can be specified in several ways:
Another example, where the pool is generated by probing the
interface (in this case the physical interfaces e100g0,
e100g1 and e100g3):
Here we exclude all addresses ending with ".1".
To get next available task from the IP pool, the PoolGetTask is
As Pool Name we specify the name of the IP pool created by IPPoolInitTask. We assign the retrieved IP address to the variable "ip". This variable can then be used in other task where we need to specify the local IP Address.
When we do not need the IP Address retrieved by PoolGetTask, we must return it to the pool using PoolReturnTask: