## -*- mode: python; coding: utf-8 -*-

## rrul test specification

include("netperf_definitions.inc")
DESCRIPTION="RTT Fair Realtime Response Under Load"
DEFAULTS={'PLOT': "all_scaled",
          'HOSTS': [
              'flent-fremont.bufferbloat.net',
              'flent-eu.bufferbloat.net',
              'flent-newark.bufferbloat.net',
              'flent-tokyo.bufferbloat.net']}

# This makes sure that four hosts are specified on the command line, and if not
# filles up the HOSTS list with input from the DEFAULTS above (repeating them if
# necessary).
min_host_count(6)

DATA_SETS = o([
    ('TCP upload BE1 %s' % HOSTS[0],
     {'command': find_netperf("TCP_STREAM", LENGTH, HOSTS[0], marking="CS0,CS0"),
      'delay': DELAY,
      'units': 'Mbits/s',
      'runner': 'netperf_demo',}),
    ('TCP upload BE2 %s' % HOSTS[1],
     {'command': find_netperf("TCP_STREAM", LENGTH, HOSTS[1], marking="CS0,CS0"),
      'delay': DELAY,
      'units': 'Mbits/s',
      'runner': 'netperf_demo',}),
    ('TCP upload BE3 %s' % HOSTS[2],
     {'command': find_netperf("TCP_STREAM", LENGTH, HOSTS[2], marking="CS0,CS0"),
      'delay': DELAY,
      'units': 'Mbits/s',
      'runner': 'netperf_demo',}),
    ('TCP upload BE4 %s' % HOSTS[3],
     {'command': find_netperf("TCP_STREAM", LENGTH, HOSTS[3], marking="CS0,CS0"),
       'delay': DELAY,
       'units': 'Mbits/s',
       'runner': 'netperf_demo',}),
    ('TCP upload BE5 %s' % HOSTS[4],
     {'command': find_netperf("TCP_STREAM", LENGTH, HOSTS[4], marking="CS0,CS0"),
       'delay': DELAY,
       'units': 'Mbits/s',
       'runner': 'netperf_demo',}),
    ('TCP upload BE6 %s' % HOSTS[5],
     {'command': find_netperf("TCP_STREAM", LENGTH, HOSTS[5], marking="CS0,CS0"),
       'delay': DELAY,
       'units': 'Mbits/s',
       'runner': 'netperf_demo',}),
    ('TCP upload avg',
     {'apply_to': [glob("TCP upload*", exclude=["TCP upload sum"])],
       'units': 'Mbits/s',
       'runner': 'average',}),
    ('TCP upload sum',
     {'apply_to': [glob("TCP upload*", exclude=["TCP upload avg"])],
       'units': 'Mbits/s',
       'runner': 'sum',}),

    ('TCP download BE1 %s' % HOSTS[0],
     {'command': find_netperf("TCP_MAERTS", LENGTH, HOSTS[0], marking="CS0,CS0"),
      'delay': DELAY,
      'units': 'Mbits/s',
      'runner': 'netperf_demo',}),
    ('TCP download BE2 %s' % HOSTS[1],
     {'command': find_netperf("TCP_MAERTS", LENGTH, HOSTS[1], marking="CS0,CS0"),
      'delay': DELAY,
      'units': 'Mbits/s',
      'runner': 'netperf_demo',}),
    ('TCP download BE3 %s' % HOSTS[2],
     {'command': find_netperf("TCP_MAERTS", LENGTH, HOSTS[2], marking="CS0,CS0"),
      'delay': DELAY,
      'units': 'Mbits/s',
      'runner': 'netperf_demo',}),
    ('TCP download BE4 %s' % HOSTS[3] ,
     {'command': find_netperf("TCP_MAERTS", LENGTH, HOSTS[3], marking="CS0,CS0"),
       'delay': DELAY,
       'units': 'Mbits/s',
       'runner': 'netperf_demo',}),
    ('TCP download BE5 %s' % HOSTS[4] ,
     {'command': find_netperf("TCP_MAERTS", LENGTH, HOSTS[4], marking="CS0,CS0"),
       'delay': DELAY,
       'units': 'Mbits/s',
       'runner': 'netperf_demo',}),
    ('TCP download BE6 %s' % HOSTS[5] ,
     {'command': find_netperf("TCP_MAERTS", LENGTH, HOSTS[5], marking="CS0,CS0"),
       'delay': DELAY,
       'units': 'Mbits/s',
       'runner': 'netperf_demo',}),
    ('TCP download avg',
     {'apply_to': [glob("TCP download*", exclude=["TCP download sum"])],
       'units': 'Mbits/s',
       'runner': 'average',}),
    ('TCP download sum',
     {'apply_to': [glob("TCP download*", exclude=["TCP download avg"])],
       'units': 'Mbits/s',
       'runner': 'sum',}),

    ('Ping (ms) ICMP1 %s' % HOSTS[0],
     {'command': find_ping(IP_VERSION, STEP_SIZE, TOTAL_LENGTH, HOSTS[0]),
      'units': 'ms',
      'runner': 'ping',}),
    ('Ping (ms) ICMP2 %s' % HOSTS[1],
     {'command': find_ping(IP_VERSION, STEP_SIZE, TOTAL_LENGTH, HOSTS[1]),
      'units': 'ms',
      'runner': 'ping',}),
    ('Ping (ms) ICMP3 %s' % HOSTS[2],
     {'command': find_ping(IP_VERSION, STEP_SIZE, TOTAL_LENGTH, HOSTS[2]),
      'units': 'ms',
      'runner': 'ping',}),
    ('Ping (ms) ICMP4 %s' % HOSTS[3],
     {'command': find_ping(IP_VERSION, STEP_SIZE, TOTAL_LENGTH, HOSTS[3]),
      'units': 'ms',
      'runner': 'ping',}),
    ('Ping (ms) ICMP5 %s' % HOSTS[4],
     {'command': find_ping(IP_VERSION, STEP_SIZE, TOTAL_LENGTH, HOSTS[4]),
      'units': 'ms',
      'runner': 'ping',}),
    ('Ping (ms) ICMP6 %s' % HOSTS[5],
     {'command': find_ping(IP_VERSION, STEP_SIZE, TOTAL_LENGTH, HOSTS[5]),
      'units': 'ms',
      'runner': 'ping',}),
    ('Ping (ms) avg',
     {'apply_to': [glob("Ping (ms)*")],
       'units': 'ms',
       'runner': 'average',}),
    ])

PLOTS = o([
    ('download',
     {'description': 'Download bandwidth plot',
      'type': 'timeseries',
      'legend_title': 'TCP download',
      'series': [{'data': 'TCP download BE1 %s' % HOSTS[0],
                  'label': 'BE %s' %HOSTS[0],
                  'linewidth': 2.0},
                 {'data': 'TCP download BE2 %s' % HOSTS[1],
                  'label': 'BE %s' % HOSTS[1] },
                 {'data': 'TCP download BE3 %s' % HOSTS[2],
                  'label': 'BE %s' % HOSTS[2] },
                 {'data': 'TCP download BE4 %s' % HOSTS[3],
                  'label': 'BE %s' % HOSTS[3]},
                 {'data': 'TCP download BE5 %s' % HOSTS[4],
                  'label': 'BE %s' % HOSTS[4]},
                 {'data': 'TCP download BE6 %s' % HOSTS[5],
                  'label': 'BE %s' % HOSTS[5]},
                 {'data': 'TCP download avg',
                  'label': 'Avg',
                  'smoothing': 10,
                  'color': 'black',
                  'linewidth': 2}]}),

    ('download_scaled',
     {'description': 'Download bandwidth w/axes scaled to remove outliers',
      'parent': 'download',
      'scaling': (5,95)}),

    ('upload',
     {'description': 'Upload bandwidth plot',
      'type': 'timeseries',
      'legend_title': 'TCP upload',
      'series': [{'data': 'TCP upload BE1 %s' % HOSTS[0],
                  'label': 'BE %s' % HOSTS[0],
                  'linewidth': 2.0},
                 {'data': 'TCP upload BE2 %s' % HOSTS[1],
                  'label': 'BE %s' % HOSTS[1]},
                 {'data': 'TCP upload BE3 %s' % HOSTS[2],
                  'label': 'BE %s' % HOSTS[2]},
                 {'data': 'TCP upload BE4 %s' % HOSTS[3],
                  'label': 'BE %s' % HOSTS[3]},
                 {'data': 'TCP upload BE5 %s' % HOSTS[4],
                  'label': 'BE %s' % HOSTS[4]},
                 {'data': 'TCP upload BE6 %s' % HOSTS[5],
                  'label': 'BE %s' % HOSTS[5]},
                 {'data': 'TCP upload avg',
                  'label': 'Avg',
                  'smoothing': 10,
                  'color': 'black',
                  'linewidth': 2}]}),

    ('upload_scaled',
     {'description': 'Upload bandwidth w/axes scaled to remove outliers',
      'parent': 'upload',
      'scaling': (5,95)}),

    ('ping',
     {'description': 'Ping plot',
      'type': 'timeseries',
      'legend_title': 'Ping (ms)',
      'axis_labels': ['Latency (ms)'],
      'series': [
                 {'data': 'Ping (ms) ICMP1 %s' % HOSTS[0],
                  'label': 'ICMP %s' % HOSTS[0] },
                 {'data': 'Ping (ms) ICMP2 %s' % HOSTS[1],
                  'label': 'ICMP %s' % HOSTS[1] },
                 {'data': 'Ping (ms) ICMP3 %s' % HOSTS[2],
                  'label': 'ICMP %s' % HOSTS[2] },
                 {'data': 'Ping (ms) ICMP4 %s' % HOSTS[3],
                  'label': 'ICMP %s' % HOSTS[3] },
                 {'data': 'Ping (ms) ICMP5 %s' % HOSTS[4],
                  'label': 'ICMP %s' % HOSTS[4] },
                 {'data': 'Ping (ms) ICMP6 %s' % HOSTS[5],
                  'label': 'ICMP %s' % HOSTS[5] },
                 {'data': 'Ping (ms) avg',
                  'label': 'Avg',
                  'smoothing': 10,
                  'color': 'black',
                  'linewidth': 2}]}),

    ('ping_scaled',
     {'description': 'Ping w/axes scaled to remove outliers',
      'parent': 'ping',
      'scaling': (5,95)}),

    ('ping_cdf',
     {'description': 'Ping CDF plot',
      'type': 'cdf',
      'axis_labels': ['Latency (ms)'],
      'parent': 'ping',
      'cutoff': (DELAY,DELAY)}),

    ('totals',
     {'description': 'Total bandwidth and average ping plot',
      'type': 'timeseries',
      'dual_axes': True,
      'axis_labels': [None, 'Latency (ms)'],
      'series': [{'data': 'TCP download sum',
                  'label': 'Download',
                  'smoothing': 10},
                 {'data': 'TCP upload sum',
                  'label': 'Upload',
                  'smoothing': 10},
                 {'data': 'Ping (ms) avg',
                  'label': 'Ping (ms)',
                  'smoothing': 10,
                  'axis': 2}]}),
    ('totals_scaled',
     {'description': 'Total bandwidth and average ping plot (scaled)',
      'parent': 'totals',
      'scaling': (5,95)}),

    ('all_scaled',
     {'description': 'Download, upload, ping (scaled versions)',
      'type': 'meta',
      'subplots': ('download_scaled', 'upload_scaled', 'ping_scaled')}),

    ('all',
     {'description': 'Download, upload, ping (unscaled versions)',
      'type': 'meta',
      'subplots': ('download', 'upload', 'ping')}),

    ('box_download',
     {'description': 'Download bandwidth box plot',
      'parent': 'download',
      'type': 'box'}),

    ('box_upload',
     {'description': 'Upload bandwidth box plot',
      'parent': 'upload',
      'type': 'box'}),

    ('box_ping',
     {'description': 'Ping box plot',
      'parent': 'ping',
      'type': 'box'}),

    ('box_totals',
     {'description': 'Box plot of totals',
      'parent': 'totals',
      'type': 'box',}),
    ])
