Newer
Older
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Parse the RTCM3 Logs\n",
"import seaborn as sns\n",
"import pandas\n",
"import matplotlib.pyplot as plt\n",
"import numpy\n",
"\n",
"# to avoid type 3 fonts. \n",
"plt.rc('pdf',fonttype = 42)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Read the files and pre process them for plotting. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Read the file\n",
"timestamps = pandas.read_csv(\"./timestamps.csv\")\n",
"\n",
"# Compute the latency in ms \n",
"timestamps[\"Latency\"] = (timestamps[\"ts_client\"]-timestamps[\"ts_relay\"])*1000\n",
"\n",
"timestamps['relay_iat'] = timestamps['ts_relay'].diff()\n",
"timestamps['relay_iat'] = timestamps['relay_iat'].apply(lambda x : x if x > 0 else numpy.nan) # Dirty hack for jumps between experiments.\n",
"timestamps['relay_iat'] = timestamps['relay_iat'].apply(lambda x : x if x < 100 else numpy.nan) # Dirty hack for jumps between experiments.\n",
"\n",
"timestamps['client_iat'] = timestamps['ts_client'].diff()\n",
"timestamps['client_iat'] = timestamps['client_iat'].apply(lambda x : x if x > 0 else numpy.nan) # Dirty hack for jumps between experiments.\n",
"timestamps['client_iat'] = timestamps['client_iat'].apply(lambda x : x if x < 100 else numpy.nan) # Dirty hack for jumps between experiments.\n",
"\n",
"# Inter-arrival time between messages. The diff is in millisec. \n",
"timestamps['iat_diff'] = abs(timestamps['relay_iat']-timestamps['client_iat'])*1000\n",
"print(timestamps[\"iat_diff\"])\n",
"\n",
"\n",
"ping = pandas.read_csv(\"./ping.csv\")\n",
"\n",
"print(timestamps[timestamps[\"Latency\"] == max(timestamps[\"Latency\"])])\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"fig, ax = plt.subplots(figsize=(17.5,5))\n",
"sns.set_context(\"poster\")\n",
"sns.color_palette(\"husl\", 8)\n",
"\n",
"\n",
"#plot_data = timestamps[timestamps[\"Technology\"].isin([\"Ethernet\", \"Wi-Fi(PE)\", \"Wi-Fi(PE)\", \"5G(BE)\", \"5G(BD)\"]) ]\n",
"plot_data = timestamps\n",
"sns.boxplot(data=plot_data, x=\"Location\", y=\"Latency\",hue=\"Technology\", whis=[5,95], showfliers=False)\n",
"handles, labels = ax.get_legend_handles_labels() \n",
"ax.set_yticklabels(labels=['0.1', '1', '10', '100'])\n",
"ax.set_ylim(0.1,300)\n",
"ax.set_xlabel(\"Location\", weight=\"bold\")\n",
"ax.set_ylabel(\"Latency (ms)\", weight=\"bold\")\n",
"handles, labels = ax.get_legend_handles_labels()\n",
"ax.legend(ncol=5, title=\"Technology\", bbox_to_anchor=(-0.02, 1.35), loc=\"upper left\")\n",
"ax.set_yscale(\"log\")\n",
"ax.grid(True, which='minor', axis='y')\n",
"\n",
"plt.savefig(\"timestamps.pdf\", dpi=1200, bbox_inches='tight')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Plot the one way latency between the client and the relay"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"fig, ax = plt.subplots(figsize=(17.5,5))\n",
"sns.set_context(\"poster\"),\n",
"sns.set_style(\"white\")\n",
"sns.set_palette(\"colorblind\")\n",
"\n",
"sns.boxplot(data=ping, x=\"Location\", y=\"Latency\",hue=\"Technology\", whis=[5,95], showfliers=False)\n",
"\n",
"ax.set_ylim(0.1,300)\n",
"ax.set_xlabel(\"Location\", weight=\"bold\")\n",
"ax.set_ylabel(\"Latency (ms)\", weight=\"bold\")\n",
"ax.legend(ncol=5, title=\"Technology\", bbox_to_anchor=(-0.02, 1.35), loc=\"upper left\")\n",
"ax.set_yscale(\"log\")\n",
"ax.grid(True, which='major', axis='y')\n",
"ax.grid(True, which='minor', axis='y')\n",
"plt.savefig(\"ping.pdf\", dpi=1200, bbox_inches='tight')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Plot the difference in the inter-arrival time of the messages. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sns.set_context(\"poster\"),\n",
"sns.set_style(\"white\")\n",
"sns.set_palette(\"colorblind\")\n",
"\n",
"\n",
"sns.boxplot(data=timestamps, x=\"Location\", y=\"iat_diff\",hue=\"Technology\", whis=[5,95], showfliers=False)\n",
"ax.set_ylim(0.01,300)\n",
"ax.set_xlabel(\"Location\", weight=\"bold\")\n",
"ax.set_ylabel(\"Inter-arrival Time \\n Difference (ms)\", weight=\"bold\")\n",
"#ax.set_yscale(\"log\")\n",
"ax.legend(ncol=5, title=\"Technology\", bbox_to_anchor=(-0.02, 1.35), loc=\"upper left\")\n",
"ax.set_yscale(\"log\")\n",
"ax.grid(True, which='minor', axis='y')\n",
"plt.savefig(\"iat.pdf\", dpi=1200, bbox_inches='tight')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"sns.set_context(\"poster\"),\n",
"sns.set_style(\"white\")\n",
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
"\n",
"def ecdf(x):\n",
" xs = numpy.sort(x)\n",
" ys = numpy.arange(1, len(xs)+1)/float(len(xs))\n",
" return xs, ys\n",
"\n",
"plot_data = timestamps[timestamps[\"relay_iat\"].notnull()]\n",
"#plot_data = plot_data[plot_data[\"relay_iat\"]>0]\n",
"\n",
"x = plot_data[\"relay_iat\"]*1000 # Convert to ms.\n",
"xs, ys = ecdf(x)\n",
"plt.plot(xs,ys)\n",
"ax.set_xscale(\"log\")\n",
"ax.grid(True, which='major')\n",
"ax.grid(True, which='minor')\n",
"ax.set_ylabel(\"ECDF\", weight=\"bold\")\n",
"ax.set_xlabel(\"Inter Arrival Time (ms)\", weight=\"bold\")\n",
"plt.savefig(\"ecdfiat.pdf\", dpi=1200, bbox_inches='tight')"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"for font in plt.rcParams['font.sans-serif']:\n",
" print(font)\n"
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "5Give-venv",
"language": "python",
"name": "5give-venv"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.9"
}
},
"nbformat": 4,
"nbformat_minor": 2
}