def __init__(self, source, destination, framenr_ge=None, framenr_le=None, timeslot=None, subslot=None,
                 filter_dummy_bursts=False):
        gr.top_block.__init__(self, "Top Block")

        self.burst_file_source = grgsm.burst_file_source(source)
        self.burst_file_sink = grgsm.burst_file_sink(destination)

        lastblock = self.burst_file_source

        if framenr_ge is not None:
            self.burst_fnr_filterge = grgsm.burst_fnr_filter(grgsm.FILTER_GREATER_OR_EQUAL, framenr_ge)
            self.msg_connect((lastblock, 'out'), (self.burst_fnr_filterge, 'in'))
            lastblock = self.burst_fnr_filterge

        if framenr_le is not None:
            self.burst_fnr_filterle = grgsm.burst_fnr_filter(grgsm.FILTER_LESS_OR_EQUAL, framenr_le)
            self.msg_connect((lastblock, 'out'), (self.burst_fnr_filterle, 'in'))
            lastblock = self.burst_fnr_filterle

        if timeslot is not None:
            self.burst_timeslot_filter = grgsm.burst_timeslot_filter(timeslot)
            self.msg_connect((lastblock, 'out'), (self.burst_timeslot_filter, 'in'))
            lastblock = self.burst_timeslot_filter

        if subslot is not None:
            self.burst_sdcch_subslot_filter = grgsm.burst_sdcch_subslot_filter(grgsm.SS_FILTER_SDCCH8, subslot)
            self.msg_connect((lastblock, 'out'), (self.burst_sdcch_subslot_filter, 'in'))
            lastblock = self.burst_sdcch_subslot_filter

        if filter_dummy_bursts:
            self.dummy_burst_filter = grgsm.dummy_burst_filter()
            self.msg_connect((lastblock, 'out'), (self.dummy_burst_filter, 'in'))
            lastblock = self.dummy_burst_filter

        self.msg_connect((lastblock, 'out'), (self.burst_file_sink, 'in'))
    def __init__(self, burst_file, timeslot, mode, framenumber):
        gr.top_block.__init__(self, "Top Block")

        self.burst_file_source = grgsm.burst_file_source(burst_file)
        self.timeslot_filter = grgsm.burst_timeslot_filter(timeslot)
        self.fnr_filter_start = grgsm.burst_fnr_filter(
            grgsm.FILTER_GREATER_OR_EQUAL, framenumber)
        if mode == 'BCCH_SDCCH4':
            self.demapper = grgsm.gsm_bcch_ccch_sdcch4_demapper(
                timeslot_nr=timeslot, )
        else:
            self.demapper = grgsm.gsm_sdcch8_demapper(timeslot_nr=timeslot, )

        self.decoder = grgsm.control_channels_decoder()

        self.extract_immediate_assignment = grgsm.extract_immediate_assignment(
        )

        self.msg_connect((self.burst_file_source, 'out'),
                         (self.timeslot_filter, 'in'))
        self.msg_connect((self.timeslot_filter, 'out'),
                         (self.fnr_filter_start, 'in'))
        self.msg_connect((self.fnr_filter_start, 'out'),
                         (self.demapper, 'bursts'))
        self.msg_connect((self.demapper, 'bursts'), (self.decoder, 'bursts'))
        self.msg_connect((self.decoder, 'msgs'),
                         (self.extract_immediate_assignment, 'msgs'))
    def __init__(self, burst_file, timeslot, subchannel, mode, fnr_start):
        gr.top_block.__init__(self, "Top Block")

        self.burst_file_source = grgsm.burst_file_source(burst_file)
        self.timeslot_filter = grgsm.burst_timeslot_filter(timeslot)
        self.fnr_filter_start = grgsm.burst_fnr_filter(grgsm.FILTER_GREATER_OR_EQUAL, fnr_start)
        # we only listen for a timespan of 12 SDCCH messages for the CMC
        self.fnr_filter_end = grgsm.burst_fnr_filter(grgsm.FILTER_LESS_OR_EQUAL, fnr_start + 51 * 10000)

        if mode == "BCCH_SDCCH4":
            self.subchannel_filter = grgsm.burst_sdcch_subslot_filter(grgsm.SS_FILTER_SDCCH4, subchannel)
            self.demapper = grgsm.gsm_bcch_ccch_sdcch4_demapper(timeslot_nr=timeslot, )
        else:
            self.subchannel_filter = grgsm.burst_sdcch_subslot_filter(grgsm.SS_FILTER_SDCCH8, subchannel)
            self.demapper = grgsm.gsm_sdcch8_demapper(timeslot_nr=timeslot, )

        self.demapper = grgsm.gsm_sdcch8_demapper(timeslot_nr=timeslot, )
        self.decoder = grgsm.control_channels_decoder()
        self.extract_cmc = grgsm.extract_cmc()

        self.msg_connect((self.burst_file_source, 'out'), (self.timeslot_filter, 'in'))
        self.msg_connect((self.timeslot_filter, 'out'), (self.subchannel_filter, 'in'))
        self.msg_connect((self.subchannel_filter, 'out'), (self.fnr_filter_start, 'in'))
        self.msg_connect((self.fnr_filter_start, 'out'), (self.fnr_filter_end, 'in'))
        self.msg_connect((self.fnr_filter_end, 'out'), (self.demapper, 'bursts'))
        self.msg_connect((self.demapper, 'bursts'), (self.decoder, 'bursts'))
        self.msg_connect((self.decoder, 'msgs'), (self.extract_cmc, 'msgs'))
    def __init__(self, timeslot, burst_file, mode, fnr_start, fnr_end):
        gr.top_block.__init__(self, "Top Block")

        self.burst_file_source = grgsm.burst_file_source(burst_file)
        self.timeslot_filter = grgsm.burst_timeslot_filter(timeslot)
        self.fnr_filter_start = grgsm.burst_fnr_filter(grgsm.FILTER_GREATER_OR_EQUAL, fnr_start)
        self.fnr_filter_end = grgsm.burst_fnr_filter(grgsm.FILTER_LESS_OR_EQUAL, fnr_end)
        if mode == 'BCCH_SDCCH4':
            self.subslot_splitter = grgsm.burst_sdcch_subslot_splitter(grgsm.SPLITTER_SDCCH4)
            self.subslot_analyzers = [CMCAnalyzerArm() for x in range(4)]
            self.demapper = grgsm.gsm_bcch_ccch_sdcch4_demapper(timeslot_nr=timeslot, )
        else:
            self.subslot_splitter = grgsm.burst_sdcch_subslot_splitter(grgsm.SPLITTER_SDCCH8)
            self.subslot_analyzers = [CMCAnalyzerArm() for x in range(8)]
            self.demapper = grgsm.gsm_sdcch8_demapper(timeslot_nr=timeslot, )

        self.control_channels_decoder = grgsm.control_channels_decoder()
        self.burst_sink = grgsm.burst_sink()

        self.msg_connect((self.burst_file_source, 'out'), (self.timeslot_filter, 'in'))
        self.msg_connect((self.timeslot_filter, 'out'), (self.fnr_filter_start, 'in'))
        self.msg_connect((self.fnr_filter_start, 'out'), (self.fnr_filter_end, 'in'))
        self.msg_connect((self.fnr_filter_end, 'out'), (self.demapper, 'bursts'))
        self.msg_connect((self.demapper, 'bursts'), (self.burst_sink, 'in'))
        self.msg_connect((self.demapper, 'bursts'), (self.subslot_splitter, 'in'))
        for i in range(4 if mode == 'BCCH_SDCCH4' else 8):
            self.msg_connect((self.subslot_splitter, 'out' + str(i)), (self.subslot_analyzers[i], 'in'))

        self.bursts = None
        self.cmcs = None
Exemple #5
0
    def __init__(self, timeslot, burst_file, mode, show_gprs):
        gr.top_block.__init__(self, "Top Block")

        self.gsm_burst_file_source = grgsm.burst_file_source(burst_file)
        self.gsm_burst_timeslot_filter = grgsm.burst_timeslot_filter(timeslot)

        if mode == 'BCCH_SDCCH4':
            self.demapper = grgsm.gsm_bcch_ccch_sdcch4_demapper(
                timeslot_nr=timeslot, )
        else:
            self.demapper = grgsm.gsm_sdcch8_demapper(timeslot_nr=timeslot, )

        self.gsm_control_channels_decoder = grgsm.control_channels_decoder()
        self.gsm_extract_cmc = grgsm.extract_cmc()
        self.gsm_extract_immediate_assignment = grgsm.extract_immediate_assignment(
            False, not show_gprs, True)
        self.gsm_extract_system_info = grgsm.extract_system_info()

        self.msg_connect((self.gsm_burst_file_source, 'out'),
                         (self.gsm_burst_timeslot_filter, 'in'))
        self.msg_connect((self.gsm_burst_timeslot_filter, 'out'),
                         (self.demapper, 'bursts'))
        self.msg_connect((self.demapper, 'bursts'),
                         (self.gsm_control_channels_decoder, 'bursts'))
        self.msg_connect((self.gsm_control_channels_decoder, 'msgs'),
                         (self.gsm_extract_cmc, 'msgs'))
        self.msg_connect((self.gsm_control_channels_decoder, 'msgs'),
                         (self.gsm_extract_immediate_assignment, 'msgs'))
        self.msg_connect((self.gsm_control_channels_decoder, 'msgs'),
                         (self.gsm_extract_system_info, 'msgs'))
    def test_001 (self):
        """
            24 random framenumbers, timeslots and bursts as input
        """
        framenumbers_input = [1259192, 1076346, 1076242, 235879, 1259218, 2194302, 2714322, 1588, 1259244, 1563637, 1435624, 1928543, 503726, 1571144, 2658397, 1807445, 869789, 624070, 2005511, 1306953, 2284894, 1600339, 551375, 1259270]
        timeslots_input = [6, 1, 4, 3, 5, 3, 2, 7, 1, 6, 0, 7, 2, 1, 2, 0, 7, 1, 0, 6, 0, 6, 5, 7]
        bursts_input = [
            "0001100001000111100111101111100101000100101011000010011110011101001111101100010100111111100000110100011111101011101100100111110011000100010001010000",
            "0001000101000000001001111110000110010110110111110111101000001101001111101100010100111111001110001001110101110001010001000111011010010001011011000000",
            "0001001101101101000111001000101011001101001110110001001100111101001111101100010100111111111001001010011010011111010010010101011001001011011100110000",
            "0000010010100000001001101010100001011100010001101100111111101101001111101100010100111111101101001110100010101110010110101111100010010000110010110000",
            "0000010101010110010011110101010101101100000000001000100100101010000111011101001000011101011101110000101011001111000100001000000000001110010001111000",
            "0001000000000010111010100000010101000010001010111010000000011010000111011101001000011101000000100010111110101000000001000000000010111010100000000000",
            "0001010101111111111010000001010101011111111111101000000001001010000111011101001000011101010111111111111010101000000001010101011011101010000001000000",
            "0000000000111110101010100001000000100010101110101010000101001010000111011101001000011101001010001111101010001000010000000000101110101010100000010000",
            "0000010000000010000001001000011001010010000011000101000000001010000111011101001000011101010100100000000001001000001000000100100011000101001000111000",
            "0001010100110111100000110111100110010100011100011000110110001010000111011101001000011101011111111001111001101010010100000000011111001101000111110000",
            "0001100110000001011110001000001100101001010100111111000100111010000111011101001000011101000011010010001010111101000100110011111010100010010101000000",
            "0000010101100101010110000011010000000000000010111001110110101010000111011101001000011101000001000100100001111001100011000101010001110001010100111000",
            "0001000100000011001010111001111100011010000000000000001001001010000111011101001000011101010110000101111010011001110110001001011010101000011110110000",
            "0001100001000111111111100001011000000011010110111010110000111010000111011101001000011101100010111100100101110001101000110100110000001010101110011000",
            "0000000100111011000000000010100100001100101010000000010010101010000111011101001000011101000110110001110110000100110100110110011001100100000101100000",
            "0000100101111010011110111010100111010100011011011101100111001010000111011101001000011101010000111010000110100000001000010011101011001001110100011000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0000110101000011011010110000110011010000000001001010110010001010000111011101001000011101010000011000111001101110000000110010100001101110101000100000",
            "0000001000010001011111111111101010100000010101011101101010101010000111011101001000011101100010010101010101011110101010101000010001011101111010101000",
            "0000101110101111011001011001000011110010100010011100110010001010000111011101001000011101100000001110000100010100110111001001100010101101100010101000",
            "0001100010000001000111011100101101101010100001111101001000101010000111011101001000011101111010000011010110010111011111010010001000001101100011111000",
            "0001011101101101011100001111001100010001000011011001101110011010000111011101001000011101010010111011100111000001011100100001111010100101111000100000",
            "0000001000100011000000000000110100000000010000001010100100001010000111011101001000011101000010010000000000001001000001011000000001010000000100010000",
            "0000100000110001000000000100000110001011100001001000000000001010000111011101001000011101001010010001010000000111010000000011000001000000000101010000"
        ]

        bursts_expected = [
            "0001000101000000001001111110000110010110110111110111101000001101001111101100010100111111001110001001110101110001010001000111011010010001011011000000",
            "0000010000000010000001001000011001010010000011000101000000001010000111011101001000011101010100100000000001001000001000000100100011000101001000111000",
            "0001100001000111111111100001011000000011010110111010110000111010000111011101001000011101100010111100100101110001101000110100110000001010101110011000",
            "0000110101000011011010110000110011010000000001001010110010001010000111011101001000011101010000011000111001101110000000110010100001101110101000100000"
        ]

        timeslot = 1
        src = grgsm.burst_source(framenumbers_input, timeslots_input, bursts_input)
        ts_filter = grgsm.burst_timeslot_filter(timeslot)
        sink = grgsm.burst_sink()

        self.tb.msg_connect(src, "out", ts_filter, "in")
        self.tb.msg_connect(ts_filter, "out", sink, "in")

        self.tb.run ()

        bursts_result = list(sink.get_burst_data())
        
        self.assertEqual(bursts_expected, bursts_result)
    def __init__(self, timeslot, burst_file, mode):
        gr.top_block.__init__(self, "Top Block")

        self.si_messages = dict()

        self.burst_file_source = grgsm.burst_file_source(burst_file)
        self.timeslot_filter = grgsm.burst_timeslot_filter(timeslot)
        if mode == 'BCCH_SDCCH4':
            self.demapper = grgsm.gsm_bcch_ccch_sdcch4_demapper(timeslot_nr=timeslot, )
        else:
            self.demapper = grgsm.gsm_sdcch8_demapper(timeslot_nr=timeslot, )

        self.decoder = grgsm.control_channels_decoder()
        self.control_channels_decoder = grgsm.control_channels_decoder()
        self.collect_system_info = grgsm.collect_system_info()

        self.msg_connect((self.burst_file_source, 'out'), (self.timeslot_filter, 'in'))
        self.msg_connect((self.timeslot_filter, 'out'), (self.demapper, 'bursts'))
        self.msg_connect((self.demapper, 'bursts'), (self.decoder, 'bursts'))
        self.msg_connect((self.decoder, 'msgs'), (self.collect_system_info, 'msgs'))
Exemple #8
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))
    def __init__(self,
                 timeslot=0,
                 chan_mode='BCCH',
                 burst_file=None,
                 cfile=None,
                 fc=None,
                 samp_rate=2e6,
                 ppm=0):

        gr.top_block.__init__(self, "gr-gsm TMSI Capture")

        ##################################################
        # Parameters
        ##################################################
        self.timeslot = timeslot
        self.chan_mode = chan_mode
        self.burst_file = burst_file
        self.cfile = cfile
        self.fc = fc
        self.samp_rate = samp_rate
        self.ppm = ppm

        ##################################################
        # Blocks
        ##################################################

        if self.burst_file:
            self.burst_file_source = grgsm.burst_file_source(burst_file)
        elif self.cfile:
            self.file_source = blocks.file_source(gr.sizeof_gr_complex * 1,
                                                  self.cfile, False)
            self.receiver = grgsm.receiver(4, ([0]), ([]))
            if self.fc is not None:
                self.input_adapter = grgsm.gsm_input(ppm=ppm,
                                                     osr=4,
                                                     fc=self.fc,
                                                     samp_rate_in=samp_rate)
                self.offset_control = grgsm.clock_offset_control(
                    self.fc, self.samp_rate)
            else:
                self.input_adapter = grgsm.gsm_input(ppm=ppm,
                                                     osr=4,
                                                     samp_rate_in=samp_rate)

        self.dummy_burst_filter = grgsm.dummy_burst_filter()
        self.timeslot_filter = grgsm.burst_timeslot_filter(self.timeslot)

        if self.chan_mode == 'BCCH':
            self.bcch_demapper = grgsm.gsm_bcch_ccch_demapper(self.timeslot)
        elif self.chan_mode == 'BCCH_SDCCH4':
            self.bcch_sdcch4_demapper = grgsm.gsm_bcch_ccch_sdcch4_demapper(
                self.timeslot)

        self.cch_decoder = grgsm.control_channels_decoder()
        self.tmsi_dumper = grgsm.tmsi_dumper()
        self.socket_pdu_server = blocks.socket_pdu("UDP_SERVER", "127.0.0.1",
                                                   "4729", 10000)
        self.socket_pdu = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729",
                                            10000)

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

        if self.burst_file:
            self.msg_connect(self.burst_file_source, "out",
                             self.dummy_burst_filter, "in")
        elif self.cfile:
            self.connect((self.file_source, 0), (self.input_adapter, 0))
            self.connect((self.input_adapter, 0), (self.receiver, 0))
            if self.fc is not None:
                self.msg_connect(self.offset_control, "ctrl",
                                 self.input_adapter, "ctrl_in")
                self.msg_connect(self.receiver, "measurements",
                                 self.offset_control, "measurements")
            self.msg_connect(self.receiver, "C0", self.dummy_burst_filter,
                             "in")

        self.msg_connect(self.dummy_burst_filter, "out", self.timeslot_filter,
                         "in")

        if self.chan_mode == 'BCCH':
            self.msg_connect(self.timeslot_filter, "out", self.bcch_demapper,
                             "bursts")
            self.msg_connect(self.bcch_demapper, "bursts", self.cch_decoder,
                             "bursts")
            self.msg_connect(self.cch_decoder, "msgs", self.socket_pdu, "pdus")
            self.msg_connect(self.cch_decoder, "msgs", self.tmsi_dumper,
                             "msgs")

        elif self.chan_mode == 'BCCH_SDCCH4':
            self.msg_connect(self.timeslot_filter, "out",
                             self.bcch_sdcch4_demapper, "bursts")
            self.msg_connect(self.bcch_sdcch4_demapper, "bursts",
                             self.cch_decoder, "bursts")
            self.msg_connect(self.cch_decoder, "msgs", self.socket_pdu, "pdus")
            self.msg_connect(self.cch_decoder, "msgs", self.tmsi_dumper,
                             "msgs")
Exemple #10
0
    def __init__(self, timeslot=0, subslot=None, chan_mode='BCCH',
                 burst_file=None,
                 cfile=None, fc=939.4e6, samp_rate=2e6, arfcn=None,
                 a5=1, a5_kc=None,
                 speech_file=None, speech_codec=None):

        gr.top_block.__init__(self, "Airprobe Decode")

        ##################################################
        # Parameters
        ##################################################
        self.timeslot = timeslot
        self.subslot = subslot
        self.chan_mode = chan_mode
        self.burst_file = burst_file
        self.cfile = cfile
        self.fc = fc
        self.samp_rate = samp_rate
        self.arfcn = arfcn
        self.a5 = a5
        self.kc = a5_kc
        if len(a5_kc) < 8:
            self.kc = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
        self.speech_file = speech_file
        self.speech_codec = speech_codec

        ##################################################
        # Blocks
        ##################################################

        if self.burst_file:
            self.burst_file_source = grgsm.burst_file_source(burst_file)
        elif self.cfile:
            self.file_source = blocks.file_source(gr.sizeof_gr_complex*1, self.cfile, False)
            self.receiver = grgsm.receiver(4, ([0]), ([]))
            self.input_adapter = grgsm.gsm_input(
                ppm=0,
                osr=4,
                fc=fc,
                samp_rate_in=samp_rate,
            )
            self.offset_control = grgsm.clock_offset_control(fc)

        self.dummy_burst_filter = grgsm.dummy_burst_filter()
        self.timeslot_filter = grgsm.burst_timeslot_filter(self.timeslot)

        self.subslot_filter = None
        if self.chan_mode == 'BCCH_SDCCH4' and self.subslot is not None:
            self.subslot_filter = grgsm.burst_sdcch_subslot_filter(grgsm.SS_FILTER_SDCCH4, self.subslot)
        elif self.chan_mode == 'SDCCH8' and self.subslot is not None:
            self.subslot_filter = grgsm.burst_sdcch_subslot_filter(grgsm.SS_FILTER_SDCCH8, self.subslot)

        if self.chan_mode == 'BCCH':
            self.bcch_demapper = grgsm.universal_ctrl_chans_demapper(self.timeslot,
                                                                     ([2, 6, 12, 16, 22, 26, 32, 36, 42, 46]),
                                                                     ([1, 2, 2, 2, 2, 2, 2, 2, 2, 2]))
        elif self.chan_mode == 'BCCH_SDCCH4':
            self.bcch_sdcch4_demapper = grgsm.universal_ctrl_chans_demapper(self.timeslot,
                                                                            ([2, 6, 12, 16, 22, 26, 32, 36, 42, 46]),
                                                                            ([1, 2, 2, 2, 7, 7, 7, 7, 135, 135]))
        elif self.chan_mode == 'SDCCH8':
            self.sdcch8_demapper = grgsm.universal_ctrl_chans_demapper(self.timeslot,
                                                                       ([0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44]),
                                                                       ([8, 8, 8, 8, 8, 8, 8, 8, 136, 136, 136, 136]))
        elif self.chan_mode == 'TCHF':
            self.tch_f_demapper = grgsm.tch_f_chans_demapper(self.timeslot)
            self.tch_f_decoder = grgsm.tch_f_decoder(speech_codec, speech_file)

        if self.kc != [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]:
            self.decryption = grgsm.decryption(self.kc, self.a5)
            self.cch_decoder_decrypted = grgsm.control_channels_decoder()
            if self.chan_mode == 'TCHF':
                self.decryption_tch_sacch = grgsm.decryption(self.kc, self.a5)

        self.cch_decoder = grgsm.control_channels_decoder()

        self.socket_pdu = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False)

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

        if self.burst_file:
            self.msg_connect(self.burst_file_source, "out", self.dummy_burst_filter, "in")
        elif self.cfile:
            self.connect((self.file_source, 0), (self.input_adapter, 0))
            self.connect((self.input_adapter, 0), (self.receiver, 0))
            self.msg_connect(self.offset_control, "ppm", self.input_adapter, "ppm_in")
            self.msg_connect(self.receiver, "measurements", self.offset_control, "measurements")
            self.msg_connect(self.receiver, "C0", self.dummy_burst_filter, "in")

        self.msg_connect(self.dummy_burst_filter, "out", self.timeslot_filter, "in")

        if (self.chan_mode == 'BCCH_SDCCH4' or self.chan_mode == 'SDCCH8') and self.subslot_filter is not None:
            self.msg_connect(self.timeslot_filter, "out", self.subslot_filter, "in")

        if self.chan_mode == 'BCCH':
            if self.subslot_filter is not None:
                self.msg_connect(self.subslot_filter, "out", self.bcch_demapper, "bursts")
            else:
                self.msg_connect(self.timeslot_filter, "out", self.bcch_demapper, "bursts")

            self.msg_connect(self.bcch_demapper, "bursts", self.cch_decoder, "bursts")
            self.msg_connect(self.cch_decoder, "msgs", self.socket_pdu, "pdus")

        elif self.chan_mode == 'BCCH_SDCCH4':
            if self.subslot_filter is not None:
                self.msg_connect(self.subslot_filter, "out", self.bcch_sdcch4_demapper, "bursts")
            else:
                self.msg_connect(self.timeslot_filter, "out", self.bcch_sdcch4_demapper, "bursts")

            if self.kc != [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]:
                self.msg_connect(self.bcch_sdcch4_demapper, "bursts", self.decryption, "bursts")
                self.msg_connect(self.decryption, "bursts", self.cch_decoder_decrypted, "bursts")
                self.msg_connect(self.cch_decoder_decrypted, "msgs", self.socket_pdu, "pdus")

            self.msg_connect(self.bcch_sdcch4_demapper, "bursts", self.cch_decoder, "bursts")
            self.msg_connect(self.cch_decoder, "msgs", self.socket_pdu, "pdus")

        elif self.chan_mode == 'SDCCH8':
            if self.subslot_filter is not None:
                self.msg_connect(self.subslot_filter, "out", self.sdcch8_demapper, "bursts")
            else:
                self.msg_connect(self.timeslot_filter, "out", self.sdcch8_demapper, "bursts")

            if self.kc != [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]:
                self.msg_connect(self.sdcch8_demapper, "bursts", self.decryption, "bursts")
                self.msg_connect(self.decryption, "bursts", self.cch_decoder_decrypted, "bursts")
                self.msg_connect(self.cch_decoder_decrypted, "msgs", self.socket_pdu, "pdus")

            self.msg_connect(self.sdcch8_demapper, "bursts", self.cch_decoder, "bursts")
            self.msg_connect(self.cch_decoder, "msgs", self.socket_pdu, "pdus")

        elif self.chan_mode == 'TCHF':
            self.msg_connect(self.timeslot_filter, "out", self.tch_f_demapper, "bursts")
            if self.kc != [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]:
                self.msg_connect(self.tch_f_demapper, "acch_bursts", self.decryption_tch_sacch, "bursts")
                self.msg_connect(self.tch_f_demapper, "tch_bursts", self.decryption, "bursts")

                self.msg_connect(self.decryption_tch_sacch, "bursts", self.cch_decoder, "bursts")
                self.msg_connect(self.decryption, "bursts", self.tch_f_decoder, "bursts")
            else:
                self.msg_connect(self.tch_f_demapper, "acch_bursts", self.cch_decoder, "bursts")
                self.msg_connect(self.tch_f_demapper, "tch_bursts", self.tch_f_decoder, "bursts")

            self.msg_connect(self.tch_f_decoder, "msgs", self.socket_pdu, "pdus")
            self.msg_connect(self.cch_decoder, "msgs", self.socket_pdu, "pdus")
Exemple #11
0
    def __init__(self, filename, samp_rate, arfcn, chan_mode='BCCH', udp_port=4000, max_timeslot=0, verbose=True, args="", connectToSelf=False):
        """
        """

        gr.top_block.__init__(self, "FileAnalyzer")

        ##################################################
        # Parameters
        ##################################################

        self.arfcn = arfcn
        for band in grgsm.arfcn.get_bands():
            if grgsm.arfcn.is_valid_arfcn(self.arfcn, band):
                self.fc = grgsm.arfcn.arfcn2downlink(arfcn, band)
                break

        self.samp_rate = samp_rate
        self.arfcn = arfcn
        self.udp_port = udp_port
        self.verbose = verbose
        self.cfile = filename.encode('utf-8')
        self.max_timeslot = max_timeslot
        self.chan_mode = chan_mode

        ##################################################
        # Processing Blocks
        ##################################################

        self.file_source = blocks.file_source(gr.sizeof_gr_complex*1, self.cfile, False)
        self.receiver = grgsm.receiver(4, ([0]), ([]))
        if self.fc is not None:
            self.input_adapter = grgsm.gsm_input(ppm=0, osr=4, fc=self.fc, samp_rate_in=self.samp_rate)
            self.offset_control = grgsm.clock_offset_control(self.fc)
        else:
            self.input_adapter = grgsm.gsm_input(ppm=0, osr=4, samp_rate_in=self.samp_rate)

        self.bursts_printer = grgsm.bursts_printer(pmt.intern(""), True, True, True, True)

        self.timeslot_filters = []
        for i in range(0, self.max_timeslot + 1):
            self.timeslot_filters.append(grgsm.burst_timeslot_filter(i))

        self.dummy_burst_filters = []
        for i in range(0, self.max_timeslot + 1):
            self.dummy_burst_filters.append(grgsm.dummy_burst_filter())

        self.other_demappers = []
        #Control channel demapper for timeslot 0
        self.control_demapper = grgsm.gsm_bcch_ccch_demapper(0)

        #Demapping other timeslots than 0 to BCCH does not really make sense
        # if self.chan_mode == 'BCCH':
        #     #Control channel demapper for other timeslots
        #     for i in range(1, self.timeslot + 1):
        #         self.other_demappers.append(grgsm.universal_ctrl_chans_demapper(0, ([2,6,12,16,22,26,32,36,42,46]), ([1,2,2,2,2,2,2,2,2,2])))
        #     #self.bcch_demapper = grgsm.universal_ctrl_chans_demapper(0, ([2,6,12,16,22,26,32,36,42,46]), ([1,2,2,2,2,2,2,2,2,2]))
        #     #This is for a newer version of grgsm
        #     #self.bcch_demapper = grgsm.gsm_bcch_ccch_demapper(self.timeslot)
        if self.chan_mode == 'BCCH_SDCCH4':
            for i in range(1, self.max_timeslot + 1):
                self.other_demappers.append(grgsm.gsm_sdcch4_demapper(i))

        elif self.chan_mode == 'SDCCH8':
            for i in range(1, self.max_timeslot + 1):
                #self.other_demappers.append(grgsm.universal_ctrl_chans_demapper(i, ([0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44]), ([8, 8, 8, 8, 8, 8, 8, 8, 136, 136, 136, 136])))
                self.other_demappers.append(grgsm.gsm_sdcch8_demapper(i))
            #
        else:
            #Defaults to SDCCH8
            for i in range(1, self.max_timeslot + 1):
                #self.other_demappers.append(grgsm.universal_ctrl_chans_demapper(i, ([0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44]), ([8, 8, 8, 8, 8, 8, 8, 8, 136, 136, 136, 136])))
                self.other_demappers.append(grgsm.gsm_sdcch8_demapper(i))

        self.decoders = []
        for i in range(0, self.max_timeslot + 1):
            self.decoders.append(grgsm.control_channels_decoder())


        #Server socket
        if connectToSelf:
            self.serversocket = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", str(self.udp_port), 10000)

        self.socket_pdu = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", str(self.udp_port), 10000)
        if self.verbose:
            self.message_printer = grgsm.message_printer(pmt.intern(""), True, True, False)



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

        self.connect((self.file_source, 0), (self.input_adapter, 0))
        self.connect((self.input_adapter, 0), (self.receiver, 0))
        if self.fc is not None:
            self.msg_connect(self.offset_control, "ppm", self.input_adapter, "ppm_in")
            self.msg_connect(self.receiver, "measurements", self.offset_control, "measurements")

        #for df in self.dummy_burst_filters:
        #    self.msg_connect(self.receiver, "C0", df, "in")
        #self.msg_connect(self.receiver, "C0", self.dummy_burst_filter, "in")

        #for index, tf in enumerate(self.dummy_burst_filters):
        #    self.msg_connect(self.dummy_burst_filters[index], "out", self.timeslot_filters[index], "in")
        #self.msg_connect(self.dummy_burst_filter, "out", self.timeslot_filter, "in")

        #if self.print_bursts:
        #for tf in self.timeslot_filters:
        #    self.msg_connect(tf, "out", self.bursts_printer, 'bursts')
        #self.msg_connect(self.timeslot_filter, "out", self.bursts_printer, 'bursts')

        #Connect the timeslot 0 demapper and decoder
        #self.msg_connect(self.timeslot_filters[0], "out", self.control_demapper, "bursts")
        self.msg_connect(self.receiver, "C0", self.control_demapper, "bursts")
        self.msg_connect(self.control_demapper, "bursts", self.decoders[0], "bursts")
        self.msg_connect(self.decoders[0], "msgs", self.socket_pdu, "pdus")
        if self.verbose:
            self.msg_connect(self.decoders[0], "msgs", self.message_printer, "msgs")


        #Connect the demappers and decoders for the other timeslots
        for i in range(1, self.max_timeslot + 1):
            self.msg_connect(self.receiver, "C0", self.other_demappers[i-1], "bursts")
            #self.msg_connect(self.timeslot_filters[i], "out", self.other_demappers[i - 1], "bursts")
            self.msg_connect(self.other_demappers[i - 1], "bursts", self.decoders[i], "bursts")
            self.msg_connect(self.decoders[i], "msgs", self.socket_pdu, "pdus")
            if self.verbose:
                self.msg_connect(self.decoders[i], "msgs", self.message_printer, "msgs")
Exemple #12
0
    def __init__(self,
                 filename,
                 samp_rate,
                 arfcn,
                 chan_mode='BCCH',
                 udp_port=4000,
                 max_timeslot=0,
                 verbose=True,
                 args="",
                 connectToSelf=False):
        """
        """

        gr.top_block.__init__(self, "FileAnalyzer")

        ##################################################
        # Parameters
        ##################################################

        self.arfcn = arfcn
        for band in grgsm.arfcn.get_bands():
            if grgsm.arfcn.is_valid_arfcn(self.arfcn, band):
                self.fc = grgsm.arfcn.arfcn2downlink(arfcn, band)
                break

        self.samp_rate = samp_rate
        self.arfcn = arfcn
        self.udp_port = udp_port
        self.verbose = verbose
        self.cfile = filename.encode('utf-8')
        self.max_timeslot = max_timeslot
        self.chan_mode = chan_mode

        ##################################################
        # Processing Blocks
        ##################################################

        self.file_source = blocks.file_source(gr.sizeof_gr_complex * 1,
                                              self.cfile, False)
        self.receiver = grgsm.receiver(4, ([0]), ([]))
        if self.fc is not None:
            self.input_adapter = grgsm.gsm_input(ppm=0,
                                                 osr=4,
                                                 fc=self.fc,
                                                 samp_rate_in=self.samp_rate)
            self.offset_control = grgsm.clock_offset_control(self.fc)
        else:
            self.input_adapter = grgsm.gsm_input(ppm=0,
                                                 osr=4,
                                                 samp_rate_in=self.samp_rate)

        self.bursts_printer = grgsm.bursts_printer(pmt.intern(""), True, True,
                                                   True, True)

        self.timeslot_filters = []
        for i in range(0, self.max_timeslot + 1):
            self.timeslot_filters.append(grgsm.burst_timeslot_filter(i))

        self.dummy_burst_filters = []
        for i in range(0, self.max_timeslot + 1):
            self.dummy_burst_filters.append(grgsm.dummy_burst_filter())

        self.other_demappers = []
        #Control channel demapper for timeslot 0
        self.control_demapper = grgsm.gsm_bcch_ccch_demapper(0)

        #Demapping other timeslots than 0 to BCCH does not really make sense
        # if self.chan_mode == 'BCCH':
        #     #Control channel demapper for other timeslots
        #     for i in range(1, self.timeslot + 1):
        #         self.other_demappers.append(grgsm.universal_ctrl_chans_demapper(0, ([2,6,12,16,22,26,32,36,42,46]), ([1,2,2,2,2,2,2,2,2,2])))
        #     #self.bcch_demapper = grgsm.universal_ctrl_chans_demapper(0, ([2,6,12,16,22,26,32,36,42,46]), ([1,2,2,2,2,2,2,2,2,2]))
        #     #This is for a newer version of grgsm
        #     #self.bcch_demapper = grgsm.gsm_bcch_ccch_demapper(self.timeslot)
        if self.chan_mode == 'BCCH_SDCCH4':
            for i in range(1, self.max_timeslot + 1):
                self.other_demappers.append(grgsm.gsm_sdcch4_demapper(i))

        elif self.chan_mode == 'SDCCH8':
            for i in range(1, self.max_timeslot + 1):
                #self.other_demappers.append(grgsm.universal_ctrl_chans_demapper(i, ([0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44]), ([8, 8, 8, 8, 8, 8, 8, 8, 136, 136, 136, 136])))
                self.other_demappers.append(grgsm.gsm_sdcch8_demapper(i))
            #
        else:
            #Defaults to SDCCH8
            for i in range(1, self.max_timeslot + 1):
                #self.other_demappers.append(grgsm.universal_ctrl_chans_demapper(i, ([0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44]), ([8, 8, 8, 8, 8, 8, 8, 8, 136, 136, 136, 136])))
                self.other_demappers.append(grgsm.gsm_sdcch8_demapper(i))

        self.decoders = []
        for i in range(0, self.max_timeslot + 1):
            self.decoders.append(grgsm.control_channels_decoder())

        #Server socket
        if connectToSelf:
            self.serversocket = blocks.socket_pdu("UDP_SERVER", "127.0.0.1",
                                                  str(self.udp_port), 10000)

        self.socket_pdu = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1",
                                            str(self.udp_port), 10000)
        if self.verbose:
            self.message_printer = grgsm.message_printer(
                pmt.intern(""), True, True, False)

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

        self.connect((self.file_source, 0), (self.input_adapter, 0))
        self.connect((self.input_adapter, 0), (self.receiver, 0))
        if self.fc is not None:
            self.msg_connect(self.offset_control, "ppm", self.input_adapter,
                             "ppm_in")
            self.msg_connect(self.receiver, "measurements",
                             self.offset_control, "measurements")

        #for df in self.dummy_burst_filters:
        #    self.msg_connect(self.receiver, "C0", df, "in")
        #self.msg_connect(self.receiver, "C0", self.dummy_burst_filter, "in")

        #for index, tf in enumerate(self.dummy_burst_filters):
        #    self.msg_connect(self.dummy_burst_filters[index], "out", self.timeslot_filters[index], "in")
        #self.msg_connect(self.dummy_burst_filter, "out", self.timeslot_filter, "in")

        #if self.print_bursts:
        #for tf in self.timeslot_filters:
        #    self.msg_connect(tf, "out", self.bursts_printer, 'bursts')
        #self.msg_connect(self.timeslot_filter, "out", self.bursts_printer, 'bursts')

        #Connect the timeslot 0 demapper and decoder
        #self.msg_connect(self.timeslot_filters[0], "out", self.control_demapper, "bursts")
        self.msg_connect(self.receiver, "C0", self.control_demapper, "bursts")
        self.msg_connect(self.control_demapper, "bursts", self.decoders[0],
                         "bursts")
        self.msg_connect(self.decoders[0], "msgs", self.socket_pdu, "pdus")
        if self.verbose:
            self.msg_connect(self.decoders[0], "msgs", self.message_printer,
                             "msgs")

        #Connect the demappers and decoders for the other timeslots
        for i in range(1, self.max_timeslot + 1):
            self.msg_connect(self.receiver, "C0", self.other_demappers[i - 1],
                             "bursts")
            #self.msg_connect(self.timeslot_filters[i], "out", self.other_demappers[i - 1], "bursts")
            self.msg_connect(self.other_demappers[i - 1], "bursts",
                             self.decoders[i], "bursts")
            self.msg_connect(self.decoders[i], "msgs", self.socket_pdu, "pdus")
            if self.verbose:
                self.msg_connect(self.decoders[i], "msgs",
                                 self.message_printer, "msgs")
    def __init__(self,
                 timeslot=0,
                 subslot=None,
                 chan_mode='BCCH',
                 burst_file=None,
                 cfile=None,
                 fc=939.4e6,
                 samp_rate=2e6,
                 arfcn=None,
                 a5=1,
                 a5_kc=None,
                 speech_file=None,
                 speech_codec=None,
                 verbose=False):

        gr.top_block.__init__(self, "Airprobe Decode")

        ##################################################
        # Parameters
        ##################################################
        self.timeslot = timeslot
        self.subslot = subslot
        self.chan_mode = chan_mode
        self.burst_file = burst_file
        self.cfile = cfile
        self.fc = fc
        self.samp_rate = samp_rate
        self.arfcn = arfcn
        self.a5 = a5
        self.kc = a5_kc
        if len(a5_kc) < 8:
            self.kc = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]
        self.speech_file = speech_file
        self.speech_codec = speech_codec
        self.verbose = verbose

        ##################################################
        # Blocks
        ##################################################

        if self.burst_file:
            self.burst_file_source = grgsm.burst_file_source(burst_file)
        elif self.cfile:
            self.file_source = blocks.file_source(gr.sizeof_gr_complex * 1,
                                                  self.cfile, False)
            self.receiver = grgsm.receiver(4, ([0]), ([]))
            self.input_adapter = grgsm.gsm_input(
                ppm=0,
                osr=4,
                fc=fc,
                samp_rate_in=samp_rate,
            )
            self.offset_control = grgsm.clock_offset_control(fc)

        self.dummy_burst_filter = grgsm.dummy_burst_filter()
        self.timeslot_filter = grgsm.burst_timeslot_filter(self.timeslot)

        self.subslot_filter = None
        if self.chan_mode == 'BCCH_SDCCH4' and self.subslot is not None:
            self.subslot_filter = grgsm.burst_sdcch_subslot_filter(
                grgsm.SS_FILTER_SDCCH4, self.subslot)
        elif self.chan_mode == 'SDCCH8' and self.subslot is not None:
            self.subslot_filter = grgsm.burst_sdcch_subslot_filter(
                grgsm.SS_FILTER_SDCCH8, self.subslot)

        if self.chan_mode == 'BCCH':
            self.bcch_demapper = grgsm.universal_ctrl_chans_demapper(
                self.timeslot, ([2, 6, 12, 16, 22, 26, 32, 36, 42, 46]),
                ([1, 2, 2, 2, 2, 2, 2, 2, 2, 2]))
        elif self.chan_mode == 'BCCH_SDCCH4':
            self.bcch_sdcch4_demapper = grgsm.universal_ctrl_chans_demapper(
                self.timeslot, ([2, 6, 12, 16, 22, 26, 32, 36, 42, 46]),
                ([1, 2, 2, 2, 7, 7, 7, 7, 135, 135]))
        elif self.chan_mode == 'SDCCH8':
            self.sdcch8_demapper = grgsm.universal_ctrl_chans_demapper(
                self.timeslot, ([0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44]),
                ([8, 8, 8, 8, 8, 8, 8, 8, 136, 136, 136, 136]))
        elif self.chan_mode == 'TCHF':
            self.tch_f_demapper = grgsm.tch_f_chans_demapper(self.timeslot)
            self.tch_f_decoder = grgsm.tch_f_decoder(speech_codec, speech_file)

        if self.kc != [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]:
            self.decryption = grgsm.decryption(self.kc, self.a5)
            self.cch_decoder_decrypted = grgsm.control_channels_decoder()
            if self.chan_mode == 'TCHF':
                self.decryption_tch_sacch = grgsm.decryption(self.kc, self.a5)

        self.cch_decoder = grgsm.control_channels_decoder()

        self.socket_pdu = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729",
                                            10000, False)
        if self.verbose:
            self.message_printer = grgsm.message_printer(
                pmt.intern(""), True, True, False)

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

        if self.burst_file:
            self.msg_connect(self.burst_file_source, "out",
                             self.dummy_burst_filter, "in")
        elif self.cfile:
            self.connect((self.file_source, 0), (self.input_adapter, 0))
            self.connect((self.input_adapter, 0), (self.receiver, 0))
            self.msg_connect(self.offset_control, "ppm", self.input_adapter,
                             "ppm_in")
            self.msg_connect(self.receiver, "measurements",
                             self.offset_control, "measurements")
            self.msg_connect(self.receiver, "C0", self.dummy_burst_filter,
                             "in")

        self.msg_connect(self.dummy_burst_filter, "out", self.timeslot_filter,
                         "in")

        if (self.chan_mode == 'BCCH_SDCCH4' or self.chan_mode
                == 'SDCCH8') and self.subslot_filter is not None:
            self.msg_connect(self.timeslot_filter, "out", self.subslot_filter,
                             "in")

        if self.chan_mode == 'BCCH':
            if self.subslot_filter is not None:
                self.msg_connect(self.subslot_filter, "out",
                                 self.bcch_demapper, "bursts")
            else:
                self.msg_connect(self.timeslot_filter, "out",
                                 self.bcch_demapper, "bursts")

            self.msg_connect(self.bcch_demapper, "bursts", self.cch_decoder,
                             "bursts")
            self.msg_connect(self.cch_decoder, "msgs", self.socket_pdu, "pdus")
            if self.verbose:
                self.msg_connect(self.cch_decoder, "msgs",
                                 self.message_printer, "msgs")

        elif self.chan_mode == 'BCCH_SDCCH4':
            if self.subslot_filter is not None:
                self.msg_connect(self.subslot_filter, "out",
                                 self.bcch_sdcch4_demapper, "bursts")
            else:
                self.msg_connect(self.timeslot_filter, "out",
                                 self.bcch_sdcch4_demapper, "bursts")

            if self.kc != [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]:
                self.msg_connect(self.bcch_sdcch4_demapper, "bursts",
                                 self.decryption, "bursts")
                self.msg_connect(self.decryption, "bursts",
                                 self.cch_decoder_decrypted, "bursts")
                self.msg_connect(self.cch_decoder_decrypted, "msgs",
                                 self.socket_pdu, "pdus")
                if self.verbose:
                    self.msg_connect(self.cch_decoder_decrypted, "msgs",
                                     self.message_printer, "msgs")

            self.msg_connect(self.bcch_sdcch4_demapper, "bursts",
                             self.cch_decoder, "bursts")
            self.msg_connect(self.cch_decoder, "msgs", self.socket_pdu, "pdus")
            if self.verbose:
                self.msg_connect(self.cch_decoder, "msgs",
                                 self.message_printer, "msgs")

        elif self.chan_mode == 'SDCCH8':
            if self.subslot_filter is not None:
                self.msg_connect(self.subslot_filter, "out",
                                 self.sdcch8_demapper, "bursts")
            else:
                self.msg_connect(self.timeslot_filter, "out",
                                 self.sdcch8_demapper, "bursts")

            if self.kc != [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]:
                self.msg_connect(self.sdcch8_demapper, "bursts",
                                 self.decryption, "bursts")
                self.msg_connect(self.decryption, "bursts",
                                 self.cch_decoder_decrypted, "bursts")
                self.msg_connect(self.cch_decoder_decrypted, "msgs",
                                 self.socket_pdu, "pdus")
                if self.verbose:
                    self.msg_connect(self.cch_decoder_decrypted, "msgs",
                                     self.message_printer, "msgs")

            self.msg_connect(self.sdcch8_demapper, "bursts", self.cch_decoder,
                             "bursts")
            self.msg_connect(self.cch_decoder, "msgs", self.socket_pdu, "pdus")
            if self.verbose:
                self.msg_connect(self.cch_decoder, "msgs",
                                 self.message_printer, "msgs")

        elif self.chan_mode == 'TCHF':
            self.msg_connect(self.timeslot_filter, "out", self.tch_f_demapper,
                             "bursts")
            if self.kc != [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00]:
                self.msg_connect(self.tch_f_demapper, "acch_bursts",
                                 self.decryption_tch_sacch, "bursts")
                self.msg_connect(self.tch_f_demapper, "tch_bursts",
                                 self.decryption, "bursts")

                self.msg_connect(self.decryption_tch_sacch, "bursts",
                                 self.cch_decoder, "bursts")
                self.msg_connect(self.decryption, "bursts", self.tch_f_decoder,
                                 "bursts")
            else:
                self.msg_connect(self.tch_f_demapper, "acch_bursts",
                                 self.cch_decoder, "bursts")
                self.msg_connect(self.tch_f_demapper, "tch_bursts",
                                 self.tch_f_decoder, "bursts")

            self.msg_connect(self.tch_f_decoder, "msgs", self.socket_pdu,
                             "pdus")
            self.msg_connect(self.cch_decoder, "msgs", self.socket_pdu, "pdus")
            if self.verbose:
                self.msg_connect(self.tch_f_decoder, "msgs",
                                 self.message_printer, "msgs")
                self.msg_connect(self.cch_decoder, "msgs",
                                 self.message_printer, "msgs")
Exemple #14
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'))
    def __init__(self,
                 timeslot=0,
                 chan_mode='BCCH',
                 fc=None,
                 arfcn=0,
                 samp_rate=2e6,
                 ppm=0,
                 gain=30):
        gr.top_block.__init__(self, "gr-gsm TMSI Capture")
        self.rec_length = 15

        ##################################################
        # Parameters
        ##################################################
        self.timeslot = timeslot
        self.chan_mode = chan_mode
        self.fc = fc
        self.arfcn = arfcn
        self.samp_rate = samp_rate
        self.ppm = ppm
        self.gain = gain
        self.shiftoff = shiftoff = 400e3
        self.args = ""

        ##################################################
        # Blocks
        ##################################################

        self.rtlsdr_source = osmosdr.source(args="numchan=" + str(1) + " " +
                                            self.args)
        self.rtlsdr_source.set_sample_rate(samp_rate)
        self.rtlsdr_source.set_center_freq(fc - shiftoff, 0)
        self.rtlsdr_source.set_freq_corr(ppm, 0)
        self.rtlsdr_source.set_dc_offset_mode(2, 0)
        self.rtlsdr_source.set_iq_balance_mode(2, 0)
        self.rtlsdr_source.set_gain_mode(True, 0)
        self.rtlsdr_source.set_gain(gain, 0)
        self.rtlsdr_source.set_if_gain(20, 0)
        self.rtlsdr_source.set_bb_gain(20, 0)
        self.rtlsdr_source.set_antenna("", 0)
        self.rtlsdr_source.set_bandwidth(250e3 + abs(shiftoff), 0)

        self.blocks_rotator = blocks.rotator_cc(-2 * pi * shiftoff / samp_rate)

        self.blocks_head = blocks.head(gr.sizeof_gr_complex,
                                       int(samp_rate * self.rec_length))

        self.gsm_receiver = grgsm.receiver(4, ([self.arfcn]), ([]))
        self.gsm_input = grgsm.gsm_input(
            ppm=0,
            osr=4,
            fc=fc,
            samp_rate_in=samp_rate,
        )
        self.gsm_clock_offset_control = grgsm.clock_offset_control(fc -
                                                                   shiftoff,
                                                                   samp_rate,
                                                                   osr=4)
        self.dummy_burst_filter = grgsm.dummy_burst_filter()
        self.timeslot_filter = grgsm.burst_timeslot_filter(self.timeslot)

        if self.chan_mode == 'BCCH':
            self.bcch_demapper = grgsm.gsm_bcch_ccch_demapper(self.timeslot)
        elif self.chan_mode == 'BCCH_SDCCH4':
            self.bcch_sdcch4_demapper = grgsm.gsm_bcch_ccch_sdcch4_demapper(
                self.timeslot)

        self.cch_decoder = grgsm.control_channels_decoder()
        self.tmsi_dumper = grgsm.tmsi_dumper()
        self.socket_pdu_server = blocks.socket_pdu("UDP_SERVER", "127.0.0.1",
                                                   "4729", 10000)
        self.socket_pdu = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729",
                                            10000)

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

        self.connect((self.rtlsdr_source, 0), (self.blocks_head, 0))
        self.connect((self.blocks_head, 0), (self.blocks_rotator, 0))
        self.connect((self.gsm_input, 0), (self.gsm_receiver, 0))
        self.connect((self.blocks_rotator, 0), (self.gsm_input, 0))
        self.msg_connect(self.gsm_clock_offset_control, "ctrl", self.gsm_input,
                         "ctrl_in")
        self.msg_connect(self.gsm_receiver, "measurements",
                         self.gsm_clock_offset_control, "measurements")

        self.msg_connect(self.gsm_receiver, "C0", self.dummy_burst_filter,
                         "in")
        self.msg_connect(self.dummy_burst_filter, "out", self.timeslot_filter,
                         "in")

        if self.chan_mode == 'BCCH':
            self.msg_connect(self.timeslot_filter, "out", self.bcch_demapper,
                             "bursts")
            self.msg_connect(self.bcch_demapper, "bursts", self.cch_decoder,
                             "bursts")
            self.msg_connect(self.cch_decoder, "msgs", self.socket_pdu, "pdus")
            self.msg_connect(self.cch_decoder, "msgs", self.tmsi_dumper,
                             "msgs")

        elif self.chan_mode == 'BCCH_SDCCH4':
            self.msg_connect(self.timeslot_filter, "out",
                             self.bcch_sdcch4_demapper, "bursts")
            self.msg_connect(self.bcch_sdcch4_demapper, "bursts",
                             self.cch_decoder, "bursts")
            self.msg_connect(self.cch_decoder, "msgs", self.socket_pdu, "pdus")
            self.msg_connect(self.cch_decoder, "msgs", self.tmsi_dumper,
                             "msgs")
Exemple #16
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))
    def test_001(self):
        """
            24 random framenumbers, timeslots and bursts as input
        """
        framenumbers_input = [
            1259192, 1076346, 1076242, 235879, 1259218, 2194302, 2714322, 1588,
            1259244, 1563637, 1435624, 1928543, 503726, 1571144, 2658397,
            1807445, 869789, 624070, 2005511, 1306953, 2284894, 1600339,
            551375, 1259270
        ]
        timeslots_input = [
            6, 1, 4, 3, 5, 3, 2, 7, 1, 6, 0, 7, 2, 1, 2, 0, 7, 1, 0, 6, 0, 6,
            5, 7
        ]
        bursts_input = [
            "0001100001000111100111101111100101000100101011000010011110011101001111101100010100111111100000110100011111101011101100100111110011000100010001010000",
            "0001000101000000001001111110000110010110110111110111101000001101001111101100010100111111001110001001110101110001010001000111011010010001011011000000",
            "0001001101101101000111001000101011001101001110110001001100111101001111101100010100111111111001001010011010011111010010010101011001001011011100110000",
            "0000010010100000001001101010100001011100010001101100111111101101001111101100010100111111101101001110100010101110010110101111100010010000110010110000",
            "0000010101010110010011110101010101101100000000001000100100101010000111011101001000011101011101110000101011001111000100001000000000001110010001111000",
            "0001000000000010111010100000010101000010001010111010000000011010000111011101001000011101000000100010111110101000000001000000000010111010100000000000",
            "0001010101111111111010000001010101011111111111101000000001001010000111011101001000011101010111111111111010101000000001010101011011101010000001000000",
            "0000000000111110101010100001000000100010101110101010000101001010000111011101001000011101001010001111101010001000010000000000101110101010100000010000",
            "0000010000000010000001001000011001010010000011000101000000001010000111011101001000011101010100100000000001001000001000000100100011000101001000111000",
            "0001010100110111100000110111100110010100011100011000110110001010000111011101001000011101011111111001111001101010010100000000011111001101000111110000",
            "0001100110000001011110001000001100101001010100111111000100111010000111011101001000011101000011010010001010111101000100110011111010100010010101000000",
            "0000010101100101010110000011010000000000000010111001110110101010000111011101001000011101000001000100100001111001100011000101010001110001010100111000",
            "0001000100000011001010111001111100011010000000000000001001001010000111011101001000011101010110000101111010011001110110001001011010101000011110110000",
            "0001100001000111111111100001011000000011010110111010110000111010000111011101001000011101100010111100100101110001101000110100110000001010101110011000",
            "0000000100111011000000000010100100001100101010000000010010101010000111011101001000011101000110110001110110000100110100110110011001100100000101100000",
            "0000100101111010011110111010100111010100011011011101100111001010000111011101001000011101010000111010000110100000001000010011101011001001110100011000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0000110101000011011010110000110011010000000001001010110010001010000111011101001000011101010000011000111001101110000000110010100001101110101000100000",
            "0000001000010001011111111111101010100000010101011101101010101010000111011101001000011101100010010101010101011110101010101000010001011101111010101000",
            "0000101110101111011001011001000011110010100010011100110010001010000111011101001000011101100000001110000100010100110111001001100010101101100010101000",
            "0001100010000001000111011100101101101010100001111101001000101010000111011101001000011101111010000011010110010111011111010010001000001101100011111000",
            "0001011101101101011100001111001100010001000011011001101110011010000111011101001000011101010010111011100111000001011100100001111010100101111000100000",
            "0000001000100011000000000000110100000000010000001010100100001010000111011101001000011101000010010000000000001001000001011000000001010000000100010000",
            "0000100000110001000000000100000110001011100001001000000000001010000111011101001000011101001010010001010000000111010000000011000001000000000101010000"
        ]

        bursts_expected = [
            "0001000101000000001001111110000110010110110111110111101000001101001111101100010100111111001110001001110101110001010001000111011010010001011011000000",
            "0000010000000010000001001000011001010010000011000101000000001010000111011101001000011101010100100000000001001000001000000100100011000101001000111000",
            "0001100001000111111111100001011000000011010110111010110000111010000111011101001000011101100010111100100101110001101000110100110000001010101110011000",
            "0000110101000011011010110000110011010000000001001010110010001010000111011101001000011101010000011000111001101110000000110010100001101110101000100000"
        ]

        timeslot = 1
        src = grgsm.burst_source(framenumbers_input, timeslots_input,
                                 bursts_input)
        ts_filter = grgsm.burst_timeslot_filter(timeslot)
        sink = grgsm.burst_sink()

        self.tb.msg_connect(src, "out", ts_filter, "in")
        self.tb.msg_connect(ts_filter, "out", sink, "in")

        self.tb.run()

        bursts_result = list(sink.get_burst_data())

        self.assertEqual(bursts_expected, bursts_result)