diff --git a/.gitignore b/.gitignore index 453ced4..8fdadcc 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,7 @@ -workspace/*/ +build +examples/*.py +.cproject +.project +.pydevproject +.settings +*.pyc diff --git a/examples/herpderp.grc b/examples/herpderp.grc deleted file mode 100644 index bb524a2..0000000 --- a/examples/herpderp.grc +++ /dev/null @@ -1,1078 +0,0 @@ - - - - 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 - - - id - wifi_loopback - - - max_nouts - 0 - - - qt_qss_theme - - - - realtime_scheduling - - - - run_command - {python} -u {filename} - - - run_options - prompt - - - run - True - - - thread_safe_setters - - - - title - - - - - variable - - comment - - - - _enabled - True - - - _coordinate - (176, 11) - - - _rotation - 0 - - - id - out_buf_size - - - value - 96000 - - - - blocks_file_sink - - append - False - - - alias - - - - comment - - - - affinity - - - - _enabled - False - - - file - /tmp/ofdm.bin - - - _coordinate - (896, 187) - - - _rotation - 0 - - - id - blocks_file_sink_0 - - - type - byte - - - unbuffered - True - - - vlen - 1 - - - - blocks_message_strobe - - alias - - - - comment - - - - affinity - - - - _enabled - True - - - _coordinate - (48, 131) - - - _rotation - 0 - - - id - blocks_message_strobe_0 - - - maxoutbuf - 0 - - - msg - pmt.intern("".join("x" for i in range(pdu_length))) - - - minoutbuf - 0 - - - period - interval - - - - blocks_multiply_const_vxx - - alias - - - - comment - - - - const - (10**(snr/10.0))**.5 - - - affinity - - - - _enabled - True - - - _coordinate - (440, 427) - - - _rotation - 0 - - - id - blocks_multiply_const_vxx_0 - - - type - complex - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - vlen - 1 - - - - blocks_null_sink - - alias - - - - bus_conns - [[0,],] - - - comment - - - - affinity - - - - _enabled - True - - - _coordinate - (232, 545) - - - _rotation - 0 - - - id - blocks_null_sink_0 - - - type - complex - - - num_inputs - 1 - - - vlen - 1 - - - - blocks_null_sink - - alias - - - - bus_conns - [[0,],] - - - comment - - - - affinity - - - - _enabled - True - - - _coordinate - (480, 633) - - - _rotation - 0 - - - id - blocks_null_sink_1 - - - type - float - - - num_inputs - 1 - - - vlen - 1 - - - - blocks_pdu_to_tagged_stream - - alias - - - - comment - - - - affinity - - - - _enabled - True - - - _coordinate - (136, 635) - - - _rotation - 0 - - - id - blocks_pdu_to_tagged_stream_0 - - - type - float - - - tag - packet_len - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - - parameter - - alias - - - - comment - Default: 1 -Else: 0 - - - _enabled - True - - - _coordinate - (480, 11) - - - _rotation - 0 - - - id - chan_est - - - label - - - - short_id - - - - type - intx - - - value - 1 - - - - channels_channel_model - - alias - - - - block_tags - False - - - comment - - - - affinity - - - - _enabled - True - - - epsilon - 1.0 - - - freq_offset - freq_offset - - - _coordinate - (664, 395) - - - _rotation - 0 - - - id - channels_channel_model_0 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - noise_voltage - .5**.5 - - - seed - 0 - - - taps - 1.0 - - - - parameter - - alias - - - - comment - 0, 1, ..., 6, 7 - - - _enabled - True - - - _coordinate - (760, 11) - - - _rotation - 0 - - - id - encoding - - - label - - - - short_id - - - - type - intx - - - value - 0 - - - - foo_packet_pad2 - - alias - - - - comment - - - - affinity - - - - debug - False - - - delay_sec - 0.001 - - - delay - False - - - _enabled - True - - - _coordinate - (272, 395) - - - _rotation - 0 - - - id - foo_packet_pad2_0 - - - maxoutbuf - 0 - - - minoutbuf - out_buf_size - - - pad_front - 500 - - - pad_tail - 0 - - - - foo_wireshark_connector - - alias - - - - comment - - - - affinity - - - - debug - False - - - _enabled - False - - - _coordinate - (688, 195) - - - _rotation - 0 - - - id - foo_wireshark_connector_0 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - tech - 127 - - - - parameter - - alias - - - - comment - A float. -Default: 0 -Min: -0.1 -Max: 0.1 - - - _enabled - True - - - _coordinate - (664, 11) - - - _rotation - 0 - - - id - freq_offset - - - label - - - - short_id - - - - type - eng_float - - - value - 0 - - - - ieee802_11_ofdm_mac - - bss_mac - [0xff, 0xff, 0xff, 0xff, 0xff, 0xff] - - - alias - - - - comment - - - - affinity - - - - dst_mac - [0x42, 0x42, 0x42, 0x42, 0x42, 0x42] - - - _enabled - True - - - _coordinate - (416, 139) - - - _rotation - 0 - - - id - ieee802_11_ofdm_mac_0 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - src_mac - [0x23, 0x23, 0x23, 0x23, 0x23, 0x23] - - - - ieee802_11_ofdm_parse_mac - - alias - - - - comment - - - - affinity - - - - debug - True - - - _enabled - True - - - _coordinate - (112, 259) - - - _rotation - 180 - - - id - ieee802_11_ofdm_parse_mac_0 - - - log - False - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - - import - - alias - - - - comment - - - - _enabled - True - - - _coordinate - (280, 11) - - - _rotation - 0 - - - id - import_0 - - - import - import math - - - - parameter - - alias - - - - comment - PDU Interval (ms). -Default: 100 -Min: 10 -Max: 1000 - - - _enabled - True - - - _coordinate - (848, 11) - - - _rotation - 0 - - - id - interval - - - label - - - - short_id - - - - type - intx - - - value - 1000 - - - - parameter - - alias - - - - comment - An integer. -Min: 0 -Max: 1500 - - - _enabled - True - - - _coordinate - (384, 11) - - - _rotation - 0 - - - id - pdu_length - - - label - - - - short_id - - - - type - intx - - - value - 500 - - - - parameter - - alias - - - - comment - A float. -Default: 10 -Min: -15 -Max: 30 - - - _enabled - True - - - _coordinate - (576, 11) - - - _rotation - 0 - - - id - snr - - - label - - - - short_id - - - - type - eng_float - - - value - 10 - - - - wifi_phy_hier - - alias - - - - comment - - - - affinity - - - - _enabled - True - - - _coordinate - (408, 281) - - - _rotation - 180 - - - id - wifi_phy_hier_0 - - - maxoutbuf - 0 - - - minoutbuf - 0 - - - chan_est - chan_est - - - encoding - encoding - - - - blocks_message_strobe_0 - ieee802_11_ofdm_mac_0 - strobe - app in - - - blocks_multiply_const_vxx_0 - channels_channel_model_0 - 0 - 0 - - - blocks_pdu_to_tagged_stream_0 - blocks_null_sink_1 - 0 - 0 - - - channels_channel_model_0 - wifi_phy_hier_0 - 0 - 0 - - - foo_packet_pad2_0 - blocks_multiply_const_vxx_0 - 0 - 0 - - - foo_wireshark_connector_0 - blocks_file_sink_0 - 0 - 0 - - - ieee802_11_ofdm_mac_0 - wifi_phy_hier_0 - phy out - mac_in - - - ieee802_11_ofdm_parse_mac_0 - blocks_pdu_to_tagged_stream_0 - fer - pdus - - - wifi_phy_hier_0 - blocks_null_sink_0 - 1 - 0 - - - wifi_phy_hier_0 - ieee802_11_ofdm_parse_mac_0 - mac_out - in - - - wifi_phy_hier_0 - foo_packet_pad2_0 - 0 - 0 - - diff --git a/workspace/Makefile b/utils/simulations/awgn/Makefile similarity index 100% rename from workspace/Makefile rename to utils/simulations/awgn/Makefile diff --git a/workspace/parse.py b/utils/simulations/awgn/parse.py similarity index 100% rename from workspace/parse.py rename to utils/simulations/awgn/parse.py diff --git a/workspace/wifi_loopback_noGUI.grc b/utils/simulations/awgn/sim.grc similarity index 100% rename from workspace/wifi_loopback_noGUI.grc rename to utils/simulations/awgn/sim.grc diff --git a/workspace/plot.png b/workspace/plot.png deleted file mode 100644 index c134c4e..0000000 Binary files a/workspace/plot.png and /dev/null differ diff --git a/workspace/run b/workspace/run deleted file mode 100755 index 5e63b29..0000000 --- a/workspace/run +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -ntrials=20 - -if [ $1 ] -then - result_dir=$1 -else - now=`date '+%m_%d__%H_%M_%S'`; - result_dir="result_$now" -fi - -mkdir -p $result_dir -rm -rf $result_dir/* - -echo ">>> Storing results in ./$result_dir." -echo - -for e in {0..3} -do - for s in `seq 1.0 2 9.0` - do - for t in `seq 1 1 $ntrials` - do - echo - echo ">>> >>> Running trial $t of $ntrials." - make result=$result_dir t=$t n=20 c=1 s=$s o=0 e=$e i=100 - done - done -done - -./parse.py $result_dir $ntrials diff --git a/workspace/wifi_loopback_noGUI.py b/workspace/wifi_loopback_noGUI.py deleted file mode 100755 index 29d3f4c..0000000 --- a/workspace/wifi_loopback_noGUI.py +++ /dev/null @@ -1,192 +0,0 @@ -#!/usr/bin/env python2 -# -*- coding: utf-8 -*- -################################################## -# GNU Radio Python Flow Graph -# Title: Wifi Loopback Nogui -# Generated: Sat Nov 21 10:57:29 2015 -################################################## - -import os -import sys -sys.path.append(os.environ.get('GRC_HIER_PATH', os.path.expanduser('~/.grc_gnuradio'))) - -from gnuradio import blocks -from gnuradio import channels -from gnuradio import eng_notation -from gnuradio import gr -from gnuradio.eng_option import eng_option -from gnuradio.filter import firdes -from optparse import OptionParser -from wifi_phy_hier import wifi_phy_hier # grc-generated hier_block -import foo -import ieee802_11 -import math -import pmt - - -class wifi_loopback_noGUI(gr.top_block): - - def __init__(self, chan_est=1, encoding=0, freq_offset=0, interval=500, nmessages=50, ntrials=0, resultdir="0", snr=10): - gr.top_block.__init__(self, "Wifi Loopback Nogui") - - ################################################## - # Parameters - ################################################## - self.chan_est = chan_est - self.encoding = encoding - self.freq_offset = freq_offset - self.interval = interval - self.nmessages = nmessages - self.ntrials = ntrials - self.resultdir = resultdir - self.snr = snr - - ################################################## - # Variables - ################################################## - self.out_buf_size = out_buf_size = 96000 - - ################################################## - # Blocks - ################################################## - self.wifi_phy_hier_0 = wifi_phy_hier( - encoding=encoding, - chan_est=chan_est, - ) - self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_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_periodic_msg_source_0 = foo.periodic_msg_source(pmt.intern("Hello World!"), interval, nmessages, True, False) - self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 1000, 1000) - (self.foo_packet_pad2_0).set_min_output_buffer(96000) - self.channels_channel_model_0 = channels.channel_model( - noise_voltage=.5**.5, - frequency_offset=freq_offset, - epsilon=1.0, - taps=(1.0, ), - noise_seed=0, - block_tags=False - ) - self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1) - self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((((10**(snr/10.0))**0.5)/(2**0.5), )) - self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, "" + resultdir + "/ofdm_" + str(ntrials) + "_" + str(nmessages) + "_" + str(snr) + "_" + str(encoding) + "_" + str(interval) + ".pcap", False) - self.blocks_file_sink_0_0.set_unbuffered(True) - - ################################################## - # Connections - ################################################## - self.msg_connect((self.foo_periodic_msg_source_0, 'out'), (self.foo_wireshark_connector_0, 'in')) - self.msg_connect((self.foo_periodic_msg_source_0, 'out'), (self.ieee802_11_ofdm_mac_0, 'app in')) - self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'), (self.wifi_phy_hier_0, 'mac_in')) - self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.foo_wireshark_connector_0, 'in')) - self.connect((self.blocks_multiply_const_vxx_0, 0), (self.channels_channel_model_0, 0)) - self.connect((self.channels_channel_model_0, 0), (self.wifi_phy_hier_0, 0)) - self.connect((self.foo_packet_pad2_0, 0), (self.blocks_multiply_const_vxx_0, 0)) - self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0_0, 0)) - self.connect((self.wifi_phy_hier_0, 1), (self.blocks_null_sink_0, 0)) - self.connect((self.wifi_phy_hier_0, 0), (self.foo_packet_pad2_0, 0)) - - def get_chan_est(self): - return self.chan_est - - def set_chan_est(self, chan_est): - self.chan_est = chan_est - self.wifi_phy_hier_0.set_chan_est(self.chan_est) - - def get_encoding(self): - return self.encoding - - def set_encoding(self, encoding): - self.encoding = encoding - self.blocks_file_sink_0_0.open("" + self.resultdir + "/ofdm_" + str(self.ntrials) + "_" + str(self.nmessages) + "_" + str(self.snr) + "_" + str(self.encoding) + "_" + str(self.interval) + ".pcap") - self.wifi_phy_hier_0.set_encoding(self.encoding) - - def get_freq_offset(self): - return self.freq_offset - - def set_freq_offset(self, freq_offset): - self.freq_offset = freq_offset - self.channels_channel_model_0.set_frequency_offset(self.freq_offset) - - def get_interval(self): - return self.interval - - def set_interval(self, interval): - self.interval = interval - self.blocks_file_sink_0_0.open("" + self.resultdir + "/ofdm_" + str(self.ntrials) + "_" + str(self.nmessages) + "_" + str(self.snr) + "_" + str(self.encoding) + "_" + str(self.interval) + ".pcap") - - def get_nmessages(self): - return self.nmessages - - def set_nmessages(self, nmessages): - self.nmessages = nmessages - self.blocks_file_sink_0_0.open("" + self.resultdir + "/ofdm_" + str(self.ntrials) + "_" + str(self.nmessages) + "_" + str(self.snr) + "_" + str(self.encoding) + "_" + str(self.interval) + ".pcap") - - def get_ntrials(self): - return self.ntrials - - def set_ntrials(self, ntrials): - self.ntrials = ntrials - self.blocks_file_sink_0_0.open("" + self.resultdir + "/ofdm_" + str(self.ntrials) + "_" + str(self.nmessages) + "_" + str(self.snr) + "_" + str(self.encoding) + "_" + str(self.interval) + ".pcap") - - def get_resultdir(self): - return self.resultdir - - def set_resultdir(self, resultdir): - self.resultdir = resultdir - self.blocks_file_sink_0_0.open("" + self.resultdir + "/ofdm_" + str(self.ntrials) + "_" + str(self.nmessages) + "_" + str(self.snr) + "_" + str(self.encoding) + "_" + str(self.interval) + ".pcap") - - def get_snr(self): - return self.snr - - def set_snr(self, snr): - self.snr = snr - self.blocks_file_sink_0_0.open("" + self.resultdir + "/ofdm_" + str(self.ntrials) + "_" + str(self.nmessages) + "_" + str(self.snr) + "_" + str(self.encoding) + "_" + str(self.interval) + ".pcap") - self.blocks_multiply_const_vxx_0.set_k((((10**(self.snr/10.0))**0.5)/(2**0.5), )) - - def get_out_buf_size(self): - return self.out_buf_size - - def set_out_buf_size(self, out_buf_size): - self.out_buf_size = out_buf_size - - -def argument_parser(): - parser = OptionParser(option_class=eng_option, usage="%prog: [options]") - parser.add_option( - "-c", "--chan-est", dest="chan_est", type="intx", default=1, - help="Set chan_est [default=%default]") - parser.add_option( - "-e", "--encoding", dest="encoding", type="intx", default=0, - help="Set encoding [default=%default]") - parser.add_option( - "-o", "--freq-offset", dest="freq_offset", type="eng_float", default=eng_notation.num_to_str(0), - help="Set freq_offset [default=%default]") - parser.add_option( - "-i", "--interval", dest="interval", type="intx", default=500, - help="Set interval [default=%default]") - parser.add_option( - "-n", "--nmessages", dest="nmessages", type="intx", default=50, - help="Set nmessages [default=%default]") - parser.add_option( - "-t", "--ntrials", dest="ntrials", type="intx", default=0, - help="Set ntrials [default=%default]") - parser.add_option( - "-r", "--resultdir", dest="resultdir", type="string", default="0", - help="Set resultdir [default=%default]") - parser.add_option( - "-s", "--snr", dest="snr", type="eng_float", default=eng_notation.num_to_str(10), - help="Set snr [default=%default]") - return parser - - -def main(top_block_cls=wifi_loopback_noGUI, options=None): - if options is None: - options, _ = argument_parser().parse_args() - - tb = top_block_cls(chan_est=options.chan_est, encoding=options.encoding, freq_offset=options.freq_offset, interval=options.interval, nmessages=options.nmessages, ntrials=options.ntrials, resultdir=options.resultdir, snr=options.snr) - tb.start() - tb.wait() - - -if __name__ == '__main__': - main()