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

## rrul test specification

include("netperf_definitions.inc")
DESCRIPTION="RTT Fair upstream only"
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(4)

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 avg',
     {'apply_to': [glob("TCP upload*", exclude=["TCP upload sum", "TCP upload fairness"])],
       'units': 'Mbits/s',
       'runner': 'average',}),
    ('TCP upload sum',
     {'apply_to': [glob("TCP upload*", exclude=["TCP upload avg", "TCP upload fairness"])],
       'units': 'Mbits/s',
       'runner': 'sum',}),
    ('TCP upload fairness',
     {'apply_to': [glob("TCP upload*", exclude=["TCP upload avg", "TCP upload sum"])],
       'units': 'Idx',
       'runner': 'fairness',}),

    ('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) avg',
     {'apply_to': [glob("Ping (ms)*")],
       'units': 'ms',
       'runner': 'average',}),
    ])

PLOTS = o([
    ('upload',
     {'description': 'Upload bandwidth plot',
      'type': 'timeseries',
      'legend_title': 'TCP upload',
      'series': [{'data': 'TCP upload BE1 %s' % HOSTS[0],
                  'label': 'BE %s' % HOSTS[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 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)}),

    ('box_combine',
     {'description': 'Upload bandwidth combined box',
      'type': 'box_combine',
      'cutoff': (DELAY,DELAY),
      'group_by': 'series',
      'axis_labels': ['Mean bandwidth (Mbits/s)'],
      'series': [{'data': 'TCP upload BE1 %s' % HOSTS[0],
                  'label': 'BE %s' % HOSTS[0],
                  'combine_mode': 'meta:MEAN_VALUE'},
                 {'data': 'TCP upload BE2 %s' % HOSTS[1],
                  'label': 'BE %s' % HOSTS[1],
                  'combine_mode': 'meta:MEAN_VALUE'},
                 {'data': 'TCP upload BE3 %s' % HOSTS[2],
                  'label': 'BE %s' % HOSTS[2],
                  'combine_mode': 'meta:MEAN_VALUE'},
                 {'data': 'TCP upload BE4 %s' % HOSTS[3],
                  'label': 'BE %s' % HOSTS[3],
                  'combine_mode': 'meta:MEAN_VALUE'}]}),
    ('bar_combine',
     {'description': 'Upload bandwidth combined bar',
      'type': 'bar_combine',
      'cutoff': (DELAY,DELAY),
      'group_by': 'series',
      'axis_labels': ['Mean bandwidth (Mbits/s)'],
      'series': [{'data': 'TCP upload BE1 %s' % HOSTS[0],
                  'label': 'BE %s' % HOSTS[0],
                  'combine_mode': 'meta:MEAN_VALUE'},
                 {'data': 'TCP upload BE2 %s' % HOSTS[1],
                  'label': 'BE %s' % HOSTS[1],
                  'combine_mode': 'meta:MEAN_VALUE'},
                 {'data': 'TCP upload BE3 %s' % HOSTS[2],
                  'label': 'BE %s' % HOSTS[2],
                  'combine_mode': 'meta:MEAN_VALUE'},
                 {'data': 'TCP upload BE4 %s' % HOSTS[3],
                  'label': 'BE %s' % HOSTS[3],
                  'combine_mode': 'meta:MEAN_VALUE'}]}),
    ('bar_combine_totals',
     {'description': 'Upload total bandwidth combined bar',
      'type': 'bar_combine',
      'cutoff': (DELAY,DELAY),
      'group_by': 'groups',
      'colour_by': 'series',
      'axis_labels': ['Mean bandwidth (Mbits/s)'],
      'series': [{'data': 'TCP upload sum',
                  'label': 'Mean bandwidth',
                  'combine_mode': 'meta:MEAN_VALUE'}]}),
    ('bar_fairness',
     {'description': 'Jain\'s fairness combined bar plot',
      'type': 'bar_combine',
      'cutoff': (DELAY,DELAY),
      'group_by': 'groups',
      'axis_labels': ['Fairness index'],
      'series': [{'data': 'TCP upload fairness',
                  'label': 'BE %s' % HOSTS[0],
                  'combine_mode': 'meta:MEAN_VALUE'}]}),

    ('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) 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 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': 'Upload, ping (scaled versions)',
      'type': 'meta',
      'subplots': ('upload_scaled', 'ping_scaled')}),

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

    ('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',}),
    ])

include("common.inc")
