From 7eae9a9bf94813c3cb62800a699f9361dee6a027 Mon Sep 17 00:00:00 2001 From: theano Date: Sat, 31 Oct 2015 12:12:36 -0700 Subject: [PATCH] Create workspace area; make no-gui version of wifi_loopback --- examples/herpderp.grc | 1078 +++++++++++++++++++++++++++++ workspace/awgn.grc | 0 workspace/wifi_loopback.py | 173 +++++ workspace/wifi_loopback_noGUI.grc | 1078 +++++++++++++++++++++++++++++ 4 files changed, 2329 insertions(+) create mode 100644 examples/herpderp.grc create mode 100644 workspace/awgn.grc create mode 100755 workspace/wifi_loopback.py create mode 100644 workspace/wifi_loopback_noGUI.grc diff --git a/examples/herpderp.grc b/examples/herpderp.grc new file mode 100644 index 0000000..bb524a2 --- /dev/null +++ b/examples/herpderp.grc @@ -0,0 +1,1078 @@ + + + + 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/awgn.grc b/workspace/awgn.grc new file mode 100644 index 0000000..e69de29 diff --git a/workspace/wifi_loopback.py b/workspace/wifi_loopback.py new file mode 100755 index 0000000..8a619b7 --- /dev/null +++ b/workspace/wifi_loopback.py @@ -0,0 +1,173 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +################################################## +# GNU Radio Python Flow Graph +# Title: Wifi Loopback +# Generated: Sat Oct 31 12:11:06 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(gr.top_block): + + def __init__(self, chan_est=1, encoding=0, freq_offset=0, pdu_length=500, snr=10, interval=500): + gr.top_block.__init__(self, "Wifi Loopback") + + ################################################## + # Parameters + ################################################## + self.chan_est = chan_est + self.encoding = encoding + self.freq_offset = freq_offset + self.pdu_length = pdu_length + self.snr = snr + self.interval = interval + + ################################################## + # 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_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, True) + 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_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 500, 0) + (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_pdu_to_tagged_stream_0 = blocks.pdu_to_tagged_stream(blocks.float_t, "packet_len") + self.blocks_null_sink_1 = blocks.null_sink(gr.sizeof_float*1) + 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))**.5, )) + self.blocks_message_strobe_0 = blocks.message_strobe(pmt.intern("".join("x" for i in range(pdu_length))), interval) + + ################################################## + # Connections + ################################################## + self.msg_connect((self.blocks_message_strobe_0, 'strobe'), (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.ieee802_11_ofdm_parse_mac_0, 'fer'), (self.blocks_pdu_to_tagged_stream_0, 'pdus')) + self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_parse_mac_0, 'in')) + self.connect((self.blocks_multiply_const_vxx_0, 0), (self.channels_channel_model_0, 0)) + self.connect((self.blocks_pdu_to_tagged_stream_0, 0), (self.blocks_null_sink_1, 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.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.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_pdu_length(self): + return self.pdu_length + + def set_pdu_length(self, pdu_length): + self.pdu_length = pdu_length + self.blocks_message_strobe_0.set_msg(pmt.intern("".join("x" for i in range(self.pdu_length)))) + + def get_snr(self): + return self.snr + + def set_snr(self, snr): + self.snr = snr + self.blocks_multiply_const_vxx_0.set_k(((10**(self.snr/10.0))**.5, )) + + def get_interval(self): + return self.interval + + def set_interval(self, interval): + self.interval = interval + self.blocks_message_strobe_0.set_period(self.interval) + + 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( + "", "--chan-est", dest="chan_est", type="intx", default=1, + help="Set chan_est [default=%default]") + parser.add_option( + "", "--encoding", dest="encoding", type="intx", default=0, + help="Set encoding [default=%default]") + parser.add_option( + "", "--freq-offset", dest="freq_offset", type="eng_float", default=eng_notation.num_to_str(0), + help="Set freq_offset [default=%default]") + parser.add_option( + "", "--pdu-length", dest="pdu_length", type="intx", default=500, + help="Set pdu_length [default=%default]") + parser.add_option( + "", "--snr", dest="snr", type="eng_float", default=eng_notation.num_to_str(10), + help="Set snr [default=%default]") + parser.add_option( + "", "--interval", dest="interval", type="intx", default=500, + help="Set interval [default=%default]") + return parser + + +def main(top_block_cls=wifi_loopback, 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, pdu_length=options.pdu_length, snr=options.snr, interval=options.interval) + tb.start() + try: + raw_input('Press Enter to quit: ') + except EOFError: + pass + tb.stop() + tb.wait() + + +if __name__ == '__main__': + main() diff --git a/workspace/wifi_loopback_noGUI.grc b/workspace/wifi_loopback_noGUI.grc new file mode 100644 index 0000000..70a620b --- /dev/null +++ b/workspace/wifi_loopback_noGUI.grc @@ -0,0 +1,1078 @@ + + + + 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 + 500 + + + + 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 + +