예제 #1
0
파일: CogMAC.py 프로젝트: difdenk/gr-inets
    def __init__(self,
                 constellation=gnuradio.digital.constellation_qpsk().base()):
        gr.top_block.__init__(self, "CogMAC")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("CogMAC")
        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", "CogMAC")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.constellation = constellation

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.range_rx_gain = range_rx_gain = 0
        self.range_mu = range_mu = 0.6
        self.usrp_device_address = usrp_device_address = "addr=10.0.0.20"
        self.tx_mode_ms = tx_mode_ms = 5
        self.system_time_granularity_us = system_time_granularity_us = 1000
        self.source_address = source_address = 3
        self.samp_rate = samp_rate = 400000
        self.rx_mode_ms = rx_mode_ms = 5
        self.rx_gain = rx_gain = range_rx_gain

        self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11 * sps)

        self.padding = padding = 64
        self.mu = mu = range_mu
        self.inter_fr_ms = inter_fr_ms = 5
        self.frame_length = frame_length = 837
        self.diff_preamble_128 = diff_preamble_128 = [
            1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0,
            1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1,
            1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0,
            1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0,
            1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1,
            1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0,
            1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1,
            0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0,
            0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0,
            0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1,
            0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1,
            1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0
        ][0:128]
        self.destination_address = destination_address = 1
        self.cs_threshold = cs_threshold = 0.005
        self.ch_switch_ms = ch_switch_ms = 5
        self.ch_pool_size = ch_pool_size = 10
        self.center_frequency = center_frequency = 400000000
        self.PU_time_ms = PU_time_ms = 100
        self.N_Mul_Fr = N_Mul_Fr = 10
        self.CCA2_ms = CCA2_ms = 10

        ##################################################
        # Blocks
        ##################################################
        self._range_rx_gain_range = Range(0, 60, 1, 0, 200)
        self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range,
                                              self.set_range_rx_gain,
                                              'Rx Gain', "counter_slider",
                                              float)
        self.top_grid_layout.addWidget(self._range_rx_gain_win, 1, 0, 1, 1)
        self._range_mu_range = Range(0, 1, 0.01, 0.6, 200)
        self._range_mu_win = RangeWidget(self._range_mu_range,
                                         self.set_range_mu,
                                         'BB Derotation Gain',
                                         "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_mu_win, 2, 0, 1, 1)
        self.inets_unbundle_0_0_0_0_0 = inets.unbundle(0, 16, 'N_Mul_Fr')
        self.inets_unbundle_0_0_0_0 = inets.unbundle(0, 16, 'N_Fr')
        self.inets_unbundle_0_0_0 = inets.unbundle(0, 16, 'CCA1_ms')
        self.inets_unbundle_0_0 = inets.unbundle(0, 16, 'N_PU')
        self.inets_unbundle_0 = inets.unbundle(0, 16, 'N_Re_fr')
        self.inets_sending_0 = inets.sending(
            develop_mode=0,
            block_id=11,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            preamble=diff_preamble_128,
            samp_rate=samp_rate,
            sps=sps,
            system_time_granularity_us=system_time_granularity_us,
            usrp_device_address=usrp_device_address,
            center_frequency=center_frequency,
            interframe_interval_s=0.005,
            t_pretx_interval_s=0,
            file_name_extension_t_control="t1TXs",
            file_name_extension_pending="Tfr",
            record_on=0,
            name_with_timestamp=1,
            tx_gain=5)
        self.inets_run_0 = inets.run(1, 10)
        self.inets_receiving_0 = inets.receiving(
            0, 21,
            gnuradio.digital.constellation_qpsk().base(), rrc, mu,
            diff_preamble_128, rx_gain, samp_rate, sps, 30,
            usrp_device_address, center_frequency)
        self.inets_general_timer_3 = inets.general_timer(
            0, 3, 0, CCA2_ms, 10, 0)
        self.inets_general_timer_2_0 = inets.general_timer(0, 3, 0, 100, 10, 0)
        self.inets_general_timer_2 = inets.general_timer(0, 3, 0, 200, 10, 0)
        self.inets_general_timer_1_0 = inets.general_timer(
            0, 3, 0, ch_switch_ms, 10, 0)
        self.inets_general_timer_1 = inets.general_timer(
            0, 3, 0, ch_switch_ms, 10, 0)
        self.inets_general_timer_0 = inets.general_timer(
            0, 3, 0, 100000, 10, 0)
        self.inets_framing_0 = inets.framing(0, 17, 1, 1, 10, 1,
                                             destination_address, 1,
                                             source_address, 1, 318, 2, 524, 2,
                                             2, -1, 1, 0, ([2, 3]),
                                             ([1000, 1000]), 2, 0, 300, 1)
        self.inets_frame_replicate_0 = inets.frame_replicate(1, 39, 4)
        self.inets_frame_probe_0_1 = inets.frame_probe(
            1, 99, 0, 0, 0.001, 0, "/home/inets/source/gr-inets/results/", "",
            1)
        self.inets_frame_probe_0_0 = inets.frame_probe(
            1, 101, 0, 0, 0.01, 0, "/home/inets/source/gr-inets/results/", "",
            1)
        self.inets_frame_probe_0 = inets.frame_probe(
            1, 100, 0, 0, 0.001, 0, "/home/inets/source/gr-inets/results/", "",
            1)
        self.inets_frame_path_2_0 = inets.frame_path(0, 39)
        self.inets_frame_path_2 = inets.frame_path(0, 39)
        self.inets_frame_path_1_1_0_0_1 = inets.frame_path(0, 39)
        self.inets_frame_path_1_1_0_0_0 = inets.frame_path(0, 39)
        self.inets_frame_path_1_1_0_0 = inets.frame_path(0, 39)
        self.inets_frame_path_1_1 = inets.frame_path(0, 39)
        self.inets_frame_path_1_0_0_1_0 = inets.frame_path(0, 39)
        self.inets_frame_path_1_0_0_1 = inets.frame_path(0, 39)
        self.inets_frame_path_1_0_0_0 = inets.frame_path(0, 39)
        self.inets_frame_path_1_0_0 = inets.frame_path(0, 39)
        self.inets_frame_path_1 = inets.frame_path(0, 39)
        self.inets_frame_path_0 = inets.frame_path(0, 39)
        self.inets_frame_index_selector_0_1 = inets.frame_index_selector(
            0, 33, (1, ), 1)
        self.inets_frame_index_selector_0_0_0 = inets.frame_index_selector(
            0, 33, (10, ), 0)
        self.inets_frame_index_selector_0_0 = inets.frame_index_selector(
            0, 33, (1, ), 0)
        self.inets_frame_index_selector_0 = inets.frame_index_selector(
            0, 33, (10, ), 0)
        self.inets_frame_counter_1 = inets.frame_counter(0, 36, 4, 0)
        self.inets_frame_counter_0 = inets.frame_counter(
            1, 36, ch_pool_size, 0)
        self.inets_frame_check_0 = inets.frame_check(0, 9)
        self.inets_frame_buffer_0_0_0 = inets.frame_buffer(0, 16, 20, 1, 1, 0)
        self.inets_frame_buffer_0_0 = inets.frame_buffer(0, 16, 13, 0, 0, 0)
        self.inets_frame_buffer_0 = inets.frame_buffer(0, 15, 10, 0, 0, 1)
        self.inets_frame_and_0_0 = inets.frame_and(0, 38, 0)
        self.inets_frame_analysis_0 = inets.frame_analysis(
            0, 7, 1, 1, 1, 1, 1, 2, 2, 2, 1, source_address)
        self.inets_dummy_source_0 = inets.dummy_source(0, 23, frame_length, 3,
                                                       1)
        self.inets_cogmac_timing_0 = inets.cogmac_timing(
            1, 37, frame_length,
            constellation.bits_per_symbol() * (samp_rate / sps), samp_rate,
            (diff_preamble_128), 64, CCA2_ms, PU_time_ms, tx_mode_ms,
            rx_mode_ms, 15, 148, inter_fr_ms, ch_pool_size, ch_switch_ms,
            N_Mul_Fr)
        self.inets_cogmac_rm_rep_0 = inets.cogmac_rm_rep(0, 37)
        self.inets_cogmac_ch_pool_0 = inets.cogmac_ch_pool(
            0, 35, ch_pool_size, 410000000, 0, 10000000)
        self.inets_carrier_sensing_0_1 = inets.carrier_sensing(
            0, 11, 2, 500, cs_threshold, system_time_granularity_us, 100, 15)
        self.inets_carrier_sensing_0_0 = inets.carrier_sensing(
            0, 13, 2, CCA2_ms, cs_threshold, system_time_granularity_us, 100,
            15)
        self.inets_carrier_sensing_0 = inets.carrier_sensing(
            0, 11, 2, 60, cs_threshold, system_time_granularity_us, 100, 15)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.inets_carrier_sensing_0, 'cmd_pass_out'),
                         (self.inets_frame_counter_0, 'counts_in'))
        self.msg_connect((self.inets_carrier_sensing_0, 'cmd_fail_out'),
                         (self.inets_general_timer_2_0, 'active_in'))
        self.msg_connect((self.inets_carrier_sensing_0_0, 'cmd_fail_out'),
                         (self.inets_frame_path_1_0_0_0, 'frame_in'))
        self.msg_connect((self.inets_carrier_sensing_0_0, 'cmd_pass_out'),
                         (self.inets_frame_path_1_0_0_1_0, 'frame_in'))
        self.msg_connect((self.inets_carrier_sensing_0_0, 'cmd_fail_out'),
                         (self.inets_general_timer_2_0, 'active_in'))
        self.msg_connect((self.inets_carrier_sensing_0_1, 'cmd_pass_out'),
                         (self.inets_frame_and_0_0, 'frame_I_in'))
        self.msg_connect((self.inets_carrier_sensing_0_1, 'cmd_fail_out'),
                         (self.inets_general_timer_2_0, 'active_in'))
        self.msg_connect((self.inets_cogmac_ch_pool_0, 'CCA_CH_f_out'),
                         (self.inets_frame_path_1_0_0_1, 'frame_in'))
        self.msg_connect((self.inets_cogmac_ch_pool_0, 'CCA_one_f_out'),
                         (self.inets_frame_path_1_0_0_1, 'frame_in'))
        self.msg_connect((self.inets_cogmac_ch_pool_0, 'CCA_CH_f_out'),
                         (self.inets_general_timer_1, 'active_in'))
        self.msg_connect((self.inets_cogmac_ch_pool_0, 'CCA_one_f_out'),
                         (self.inets_general_timer_1_0, 'active_in'))
        self.msg_connect((self.inets_cogmac_rm_rep_0, 'new_cmd_out'),
                         (self.inets_frame_probe_0_1, 'info_in'))
        self.msg_connect((self.inets_cogmac_timing_0, 'cmd_out'),
                         (self.inets_cogmac_ch_pool_0, 'CCA_CH_in'))
        self.msg_connect((self.inets_cogmac_timing_0, 'cmd_out'),
                         (self.inets_dummy_source_0, 'trigger'))
        self.msg_connect((self.inets_cogmac_timing_0, 'cmd_out'),
                         (self.inets_general_timer_0, 'active_in'))
        self.msg_connect((self.inets_cogmac_timing_0, 'cogmac_config_out'),
                         (self.inets_unbundle_0, 'cmd_in'))
        self.msg_connect((self.inets_cogmac_timing_0, 'cogmac_config_out'),
                         (self.inets_unbundle_0_0, 'cmd_in'))
        self.msg_connect((self.inets_cogmac_timing_0, 'cogmac_config_out'),
                         (self.inets_unbundle_0_0_0, 'cmd_in'))
        self.msg_connect((self.inets_cogmac_timing_0, 'cogmac_config_out'),
                         (self.inets_unbundle_0_0_0_0, 'cmd_in'))
        self.msg_connect((self.inets_cogmac_timing_0, 'cogmac_config_out'),
                         (self.inets_unbundle_0_0_0_0_0, 'cmd_in'))
        self.msg_connect((self.inets_dummy_source_0, 'output'),
                         (self.inets_framing_0, 'data_in'))
        self.msg_connect((self.inets_frame_analysis_0, 'frame_info_out'),
                         (self.inets_frame_check_0, 'frame_info_in'))
        self.msg_connect((self.inets_frame_and_0_0, 'frame_out'),
                         (self.inets_frame_buffer_0_0, 'dequeue'))
        self.msg_connect((self.inets_frame_and_0_0, 'frame_out'),
                         (self.inets_framing_0, 'reset_index'))
        self.msg_connect((self.inets_frame_buffer_0, 'dequeue_element'),
                         (self.inets_frame_index_selector_0, 'frame_in'))
        self.msg_connect((self.inets_frame_buffer_0, 'dequeue_element'),
                         (self.inets_frame_index_selector_0_0, 'frame_in'))
        self.msg_connect((self.inets_frame_buffer_0, 'buffer_not_full'),
                         (self.inets_frame_path_0, 'frame_in'))
        self.msg_connect((self.inets_frame_buffer_0_0, 'buffer_full'),
                         (self.inets_frame_and_0_0, 'frame_II_in'))
        self.msg_connect((self.inets_frame_buffer_0_0, 'dequeue_element'),
                         (self.inets_frame_buffer_0_0_0, 'enqueue'))
        self.msg_connect((self.inets_frame_buffer_0_0, 'dequeue_element'),
                         (self.inets_frame_path_1_1, 'frame_in'))
        self.msg_connect((self.inets_frame_buffer_0_0_0, 'dequeue_element'),
                         (self.inets_frame_counter_1, 'counts_in'))
        self.msg_connect((self.inets_frame_check_0, 'good_frame_info_out'),
                         (self.inets_cogmac_rm_rep_0, 'frame_cmd_in'))
        self.msg_connect((self.inets_frame_check_0, 'good_frame_info_out'),
                         (self.inets_general_timer_2_0, 'active_in'))
        self.msg_connect((self.inets_frame_counter_0, 'unselect_out'),
                         (self.inets_frame_path_1_0_0, 'frame_in'))
        self.msg_connect((self.inets_frame_counter_0, 'select_out'),
                         (self.inets_frame_path_1_1_0_0, 'frame_in'))
        self.msg_connect((self.inets_frame_counter_0, 'select_out'),
                         (self.inets_frame_path_1_1_0_0_1, 'frame_in'))
        self.msg_connect((self.inets_frame_counter_1, 'unselect_out'),
                         (self.inets_frame_path_1_0_0_1_0, 'frame_in'))
        self.msg_connect((self.inets_frame_counter_1, 'select_out'),
                         (self.inets_frame_path_1_1_0_0_0, 'frame_in'))
        self.msg_connect((self.inets_frame_counter_1, 'select_out'),
                         (self.inets_general_timer_3, 'active_in'))
        self.msg_connect(
            (self.inets_frame_index_selector_0, 'unselected_frame_out'),
            (self.inets_frame_path_1, 'frame_in'))
        self.msg_connect((self.inets_frame_index_selector_0, 'frame_out'),
                         (self.inets_frame_replicate_0, 'frame_in'))
        self.msg_connect(
            (self.inets_frame_index_selector_0_0, 'unselected_frame_out'),
            (self.inets_frame_index_selector_0_0_0, 'frame_in'))
        self.msg_connect(
            (self.inets_frame_index_selector_0_0_0, 'unselected_frame_out'),
            (self.inets_frame_buffer_0, 'dequeue'))
        self.msg_connect((self.inets_frame_index_selector_0_1, 'frame_out'),
                         (self.inets_general_timer_2, 'active_in'))
        self.msg_connect((self.inets_frame_path_0, 'frame_out'),
                         (self.inets_dummy_source_0, 'trigger'))
        self.msg_connect((self.inets_frame_path_1, 'frame_out'),
                         (self.inets_frame_buffer_0_0, 'enqueue'))
        self.msg_connect((self.inets_frame_path_1_0_0, 'frame_out'),
                         (self.inets_cogmac_ch_pool_0, 'CCA_CH_in'))
        self.msg_connect((self.inets_frame_path_1_0_0_0, 'frame_out'),
                         (self.inets_frame_buffer_0_0_0, 'flush'))
        self.msg_connect((self.inets_frame_path_1_0_0_1, 'frame_out'),
                         (self.inets_receiving_0, 'reconfig_in'))
        self.msg_connect((self.inets_frame_path_1_0_0_1, 'frame_out'),
                         (self.inets_sending_0, 'reconfig_in'))
        self.msg_connect((self.inets_frame_path_1_0_0_1_0, 'frame_out'),
                         (self.inets_receiving_0, 'rx_switch_in'))
        self.msg_connect((self.inets_frame_path_1_1, 'frame_out'),
                         (self.inets_frame_buffer_0_0, 'dequeue'))
        self.msg_connect((self.inets_frame_path_1_1_0_0, 'frame_out'),
                         (self.inets_frame_counter_0, 'reset_in'))
        self.msg_connect((self.inets_frame_path_1_1_0_0_0, 'frame_out'),
                         (self.inets_frame_counter_1, 'reset_in'))
        self.msg_connect((self.inets_frame_path_1_1_0_0_1, 'frame_out'),
                         (self.inets_cogmac_ch_pool_0, 'CCA_one_in'))
        self.msg_connect((self.inets_frame_path_2, 'frame_out'),
                         (self.inets_frame_buffer_0_0_0, 'dequeue'))
        self.msg_connect((self.inets_frame_path_2_0, 'frame_out'),
                         (self.inets_frame_counter_1, 'reset_in'))
        self.msg_connect((self.inets_frame_replicate_0, 'complete_out'),
                         (self.inets_frame_buffer_0, 'dequeue'))
        self.msg_connect((self.inets_frame_replicate_0, 'replicate_out'),
                         (self.inets_frame_path_1, 'frame_in'))
        self.msg_connect((self.inets_framing_0, 'frame_out'),
                         (self.inets_frame_buffer_0, 'enqueue'))
        self.msg_connect((self.inets_general_timer_0, 'expire_signal_out'),
                         (self.inets_dummy_source_0, 'stop_in'))
        self.msg_connect((self.inets_general_timer_1, 'expire_signal_out'),
                         (self.inets_carrier_sensing_0, 'cmd_in'))
        self.msg_connect((self.inets_general_timer_1_0, 'expire_signal_out'),
                         (self.inets_carrier_sensing_0_1, 'cmd_in'))
        self.msg_connect((self.inets_general_timer_2, 'expire_signal_out'),
                         (self.inets_cogmac_ch_pool_0, 'CCA_CH_in'))
        self.msg_connect((self.inets_general_timer_2, 'expire_signal_out'),
                         (self.inets_frame_path_0, 'frame_in'))
        self.msg_connect((self.inets_general_timer_2, 'expire_signal_out'),
                         (self.inets_frame_path_2_0, 'frame_in'))
        self.msg_connect((self.inets_general_timer_2_0, 'expire_signal_out'),
                         (self.inets_frame_path_1_0_0, 'frame_in'))
        self.msg_connect((self.inets_general_timer_3, 'expire_signal_out'),
                         (self.inets_carrier_sensing_0_0, 'cmd_in'))
        self.msg_connect((self.inets_receiving_0, 'rx_power_out'),
                         (self.inets_carrier_sensing_0, 'power_in'))
        self.msg_connect((self.inets_receiving_0, 'rx_power_out'),
                         (self.inets_carrier_sensing_0_0, 'power_in'))
        self.msg_connect((self.inets_receiving_0, 'rx_power_out'),
                         (self.inets_carrier_sensing_0_1, 'power_in'))
        self.msg_connect((self.inets_receiving_0, 'rx_frame_out'),
                         (self.inets_frame_analysis_0, 'frame_in'))
        self.msg_connect((self.inets_receiving_0, 'rx_switch_out'),
                         (self.inets_sending_0, 'in'))
        self.msg_connect((self.inets_run_0, 'trigger_out'),
                         (self.inets_cogmac_timing_0, 'trigger_in'))
        self.msg_connect((self.inets_sending_0, 'data_frame_out'),
                         (self.inets_frame_index_selector_0_1, 'frame_in'))
        self.msg_connect((self.inets_sending_0, 'data_frame_out'),
                         (self.inets_frame_path_2, 'frame_in'))
        self.msg_connect((self.inets_sending_0, 'data_frame_out'),
                         (self.inets_frame_probe_0, 'info_in'))
        self.msg_connect((self.inets_sending_0, 'rx_control_out'),
                         (self.inets_receiving_0, 'rx_switch_in'))
        self.msg_connect((self.inets_unbundle_0, 'cmd_out'),
                         (self.inets_frame_replicate_0, 'reset_number_in'))
        self.msg_connect((self.inets_unbundle_0_0, 'cmd_out'),
                         (self.inets_frame_counter_1, 'set_n_counts_in'))
        self.msg_connect((self.inets_unbundle_0_0_0, 'cmd_out'),
                         (self.inets_carrier_sensing_0, 'reset_duration_in'))
        self.msg_connect((self.inets_unbundle_0_0_0, 'cmd_out'),
                         (self.inets_carrier_sensing_0_1, 'reset_duration_in'))
        self.msg_connect((self.inets_unbundle_0_0_0_0, 'cmd_out'),
                         (self.inets_frame_buffer_0_0, 'reset_size_in'))
        self.msg_connect((self.inets_unbundle_0_0_0_0_0, 'cmd_out'),
                         (self.inets_frame_buffer_0, 'reset_size_in'))
예제 #2
0
    def __init__(self):
        gr.top_block.__init__(self, "theoretical_csma")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("theoretical_csma")
        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", "theoretical_csma")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.usrp_device_address = usrp_device_address = "addr=10.0.0.14"
        self.tx_center_frequency = tx_center_frequency = 3.9e8
        self.timeout_duration_ms = timeout_duration_ms = 1000
        self.system_time_granularity_us = system_time_granularity_us = 10
        self.source_address = source_address = 3
        self.samp_rate = samp_rate = 400000
        self.rx_gain = rx_gain = 0
        self.rx_center_frequency = rx_center_frequency = 3.9e8

        self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11 * sps)

        self.mu = mu = 0.6
        self.diff_preamble_128 = diff_preamble_128 = [
            1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0,
            1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1,
            1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0,
            1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0,
            1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1,
            1, 1, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0,
            1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1,
            0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0,
            0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0,
            0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1,
            0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1,
            1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0
        ][0:128]
        self.destination_address = destination_address = 2
        self.cs_threshold = cs_threshold = 0.005

        ##################################################
        # Blocks
        ##################################################
        self.inets_time_probe_0 = inets.time_probe(1, 200, 0)
        self.inets_standard_timer_0 = inets.standard_timer(0, 51, 4, 10)
        self.inets_sending_0 = inets.sending(
            develop_mode=0,
            block_id=11,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            preamble=diff_preamble_128,
            samp_rate=samp_rate,
            sps=sps,
            system_time_granularity_us=system_time_granularity_us,
            usrp_device_address=usrp_device_address,
            center_frequency=tx_center_frequency,
            interframe_interval_s=0.004,
            t_pretx_interval_s=0,
            file_name_extension_t_control="t1TXs",
            file_name_extension_pending="Tfr",
            record_on=0,
            name_with_timestamp=0,
            tx_gain=0)
        self.inets_run_0 = inets.run(20, 10)
        self.inets_receiving_0 = inets.receiving(
            0, 21,
            gnuradio.digital.constellation_qpsk().base(), rrc, mu,
            diff_preamble_128, rx_gain, samp_rate, sps, 30,
            usrp_device_address, rx_center_frequency)
        self.inets_random_filter_1 = inets.random_filter(0, 3, 0.3694528)
        self.inets_random_filter_0 = inets.random_filter(0, 3, 0.03)
        self.inets_parameter_list_0 = inets.parameter_list(
            0, 49, [
                0.00091578, 0.002489, 0.00676676, 0.018393972, 0.05, 0.135914,
                0.3694528
            ])
        self.inets_general_timer_0_0_0 = inets.general_timer(0, 1, 0, 4, 10, 0)
        self.inets_general_timer_0_0 = inets.general_timer(
            0, 1, 0, 500000, 10, 0)
        self.inets_framing_0 = inets.framing(0, 17, 1, 1, 0, 1,
                                             destination_address, 1,
                                             source_address, 1, 318, 2, 524, 2,
                                             2, 1, 1, 0, ([2, 3]),
                                             ([1000, 1000]), 2, 0, 300, 1)
        self.inets_frame_probe_1 = inets.frame_probe(
            2, 100, 0, 0, 0.01, 0, "/home/inets/source/gr-inets/results/", "",
            1)
        self.inets_frame_probe_0 = inets.frame_probe(
            2, 100, 0, 1, 0.0015, 0, "/home/inets/source/gr-inets/results/",
            "", 1)
        self.inets_frame_counter_0 = inets.frame_counter(0, 36, 7, 0)
        self.inets_frame_buffer_0_0 = inets.frame_buffer(0, 16, 1, 1, 1, 0)
        self.inets_dummy_source_0 = inets.dummy_source(0, 23, 770, 3, 1)
        self.inets_counter_0_0_0 = inets.counter(
            3, 1, 1, "sent_3", 1, "/home/inets/source/gr-inets/results/", 0)
        self.inets_counter_0 = inets.counter(
            1, 2, 1, "sent", 0, "/home/inets/source/gr-inets/results/", 1)
        self.inets_cmd_path_0_0_0 = inets.cmd_path(0, 44, 1)
        self.inets_carrier_sensing_0 = inets.carrier_sensing(
            0, 11, 3, 3, 0.0015, system_time_granularity_us, -1, 20)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.inets_carrier_sensing_0, 'cmd_pass_out'),
                         (self.inets_random_filter_0, 'cmd_in'))
        self.msg_connect((self.inets_cmd_path_0_0_0, 'cmd_out'),
                         (self.inets_frame_buffer_0_0, 'dequeue'))
        self.msg_connect((self.inets_dummy_source_0, 'output'),
                         (self.inets_framing_0, 'data_in'))
        self.msg_connect((self.inets_frame_buffer_0_0, 'dequeue_element'),
                         (self.inets_carrier_sensing_0, 'cmd_in'))
        self.msg_connect((self.inets_frame_counter_0, 'unselect_out'),
                         (self.inets_general_timer_0_0, 'active_in'))
        self.msg_connect((self.inets_frame_counter_0, 'select_out'),
                         (self.inets_standard_timer_0, 'disable_timer_in'))
        self.msg_connect((self.inets_framing_0, 'frame_out'),
                         (self.inets_frame_buffer_0_0, 'enqueue'))
        self.msg_connect((self.inets_general_timer_0_0, 'expire_signal_out'),
                         (self.inets_counter_0_0_0, 'reset_counter'))
        self.msg_connect((self.inets_general_timer_0_0, 'expire_signal_out'),
                         (self.inets_frame_counter_0, 'counts_in'))
        self.msg_connect((self.inets_general_timer_0_0, 'expire_signal_out'),
                         (self.inets_parameter_list_0, 'trigger_in'))
        self.msg_connect((self.inets_general_timer_0_0_0, 'expire_signal_out'),
                         (self.inets_carrier_sensing_0, 'cmd_in'))
        self.msg_connect((self.inets_parameter_list_0, 'parameter_out'),
                         (self.inets_random_filter_1, 'set_threshold'))
        self.msg_connect((self.inets_random_filter_0, 'lose_cmd_out'),
                         (self.inets_general_timer_0_0_0, 'active_in'))
        self.msg_connect((self.inets_random_filter_0, 'win_cmd_out'),
                         (self.inets_sending_0, 'in'))
        self.msg_connect((self.inets_random_filter_1, 'win_cmd_out'),
                         (self.inets_dummy_source_0, 'trigger'))
        self.msg_connect((self.inets_receiving_0, 'rx_power_out'),
                         (self.inets_carrier_sensing_0, 'power_in'))
        self.msg_connect((self.inets_run_0, 'trigger_out'),
                         (self.inets_general_timer_0_0, 'active_in'))
        self.msg_connect((self.inets_run_0, 'trigger_out'),
                         (self.inets_parameter_list_0, 'trigger_in'))
        self.msg_connect((self.inets_run_0, 'trigger_out'),
                         (self.inets_standard_timer_0, 'active_in'))
        self.msg_connect((self.inets_sending_0, 'data_frame_out'),
                         (self.inets_cmd_path_0_0_0, 'cmd_in'))
        self.msg_connect((self.inets_sending_0, 'data_frame_out'),
                         (self.inets_counter_0, 'message_in'))
        self.msg_connect((self.inets_sending_0, 'data_frame_out'),
                         (self.inets_counter_0_0_0, 'message_in'))
        self.msg_connect((self.inets_standard_timer_0, 'expire_cmd_out'),
                         (self.inets_random_filter_1, 'cmd_in'))
예제 #3
0
    def __init__(self):
        gr.top_block.__init__(self, "CogMAC_plus")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("CogMAC_plus")
        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", "CogMAC_plus")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.range_rx_gain = range_rx_gain = 0
        self.range_mu = range_mu = 0.6
        self.usrp_device_address = usrp_device_address = "addr=10.0.0.6"
        self.tx_center_frequency = tx_center_frequency = 3.9e8
        self.system_time_granularity_us = system_time_granularity_us = 10
        self.source_address = source_address = 1
        self.samp_rate = samp_rate = 400000
        self.rx_gain = rx_gain = range_rx_gain
        self.rx_center_frequency = rx_center_frequency = 3.9e8

        self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11*sps)

        self.mu = mu = range_mu
        self.diff_preamble_128 = diff_preamble_128 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0][0:128]
        self.destination_address = destination_address = 3
        self.cs_threshold = cs_threshold = 0.005

        ##################################################
        # Blocks
        ##################################################
        self._range_rx_gain_range = Range(0, 60, 1, 0, 200)
        self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range, self.set_range_rx_gain, 'Rx Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_rx_gain_win, 1,0,1,1)
        self._range_mu_range = Range(0, 1, 0.01, 0.6, 200)
        self._range_mu_win = RangeWidget(self._range_mu_range, self.set_range_mu, 'BB Derotation Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_mu_win, 2,0,1,1)
        self.inets_sending_0 = inets.sending(develop_mode=0, block_id=11, constellation=gnuradio.digital.constellation_qpsk().base(), preamble=diff_preamble_128, samp_rate=samp_rate, sps=sps, system_time_granularity_us=system_time_granularity_us, usrp_device_address=usrp_device_address, center_frequency=tx_center_frequency, interframe_interval_s=0.005, t_pretx_interval_s=0, file_name_extension_t_control="t1TXs", file_name_extension_pending="Tfr", record_on=0, name_with_timestamp=1, tx_gain=0)
        self.inets_run_0 = inets.run(5, 10)
        self.inets_receiving_0 = inets.receiving(1, 21, gnuradio.digital.constellation_qpsk().base(), rrc, mu, diff_preamble_128, rx_gain, samp_rate, sps, 30, usrp_device_address, rx_center_frequency)
        self.inets_general_timer_1 = inets.general_timer(0, 3, 0, 100, 10, 0)
        self.inets_general_timer_0 = inets.general_timer(1, 15, 0, 1000, 10, 0)
        self.inets_framing_0 = inets.framing(0, 17, 1, 1, 10, 1, destination_address, 1, source_address, 1, 318, 2, 524, 2, 2, -1, 1, 0, ([2, 3]), ([1000, 1000]), 2, 0, 300, 1)
        self.inets_frame_replicate_0 = inets.frame_replicate(0, 37, 4)
        self.inets_frame_probe_0_0 = inets.frame_probe(0, 100, 0, 0, 0.01, 0, "/home/inets/source/gr-inets/results/", "", 1)
        self.inets_frame_probe_0 = inets.frame_probe(2, 100, 0, 1, 0.01, 0, "/home/inets/source/gr-inets/results/", "", 1)
        self.inets_frame_path_0_0_2 = inets.frame_path(0, 39)
        self.inets_frame_path_0_0_1_1_0 = inets.frame_path(0, 39)
        self.inets_frame_path_0_0_1_1 = inets.frame_path(0, 39)
        self.inets_frame_path_0_0_1_0_2_0 = inets.frame_path(0, 39)
        self.inets_frame_path_0_0_1_0_2 = inets.frame_path(0, 39)
        self.inets_frame_path_0_0_1_0_0_0 = inets.frame_path(0, 39)
        self.inets_frame_path_0_0_1_0_0 = inets.frame_path(0, 39)
        self.inets_frame_path_0_0_1_0 = inets.frame_path(0, 39)
        self.inets_frame_path_0_0_0 = inets.frame_path(0, 39)
        self.inets_frame_path_0_0 = inets.frame_path(0, 39)
        self.inets_frame_path_0 = inets.frame_path(0, 39)
        self.inets_frame_index_selector_1 = inets.frame_index_selector(0, 33, (1, ), 0)
        self.inets_frame_index_selector_0 = inets.frame_index_selector(0, 33, (10, ), 0)
        self.inets_frame_counter_0 = inets.frame_counter(0, 36, 4)
        self.inets_frame_check_0 = inets.frame_check(0, 9)
        self.inets_frame_buffer_0_0 = inets.frame_buffer(0, 16, 100, 0, 0, 0)
        self.inets_frame_buffer_0 = inets.frame_buffer(0, 16, 10, 0, 0, 1)
        self.inets_frame_and_0 = inets.frame_and(0, 38, 0)
        self.inets_frame_analysis_0 = inets.frame_analysis(0, 7, 1, 1, 1, 1, 1, 2, 2, 2, 1, source_address)
        self.inets_dummy_source_0 = inets.dummy_source(0, 23, 300, 3, 100)
        self.inets_cogmac_ch_pool_0 = inets.cogmac_ch_pool(1, 35, 3, 390000000, 0, 10000000)
        self.inets_carrier_sensing_0 = inets.carrier_sensing(1, 11, 2, 1000, 0.005, 1000, 100)
        self.inets_backoff_0 = inets.backoff(0, 11, 3, 10, 1000, 4000, 1, 0.005, 10, 1)
        self.inets_address_check_0 = inets.address_check(0, 17, source_address)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.inets_backoff_0, 'frame_info_out'), (self.inets_frame_buffer_0, 'indicate_empty'))
        self.msg_connect((self.inets_carrier_sensing_0, 'frame_info_pass_out'), (self.inets_frame_path_0_0_1_0, 'frame_in'))
        self.msg_connect((self.inets_carrier_sensing_0, 'frame_info_fail_out'), (self.inets_frame_path_0_0_1_0_2, 'frame_in'))
        self.msg_connect((self.inets_cogmac_ch_pool_0, 'next_frequency_out'), (self.inets_frame_path_0_0_1_0_0, 'frame_in'))
        self.msg_connect((self.inets_cogmac_ch_pool_0, 'next_frequency_out'), (self.inets_sending_0, 'reconfig_in'))
        self.msg_connect((self.inets_dummy_source_0, 'output'), (self.inets_framing_0, 'data_in'))
        self.msg_connect((self.inets_frame_analysis_0, 'frame_info_out'), (self.inets_frame_check_0, 'frame_info_in'))
        self.msg_connect((self.inets_frame_and_0, 'frame_out'), (self.inets_frame_counter_0, 'reset_in'))
        self.msg_connect((self.inets_frame_and_0, 'frame_out'), (self.inets_frame_path_0_0_1_1_0, 'frame_in'))
        self.msg_connect((self.inets_frame_buffer_0, 'dequeue_element'), (self.inets_frame_index_selector_0, 'frame_in'))
        self.msg_connect((self.inets_frame_buffer_0, 'buffer_not_full'), (self.inets_frame_path_0_0, 'frame_in'))
        self.msg_connect((self.inets_frame_buffer_0, 'buffer_empty'), (self.inets_frame_path_0_0_0, 'frame_in'))
        self.msg_connect((self.inets_frame_buffer_0_0, 'buffer_empty'), (self.inets_frame_path_0_0_1_0_2_0, 'frame_in'))
        self.msg_connect((self.inets_frame_buffer_0_0, 'dequeue_element'), (self.inets_general_timer_0, 'suspend_timer_in'))
        self.msg_connect((self.inets_frame_buffer_0_0, 'dequeue_element'), (self.inets_sending_0, 'in'))
        self.msg_connect((self.inets_frame_check_0, 'good_frame_info_out'), (self.inets_address_check_0, 'frame_info_in'))
        self.msg_connect((self.inets_frame_check_0, 'good_frame_info_out'), (self.inets_general_timer_1, 'active_in'))
        self.msg_connect((self.inets_frame_counter_0, 'select_out'), (self.inets_carrier_sensing_0, 'info_in'))
        self.msg_connect((self.inets_frame_index_selector_0, 'unselected_frame_out'), (self.inets_frame_index_selector_1, 'frame_in'))
        self.msg_connect((self.inets_frame_index_selector_0, 'frame_out'), (self.inets_frame_path_0, 'frame_in'))
        self.msg_connect((self.inets_frame_index_selector_0, 'unselected_frame_out'), (self.inets_frame_path_0, 'frame_in'))
        self.msg_connect((self.inets_frame_index_selector_0, 'frame_out'), (self.inets_frame_replicate_0, 'frame_in'))
        self.msg_connect((self.inets_frame_index_selector_1, 'frame_out'), (self.inets_frame_buffer_0_0, 'dequeue'))
        self.msg_connect((self.inets_frame_index_selector_1, 'frame_out'), (self.inets_frame_path_0_0_1_1, 'frame_in'))
        self.msg_connect((self.inets_frame_index_selector_1, 'unselected_frame_out'), (self.inets_frame_path_0_0_1_1, 'frame_in'))
        self.msg_connect((self.inets_frame_path_0, 'frame_out'), (self.inets_frame_buffer_0, 'dequeue'))
        self.msg_connect((self.inets_frame_path_0_0, 'frame_out'), (self.inets_dummy_source_0, 'trigger'))
        self.msg_connect((self.inets_frame_path_0_0_0, 'frame_out'), (self.inets_framing_0, 'reset_index'))
        self.msg_connect((self.inets_frame_path_0_0_1_0, 'frame_out'), (self.inets_frame_buffer_0_0, 'dequeue'))
        self.msg_connect((self.inets_frame_path_0_0_1_0, 'frame_out'), (self.inets_general_timer_0, 'suspend_timer_in'))
        self.msg_connect((self.inets_frame_path_0_0_1_0_0, 'frame_out'), (self.inets_receiving_0, 'reconfig_in'))
        self.msg_connect((self.inets_frame_path_0_0_1_0_0_0, 'frame_out'), (self.inets_general_timer_0, 'active_in'))
        self.msg_connect((self.inets_frame_path_0_0_1_0_2, 'frame_out'), (self.inets_frame_buffer_0_0, 'flush'))
        self.msg_connect((self.inets_frame_path_0_0_1_0_2, 'frame_out'), (self.inets_general_timer_0, 'suspend_timer_in'))
        self.msg_connect((self.inets_frame_path_0_0_1_0_2_0, 'frame_out'), (self.inets_frame_and_0, 'frame_II_in'))
        self.msg_connect((self.inets_frame_path_0_0_1_1, 'frame_out'), (self.inets_frame_buffer_0_0, 'enqueue'))
        self.msg_connect((self.inets_frame_path_0_0_1_1_0, 'frame_out'), (self.inets_backoff_0, 'frame_info_in'))
        self.msg_connect((self.inets_frame_path_0_0_1_1_0, 'frame_out'), (self.inets_general_timer_0, 'resume_timer_in'))
        self.msg_connect((self.inets_frame_path_0_0_2, 'frame_out'), (self.inets_frame_buffer_0, 'dequeue'))
        self.msg_connect((self.inets_frame_replicate_0, 'replicate_out'), (self.inets_frame_path_0_0_1_1, 'frame_in'))
        self.msg_connect((self.inets_framing_0, 'frame_out'), (self.inets_frame_buffer_0, 'enqueue'))
        self.msg_connect((self.inets_general_timer_0, 'expire_signal_out'), (self.inets_cogmac_ch_pool_0, 'change_in'))
        self.msg_connect((self.inets_general_timer_0, 'expire_signal_out'), (self.inets_frame_path_0_0_1_0_0_0, 'frame_in'))
        self.msg_connect((self.inets_general_timer_1, 'expire_signal_out'), (self.inets_general_timer_0, 'resume_timer_in'))
        self.msg_connect((self.inets_receiving_0, 'rx_power_out'), (self.inets_carrier_sensing_0, 'power_in'))
        self.msg_connect((self.inets_receiving_0, 'rx_frame_out'), (self.inets_frame_analysis_0, 'frame_in'))
        self.msg_connect((self.inets_run_0, 'trigger_out'), (self.inets_frame_buffer_0, 'indicate_empty'))
        self.msg_connect((self.inets_run_0, 'trigger_out'), (self.inets_general_timer_0, 'active_in'))
        self.msg_connect((self.inets_sending_0, 'data_frame_out'), (self.inets_frame_and_0, 'frame_I_in'))
        self.msg_connect((self.inets_sending_0, 'data_frame_out'), (self.inets_frame_counter_0, 'counts_in'))
        self.msg_connect((self.inets_sending_0, 'data_frame_out'), (self.inets_frame_path_0_0_1_0, 'frame_in'))
예제 #4
0
    def __init__(self):
        gr.top_block.__init__(self, "theoretical_csma_rx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("theoretical_csma_rx")
        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", "theoretical_csma_rx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.range_rx_gain = range_rx_gain = 0
        self.range_mu = range_mu = 0.6
        self.usrp_device_address = usrp_device_address = "addr=10.0.0.6"
        self.tx_center_frequency = tx_center_frequency = 3.9e8
        self.timeout_duration_ms = timeout_duration_ms = 1000
        self.system_time_granularity_us = system_time_granularity_us = 10
        self.source_address = source_address = 2
        self.samp_rate = samp_rate = 400000
        self.rx_gain = rx_gain = range_rx_gain
        self.rx_center_frequency = rx_center_frequency = 3.9e8

        self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11*sps)

        self.mu = mu = range_mu
        self.diff_preamble_128 = diff_preamble_128 = [1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 0,0, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0,0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 1,1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 0][0:128]
        self.destination_address = destination_address = 1
        self.cs_threshold = cs_threshold = 0.005

        ##################################################
        # Blocks
        ##################################################
        self._range_rx_gain_range = Range(0, 60, 1, 0, 200)
        self._range_rx_gain_win = RangeWidget(self._range_rx_gain_range, self.set_range_rx_gain, 'Rx Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_rx_gain_win, 1,0,1,1)
        self._range_mu_range = Range(0, 1, 0.01, 0.6, 200)
        self._range_mu_win = RangeWidget(self._range_mu_range, self.set_range_mu, 'BB Derotation Gain', "counter_slider", float)
        self.top_grid_layout.addWidget(self._range_mu_win, 2,0,1,1)
        self.inets_run_0 = inets.run(20, 10)
        self.inets_receiving_0 = inets.receiving(0, 21, gnuradio.digital.constellation_qpsk().base(), rrc, mu, diff_preamble_128, rx_gain, samp_rate, sps, 30, usrp_device_address, rx_center_frequency)
        self.inets_general_timer_0 = inets.general_timer(0, 5, 0, 500000, 10, 0)
        self.inets_frame_probe_0 = inets.frame_probe(2, 100, 0, 1, 0.0015, 0, "/home/inets/source/gr-inets/results/", "", 1)
        self.inets_frame_counter_0 = inets.frame_counter(0, 36, 8, 0)
        self.inets_frame_check_0 = inets.frame_check(0, 9)
        self.inets_frame_analysis_0 = inets.frame_analysis(0, 7, 1, 1, 1, 1, 1, 2, 2, 2, 1, source_address)
        self.inets_counter_0_0_2 = inets.counter(1, 1, 1, "", 0, "/home/inets/source/gr-inets/results/", 1)
        self.inets_counter_0_0_1 = inets.counter(1, 2, 1, "", 0, "/home/inets/source/gr-inets/results/", 1)
        self.inets_counter_0_0_0 = inets.counter(1, 3, 1, "", 0, "/home/inets/source/gr-inets/results/", 1)
        self.inets_counter_0_0 = inets.counter(3, 5, 1, "not_addressed", 1, "/home/inets/source/gr-inets/results/", 0)
        self.inets_counter_0 = inets.counter(3, 4, 1, "addressed", 1, "/home/inets/source/gr-inets/results/", 0)
        self.inets_cmd_path_0 = inets.cmd_path(0, 44, 1)
        self.inets_address_check_0 = inets.address_check(0, 17, source_address)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.inets_address_check_0, 'address_check_pass_out'), (self.inets_counter_0, 'message_in'))
        self.msg_connect((self.inets_address_check_0, 'address_check_fail_out'), (self.inets_counter_0_0, 'message_in'))
        self.msg_connect((self.inets_cmd_path_0, 'cmd_out'), (self.inets_general_timer_0, 'active_in'))
        self.msg_connect((self.inets_frame_analysis_0, 'frame_info_out'), (self.inets_frame_check_0, 'frame_info_in'))
        self.msg_connect((self.inets_frame_check_0, 'good_frame_info_out'), (self.inets_address_check_0, 'frame_info_in'))
        self.msg_connect((self.inets_frame_counter_0, 'unselect_out'), (self.inets_cmd_path_0, 'cmd_in'))
        self.msg_connect((self.inets_frame_counter_0, 'unselect_out'), (self.inets_counter_0, 'reset_counter'))
        self.msg_connect((self.inets_frame_counter_0, 'unselect_out'), (self.inets_counter_0_0, 'reset_counter'))
        self.msg_connect((self.inets_general_timer_0, 'expire_signal_out'), (self.inets_frame_counter_0, 'counts_in'))
        self.msg_connect((self.inets_receiving_0, 'rx_frame_out'), (self.inets_frame_analysis_0, 'frame_in'))
        self.msg_connect((self.inets_run_0, 'trigger_out'), (self.inets_general_timer_0, 'active_in'))