Commit bf909daf authored by Andreas Schmidt's avatar Andreas Schmidt
Browse files

~= polish notebook

parent 0841f81b
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
@@ -3,6 +3,10 @@ import pandas as pd
import numpy as np
import math
import matplotlib.pyplot as plt
from ipywidgets import interact, interactive
import ipywidgets as widgets
from IPython.display import display


pace_columns = [
                "TransReceivePaceInternal",
@@ -56,6 +60,53 @@ def dts_box(folder, r=None):
    plt.xlabel("E2E Delivery Time [ms]")
    plt.legend()


def live_receiver_dts_cdf(exp, figsize=(16,6), pkt_max=None, protocols=None, dtopt=None):
    df = preprocess("{0}/receiver_{1}.csv".format(exp, "prrt"))
    iterations = len(df)
    if protocols is None:
        protocols = ["prrt","tcp-bbr","tcp-cubic"]
    if pkt_max is None:
        pkt_max = iterations
    t_max = 0
    for proto in protocols:
        df = preprocess("{0}/receiver_{1}.csv".format(exp, proto))
        t_max = max(t_max, df["time"].max())

    lengthSlider = widgets.IntSlider(min=10, max=iterations, step=20, value=100,
                                     continuous_update=False, description="Window:")
    packetSlider = widgets.IntSlider(step=20,max=iterations, continuous_update=False, description='Packet Idx:',)
    play = widgets.Play(value=5, min=1, max=pkt_max, step=1,
                        disabled=False, continuous_update=False)
    widgets.jslink((play, 'value'), (packetSlider, 'value'))
    display(widgets.HBox([packetSlider, play]))
    display(lengthSlider)
    plot = interactive(create_interactive_receiver_dts_cdf(exp, figsize, t_max, protocols, dtopt),
                       packet_idx=play,
                       window=lengthSlider)
    output = plot.children[-1]
    output.layout.height = '350px'
    plot.children = (output,)
    return plot

def create_interactive_receiver_dts_cdf(exp,
                                        figsize,
                                        t_max,
                                        protocols=None,
                                        dtopt=None):
    def _f(packet_idx, window):
        receiver_dts_cdf(exp,
                         r=slice(max(packet_idx - window, 0), packet_idx),
                         figsize=figsize,
                         t_max=t_max,
                         protocols=protocols,
                         dtopt=dtopt,
                         grid=True,
                         legend={"bbox_to_anchor": (1.05, 1.05)}
                         )
    return _f


def receiver_dts_cdf(folder, r=None, protocols=None,
                     grid=False, figsize=(16, 5),
                     export=False, file_name="dts_cdf.pdf",
+32 −9
Original line number Diff line number Diff line
@@ -94,15 +94,38 @@ def experiment_config(folder):
        "app_recv_jitter": exp.at[0,"APP_RECV_JITTER"],
        "app_send_rate": exp.at[0,"Size"] / exp.at[0,"APP_SEND_PACE"] if exp.at[0,"APP_SEND_PACE"] != 0 else np.inf,
        "app_recv_rate": exp.at[0,"Size"] / exp.at[0,"APP_RECV_PACE"] if exp.at[0,"APP_RECV_PACE"] != 0 else np.inf,
        #"btlbuf": exp.at[0,"BTLBUF"]
    }

def duration_inflate(dfs, proto, exp, length):
    last_time = dfs[proto].iloc[-1]["SendT"]
    conf = experiment_config(exp)
    opt = conf["app_recv_delay"] * length * 1000
    return [proto, last_time/1000, opt/1000]
def experiment_config_repr(folder):
    c = experiment_config(folder)
    c["delay"] = "{:.2f}ms".format(c["delay"] * 1000)
    c["jitter"] = "{:.2f}ms".format(c["jitter"] * 1000)
    c["rate"] = "{:.2f}Mbps".format(c["rate"] / (1000**2))
    c["network_pace"] = "{:.2f}ms".format(c["network_pace"]*1000)
    c["size"] = "{}B/packet" .format(c["size"])
    c["bdp"] = "{}KB" .format(c["bdp"] / 1000)
    c["rcvbuf"] = "{}KB".format(c["rcvbuf"] / 1000)
    c["sndbuf"] = "{}KB".format(c["sndbuf"] / 1000)
    c["app_send_delay"] = "{}ms".format(c["app_send_delay"] * 1000)
    c["app_send_jitter"] = "{}ms".format(c["app_send_jitter"] * 1000)
    c["app_send_rate"] = "{}Kbps".format(c["app_send_rate"] / 1000) if c["app_send_rate"] is not np.Inf else "Infinite"
    c["app_recv_delay"] = "{}ms".format(c["app_recv_delay"] * 1000)
    c["app_recv_jitter"] = "{}ms".format(c["app_recv_jitter"] * 1000)
    c["app_recv_rate"] = "{}Kbps".format(c["app_recv_rate"] / 1000) if c["app_recv_rate"] is not np.Inf else "Infinite"
    return pd.DataFrame({k: [v] for k,v in c.items()})

def experiment_duration_inflation(protos, dfs, exp, length):
    rows = [duration_inflate(dfs, proto, exp, length) for proto in protos]
    return pd.DataFrame(rows,columns=["Proto","EXP_ACT [ms]","EXP_OPT [ms]"]).set_index("Proto")
def experiment_duration_inflation(protos, dfs, opt):
    rows = [[proto.upper(),
            dfs[proto].iloc[-1]["SendT"]/1000,
            opt] for proto in protos]

    return pd.DataFrame(rows,columns=["Proto","EXP_ACT [s]","EXP_OPT [s]"]).set_index("Proto")

def aggregated_statistics(dfs, key):
    rows = [[proto.upper(),
             df[key].quantile(0.01),
             df[key].quantile(0.95),
             df[key].quantile(0.99),
             df[key].std(),
            ] for proto, df in dfs.items()]
    return pd.DataFrame(rows,columns=["Proto","1%","95%","99%","STD"]).set_index("Proto")
+44 −130
Original line number Diff line number Diff line
%% Cell type:markdown id: tags:

# X-Pace in Action

%% Cell type:code id: tags:

``` python
from analyze.util import experiment_config, protos, experiment_duration_inflation
from analyze.util import experiment_config, experiment_config_repr, protos, experiment_duration_inflation, aggregated_statistics
from analyze.ipts import ipts_timeseries, ipts_cdf
from analyze.receiver import receiver_dts_timeseries, receiver_dts_cdf
from analyze.receiver import receiver_dts_timeseries, receiver_dts_cdf, live_receiver_dts_cdf
%matplotlib inline

dts_ts_size = (16,6)
dts_length = 500
ipts_ts_size = (12,4)
small_ipts_ts_size = (12,4)
half_small_ipts_ts_size = (16,6)
ipts_ts_size = (16,6)
cdf_size = (16,6)
```

%% Cell type:markdown id: tags:

# Receiving Application Bottleneck

%% Cell type:code id: tags:

``` python
length = 2000
exp = "2018_09_07_15_28_16"; r = slice(1,length)
experiment_config_repr(exp)
```

%% Cell type:markdown id: tags:

## Inter-Packet-Time

%% Cell type:code id: tags:

``` python
dfs = ipts_timeseries(exp,rounds=False,r=r,figsize=half_small_ipts_ts_size)
```

%% Cell type:markdown id: tags:

### Experiment Duration Inflation

%% Cell type:code id: tags:
dfs = ipts_timeseries(exp,rounds=False,r=r,figsize=ipts_ts_size)

``` python
protos = ["prrt","tcp-bbr","tcp-cubic"]
experiment_duration_inflation(protos, dfs, exp, length)
exp_opt = experiment_config(exp)["app_recv_delay"] * length
experiment_duration_inflation(protos, dfs, exp_opt)
```

%% Cell type:markdown id: tags:

## Delivery Time
### Time Series

%% Cell type:code id: tags:

``` python
receiver_dts_timeseries(exp,r=slice(1,dts_length),figsize=dts_ts_size);
```

%% Cell type:markdown id: tags:

### CDF

%% Cell type:code id: tags:

``` python
from ipywidgets import interact, interactive
import ipywidgets as widgets
from analyze.receiver import preprocess
from IPython.display import display

def create_interactive_f(figsize,t_max,length,iterations):
    def _f(start, length):
        end = start
        receiver_dts_cdf(exp,
                         r=slice(max(end - length,0), end),
                         figsize=figsize,
                         t_max=t_max,
                         grid=True,
                         legend={"bbox_to_anchor": (1.05, 1.05)}
                         )
    return _f

def live_receiver_dts_cdf(exp,figsize=cdf_size):
    df = preprocess("{0}/receiver_{1}.csv".format(exp, "prrt"))
    iterations = len(df)
    protos = ["prrt","tcp-bbr","tcp-cubic"]
    t_max = 0
    for proto in protos:
        df = preprocess("{0}/receiver_{1}.csv".format(exp, proto))
        t_max = max(t_max, df["time"].max())

    #widgets.IntSlider(min=1, max=iterations, step=20, value=1)
    lengthSlider = widgets.IntSlider(min=10, max=iterations, step=20, value=100,
                                     continuous_update=False, description="Window:")
    start = 1
    startSlider = widgets.IntSlider(step=20,max=iterations, continuous_update=False, description='Iteration:',)
    play = widgets.Play(value=5, min=1, max=350, step=1,
                        disabled=False, continuous_update=False)
    widgets.jslink((play, 'value'), (startSlider, 'value'))
    display(widgets.HBox([startSlider, play]))
    display(lengthSlider)
    plot = interactive(create_interactive_f(cdf_size,t_max,length,iterations), start=play, length=lengthSlider)
    output = plot.children[-1]
    output.layout.height = '350px'
    plot.children = (output,)
    return plot

display(live_receiver_dts_cdf(exp,figsize=cdf_size))
```

%% Cell type:markdown id: tags:

# Network Bottleneck

%% Cell type:code id: tags:

``` python
length = 2000
exp = "2018_09_07_17_13_32"; r = slice(1,length)
experiment_config(exp)
experiment_config_repr(exp)
```

%% Cell type:code id: tags:
%% Cell type:markdown id: tags:

``` python
dfs = ipts_timeseries(exp,rounds=False,r=r,figsize=half_small_ipts_ts_size)
```
## Inter-Packet Time

%% Cell type:code id: tags:

``` python
last_time = dfs["prrt"].iloc[-1]["SendT"]
conf = experiment_config(exp)
opt = conf["network_pace"] * length * 1000
print(last_time, opt)
dfs = ipts_timeseries(exp,rounds=False,r=r,figsize=ipts_ts_size)

protos = ["prrt","tcp-bbr","tcp-cubic"]
exp_opt = experiment_config(exp)["network_pace"] * length
experiment_duration_inflation(protos, dfs, exp_opt)
```

%% Cell type:markdown id: tags:

## Delivery Time

%% Cell type:code id: tags:

``` python
dfs = receiver_dts_timeseries(exp,r=slice(1,dts_length),figsize=dts_ts_size)
receiver_dts_timeseries(exp,r=slice(1,dts_length),figsize=dts_ts_size);
```

%% Cell type:code id: tags:

``` python
dfs = receiver_dts_cdf(exp,r=r,figsize=cdf_size)
display(live_receiver_dts_cdf(exp,figsize=cdf_size))
```

%% Cell type:markdown id: tags:

# Sender Bottleneck

%% Cell type:code id: tags:

``` python
length = 2500
exp = "2018_09_07_17_20_40"; r = slice(1,length)
experiment_config(exp)
exp = "2018_09_07_17_20_40"
experiment_config_repr(exp)
```

%% Cell type:code id: tags:

``` python
receiver_dts_cdf(exp,r=r,figsize=cdf_size,grid=True);
display(live_receiver_dts_cdf(exp,figsize=cdf_size))
```

%% Cell type:markdown id: tags:

# Internet Bottleneck

%% Cell type:code id: tags:

``` python
exp = "2018_09_07_16_46_10"
r=slice(1,3500)
dtopt=15.8
exp = "2018_09_07_16_46_10"; r=slice(1,3500); dtopt=15.8
experiment_config_repr(exp)
```

%% Cell type:code id: tags:

``` python
experiment_config(exp)
receiver_dts_timeseries(exp,r=slice(1,dts_length),figsize=dts_ts_size, dtopt=dtopt);
```

%% Cell type:code id: tags:

``` python
dfs = receiver_dts_timeseries(exp,r=slice(1,dts_length),figsize=dts_ts_size, dtopt=dtopt)
dfs = receiver_dts_cdf(exp,show=False)
display(live_receiver_dts_cdf(exp,figsize=cdf_size,dtopt=dtopt))
```

%% Cell type:code id: tags:

``` python
dfs = receiver_dts_cdf(exp,r=r,figsize=cdf_size,dtopt=dtopt)
```

%% Cell type:code id: tags:

``` python
print("Proto\t\t1%\t95%\t99%\tSTD")
for proto in protos:
    dts = dfs[proto]["time"]
    print("{:10s}\t{:.3f}\t{:.3f}\t{:.3f}\t{:.3f}".format(proto, dts.quantile(0.01),dts.quantile(0.95),dts.quantile(0.99), dts.std()))
aggregated_statistics(dfs, "time")
```

%% Cell type:markdown id: tags:

# Optimized vs. Non-Optimized

%% Cell type:code id: tags:

``` python
exp = "2018_09_07_16_59_34"
r = slice(1,2500)
protocols = ["tcp-cubic","tcp-cubic-u","tcp-bbr","tcp-bbr-u","prrt"]
dfs = ipts_cdf(exp,
               r=r,
               protocols=protocols,
               figsize=half_small_ipts_ts_size,
               legend={"loc":"upper center", "bbox_to_anchor": (0.43, 0.9)})
```

%% Cell type:code id: tags:

``` python
experiment_config(exp)
```

%% Cell type:code id: tags:

``` python
print("Proto\t\t1%\t99%")
for proto in protocols:
    ipts = dfs[proto]["IPT"]
    print("{:10s}\t{:.3f}\t{:.3f}".format(proto, ipts.quantile(0.01),ipts.quantile(0.99)))
experiment_config_repr(exp)
```

%% Cell type:code id: tags:

``` python
dfs = receiver_dts_timeseries(exp,r=slice(1,250),protocols=protocols,figsize=small_ipts_ts_size)
dfs = ipts_cdf(exp,
               r=r,
               protocols=protocols,
               figsize=ipts_ts_size,
               legend={"loc":"upper center", "bbox_to_anchor": (0.43, 0.9)})
aggregated_statistics(dfs, "IPT")
```

%% Cell type:code id: tags:

``` python
for proto in protocols:
    dts = dfs[proto]["time"]
    print(proto, dts.quantile(0.01),dts.quantile(0.99))
dfs = receiver_dts_timeseries(exp,r=slice(1,250),protocols=protocols,figsize=ipts_ts_size)
aggregated_statistics(dfs, "time")
```

%% Cell type:code id: tags:

``` python
protocols = ["tcp-cubic","tcp-cubic-u","tcp-bbr","tcp-bbr-u","prrt"]
dfs = receiver_dts_cdf(exp,
                       r=r,
                       protocols=protocols,
                       figsize=half_small_ipts_ts_size,
                       legend={"loc":"upper center", "bbox_to_anchor": (0.43, 0.9)})
display(live_receiver_dts_cdf(exp,figsize=cdf_size,protocols=protocols))
```

%% Cell type:markdown id: tags:

# WLAN Bottleneck

%% Cell type:code id: tags:

``` python
length = 2000
exp = "2018_12_06_15_49_59"; r = slice(1,length)
dtopt=3
experiment_config(exp)
length = 2000; exp = "2018_12_06_15_49_59"; r = slice(1,length); dtopt=3; experiment_config_repr(exp)
```

%% Cell type:code id: tags:

``` python
dfs = receiver_dts_cdf(exp,r=r,figsize=cdf_size,dtopt=dtopt)
dfs = receiver_dts_cdf(exp,show=False)
display(live_receiver_dts_cdf(exp,figsize=cdf_size, dtopt=dtopt))
```

%% Cell type:code id: tags:

``` python
print("Proto\t\t1%\t95%\t99%\tSTD")
for proto in protos:
    dts = dfs[proto]["time"]
    print("{:10s}\t{:.3f}\t{:.3f}\t{:.3f}\t{:.3f}".format(proto, dts.quantile(0.01),dts.quantile(0.95),dts.quantile(0.99), dts.std()))
aggregated_statistics(dfs, "time")
```