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

include("netperf_definitions.inc")
DESCRIPTION="TCP upload stream w/ToS prio bits"
#
# Special care need to be take for using this on the default
# qdisc MQ which have pfifo_fast assigned to every HW queue.
#
# Setup requirements
# 1. IRQ align CPUs to NIC HW queues
#  E.g. via: set_irq_affinity ethX
#  From: https://github.com/netoptimizer/network-testing/
#
# 2. Force flent subcommands to run the same CPU
#  E.g: taskset -c 2 ./flent -H IP tcp_upload_prio
#
# This will force all measurements to go through the same qdisc.  This
# is needed so the ping/latency tests measures the real property of
# the qdisc and Head-of-Line blocking effect.

DEFAULTS={'PLOT': 'totals'}

DATA_SETS = o([
        ('TCP upload',
         {'command': find_netperf("TCP_STREAM", LENGTH, HOST),
          'delay': DELAY,
          'units': 'Mbits/s',
          'runner': 'netperf_demo',}),

        ('TCP upload2',
         {'command': find_netperf("TCP_STREAM", LENGTH, HOST),
          'delay': DELAY,
          'units': 'Mbits/s',
          'runner': 'netperf_demo',}),

        ('TCP upload total',
         {'apply_to': [glob("TCP upload*")],
          'units': 'Mbits/s',
          'runner': 'sum',}),

        ('Ping (ms) ICMP',
         {'command': find_ping(IP_VERSION, STEP_SIZE, TOTAL_LENGTH, HOST),
          'units': 'ms',
          'runner': 'ping',}),

        ('Ping (ms) ICMP PRIO',
         {'command': find_ping(IP_VERSION, STEP_SIZE, TOTAL_LENGTH, HOST, marking="0x10"),
          'units': 'ms',
          'runner': 'ping',}),

        ('Ping (ms) avg',
         {'apply_to': [glob("Ping (ms)*")],
          'units': 'ms',
          'runner': 'average',}),

        ])

PLOTS = o([
    ('totals',
     {'description': 'Bandwidth and ping plot',
      'type': 'timeseries',
      'dual_axes': True,
      'axis_labels': ['Bandwidth (Mbit/s)','Latency (ms)'],
      'series': [{'data': 'TCP upload',
                  'label': 'Upload (MBit/s)'},
                 {'data': 'TCP upload2',
                  'label': 'Upload2 (MBit/s)'},
                 {'data': 'TCP upload total',
                  'label': 'Total Upload (Mbit/s)',
                  'smoothing': 10,
                  'color': 'green',
                  'linewidth': 3},
                 {'data': 'Ping (ms) ICMP',
                  'label': 'Ping (ms)',
                  'axis': 2},
                 {'data': 'Ping (ms) ICMP PRIO',
                  'label': 'Ping hi-prio (ms)',
                  'axis': 2},
                 {'data': 'Ping (ms) avg',
                  'label': 'Avg Ping (ms)',
                  'smoothing': 10,
                  'color': 'black',
                  'linewidth': 2,
                  'axis': 2},
                                  ]
      }
     ),

    ('ping',
     {'description': 'Ping plot',
      'type': 'timeseries',
      'legend_title': 'Ping (ms)',
      'axis_labels': ['Latency (ms)'],
      'series': [{'data': 'Ping (ms) ICMP',
                  'label': 'ICMP'},
                 {'data': 'Ping (ms) ICMP PRIO',
                  'label': 'Ping hi-prio'},
                 {'data': 'Ping (ms) avg',
                  'label': 'Avg',
                  'smoothing': 10,
                  'color': 'black',
                  'linewidth': 2},
                 ]}),

    ('ping_hiprio',
     {'description': 'Ping plot hi-prio',
      'type': 'timeseries',
      'legend_title': 'Ping (ms)',
      'axis_labels': ['Latency (ms)'],
      'series': [{'data': 'Ping (ms) ICMP PRIO',
                  'label': 'Ping hi-prio'},
                 {'data': 'Ping (ms) ICMP PRIO',
                  'label': 'Ping hi-prio (smoothed)',
                  'smoothing': 10,
                  'linewidth': 2},
                 ]}),

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

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