## -*- mode: python; coding: utf-8 -*-
## Regrettably netperf cannot generate the data rrul needs for SCTP
## or my sctp implementation is broken or both.
## rrul test specification

include("netperf_definitions.inc")
DESCRIPTION="SCTP vs TCP"
DEFAULTS={'PLOT': "all_scaled"}

DATA_SETS = o([
    ('TCP upload CS0',
     {'command': find_netperf("TCP_STREAM", LENGTH, HOST, marking="CS0,CS0"),
      'delay': DELAY,
      'units': 'Mbits/s',
      'runner': 'netperf_demo',}),
    ('SCTP upload CS0',
     {'command': find_netperf("SCTP_STREAM", LENGTH, HOST, marking="CS0,CS0"),
      'delay': DELAY,
      'units': 'Mbits/s',
      'runner': 'netperf_demo',}),
    ('TCP upload CS1',
     {'command': find_netperf("TCP_STREAM", LENGTH, HOST, marking="CS1,CS1"),
      'delay': DELAY,
      'units': 'Mbits/s',
      'runner': 'netperf_demo',}),
    ('SCTP upload CS1',
     {'command': find_netperf("SCTP_STREAM", LENGTH, HOST, marking="CS1,CS1"),
       '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',}),
    ('SCTP upload avg',
     {'apply_to': [glob("SCTP upload*", exclude=["SCTP upload sum"])],
       'units': 'Mbits/s',
       'runner': 'average',}),
    ('SCTP upload sum',
     {'apply_to': [glob("SCTP upload*", exclude=["SCTP upload avg"])],
       'units': 'Mbits/s',
       'runner': 'sum',}),

# FIXME- grok globbing We want just *upload*

    ('Upload avg',
     {'apply_to': [glob("*upload avg*", exclude=["Upload sum"])],
       'units': 'Mbits/s',
       'runner': 'average',}),
    ('Upload sum',
     {'apply_to': [glob("*upload sum*", exclude=["Upload avg"])],
       'units': 'Mbits/s',
       'runner': 'sum',}),

    ('TCP download CS0',
     {'command': find_netperf("TCP_MAERTS", LENGTH, HOST, marking="CS0,CS0"),
      'delay': DELAY,
      'units': 'Mbits/s',
      'runner': 'netperf_demo',}),
    ('SCTP download CS0',
     {'command': find_netperf("SCTP_STREAM_MANY", LENGTH, HOST, marking="CS0,CS0"),
      'delay': DELAY,
      'units': 'Mbits/s',
      'runner': 'netperf_demo',}),
    ('TCP download CS1',
     {'command': find_netperf("TCP_MAERTS", LENGTH, HOST, marking="CS1,CS1"),
      'delay': DELAY,
      'units': 'Mbits/s',
      'runner': 'netperf_demo',}),
    ('SCTP download CS1',
     {'command': find_netperf("SCTP_STREAM_MANY", LENGTH, HOST, marking="CS1,CS1"),
       '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',}),
    ('SCTP download avg',
     {'apply_to': [glob("SCTP download*", exclude=["SCTP download sum"])],
       'units': 'Mbits/s',
       'runner': 'average',}),
    ('TCP download sum',
     {'apply_to': [glob("TCP download*", exclude=["TCP download avg"])],
       'units': 'Mbits/s',
       'runner': 'sum',}),
    ('SCTP download sum',
     {'apply_to': [glob("SCTP download*", exclude=["SCTP download avg"])],
       'units': 'Mbits/s',
       'runner': 'sum',}),

# Fixme, grok globbing

    ('Download avg',
     {'apply_to': [glob("*download*", exclude=["SCTP download sum"])],
       'units': 'Mbits/s',
       'runner': 'average',}),
    ('Download sum',
     {'apply_to': [glob("*download*", exclude=["TCP download avg"])],
       'units': 'Mbits/s',
       'runner': 'sum',}),

    ('Ping (ms) UDP CS0',
     {'command': find_netperf("UDP_RR", TOTAL_LENGTH, HOST, marking="CS0,CS0"),
      'data_transform': 'rr_to_ms',
      'units': 'ms',
      'runner': 'netperf_demo',}),
    ('Ping (ms) SCTP CS0',
     {'command': find_netperf("SCTP_RR", TOTAL_LENGTH, HOST, marking="CS0,CS0"),
      'data_transform': 'rr_to_ms',
      'units': 'ms',
      'runner': 'netperf_demo',}),
    ('Ping (ms) TCP CS0',
     {'command': find_netperf("TCP_RR", TOTAL_LENGTH, HOST),
      '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': 'TCP download CS0',
                  'label': 'TCP CS0',
                  'linewidth': 2.0},
                 {'data': 'TCP download CS1',
                  'label': 'TCP CS1'},
                 {'data': 'SCTP download CS0',
                  'label': 'SCTP CS0'},
                 {'data': 'SCTP download CS1',
                  'label': 'SCTP CS1'},
                 {'data': 'TCP download avg',
                  'label': 'Avg',
                  'smoothing': 10,
                  'color': 'black',
                  'linewidth': 2},
                 {'data': 'SCTP 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 CS0',
                  'label': 'TCP CS0',
                  'linewidth': 2.0},
                 {'data': 'TCP upload CS1',
                  'label': 'TCP CS1'},
                 {'data': 'SCTP upload CS0',
                  'label': 'SCTP CS0'},
                 {'data': 'SCTP upload CS1',
                  'label': 'SCTP CS1'},
                 {'data': 'TCP upload avg',
                  'label': 'Avg',
                  'smoothing': 10,
                  'color': 'black',
                  'linewidth': 2},
                 {'data': 'SCTP 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) UDP CS0',
                  'label': 'UDP CS0'},
                 {'data': 'Ping (ms) SCTP CS0',
                  'label': 'SCTP CS0'},
                 {'data': 'Ping (ms) TCP CS0',
                  'label': 'TCP CS0'},
                 {'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': 'Download sum',
                  'label': 'Download',
                  'smoothing': 10},
                 {'data': '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',}),

    ('qq_icmp',
     {'description': 'Q-Q plot of ICMP pings',
      'type': 'qq',
      'series': [{'data': 'Ping (ms) ICMP',
                  'label': 'Latency (ms)'},
                 ]}),

    ('qq_download',
     {'description': 'Q-Q plot of total download bandwidth',
      'type': 'qq',
      'series': [{'data': 'Download sum',
                  'label': 'Download (Mbps)'},
                 ]}),

    ('qq_upload',
     {'description': 'Q-Q plot of total upload bandwidth',
      'type': 'qq',
      'series': [{'data': 'Upload sum',
                  'label': 'Upload (Mbps)'},
                 ]}),
    ])
