예제 #1
0
    def __init__(self):
        gr.top_block.__init__(self, "aloha")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("aloha")
        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", "aloha")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.range_rx_gain = range_rx_gain = 5
        self.range_mu = range_mu = 0.6
        self.usrp_device_address = usrp_device_address = "addr=10.0.0.6"
        self.timeout_duration_ms = timeout_duration_ms = 500
        self.system_time_granularity_us = system_time_granularity_us = 1000
        self.source_address = source_address = 1
        self.self_data_info = self_data_info = pmt.to_pmt({
            'frame_type':
            1,
            'frame_index':
            1,
            'destination_address':
            2,
            'source_address':
            1,
            'num_resend':
            3,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            200
        })
        self.self_ack_info = self_ack_info = pmt.to_pmt({
            'frame_type': 2,
            'frame_index': 1,
            'destination_address': 2,
            'source_address': 1,
            'num_resend': 0,
            'reserved_field_I': 1,
            'reserved_field_II': 1,
            'pay_load_length': 0
        })
        self.samp_rate = samp_rate = 1000000
        self.rx_gain = rx_gain = range_rx_gain

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

        self.reserved_field_II = reserved_field_II = 6
        self.reserved_field_I = reserved_field_I = 5
        self.preamble_detector_threshold = preamble_detector_threshold = 30
        self.mu = mu = range_mu
        self.min_backoff_ms = min_backoff_ms = 50
        self.max_num_retransmission = max_num_retransmission = 5
        self.max_buffer_size = max_buffer_size = 10
        self.len_source_address = len_source_address = 1
        self.len_reserved_field_II = len_reserved_field_II = 2
        self.len_reserved_field_I = len_reserved_field_I = 2
        self.len_payload_length = len_payload_length = 1
        self.len_num_transmission = len_num_transmission = 1
        self.len_frame_type = len_frame_type = 1
        self.len_frame_index = len_frame_index = 1
        self.len_destination_address = len_destination_address = 1
        self.increase_index = increase_index = 1
        self.frame_type = frame_type = 1
        self.frame_index = frame_index = 0
        self.experiment_duration_s = experiment_duration_s = 1000
        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.develop_mode_list = develop_mode_list = [0]
        self.destination_address = destination_address = 2
        self.cs_threshold = cs_threshold = 0.005
        self.cs_duration = cs_duration = 1000
        self.counter_id = counter_id = 20
        self.backoff_time_unit_ms = backoff_time_unit_ms = 50
        self.apply_address_check = apply_address_check = 1
        self.another_data_info = another_data_info = pmt.to_pmt({
            'frame_type':
            1,
            'frame_index':
            1,
            'destination_address':
            1,
            'source_address':
            2,
            'num_resend':
            3,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            200
        })
        self.another_ack_info = another_ack_info = pmt.to_pmt({
            'good_frame':
            1,
            'address_check':
            1,
            'header_length':
            9,
            'payload_length':
            0,
            'reserved_field_II':
            6,
            'reserved_field_I':
            5,
            'num_transmission':
            0,
            'source_address':
            1,
            'destination_address':
            3,
            'frame_index':
            22,
            'frame_type':
            1
        })

        ##################################################
        # Blocks
        ##################################################
        self.send_frame_0 = send_frame(
            block_id=2,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            develop_mode=1,
            preamble=diff_preamble_128,
            samp_rate=samp_rate,
            sps=sps,
            system_time_granularity_us=system_time_granularity_us,
            usrp_device_address=usrp_device_address,
        )
        self.receive_frame_0_0 = receive_frame(
            apply_address_check=apply_address_check,
            block_id=3,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            develop_mode=[11],
            len_destination_address=len_destination_address,
            len_frame_index=len_frame_index,
            len_frame_type=len_frame_type,
            len_num_transmission=len_num_transmission,
            len_payload_length=len_payload_length,
            len_reserved_field_I=len_reserved_field_I,
            len_reserved_field_II=len_reserved_field_II,
            len_source_address=len_source_address,
            matched_filter_coeff=rrc,
            mu=mu,
            my_address=source_address,
            preamble=diff_preamble_128,
            rx_gain=rx_gain,
            samp_rate=samp_rate,
            sps=sps,
            threshold=preamble_detector_threshold,
            usrp_device_address=usrp_device_address,
        )
        self._range_rx_gain_range = Range(0, 60, 1, 5, 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_timeout_cpp_0 = inets.timeout_cpp(
            0, 10, timeout_duration_ms, system_time_granularity_us)
        self.inets_idle_0 = inets.idle(
            0, 1, experiment_duration_s, max_num_retransmission,
            max_buffer_size, frame_type, len_frame_type, frame_index,
            len_frame_index, destination_address, len_destination_address,
            source_address, len_source_address, reserved_field_I,
            len_reserved_field_I, reserved_field_II, len_reserved_field_II,
            len_payload_length, increase_index, len_num_transmission)
        self.inets_frame_info_selector_0_0_0 = inets.frame_info_selector()
        self.inets_frame_info_selector_0_0 = inets.frame_info_selector()
        self.inets_frame_info_selector_0 = inets.frame_info_selector()
        self.inets_exponential_backoff_cpp_0 = inets.exponential_backoff_cpp(
            0, 11, backoff_time_unit_ms, max_num_retransmission,
            min_backoff_ms)
        self.inets_counter_0_1 = inets.counter(([22]), 22)
        self.frame_info_simulator = blocks.message_strobe_random(
            pmt.to_pmt({
                'good_frame': 1,
                'address_check': 1,
                'header_length': 9,
                'payload_length': 0,
                'reserved_field_II': 6,
                'reserved_field_I': 5,
                'num_transmission': 0,
                'source_address': 1,
                'destination_address': 3,
                'frame_index': 22,
                'frame_type': 1
            }), blocks.STROBE_POISSON, 2000, 1000)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", 'localhost',
                                                     '52001', 10000, False)
        self.blocks_message_strobe_random_1 = blocks.message_strobe_random(
            pmt.from_bool(True), blocks.STROBE_POISSON, 2000, 5)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'),
                         (self.inets_idle_0, 'data_in'))
        self.msg_connect(
            (self.inets_exponential_backoff_cpp_0, 'frame_info_out'),
            (self.inets_idle_0, 'data_in'))
        self.msg_connect(
            (self.inets_frame_info_selector_0, 'data_frame_info_out'),
            (self.inets_idle_0, 'data_in'))
        self.msg_connect(
            (self.inets_frame_info_selector_0, 'ack_frame_info_out'),
            (self.inets_timeout_cpp_0, 'ack_frame_info_in'))
        self.msg_connect(
            (self.inets_frame_info_selector_0_0, 'data_frame_info_out'),
            (self.inets_timeout_cpp_0, 'data_frame_info_in'))
        self.msg_connect(
            (self.inets_frame_info_selector_0_0_0, 'data_frame_info_out'),
            (self.inets_exponential_backoff_cpp_0, 'frame_info_trigger_in'))
        self.msg_connect(
            (self.inets_frame_info_selector_0_0_0, 'ack_frame_info_out'),
            (self.inets_idle_0, 'data_in'))
        self.msg_connect((self.inets_idle_0, 'successful_transmission'),
                         (self.inets_counter_0_1, 'message_in'))
        self.msg_connect((self.inets_idle_0, 'data_out'),
                         (self.send_frame_0, 'in'))
        self.msg_connect(
            (self.inets_timeout_cpp_0, 'frame_info_out'),
            (self.inets_frame_info_selector_0_0_0, 'frame_info_in'))
        self.msg_connect((self.receive_frame_0_0, 'rx_frame_info_out'),
                         (self.inets_frame_info_selector_0, 'frame_info_in'))
        self.msg_connect((self.send_frame_0, 'tx_frame_info_out'),
                         (self.inets_frame_info_selector_0_0, 'frame_info_in'))
    def __init__(self):
        gr.top_block.__init__(self, "Test_idle_sendframe_receiveframe_idle")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Test_idle_sendframe_receiveframe_idle")
        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", "Test_idle_sendframe_receiveframe_idle")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.range_rx_gain = range_rx_gain = 5
        self.range_mu = range_mu = 0.6
        self.timeout_duration_ms = timeout_duration_ms = 500
        self.system_time_granularity_us = system_time_granularity_us = 10000
        self.source_address = source_address = 1
        self.self_data_info = self_data_info = pmt.to_pmt({'frame_type': 1, 'frame_index': 1, 'destination_address': 2, 'source_address': 1, 'num_resend': 3, 'reserved_field_I': 1, 'reserved_field_II': 1, 'pay_load_length': 200})
        self.self_ack_info = self_ack_info = pmt.to_pmt({'frame_type': 2, 'frame_index': 1, 'destination_address': 2, 'source_address': 1, 'num_resend': 0, 'reserved_field_I': 1, 'reserved_field_II': 1, 'pay_load_length': 0})
        self.samp_rate = samp_rate = 1000000
        self.rx_gain = rx_gain = range_rx_gain
        
        self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11*sps)
          
        self.reserved_field_II = reserved_field_II = 6
        self.reserved_field_I = reserved_field_I = 5
        self.preamble_detector_threshold = preamble_detector_threshold = 30
        self.mu = mu = range_mu
        self.max_num_retransmission = max_num_retransmission = 5
        self.max_buffer_size = max_buffer_size = 10
        self.len_source_address = len_source_address = 1
        self.len_reserved_field_II = len_reserved_field_II = 2
        self.len_reserved_field_I = len_reserved_field_I = 2
        self.len_payload_length = len_payload_length = 1
        self.len_num_transmission = len_num_transmission = 1
        self.len_frame_type = len_frame_type = 1
        self.len_frame_index = len_frame_index = 1
        self.len_destination_address = len_destination_address = 1
        self.increase_index = increase_index = 1
        self.frame_type = frame_type = 1
        self.frame_index = frame_index = 0
        self.experiment_duration_s = experiment_duration_s = 1000
        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.develop_mode_list = develop_mode_list = [0]
        self.destination_address = destination_address = 3
        self.counter_id = counter_id = 20
        self.apply_address_check = apply_address_check = 1
        self.another_data_info = another_data_info = pmt.to_pmt({'frame_type': 1, 'frame_index': 1, 'destination_address': 1, 'source_address': 2, 'num_resend': 3, 'reserved_field_I': 1, 'reserved_field_II': 1, 'pay_load_length': 200})
        self.another_ack_info = another_ack_info = pmt.to_pmt({'good_frame' : 1, 'address_check' : 1, 'header_length' : 9, 'payload_length' : 0, 'reserved_field_II' : 6, 'reserved_field_I' : 5, 'num_transmission' : 0, 'source_address' : 1, 'destination_address': 3, 'frame_index' : 22, 'frame_type' : 1})

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0_0 = uhd.usrp_source(
        	",".join(("addr=10.0.0.6", "")),
        	uhd.stream_args(
        		cpu_format="fc32",
        		channels=range(1),
        	),
        )
        self.uhd_usrp_source_0_0.set_time_now(uhd.time_spec(time.time()), uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0_0.set_center_freq(4e8, 0)
        self.uhd_usrp_source_0_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0 = uhd.usrp_source(
        	",".join(("addr=10.0.0.13", "")),
        	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(4e8, 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
        	",".join(("addr=10.0.0.13", "")),
        	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(4e8, 0)
        self.uhd_usrp_sink_0_0.set_gain(0, 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
        	",".join(("addr=10.0.0.6", "")),
        	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(4e8, 0)
        self.uhd_usrp_sink_0.set_gain(0, 0)
        self.send_frame_0_0 = send_frame(
            block_id=102,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            destination_address=source_address,
            develop_mode=1,
            frame_index=frame_index,
            frame_type=frame_type,
            increase_index=increase_index,
            len_destination_address=len_destination_address,
            len_frame_index=len_frame_index,
            len_frame_type=len_frame_type,
            len_payload_length=len_payload_length,
            len_reserved_field_I=len_reserved_field_I,
            len_reserved_field_II=len_reserved_field_II,
            len_source_address=len_source_address,
            preamble=diff_preamble_128,
            reserved_field_I=reserved_field_I,
            reserved_field_II=reserved_field_II,
            samp_rate=samp_rate,
            source_address=destination_address,
            sps=sps,
            system_time_granularity_us=system_time_granularity_us,
        )
        self.send_frame_0 = send_frame(
            block_id=2,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            destination_address=destination_address,
            develop_mode=1,
            frame_index=frame_index,
            frame_type=frame_type,
            increase_index=increase_index,
            len_destination_address=len_destination_address,
            len_frame_index=len_frame_index,
            len_frame_type=len_frame_type,
            len_payload_length=len_payload_length,
            len_reserved_field_I=len_reserved_field_I,
            len_reserved_field_II=len_reserved_field_II,
            len_source_address=len_source_address,
            preamble=diff_preamble_128,
            reserved_field_I=reserved_field_I,
            reserved_field_II=reserved_field_II,
            samp_rate=samp_rate,
            source_address=source_address,
            sps=sps,
            system_time_granularity_us=system_time_granularity_us,
        )
        self.receive_frame_0_0 = receive_frame(
            apply_address_check=apply_address_check,
            block_id=3,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            develop_mode=[11],
            len_destination_address=len_destination_address,
            len_frame_index=len_frame_index,
            len_frame_type=len_frame_type,
            len_num_transmission=len_num_transmission,
            len_payload_length=len_payload_length,
            len_reserved_field_I=len_reserved_field_I,
            len_reserved_field_II=len_reserved_field_II,
            len_source_address=len_source_address,
            matched_filter_coeff=rrc,
            mu=mu,
            my_address=source_address,
            preamble=diff_preamble_128,
            rx_gain=rx_gain,
            samp_rate=samp_rate,
            sps=sps,
            threshold=preamble_detector_threshold,
        )
        self.receive_frame_0 = receive_frame(
            apply_address_check=apply_address_check,
            block_id=103,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            develop_mode=[11],
            len_destination_address=len_destination_address,
            len_frame_index=len_frame_index,
            len_frame_type=len_frame_type,
            len_num_transmission=len_num_transmission,
            len_payload_length=len_payload_length,
            len_reserved_field_I=len_reserved_field_I,
            len_reserved_field_II=len_reserved_field_II,
            len_source_address=len_source_address,
            matched_filter_coeff=rrc,
            mu=mu,
            my_address=destination_address,
            preamble=diff_preamble_128,
            rx_gain=rx_gain,
            samp_rate=samp_rate,
            sps=sps,
            threshold=preamble_detector_threshold,
        )
        self._range_rx_gain_range = Range(0, 60, 1, 5, 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_idle_0_0 = inets.idle(1, 100, experiment_duration_s, max_num_retransmission, max_buffer_size, frame_type, len_frame_type, frame_index, len_frame_index, source_address, len_destination_address, destination_address, len_source_address, reserved_field_I, len_reserved_field_I, reserved_field_II, len_reserved_field_II, len_payload_length, increase_index, len_num_transmission)
        self.inets_idle_0 = inets.idle(2, 1, experiment_duration_s, max_num_retransmission, max_buffer_size, frame_type, len_frame_type, frame_index, len_frame_index, destination_address, len_destination_address, source_address, len_source_address, reserved_field_I, len_reserved_field_I, reserved_field_II, len_reserved_field_II, len_payload_length, increase_index, len_num_transmission)
        self.inets_frame_info_selector_0 = inets.frame_info_selector()
        self.frame_info_simulator = blocks.message_strobe_random(pmt.to_pmt({'good_frame' : 1, 'address_check' : 1, 'header_length' : 9, 'payload_length' : 0, 'reserved_field_II' : 6, 'reserved_field_I' : 5, 'num_transmission' : 0, 'source_address' : 1, 'destination_address': 3, 'frame_index' : 22, 'frame_type' : 1}), blocks.STROBE_POISSON, 2000, 1000)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "localhost", "52001", 10000, False)
        self.blocks_message_strobe_random_1 = blocks.message_strobe_random(pmt.from_bool(True), blocks.STROBE_POISSON, 2000, 5)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'), (self.inets_idle_0, 'data_in'))    
        self.msg_connect((self.inets_frame_info_selector_0, 'data_frame_info_out'), (self.inets_idle_0, 'data_in'))    
        self.msg_connect((self.inets_idle_0, 'data_out'), (self.send_frame_0, 'in'))    
        self.msg_connect((self.inets_idle_0_0, 'data_out'), (self.send_frame_0_0, 'in'))    
        self.msg_connect((self.receive_frame_0, 'rx_frame_info_out'), (self.inets_idle_0_0, 'data_in'))    
        self.msg_connect((self.receive_frame_0_0, 'rx_frame_info_out'), (self.inets_frame_info_selector_0, 'frame_info_in'))    
        self.connect((self.send_frame_0, 0), (self.uhd_usrp_sink_0, 0))    
        self.connect((self.send_frame_0_0, 0), (self.uhd_usrp_sink_0_0, 0))    
        self.connect((self.uhd_usrp_source_0, 0), (self.receive_frame_0, 0))    
        self.connect((self.uhd_usrp_source_0_0, 0), (self.receive_frame_0_0, 0))    
예제 #3
0
    def __init__(self, apply_address_check=1, destination_address=3, frame_index=2, frame_type=1, increase_index=1, len_destination_address=1, len_frame_index=1, len_frame_type=1, len_payload_length=1, len_reserved_field_I=2, len_reserved_field_II=2, len_source_address=1, reserved_field_I=5, reserved_field_II=6, source_address=4, system_time_granularity_us=5):
        gr.top_block.__init__(self, "Test tx rx")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Test tx 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", "Test_tx_rx")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Parameters
        ##################################################
        self.apply_address_check = apply_address_check
        self.destination_address = destination_address
        self.frame_index = frame_index
        self.frame_type = frame_type
        self.increase_index = increase_index
        self.len_destination_address = len_destination_address
        self.len_frame_index = len_frame_index
        self.len_frame_type = len_frame_type
        self.len_payload_length = len_payload_length
        self.len_reserved_field_I = len_reserved_field_I
        self.len_reserved_field_II = len_reserved_field_II
        self.len_source_address = len_source_address
        self.reserved_field_I = reserved_field_I
        self.reserved_field_II = reserved_field_II
        self.source_address = source_address
        self.system_time_granularity_us = system_time_granularity_us

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.range_rx_gain = range_rx_gain = 15
        self.range_mu = range_mu = 0.6
        self.threshold = threshold = 40
        self.samp_rate = samp_rate = 4e6
        self.rx_gain = rx_gain = range_rx_gain
        
        self.rrc = rrc = firdes.root_raised_cosine(1.0, sps, 1, 0.5, 11*sps)
          
        self.range_noise = range_noise = 0
        self.qpsk_mod = qpsk_mod = gnuradio.digital.constellation_qpsk().base()
        self.preamble = preamble = [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]
        self.mu = mu = range_mu
        self.max_num_retransmission = max_num_retransmission = 5
        self.max_buffer_size = max_buffer_size = 10
        self.len_num_transmission = len_num_transmission = 1
        self.experiment_duration_s = experiment_duration_s = 1000
        self.diff_preamble_256 = diff_preamble_256 = [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]
        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.develop_mode_list = develop_mode_list = [0]
        self.bpsk_mod = bpsk_mod = gnuradio.digital.constellation_bpsk().base()

        ##################################################
        # Blocks
        ##################################################
        self.tab = Qt.QTabWidget()
        self.tab_widget_0 = Qt.QWidget()
        self.tab_layout_0 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_0)
        self.tab_grid_layout_0 = Qt.QGridLayout()
        self.tab_layout_0.addLayout(self.tab_grid_layout_0)
        self.tab.addTab(self.tab_widget_0, 'TX')
        self.tab_widget_1 = Qt.QWidget()
        self.tab_layout_1 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_1)
        self.tab_grid_layout_1 = Qt.QGridLayout()
        self.tab_layout_1.addLayout(self.tab_grid_layout_1)
        self.tab.addTab(self.tab_widget_1, 'RX')
        self.tab_widget_2 = Qt.QWidget()
        self.tab_layout_2 = Qt.QBoxLayout(Qt.QBoxLayout.TopToBottom, self.tab_widget_2)
        self.tab_grid_layout_2 = Qt.QGridLayout()
        self.tab_layout_2.addLayout(self.tab_grid_layout_2)
        self.tab.addTab(self.tab_widget_2, 'Demod')
        self.top_layout.addWidget(self.tab)
        self.send_frame_0 = send_frame(
            constellation=gnuradio.digital.constellation_qpsk().base(),
            destination_address=destination_address,
            develop_mode_list=develop_mode_list,
            frame_index=frame_index,
            frame_type=frame_type,
            increase_index=increase_index,
            len_destination_address=len_destination_address,
            len_frame_index=len_frame_index,
            len_frame_type=len_frame_type,
            len_payload_length=len_payload_length,
            len_reserved_field_I=len_reserved_field_I,
            len_reserved_field_II=len_reserved_field_II,
            len_source_address=len_source_address,
            preamble=diff_preamble_128,
            reserved_field_I=reserved_field_I,
            reserved_field_II=reserved_field_II,
            samp_rate=samp_rate,
            source_address=source_address,
            sps=sps,
            system_time_granularity_us=system_time_granularity_us,
        )
        self.receive_frame_0 = receive_frame(
            apply_address_check=apply_address_check,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            develop_mode_list=[10],
            len_destination_address=len_destination_address,
            len_frame_index=len_frame_index,
            len_frame_type=len_frame_type,
            len_payload_length=len_payload_length,
            len_reserved_field_I=len_reserved_field_I,
            len_reserved_field_II=len_reserved_field_II,
            len_source_address=len_source_address,
            matched_filter_coeff=rrc,
            mu=mu,
            my_address=destination_address,
            preamble=diff_preamble_128,
            rx_gain=rx_gain,
            samp_rate=samp_rate,
            sps=sps,
            threshold=30,
        )
        self._range_rx_gain_range = Range(0, 60, 1, 15, 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_noise_range = Range(0, 0.01, 0.00001, 0, 200)
        self._range_noise_win = RangeWidget(self._range_noise_range, self.set_range_noise, 'noise', "counter_slider", float)
        self.top_layout.addWidget(self._range_noise_win)
        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_null_message_source_0 = inets.null_message_source()
        self.inets_message_tomb_0 = inets.message_tomb()
        self.inets_idle_0 = inets.idle((develop_mode_list), experiment_duration_s, max_num_retransmission, max_buffer_size, frame_type, len_frame_type, frame_index, len_frame_index, destination_address, len_destination_address, source_address, len_source_address, reserved_field_I, len_reserved_field_I, reserved_field_II, len_reserved_field_II, len_payload_length, increase_index, len_num_transmission)
        self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", 'localhost', '52001', 10000, False)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", 'localhost', '52001', 10000, False)
        self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*1)
        self.blocks_message_strobe_random_0 = blocks.message_strobe_random(pmt.from_bool(True), blocks.STROBE_POISSON, 10000, 5000)
        self.blocks_message_strobe_0_0 = blocks.message_strobe(pmt.from_bool(True), 1000)
        self.blocks_message_debug_0_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_random_0, 'strobe'), (self.receive_frame_0, 'rx_switch_in'))    
        self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'), (self.inets_idle_0, 'data_in'))    
        self.msg_connect((self.inets_idle_0, 'successful_transmission'), (self.inets_message_tomb_0, 'message_in'))    
        self.msg_connect((self.inets_idle_0, 'data_out'), (self.send_frame_0, 'in'))    
        self.msg_connect((self.inets_null_message_source_0, 'null_message_out'), (self.inets_idle_0, 'reset_idle'))    
        self.msg_connect((self.receive_frame_0, 'rx_frame_info_out'), (self.blocks_message_debug_0_0, 'print'))    
        self.msg_connect((self.send_frame_0, 'tx_frame_info_out'), (self.inets_message_tomb_0, 'message_in'))    
        self.connect((self.send_frame_0, 0), (self.blocks_null_sink_0, 0))    
        self.connect((self.send_frame_0, 0), (self.receive_frame_0, 0))    
예제 #4
0
    def __init__(self):
        gr.top_block.__init__(self, "Test_idle_sendframe")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Test_idle_sendframe")
        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", "Test_idle_sendframe")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.source_address = source_address = 1
        self.self_data_info = self_data_info = pmt.to_pmt({
            'frame_type':
            1,
            'frame_index':
            1,
            'destination_address':
            2,
            'source_address':
            1,
            'num_resend':
            3,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            200
        })
        self.self_ack_info = self_ack_info = pmt.to_pmt({
            'frame_type': 2,
            'frame_index': 1,
            'destination_address': 2,
            'source_address': 1,
            'num_resend': 0,
            'reserved_field_I': 1,
            'reserved_field_II': 1,
            'pay_load_length': 0
        })
        self.samp_rate = samp_rate = 1000000
        self.reserved_field_II = reserved_field_II = 6
        self.reserved_field_I = reserved_field_I = 5
        self.max_num_retransmission = max_num_retransmission = 5
        self.max_buffer_size = max_buffer_size = 10
        self.len_source_address = len_source_address = 1
        self.len_reserved_field_II = len_reserved_field_II = 2
        self.len_reserved_field_I = len_reserved_field_I = 2
        self.len_payload_length = len_payload_length = 1
        self.len_num_transmission = len_num_transmission = 1
        self.len_frame_type = len_frame_type = 1
        self.len_frame_index = len_frame_index = 1
        self.len_destination_address = len_destination_address = 1
        self.increase_index = increase_index = 0
        self.frame_type = frame_type = 1
        self.frame_index = frame_index = 1
        self.experiment_duration_s = experiment_duration_s = 1000
        self.develop_mode_list = develop_mode_list = [0]
        self.destination_address = destination_address = 3
        self.counter_id = counter_id = 20
        self.another_data_info = another_data_info = pmt.to_pmt({
            'frame_type':
            1,
            'frame_index':
            1,
            'destination_address':
            1,
            'source_address':
            2,
            'num_resend':
            3,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            200
        })
        self.another_ack_info = another_ack_info = pmt.to_pmt({
            'frame_type':
            2,
            'frame_index':
            1,
            'destination_address':
            1,
            'source_address':
            2,
            'num_resend':
            0,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            0
        })

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_sink_0_0 = uhd.usrp_sink(
            ",".join(("addr=10.0.0.13", "")),
            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(4e8, 0)
        self.uhd_usrp_sink_0_0.set_gain(0, 0)
        self.send_frame_0 = send_frame(
            block_id=2,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            destination_address=3,
            develop_mode=1,
            frame_index=2,
            frame_type=1,
            increase_index=1,
            len_destination_address=1,
            len_frame_index=1,
            len_frame_type=1,
            len_payload_length=1,
            len_reserved_field_I=2,
            len_reserved_field_II=2,
            len_source_address=1,
            preamble=[],
            reserved_field_I=5,
            reserved_field_II=6,
            samp_rate=4e6,
            source_address=4,
            sps=4,
            system_time_granularity_us=10,
        )
        self.inets_message_tomb_0 = inets.message_tomb()
        self.inets_idle_0 = inets.idle(
            2, 1, experiment_duration_s, max_num_retransmission,
            max_buffer_size, frame_type, len_frame_type, frame_index,
            len_frame_index, destination_address, len_destination_address,
            source_address, len_source_address, reserved_field_I,
            len_reserved_field_I, reserved_field_II, len_reserved_field_II,
            len_payload_length, increase_index, len_num_transmission)
        self.frame_info_simulator = blocks.message_strobe_random(
            another_ack_info, blocks.STROBE_POISSON, 4000, 2000)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", "localhost",
                                                     "52001", 10000, False)
        self.blocks_message_strobe_random_0_0_0 = blocks.message_strobe_random(
            pmt.from_bool(True), blocks.STROBE_POISSON, 2000, 0)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_random_0_0_0, 'strobe'),
                         (self.inets_idle_0, 'reset_idle'))
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'),
                         (self.inets_idle_0, 'data_in'))
        self.msg_connect((self.inets_idle_0, 'successful_transmission'),
                         (self.inets_message_tomb_0, 'message_in'))
        self.msg_connect((self.inets_idle_0, 'data_out'),
                         (self.send_frame_0, 'in'))
        self.connect((self.send_frame_0, 0), (self.uhd_usrp_sink_0_0, 0))
예제 #5
0
    def __init__(self):
        gr.top_block.__init__(self, "Test_idle")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Test_idle")
        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", "Test_idle")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.source_address = source_address = 1
        self.self_data_info = self_data_info = pmt.to_pmt({
            'frame_type':
            1,
            'frame_index':
            1,
            'destination_address':
            2,
            'source_address':
            1,
            'num_resend':
            3,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            200
        })
        self.samp_rate = samp_rate = 320000
        self.reserved_field_II = reserved_field_II = 6
        self.reserved_field_I = reserved_field_I = 5
        self.max_num_retransmission = max_num_retransmission = 5
        self.max_buffer_size = max_buffer_size = 10
        self.len_source_address = len_source_address = 1
        self.len_reserved_field_II = len_reserved_field_II = 2
        self.len_reserved_field_I = len_reserved_field_I = 2
        self.len_payload_length = len_payload_length = 1
        self.len_num_transmission = len_num_transmission = 1
        self.len_frame_type = len_frame_type = 1
        self.len_frame_index = len_frame_index = 1
        self.len_destination_address = len_destination_address = 1
        self.increase_index = increase_index = 1
        self.frame_type = frame_type = 1
        self.frame_index = frame_index = 0
        self.experiment_duration_s = experiment_duration_s = 1000
        self.develop_mode = develop_mode = 2
        self.destination_address = destination_address = 3
        self.another_data_info = another_data_info = pmt.to_pmt({
            'frame_type':
            1,
            'frame_index':
            1,
            'destination_address':
            1,
            'source_address':
            2,
            'num_resend':
            3,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            200
        })
        self.another_ack_info = another_ack_info = pmt.to_pmt({
            'frame_type':
            2,
            'frame_index':
            1,
            'destination_address':
            1,
            'source_address':
            2,
            'num_resend':
            0,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            0
        })

        ##################################################
        # Blocks
        ##################################################
        self.inets_null_message_source_0 = inets.null_message_source()
        self.inets_message_tomb_0 = inets.message_tomb()
        self.inets_idle_0 = inets.idle(
            2, 1, experiment_duration_s, max_num_retransmission,
            max_buffer_size, frame_type, len_frame_type, frame_index,
            len_frame_index, destination_address, len_destination_address,
            source_address, len_source_address, reserved_field_I,
            len_reserved_field_I, reserved_field_II, len_reserved_field_II,
            len_payload_length, increase_index, len_num_transmission)
        self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_SERVER", 'localhost',
                                                     '52001', 10000, False)
        self.blocks_message_strobe_random_0_0_0 = blocks.message_strobe_random(
            pmt.from_bool(True), blocks.STROBE_POISSON, 2000, 0)
        self.blocks_message_strobe_random_0_0 = blocks.message_strobe_random(
            another_ack_info, blocks.STROBE_POISSON, 2000, 0)
        self.blocks_message_debug_0 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_socket_pdu_0, 'pdus'),
                         (self.inets_idle_0, 'data_in'))
        self.msg_connect((self.inets_idle_0, 'data_out'),
                         (self.blocks_message_debug_0, 'print'))
        self.msg_connect((self.inets_idle_0, 'successful_transmission'),
                         (self.inets_message_tomb_0, 'message_in'))
        self.msg_connect(
            (self.inets_null_message_source_0, 'null_message_out'),
            (self.inets_idle_0, 'reset_idle'))
예제 #6
0
    def __init__(self):
        gr.top_block.__init__(self, "Test_receive_ack")
        Qt.QWidget.__init__(self)
        self.setWindowTitle("Test_receive_ack")
        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", "Test_receive_ack")
        self.restoreGeometry(self.settings.value("geometry").toByteArray())

        ##################################################
        # Variables
        ##################################################
        self.sps = sps = 4
        self.range_rx_gain = range_rx_gain = 25
        self.range_mu = range_mu = 0.6
        self.system_time_granularity_us = system_time_granularity_us = 1000
        self.source_address = source_address = 1
        self.self_data_info = self_data_info = pmt.to_pmt({
            'frame_type':
            1,
            'frame_index':
            1,
            'destination_address':
            2,
            'source_address':
            1,
            'num_resend':
            3,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            200
        })
        self.self_ack_info = self_ack_info = pmt.to_pmt({
            'frame_type': 2,
            'frame_index': 1,
            'destination_address': 2,
            'source_address': 1,
            'num_resend': 0,
            'reserved_field_I': 1,
            'reserved_field_II': 1,
            'pay_load_length': 0
        })
        self.samp_rate = samp_rate = 4000000
        self.rx_gain = rx_gain = range_rx_gain

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

        self.reserved_field_II = reserved_field_II = 6
        self.reserved_field_I = reserved_field_I = 5
        self.preamble_detector_threshold = preamble_detector_threshold = 30
        self.mu = mu = range_mu
        self.max_num_retransmission = max_num_retransmission = 5
        self.max_buffer_size = max_buffer_size = 10
        self.len_source_address = len_source_address = 1
        self.len_reserved_field_II = len_reserved_field_II = 2
        self.len_reserved_field_I = len_reserved_field_I = 2
        self.len_payload_length = len_payload_length = 1
        self.len_num_transmission = len_num_transmission = 1
        self.len_frame_type = len_frame_type = 1
        self.len_frame_index = len_frame_index = 1
        self.len_destination_address = len_destination_address = 1
        self.increase_index = increase_index = 1
        self.frame_type = frame_type = 1
        self.frame_index = frame_index = 1
        self.experiment_duration_s = experiment_duration_s = 1000
        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.develop_mode_list = develop_mode_list = [20, 21, 22]
        self.destination_address = destination_address = 3
        self.counter_id = counter_id = 20
        self.apply_address_check = apply_address_check = 1
        self.another_data_info = another_data_info = pmt.to_pmt({
            'frame_type':
            1,
            'frame_index':
            2,
            'destination_address':
            1,
            'source_address':
            3,
            'num_transmission':
            3,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            200,
            'header_length':
            9,
            'address_check':
            1,
            'good_frame':
            1
        })
        self.another_ack_info = another_ack_info = pmt.to_pmt({
            'frame_type':
            2,
            'frame_index':
            1,
            'destination_address':
            1,
            'source_address':
            2,
            'num_resend':
            0,
            'reserved_field_I':
            1,
            'reserved_field_II':
            1,
            'pay_load_length':
            0
        })

        ##################################################
        # Blocks
        ##################################################
        self.send_frame_0 = send_frame(
            constellation=gnuradio.digital.constellation_qpsk().base(),
            destination_address=destination_address,
            develop_mode_list=develop_mode_list,
            frame_index=frame_index,
            frame_type=frame_type,
            increase_index=increase_index,
            len_destination_address=len_destination_address,
            len_frame_index=len_frame_index,
            len_frame_type=len_frame_type,
            len_payload_length=len_payload_length,
            len_reserved_field_I=len_reserved_field_I,
            len_reserved_field_II=len_reserved_field_II,
            len_source_address=len_source_address,
            preamble=diff_preamble_128,
            reserved_field_I=reserved_field_I,
            reserved_field_II=reserved_field_II,
            samp_rate=samp_rate,
            source_address=source_address,
            sps=sps,
            system_time_granularity_us=system_time_granularity_us,
        )
        self.receive_frame_0 = receive_frame(
            apply_address_check=apply_address_check,
            constellation=gnuradio.digital.constellation_qpsk().base(),
            develop_mode_list=develop_mode_list,
            len_destination_address=len_destination_address,
            len_frame_index=len_frame_index,
            len_frame_type=len_frame_type,
            len_num_transmission=len_num_transmission,
            len_payload_length=len_payload_length,
            len_reserved_field_I=len_reserved_field_I,
            len_reserved_field_II=len_reserved_field_II,
            len_source_address=len_source_address,
            matched_filter_coeff=rrc,
            mu=mu,
            my_address=destination_address,
            preamble=diff_preamble_128,
            rx_gain=rx_gain,
            samp_rate=samp_rate,
            sps=sps,
            threshold=preamble_detector_threshold,
        )
        self._range_rx_gain_range = Range(0, 60, 1, 25, 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_idle_0 = inets.idle(
            (develop_mode_list), experiment_duration_s, max_num_retransmission,
            max_buffer_size, frame_type, len_frame_type, frame_index,
            len_frame_index, destination_address, len_destination_address,
            source_address, len_source_address, reserved_field_I,
            len_reserved_field_I, reserved_field_II, len_reserved_field_II,
            len_payload_length, increase_index, len_num_transmission)
        self.inets_counter_0 = inets.counter((develop_mode_list), 20)
        self.frame_info_simulator = blocks.message_strobe_random(
            another_data_info, blocks.STROBE_POISSON, 4000, 2000)
        self.blocks_message_strobe_random_1 = blocks.message_strobe_random(
            pmt.from_bool(True), blocks.STROBE_POISSON, 50, 5)
        self.blocks_message_debug_1 = blocks.message_debug()

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.blocks_message_strobe_random_1, 'strobe'),
                         (self.inets_idle_0, 'reset_idle'))
        self.msg_connect((self.frame_info_simulator, 'strobe'),
                         (self.inets_idle_0, 'data_in'))
        self.msg_connect((self.inets_idle_0, 'data_out'),
                         (self.inets_counter_0, 'message_in'))
        self.msg_connect((self.inets_idle_0, 'data_out'),
                         (self.send_frame_0, 'in'))
        self.msg_connect((self.receive_frame_0, 'rx_frame_info_out'),
                         (self.blocks_message_debug_1, 'print'))
        self.connect((self.send_frame_0, 0), (self.receive_frame_0, 0))