From 162484280107f804e6b4a3c8965f4ab68d4314b9 Mon Sep 17 00:00:00 2001 From: Bastian Bloessl Date: Thu, 12 Oct 2017 16:24:54 +0100 Subject: [PATCH] interfernce simulation --- simulations/interference/.gitignore | 1 + simulations/interference/Makefile | 25 + simulations/interference/parse.sh | 19 + simulations/interference/pdr.pdf | Bin 0 -> 9343 bytes simulations/interference/plot.py | 13 + simulations/interference/sim.grc | 2067 +++++++++++++++++++++++++++ simulations/interference/sim.py | 270 ++++ 7 files changed, 2395 insertions(+) create mode 100644 simulations/interference/.gitignore create mode 100644 simulations/interference/Makefile create mode 100755 simulations/interference/parse.sh create mode 100644 simulations/interference/pdr.pdf create mode 100644 simulations/interference/plot.py create mode 100644 simulations/interference/sim.grc create mode 100755 simulations/interference/sim.py diff --git a/simulations/interference/.gitignore b/simulations/interference/.gitignore new file mode 100644 index 0000000..fbca225 --- /dev/null +++ b/simulations/interference/.gitignore @@ -0,0 +1 @@ +results/ diff --git a/simulations/interference/Makefile b/simulations/interference/Makefile new file mode 100644 index 0000000..dd843da --- /dev/null +++ b/simulations/interference/Makefile @@ -0,0 +1,25 @@ +SHELL=/bin/bash +MESSAGES=100 + +PCAPFILES=$(shell python -c 'import itertools; import numpy as np; print(" ".join(["results/sim_%d_%.1f_%s_.pcap" % x for x in itertools.product(range(20), np.arange(0,12,0.5), ["ofdm", "noise"])]))') + +all: pdr.pdf + +pdr.pdf: plot.py results/all.csv + python ./plot.py + +results/all.csv: $(PCAPFILES) + ./parse.sh + +%.pcap: sim.py + mkdir -p results + export GR_CONF_DEFAULT_MAX_MESSAGES=2000 + @echo $@ + $(eval REPETITION=$(shell python -c "print \"$@\".split(\"_\")[1]")) + $(eval SNR=$(shell python -c "print \"$@\".split(\"_\")[2]")) + $(eval INTERFERENCE=$(shell python -c "print \"$@\".split(\"_\")[3]")) + @echo REPETITION=$(REPETITION) + @echo SNR=$(SNR) + @echo INTERFERENCE=$(INTERFERENCE) + ./sim.py --repetition=$(REPETITION) --snr=$(SNR) --messages=$(MESSAGES) --interference=$(INTERFERENCE) + diff --git a/simulations/interference/parse.sh b/simulations/interference/parse.sh new file mode 100755 index 0000000..63e285e --- /dev/null +++ b/simulations/interference/parse.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +files=`ls results/*.pcap` +outfile=results/all.csv +rm -f ${outfile} + +echo "repetition;interference;snr;received" +echo "repetition;interference;snr;received" > ${outfile} + +for f in ${files} +do + repetition=`python -c "print \"${f}\".split(\"_\")[1]"` + snr=`python -c "print \"${f}\".split(\"_\")[2]"` + interference=`python -c "print \"${f}\".split(\"_\")[3]"` + echo "file ${f} repetition ${repetition} interference ${interference} snr ${snr}" + rcvd=`tshark -r ${f} -Y "wlan.sa == 23:23:23:23:23:23" | wc -l | tr -d " "` + echo "${repetition};${interference};${snr};${rcvd}" + echo "${repetition};${interference};${snr};${rcvd}" >> ${outfile} +done diff --git a/simulations/interference/pdr.pdf b/simulations/interference/pdr.pdf new file mode 100644 index 0000000000000000000000000000000000000000..48dc5a500b3c1ba83d7ecbab0ffa8401df32b2ff GIT binary patch literal 9343 zcmb_?2{@GB_c&S7plm}zy~z?`_8DU<43d2*`cN5+$UcUIv{_O}MV2gOE40{Cic0oS zBDCn6wFnX6)8cpEk&-;0r|19tXP*1q_dV~q=bm%!dCxibo>$tGqN|8e!Xu=wy@K-Y zATSUb^0YsIP*a0YmWRA(5K5cMpt^bPhft=}{WKp43lPj94Gjd%!x2VQUNpek#Qp%y zfdP@2IA8#SL8E&>1o#$#GNpSuSkM@d4Io9)1>|Y|3<#y~4#;Z#=(T_J`p_N-rQ^@g zvtUpeGzdRWz`~j8=;E;-BF>Z7_4HssIOg>)b}(oFSP(#u?&<3V!J=qeKqv~$&&7de zt_LOqcb0UjhmRMPPV;a$v>@s{zJ>-YD|o<|7Z!msqB*)ywLJX+>o9pd5v`;Q;qU|{ zBFv|zhleM_2RsAU<}@EqU%CU(6Ra2W1;ViE5GZZHFrexKk(tkaF%91@@T}|N29yS& zblrgD6qIG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dNF6maDT0d+F3m~I*S;|4g}`2sHRx6H#!P}_!mGnN@ZAmDz%nlp#NE*#4&Uc>Gf zSO6310bzesu$itMoM!_tAOQiJVIt6huII1johCDj1pI(%_YVv>Kmhf^*uR|JVxO%G z3}$}fU(XkZRZYx%SzHs)ScnTh%k3x!D#XlQP@1@(XrSV~EFxSAha-t5b^#T$JR(eS z5x0w!|BJ;%d)HsUMccezzy-(7Ebe>yg75^UHE?l+11a+x0CTt;KObx6KV0}V7DVD- z35GT(q%&MRJt**p2Ae4=STu%&L1VCBdrZO*x1ceyXtb;x^XmmiUk6Z`-|S9hc)58p z++6G-FGnZHp6cKV!VN%Sk^)J}VhpSjS_!KFIWrhuDk#*ip-P_g{c?-c;ZLVIA%J(m zBY>a&@dIv{0Gyr^^b-c#DExyw7GTOa(w{I44%p8UJRr>0Fe32tOYxN9HxvH-niq!!E4CCygkSw7cx1vK{Nb@6+%3Vw6M*ku z3L^n`yc9+T;d%*-fW`m89{~?y+EP67pF9H({l{7=<3R}hIhH}Ey13Ek%rAxXJ)As2 pz@2wm=ANGL+sJff7A^t6Q~fxHqtY2nGgl@kgYS)`bxd>-{|Buren + + + 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 + + + sizing_mode + fixed + + + thread_safe_setters + 1 + + + title + + + + placement + (0,0) + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 244) + + + _rotation + 0 + + + id + filename + + + value + "results/sim_%d_%.1f_%s_.pcap" % (repetition, snr, interference) + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (8, 85) + + + _rotation + 0 + + + id + out_buf_size + + + value + 960000 + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (840, 4) + + + _rotation + 0 + + + id + sync_length + + + value + 320 + + + + variable + + comment + + + + _enabled + True + + + _coordinate + (944, 4) + + + _rotation + 0 + + + id + window_size + + + value + 48 + + + + analog_noise_source_x + + amp + 1 + + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (24, 820) + + + _rotation + 0 + + + id + analog_noise_source_x_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + noise_type + analog.GR_GAUSSIAN + + + type + complex + + + seed + repetition+12312 + + + + analog_noise_source_x + + amp + 1 + + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (1124, 808) + + + _rotation + 90 + + + id + analog_noise_source_x_0_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + noise_type + analog.GR_GAUSSIAN + + + type + complex + + + seed + repetition+1 + + + + blocks_add_xx + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (1048, 392) + + + _rotation + 90 + + + id + blocks_add_xx_0 + + + type + complex + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + num_inputs + 4 + + + vlen + 1 + + + + blocks_add_xx + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (184, 768) + + + _rotation + 0 + + + id + blocks_add_xx_1 + + + type + complex + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + num_inputs + 2 + + + vlen + 1 + + + + blocks_file_sink + + append + False + + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + file + filename + + + _coordinate + (200, 252) + + + _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, 452) + + + _rotation + 0 + + + id + blocks_multiply_const_vxx_0 + + + type + complex + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + vlen + 1 + + + + blocks_multiply_const_vxx + + alias + + + + comment + + + + const + 1 if interference == "ofdm" else 0 + + + affinity + + + + _enabled + 1 + + + _coordinate + (1076, 496) + + + _rotation + 90 + + + id + blocks_multiply_const_vxx_1 + + + type + complex + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + vlen + 1 + + + + blocks_multiply_const_vxx + + alias + + + + comment + + + + const + 0.00001 + + + affinity + + + + _enabled + True + + + _coordinate + (1140, 648) + + + _rotation + 90 + + + id + blocks_multiply_const_vxx_1_0 + + + type + complex + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + vlen + 1 + + + + blocks_multiply_const_vxx + + alias + + + + comment + + + + const + 1 if interference == "noise" else 0 + + + affinity + + + + _enabled + 1 + + + _coordinate + (968, 836) + + + _rotation + 0 + + + id + blocks_multiply_const_vxx_1_1 + + + type + complex + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + vlen + 1 + + + + blocks_multiply_const_vxx + + alias + + + + comment + + + + const + 0 + + + affinity + + + + _enabled + True + + + _coordinate + (344, 564) + + + _rotation + 0 + + + id + blocks_multiply_const_vxx_2 + + + type + complex + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + vlen + 1 + + + + blocks_skiphead + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (872, 452) + + + _rotation + 0 + + + id + blocks_skiphead_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + num_items + 2400 + repetition * 4 + + + type + complex + + + vlen + 1 + + + + blocks_stream_to_tagged_stream + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (224, 828) + + + _rotation + 0 + + + id + blocks_stream_to_tagged_stream_0 + + + len_tag_key + "packet_len" + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + packet_len + ieee802_11.payload_to_samples(ieee802_11.mac_payload_to_payload(size), encoding) + + + type + complex + + + vlen + 1 + + + + parameter + + alias + + + + comment + + + + _enabled + 1 + + + _coordinate + (752, 4) + + + _rotation + 0 + + + id + encoding + + + label + + + + short_id + + + + hide + none + + + type + intx + + + value + 2 + + + + foo_packet_pad2 + + alias + + + + comment + + + + affinity + + + + debug + False + + + delay_sec + 0.001 + + + delay + False + + + _enabled + 1 + + + _coordinate + (480, 424) + + + _rotation + 0 + + + id + foo_packet_pad2_0 + + + maxoutbuf + 0 + + + minoutbuf + out_buf_size + + + pad_front + 4000 + + + pad_tail + 5000 + + + + foo_packet_pad2 + + alias + + + + comment + + + + affinity + + + + debug + False + + + delay_sec + 0.001 + + + delay + False + + + _enabled + 1 + + + _coordinate + (704, 648) + + + _rotation + 0 + + + id + foo_packet_pad2_0_0 + + + maxoutbuf + 0 + + + minoutbuf + out_buf_size + + + pad_front + 4000 + + + pad_tail + 5000 + + + + foo_packet_pad2 + + alias + + + + comment + + + + affinity + + + + debug + False + + + delay_sec + 0.001 + + + delay + False + + + _enabled + 1 + + + _coordinate + (472, 808) + + + _rotation + 0 + + + id + foo_packet_pad2_0_0_0 + + + maxoutbuf + 0 + + + minoutbuf + out_buf_size + + + pad_front + 4000 + + + pad_tail + 5000 + + + + foo_random_periodic_msg_source + + alias + + + + comment + + + + affinity + + + + debug + False + + + _enabled + True + + + _coordinate + (272, 112) + + + _rotation + 0 + + + id + foo_random_periodic_msg_source_0 + + + maxoutbuf + 0 + + + msg_len + ieee802_11.mac_payload_to_payload(size) + + + minoutbuf + 0 + + + num + messages + + + interval + interval + + + quit + True + + + seed + repetition+4242 + + + + foo_random_periodic_msg_source + + alias + + + + comment + + + + affinity + + + + debug + False + + + _enabled + 1 + + + _coordinate + (8, 616) + + + _rotation + 0 + + + id + foo_random_periodic_msg_source_0_0 + + + maxoutbuf + 0 + + + msg_len + ieee802_11.mac_payload_to_payload(size) + + + minoutbuf + 0 + + + num + messages + + + interval + interval + + + quit + True + + + seed + repetition+123 + + + + foo_wireshark_connector + + alias + + + + comment + + + + affinity + + + + debug + False + + + _enabled + 1 + + + _coordinate + (400, 260) + + + _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 + (600, 148) + + + _rotation + 0 + + + id + ieee802_11_mac_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + src_mac + [0x23, 0x23, 0x23, 0x23, 0x23, 0x23] + + + + ieee802_11_mac + + bss_mac + [0x56, 0x56, 0x56, 0x56, 0x56, 0x56] + + + alias + + + + comment + + + + affinity + + + + dst_mac + [0x34, 0x34, 0x34, 0x34, 0x34, 0x34] + + + _enabled + 1 + + + _coordinate + (296, 652) + + + _rotation + 0 + + + id + ieee802_11_mac_0_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + src_mac + [0x12, 0x12, 0x12, 0x12, 0x12, 0x12] + + + + 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 + (472, 4) + + + _rotation + 0 + + + id + interference + + + label + + + + short_id + + + + hide + none + + + type + str + + + value + "ofdm" + + + + parameter + + alias + + + + comment + + + + _enabled + True + + + _coordinate + (576, 4) + + + _rotation + 0 + + + id + interval + + + label + + + + short_id + + + + hide + none + + + type + eng_float + + + value + 50 + + + + parameter + + alias + + + + comment + + + + _enabled + True + + + _coordinate + (384, 4) + + + _rotation + 0 + + + id + messages + + + label + + + + short_id + + + + hide + none + + + type + intx + + + value + 50 + + + + pfb_arb_resampler_xxx + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (856, 656) + + + _rotation + 0 + + + id + pfb_arb_resampler_xxx_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + nfilts + 32 + + + rrate + 1 + 15e-6 + + + samp_delay + 0 + + + atten + 100 + + + taps + + + + type + ccf + + + + pfb_arb_resampler_xxx + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (672, 816) + + + _rotation + 0 + + + id + pfb_arb_resampler_xxx_0_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + nfilts + 32 + + + rrate + 1 + 15e-6 + + + samp_delay + 0 + + + atten + 100 + + + taps + + + + type + ccf + + + + parameter + + alias + + + + comment + + + + _enabled + True + + + _coordinate + (208, 4) + + + _rotation + 0 + + + id + repetition + + + label + + + + short_id + + + + hide + none + + + type + intx + + + value + 23 + + + + parameter + + alias + + + + comment + + + + _enabled + True + + + _coordinate + (664, 4) + + + _rotation + 0 + + + id + size + + + label + + + + short_id + + + + hide + none + + + type + intx + + + value + 546 + + + + parameter + + alias + + + + comment + + + + _enabled + True + + + _coordinate + (296, 4) + + + _rotation + 0 + + + id + snr + + + label + + + + short_id + + + + hide + none + + + type + eng_float + + + value + 20 + + + + wifi_phy_hier + + alias + + + + comment + + + + affinity + + + + _enabled + True + + + _coordinate + (800, 272) + + + _rotation + 180 + + + id + wifi_phy_hier_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + bandwidth + 10e6 + + + chan_est + ieee802_11.LS + + + encoding + encoding + + + frequency + 5.89e9 + + + sensitivity + 0.56 + + + + wifi_phy_hier + + alias + + + + comment + + + + affinity + + + + _enabled + 1 + + + _coordinate + (520, 640) + + + _rotation + 0 + + + id + wifi_phy_hier_0_0 + + + maxoutbuf + 0 + + + minoutbuf + 0 + + + bandwidth + 10e6 + + + chan_est + ieee802_11.LS + + + encoding + encoding + + + frequency + 5.89e9 + + + sensitivity + 0.56 + + + + analog_noise_source_x_0 + blocks_add_xx_1 + 0 + 1 + + + analog_noise_source_x_0_0 + blocks_multiply_const_vxx_1_0 + 0 + 0 + + + blocks_add_xx_0 + wifi_phy_hier_0 + 0 + 0 + + + blocks_add_xx_1 + blocks_stream_to_tagged_stream_0 + 0 + 0 + + + blocks_multiply_const_vxx_0 + blocks_skiphead_0 + 0 + 0 + + + blocks_multiply_const_vxx_1 + blocks_add_xx_0 + 0 + 1 + + + blocks_multiply_const_vxx_1_0 + blocks_add_xx_0 + 0 + 3 + + + blocks_multiply_const_vxx_1_1 + blocks_add_xx_0 + 0 + 2 + + + blocks_multiply_const_vxx_2 + blocks_add_xx_1 + 0 + 0 + + + blocks_multiply_const_vxx_2 + wifi_phy_hier_0_0 + 0 + 0 + + + blocks_skiphead_0 + blocks_add_xx_0 + 0 + 0 + + + blocks_stream_to_tagged_stream_0 + foo_packet_pad2_0_0_0 + 0 + 0 + + + foo_packet_pad2_0 + blocks_multiply_const_vxx_0 + 0 + 0 + + + foo_packet_pad2_0_0 + pfb_arb_resampler_xxx_0 + 0 + 0 + + + foo_packet_pad2_0_0_0 + pfb_arb_resampler_xxx_0_0 + 0 + 0 + + + foo_random_periodic_msg_source_0 + ieee802_11_mac_0 + out + app in + + + foo_random_periodic_msg_source_0_0 + ieee802_11_mac_0_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 + + + ieee802_11_mac_0_0 + wifi_phy_hier_0_0 + phy out + mac_in + + + pfb_arb_resampler_xxx_0 + blocks_multiply_const_vxx_1 + 0 + 0 + + + pfb_arb_resampler_xxx_0_0 + blocks_multiply_const_vxx_1_1 + 0 + 0 + + + wifi_phy_hier_0 + foo_wireshark_connector_0 + mac_out + in + + + wifi_phy_hier_0 + blocks_multiply_const_vxx_2 + 0 + 0 + + + wifi_phy_hier_0 + foo_packet_pad2_0 + 0 + 0 + + + wifi_phy_hier_0_0 + foo_packet_pad2_0_0 + 0 + 0 + + diff --git a/simulations/interference/sim.py b/simulations/interference/sim.py new file mode 100755 index 0000000..37391b1 --- /dev/null +++ b/simulations/interference/sim.py @@ -0,0 +1,270 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +################################################## +# GNU Radio Python Flow Graph +# Title: Sim +# Generated: Thu Oct 12 12:33:05 2017 +################################################## +import threading + + +import os +import sys +sys.path.append(os.environ.get('GRC_HIER_PATH', os.path.expanduser('~/.grc_gnuradio'))) + +from argparse import ArgumentParser +from gnuradio import analog +from gnuradio import blocks +from gnuradio import eng_notation +from gnuradio import gr +from gnuradio.eng_arg import eng_float, intx +from gnuradio.filter import firdes +from gnuradio.filter import pfb +from wifi_phy_hier import wifi_phy_hier # grc-generated hier_block +import foo +import ieee802_11 +import math +import pmt +import random + + +class sim(gr.top_block): + + def __init__(self, encoding=2, interference="ofdm", interval=50, messages=50, repetition=23, size=546, snr=20): + gr.top_block.__init__(self, "Sim") + + self._lock = threading.RLock() + + ################################################## + # Parameters + ################################################## + self.encoding = encoding + self.interference = interference + self.interval = interval + self.messages = messages + self.repetition = repetition + self.size = size + self.snr = snr + + ################################################## + # Variables + ################################################## + self.window_size = window_size = 48 + self.sync_length = sync_length = 320 + self.out_buf_size = out_buf_size = 960000 + self.filename = filename = "results/sim_%d_%.1f_%s_.pcap" % (repetition, snr, interference) + + ################################################## + # Blocks + ################################################## + self.wifi_phy_hier_0_0 = wifi_phy_hier( + bandwidth=10e6, + chan_est=ieee802_11.LS, + encoding=encoding, + frequency=5.89e9, + sensitivity=0.56, + ) + self.wifi_phy_hier_0 = wifi_phy_hier( + bandwidth=10e6, + chan_est=ieee802_11.LS, + encoding=encoding, + frequency=5.89e9, + sensitivity=0.56, + ) + self.pfb_arb_resampler_xxx_0_0 = pfb.arb_resampler_ccf( + 1 + 15e-6, + taps=None, + flt_size=32) + self.pfb_arb_resampler_xxx_0_0.declare_sample_delay(0) + + self.pfb_arb_resampler_xxx_0 = pfb.arb_resampler_ccf( + 1 + 15e-6, + taps=None, + flt_size=32) + self.pfb_arb_resampler_xxx_0.declare_sample_delay(0) + + self.ieee802_11_mac_0_0 = ieee802_11.mac(([0x12, 0x12, 0x12, 0x12, 0x12, 0x12]), ([0x34, 0x34, 0x34, 0x34, 0x34, 0x34]), ([0x56, 0x56, 0x56, 0x56, 0x56, 0x56])) + self.ieee802_11_mac_0 = ieee802_11.mac(([0x23, 0x23, 0x23, 0x23, 0x23, 0x23]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff])) + self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False) + self.foo_random_periodic_msg_source_0_0 = foo.random_periodic_msg_source(ieee802_11.mac_payload_to_payload(size), interval, messages, True, False, repetition+123) + self.foo_random_periodic_msg_source_0 = foo.random_periodic_msg_source(ieee802_11.mac_payload_to_payload(size), interval, messages, True, False, repetition+4242) + self.foo_packet_pad2_0_0_0 = foo.packet_pad2(False, False, 0.001, 4000, 5000) + (self.foo_packet_pad2_0_0_0).set_min_output_buffer(960000) + self.foo_packet_pad2_0_0 = foo.packet_pad2(False, False, 0.001, 4000, 5000) + (self.foo_packet_pad2_0_0).set_min_output_buffer(960000) + self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 4000, 5000) + (self.foo_packet_pad2_0).set_min_output_buffer(960000) + self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream(gr.sizeof_gr_complex, 1, ieee802_11.payload_to_samples(ieee802_11.mac_payload_to_payload(size), encoding), "packet_len") + self.blocks_skiphead_0 = blocks.skiphead(gr.sizeof_gr_complex*1, 2400 + repetition * 4) + self.blocks_multiply_const_vxx_2 = blocks.multiply_const_vcc((0, )) + self.blocks_multiply_const_vxx_1_1 = blocks.multiply_const_vcc((1 if interference == "noise" else 0, )) + self.blocks_multiply_const_vxx_1_0 = blocks.multiply_const_vcc((0.00001, )) + self.blocks_multiply_const_vxx_1 = blocks.multiply_const_vcc((1 if interference == "ofdm" else 0, )) + self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(((10**(snr/10.0))**.5, )) + self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, filename, False) + self.blocks_file_sink_0.set_unbuffered(True) + self.blocks_add_xx_1 = blocks.add_vcc(1) + self.blocks_add_xx_0 = blocks.add_vcc(1) + self.analog_noise_source_x_0_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 1, repetition+1) + self.analog_noise_source_x_0 = analog.noise_source_c(analog.GR_GAUSSIAN, 1, repetition+12312) + + + + ################################################## + # Connections + ################################################## + self.msg_connect((self.foo_random_periodic_msg_source_0, 'out'), (self.ieee802_11_mac_0, 'app in')) + self.msg_connect((self.foo_random_periodic_msg_source_0_0, 'out'), (self.ieee802_11_mac_0_0, 'app in')) + self.msg_connect((self.ieee802_11_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in')) + self.msg_connect((self.ieee802_11_mac_0_0, 'phy out'), (self.wifi_phy_hier_0_0, 'mac_in')) + self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.foo_wireshark_connector_0, 'in')) + self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_1, 1)) + self.connect((self.analog_noise_source_x_0_0, 0), (self.blocks_multiply_const_vxx_1_0, 0)) + self.connect((self.blocks_add_xx_0, 0), (self.wifi_phy_hier_0, 0)) + self.connect((self.blocks_add_xx_1, 0), (self.blocks_stream_to_tagged_stream_0, 0)) + self.connect((self.blocks_multiply_const_vxx_0, 0), (self.blocks_skiphead_0, 0)) + self.connect((self.blocks_multiply_const_vxx_1, 0), (self.blocks_add_xx_0, 1)) + self.connect((self.blocks_multiply_const_vxx_1_0, 0), (self.blocks_add_xx_0, 3)) + self.connect((self.blocks_multiply_const_vxx_1_1, 0), (self.blocks_add_xx_0, 2)) + self.connect((self.blocks_multiply_const_vxx_2, 0), (self.blocks_add_xx_1, 0)) + self.connect((self.blocks_multiply_const_vxx_2, 0), (self.wifi_phy_hier_0_0, 0)) + self.connect((self.blocks_skiphead_0, 0), (self.blocks_add_xx_0, 0)) + self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.foo_packet_pad2_0_0_0, 0)) + self.connect((self.foo_packet_pad2_0, 0), (self.blocks_multiply_const_vxx_0, 0)) + self.connect((self.foo_packet_pad2_0_0, 0), (self.pfb_arb_resampler_xxx_0, 0)) + self.connect((self.foo_packet_pad2_0_0_0, 0), (self.pfb_arb_resampler_xxx_0_0, 0)) + self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0)) + self.connect((self.pfb_arb_resampler_xxx_0, 0), (self.blocks_multiply_const_vxx_1, 0)) + self.connect((self.pfb_arb_resampler_xxx_0_0, 0), (self.blocks_multiply_const_vxx_1_1, 0)) + self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_2, 0)) + self.connect((self.wifi_phy_hier_0, 0), (self.foo_packet_pad2_0, 0)) + self.connect((self.wifi_phy_hier_0_0, 0), (self.foo_packet_pad2_0_0, 0)) + + def get_encoding(self): + return self.encoding + + def set_encoding(self, encoding): + with self._lock: + self.encoding = encoding + self.wifi_phy_hier_0_0.set_encoding(self.encoding) + self.wifi_phy_hier_0.set_encoding(self.encoding) + self.blocks_stream_to_tagged_stream_0.set_packet_len(ieee802_11.payload_to_samples(ieee802_11.mac_payload_to_payload(self.size), self.encoding)) + self.blocks_stream_to_tagged_stream_0.set_packet_len_pmt(ieee802_11.payload_to_samples(ieee802_11.mac_payload_to_payload(self.size), self.encoding)) + + def get_interference(self): + return self.interference + + def set_interference(self, interference): + with self._lock: + self.interference = interference + self.set_filename("results/sim_%d_%.1f_%s_.pcap" % (self.repetition, self.snr, self.interference)) + self.blocks_multiply_const_vxx_1_1.set_k((1 if self.interference == "noise" else 0, )) + self.blocks_multiply_const_vxx_1.set_k((1 if self.interference == "ofdm" else 0, )) + + def get_interval(self): + return self.interval + + def set_interval(self, interval): + with self._lock: + self.interval = interval + + def get_messages(self): + return self.messages + + def set_messages(self, messages): + with self._lock: + self.messages = messages + + def get_repetition(self): + return self.repetition + + def set_repetition(self, repetition): + with self._lock: + self.repetition = repetition + self.set_filename("results/sim_%d_%.1f_%s_.pcap" % (self.repetition, self.snr, self.interference)) + + def get_size(self): + return self.size + + def set_size(self, size): + with self._lock: + self.size = size + self.blocks_stream_to_tagged_stream_0.set_packet_len(ieee802_11.payload_to_samples(ieee802_11.mac_payload_to_payload(self.size), self.encoding)) + self.blocks_stream_to_tagged_stream_0.set_packet_len_pmt(ieee802_11.payload_to_samples(ieee802_11.mac_payload_to_payload(self.size), self.encoding)) + + def get_snr(self): + return self.snr + + def set_snr(self, snr): + with self._lock: + self.snr = snr + self.set_filename("results/sim_%d_%.1f_%s_.pcap" % (self.repetition, self.snr, self.interference)) + self.blocks_multiply_const_vxx_0.set_k(((10**(self.snr/10.0))**.5, )) + + def get_window_size(self): + return self.window_size + + def set_window_size(self, window_size): + with self._lock: + self.window_size = window_size + + def get_sync_length(self): + return self.sync_length + + def set_sync_length(self, sync_length): + with self._lock: + self.sync_length = sync_length + + def get_out_buf_size(self): + return self.out_buf_size + + def set_out_buf_size(self, out_buf_size): + with self._lock: + self.out_buf_size = out_buf_size + + def get_filename(self): + return self.filename + + def set_filename(self, filename): + with self._lock: + self.filename = filename + self.blocks_file_sink_0.open(self.filename) + + +def argument_parser(): + parser = ArgumentParser() + parser.add_argument( + "--encoding", dest="encoding", type=intx, default=2, + help="Set encoding [default=%(default)r]") + parser.add_argument( + "--interference", dest="interference", type=str, default="ofdm", + help="Set interference [default=%(default)r]") + parser.add_argument( + "--interval", dest="interval", type=eng_float, default=eng_notation.num_to_str(50), + help="Set interval [default=%(default)r]") + parser.add_argument( + "--messages", dest="messages", type=intx, default=50, + help="Set messages [default=%(default)r]") + parser.add_argument( + "--repetition", dest="repetition", type=intx, default=23, + help="Set repetition [default=%(default)r]") + parser.add_argument( + "--size", dest="size", type=intx, default=546, + help="Set size [default=%(default)r]") + parser.add_argument( + "--snr", dest="snr", type=eng_float, default=eng_notation.num_to_str(20), + help="Set snr [default=%(default)r]") + return parser + + +def main(top_block_cls=sim, options=None): + if options is None: + options = argument_parser().parse_args() + + tb = top_block_cls(encoding=options.encoding, interference=options.interference, interval=options.interval, messages=options.messages, repetition=options.repetition, size=options.size, snr=options.snr) + tb.start() + tb.wait() + + +if __name__ == '__main__': + main()