Esempio n. 1
0
        def run():
            # It's safer to restart each time actually...
            server.run_cmd('pkill picoquicdemo')
            # Get rid of the variability of processes
            server.run_cmd([
                "sh", "-c",
                "'cd ~/picoquic; nohup nice --20 ./picoquicdemo -a 1 {} {} -p 4443 2>&1 > /tmp/log_server.log'"
                .format(server_logs, plugins)
            ],
                           daemon=True)
            server_ip = '42.0.0.1'

            # Empty the buffers and let the server start quietly
            time.sleep(0.2)

            # Get rid of the variability of processes
            client_cmd = 'timeout 60 nice --20 ~/picoquic/picoquicdemo -a 1 -4 -G {} {} -l /dev/null {} 4443 2>&1 > /tmp/log_client.log'.format(
                size, plugins, server_ip)
            err = client.run_cmd(client_cmd)

            if err != 0:
                print("client returned err %d" % err)
                return 0

            # Get the file to access it
            client.scp_file_from_node('/tmp/log_client.log', 'log_client.log')
            server.scp_file_from_node('/tmp/log_server.log', 'log_server.log')
            log_client = open('log_client.log')
            lines = log_client.readlines()
            elapsed_ms_str = lines[-2].split()[0]
            if elapsed_ms_str.startswith('-') or len([
                    1 for line in lines if
                    "Received file /doc-{}.html, after {} bytes, closing stream 4"
                    .format(size, size) in line
            ]) == 0:
                print lines
                print "Error for this run..."
                # Relaunch the server
                return 0

            elf_us = 0
            plugin_us = 0
            total_plugin_us = 0
            for line in lines:
                if "ELF_load" in line:
                    elf_us += int(line.split()[-1])
                elif "Plugin_load" in line:
                    plugin_us += int(line.split()[-1])
                elif "Plugin_insert_plugins_from_fnames" in line:
                    total_plugin_us += int(line.split()[-1])

            print "elapsed: %s milliseconds for %s, elf_us %d, plugin_us %d total_plugin_us %d" % (
                elapsed_ms_str, test_name, elf_us, plugin_us, total_plugin_us)
            return float(elapsed_ms_str), elf_us, plugin_us, total_plugin_us
Esempio n. 2
0
def run_benchmark_xp(test_name, setup_nets_opts, store_result_in_db_func,
                     **kwargs):
    global index

    client.run_cmd('pkill picoquic')
    server.run_cmd('pkill picoquic')
    client.run_cmd('pkill ab')
    server.run_cmd('pkill lighttpd')
    client.run_cmd('pkill client')
    server.run_cmd('pkill server')
    client.run_cmd('rm -rf /tmp/*.log /tmp/cache*')
    server.run_cmd('rm -rf /tmp/*.log /tmp/random*')
    client.run_cmd('rm -rf /tmp/plugins')
    server.run_cmd('rm -rf /tmp/plugins')

    client.run_cmd('cp -r ~/picoquic/plugins /tmp')
    server.run_cmd('cp -r ~/picoquic/plugins /tmp')

    plugins = ""
    if "plugins" in setup_nets_opts:
        plugins = setup_nets_opts["plugins"]
    elif test_name.startswith('fec'):
        plugins = '-P /tmp/plugins/fec/{test_name}.plugin'.format(
            test_name=test_name)
    elif test_name.startswith('multipath'):
        plugins = '-P /tmp/plugins/multipath/{test_name}.plugin -P /tmp/plugins/multipath/addresses_filters/filter_only_42_0_0_0_8.plugin'.format(
            test_name=test_name)
    elif test_name != 'plain':
        plugins = '-P /tmp/plugins/{test_name}/{test_name}.plugin'.format(
            test_name=test_name)

    server_logs = "-l /dev/null"

    sysctl_cmds = [
        "sysctl -w net.ipv4.udp_mem='65536 131072 262144'",
        'sysctl -w net.ipv4.udp_rmem_min=16384',
        'sysctl -w net.ipv4.udp_wmem_min=16384'
    ]
    for cmd in sysctl_cmds:
        client.run_cmd(cmd)
        server.run_cmd(cmd)

    file_sizes = kwargs['file_sizes']
    for size in file_sizes:
        print "file size %d" % size

        def run():
            # It's safer to restart each time actually...
            server.run_cmd('pkill picoquicdemo')
            # Get rid of the variability of processes
            server.run_cmd([
                "sh", "-c",
                "'cd ~/picoquic; nohup nice --20 ./picoquicdemo -a 1 {} {} -p 4443 2>&1 > /tmp/log_server.log'"
                .format(server_logs, plugins)
            ],
                           daemon=True)
            server_ip = '42.0.0.1'

            # Empty the buffers and let the server start quietly
            time.sleep(0.2)

            # Get rid of the variability of processes
            client_cmd = 'timeout 60 nice --20 ~/picoquic/picoquicdemo -a 1 -4 -G {} {} -l /dev/null {} 4443 2>&1 > /tmp/log_client.log'.format(
                size, plugins, server_ip)
            err = client.run_cmd(client_cmd)

            if err != 0:
                print("client returned err %d" % err)
                return 0

            # Get the file to access it
            client.scp_file_from_node('/tmp/log_client.log', 'log_client.log')
            server.scp_file_from_node('/tmp/log_server.log', 'log_server.log')
            log_client = open('log_client.log')
            lines = log_client.readlines()
            elapsed_ms_str = lines[-2].split()[0]
            if elapsed_ms_str.startswith('-') or len([
                    1 for line in lines if
                    "Received file /doc-{}.html, after {} bytes, closing stream 4"
                    .format(size, size) in line
            ]) == 0:
                print lines
                print "Error for this run..."
                # Relaunch the server
                return 0

            elf_us = 0
            plugin_us = 0
            total_plugin_us = 0
            for line in lines:
                if "ELF_load" in line:
                    elf_us += int(line.split()[-1])
                elif "Plugin_load" in line:
                    plugin_us += int(line.split()[-1])
                elif "Plugin_insert_plugins_from_fnames" in line:
                    total_plugin_us += int(line.split()[-1])

            print "elapsed: %s milliseconds for %s, elf_us %d, plugin_us %d total_plugin_us %d" % (
                elapsed_ms_str, test_name, elf_us, plugin_us, total_plugin_us)
            return float(elapsed_ms_str), elf_us, plugin_us, total_plugin_us

        results = list(filter(lambda x: x, sorted(run() for _ in range(1))))
        results, elf_us, plugin_us, total_plugin_us = [
            r[0] for r in results if r[0] > 0
        ], results[0][1] if len(results) > 0 else 0, results[0][2] if len(
            results) > 0 else 0, results[0][3] if len(results) > 0 else 0
        median = results[int(len(results) / 2)] if results else 0
        print "index = %d median = %dms elf_us = %d plugin_us = %d total_plugin_us = %d" % (
            index, median, elf_us, plugin_us, total_plugin_us)
        store_result_in_db_func([
            test_name, median, index, size, elf_us, plugin_us, total_plugin_us
        ])

    server.run_cmd('pkill picoquicdemo')
    index += 1
Esempio n. 3
0
def run_vpn(nodes, test_name, setup_nets_opts, store_result_in_db_func, **kwargs):
    server_ip = '42.2.1.1'

    comp.run_cmd_on_client(nodes, 'pkill picoquic')
    comp.run_cmd_on_server(nodes, 'pkill picoquic')
    comp.run_cmd_on_client(nodes, 'pkill ab')
    comp.run_cmd_on_server(nodes, 'pkill lighttpd')
    comp.run_cmd_on_client(nodes, 'pkill client')
    comp.run_cmd_on_server(nodes, 'pkill server')
    comp.run_cmd_on_client(nodes, 'rm -rf /tmp/*.log /tmp/cache*')
    comp.run_cmd_on_server(nodes, 'rm -rf /tmp/*.log /tmp/random*')

    lighttpd_conf = """
server.document-root = "/tmp" 
dir-listing.activate = "enable"
server.pid-file      = "/var/run/lighttpd.pid"
server.port          = 8080
"""

    if test_name == "sp_vpn":
        # Add tun0/tun1
        comp.run_cmd_on_client(nodes, 'ip tuntap add mode tun dev tun0')
        comp.run_cmd_on_client(nodes, 'ip addr add 43.0.0.2/24 dev tun0')
        comp.run_cmd_on_client(nodes, 'ip link set dev tun0 mtu 1400')
        comp.run_cmd_on_client(nodes, 'ip link set dev tun0 up')

        comp.run_cmd_on_client(nodes, 'ip addr add 128.0.0.2/32 dev lo')
        comp.run_cmd_on_client(nodes, 'ip route add 128.0.0.1/32 via 43.0.0.2 dev tun0')

        comp.run_cmd_on_server(nodes, 'ip tuntap add mode tun dev tun1')
        comp.run_cmd_on_server(nodes, 'ip addr add 43.0.0.1/24 dev tun1')
        comp.run_cmd_on_server(nodes, 'ip link set dev tun1 mtu 1400')
        comp.run_cmd_on_server(nodes, 'ip link set dev tun1 up')

        comp.run_cmd_on_server(nodes, 'ip addr add 128.0.0.1/32 dev lo')
        comp.run_cmd_on_server(nodes, 'ip route add 128.0.0.2/32 via 43.0.0.1 dev tun1')

        # Start the VPN server and client
        plugins = "-P ~/picoquic/plugins/datagram/datagram.plugin"
        if setup_nets_opts['multipath']:
            plugins = "-P ~/picoquic/plugins/multipath/multipath_rr.plugin"

        server_logs = ""
        if setup_nets_opts["log_server"]:
            server_logs = "-l {}".format(setup_nets_opts["log_server"])

        comp.run_cmd_on_server(nodes, 'pkill picoquicvpn')
        comp.run_cmd_on_client(nodes, 'pkill picoquicvpn')

        # Unfortunalely, it is a very complicated command, so provide the array directly
        comp.run_cmd_on_server(nodes, ["sh", "-c", "'cd ~/picoquic; nohup ./picoquicvpn {} {} -p 4443 2>&1 > /tmp/log_server.log'".format(server_logs, plugins)], daemon=True)

        time.sleep(1)
        comp.run_cmd_on_client(nodes, ["sh", "-c", "'~/picoquic/picoquicvpn {} {} 4443 2>&1 > /tmp/log_client.log'".format(plugins, server_ip)], daemon=True)
        time.sleep(1)

        lighttpd_conf += 'server.bind = "128.0.0.1"\n'

    comp.run_cmd_on_server(nodes, 'pkill lighttpd')
    comp.run_cmd_on_server(nodes, ["echo", "'%s'" % lighttpd_conf, "> ~/lighttpd.conf"], daemon=True)
    comp.run_cmd_on_server(nodes, ["lighttpd", "-f", "~/lighttpd.conf"], daemon=True)

    file_sizes = kwargs['file_sizes']
    for size in file_sizes:
        print "file size %d" % size
        comp.run_cmd_on_server(nodes, 'dd if=/dev/urandom of=/tmp/random_{size} bs={size} count=1'.format(size=size))

        def run():
            start_time = time.time()
            additional_curl_params = ''
            if test_name == 'sp_vpn':
                additional_curl_params = '--interface {}'.format('128.0.0.2')
            err = comp.run_cmd_on_client(nodes, 'curl {}:8080/random_{} -s --connect-timeout 5 --output /dev/null -w "%{{time_total}}" {} > /tmp/curl.log'.format(
                '128.0.0.1' if test_name == 'sp_vpn' else server_ip, size, additional_curl_params)
            )

            elapsed_ms = (time.time() - start_time) * 1000

            if err != 0:
                print("client returned err %d" % err)
                return 0

                # Get the file to access it
            comp.scp_file_from_client(nodes, '/tmp/curl.log', 'curl.log')
            with open('curl.log') as f:
                lines = f.readlines()
            elapsed_ms = float(lines[-1]) * 1000
            print "elapsed: %f milliseconds for %s" % (elapsed_ms, test_name)
            return elapsed_ms

        results = list(filter(lambda x: x, sorted(run() for _ in range(9))))
        results = [r for r in results if r > 0]
        avg = sum(results) / len(results) if results else 0
        median = results[int(len(results)/2)] if results else 0
        std_dev = sum(abs(x - avg) for x in results) / len(results) if results else 0
        print "median = %dms, avg = %dms, std_dev = %dms" % (median, avg, std_dev)
        store_result_in_db_func([test_name, median, std_dev, size])

    comp.run_cmd_on_server(nodes, 'pkill lighttpd')

    if test_name == 'sp_vpn':
        comp.run_cmd_on_client(nodes, 'pkill picoquicvpn')
        comp.run_cmd_on_server(nodes, 'pkill picoquicvpn')

        comp.run_cmd_on_server(nodes, 'ip tuntap del mode tun dev tun1')
        comp.run_cmd_on_client(nodes, 'ip tuntap del mode tun dev tun0')

        comp.run_cmd_on_client(nodes, 'ip addr del 128.0.0.2/32 dev lo')
        comp.run_cmd_on_server(nodes, 'ip addr del 128.0.0.1/32 dev lo')
Esempio n. 4
0
def run_multipath_xp(nodes, test_name, setup_nets_opts,
                     store_result_in_db_func, **kwargs):
    plugins = ""
    if setup_nets_opts.get('multipath', False):
        plugins = "-P ~/picoquic/plugins/multipath/multipath_rtt.plugin -P ~/picoquic/plugins/multipath/addresses_filters/filter_no_v6_no_10_no_42-3.plugin"
    else:
        plugins = "-P ~/picoquic/plugins/no_pacing/no_pacing.plugin"

    server_logs = ""
    if setup_nets_opts.get("log_server", False):
        server_logs = "-l {}".format(setup_nets_opts["log_server"])

    def relaunch_config():
        comp.run_cmd_on_client(nodes, 'pkill picoquic')
        comp.run_cmd_on_server(nodes, 'pkill picoquic')
        comp.run_cmd_on_client(nodes, 'pkill ab')
        comp.run_cmd_on_server(nodes, 'pkill lighttpd')
        comp.run_cmd_on_client(nodes, 'pkill client')
        comp.run_cmd_on_server(nodes, 'pkill server')
        comp.run_cmd_on_client(nodes, 'rm -rf /tmp/*.log /tmp/cache*')
        comp.run_cmd_on_server(nodes, 'rm -rf /tmp/*.log /tmp/random*')

        comp.run_cmd_on_server(nodes, 'pkill picoquicdemo')
        time.sleep(1)
        # Unfortunalely, it is a very complicated command, so provide the array directly
        comp.run_cmd_on_server(nodes, [
            "sh", "-c",
            "'cd ~/picoquic; nohup ./picoquicdemo {} {} -p 4443 2>&1 > /tmp/log_server.log'"
            .format(server_logs, plugins)
        ],
                               daemon=True)
        time.sleep(1)

    relaunch_config()
    file_sizes = kwargs['file_sizes']
    for size in file_sizes:
        print "file size %d" % size

        def run():
            # It's safer to restart each time actually...
            comp.run_cmd_on_server(nodes, 'pkill picoquicdemo')
            comp.run_cmd_on_server(nodes, [
                "sh", "-c",
                "'cd ~/picoquic; nohup ./picoquicdemo {} {} -p 4443 2>&1 > /tmp/log_server.log'"
                .format(server_logs, plugins)
            ],
                                   daemon=True)
            server_ip = '42.2.1.1'

            # Empty the buffers and let the server start quietly
            time.sleep(0.2)

            client_cmd = 'timeout 30 ~/picoquic/picoquicdemo -G {} {} -l /dev/null {} 4443 2>&1 > /tmp/log_client.log'.format(
                size, plugins, server_ip)
            err = comp.run_cmd_on_client(nodes, client_cmd)

            if err != 0:
                print("client returned err %d" % err)
                relaunch_config()
                return 0

            # Get the file to access it
            comp.scp_file_from_client(nodes, '/tmp/log_client.log',
                                      'log_client.log')
            log_client = open('log_client.log')
            lines = log_client.readlines()
            elapsed_ms_str = lines[-2].split()[0]
            if (elapsed_ms_str.startswith('-')
                    or "Client exit with code = 0" not in lines[-1]):
                print lines[-1]
                print "Error for this run..."
                # Relaunch the server
                relaunch_config()
                return 0

            print "elapsed: %s milliseconds for %s" % (elapsed_ms_str,
                                                       test_name)
            return float(elapsed_ms_str)

        results = list(filter(lambda x: x, sorted(run() for _ in range(9))))
        results = [r for r in results if r > 0]
        avg = sum(results) / len(results) if results else 0
        median = results[int(len(results) / 2)] if results else 0
        std_dev = sum(abs(x - avg)
                      for x in results) / len(results) if results else 0
        print "median = %dms, avg = %dms, std_dev = %dms" % (median, avg,
                                                             std_dev)
        store_result_in_db_func(
            [test_name, median, std_dev, size,
             len(results)])

    comp.run_cmd_on_server(nodes, 'pkill picoquicdemo')
Esempio n. 5
0
def run_fec_xp(nodes, test_name, setup_nets_opts, store_result_in_db_func, **kwargs):
    plugins = ""
    if setup_nets_opts['fec'] and setup_nets_opts['fec_only_end']:
        plugins = "-P ~/picoquic/plugins/fec/fec_rlc_gf256_window_protect_end_of_stream_only_inflight.plugin -P ~/picoquic/plugins/no_pacing/no_pacing.plugin"
    elif setup_nets_opts['fec']:
        plugins = "-P ~/picoquic/plugins/fec/fec_rlc_gf256_window.plugin -P ~/picoquic/plugins/no_pacing/no_pacing.plugin"
    else:
        plugins = "-P ~/picoquic/plugins/no_pacing/no_pacing.plugin"

    server_logs = ""
    if setup_nets_opts["log_server"]:
        server_logs = "-l {}".format(setup_nets_opts["log_server"])

    comp.run_cmd_on_client(nodes, 'pkill picoquic')
    comp.run_cmd_on_server(nodes, 'pkill picoquic')
    comp.run_cmd_on_client(nodes, 'pkill ab')
    comp.run_cmd_on_server(nodes, 'pkill lighttpd')
    comp.run_cmd_on_client(nodes, 'pkill client')
    comp.run_cmd_on_server(nodes, 'pkill server')
    comp.run_cmd_on_client(nodes, 'rm -rf /tmp/*.log /tmp/cache*')
    comp.run_cmd_on_server(nodes, 'rm -rf /tmp/*.log /tmp/random*')
    # Unfortunalely, it is a very complicated command, so provide the array directly
    comp.run_cmd_on_server(nodes, ["sh", "-c", "'cd ~/picoquic; nohup ./picoquicdemo {} {} -p 4443 2>&1 > /tmp/log_server.log'".format(server_logs, plugins)], daemon=True)

    file_sizes = kwargs['file_sizes']
    for size in file_sizes:
        print "file size %d" % size
        def run():
            for cmd in comp.tc_dropper_reset(nodes["comp5"].links["comp1"]['ifname']):
                print nodes["comp5"].name, "should be comp5"
                nodes["comp5"].run_cmd(cmd)
            for cmd in comp.tc_dropper_reset(nodes["comp1"].links["comp5"]['ifname']):
                nodes["comp1"].run_cmd(cmd)
                print nodes["comp1"].name, "should be comp1"
            # It's safer to restart each time actually...
            comp.run_cmd_on_server(nodes, 'pkill picoquicdemo')
            comp.run_cmd_on_server(nodes, ["sh", "-c", "'cd ~/picoquic; nohup ./picoquicdemo {} {} -p 4443 2>&1 > /tmp/log_server.log'".format(server_logs, plugins)], daemon=True)
            server_ip = SERVER_IP
            # Empty the buffers and let the server start quietly
            time.sleep(0.2)

            client_cmd = 'timeout 120 ~/picoquic/picoquicdemo -4 -G {} {} -l /dev/null {} 4443 2>&1 > /tmp/log_client.log'.format(size, plugins, server_ip)
            err = comp.run_cmd_on_client(nodes, client_cmd)

            if err != 0:
                print("client returned err %d" % err)
                return 0

            # Get the file to access it
            comp.scp_file_from_client(nodes, '/tmp/log_client.log', 'log_client.log')
            log_client = open('log_client.log')
            lines = log_client.readlines()
            elapsed_ms_str = lines[-2].split()[0]
            if (elapsed_ms_str.startswith('-') or "Client exit with code = 0" not in lines[-1]):
                print lines[-1]
                print "Error for this run..."
                # Relaunch the server
                return 0

            print "elapsed: %s milliseconds for %s" % (elapsed_ms_str, test_name)
            return float(elapsed_ms_str)

        results = list(filter(lambda x: x, sorted(run() for _ in range(5))))
        results = [r for r in results if r > 0]
        avg = sum(results) / len(results) if results else 0
        median = results[int(len(results)/2)] if results else 0
        std_dev = sum(abs(x - avg) for x in results) / len(results) if results else 0
        print "median = %dms, avg = %dms, std_dev = %dms" % (median, avg, std_dev)
        store_result_in_db_func([test_name, median, std_dev, size])

    comp.run_cmd_on_server(nodes, 'pkill picoquicdemo')