diff --git a/simulations/sensitivity/.gitignore b/simulations/sensitivity/.gitignore new file mode 100644 index 0000000..e343d66 --- /dev/null +++ b/simulations/sensitivity/.gitignore @@ -0,0 +1,2 @@ +results/ +sim.py diff --git a/simulations/sensitivity/Makefile b/simulations/sensitivity/Makefile new file mode 100644 index 0000000..6bdb414 --- /dev/null +++ b/simulations/sensitivity/Makefile @@ -0,0 +1,30 @@ +SHELL=/bin/bash +MESSAGES=100 +ENCODING=0 + +PCAPFILES=$(shell python -c 'import itertools; import numpy as np; print(" ".join(["results/sim_%d_%.2f_%.1f_.pcap" % x for x in itertools.product(range(10), np.arange(.4, .7,.02), np.arange(-3, 10, .5))]))') + +all: pdr.pdf + +pdr.pdf: plot.py results/all.csv + python ./plot.py + +sim.py: sim.grc + grcc -d . sim.grc + +results/all.csv: $(PCAPFILES) + ./parse.sh + +%.pcap: sim.py + mkdir -p results + export GR_CONF_DEFAULT_MAX_MESSAGES=123 + @echo $@ + $(eval REPETITION=$(shell python -c "print \"$@\".split(\"_\")[1]")) + $(eval SENSITIVITY=$(shell python -c "print \"$@\".split(\"_\")[2]")) + $(eval SNR=$(shell python -c "print \"$@\".split(\"_\")[3]")) + @echo REPETITION=$(REPETITION) + @echo SENSITIVITY=$(SENSITiVITY) + @echo SNR=$(SNR) + ./sim.py --messages=$(MESSAGES) --encoding=$(ENCODING) --sensitivity=$(SENSITIVITY) --snr=$(SNR) --repetition=$(REPETITION) +# gdb -ex run -ex quit --args python ./sim.py --messages=$(MESSAGES) --encoding=$(ENCODING) --sensitivity=$(SENSITIVITY) --snr=$(SNR) --repetition=$(REPETITION) + diff --git a/simulations/sensitivity/parse.sh b/simulations/sensitivity/parse.sh new file mode 100755 index 0000000..d523df1 --- /dev/null +++ b/simulations/sensitivity/parse.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +files=`ls results/*.pcap` +outfile=results/all.csv +rm -f ${outfile} + +echo "repetition;sensitivity;snr;received" +echo "repetition;sensitivity;snr;received" > ${outfile} + +for f in ${files} +do + repetition=`python -c "print \"${f}\".split(\"_\")[1]"` + sensitivity=`python -c "print \"${f}\".split(\"_\")[2]"` + snr=`python -c "print \"${f}\".split(\"_\")[3]"` + echo "file ${f} repetition ${repetition} sensitivity ${sensitivity} snr ${snr}" + rcvd=`tshark -r ${f} | wc -l | tr -d " "` + echo "${repetition};${sensitivity};${snr};${rcvd}" + echo "${repetition};${sensitivity};${snr};${rcvd}" >> ${outfile} +done diff --git a/simulations/sensitivity/pdr.pdf b/simulations/sensitivity/pdr.pdf new file mode 100644 index 0000000..e23c7b3 Binary files /dev/null and b/simulations/sensitivity/pdr.pdf differ diff --git a/simulations/sensitivity/plot.py b/simulations/sensitivity/plot.py new file mode 100644 index 0000000..94da339 --- /dev/null +++ b/simulations/sensitivity/plot.py @@ -0,0 +1,14 @@ +import numpy as np +import pandas as pd +import matplotlib as mpl +import matplotlib.pyplot as plt + +pdr = pd.read_csv('./results/all.csv', sep=';') + +a = pdr.groupby(['sensitivity', 'snr']) + +b = a.agg({'received': np.mean}).reset_index() +c = b.pivot(index='snr', columns='sensitivity', values='received') +c.plot() +plt.savefig('pdr.pdf') + diff --git a/simulations/sensitivity/sim.grc b/simulations/sensitivity/sim.grc new file mode 100644 index 0000000..49097c6 --- /dev/null +++ b/simulations/sensitivity/sim.grc @@ -0,0 +1,966 @@ + + + + Sat Feb 1 18:28:19 2014 + + options + + author + + + + window_size + 1280, 1024 + + + category + Custom + + + comment + + + + description + + + + _enabled + True + + + _coordinate + (7, 4) + + + _rotation + 0 + + + generate_options + no_gui + + + hier_block_src_path + .: + + + id + sim + + + max_nouts + 0 + + + qt_qss_theme + + + + realtime_scheduling + + + + run_command + {python} -u {filename} + + + run_options + run + + + run + True + + + thread_safe_setters + + + + title + + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 85) + + + _rotation + 0 + + + id + out_buf_size + + + value + 96000 + + + + blocks_file_sink + + append + False + + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + file + " + os.path.dirname(os.path.realpath(__file__)) + "/results/sim_%d_%.2f_%.1f_.pcap" % (repetition, sensitivity, snr) + " + + + _coordinate + (112, 358) + + + _rotation + 180 + + + id + blocks_file_sink_0 + + + type + byte + + + unbuffered + True + + + vlen + 1 + + + + blocks_multiply_const_vxx + + alias + + + + comment + + + + const + (10**(snr/10.0))**.5 + + + affinity + + + + _enabled + True + + + _coordinate + (696, 548) + + + _rotation + 0 + + + id + blocks_multiply_const_vxx_0 + + + type + complex + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + vlen + 1 + + + + channels_channel_model + + alias + + + + block_tags + False + + + comment + + + + affinity + + + + _enabled + True + + + epsilon + 1.0 + + + freq_offset + 0 + + + _coordinate + (928, 520) + + + _rotation + 0 + + + id + channels_channel_model_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + noise_voltage + 1 + + + seed + repetition + + + taps + 1.0 + + + + parameter + + alias + + + + comment + + + + _enabled + 1 + + + _coordinate + (208, 6) + + + _rotation + 0 + + + id + encoding + + + label + + + + short_id + e + + + type + intx + + + value + 0 + + + + foo_packet_pad2 + + alias + + + + comment + + + + affinity + + + + debug + False + + + delay_sec + 0.001 + + + delay + False + + + _enabled + True + + + _coordinate + (480, 520) + + + _rotation + 0 + + + id + foo_packet_pad2_0 + + + maxoutbuf + 0 + + + minoutbuf + out_buf_size + + + pad_front + 2000 + + + pad_tail + 2000 + + + + foo_random_periodic_msg_source + + alias + + + + comment + + + + affinity + + + + debug + False + + + _enabled + True + + + _coordinate + (472, 184) + + + _rotation + 0 + + + id + foo_random_periodic_msg_source_0 + + + maxoutbuf + 0 + + + msg_len + pdu_len - 24 + + + minoutbuf + 0 + + + num + messages + + + interval + 5 + + + quit + True + + + seed + repetition + + + + foo_wireshark_connector + + alias + + + + comment + + + + affinity + + + + debug + False + + + _enabled + 1 + + + _coordinate + (320, 365) + + + _rotation + 180 + + + id + foo_wireshark_connector_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + tech + 127 + + + + ieee802_11_mac + + bss_mac + [0xff, 0xff, 0xff, 0xff, 0xff, 0xff] + + + alias + + + + comment + + + + affinity + + + + dst_mac + [0x42, 0x42, 0x42, 0x42, 0x42, 0x42] + + + _enabled + True + + + _coordinate + (800, 220) + + + _rotation + 0 + + + id + ieee802_11_mac_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + src_mac + [0x23, 0x23, 0x23, 0x23, 0x23, 0x23] + + + + import + + alias + + + + comment + + + + _enabled + True + + + _coordinate + (8, 148) + + + _rotation + 0 + + + id + import_0 + + + import + import math + + + + import + + alias + + + + comment + + + + _enabled + True + + + _coordinate + (8, 196) + + + _rotation + 0 + + + id + import_0_0 + + + import + import random + + + + parameter + + alias + + + + comment + + + + _enabled + True + + + _coordinate + (576, 6) + + + _rotation + 0 + + + id + interval + + + label + + + + short_id + i + + + type + eng_float + + + value + 400 + + + + parameter + + alias + + + + comment + + + + _enabled + True + + + _coordinate + (672, 6) + + + _rotation + 0 + + + id + messages + + + label + + + + short_id + m + + + type + intx + + + value + 10 + + + + parameter + + alias + + + + comment + + + + _enabled + True + + + _coordinate + (392, 6) + + + _rotation + 0 + + + id + pdu_len + + + label + + + + short_id + l + + + type + intx + + + value + 435 + + + + parameter + + alias + + + + comment + + + + _enabled + True + + + _coordinate + (296, 6) + + + _rotation + 0 + + + id + repetition + + + label + + + + short_id + r + + + type + intx + + + value + 23 + + + + parameter + + alias + + + + comment + + + + _enabled + True + + + _coordinate + (760, 6) + + + _rotation + 0 + + + id + sensitivity + + + label + + + + short_id + S + + + type + eng_float + + + value + 0.58 + + + + parameter + + alias + + + + comment + + + + _enabled + True + + + _coordinate + (480, 6) + + + _rotation + 0 + + + id + snr + + + label + + + + short_id + s + + + type + eng_float + + + value + 10 + + + + wifi_phy_hier + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (792, 377) + + + _rotation + 180 + + + id + wifi_phy_hier_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + bandwidth + 10e6 + + + chan_est + 0 + + + encoding + encoding + + + frequency + 5.89e9 + + + sensitivity + sensitivity + + + + blocks_multiply_const_vxx_0 + channels_channel_model_0 + 0 + 0 + + + channels_channel_model_0 + wifi_phy_hier_0 + 0 + 0 + + + foo_packet_pad2_0 + blocks_multiply_const_vxx_0 + 0 + 0 + + + foo_random_periodic_msg_source_0 + ieee802_11_mac_0 + out + app in + + + foo_wireshark_connector_0 + blocks_file_sink_0 + 0 + 0 + + + ieee802_11_mac_0 + wifi_phy_hier_0 + phy out + mac_in + + + wifi_phy_hier_0 + foo_wireshark_connector_0 + mac_out + in + + + wifi_phy_hier_0 + foo_packet_pad2_0 + 0 + 0 + +