<jupyter_start><jupyter_text>Experiment Parametrization<jupyter_code>exp_dir = './paper_results/'
exp_epoch_size = 2**16<jupyter_output><empty_output><jupyter_text>Imports<jupyter_code>import math
import numpy as np
import pandas as pd

# MatPlotLib
import matplotlib.pylab as pylab
from matplotlib.patches import Rectangle
from matplotlib.ticker import (MultipleLocator, FormatStrFormatter, AutoMinorLocator)

%matplotlib inline

pylab.rcParams['font.size'] = 24
pylab.rcParams['figure.figsize'] = [3*x for x in [3.52, 2.64]]
pylab.rcParams['figure.dpi'] = 100
pylab.rcParams['errorbar.capsize'] = 3
pylab.rcParams['legend.fontsize'] = 16
pylab.rcParams['lines.linewidth'] = 2

gridcolor = '#bbbbbb'

zvalue = 2.576  # 99%<jupyter_output><empty_output><jupyter_text>Load data<jupyter_code>import importlib.util
spec = importlib.util.spec_from_file_location("mn", exp_dir + "/configure.py")
make_network = importlib.util.module_from_spec(spec)
spec.loader.exec_module(make_network)
exp_LBW = make_network.LBW
exp_Q_RATE = make_network.Q_RATE
exp_Q_DEPTH_FRAC = make_network.Q_DEPTH_FRAC
exp_CTH_DEPTH_FRAC = make_network.CTH_DEPTH_FRAC
exp_Q_DEPTH = make_network.Q_DEPTH
exp_CTH_DEPTH = make_network.CTH_DEPTH
exp_CTH_TIMEDELTA = make_network.CTH_TIMEDELTA

print('LBW:           ', exp_LBW, 'Mb/s')
print('Q_RATE:        ', exp_Q_RATE, 'Packets/Second')
print('Q_DEPTH:       ', exp_Q_DEPTH, 'Packets')
print('Q_DEPTH_FRAC:  ', exp_Q_DEPTH_FRAC)
print('CTH_DEPTH:     ', exp_CTH_DEPTH, 'Packets')
print('CTH_DEPTH_FRAC:', exp_CTH_DEPTH_FRAC)
print('CTH_TIMEDELTA: ', exp_CTH_TIMEDELTA, 'Microseconds')
fns = []
flows = []
fns = ['s1-reports.csv', 's2-reports.csv', 's3-reports.csv', 's4-reports.csv', 's5-reports.csv', 's6-reports.csv', 's7-reports.csv']
flows = [
    {'id': 11, 'name': 'green', 'color': '#009900', 'psrc': 3, 'pdst': 5, 'path': 'C–E'},
    {'id': 5, 'name': 'teal', 'color': '#009999', 'psrc': 1, 'pdst': 5, 'path': 'B–E'},
    {'id': 26, 'name': 'orange', 'color': '#FF8000', 'psrc': 3, 'pdst': 7, 'path': 'C–G'},
    {'id': 3, 'name': 'red', 'color': '#CC0000', 'psrc': 1, 'pdst': 7, 'path': 'A–H'}
]

for fn in fns:
    tmp1 = pd.read_csv(exp_dir + '/logs/' + fn)
    tmp1['eepoch'] = tmp1['eepoch'] - tmp1['eepoch'].min() + 1 - math.floor(5e6/exp_epoch_size)
    
    for flow in flows:
        if 'reports' not in flow:
            flow['reports'] = pd.DataFrame()
        tmp2 = tmp1[(tmp1['flow'] == flow['id']) & (tmp1['psrc'] == flow['psrc']) & (tmp1['pdst'] == flow['pdst'])]
        flow['reports'] = pd.concat([flow['reports'], tmp2])

last_epoch = 0
for flow in flows:
    flow['label'] = '{} ({})'.format(flow['name'].title(), flow['path'])
    flow['reports']['epoch'] = flow['reports']['epoch'] \
                               - flow['reports']['epoch'].min() + 1 - math.floor(5e6/exp_epoch_size)
    last_epoch = max(last_epoch, flow['reports']['epoch'].max())
    flow['reports'] = flow['reports'][flow['reports']['epoch'] > 0]
    flow['reports']['ibits'] = flow['reports']['ibytes']*8
    flow['reports']['ebits'] = flow['reports']['ebytes']*8

last_epoch = math.ceil(60e6/exp_epoch_size)
print('last epoch:', last_epoch)<jupyter_output>last epoch: 916<jupyter_text>Figures  Upper part of Figure 6(b) – Provided bandwidth for the Red Traffic.<jupyter_code>beg = 10
end = 50

show_acc = False
show_flows = ['red']
show_legend = True

fig = pylab.figure(figsize=[3*3.52, 1.5*2.64])
ax1 = fig.add_subplot(111)
ax2 = ax1.twiny()

yacum = None
xacum = None

for flow in flows:
    if flow['name'] not in show_flows:
        continue
    df = flow['reports']
    df = df[(df['epoch'] >= ((beg*1e6)/exp_epoch_size)) & (df['epoch'] <= ((end*1e6)/exp_epoch_size))]
    x = df['epoch']/(1e6/exp_epoch_size)

    y = df['ibits']*(1/exp_epoch_size)
    ax1.plot(x, y, label='Received', color='#AAAAAA', ls='-', lw=2)
    
    y = df['ebits']*(1/exp_epoch_size)
    ax1.plot(x, y, label='Transmitted', color=flow['color'], lw=2)
    
    if yacum is None:
        xacum = np.array(x)
        yacum = np.array(y)
    else:
        yacum = yacum + np.array(y)

if show_acc is True:
    ax1.plot(xacum, yacum, label='Accumulated', lw=1, c='k')
ax1.hlines(25, beg, end, lw=2, color='k', ls=':')
ax1.text(15, 25.25, 'SLO Threshold', size=16, horizontalalignment='center')

# ax1.set_xlabel('Experiment Second')
ax1.set_xlim(beg, end)
ax1.set_xticks(range(beg, end + 1, 5))
ax1.tick_params(length=0)
ax1.set_xticklabels(ax1.get_xticks(), fontsize=18, color='w')

ax2.set_xlabel('Epoch')
ax2.set_xlim(((beg*1e6)/exp_epoch_size), ((end*1e6)/exp_epoch_size))
ax2.set_xticklabels([int(x) for x in ax2.get_xticks()], fontsize=18)

ax1.set_axisbelow(True)
ax1.grid(ls=':', axis='both', which='both', c=gridcolor)

ax1.set_ylabel('Bandwidth (Mbps)')
ax1.set_ylim(21.5, 32.5)
ax1.set_yticks(range(22, 32 + 1, 2))
ax1.set_yticklabels([int(x) for x in ax1.get_yticks()], fontsize=18)
ax1.yaxis.set_minor_locator(MultipleLocator(1))

if show_legend is True:
    ax1.legend(loc='center right')

pylab.tight_layout()
pylab.savefig(exp_dir + 'upperfig6b.pdf', transparent=True)<jupyter_output><empty_output><jupyter_text>Lower part of Figure 6(b) – Packet drops for the Red Traffic.<jupyter_code>beg = 10
end = 50

show_acc = False
show_flows = ['red']
show_legend = False

fig = pylab.figure(figsize=[3*3.52, 1.5*2.64])
ax1 = fig.add_subplot(111)
ax2 = ax1.twiny()

yacum = None
xacum = None

for flow in flows:
    if flow['name'] not in show_flows:
        continue
    df = flow['reports']
    df = df[(df['epoch'] >= ((beg*1e6)/exp_epoch_size)) & (df['epoch'] <= ((end*1e6)/exp_epoch_size))]
    x = df['epoch']/(1e6/exp_epoch_size)
    y = df['drops']*100/df['ipkts']
    
    ax1.plot(x, y, label=flow['label'], color=flow['color'], lw=2)
    
    if yacum is None:
        xacum = np.array(x)
        yacum = np.array(y)
    else:
        yacum = yacum + np.array(y)

if show_acc is True:
    ax1.plot(xacum, yacum, label='Accumulated', lw=1, c='k')

ax1.set_xlabel('Experiment Second')
ax1.set_xlim(beg, end)
ax1.set_xticks(range(beg, end + 1, 5))
ax1.set_xticklabels(ax1.get_xticks(), fontsize=18)

# ax2.set_xlabel('Epoch')
ax2.set_xlim(((beg*1e6)/exp_epoch_size), ((end*1e6)/exp_epoch_size))
ax2.set_xticklabels([int(x) for x in ax2.get_xticks()], fontsize=18, color='w')
ax2.tick_params(length=0)

ax1.set_axisbelow(True)
ax1.grid(ls=':', axis='both', which='both', c=gridcolor)

ax1.set_ylabel('Packet Drops (%)')
ax1.set_ylim(-1.25, 26.25)
ax1.set_yticks(range(0, 25 + 1, 5))
ax1.set_yticklabels([int(x) for x in ax1.get_yticks()], fontsize=18)
ax1.yaxis.set_minor_locator(MultipleLocator(5))

if show_legend is True:
    ax1.legend(loc='center')

pylab.tight_layout()
pylab.savefig(exp_dir + 'lowerfig6b.pdf', transparent=True)<jupyter_output><empty_output><jupyter_text>Figure 6(c) – Arrival rate (in Mb/s) for traffic being forwarded by Node N3.<jupyter_code>beg = 10
end = 50

fig = pylab.figure()
ax1 = fig.add_subplot(111)
ax2 = ax1.twiny()

yacum = None
xacum = None

for flow in flows:
    df = flow['reports']
    df = df[(df['epoch'] >= ((beg*1e6)/exp_epoch_size)) & (df['epoch'] <= ((end*1e6)/exp_epoch_size))]
    x = df['epoch']/(1e6/exp_epoch_size)
    y = df['ibits']*(1/exp_epoch_size)
    
    ax1.plot(x, y, label=flow['label'], color=flow['color'], lw=2)
    
    if yacum is None:
        xacum = np.array(x)
        yacum = np.array(y)
    else:
        yacum = yacum + np.array(y)

ax1.plot(xacum, yacum, label='Accumulated', ls='--', lw=2, c='k')
ax1.hlines(100, beg, end, lw=2, color='k', ls=':')
ax1.text(beg + 10, 103, 'Link Capacity', size=16, horizontalalignment='center')
ax1.hlines(50, beg, end, lw=2, color='k', ls=':')
ax1.text(beg + 10, 53, 'Suspicion Threshold', size=16, horizontalalignment='center')

ax1.set_xlabel('Experiment Second')
ax1.set_xlim(beg, end)
ax1.set_xticks(range(beg, end + 1, 5))
ax1.set_xticklabels(ax1.get_xticks(), fontsize=18)

ax2.set_xlabel('Epoch')
ax2.set_xlim(((beg*1e6)/exp_epoch_size), ((end*1e6)/exp_epoch_size))
ax2.set_xticklabels([int(x) for x in ax2.get_xticks()], fontsize=18)

ax1.set_axisbelow(True)
ax1.grid(ls=':', axis='both', which='both', c=gridcolor)

ax1.set_ylabel('Arrival Bitrate at Node $N_{3}$ (Mbps)')
ax1.set_ylim(-6, 126)
ax1.set_yticks(range(0, 120 + 1, 20))
ax1.set_yticklabels([int(x) for x in ax1.get_yticks()], fontsize=18)
ax1.yaxis.set_minor_locator(MultipleLocator(10))

ax1.legend(loc='upper right')

pylab.tight_layout()
pylab.savefig(exp_dir + 'fig6c.pdf', transparent=True)<jupyter_output><empty_output><jupyter_text>Extra Figures  Reports  Reporting Reasons<jupyter_code>for f in flows:
    reps = f['reports']
    
    reps = reps[(reps['epoch'] >= 305) & (reps['epoch'] <= 625)]
    print('#', f['name'].title())
    flg = True
    slic = reps[(reps['cps'].apply(lambda x: ('^' in x) or ('c' in x)))]
    if len(slic):
        print('Contention ({})'.format(len(slic)))
        flg = False
        display(slic)
        
    slic = reps[(reps['sps'].apply(lambda x: ('s' in x)))]
    if len(slic):
        print('Suspicion ({})'.format(len(slic)))
        flg = False
        display(slic)

    slic = reps[(reps['hds'] > 0)]
    if len(slic):
        print('High Delayed Packets ({})'.format(len(slic)))
        flg = False
        display(slic)
        
    slic = reps[(reps['drops'] > 0)]
    if len(slic):
        print('Drops ({})'.format(len(slic)))
        flg = False
        display(slic)
    
    if f['name'] == 'red':
        BW_SLA = (25e6/8)*(2**16/1e6)  # 25 Mbps SLA
        slic = reps[(reps['ebytes'] < BW_SLA) & (reps['drops'] > 0)]
        if len(slic):
            print('Low Goodput ({})'.format(len(slic)))
            flg = False
            display(slic)
        
    if flg:
        print('    nothing to display\n')<jupyter_output># Green
Contention (210)<jupyter_text>Raw Reports<jupyter_code>raw_reports = None

for f in flows:
    reps = f['reports']
    reps['flow'] =  [f['name'].title()]*len(reps)

    if f['name'] != 'red':
        slic = reps[(reps['cps'].apply(lambda x: ('^' in x) or ('c' in x)))
                    | (reps['sps'].apply(lambda x: ('s' in x)))
                    | (reps['hds'] > 0)
                    | (reps['drops'] > 0)]
    else:
        BW_SLA = (25e6/8)*(2**16/1e6)  # 25 Mbps SLA
        slic = reps[(reps['cps'].apply(lambda x: ('^' in x) or ('c' in x)))
                    | (reps['sps'].apply(lambda x: ('s' in x)))
                    | (reps['hds'] > 0)
                    | (reps['drops'] > 0)
                    | ((reps['ebytes'] < BW_SLA) & (reps['drops'] > 0))]
    
    
    if raw_reports is None:
        raw_reports = slic
    else:
        raw_reports = pd.concat([raw_reports, slic])
        
display(raw_reports)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1914458391445839, 'fraction_numerical': 0.03672710367271037, 'mean_word_length': 4.00046490004649, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 44, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '181523', 'license': 'MIT', 'n_tokens_mistral': 4705, 'n_tokens_neox': 4445, 'n_words': 805, 'path': 'Experiments/Waypoint/experiments/waypoint/genfigures.ipynb', 'repo_name': 'gabrielvassoler/intsight-bmv2', 'size': '10755'}