Пример #1
0
    def __init__(self, fc=936.6e6, ppm=0, samp_rate_in=1625000.0/6.0*4.0):
        grgsm.hier_block.__init__(
            self, "Clock offset corrector",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
        )
        self.message_port_register_hier_in("ppm_in")
        
        ##################################################
        # Parameters
        ##################################################
        self.fc = fc
        self.ppm = ppm
        self.samp_rate_in = samp_rate_in

        ##################################################
        # Variables
        ##################################################
        self.samp_rate_out = samp_rate_out = samp_rate_in

        ##################################################
        # Blocks
        ##################################################
        self.gsm_controlled_rotator_cc_0 = grgsm.controlled_rotator_cc(0,samp_rate_out)
        self.gsm_controlled_const_source_f_0 = grgsm.controlled_const_source_f(ppm)
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((fc/samp_rate_out*(2*math.pi)/1e6, ))

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self, 'ppm_in'), (self.gsm_controlled_const_source_f_0, 'constant_msg'))    
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.gsm_controlled_rotator_cc_0, 1))    
        self.connect((self.gsm_controlled_const_source_f_0, 0), (self.blocks_multiply_const_vxx_0, 0))    
        self.connect((self.gsm_controlled_rotator_cc_0, 0), (self, 0))    
        self.connect((self, 0), (self.gsm_controlled_rotator_cc_0, 0))    
    def __init__(self, fc=936.6e6, ppm=0, samp_rate_in=1625000.0/6.0*4.0):
        gr.hier_block2.__init__(
            self, "Clock offset corrector",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
        )
        if version(gr.version()) >= version('3.7.9'):
            self.message_port_register_hier_in("ppm_in")
        else:
            self.message_port_register_hier_out("ppm_in")

        ##################################################
        # Parameters
        ##################################################
        self.fc = fc
        self.ppm = ppm
        self.samp_rate_in = samp_rate_in

        ##################################################
        # Variables
        ##################################################
        self.samp_rate_out = samp_rate_out = samp_rate_in

        ##################################################
        # Blocks
        ##################################################
        self.gsm_controlled_rotator_cc_0 = grgsm.controlled_rotator_cc(0,samp_rate_out)
        self.gsm_controlled_const_source_f_0 = grgsm.controlled_const_source_f(ppm)
        self.fractional_resampler_xx_0 = filter.fractional_resampler_cc(0, samp_rate_in/samp_rate_out)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((1.0e-6*samp_rate_in/samp_rate_out, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((fc/samp_rate_out*(2*math.pi)/1e6, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((samp_rate_in/samp_rate_out, ))

        ##################################################
        # Connections
        ##################################################
        self.connect((self, 0), (self.fractional_resampler_xx_0, 0))
        self.connect((self.fractional_resampler_xx_0, 0), (self.gsm_controlled_rotator_cc_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.fractional_resampler_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.gsm_controlled_rotator_cc_0, 1))
        self.connect((self.gsm_controlled_rotator_cc_0, 0), (self, 0))
        self.connect((self.gsm_controlled_const_source_f_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.gsm_controlled_const_source_f_0, 0), (self.blocks_multiply_const_vxx_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self, "ppm_in", self.gsm_controlled_const_source_f_0, "constant_msg")
    def __init__(self,
                 fc=936.6e6,
                 osr=4,
                 ppm=0,
                 samp_rate_in=1625000.0 / 6.0 * 4.0):
        gr.hier_block2.__init__(
            self,
            "Clock Offset Corrector Tagged",
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex * 1),
        )
        self.message_port_register_hier_in("ctrl")

        ##################################################
        # Parameters
        ##################################################
        self.fc = fc
        self.osr = osr
        self.ppm = ppm
        self.samp_rate_in = samp_rate_in

        ##################################################
        # Variables
        ##################################################
        self.gsm_symb_rate = gsm_symb_rate = 1625000.0 / 6.0
        self.samp_rate_out = samp_rate_out = osr * gsm_symb_rate

        ##################################################
        # Blocks
        ##################################################
        self.gsm_msg_to_tag_0 = grgsm.msg_to_tag()
        self.gsm_controlled_rotator_cc_0 = grgsm.controlled_rotator_cc(
            ppm / 1.0e6 * 2 * math.pi * fc / samp_rate_out)
        self.gsm_controlled_fractional_resampler_cc_0 = grgsm.controlled_fractional_resampler_cc(
            0, samp_rate_in / samp_rate_out)

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self, 'ctrl'), (self.gsm_msg_to_tag_0, 'msg'))
        self.connect((self.gsm_controlled_fractional_resampler_cc_0, 0),
                     (self.gsm_controlled_rotator_cc_0, 0))
        self.connect((self.gsm_controlled_rotator_cc_0, 0), (self, 0))
        self.connect((self.gsm_msg_to_tag_0, 0),
                     (self.gsm_controlled_fractional_resampler_cc_0, 0))
        self.connect((self, 0), (self.gsm_msg_to_tag_0, 0))
Пример #4
0
    def __init__(self, fc=936.6e6, ppm=0, samp_rate_in=1625000.0/6.0*4.0):
        grgsm.hier_block.__init__(
            self, "Clock offset corrector",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
        )
        self.message_port_register_hier_in("ppm_in")
        
        ##################################################
        # Parameters
        ##################################################
        self.fc = fc
        self.ppm = ppm
        self.samp_rate_in = samp_rate_in

        ##################################################
        # Variables
        ##################################################
        self.samp_rate_out = samp_rate_out = samp_rate_in

        ##################################################
        # Blocks
        ##################################################
        self.gsm_controlled_rotator_cc_0 = grgsm.controlled_rotator_cc(0,samp_rate_out)
        self.gsm_controlled_const_source_f_0 = grgsm.controlled_const_source_f(ppm)
        self.fractional_resampler_xx_0 = filter.fractional_resampler_cc(0, samp_rate_in/samp_rate_out)
        self.blocks_multiply_const_vxx_0_0 = blocks.multiply_const_vff((1.0e-6*samp_rate_in/samp_rate_out, ))
        self.blocks_multiply_const_vxx_0 = blocks.multiply_const_vff((fc/samp_rate_out*(2*math.pi)/1e6, ))
        self.blocks_add_const_vxx_0 = blocks.add_const_vff((samp_rate_in/samp_rate_out, ))

        ##################################################
        # Connections
        ##################################################
        self.connect((self, 0), (self.fractional_resampler_xx_0, 0))
        self.connect((self.fractional_resampler_xx_0, 0), (self.gsm_controlled_rotator_cc_0, 0))
        self.connect((self.blocks_add_const_vxx_0, 0), (self.fractional_resampler_xx_0, 1))
        self.connect((self.blocks_multiply_const_vxx_0_0, 0), (self.blocks_add_const_vxx_0, 0))
        self.connect((self.blocks_multiply_const_vxx_0, 0), (self.gsm_controlled_rotator_cc_0, 1))
        self.connect((self.gsm_controlled_rotator_cc_0, 0), (self, 0))
        self.connect((self.gsm_controlled_const_source_f_0, 0), (self.blocks_multiply_const_vxx_0_0, 0))
        self.connect((self.gsm_controlled_const_source_f_0, 0), (self.blocks_multiply_const_vxx_0, 0))

        ##################################################
        # Asynch Message Connections
        ##################################################
        self.msg_connect(self, "ppm_in", self.gsm_controlled_const_source_f_0, "constant_msg")
    def __init__(self, fc=936.6e6, osr=4, ppm=0, samp_rate_in=1625000.0/6.0*4.0):
        gr.hier_block2.__init__(
            self, "Clock Offset Corrector Tagged",
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
            gr.io_signature(1, 1, gr.sizeof_gr_complex*1),
        )
        self.message_port_register_hier_in("ctrl")

        ##################################################
        # Parameters
        ##################################################
        self.fc = fc
        self.osr = osr
        self.ppm = ppm
        self.samp_rate_in = samp_rate_in

        ##################################################
        # Variables
        ##################################################
        self.gsm_symb_rate = gsm_symb_rate = 1625000.0/6.0
        self.samp_rate_out = samp_rate_out = osr*gsm_symb_rate

        ##################################################
        # Blocks
        ##################################################
        self.gsm_msg_to_tag_0 = grgsm.msg_to_tag()
        self.gsm_controlled_rotator_cc_0 = grgsm.controlled_rotator_cc(ppm/1.0e6*2*math.pi*fc/samp_rate_out)
        self.gsm_controlled_fractional_resampler_cc_0 = grgsm.controlled_fractional_resampler_cc(0, (1-ppm/1.0e6)*(samp_rate_in/samp_rate_out))

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self, 'ctrl'), (self.gsm_msg_to_tag_0, 'msg'))    
        self.connect((self.gsm_controlled_fractional_resampler_cc_0, 0), (self.gsm_controlled_rotator_cc_0, 0))    
        self.connect((self.gsm_controlled_rotator_cc_0, 0), (self, 0))    
        self.connect((self.gsm_msg_to_tag_0, 0), (self.gsm_controlled_fractional_resampler_cc_0, 0))    
        self.connect((self, 0), (self.gsm_msg_to_tag_0, 0))    
Пример #6
0
    def __init__(self, phy_args, phy_sample_rate, phy_rx_gain, phy_tx_gain,
                 phy_ppm, phy_rx_antenna, phy_tx_antenna, phy_freq_offset,
                 trx_bind_addr, trx_remote_addr, trx_base_port):

        print("[i] Init Radio interface (L:%s:%u <-> R:%s:%u)" %
              (trx_bind_addr, trx_base_port + 2, trx_remote_addr,
               trx_base_port + 102))

        # PHY specific variables
        self.sample_rate = phy_sample_rate
        self.rx_gain = phy_rx_gain
        self.tx_gain = phy_tx_gain
        self.ppm = phy_ppm
        self.freq_offset = phy_freq_offset

        gr.top_block.__init__(self, "GR-GSM TRX")

        # TRX Burst Interface
        self.trx_burst_if = grgsm.trx_burst_if(trx_bind_addr, trx_remote_addr,
                                               str(trx_base_port))

        # RX path definition
        self.phy_src = uhd.usrp_source(
            phy_args, uhd.stream_args(cpu_format="fc32", channels=range(1)))

        self.phy_src.set_clock_rate(26e6, uhd.ALL_MBOARDS)
        self.phy_src.set_center_freq(self.rx_freq, 0)
        self.phy_src.set_antenna(phy_rx_antenna, 0)
        self.phy_src.set_samp_rate(phy_sample_rate)
        self.phy_src.set_bandwidth(650e3, 0)
        self.phy_src.set_gain(phy_rx_gain)

        self.msg_to_tag_src = grgsm.msg_to_tag()

        self.rotator_src = grgsm.controlled_rotator_cc(
            self.calc_phase_inc(self.rx_freq))

        self.lpf = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, phy_sample_rate, 125e3, 5e3, firdes.WIN_HAMMING,
                            6.76))

        self.gsm_receiver = grgsm.receiver(self.osr, ([0]), ([]))

        self.ts_filter = grgsm.burst_timeslot_filter(0)
        self.ts_filter.set_policy(grgsm.FILTER_POLICY_DROP_ALL)

        # Connections
        self.connect((self.phy_src, 0), (self.msg_to_tag_src, 0))

        self.connect((self.msg_to_tag_src, 0), (self.rotator_src, 0))

        self.connect((self.rotator_src, 0), (self.lpf, 0))

        self.connect((self.lpf, 0), (self.gsm_receiver, 0))

        self.msg_connect((self.gsm_receiver, 'C0'), (self.ts_filter, 'in'))

        self.msg_connect((self.ts_filter, 'out'),
                         (self.trx_burst_if, 'bursts'))

        # TX Path Definition
        self.phy_sink = uhd.usrp_sink(
            phy_args, uhd.stream_args(cpu_format="fc32", channels=range(1)),
            "packet_len")

        self.phy_sink.set_clock_rate(26e6, uhd.ALL_MBOARDS)
        self.phy_sink.set_antenna(phy_tx_antenna, 0)
        self.phy_sink.set_samp_rate(phy_sample_rate)
        self.phy_sink.set_center_freq(self.tx_freq, 0)
        self.phy_sink.set_gain(self.tx_gain)

        self.tx_time_setter = grgsm.txtime_setter(
            0xffffffff, 0, 0, 0, 0, 0,
            self.delay_correction + self.GSM_UL_DL_SHIFT_uS * 1e-6)

        self.tx_burst_proc = grgsm.preprocess_tx_burst()

        self.pdu_to_tagged_stream = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')

        self.gmsk_mod = grgsm.gsm_gmsk_mod(BT=0.3,
                                           pulse_duration=4,
                                           sps=self.osr)

        self.burst_shaper = digital.burst_shaper_cc(
            (firdes.window(firdes.WIN_HANN, 16, 0)), 0, 20, False,
            "packet_len")

        self.msg_to_tag_sink = grgsm.msg_to_tag()

        self.rotator_sink = grgsm.controlled_rotator_cc(
            -self.calc_phase_inc(self.tx_freq))

        # Connections
        self.msg_connect((self.trx_burst_if, 'bursts'),
                         (self.tx_time_setter, 'bursts_in'))

        self.msg_connect((self.tx_time_setter, 'bursts_out'),
                         (self.tx_burst_proc, 'bursts_in'))

        self.msg_connect((self.tx_burst_proc, 'bursts_out'),
                         (self.pdu_to_tagged_stream, 'pdus'))

        self.connect((self.pdu_to_tagged_stream, 0), (self.gmsk_mod, 0))

        self.connect((self.gmsk_mod, 0), (self.burst_shaper, 0))

        self.connect((self.burst_shaper, 0), (self.msg_to_tag_sink, 0))

        self.connect((self.msg_to_tag_sink, 0), (self.rotator_sink, 0))

        self.connect((self.rotator_sink, 0), (self.phy_sink, 0))

        # RX & TX synchronization
        self.bt_filter = grgsm.burst_type_filter([3])
        self.burst_to_fn_time = grgsm.burst_to_fn_time()

        # Connections
        self.msg_connect((self.gsm_receiver, 'C0'),
                         (self.bt_filter, 'bursts_in'))

        self.msg_connect((self.bt_filter, 'bursts_out'),
                         (self.burst_to_fn_time, 'bursts_in'))

        self.msg_connect((self.burst_to_fn_time, 'fn_time_out'),
                         (self.tx_time_setter, 'fn_time'))

        # AFC (Automatic Frequency Correction)
        self.gsm_clck_ctrl = grgsm.clock_offset_control(self.rx_freq,
                                                        phy_sample_rate,
                                                        osr=self.osr)

        self.dict_toggle_sign = dict_toggle_sign()

        # Connections
        self.msg_connect((self.gsm_receiver, 'measurements'),
                         (self.gsm_clck_ctrl, 'measurements'))

        self.msg_connect((self.gsm_clck_ctrl, 'ctrl'),
                         (self.msg_to_tag_src, 'msg'))

        self.msg_connect((self.gsm_clck_ctrl, 'ctrl'),
                         (self.dict_toggle_sign, 'dict_in'))

        self.msg_connect((self.dict_toggle_sign, 'dict_out'),
                         (self.msg_to_tag_sink, 'msg'))

        # Some UHD devices (such as UmTRX) do start the clock
        # not from 0, so it's required to reset it manually.
        # Resetting UHD source will also affect the sink.
        self.phy_src.set_time_now(uhd.time_spec(0.0))
Пример #7
0
    def __init__(self,
                 delay_correction=285.616e-6,
                 osr=4,
                 ppm=-0.799427,
                 rx_freq=935e6 + 36 * 0.2e6,
                 rx_gain=40,
                 samp_rate=13e6 / 12.0,
                 timing_advance=0,
                 trx_base_port="5710",
                 trx_remote_addr="127.0.0.1",
                 tx_freq=935e6 + 36 * 0.2e6 - 45e6,
                 tx_gain=40,
                 uplink_shift=-(6.0 / 1625000 * (156.25) * 3)):
        gr.top_block.__init__(self, "Trx radio interface")

        ##################################################
        # Parameters
        ##################################################
        self.delay_correction = delay_correction
        self.osr = osr
        self.ppm = ppm
        self.rx_freq = rx_freq
        self.rx_gain = rx_gain
        self.samp_rate = samp_rate
        self.timing_advance = timing_advance
        self.trx_base_port = trx_base_port
        self.trx_remote_addr = trx_remote_addr
        self.tx_freq = tx_freq
        self.tx_gain = tx_gain
        self.uplink_shift = uplink_shift

        ##################################################
        # Blocks
        ##################################################
        self.uhd_usrp_source_0 = uhd.usrp_source(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
        )
        self.uhd_usrp_source_0.set_clock_rate(26e6, uhd.ALL_MBOARDS)
        self.uhd_usrp_source_0.set_samp_rate(samp_rate)
        self.uhd_usrp_source_0.set_center_freq(rx_freq, 0)
        self.uhd_usrp_source_0.set_gain(rx_gain, 0)
        self.uhd_usrp_source_0.set_antenna("RX2", 0)
        self.uhd_usrp_sink_0 = uhd.usrp_sink(
            ",".join(("", "")),
            uhd.stream_args(
                cpu_format="fc32",
                channels=range(1),
            ),
            "packet_len",
        )
        self.uhd_usrp_sink_0.set_clock_rate(26e6, uhd.ALL_MBOARDS)
        self.uhd_usrp_sink_0.set_subdev_spec("A:B", 0)
        self.uhd_usrp_sink_0.set_samp_rate(samp_rate)
        self.uhd_usrp_sink_0.set_center_freq(tx_freq, 0)
        self.uhd_usrp_sink_0.set_gain(tx_gain, 0)
        self.uhd_usrp_sink_0.set_antenna("TX/RX", 0)
        self.ts_filter = grgsm.burst_timeslot_filter(0)
        self.low_pass_filter_0_0 = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, samp_rate, 125e3, 5e3, firdes.WIN_HAMMING,
                            6.76))
        self.gsm_txtime_setter_0 = grgsm.txtime_setter(
            None if (None is not None) else 0xffffffff, 0, 0, 0, 0,
            timing_advance, delay_correction + uplink_shift)
        self.gsm_trx_burst_if_0 = grgsm.trx_burst_if(trx_remote_addr,
                                                     trx_base_port)
        self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([4]), False)
        self.gsm_preprocess_tx_burst_0 = grgsm.preprocess_tx_burst()
        self.gsm_msg_to_tag_0_0 = grgsm.msg_to_tag()
        self.gsm_msg_to_tag_0 = grgsm.msg_to_tag()
        self.gsm_gmsk_mod_0 = gsm_gmsk_mod(
            BT=0.3,
            pulse_duration=4,
            sps=osr,
        )
        self.gsm_controlled_rotator_cc_0_0 = grgsm.controlled_rotator_cc(
            -ppm / 1.0e6 * 2 * math.pi * tx_freq / samp_rate)
        self.gsm_controlled_rotator_cc_0 = grgsm.controlled_rotator_cc(
            ppm / 1.0e6 * 2 * math.pi * rx_freq / samp_rate)
        self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(
            rx_freq, samp_rate, osr)
        self.gsm_burst_type_filter_0 = grgsm.burst_type_filter(([3]))
        self.gsm_burst_to_fn_time_0 = grgsm.burst_to_fn_time()
        self.digital_burst_shaper_xx_0 = digital.burst_shaper_cc(
            (firdes.window(firdes.WIN_HANN, 16, 0)), 0, 20, False,
            "packet_len")
        self.dict_toggle_sign = dict_toggle_sign()
        self.blocks_pdu_to_tagged_stream_0_0 = blocks.pdu_to_tagged_stream(
            blocks.byte_t, "packet_len")

        ##################################################
        # Connections
        ##################################################
        self.msg_connect((self.dict_toggle_sign, 'dict_out'),
                         (self.gsm_msg_to_tag_0_0, 'msg'))
        self.msg_connect((self.gsm_burst_to_fn_time_0, 'fn_time_out'),
                         (self.gsm_txtime_setter_0, 'fn_time'))
        self.msg_connect((self.gsm_burst_type_filter_0, 'bursts_out'),
                         (self.gsm_burst_to_fn_time_0, 'bursts_in'))
        self.msg_connect((self.gsm_clock_offset_control_0, 'ctrl'),
                         (self.dict_toggle_sign, 'dict_in'))
        self.msg_connect((self.gsm_clock_offset_control_0, 'ctrl'),
                         (self.gsm_msg_to_tag_0, 'msg'))
        self.msg_connect((self.gsm_preprocess_tx_burst_0, 'bursts_out'),
                         (self.blocks_pdu_to_tagged_stream_0_0, 'pdus'))
        self.msg_connect((self.gsm_receiver_0, 'C0'),
                         (self.gsm_burst_type_filter_0, 'bursts_in'))
        self.msg_connect((self.gsm_receiver_0, 'measurements'),
                         (self.gsm_clock_offset_control_0, 'measurements'))
        self.msg_connect((self.gsm_receiver_0, 'C0'), (self.ts_filter, 'in'))
        self.msg_connect((self.gsm_trx_burst_if_0, 'bursts'),
                         (self.gsm_txtime_setter_0, 'bursts_in'))
        self.msg_connect((self.gsm_txtime_setter_0, 'bursts_out'),
                         (self.gsm_preprocess_tx_burst_0, 'bursts_in'))
        self.msg_connect((self.ts_filter, 'out'),
                         (self.gsm_trx_burst_if_0, 'bursts'))
        self.connect((self.blocks_pdu_to_tagged_stream_0_0, 0),
                     (self.gsm_gmsk_mod_0, 0))
        self.connect((self.digital_burst_shaper_xx_0, 0),
                     (self.gsm_msg_to_tag_0_0, 0))
        self.connect((self.gsm_controlled_rotator_cc_0, 0),
                     (self.low_pass_filter_0_0, 0))
        self.connect((self.gsm_controlled_rotator_cc_0_0, 0),
                     (self.uhd_usrp_sink_0, 0))
        self.connect((self.gsm_gmsk_mod_0, 0),
                     (self.digital_burst_shaper_xx_0, 0))
        self.connect((self.gsm_msg_to_tag_0, 0),
                     (self.gsm_controlled_rotator_cc_0, 0))
        self.connect((self.gsm_msg_to_tag_0_0, 0),
                     (self.gsm_controlled_rotator_cc_0_0, 0))
        self.connect((self.low_pass_filter_0_0, 0), (self.gsm_receiver_0, 0))
        self.connect((self.uhd_usrp_source_0, 0), (self.gsm_msg_to_tag_0, 0))
Пример #8
0
    def __init__(self, phy_args, phy_sample_rate, phy_rx_gain, phy_tx_gain,
                 phy_ppm, phy_rx_antenna, phy_tx_antenna, phy_freq_offset,
                 trx_bind_addr, trx_remote_addr, trx_base_port):

        print("[i] Init %s Radio interface (L:%s:%u <-> R:%s:%u)" %
              (self, trx_bind_addr, trx_base_port + 2, trx_remote_addr,
               trx_base_port + 102))

        # PHY specific variables
        self.sample_rate = phy_sample_rate
        self.rx_gain = phy_rx_gain
        self.tx_gain = phy_tx_gain
        self.ppm = phy_ppm
        self.freq_offset = phy_freq_offset

        self.phy_args = phy_args
        self.rx_antenna = phy_rx_antenna
        self.tx_antenna = phy_tx_antenna

        gr.top_block.__init__(self, "GR-GSM TRX")

        # TRX Burst Interface
        self.trx_burst_if = grgsm.trx_burst_if(trx_bind_addr, trx_remote_addr,
                                               str(trx_base_port))

        # RX path definition
        self.phy_init_source()

        self.msg_to_tag_src = grgsm.msg_to_tag()

        self.rotator_src = grgsm.controlled_rotator_cc(0.0)

        self.lpf = filter.fir_filter_ccf(
            1,
            firdes.low_pass(1, phy_sample_rate, 125e3, 5e3, firdes.WIN_HAMMING,
                            6.76))

        self.gsm_receiver = grgsm.receiver(self.osr, ([0]), ([]))

        self.ts_filter = grgsm.burst_timeslot_filter(0)
        self.ts_filter.set_policy(grgsm.FILTER_POLICY_DROP_ALL)

        # Connections
        self.connect((self._phy_src, 0), (self.msg_to_tag_src, 0))

        self.connect((self.msg_to_tag_src, 0), (self.rotator_src, 0))

        self.connect((self.rotator_src, 0), (self.lpf, 0))

        self.connect((self.lpf, 0), (self.gsm_receiver, 0))

        self.msg_connect((self.gsm_receiver, 'C0'), (self.ts_filter, 'in'))

        self.msg_connect((self.ts_filter, 'out'),
                         (self.trx_burst_if, 'bursts'))

        # TX Path Definition
        self.phy_init_sink()

        self.tx_time_setter = grgsm.txtime_setter(
            0xffffffff, 0, 0, 0, 0, 0,
            self.phy_proc_delay + self.GSM_UL_DL_SHIFT_uS * 1e-6)

        self.tx_burst_proc = grgsm.preprocess_tx_burst()

        self.pdu_to_tagged_stream = blocks.pdu_to_tagged_stream(
            blocks.byte_t, 'packet_len')

        self.gmsk_mod = grgsm.gsm_gmsk_mod(BT=0.3,
                                           pulse_duration=4,
                                           sps=self.osr)

        self.burst_shaper = digital.burst_shaper_cc(
            (firdes.window(firdes.WIN_HANN, 16, 0)), 0, 20, False,
            "packet_len")

        self.msg_to_tag_sink = grgsm.msg_to_tag()

        self.rotator_sink = grgsm.controlled_rotator_cc(0.0)

        # Connections
        self.msg_connect((self.trx_burst_if, 'bursts'),
                         (self.tx_time_setter, 'bursts_in'))

        self.msg_connect((self.tx_time_setter, 'bursts_out'),
                         (self.tx_burst_proc, 'bursts_in'))

        self.msg_connect((self.tx_burst_proc, 'bursts_out'),
                         (self.pdu_to_tagged_stream, 'pdus'))

        self.connect((self.pdu_to_tagged_stream, 0), (self.gmsk_mod, 0))

        self.connect((self.gmsk_mod, 0), (self.burst_shaper, 0))

        self.connect((self.burst_shaper, 0), (self.msg_to_tag_sink, 0))

        self.connect((self.msg_to_tag_sink, 0), (self.rotator_sink, 0))

        self.connect((self.rotator_sink, 0), (self._phy_sink, 0))

        # RX & TX synchronization
        self.bt_filter = grgsm.burst_type_filter([3])
        self.burst_to_fn_time = grgsm.burst_to_fn_time()

        # Connections
        self.msg_connect((self.gsm_receiver, 'C0'),
                         (self.bt_filter, 'bursts_in'))

        self.msg_connect((self.bt_filter, 'bursts_out'),
                         (self.burst_to_fn_time, 'bursts_in'))

        self.msg_connect((self.burst_to_fn_time, 'fn_time_out'),
                         (self.tx_time_setter, 'fn_time'))

        # AFC (Automatic Frequency Correction)
        # NOTE: dummy frequency is used during init
        self.gsm_clck_ctrl = grgsm.clock_offset_control(self.DUMMY_FREQ,
                                                        phy_sample_rate,
                                                        osr=self.osr)

        self.dict_toggle_sign = dict_toggle_sign()

        # Connections
        self.msg_connect((self.gsm_receiver, 'measurements'),
                         (self.gsm_clck_ctrl, 'measurements'))

        self.msg_connect((self.gsm_clck_ctrl, 'ctrl'),
                         (self.msg_to_tag_src, 'msg'))

        self.msg_connect((self.gsm_clck_ctrl, 'ctrl'),
                         (self.dict_toggle_sign, 'dict_in'))

        self.msg_connect((self.dict_toggle_sign, 'dict_out'),
                         (self.msg_to_tag_sink, 'msg'))