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,
                 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")
    def test_001(self):
        """
            filter mode less_or_equal, limiting frame number 1500123
            24 bursts as input, 10 of them dummy bursts
        """
        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, 3, 4, 3, 5, 3, 2, 7, 1, 6, 0, 7, 2, 3, 2, 0, 7, 1, 0, 6, 0, 6,
            5, 7
        ]
        bursts_input = [
            "0001100001000111100111101111100101000100101011000010011110011101001111101100010100111111100000110100011111101011101100100111110011000100010001010000",
            "0001000101000000001001111110000110010110110111110111101000001101001111101100010100111111001110001001110101110001010001000111011010010001011011000000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0000010010100000001001101010100001011100010001101100111111101101001111101100010100111111101101001110100010101110010110101111100010010000110010110000",
            "0000010101010110010011110101010101101100000000001000100100101010000111011101001000011101011101110000101011001111000100001000000000001110010001111000",
            "0001000000000010111010100000010101000010001010111010000000011010000111011101001000011101000000100010111110101000000001000000000010111010100000000000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0000000000111110101010100001000000100010101110101010000101001010000111011101001000011101001010001111101010001000010000000000101110101010100000010000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0001000100000011001010111001111100011010000000000000001001001010000111011101001000011101010110000101111010011001110110001001011010101000011110110000",
            "0001100001000111111111100001011000000011010110111010110000111010000111011101001000011101100010111100100101110001101000110100110000001010101110011000",
            "0000000100111011000000000010100100001100101010000000010010101010000111011101001000011101000110110001110110000100110100110110011001100100000101100000",
            "0000100101111010011110111010100111010100011011011101100111001010000111011101001000011101010000111010000110100000001000010011101011001001110100011000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0000110101000011011010110000110011010000000001001010110010001010000111011101001000011101010000011000111001101110000000110010100001101110101000100000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0001100010000001000111011100101101101010100001111101001000101010000111011101001000011101111010000011010110010111011111010010001000001101100011111000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0000001000100011000000000000110100000000010000001010100100001010000111011101001000011101000010010000000000001001000001011000000001010000000100010000",
            "0000100000110001000000000100000110001011100001001000000000001010000111011101001000011101001010010001010000000111010000000011000001000000000101010000",
        ]

        bursts_expected = [
            "0001100001000111100111101111100101000100101011000010011110011101001111101100010100111111100000110100011111101011101100100111110011000100010001010000",
            "0001000101000000001001111110000110010110110111110111101000001101001111101100010100111111001110001001110101110001010001000111011010010001011011000000",
            "0000010010100000001001101010100001011100010001101100111111101101001111101100010100111111101101001110100010101110010110101111100010010000110010110000",
            "0000010101010110010011110101010101101100000000001000100100101010000111011101001000011101011101110000101011001111000100001000000000001110010001111000",
            "0001000000000010111010100000010101000010001010111010000000011010000111011101001000011101000000100010111110101000000001000000000010111010100000000000",
            "0000000000111110101010100001000000100010101110101010000101001010000111011101001000011101001010001111101010001000010000000000101110101010100000010000",
            "0001000100000011001010111001111100011010000000000000001001001010000111011101001000011101010110000101111010011001110110001001011010101000011110110000",
            "0001100001000111111111100001011000000011010110111010110000111010000111011101001000011101100010111100100101110001101000110100110000001010101110011000",
            "0000000100111011000000000010100100001100101010000000010010101010000111011101001000011101000110110001110110000100110100110110011001100100000101100000",
            "0000100101111010011110111010100111010100011011011101100111001010000111011101001000011101010000111010000110100000001000010011101011001001110100011000",
            "0000110101000011011010110000110011010000000001001010110010001010000111011101001000011101010000011000111001101110000000110010100001101110101000100000",
            "0001100010000001000111011100101101101010100001111101001000101010000111011101001000011101111010000011010110010111011111010010001000001101100011111000",
            "0000001000100011000000000000110100000000010000001010100100001010000111011101001000011101000010010000000000001001000001011000000001010000000100010000",
            "0000100000110001000000000100000110001011100001001000000000001010000111011101001000011101001010010001010000000111010000000011000001000000000101010000"
        ]

        dummy_burst_filter = grgsm.dummy_burst_filter()

        src = grgsm.burst_source(framenumbers_input, timeslots_input,
                                 bursts_input)
        sink = grgsm.burst_sink()

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

        self.tb.run()

        bursts_result = list(sink.get_burst_data())

        self.assertEqual(bursts_expected, bursts_result)
示例#4
0
    def test_001 (self):
        """
            filter mode less_or_equal, limiting frame number 1500123
            24 bursts as input, 10 of them dummy bursts
        """
        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, 3, 4, 3, 5, 3, 2, 7, 1, 6, 0, 7, 2, 3, 2, 0, 7, 1, 0, 6, 0, 6, 5, 7]
        bursts_input = [
            "0001100001000111100111101111100101000100101011000010011110011101001111101100010100111111100000110100011111101011101100100111110011000100010001010000",
            "0001000101000000001001111110000110010110110111110111101000001101001111101100010100111111001110001001110101110001010001000111011010010001011011000000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0000010010100000001001101010100001011100010001101100111111101101001111101100010100111111101101001110100010101110010110101111100010010000110010110000",
            "0000010101010110010011110101010101101100000000001000100100101010000111011101001000011101011101110000101011001111000100001000000000001110010001111000",
            "0001000000000010111010100000010101000010001010111010000000011010000111011101001000011101000000100010111110101000000001000000000010111010100000000000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0000000000111110101010100001000000100010101110101010000101001010000111011101001000011101001010001111101010001000010000000000101110101010100000010000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0001000100000011001010111001111100011010000000000000001001001010000111011101001000011101010110000101111010011001110110001001011010101000011110110000",
            "0001100001000111111111100001011000000011010110111010110000111010000111011101001000011101100010111100100101110001101000110100110000001010101110011000",
            "0000000100111011000000000010100100001100101010000000010010101010000111011101001000011101000110110001110110000100110100110110011001100100000101100000",
            "0000100101111010011110111010100111010100011011011101100111001010000111011101001000011101010000111010000110100000001000010011101011001001110100011000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0000110101000011011010110000110011010000000001001010110010001010000111011101001000011101010000011000111001101110000000110010100001101110101000100000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0001100010000001000111011100101101101010100001111101001000101010000111011101001000011101111010000011010110010111011111010010001000001101100011111000",
            "0001111101101110110000010100100111000001001000100000001111100011100010111000101110001010111010010100011001100111001111010011111000100101111101010000",
            "0000001000100011000000000000110100000000010000001010100100001010000111011101001000011101000010010000000000001001000001011000000001010000000100010000",
            "0000100000110001000000000100000110001011100001001000000000001010000111011101001000011101001010010001010000000111010000000011000001000000000101010000",
        ]

        bursts_expected = [
            "0001100001000111100111101111100101000100101011000010011110011101001111101100010100111111100000110100011111101011101100100111110011000100010001010000",
            "0001000101000000001001111110000110010110110111110111101000001101001111101100010100111111001110001001110101110001010001000111011010010001011011000000",
            "0000010010100000001001101010100001011100010001101100111111101101001111101100010100111111101101001110100010101110010110101111100010010000110010110000",
            "0000010101010110010011110101010101101100000000001000100100101010000111011101001000011101011101110000101011001111000100001000000000001110010001111000",
            "0001000000000010111010100000010101000010001010111010000000011010000111011101001000011101000000100010111110101000000001000000000010111010100000000000",
            "0000000000111110101010100001000000100010101110101010000101001010000111011101001000011101001010001111101010001000010000000000101110101010100000010000",
            "0001000100000011001010111001111100011010000000000000001001001010000111011101001000011101010110000101111010011001110110001001011010101000011110110000",
            "0001100001000111111111100001011000000011010110111010110000111010000111011101001000011101100010111100100101110001101000110100110000001010101110011000",
            "0000000100111011000000000010100100001100101010000000010010101010000111011101001000011101000110110001110110000100110100110110011001100100000101100000",
            "0000100101111010011110111010100111010100011011011101100111001010000111011101001000011101010000111010000110100000001000010011101011001001110100011000",
            "0000110101000011011010110000110011010000000001001010110010001010000111011101001000011101010000011000111001101110000000110010100001101110101000100000",
            "0001100010000001000111011100101101101010100001111101001000101010000111011101001000011101111010000011010110010111011111010010001000001101100011111000",
            "0000001000100011000000000000110100000000010000001010100100001010000111011101001000011101000010010000000000001001000001011000000001010000000100010000",
            "0000100000110001000000000100000110001011100001001000000000001010000111011101001000011101001010010001010000000111010000000011000001000000000101010000"
        ]

        dummy_burst_filter = grgsm.dummy_burst_filter()
        
        src = grgsm.burst_source(framenumbers_input, timeslots_input, bursts_input)
        sink = grgsm.burst_sink()

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

        self.tb.run()

        bursts_result = list(sink.get_burst_data())
        
        self.assertEqual(bursts_expected, bursts_result)
示例#5
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")
    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")
示例#7
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")
示例#9
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")