Load Tests¶
To do stability testing and performance optimizations, charon provides a load-tester plugin. This plugin allows to set up thousands of tunnels concurrently against the daemon itself or a remote host.
Setup¶
To build and enable the plugin, add
--enable-load-tester
to your ./configure options.
Warning: Never enable the load-testing plugin on productive systems. It provides preconfigured credentials and allows an attacker to authenticate as any user.
To make sure you are aware of this risk, an additional enable switch in strongswan.conf is required to load the plugin.
Testing against self¶
In the simplest case, the the daemon initiates IKE_SAs against self using the loopback interface. This will actually establish the doubled number of IKE_SAs, as the daemon is initiator and responder for each IKE_SA at the same time. Installation of IPsec SAs would fail, as each SA gets installed twice. To simulate the correct behavior, a faked kernel interface can be enabled which does not install the IPsec SAs at the kernel level.
A simple loop-back configuration in /etc/strongswan.conf might look like this:
charon {
# create a new IKE_SA for each CHILD_SA to simulate different clients
reuse_ikesa = no
# turn off denial of service protection
dos_protection = no
plugins {
load-tester {
# enable the plugin
enable = yes
# use 4 threads to initiate connections simultaneously
initiators = 4
# each thread initiates 1000 connections
iterations = 1000
# delay each initiation in each thread by 20ms
delay = 20
# fake the kernel interface to avoid SA conflicts
fake_kernel = yes
}
}
}
This will initiate 4000 IKE_SAs within 20 seconds. You may increase the delay value if your box can not handle that much load, or decrease it to put more load on it. If the daemon starts retransmitting messages, your box probably can not handle all connection attempts.
Testing against remote host¶
The plugin also allows to test against a remote host. This might help to test against a real world configuration. A connection setup to do stress testing of a gateway might look like this:
charon {
reuse_ikesa = no
threads = 32
plugins {
load-tester {
# enable the plugin
enable = yes
# 10000 connections, ten in parallel
initiators = 10
iterations = 1000
# use a delay of 100ms, overall time is: iterations * delay = 100s
delay = 100
# address of the gateway
remote = 1.2.3.4
# IKE-proposal to use
proposal = aes128-sha1-modp1024
# use faster PSK authentication instead of 1024bit RSA
initiator_auth = psk
responder_auth = psk
# request a virtual IP using configuration payloads
request_virtual_ip = yes
# disable IKE_SA rekeying (default)
ike_rekey = 0
# enable CHILD_SA every 60s
child_rekey = 60
# do not delete the IKE_SA after it has been established (default)
delete_after_established = no
# do not shut down the daemon if all IKE_SAs established
shutdown_when_complete = no
}
}
}
Configuration details¶
For public key authentication, the responder uses the "CN=srv, OU=load-test, O=strongSwan" identity. The initiator, each connection attempt uses a different identity in the form "CN=c1-r1, OU=load-test, O=strongSwan", where the first number inidicated the client number, the second the authentication round (if multiple authentication is used).
For PSK authentication, FQDN identities are used. The server uses srv.strongswan.org, the client uses an identity in the form c1-r1.strongswan.org.
For EAP authentication, the client uses a NAI in the form 100000000010001@strongswan.org.
To configure multiple authentication, concatenate multiple methods using, e.g.
initiator_auth = pubkey|psk|eap-md5|eap-aka
The responder uses a hardcoded certificate based on a 1024-bit RSA key (see source:src/libcharon/plugins/load_tester/load_tester_creds.c). This certificate additionally serves as CA certificate. A peer uses the same private key, but generates client certificates on demand signed by the CA certificate. Install the Responder/CA certificate on the remote host to authenticate all clients.
To speed up testing, the load tester plugin implements a special Diffie-Hellman implementation called modpnull. By setting proposal = aes128-sha1-modpnull, this wicked fast DH implementation is used. It does not provide any security at all, but allows to run tests without DH calculation overhead.
There is a list of available configuration options for the load-tester plugin at the strongswan.conf page.