Commit bf909daf authored by Andreas Schmidt's avatar Andreas Schmidt

~= polish notebook

parent 0841f81b
......@@ -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",
......
......@@ -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")
......@@ -13,16 +13,14 @@
"metadata": {},
"outputs": [],
"source": [
"from analyze.util import experiment_config, protos, experiment_duration_inflation\n",
"from analyze.util import experiment_config, experiment_config_repr, protos, experiment_duration_inflation, aggregated_statistics\n",
"from analyze.ipts import ipts_timeseries, ipts_cdf\n",
"from analyze.receiver import receiver_dts_timeseries, receiver_dts_cdf\n",
"from analyze.receiver import receiver_dts_timeseries, receiver_dts_cdf, live_receiver_dts_cdf\n",
"%matplotlib inline\n",
"\n",
"dts_ts_size = (16,6)\n",
"dts_length = 500\n",
"ipts_ts_size = (12,4)\n",
"small_ipts_ts_size = (12,4)\n",
"half_small_ipts_ts_size = (16,6)\n",
"ipts_ts_size = (16,6)\n",
"cdf_size = (16,6)"
]
},
......@@ -40,7 +38,8 @@
"outputs": [],
"source": [
"length = 2000\n",
"exp = \"2018_09_07_15_28_16\"; r = slice(1,length)"
"exp = \"2018_09_07_15_28_16\"; r = slice(1,length)\n",
"experiment_config_repr(exp)"
]
},
{
......@@ -56,32 +55,18 @@
"metadata": {},
"outputs": [],
"source": [
"dfs = ipts_timeseries(exp,rounds=False,r=r,figsize=half_small_ipts_ts_size)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Experiment Duration Inflation"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dfs = ipts_timeseries(exp,rounds=False,r=r,figsize=ipts_ts_size)\n",
"\n",
"protos = [\"prrt\",\"tcp-bbr\",\"tcp-cubic\"]\n",
"experiment_duration_inflation(protos, dfs, exp, length)"
"exp_opt = experiment_config(exp)[\"app_recv_delay\"] * length\n",
"experiment_duration_inflation(protos, dfs, exp_opt)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Delivery Time\n",
"### Time Series"
"## Delivery Time"
]
},
{
......@@ -93,61 +78,12 @@
"receiver_dts_timeseries(exp,r=slice(1,dts_length),figsize=dts_ts_size);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### CDF"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from ipywidgets import interact, interactive\n",
"import ipywidgets as widgets\n",
"from analyze.receiver import preprocess\n",
"from IPython.display import display\n",
"\n",
"def create_interactive_f(figsize,t_max,length,iterations):\n",
" def _f(start, length):\n",
" end = start\n",
" receiver_dts_cdf(exp,\n",
" r=slice(max(end - length,0), end),\n",
" figsize=figsize,\n",
" t_max=t_max,\n",
" grid=True,\n",
" legend={\"bbox_to_anchor\": (1.05, 1.05)}\n",
" )\n",
" return _f\n",
"\n",
"def live_receiver_dts_cdf(exp,figsize=cdf_size):\n",
" df = preprocess(\"{0}/receiver_{1}.csv\".format(exp, \"prrt\"))\n",
" iterations = len(df)\n",
" protos = [\"prrt\",\"tcp-bbr\",\"tcp-cubic\"]\n",
" t_max = 0\n",
" for proto in protos:\n",
" df = preprocess(\"{0}/receiver_{1}.csv\".format(exp, proto))\n",
" t_max = max(t_max, df[\"time\"].max())\n",
" \n",
" #widgets.IntSlider(min=1, max=iterations, step=20, value=1)\n",
" lengthSlider = widgets.IntSlider(min=10, max=iterations, step=20, value=100, \n",
" continuous_update=False, description=\"Window:\")\n",
" start = 1\n",
" startSlider = widgets.IntSlider(step=20,max=iterations, continuous_update=False, description='Iteration:',)\n",
" play = widgets.Play(value=5, min=1, max=350, step=1,\n",
" disabled=False, continuous_update=False)\n",
" widgets.jslink((play, 'value'), (startSlider, 'value'))\n",
" display(widgets.HBox([startSlider, play]))\n",
" display(lengthSlider)\n",
" plot = interactive(create_interactive_f(cdf_size,t_max,length,iterations), start=play, length=lengthSlider)\n",
" output = plot.children[-1]\n",
" output.layout.height = '350px'\n",
" plot.children = (output,)\n",
" return plot\n",
" \n",
"display(live_receiver_dts_cdf(exp,figsize=cdf_size))"
]
},
......@@ -166,16 +102,14 @@
"source": [
"length = 2000\n",
"exp = \"2018_09_07_17_13_32\"; r = slice(1,length)\n",
"experiment_config(exp)"
"experiment_config_repr(exp)"
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "markdown",
"metadata": {},
"outputs": [],
"source": [
"dfs = ipts_timeseries(exp,rounds=False,r=r,figsize=half_small_ipts_ts_size)"
"## Inter-Packet Time"
]
},
{
......@@ -184,10 +118,18 @@
"metadata": {},
"outputs": [],
"source": [
"last_time = dfs[\"prrt\"].iloc[-1][\"SendT\"]\n",
"conf = experiment_config(exp)\n",
"opt = conf[\"network_pace\"] * length * 1000\n",
"print(last_time, opt)"
"dfs = ipts_timeseries(exp,rounds=False,r=r,figsize=ipts_ts_size)\n",
"\n",
"protos = [\"prrt\",\"tcp-bbr\",\"tcp-cubic\"]\n",
"exp_opt = experiment_config(exp)[\"network_pace\"] * length\n",
"experiment_duration_inflation(protos, dfs, exp_opt)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Delivery Time"
]
},
{
......@@ -196,7 +138,7 @@
"metadata": {},
"outputs": [],
"source": [
"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);"
]
},
{
......@@ -205,7 +147,7 @@
"metadata": {},
"outputs": [],
"source": [
"dfs = receiver_dts_cdf(exp,r=r,figsize=cdf_size)"
"display(live_receiver_dts_cdf(exp,figsize=cdf_size))"
]
},
{
......@@ -221,9 +163,8 @@
"metadata": {},
"outputs": [],
"source": [
"length = 2500\n",
"exp = \"2018_09_07_17_20_40\"; r = slice(1,length)\n",
"experiment_config(exp)"
"exp = \"2018_09_07_17_20_40\"\n",
"experiment_config_repr(exp)"
]
},
{
......@@ -232,7 +173,7 @@
"metadata": {},
"outputs": [],
"source": [
"receiver_dts_cdf(exp,r=r,figsize=cdf_size,grid=True);"
"display(live_receiver_dts_cdf(exp,figsize=cdf_size))"
]
},
{
......@@ -248,9 +189,8 @@
"metadata": {},
"outputs": [],
"source": [
"exp = \"2018_09_07_16_46_10\"\n",
"r=slice(1,3500)\n",
"dtopt=15.8"
"exp = \"2018_09_07_16_46_10\"; r=slice(1,3500); dtopt=15.8\n",
"experiment_config_repr(exp)"
]
},
{
......@@ -259,7 +199,7 @@
"metadata": {},
"outputs": [],
"source": [
"experiment_config(exp)"
"receiver_dts_timeseries(exp,r=slice(1,dts_length),figsize=dts_ts_size, dtopt=dtopt);"
]
},
{
......@@ -268,7 +208,8 @@
"metadata": {},
"outputs": [],
"source": [
"dfs = receiver_dts_timeseries(exp,r=slice(1,dts_length),figsize=dts_ts_size, dtopt=dtopt)"
"dfs = receiver_dts_cdf(exp,show=False)\n",
"display(live_receiver_dts_cdf(exp,figsize=cdf_size,dtopt=dtopt))"
]
},
{
......@@ -277,19 +218,7 @@
"metadata": {},
"outputs": [],
"source": [
"dfs = receiver_dts_cdf(exp,r=r,figsize=cdf_size,dtopt=dtopt)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"print(\"Proto\\t\\t1%\\t95%\\t99%\\tSTD\")\n",
"for proto in protos:\n",
" dts = dfs[proto][\"time\"]\n",
" 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\")"
]
},
{
......@@ -308,20 +237,7 @@
"exp = \"2018_09_07_16_59_34\"\n",
"r = slice(1,2500)\n",
"protocols = [\"tcp-cubic\",\"tcp-cubic-u\",\"tcp-bbr\",\"tcp-bbr-u\",\"prrt\"]\n",
"dfs = ipts_cdf(exp,\n",
" r=r,\n",
" protocols=protocols,\n",
" figsize=half_small_ipts_ts_size,\n",
" legend={\"loc\":\"upper center\", \"bbox_to_anchor\": (0.43, 0.9)})"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"experiment_config(exp)"
"experiment_config_repr(exp)"
]
},
{
......@@ -330,19 +246,12 @@
"metadata": {},
"outputs": [],
"source": [
"print(\"Proto\\t\\t1%\\t99%\")\n",
"for proto in protocols:\n",
" ipts = dfs[proto][\"IPT\"]\n",
" print(\"{:10s}\\t{:.3f}\\t{:.3f}\".format(proto, ipts.quantile(0.01),ipts.quantile(0.99)))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dfs = receiver_dts_timeseries(exp,r=slice(1,250),protocols=protocols,figsize=small_ipts_ts_size)"
"dfs = ipts_cdf(exp,\n",
" r=r,\n",
" protocols=protocols,\n",
" figsize=ipts_ts_size,\n",
" legend={\"loc\":\"upper center\", \"bbox_to_anchor\": (0.43, 0.9)})\n",
"aggregated_statistics(dfs, \"IPT\")"
]
},
{
......@@ -351,9 +260,8 @@
"metadata": {},
"outputs": [],
"source": [
"for proto in protocols:\n",
" dts = dfs[proto][\"time\"]\n",
" 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)\n",
"aggregated_statistics(dfs, \"time\")"
]
},
{
......@@ -363,11 +271,7 @@
"outputs": [],
"source": [
"protocols = [\"tcp-cubic\",\"tcp-cubic-u\",\"tcp-bbr\",\"tcp-bbr-u\",\"prrt\"]\n",
"dfs = receiver_dts_cdf(exp,\n",
" r=r,\n",
" protocols=protocols,\n",
" figsize=half_small_ipts_ts_size,\n",
" legend={\"loc\":\"upper center\", \"bbox_to_anchor\": (0.43, 0.9)})"
"display(live_receiver_dts_cdf(exp,figsize=cdf_size,protocols=protocols))"
]
},
{
......@@ -383,10 +287,7 @@
"metadata": {},
"outputs": [],
"source": [
"length = 2000\n",
"exp = \"2018_12_06_15_49_59\"; r = slice(1,length)\n",
"dtopt=3\n",
"experiment_config(exp)"
"length = 2000; exp = \"2018_12_06_15_49_59\"; r = slice(1,length); dtopt=3; experiment_config_repr(exp)"
]
},
{
......@@ -395,7 +296,8 @@
"metadata": {},
"outputs": [],
"source": [
"dfs = receiver_dts_cdf(exp,r=r,figsize=cdf_size,dtopt=dtopt)"
"dfs = receiver_dts_cdf(exp,show=False)\n",
"display(live_receiver_dts_cdf(exp,figsize=cdf_size, dtopt=dtopt))"
]
},
{
......@@ -404,10 +306,7 @@
"metadata": {},
"outputs": [],
"source": [
"print(\"Proto\\t\\t1%\\t95%\\t99%\\tSTD\")\n",
"for proto in protos:\n",
" dts = dfs[proto][\"time\"]\n",
" 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\")"
]
}
],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment