## -*- mode: python; coding: utf-8 -*-
## DSLreports has a test for bufferbloat. This more or less duplicates
## their current 8 flow test with the (current) exception of not using
## different servers
## it would be nice to have the duplicates be settable on the command line

include("netperf_definitions.inc")
DESCRIPTION="8 down - dslreports dsl test equivalent"
DEFAULTS={'PLOT': "all_scaled"}

DATA_SETS = o([
    ('TCP download BE',
     {'command': find_netperf("TCP_MAERTS", LENGTH, HOST, marking="CS0,CS0"),
      'delay': DELAY,
      'units': 'Mbits/s',
      'runner': 'netperf_demo',
      'duplicates': 8 }),
    ('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) TCP BE1',
     {'command': find_netperf("TCP_RR", TOTAL_LENGTH, HOST, marking="CS0,CS0"),
      'data_transform': 'rr_to_ms',
      'units': 'ms',
      'runner': 'netperf_demo',}),
    ('Ping (ms) TCP BE2',
     {'command': find_netperf("TCP_RR", TOTAL_LENGTH, HOST, marking="CS0,CS0"),
      'data_transform': 'rr_to_ms',
      'units': 'ms',
      'runner': 'netperf_demo',}),
    ('Ping (ms) TCP BE3',
     {'command': find_netperf("TCP_RR", TOTAL_LENGTH, HOST, marking="CS0,CS0"),
      'data_transform': 'rr_to_ms',
      'units': 'ms',
      'runner': 'netperf_demo',}),
    ('Ping (ms) ICMP',
     {'command': find_ping(IP_VERSION, STEP_SIZE, TOTAL_LENGTH, HOST),
      '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': glob('TCP download BE::*'),
                  'label': 'BE'},
                 {'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)}),

    ('ping',
     {'description': 'Ping plot',
      'type': 'timeseries',
      'legend_title': 'Ping (ms)',
      'axis_labels': ['Latency (ms)'],
      'series': [{'data': 'Ping (ms) TCP BE1',
                  'label': 'TCP BE1'},
                 {'data': 'Ping (ms) TCP BE2',
                  'label': 'TCP BE2'},
                 {'data': 'Ping (ms) TCP BE3',
                  'label': 'TCP BE3'},
                 {'data': 'Ping (ms) ICMP',
                  'label': 'ICMP'},
                 {'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)}),

    ('icmp_cdf',
     {'description': 'ICMP CDF plot',
      'type': 'cdf',
      'axis_labels': ['Latency (ms)'],
      'series': [{'data': 'Ping (ms) ICMP',
                  'label': 'Ping (ms)'},
                 ],
      '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': '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, ping (scaled versions)',
      'type': 'meta',
      'subplots': ('download_scaled', 'ping_scaled')}),

    ('all',
     {'description': 'Download, ping (unscaled versions)',
      'type': 'meta',
      'subplots': ('download', 'ping')}),
    ('box_download',
     {'description': 'Download bandwidth box plot',
      'parent': 'download',
      'type': 'box'}),

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

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