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 test_002_sdcch4(self): bursts_expected = [ '0001110111001111101101110111110000001110111011011100110110001001001011100001000100101110100101001001000110101110111110100110100100111111011001011000', '0001011111010100110010101100011000100011000011111000111100010101001111101100010100111111100110001110010110001110000101110000100101010111100100111000', '0001000100110100001010000101011001010000001111001110011010001001001011100001000100101111100011000100111100100010111001010010110100010000110000110000', '0001001100101001010111000101000101000000111101011111000001011010001111011010001000111100110110011000000011010000100110111101110011110011000011010000', '0001110110111100101101010011111100101100100100110001110110111001001011100001000100101110010111011011100001001010010100010101110100011111010101001000', '0000111001001000110010011110000010011101000001010111011011111010011101011000001001110101011101101100101110010111010001100100000011100100111101010000', '0001000001010011101010101011111100010010101110100001000111110010011101011000001001110101100000100101011101111101101101111000001101101010001000101000', '0001101000001011010011001010011010100110010100011010101101011010000111011101001000011101100010011011111111101011100110000011110110001111000101101000', '0001011000010101011100101011111010110101011110011011001011010010001111011010001000111100110111000110100100001100110100000001100100100111101010011000', '0001010101101101101001011100101001110000100101011110100011100010011101011000001001110100111100001000000111000001111100011011101000101100111100111000', '0000010101001010001110001001101101011011000110011011110111111000110101110010000011010110000000110010100100111001010110110011011101011001110100100000', '0001111111000101100000111010111010011010011110110010111000010101001111101100010100111110000110010011101101011111001000010001111111000111001111011000', ] subslot = 2 src = grgsm.burst_source(self.framenumbers_input, self.timeslots_input, self.bursts_input) splitter = grgsm.burst_sdcch_subslot_filter(grgsm.SS_FILTER_SDCCH4, subslot) sink = grgsm.burst_sink() self.tb.msg_connect(src, "out", splitter, "in") self.tb.msg_connect(splitter, "out", sink, "in") self.tb.run() bursts_result = list(sink.get_burst_data()) self.assertEqual(bursts_result, bursts_expected)
def test_002_sdcch4 (self): bursts_expected = [ '0001110111001111101101110111110000001110111011011100110110001001001011100001000100101110100101001001000110101110111110100110100100111111011001011000', '0001011111010100110010101100011000100011000011111000111100010101001111101100010100111111100110001110010110001110000101110000100101010111100100111000', '0001000100110100001010000101011001010000001111001110011010001001001011100001000100101111100011000100111100100010111001010010110100010000110000110000', '0001001100101001010111000101000101000000111101011111000001011010001111011010001000111100110110011000000011010000100110111101110011110011000011010000', '0001110110111100101101010011111100101100100100110001110110111001001011100001000100101110010111011011100001001010010100010101110100011111010101001000', '0000111001001000110010011110000010011101000001010111011011111010011101011000001001110101011101101100101110010111010001100100000011100100111101010000', '0001000001010011101010101011111100010010101110100001000111110010011101011000001001110101100000100101011101111101101101111000001101101010001000101000', '0001101000001011010011001010011010100110010100011010101101011010000111011101001000011101100010011011111111101011100110000011110110001111000101101000', '0001011000010101011100101011111010110101011110011011001011010010001111011010001000111100110111000110100100001100110100000001100100100111101010011000', '0001010101101101101001011100101001110000100101011110100011100010011101011000001001110100111100001000000111000001111100011011101000101100111100111000', '0000010101001010001110001001101101011011000110011011110111111000110101110010000011010110000000110010100100111001010110110011011101011001110100100000', '0001111111000101100000111010111010011010011110110010111000010101001111101100010100111110000110010011101101011111001000010001111111000111001111011000', ] subslot = 2 src = grgsm.burst_source(self.framenumbers_input, self.timeslots_input, self.bursts_input) splitter = grgsm.burst_sdcch_subslot_filter(grgsm.SS_FILTER_SDCCH4, subslot) sink = grgsm.burst_sink() self.tb.msg_connect(src, "out", splitter, "in") self.tb.msg_connect(splitter, "out", sink, "in") self.tb.run () bursts_result = list(sink.get_burst_data()) self.assertEqual(bursts_result, bursts_expected)
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, 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, 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")