def __init__(self, addr, no_usrp, initialFreq, otw, source, no_self_loop,
                 debug_MAC, wireshark):
        gr.top_block.__init__(
            self, "IEEE 802.15.4m Slave Node Transceiver using OQPSK")
        Qt.QWidget.__init__(self)
        self.setWindowTitle(
            "IEEE 802.15.4m Slave Node Transceiver using OQPSK")
        qtgui.util.check_set_qss()
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "transceiver_OQPSK_Slave")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.addr = addr
        self.no_usrp = no_usrp
        self.freq = initialFreq
        self.otw = otw
        self.no_self_loop = no_self_loop
        self.debug_MAC = debug_MAC
        self.source = source
        self.wireshark = wireshark
        self.tx_gain = tx_gain = 0.25
        self.rx_gain = rx_gain = 0.25
        ##################################################
        # Blocks
        ##################################################
        if self.no_usrp:
            self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                     4 * 1e6, True)
            ## Using files instead of USRPs
            self.blocks_file_source_slave = blocks.file_source(
                gr.sizeof_gr_complex * 1,
                (os.getcwd() + "/utils/masterFileSink"), True)
            self.blocks_file_sink_slave = blocks.file_sink(
                gr.sizeof_gr_complex * 1,
                (os.getcwd() + "/utils/slaveFileSink"), False)
            self.blocks_file_sink_slave.set_unbuffered(False)
        else:
            ## usrp_source
            self.uhd_usrp_source_0 = uhd.usrp_source(
                ",".join((self.addr, "")),
                uhd.stream_args(
                    cpu_format="fc32",
                    channels=range(1),
                ),
            )
            ## usrp_sink
            self.uhd_usrp_sink_0 = uhd.usrp_sink(
                ",".join((self.addr, "")),
                uhd.stream_args(
                    cpu_format="fc32",
                    channels=range(1),
                ),
            )

            # TODO Explain the usage
            self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                                uhd.ALL_MBOARDS)
            self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()),
                                              uhd.ALL_MBOARDS)
            self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0)
            self.uhd_usrp_sink_0.set_normalized_gain(tx_gain, 0)

        self._tx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        "tx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self._rx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        "rx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._rx_gain_win)
        self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c(
            1024,  #size
            firdes.WIN_BLACKMAN_hARRIS,  #wintype
            0,  #fc
            4e6,  #bw
            "",  #name
            1  #number of inputs
        )
        self.qtgui_freq_sink_x_0.set_update_time(0.10)
        self.qtgui_freq_sink_x_0.set_y_axis(-140, 10)
        self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB')
        self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0,
                                                  "")
        self.qtgui_freq_sink_x_0.enable_autoscale(False)
        self.qtgui_freq_sink_x_0.enable_grid(False)
        self.qtgui_freq_sink_x_0.set_fft_average(1.0)
        self.qtgui_freq_sink_x_0.enable_axis_labels(True)
        self.qtgui_freq_sink_x_0.enable_control_panel(False)

        if not True:
            self.qtgui_freq_sink_x_0.disable_legend()

        if "complex" == "float" or "complex" == "msg_float":
            self.qtgui_freq_sink_x_0.set_plot_pos_half(not True)

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "green", "black", "cyan", "magenta", "yellow",
            "dark red", "dark green", "dark blue"
        ]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_freq_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_freq_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_freq_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_freq_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_freq_sink_x_0_win = sip.wrapinstance(
            self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win)

        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))
        self.ieee802_15_4_oqpsk_phy_0 = ieee802_15_4_oqpsk_phy()
        # 802.15.4m MAC layer #
        #self.ieee802_15_4_mac_0 = ieee802_15_4.mac(True)
        self.ieee802_15_4_mac_0 = mac_15_4m(self.debug_MAC, self.no_self_loop)
        # Ethernet Encapsulation #TODO explain its usage, Specific to 802.11 ?
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(True)

        self._freq_options = [
            TVWS_channelmap.get_TVWS_freq(i) for i in range(2, 69)
        ]
        self._freq_labels = [str(i) for i in range(2, 69)]
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel('Channel' + ": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels:
            self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freq(self._freq_options[i]))

        self.top_layout.addWidget(self._freq_tool_bar)

        ##################################################
        # Asynch Message Connections
        ##################################################
        if self.source == "tuntap":  # Tuntap Block to quantify the achievable throughput
            print "TUNTAP"
            self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap1", 440)
            self.msg_connect(self.ieee802_11_ether_encap_0, "to tap",
                             self.blocks_tuntap_pdu_0, "pdus")
            self.msg_connect(self.blocks_tuntap_pdu_0, "pdus",
                             self.ieee802_11_ether_encap_0, "from tap")

            self.msg_connect(self.ieee802_15_4_rime_stack_0, "bcout",
                             self.ieee802_11_ether_encap_0, "from wifi")
            self.msg_connect(self.ieee802_11_ether_encap_0, "to wifi",
                             self.ieee802_15_4_rime_stack_0, "bcin")

        elif self.source == "socket":  #using PDU Sockets instead #TODO Test ME !
            self.blocks_socket_pdu_0_Tx = blocks.socket_pdu(
                "UDP_SERVER", "localhost", "52004", 10000)
            self.blocks_socket_pdu_0_Rx = blocks.socket_pdu(
                "UDP_CLIENT", "localhost", "3333", 10000)

            self.msg_connect(self.ieee802_15_4_rime_stack_0, "bcout",
                             self.blocks_socket_pdu_0_Rx, "pdus")
            self.msg_connect(self.blocks_socket_pdu_0_Tx, "pdus",
                             self.ieee802_15_4_rime_stack_0, "bcin")

        elif self.source == "strobe":
            self.blocks_message_strobe_0 = blocks.message_strobe(
                pmt.intern("Hello World!\n"), 1000)
            self.msg_connect((self.blocks_message_strobe_0, 'strobe'),
                             (self.ieee802_15_4_rime_stack_0, 'bcin'))

        if self.wireshark:
            self.foo_wireshark_connector_0 = foo.wireshark_connector(127, True)

            self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                       "/tmp/ofdm.pcap", True)
            self.blocks_file_sink_0.set_unbuffered(True)

            self.connect((self.foo_wireshark_connector_0, 0),
                         (self.blocks_file_sink_0, 0))

            self.msg_connect(self.ieee802_15_4_mac_0, "PHY",
                             self.foo_wireshark_connector_0, "in")
            self.msg_connect(self.ieee802_15_4_oqpsk_phy_0, "mac_out",
                             self.foo_wireshark_connector_0, "in")

        self.msg_connect((self.ieee802_15_4_mac_0, 'pdu out'),
                         (self.ieee802_15_4_oqpsk_phy_0, 'txin'))
        self.msg_connect((self.ieee802_15_4_mac_0, 'app out'),
                         (self.ieee802_15_4_rime_stack_0, 'fromMAC'))
        self.msg_connect((self.ieee802_15_4_oqpsk_phy_0, 'rxout'),
                         (self.ieee802_15_4_mac_0, 'pdu in'))
        self.msg_connect((self.ieee802_15_4_rime_stack_0, 'toMAC'),
                         (self.ieee802_15_4_mac_0, 'app in'))

        ##################################################
        # Connections
        ##################################################
        self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                     (self.qtgui_freq_sink_x_0, 0))
        if self.no_usrp:
            self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                         ((self.blocks_file_sink_slave, 0)))
            self.connect((self.blocks_file_source_slave, 0),
                         (self.ieee802_15_4_oqpsk_phy_0, 0))
        else:
            self.connect((self.ieee802_15_4_oqpsk_phy_0, 0),
                         ((self.uhd_usrp_sink_0, 0)))
            self.connect((self.uhd_usrp_source_0, 0),
                         (self.ieee802_15_4_oqpsk_phy_0, 0))
Exemplo n.º 2
0
    def __init__(self):
        gr.top_block.__init__(self, "Wifi Transceiver Csma Tuntap 4")

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 750e-3
        self.samp_rate = samp_rate = 5e6
        self.rx_gain = rx_gain = 500e-3
        self.pdu_length = pdu_length = 500
        self.mac_dst = mac_dst = [0x12,0x34,0x56,0x78,0x90,0xaa]
        self.mac_addr = mac_addr = [0x12,0x34,0x56,0x78,0x90,0xae]
        self.lo_offset = lo_offset = 0
        self.interval = interval = 1e3
        self.freq = freq = 2.52e9
        self.encoding = encoding = 0
        self.chan_est = chan_est = 0

        ##################################################
        # Blocks
        ##################################################
        self.wifi_phy_hier_0 = wifi_phy_hier(
            bandwidth=samp_rate,
            chan_est=chan_est,
            encoding=encoding,
            frequency=freq,
            sensitivity=0.56,
        )
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0)
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	"packet_len",
        )
        self.uhd_usrp_sink_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_sink_0_0.set_normalized_gain(tx_gain, 0)
        self.toolkit_cs_0 = toolkit.cs()
        self.macprotocols_frame_buffer_0 = macprotocols.frame_buffer(256, True, 0, True)
        self.macprotocols_csma_ca_0 = macprotocols.csma_ca((mac_addr), 9, 16, 34, 1000, -60, True)
        self.logpwrfft_x_0 = logpwrfft.logpwrfft_c(
        	sample_rate=samp_rate,
        	fft_size=64,
        	ref_scale=2,
        	frame_rate=30,
        	avg_alpha=1.0,
        	average=False,
        )
        self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(False, False)
        self.ieee802_11_mac_0_0 = ieee802_11.mac((mac_addr), (mac_dst), ([0xff, 0xff, 0xff, 0xff, 0xff, 255]))
        (self.ieee802_11_mac_0_0).set_min_output_buffer(256)
        (self.ieee802_11_mac_0_0).set_max_output_buffer(4096)
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(False)
        self.foo_wireshark_connector_0_0 = foo.wireshark_connector(127, False)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.blocks_vector_to_stream_0 = blocks.vector_to_stream(gr.sizeof_float*1, 64)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.6, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_file_sink_0_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/wifi_rx.pcap", False)
        self.blocks_file_sink_0_0.set_unbuffered(True)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/wifi_rx_all.pcap", False)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.ieee802_11_ether_encap_0, 'from tap'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to tap'), (self.blocks_tuntap_pdu_0, 'pdus'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'), (self.ieee802_11_mac_0_0, 'app in'))    
        self.msg_connect((self.ieee802_11_mac_0_0, 'phy out'), (self.macprotocols_frame_buffer_0, 'app in'))    
        self.msg_connect((self.macprotocols_csma_ca_0, 'frame to app'), (self.foo_wireshark_connector_0_0, 'in'))    
        self.msg_connect((self.macprotocols_csma_ca_0, 'frame to app'), (self.ieee802_11_ether_encap_0, 'from wifi'))    
        self.msg_connect((self.macprotocols_csma_ca_0, 'frame to app'), (self.ieee802_11_mac_0_0, 'phy in'))    
        self.msg_connect((self.macprotocols_csma_ca_0, 'frame request'), (self.macprotocols_frame_buffer_0, 'req in 0'))    
        self.msg_connect((self.macprotocols_csma_ca_0, 'request to cs'), (self.toolkit_cs_0, 'in_msg'))    
        self.msg_connect((self.macprotocols_csma_ca_0, 'frame to phy'), (self.wifi_phy_hier_0, 'mac_in'))    
        self.msg_connect((self.macprotocols_frame_buffer_0, 'frame out 0'), (self.macprotocols_csma_ca_0, 'frame from buffer'))    
        self.msg_connect((self.toolkit_cs_0, 'out_msg'), (self.macprotocols_csma_ca_0, 'cs in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.foo_wireshark_connector_0, 'in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_parse_mac_0, 'in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.macprotocols_csma_ca_0, 'frame from phy'))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0))    
        self.connect((self.blocks_vector_to_stream_0, 0), (self.toolkit_cs_0, 0))    
        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0_0, 0))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.foo_wireshark_connector_0_0, 0), (self.blocks_file_sink_0_0, 0))    
        self.connect((self.logpwrfft_x_0, 0), (self.blocks_vector_to_stream_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.logpwrfft_x_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.wifi_phy_hier_0, 0))    
        self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Transceiver")

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 40
        self.samp_rate = samp_rate = 20e6
        self.rx_gain = rx_gain = 40
        self.mult = mult = 0.38
        self.lo_offset = lo_offset = 0
        self.freq = freq = 2.412e9
        self.encoding = encoding = 0

        ##################################################
        # Blocks
        ##################################################
        _tx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	label='tx_gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_tx_gain_sizer)
        self._samp_rate_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.samp_rate,
        	callback=self.set_samp_rate,
        	label="Sample Rate",
        	choices=[5e6,10e6, 20e6],
        	labels=["5MHz", "10 MHz", "20 MHz"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        _rx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_gain_sizer,
        	value=self.rx_gain,
        	callback=self.set_rx_gain,
        	label='rx_gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_gain_sizer,
        	value=self.rx_gain,
        	callback=self.set_rx_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_rx_gain_sizer)
        _mult_sizer = wx.BoxSizer(wx.VERTICAL)
        self._mult_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_mult_sizer,
        	value=self.mult,
        	callback=self.set_mult,
        	label='mult',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._mult_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_mult_sizer,
        	value=self.mult,
        	callback=self.set_mult,
        	minimum=0,
        	maximum=1,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_mult_sizer)
        self._lo_offset_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.lo_offset,
        	callback=self.set_lo_offset,
        	label="LO Offset",
        	choices=[0, 6e6, 11e6],
        	labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        self._freq_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Channel",
        	choices=[2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0],
        	labels=['  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g', '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g', '  6 | 2437.0 | 11g', '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g', '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'],
        )
        self.Add(self._freq_chooser)
        self._encoding_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.encoding,
        	callback=self.set_encoding,
        	label="Encoding",
        	choices=[0,1,2,3,4,5,6,7],
        	labels=["BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._encoding_chooser)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=5000,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=True,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wifi_phy_hier_0 = wifi_phy_hier(
            chan_est=0,
            encoding=0,
            sensitivity=0.56,
        )
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	"packet_len",
        )
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, True)
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x30, 0x14, 0x4a, 0xe6, 0x46, 0xe4]), ([0x02, 0x11, 0x87, 0xBA, 0x68, 0x3B]))
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(False)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/ofdm.pcap", True)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.ieee802_11_ether_encap_0, 'from tap'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to tap'), (self.blocks_tuntap_pdu_0, 'pdus'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'), (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.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ether_encap_0, 'from wifi'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_mac_0, 'phy in'))    
        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.foo_packet_pad2_0, 0))    
        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.wifi_phy_hier_0, 0))    
        self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.wifi_phy_hier_0, 1), (self.wxgui_scopesink2_0, 0))    
    def __init__(self):
        gr.top_block.__init__(self, "Uniflex Wifi Transceiver")

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 0.75
        self.samp_rate = samp_rate = 20e6
        self.rx_gain = rx_gain = 0.75
        self.lo_offset = lo_offset = 0
        self.freq = freq = 5890000000
        self.encoding = encoding = 0
        self.chan_est = chan_est = 0

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(
            ("localhost", 8080), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        self.xmlrpc_server_0_thread = threading.Thread(
            target=self.xmlrpc_server_0.serve_forever)
        self.xmlrpc_server_0_thread.daemon = True
        self.xmlrpc_server_0_thread.start()
        self.wifi_phy_hier_0 = wifi_phy_hier(
            bandwidth=samp_rate,
            chan_est=chan_est,
            encoding=encoding,
            frequency=freq,
            sensitivity=0.56,
        )
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                            uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(
            uhd.tune_request(freq,
                             rf_freq=freq - lo_offset,
                             rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
            "packet_len",
        )
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()),
                                          uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(
            uhd.tune_request(freq,
                             rf_freq=freq - lo_offset,
                             rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_sink_0.set_normalized_gain(tx_gain, 0)
        self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(False, True)
        self.ieee802_11_mac_0 = ieee802_11.mac(
            ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]),
            ([0x30, 0x14, 0x4a, 0xe6, 0x46, 0xe4]),
            ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]))
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(False)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000,
                                                 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.6, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   "/tmp/wifi.pcap", True)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'),
                         (self.ieee802_11_ether_encap_0, 'from tap'))
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to tap'),
                         (self.blocks_tuntap_pdu_0, 'pdus'))
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'),
                         (self.ieee802_11_mac_0, 'app in'))
        self.msg_connect((self.ieee802_11_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.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_ether_encap_0, 'from wifi'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_mac_0, 'phy in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_parse_mac_0, 'in'))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.foo_packet_pad2_0, 0))
        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.wifi_phy_hier_0, 0))
        self.connect((self.wifi_phy_hier_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
Exemplo n.º 5
0
    def __init__(self, addr, no_usrp, rate, lo_offset, encod, otw, debug):

        grc_wxgui.top_block_gui.__init__(self, title="TransceiverMaster")

        # Variables
        self.addr = addr
        self.no_usrp = no_usrp
        self.samp_rate = rate
        self.otw = otw
        self.debug = debug
        self.lo_offset = lo_offset

        # Blocks
        if self.no_usrp:
            self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                     self.samp_rate * 1e6,
                                                     True)
            ## Using files instead of USRPs
            self.blocks_file_source_Master = blocks.file_source(
                gr.sizeof_gr_complex * 1,
                (os.getcwd() + "/utils/fileSourceMaster"), True)
            self.blocks_file_sink_Master = blocks.file_sink(
                gr.sizeof_gr_complex * 1,
                (os.getcwd() + "/utils/fileSinkMaster"), False)
            self.blocks_file_sink_Master.set_unbuffered(False)

        else:
            ## usrp_source
            self.uhd_usrp_source_0 = uhd.usrp_source(
                ",".join((self.addr, "")),
                uhd.stream_args(
                    cpu_format="fc32",
                    otw_format=self.otw,
                    channels=range(1),
                ),
            )
            self.uhd_usrp_source_0.set_time_now(uhd.time_spec(
                time.time()), uhd.ALL_MBOARDS)  # TODO Explain the usage

            ## usrp_sink
            self.uhd_usrp_sink_0 = uhd.usrp_sink(
                ",".join((self.addr, "")),
                uhd.stream_args(
                    cpu_format="fc32",
                    otw_format=self.otw,
                    channels=range(1),
                ),
                "packet_len",
            )

    # 802.11 a,g,p PHY Layer OFDM
    # Encoding choices=[0,1,2,3,4,5,6,7]="BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"
        self.PHY = wifi_phy_hier(encoding=int(encod), )

        self.foo_packet_pad2_0 = foo.packet_pad2(
            False, False, 0.001, 0, 10000)  #TODO explain its usage
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)

        # Multiply Const Block
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.38, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)

        # 802.11 a,g,p OFDM MAC Layer
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(
            ([0x33, 0x33, 0x33, 0x33, 0x33, 0x33]),
            ([0x32, 0x32, 0x32, 0x32, 0x32, 0x32]),
            ([0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc]), self.debug, True)

        # ofdm_parse_mac block for debugging purpose
        self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(
            False,
            False)  #TODO make it parse frames' structure of the MAC am using

        # Ethernet Encapsulation #TODO explain its usage
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(True)

        # Asynch Message Connections

        self.blocks_socket_pdu_0_Tx = blocks.socket_pdu(
            "UDP_SERVER", "localhost", "52002", 10000)
        self.blocks_socket_pdu_0_Rx = blocks.socket_pdu(
            "UDP_CLIENT", "localhost", "3334", 10000)

        self.msg_connect(self.ieee802_11_ofdm_mac_0, "app out",
                         self.blocks_socket_pdu_0_Rx, "pdus")
        self.msg_connect(self.blocks_socket_pdu_0_Tx, "pdus",
                         self.ieee802_11_ofdm_mac_0, "app in")

        self.msg_connect(self.PHY, "mac_out", self.ieee802_11_ofdm_parse_mac_0,
                         "in")
        self.msg_connect(self.PHY, "mac_out", self.ieee802_11_ofdm_mac_0,
                         "phy in")
        self.msg_connect(self.ieee802_11_ofdm_mac_0, "phy out", self.PHY,
                         "mac_in")

        # Connections

        if self.no_usrp:
            self.connect((self.PHY, 0), (self.blocks_multiply_const_vxx_0, 0))
            self.connect((self.blocks_file_source_Master, 0), (self.PHY, 0))
            self.connect((self.foo_packet_pad2_0, 0),
                         (self.blocks_file_sink_Master, 0))
            self.connect((self.blocks_multiply_const_vxx_0, 0),
                         (self.foo_packet_pad2_0, 0))
        else:
            self.connect((self.PHY, 0), (self.blocks_multiply_const_vxx_0, 0))
            self.connect((self.uhd_usrp_source_0, 0), (self.PHY, 0))
            self.connect((self.foo_packet_pad2_0, 0),
                         (self.uhd_usrp_sink_0, 0))
            self.connect((self.blocks_multiply_const_vxx_0, 0),
                         (self.foo_packet_pad2_0, 0))

        if not self.lo_offset:
            self.lo_offset = self.samp_rate / 2.0
        print "LO offset set to", self.lo_offset / 1e6, "MHz"
Exemplo n.º 6
0
    def __init__(self, addr, no_usrp, rate, lo_offset, encod, rime, otw,
                 source, no_self_loop, debug_MAC):
        grc_wxgui.top_block_gui.__init__(self, title="TransceiverSlave")

        ##################################################
        # Variables
        ##################################################
        self.addr = addr
        self.no_usrp = no_usrp
        self.samp_rate = rate
        self.rime = rime
        self.otw = otw
        self.no_self_loop = no_self_loop
        self.debug_MAC = debug_MAC
        self.lo_offset = lo_offset
        ##################################################
        # Blocks
        ##################################################
        if self.no_usrp:
            self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1,
                                                     self.samp_rate * 1e6,
                                                     True)
            ################################
            ## Using files instead of USRPs
            ###############################
            self.blocks_slaveFileSource = blocks.file_source(
                gr.sizeof_gr_complex * 1, (os.getcwd() + "/masterFileSink"),
                True)
            self.blocks_slaveFileSink = blocks.file_sink(
                gr.sizeof_gr_complex * 1, (os.getcwd() + "/slaveFileSink"),
                False)
            self.blocks_slaveFileSink.set_unbuffered(False)

        else:
            ############
            ## source
            ############
            self.uhd_usrp_source_0 = uhd.usrp_source(
                ",".join((self.addr, "")),
                stream_args=uhd.stream_args(
                    cpu_format="fc32",
                    otw_format=self.otw,
                    channels=range(1),
                ),
            )

            # TODO Explain the usage
            self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()),
                                                uhd.ALL_MBOARDS)

            #############
            ## sink
            #############
            self.uhd_usrp_sink_0 = uhd.usrp_sink(
                ",".join((self.addr, "")),
                uhd.stream_args(
                    cpu_format="fc32",
                    otw_format=self.otw,
                    channels=range(1),
                ),
                "packet_len",
            )

            # TODO Explain the usage
            self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()),
                                              uhd.ALL_MBOARDS)

        # 802.15.4 PHY Layer O-QPSK
        #self.PHY = ieee802_15_4_phy()

        # 802.11 a,g,p PHY Layer OFDM
        # Encoding choices=[0,1,2,3,4,5,6,7]="BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"
        self.PHY = wifi_phy_hier(encoding=int(encod), )

        # Foo block #TODO explain its usage
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 0,
                                                 10000)  ## ?! ##
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)

        # Multiply Const Block
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc(
            (0.38, ))  #mult = 0.38
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)

        # 802.15.4m MAC layer #
        self.MAC = mac(self.debug_MAC, self.no_self_loop)

        # 802.11 a,g,p OFDM MAC Layer
        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]))

        # ofdm_parse_mac block for debugging purpose TODO Modify it so that it parse the frames structure of the MAC am using
        self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(
            False, True)

        # Communication Layer RIME Stack
        self.ieee802_15_4_rime_stack_0 = ieee802_15_4.rime_stack(
            ([129]), ([131]), ([132]), ([23, 42]))

        # Ethernet Encapsulation #TODO explain its usage
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(True)

        ##################################################
        # Asynch Message Connections
        ##################################################

        if self.rime:

            if source == "tuntap":  # Tuntap Block to quantify the achievable throughput
                self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, True)
                # istunFlag == True: TUN(IP Packet)
                # 	    == False: TAP(Ethernet Frame)
                self.msg_connect(self.ieee802_11_ether_encap_0, "to tap",
                                 self.blocks_tuntap_pdu_0, "pdus")
                self.msg_connect(self.blocks_tuntap_pdu_0, "pdus",
                                 self.ieee802_11_ether_encap_0, "from tap")

                self.msg_connect(self.ieee802_15_4_rime_stack_0, "bcout",
                                 self.ieee802_11_ether_encap_0, "from wifi")
                self.msg_connect(self.ieee802_11_ether_encap_0, "to wifi",
                                 self.ieee802_15_4_rime_stack_0, "bcin")

            else:  #using PDU Sockets instead #TODO Test ME !
                self.blocks_socket_pdu_0_Tx = blocks.socket_pdu(
                    "UDP_SERVER", "localhost", "52004", 10000)
                self.blocks_socket_pdu_0_Rx = blocks.socket_pdu(
                    "UDP_CLIENT", "localhost", "3333", 10000)

                self.msg_connect(self.ieee802_15_4_rime_stack_0, "bcout",
                                 self.self.blocks_socket_pdu_0_Rx, "pdus")
                self.msg_connect(self.blocks_socket_pdu_0_Tx, "pdus",
                                 self.ieee802_15_4_rime_stack_0, "bcin")

            self.msg_connect(self.ieee802_15_4_rime_stack_0, "toMAC",
                             self.ieee802_11_ofdm_parse_mac_0, "app in")
            self.msg_connect(self.ieee802_11_ofdm_parse_mac_0, "app out",
                             self.ieee802_15_4_rime_stack_0, "fromMAC")
        else:

            if source == "tuntap":  # Tuntap Block to quantify the achievable throughput
                # istunFlag == True: TUN(IP Packet)
                #           == False: TAP(Ethernet Frame)
                self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, True)
                self.msg_connect(self.ieee802_11_ether_encap_0, "to tap",
                                 self.blocks_tuntap_pdu_0, "pdus")
                self.msg_connect(self.blocks_tuntap_pdu_0, "pdus",
                                 self.ieee802_11_ether_encap_0, "from tap")

                self.msg_connect(self.ieee802_11_ofdm_mac_0, "app out",
                                 self.blocks_tuntap_pdu_0, "pdus")
                self.msg_connect(self.blocks_tuntap_pdu_0, "pdus",
                                 self.ieee802_11_ofdm_mac_0, "app in")

#print "Using Tap interface (IP) ==> No ethernet Encapsulation used !!"
#self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, True)
#self.msg_connect(self.ieee802_11_ofdm_mac_0, "app out", self.blocks_tuntap_pdu_0, "pdus")
#self.msg_connect(self.blocks_tuntap_pdu_0, "pdus", self.ieee802_11_ofdm_mac_0, "app in")

            else:  ##using PDU Sockets instead #TODO Test ME !
                self.blocks_socket_pdu_0_Tx = blocks.socket_pdu(
                    "UDP_SERVER", "localhost", "52004", 10000)
                self.blocks_socket_pdu_0_Rx = blocks.socket_pdu(
                    "UDP_CLIENT", "localhost", "3333", 10000)

                self.msg_connect(self.ieee802_11_ofdm_mac_0, "app out",
                                 self.blocks_socket_pdu_0_Rx, "pdus")
                self.msg_connect(self.blocks_socket_pdu_0_Tx, "pdus",
                                 self.ieee802_11_ofdm_mac_0, "app in")

        ## Debugging at the MAC level To parse at the level of MAC ! Look at the flowgraph
        ##self.msg_connect(self.PHY, "mac_out", self.ieee802_11_ofdm_parse_mac_0, "in")
        self.msg_connect(self.PHY, "mac_out", self.ieee802_11_ofdm_parse_mac_0,
                         "in")
        self.msg_connect(self.PHY, "mac_out", self.ieee802_11_ofdm_mac_0,
                         "phy in")
        self.msg_connect(self.ieee802_11_ofdm_mac_0, "phy out", self.PHY,
                         "mac_in")

        ##################################################
        # Connections
        ##################################################

        if self.no_usrp:
            self.connect((self.PHY, 0), (self.blocks_multiply_const_vxx_0, 0))
            self.connect((self.blocks_slaveFileSource, 0), (self.PHY, 0))
            self.connect((self.foo_packet_pad2_0, 0),
                         (self.blocks_slaveFileSink, 0))
            self.connect((self.blocks_multiply_const_vxx_0, 0),
                         (self.foo_packet_pad2_0, 0))
        else:
            self.connect((self.PHY, 0), (self.blocks_multiply_const_vxx_0, 0))
            self.connect((self.uhd_usrp_source_0, 0), (self.PHY, 0))
            self.connect((self.foo_packet_pad2_0, 0),
                         (self.uhd_usrp_sink_0, 0))
            self.connect((self.blocks_multiply_const_vxx_0, 0),
                         (self.foo_packet_pad2_0, 0))
Exemplo n.º 7
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Transceiver")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 15
        self.samp_rate = samp_rate = 10e6
        self.rx_gain = rx_gain = 5
        self.mult = mult = 0.38
        self.lo_offset = lo_offset = 0
        self.freq = freq = 5.89e9
        self.encoding = encoding = 0

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.samp_rate,
        	callback=self.set_samp_rate,
        	label="Sample Rate",
        	choices=[5e6,10e6, 20e6],
        	labels=["5MHz", "10 MHz", "20 MHz"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        _mult_sizer = wx.BoxSizer(wx.VERTICAL)
        self._mult_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_mult_sizer,
        	value=self.mult,
        	callback=self.set_mult,
        	label='mult',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._mult_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_mult_sizer,
        	value=self.mult,
        	callback=self.set_mult,
        	minimum=0,
        	maximum=1,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_mult_sizer)
        self._encoding_chooser = forms.radio_buttons(
        	parent=self.GetWin(),
        	value=self.encoding,
        	callback=self.set_encoding,
        	label="Encoding",
        	choices=[0,1,2,3,4,5,6,7],
        	labels=["BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"],
        	style=wx.RA_HORIZONTAL,
        )
        self.Add(self._encoding_chooser)
        self.wxgui_scopesink2_0_0 = scopesink2.scope_sink_c(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=5000,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=False,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0_0.win)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
        	self.GetWin(),
        	title="Scope Plot",
        	sample_rate=5000,
        	v_scale=0,
        	v_offset=0,
        	t_scale=0,
        	ac_couple=False,
        	xy_mode=True,
        	num_inputs=1,
        	trig_mode=wxgui.TRIG_MODE_AUTO,
        	y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wifi_phy_hier_0_0 = wifi_phy_hier(
            chan_est=0,
            encoding=0,
        )
        self.wifi_phy_hier_0 = wifi_phy_hier(
            chan_est=0,
            encoding=0,
        )
        _tx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	label='tx_gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._tx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_tx_gain_sizer,
        	value=self.tx_gain,
        	callback=self.set_tx_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_tx_gain_sizer)
        _rx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_gain_text_box = forms.text_box(
        	parent=self.GetWin(),
        	sizer=_rx_gain_sizer,
        	value=self.rx_gain,
        	callback=self.set_rx_gain,
        	label='rx_gain',
        	converter=forms.float_converter(),
        	proportion=0,
        )
        self._rx_gain_slider = forms.slider(
        	parent=self.GetWin(),
        	sizer=_rx_gain_sizer,
        	value=self.rx_gain,
        	callback=self.set_rx_gain,
        	minimum=0,
        	maximum=100,
        	num_steps=100,
        	style=wx.SL_HORIZONTAL,
        	cast=float,
        	proportion=1,
        )
        self.Add(_rx_gain_sizer)
        self._lo_offset_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.lo_offset,
        	callback=self.set_lo_offset,
        	label="LO Offset",
        	choices=[0, 6e6, 11e6],
        	labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        self.ieee802_11_ofdm_parse_mac_0_0 = ieee802_11.ofdm_parse_mac(False, True)
        self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, True)
        self.ieee802_11_ofdm_mac_0_0 = ieee802_11.ofdm_mac(([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]))
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]))
        self.ieee802_11_ether_encap_0_0 = ieee802_11.ether_encap(False)
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(False)
        self._freq_chooser = forms.drop_down(
        	parent=self.GetWin(),
        	value=self.freq,
        	callback=self.set_freq,
        	label="Channel",
        	choices=[2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0, 5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0, 5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0, 5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0, 5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0, 5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0, 5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0],
        	labels=['  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g', '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g', '  6 | 2437.0 | 11g', '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g', '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g', ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a', ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a', ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a', '100 | 5500.0 | 11a', '104 | 5520.0 | 11a', '108 | 5540.0 | 11a', '112 | 5560.0 | 11a', '116 | 5580.0 | 11a', '120 | 5600.0 | 11a', '124 | 5620.0 | 11a', '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '136 | 5680.0 | 11a', '140 | 5700.0 | 11a', '149 | 5745.0 | 11a', '153 | 5765.0 | 11a', '157 | 5785.0 | 11a', '161 | 5805.0 | 11a', '165 | 5825.0 | 11a', '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p', '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p', '184 | 5920.0 | 11p'],
        )
        self.Add(self._freq_chooser)
        self.foo_packet_pad2_0_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000)
        (self.foo_packet_pad2_0_0).set_min_output_buffer(100000)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.blocks_tuntap_pdu_0_0 = blocks.tuntap_pdu("tap1", 1500, False)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 1500, False)
        self.blocks_throttle_1 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, samp_rate,True)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vcc((mult, ))
        (self.blocks_multiply_const_vxx_0_0).set_min_output_buffer(100000)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.ieee802_11_ether_encap_0, 'from tap'))    
        self.msg_connect((self.blocks_tuntap_pdu_0_0, 'pdus'), (self.ieee802_11_ether_encap_0_0, 'from tap'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to tap'), (self.blocks_tuntap_pdu_0, 'pdus'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'), (self.ieee802_11_ofdm_mac_0, 'app in'))    
        self.msg_connect((self.ieee802_11_ether_encap_0_0, 'to tap'), (self.blocks_tuntap_pdu_0_0, 'pdus'))    
        self.msg_connect((self.ieee802_11_ether_encap_0_0, 'to wifi'), (self.ieee802_11_ofdm_mac_0_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_mac_0_0, 'phy out'), (self.wifi_phy_hier_0_0, 'mac_in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ether_encap_0, 'from wifi'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_mac_0, 'phy in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ofdm_parse_mac_0, 'in'))    
        self.msg_connect((self.wifi_phy_hier_0_0, 'mac_out'), (self.ieee802_11_ether_encap_0_0, 'from wifi'))    
        self.msg_connect((self.wifi_phy_hier_0_0, 'mac_out'), (self.ieee802_11_ofdm_mac_0_0, 'phy in'))    
        self.msg_connect((self.wifi_phy_hier_0_0, 'mac_out'), (self.ieee802_11_ofdm_parse_mac_0_0, 'in'))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0))    
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.foo_packet_pad2_0_0, 0))    
        self.connect((self.blocks_throttle_0, 0), (self.wifi_phy_hier_0_0, 0))    
        self.connect((self.blocks_throttle_1, 0), (self.wifi_phy_hier_0, 0))    
        self.connect((self.foo_packet_pad2_0, 0), (self.blocks_throttle_1, 0))    
        self.connect((self.foo_packet_pad2_0_0, 0), (self.blocks_throttle_0, 0))    
        self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.wifi_phy_hier_0, 1), (self.wxgui_scopesink2_0, 0))    
        self.connect((self.wifi_phy_hier_0_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))    
        self.connect((self.wifi_phy_hier_0_0, 1), (self.wxgui_scopesink2_0_0, 0))    
Exemplo n.º 8
0
    def __init__(self):
        grc_wxgui.top_block_gui.__init__(self, title="Wifi Transceiver Juan")
        _icon_path = "/usr/share/icons/hicolor/32x32/apps/gnuradio-grc.png"
        self.SetIcon(wx.Icon(_icon_path, wx.BITMAP_TYPE_ANY))

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 15
        self.samp_rate_0 = samp_rate_0 = 20e6
        self.samp_rate = samp_rate = 10e6
        self.rx_gain = rx_gain = 5
        self.oversampling = oversampling = 4
        self.mult = mult = 0.38
        self.lo_offset = lo_offset = 0
        self.freq = freq = 5.89e9
        self.encoding = encoding = 0

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.samp_rate,
            callback=self.set_samp_rate,
            label="Sample Rate",
            choices=[5e6, 10e6, 20e6],
            labels=["5MHz", "10 MHz", "20 MHz"],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._samp_rate_chooser)
        _mult_sizer = wx.BoxSizer(wx.VERTICAL)
        self._mult_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_mult_sizer,
            value=self.mult,
            callback=self.set_mult,
            label='mult',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._mult_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_mult_sizer,
            value=self.mult,
            callback=self.set_mult,
            minimum=0,
            maximum=1,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_mult_sizer)
        self._encoding_chooser = forms.radio_buttons(
            parent=self.GetWin(),
            value=self.encoding,
            callback=self.set_encoding,
            label="Encoding",
            choices=[0, 1, 2, 3, 4, 5, 6, 7],
            labels=[
                "BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2",
                "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"
            ],
            style=wx.RA_HORIZONTAL,
        )
        self.Add(self._encoding_chooser)
        self.wxgui_scopesink2_0 = scopesink2.scope_sink_c(
            self.GetWin(),
            title="Scope Plot",
            sample_rate=5000,
            v_scale=0,
            v_offset=0,
            t_scale=0,
            ac_couple=False,
            xy_mode=True,
            num_inputs=1,
            trig_mode=wxgui.TRIG_MODE_AUTO,
            y_axis_label="Counts",
        )
        self.Add(self.wxgui_scopesink2_0.win)
        self.wifi_phy_hier_0 = wifi_phy_hier(
            chan_est=0,
            encoding=0,
        )
        _tx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._tx_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_tx_gain_sizer,
            value=self.tx_gain,
            callback=self.set_tx_gain,
            label='tx_gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._tx_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_tx_gain_sizer,
            value=self.tx_gain,
            callback=self.set_tx_gain,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_tx_gain_sizer)
        _rx_gain_sizer = wx.BoxSizer(wx.VERTICAL)
        self._rx_gain_text_box = forms.text_box(
            parent=self.GetWin(),
            sizer=_rx_gain_sizer,
            value=self.rx_gain,
            callback=self.set_rx_gain,
            label='rx_gain',
            converter=forms.float_converter(),
            proportion=0,
        )
        self._rx_gain_slider = forms.slider(
            parent=self.GetWin(),
            sizer=_rx_gain_sizer,
            value=self.rx_gain,
            callback=self.set_rx_gain,
            minimum=0,
            maximum=100,
            num_steps=100,
            style=wx.SL_HORIZONTAL,
            cast=float,
            proportion=1,
        )
        self.Add(_rx_gain_sizer)
        self._lo_offset_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.lo_offset,
            callback=self.set_lo_offset,
            label="LO Offset",
            choices=[0, 6e6, 11e6],
            labels=['0 MHz', '6 MHz', '11 MHz'],
        )
        self.Add(self._lo_offset_chooser)
        self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(
            ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]),
            ([0x30, 0x14, 0x4a, 0xe6, 0x46, 0xe4]),
            ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]))
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(True)
        self._freq_chooser = forms.drop_down(
            parent=self.GetWin(),
            value=self.freq,
            callback=self.set_freq,
            label="Channel",
            choices=[
                2412000000.0, 2417000000.0, 2422000000.0, 2427000000.0,
                2432000000.0, 2437000000.0, 2442000000.0, 2447000000.0,
                2452000000.0, 2457000000.0, 2462000000.0, 2467000000.0,
                2472000000.0, 2484000000.0, 5170000000.0, 5180000000.0,
                5190000000.0, 5200000000.0, 5210000000.0, 5220000000.0,
                5230000000.0, 5240000000.0, 5260000000.0, 5280000000.0,
                5300000000.0, 5320000000.0, 5500000000.0, 5520000000.0,
                5540000000.0, 5560000000.0, 5580000000.0, 5600000000.0,
                5620000000.0, 5640000000.0, 5660000000.0, 5680000000.0,
                5700000000.0, 5745000000.0, 5765000000.0, 5785000000.0,
                5805000000.0, 5825000000.0, 5860000000.0, 5870000000.0,
                5880000000.0, 5890000000.0, 5900000000.0, 5910000000.0,
                5920000000.0
            ],
            labels=[
                '  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g',
                '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g',
                '  5 | 2432.0 | 11g', '  6 | 2437.0 | 11g',
                '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g',
                '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g',
                ' 11 | 2462.0 | 11g', ' 12 | 2467.0 | 11g',
                ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g',
                ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a',
                ' 38 | 5190.0 | 11a', ' 40 | 5200.0 | 11a',
                ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a',
                ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a',
                ' 52 | 5260.0 | 11a', ' 56 | 5280.0 | 11a',
                ' 58 | 5300.0 | 11a', ' 60 | 5320.0 | 11a',
                '100 | 5500.0 | 11a', '104 | 5520.0 | 11a',
                '108 | 5540.0 | 11a', '112 | 5560.0 | 11a',
                '116 | 5580.0 | 11a', '120 | 5600.0 | 11a',
                '124 | 5620.0 | 11a', '128 | 5640.0 | 11a',
                '132 | 5660.0 | 11a', '136 | 5680.0 | 11a',
                '140 | 5700.0 | 11a', '149 | 5745.0 | 11a',
                '153 | 5765.0 | 11a', '157 | 5785.0 | 11a',
                '161 | 5805.0 | 11a', '165 | 5825.0 | 11a',
                '172 | 5860.0 | 11p', '174 | 5870.0 | 11p',
                '176 | 5880.0 | 11p', '178 | 5890.0 | 11p',
                '180 | 5900.0 | 11p', '182 | 5910.0 | 11p',
                '184 | 5920.0 | 11p'
            ],
        )
        self.Add(self._freq_chooser)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000,
                                                 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.channels_channel_model_0 = channels.channel_model(
            noise_voltage=.5**.5,
            frequency_offset=0,
            epsilon=1.0,
            taps=(1.0, ),
            noise_seed=0,
            block_tags=False)
        self.blocks_udp_sink_0 = blocks.udp_sink(gr.sizeof_char * 1,
                                                 "192.168.200.2", 1234, 100,
                                                 True)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, False)
        self.blocks_throttle_0 = blocks.throttle(
            gr.sizeof_char * 1,
            2 * 4e3 + 0 * samp_rate / 40 / (oversampling * 8 * 2), True)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((mult, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_message_debug_0 = blocks.message_debug()
        self.blocks_file_source_0 = blocks.file_source(
            gr.sizeof_char * 1,
            "/media/juan/d6aba572-c85c-40cc-9258-ae1538dfb8c5/home/juan/Music/de_mi.mp3",
            True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'),
                         (self.ieee802_11_ether_encap_0, 'from tap'))
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to tap'),
                         (self.blocks_tuntap_pdu_0, 'pdus'))
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'),
                         (self.ieee802_11_ofdm_mac_0, 'app in'))
        self.msg_connect((self.ieee802_11_ofdm_mac_0, 'phy out'),
                         (self.blocks_message_debug_0, 'print'))
        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.ieee802_11_ether_encap_0, 'from wifi'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_ofdm_mac_0, 'phy in'))
        self.connect((self.blocks_file_source_0, 0),
                     (self.blocks_throttle_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.foo_packet_pad2_0, 0))
        self.connect((self.blocks_throttle_0, 0), (self.blocks_udp_sink_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.channels_channel_model_0, 0))
        self.connect((self.wifi_phy_hier_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))
        self.connect((self.wifi_phy_hier_0, 1), (self.wxgui_scopesink2_0, 0))
Exemplo n.º 9
0
    def __init__(self, addr, no_usrp, rate, lo_offset, encod, otw, source, no_self_loop, debug_MAC):
        grc_wxgui.top_block_gui.__init__(self, title="TransceiverSlave") #FIXME how to get rid of the gui

        ##################################################
        # Variables
        ##################################################
        self.addr         = addr
	self.no_usrp	  = no_usrp
	self.samp_rate	  = rate	
        self.otw          = otw 
        self.no_self_loop = no_self_loop    
	self.debug_MAC	  = debug_MAC
	self.lo_offset	  = lo_offset
        ##################################################
        # Blocks
        ##################################################
	if self.no_usrp:
                self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*1, self.samp_rate*1e6,True)
                ################################
                ## Using files instead of USRPs
                ###############################
                self.blocks_slaveFileSource = blocks.file_source(gr.sizeof_gr_complex*1, (os.getcwd()+"/utils/fileSinkMaster"), True)
                self.blocks_slaveFileSink   = blocks.file_sink(gr.sizeof_gr_complex*1, (os.getcwd()+"/utils/fileSinkSlave"), False)
                self.blocks_slaveFileSink.set_unbuffered(False)
                    
        else:
		############
		## source
		############
      		self.uhd_usrp_source_0 = uhd.usrp_source(",".join((self.addr, "")),
                                                         uhd.stream_args(cpu_format="fc32",
                                                                         otw_format=self.otw,
                                                                         channels=range(1),),)

                # TODO Explain the usage 
                self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)

		#############
		## sink
		#############
	        self.uhd_usrp_sink_0 = uhd.usrp_sink(",".join((self.addr, "")),
			                            uhd.stream_args(cpu_format="fc32",
		                    				    otw_format=self.otw,
		                                                    channels=range(1),),"packet_len",)
 
                # TODO Explain the usage 
                self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)

        # 802.11 a,g,p PHY Layer OFDM
        # Encoding choices=[0,1,2,3,4,5,6,7]="BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2", "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"
	print "Encoding Used: ", int(encod) #FIXME add the equivalent scheme
        self.PHY = wifi_phy_hier( encoding=int(encod), )

	# Foo block #TODO explain its usage
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 0, 10000) ## ?! ##
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)

	# Multiply Const Block 
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.38, )) #mult = 0.38
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)

        # 802.11 a,g,p OFDM MAC Layer
	self.ieee802_11_ofdm_mac_0 = ieee802_11.ofdm_mac(([0x43, 0x43, 0x43, 0x43, 0x43, 0x43]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]), ([0xff, 0xff, 0xff, 0xff, 0xff, 0xff])) 

	# ofdm_parse_mac block for debugging purpose
        self.ieee802_11_ofdm_parse_mac_0 = ieee802_11.ofdm_parse_mac(False, False) 
        
        # Ethernet Encapsulation #TODO explain its usage 
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(True)

        # ///////////////////////////////////////////////////////////////////////////////////////////////////////
        #   Set virtual ethernet interface (tap0), relays packets between the interface and the GNU Radio PHY+MAC
        #   Use the Universal TUN/TAP device driver to move packets to/from kernel
        #   See /usr/src/linux/Documentation/networking/tuntap.txt
        # ///////////////////////////////////////////////////////////////////////////////////////////////////////
        if source == "tuntap":
                self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, False)

        ##################################################
        # Asynch Message Connections
        ##################################################i

                self.msg_connect(self.ieee802_11_ether_encap_0, "to tap", self.blocks_tuntap_pdu_0, "pdus")
                self.msg_connect(self.blocks_tuntap_pdu_0, "pdus", self.ieee802_11_ether_encap_0, "from tap")

                self.msg_connect(self.ieee802_11_ether_encap_0, "to wifi", self.ieee802_11_ofdm_mac_0,    "app in")
                self.msg_connect(self.ieee802_11_ofdm_mac_0,    "app out", self.ieee802_11_ether_encap_0, "from wifi")

        else:   # UDP_Sockets 
		#TODO Test me ! 
                self.blocks_socket_pdu_0_Tx = blocks.socket_pdu("UDP_SERVER", "localhost", "52004", 10000)
                self.blocks_socket_pdu_0_Rx = blocks.socket_pdu("UDP_CLIENT", "localhost", "3333", 10000)

                self.msg_connect(self.ieee802_11_ofdm_mac_0, "app out", self.blocks_socket_pdu_0_Rx,      "pdus")
                self.msg_connect(self.blocks_socket_pdu_0_Tx, "pdus"  , self.ieee802_11_ofdm_mac_0,      "app in")

        ## Debugging at the MAC level To parse at the level of MAC ! Look at the flowgraph
        self.msg_connect(self.PHY,                   "mac_out", self.ieee802_11_ofdm_parse_mac_0, "in")   #TODO Test me !
        self.msg_connect(self.PHY,                   "mac_out", self.ieee802_11_ofdm_mac_0,      "phy in")
        self.msg_connect(self.ieee802_11_ofdm_mac_0, "phy out", self.PHY,                        "mac_in")

        ##################################################
        # Connections
        ##################################################

        if self.no_usrp:
		self.connect((self.PHY, 0), (self.blocks_multiply_const_vxx_0, 0)) 
	        self.connect((self.blocks_slaveFileSource, 0), (self.PHY, 0)) 
	        self.connect((self.foo_packet_pad2_0, 0), (self.blocks_slaveFileSink, 0)) 
	        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0)) 
        else:
		self.connect((self.PHY, 0), (self.blocks_multiply_const_vxx_0, 0)) 
	        self.connect((self.uhd_usrp_source_0, 0), (self.PHY, 0)) 
	        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0)) 
	        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0)) 

        if not self.lo_offset:
            self.lo_offset = self.samp_rate / 2.0 

        print "LO offset set to: ", self.lo_offset/1e6, "MHz"
    def __init__(self):
        gr.top_block.__init__(self, "Uniflex Wifi Transceiver")

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 0.75
        self.samp_rate = samp_rate = 20e6
        self.rx_gain = rx_gain = 0.75
        self.lo_offset = lo_offset = 0
        self.freq = freq = 5890000000
        self.encoding = encoding = 0
        self.chan_est = chan_est = 0

        ##################################################
        # Blocks
        ##################################################
        self.xmlrpc_server_0 = SimpleXMLRPCServer.SimpleXMLRPCServer(("localhost", 8080), allow_none=True)
        self.xmlrpc_server_0.register_instance(self)
        self.xmlrpc_server_0_thread = threading.Thread(target=self.xmlrpc_server_0.serve_forever)
        self.xmlrpc_server_0_thread.daemon = True
        self.xmlrpc_server_0_thread.start()
        self.wifi_phy_hier_0 = wifi_phy_hier(
            bandwidth=samp_rate,
            chan_est=chan_est,
            encoding=encoding,
            frequency=freq,
            sensitivity=0.56,
        )
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_source_0.set_normalized_gain(rx_gain, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        	"packet_len",
        )
        self.uhd_usrp_sink_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(uhd.tune_request(freq, rf_freq = freq - lo_offset, rf_freq_policy=uhd.tune_request.POLICY_MANUAL), 0)
        self.uhd_usrp_sink_0.set_normalized_gain(tx_gain, 0)
        self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(False, True)
        self.ieee802_11_mac_0 = ieee802_11.mac(([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]), ([0x30, 0x14, 0x4a, 0xe6, 0x46, 0xe4]), ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]))
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(False)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000, 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.blocks_tuntap_pdu_0 = blocks.tuntap_pdu("tap0", 440, False)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.6, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char*1, "/tmp/wifi.pcap", True)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_tuntap_pdu_0, 'pdus'), (self.ieee802_11_ether_encap_0, 'from tap'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to tap'), (self.blocks_tuntap_pdu_0, 'pdus'))    
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'), (self.ieee802_11_mac_0, 'app in'))    
        self.msg_connect((self.ieee802_11_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.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_ether_encap_0, 'from wifi'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_mac_0, 'phy in'))    
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'), (self.ieee802_11_parse_mac_0, 'in'))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.foo_packet_pad2_0, 0))    
        self.connect((self.foo_packet_pad2_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.foo_wireshark_connector_0, 0), (self.blocks_file_sink_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.wifi_phy_hier_0, 0))    
        self.connect((self.wifi_phy_hier_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
Exemplo n.º 11
0
    def __init__(self):
        gr.top_block.__init__(self, "Wifi Transceiver")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Wifi Transceiver")
        try:
            self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc'))
        except:
            pass
        self.top_scroll_layout = Qt.QVBoxLayout()
        self.setLayout(self.top_scroll_layout)
        self.top_scroll = Qt.QScrollArea()
        self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame)
        self.top_scroll_layout.addWidget(self.top_scroll)
        self.top_scroll.setWidgetResizable(True)
        self.top_widget = Qt.QWidget()
        self.top_scroll.setWidget(self.top_widget)
        self.top_layout = Qt.QVBoxLayout(self.top_widget)
        self.top_grid_layout = Qt.QGridLayout()
        self.top_layout.addLayout(self.top_grid_layout)

        self.settings = Qt.QSettings("GNU Radio", "wifi_transceiver")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.tx_gain = tx_gain = 0.75
        self.samp_rate = samp_rate = 10e6
        self.rx_gain = rx_gain = 0.75
        self.lo_offset = lo_offset = 0
        self.freq = freq = 3500000000
        self.encoding = encoding = 0
        self.chan_est = chan_est = 0

        ##################################################
        # Blocks
        ##################################################
        self._samp_rate_options = [5e6, 10e6, 20e6]
        self._samp_rate_labels = ["5 MHz", "10 MHz", "20 MHz"]
        self._samp_rate_tool_bar = Qt.QToolBar(self)
        self._samp_rate_tool_bar.addWidget(Qt.QLabel("samp_rate" + ": "))
        self._samp_rate_combo_box = Qt.QComboBox()
        self._samp_rate_tool_bar.addWidget(self._samp_rate_combo_box)
        for label in self._samp_rate_labels:
            self._samp_rate_combo_box.addItem(label)
        self._samp_rate_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._samp_rate_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._samp_rate_options.index(i)))
        self._samp_rate_callback(self.samp_rate)
        self._samp_rate_combo_box.currentIndexChanged.connect(
            lambda i: self.set_samp_rate(self._samp_rate_options[i]))
        self.top_layout.addWidget(self._samp_rate_tool_bar)
        self._freq_options = [
            3500000000.0, 2412000000.0, 2417000000.0, 2422000000.0,
            2427000000.0, 2432000000.0, 2437000000.0, 2442000000.0,
            2447000000.0, 2452000000.0, 2457000000.0, 2462000000.0,
            2467000000.0, 2472000000.0, 2484000000.0, 5170000000.0,
            5180000000.0, 5190000000.0, 5200000000.0, 5210000000.0,
            5220000000.0, 5230000000.0, 5240000000.0, 5250000000.0,
            5260000000.0, 5270000000.0, 5280000000.0, 5290000000.0,
            5300000000.0, 5310000000.0, 5320000000.0, 5500000000.0,
            5510000000.0, 5520000000.0, 5530000000.0, 5540000000.0,
            5550000000.0, 5560000000.0, 5570000000.0, 5580000000.0,
            5590000000.0, 5600000000.0, 5610000000.0, 5620000000.0,
            5630000000.0, 5640000000.0, 5660000000.0, 5670000000.0,
            5680000000.0, 5690000000.0, 5700000000.0, 5710000000.0,
            5720000000.0, 5745000000.0, 5755000000.0, 5765000000.0,
            5775000000.0, 5785000000.0, 5795000000.0, 5805000000.0,
            5825000000.0, 5860000000.0, 5870000000.0, 5880000000.0,
            5890000000.0, 5900000000.0, 5910000000.0, 5920000000.0
        ]
        self._freq_labels = [
            ' 0|3.5G', '  1 | 2412.0 | 11g', '  2 | 2417.0 | 11g',
            '  3 | 2422.0 | 11g', '  4 | 2427.0 | 11g', '  5 | 2432.0 | 11g',
            '  6 | 2437.0 | 11g', '  7 | 2442.0 | 11g', '  8 | 2447.0 | 11g',
            '  9 | 2452.0 | 11g', ' 10 | 2457.0 | 11g', ' 11 | 2462.0 | 11g',
            ' 12 | 2467.0 | 11g', ' 13 | 2472.0 | 11g', ' 14 | 2484.0 | 11g',
            ' 34 | 5170.0 | 11a', ' 36 | 5180.0 | 11a', ' 38 | 5190.0 | 11a',
            ' 40 | 5200.0 | 11a', ' 42 | 5210.0 | 11a', ' 44 | 5220.0 | 11a',
            ' 46 | 5230.0 | 11a', ' 48 | 5240.0 | 11a', ' 50 | 5250.0 | 11a',
            ' 52 | 5260.0 | 11a', ' 54 | 5270.0 | 11a', ' 56 | 5280.0 | 11a',
            ' 58 | 5290.0 | 11a', ' 60 | 5300.0 | 11a', ' 62 | 5310.0 | 11a',
            ' 64 | 5320.0 | 11a', '100 | 5500.0 | 11a', '102 | 5510.0 | 11a',
            '104 | 5520.0 | 11a', '106 | 5530.0 | 11a', '108 | 5540.0 | 11a',
            '110 | 5550.0 | 11a', '112 | 5560.0 | 11a', '114 | 5570.0 | 11a',
            '116 | 5580.0 | 11a', '118 | 5590.0 | 11a', '120 | 5600.0 | 11a',
            '122 | 5610.0 | 11a', '124 | 5620.0 | 11a', '126 | 5630.0 | 11a',
            '128 | 5640.0 | 11a', '132 | 5660.0 | 11a', '134 | 5670.0 | 11a',
            '136 | 5680.0 | 11a', '138 | 5690.0 | 11a', '140 | 5700.0 | 11a',
            '142 | 5710.0 | 11a', '144 | 5720.0 | 11a',
            '149 | 5745.0 | 11a (SRD)', '151 | 5755.0 | 11a (SRD)',
            '153 | 5765.0 | 11a (SRD)', '155 | 5775.0 | 11a (SRD)',
            '157 | 5785.0 | 11a (SRD)', '159 | 5795.0 | 11a (SRD)',
            '161 | 5805.0 | 11a (SRD)', '165 | 5825.0 | 11a (SRD)',
            '172 | 5860.0 | 11p', '174 | 5870.0 | 11p', '176 | 5880.0 | 11p',
            '178 | 5890.0 | 11p', '180 | 5900.0 | 11p', '182 | 5910.0 | 11p',
            '184 | 5920.0 | 11p'
        ]
        self._freq_tool_bar = Qt.QToolBar(self)
        self._freq_tool_bar.addWidget(Qt.QLabel("freq" + ": "))
        self._freq_combo_box = Qt.QComboBox()
        self._freq_tool_bar.addWidget(self._freq_combo_box)
        for label in self._freq_labels:
            self._freq_combo_box.addItem(label)
        self._freq_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._freq_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._freq_options.index(i)))
        self._freq_callback(self.freq)
        self._freq_combo_box.currentIndexChanged.connect(
            lambda i: self.set_freq(self._freq_options[i]))
        self.top_layout.addWidget(self._freq_tool_bar)
        self._encoding_options = [0, 1, 2, 3, 4, 5, 6, 7]
        self._encoding_labels = [
            "BPSK 1/2", "BPSK 3/4", "QPSK 1/2", "QPSK 3/4", "16QAM 1/2",
            "16QAM 3/4", "64QAM 2/3", "64QAM 3/4"
        ]
        self._encoding_group_box = Qt.QGroupBox("encoding")
        self._encoding_box = Qt.QHBoxLayout()

        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)

            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)

        self._encoding_button_group = variable_chooser_button_group()
        self._encoding_group_box.setLayout(self._encoding_box)
        for i, label in enumerate(self._encoding_labels):
            radio_button = Qt.QRadioButton(label)
            self._encoding_box.addWidget(radio_button)
            self._encoding_button_group.addButton(radio_button, i)
        self._encoding_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._encoding_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._encoding_options.index(i)))
        self._encoding_callback(self.encoding)
        self._encoding_button_group.buttonClicked[int].connect(
            lambda i: self.set_encoding(self._encoding_options[i]))
        self.top_layout.addWidget(self._encoding_group_box)
        self._chan_est_options = [
            ieee802_11.LS, ieee802_11.LMS, ieee802_11.STA, ieee802_11.COMB
        ]
        self._chan_est_labels = ["LS", "LMS", "STA", "Linear Comb"]
        self._chan_est_group_box = Qt.QGroupBox("chan_est")
        self._chan_est_box = Qt.QHBoxLayout()

        class variable_chooser_button_group(Qt.QButtonGroup):
            def __init__(self, parent=None):
                Qt.QButtonGroup.__init__(self, parent)

            @pyqtSlot(int)
            def updateButtonChecked(self, button_id):
                self.button(button_id).setChecked(True)

        self._chan_est_button_group = variable_chooser_button_group()
        self._chan_est_group_box.setLayout(self._chan_est_box)
        for i, label in enumerate(self._chan_est_labels):
            radio_button = Qt.QRadioButton(label)
            self._chan_est_box.addWidget(radio_button)
            self._chan_est_button_group.addButton(radio_button, i)
        self._chan_est_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._chan_est_button_group, "updateButtonChecked",
            Qt.Q_ARG("int", self._chan_est_options.index(i)))
        self._chan_est_callback(self.chan_est)
        self._chan_est_button_group.buttonClicked[int].connect(
            lambda i: self.set_chan_est(self._chan_est_options[i]))
        self.top_layout.addWidget(self._chan_est_group_box)
        self.wifi_phy_hier_0 = wifi_phy_hier(
            bandwidth=samp_rate,
            chan_est=chan_est,
            encoding=encoding,
            frequency=freq,
            sensitivity=0.56,
        )
        self._tx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._tx_gain_win = RangeWidget(self._tx_gain_range, self.set_tx_gain,
                                        "tx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._tx_gain_win)
        self._rx_gain_range = Range(0, 1, 0.01, 0.75, 200)
        self._rx_gain_win = RangeWidget(self._rx_gain_range, self.set_rx_gain,
                                        "rx_gain", "counter_slider", float)
        self.top_layout.addWidget(self._rx_gain_win)
        self.qtgui_const_sink_x_0 = qtgui.const_sink_c(
            48 * 10,  #size
            "",  #name
            1  #number of inputs
        )
        self.qtgui_const_sink_x_0.set_update_time(0.10)
        self.qtgui_const_sink_x_0.set_y_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_x_axis(-2, 2)
        self.qtgui_const_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE,
                                                   qtgui.TRIG_SLOPE_POS, 0.0,
                                                   0, "")
        self.qtgui_const_sink_x_0.enable_autoscale(False)
        self.qtgui_const_sink_x_0.enable_grid(False)
        self.qtgui_const_sink_x_0.enable_axis_labels(True)

        if not True:
            self.qtgui_const_sink_x_0.disable_legend()

        labels = ['', '', '', '', '', '', '', '', '', '']
        widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
        colors = [
            "blue", "red", "red", "red", "red", "red", "red", "red", "red",
            "red"
        ]
        styles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        markers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
        alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
        for i in xrange(1):
            if len(labels[i]) == 0:
                self.qtgui_const_sink_x_0.set_line_label(
                    i, "Data {0}".format(i))
            else:
                self.qtgui_const_sink_x_0.set_line_label(i, labels[i])
            self.qtgui_const_sink_x_0.set_line_width(i, widths[i])
            self.qtgui_const_sink_x_0.set_line_color(i, colors[i])
            self.qtgui_const_sink_x_0.set_line_style(i, styles[i])
            self.qtgui_const_sink_x_0.set_line_marker(i, markers[i])
            self.qtgui_const_sink_x_0.set_line_alpha(i, alphas[i])

        self._qtgui_const_sink_x_0_win = sip.wrapinstance(
            self.qtgui_const_sink_x_0.pyqwidget(), Qt.QWidget)
        self.top_layout.addWidget(self._qtgui_const_sink_x_0_win)
        self.pluto_source_0 = iio.pluto_source('', 3500000000, 10000000,
                                               20000000, 0x8000, True, True,
                                               True, "manual", 64.0, '', True)
        self.pluto_sink_0 = iio.pluto_sink('', 3500000000, 10000000, 20000000,
                                           0x8000, False, 10.0, '', True)
        self._lo_offset_options = (
            0,
            6e6,
            11e6,
        )
        self._lo_offset_labels = (
            str(self._lo_offset_options[0]),
            str(self._lo_offset_options[1]),
            str(self._lo_offset_options[2]),
        )
        self._lo_offset_tool_bar = Qt.QToolBar(self)
        self._lo_offset_tool_bar.addWidget(Qt.QLabel("lo_offset" + ": "))
        self._lo_offset_combo_box = Qt.QComboBox()
        self._lo_offset_tool_bar.addWidget(self._lo_offset_combo_box)
        for label in self._lo_offset_labels:
            self._lo_offset_combo_box.addItem(label)
        self._lo_offset_callback = lambda i: Qt.QMetaObject.invokeMethod(
            self._lo_offset_combo_box, "setCurrentIndex",
            Qt.Q_ARG("int", self._lo_offset_options.index(i)))
        self._lo_offset_callback(self.lo_offset)
        self._lo_offset_combo_box.currentIndexChanged.connect(
            lambda i: self.set_lo_offset(self._lo_offset_options[i]))
        self.top_layout.addWidget(self._lo_offset_tool_bar)
        self.ieee802_11_parse_mac_0 = ieee802_11.parse_mac(False, True)
        self.ieee802_11_mac_0 = ieee802_11.mac(
            ([0x12, 0x34, 0x56, 0x78, 0x90, 0xab]),
            ([0x30, 0x14, 0x4a, 0xe6, 0x46, 0xe4]),
            ([0x42, 0x42, 0x42, 0x42, 0x42, 0x42]))
        self.ieee802_11_ether_encap_0 = ieee802_11.ether_encap(False)
        self.foo_wireshark_connector_0 = foo.wireshark_connector(127, False)
        self.foo_packet_pad2_0 = foo.packet_pad2(False, False, 0.001, 10000,
                                                 10000)
        (self.foo_packet_pad2_0).set_min_output_buffer(100000)
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(
            blocks.complex_t, 'packet_len')
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vcc((0.6, ))
        (self.blocks_multiply_const_vxx_0).set_min_output_buffer(100000)
        self.blocks_file_sink_0 = blocks.file_sink(gr.sizeof_char * 1,
                                                   '/tmp/wifi.pcap', True)
        self.blocks_file_sink_0.set_unbuffered(True)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.ieee802_11_ether_encap_0, 'to wifi'),
                         (self.ieee802_11_mac_0, 'app in'))
        self.msg_connect((self.ieee802_11_mac_0, 'phy out'),
                         (self.wifi_phy_hier_0, 'mac_in'))
        self.msg_connect((self.wifi_phy_hier_0, 'carrier'),
                         (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.foo_wireshark_connector_0, 'in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_ether_encap_0, 'from wifi'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_mac_0, 'phy in'))
        self.msg_connect((self.wifi_phy_hier_0, 'mac_out'),
                         (self.ieee802_11_parse_mac_0, 'in'))
        self.connect((self.blocks_multiply_const_vxx_0, 0),
                     (self.foo_packet_pad2_0, 0))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.qtgui_const_sink_x_0, 0))
        self.connect((self.foo_packet_pad2_0, 0), (self.pluto_sink_0, 0))
        self.connect((self.foo_wireshark_connector_0, 0),
                     (self.blocks_file_sink_0, 0))
        self.connect((self.pluto_source_0, 0), (self.wifi_phy_hier_0, 0))
        self.connect((self.wifi_phy_hier_0, 0),
                     (self.blocks_multiply_const_vxx_0, 0))