Project

General

Profile

Load Tests » History » Version 7

« Previous - Version 7/23 (diff) - Next » - Current version
Martin Willi, 09.12.2008 10:26


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-tests

to your ./configure flags.
----
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.
----
Due a bug in the 4.2.9 release, load tests against self fails. Apply r4671 if you want to do tests against 127.0.0.1 with this release.
----

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
            # setup all tunnels in 100 seconds
            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
            auth = psk
            # request a virtual IP using configuration payloads
            request_virtual_ip = yes
        }
    }
}

Configuration details

The configuration currently uses a hardcoded "_CN=srv, OU=load-test, O=strongSwan_" responder identity. For the initiator, each connection attempt uses a different identity in the form "_CN=cli-1, OU=load-test, O=strongSwan_".

The responder uses a hardcoded certificate based on a [browser:trunk/src/charon/plugins/load_tester/load_tester_creds.c 1024-bit RSA key]. 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.

Alternatively, faster preshared key authentication can be used by setting auth = psk.

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 strongswanconf page.