def __init__(self, fc=943.6e6, shiftoff=400e3, ppm=0, gain=30, samp_rate=2000000.052982): gr.top_block.__init__(self, "Decode Raw Nogui") ################################################## # Parameters ################################################## self.fc = fc self.shiftoff = shiftoff self.ppm = ppm self.gain = gain self.samp_rate = samp_rate ################################################## # Blocks ################################################## self.gsm_sdcch8_demapper_0 = grgsm.universal_ctrl_chans_demapper(1, ([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.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) self.gsm_message_printer_1 = grgsm.message_printer(pmt.intern(""), False, False, False) self.gsm_input_0 = grgsm.gsm_input( ppm=0, osr=4, fc=fc, samp_rate_in=samp_rate, ) self.gsm_decryption_0 = grgsm.decryption(([]), 1) self.gsm_control_channels_decoder_0_0 = grgsm.control_channels_decoder() self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc-shiftoff) self.gsm_bcch_ccch_demapper_0 = 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.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "4729", 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) self.blocks_rotator_cc_0 = blocks.rotator_cc(-2*pi*shiftoff/samp_rate) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/tmp/gsm_raw", False) ################################################## # Connections ################################################## self.connect((self.blocks_rotator_cc_0, 0), (self.gsm_input_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_rotator_cc_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.gsm_bcch_ccch_demapper_0, "bursts", self.gsm_control_channels_decoder_0, "bursts") self.msg_connect(self.gsm_clock_offset_control_0, "ppm", self.gsm_input_0, "ppm_in") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.blocks_socket_pdu_0, "pdus") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.gsm_message_printer_1, "msgs") self.msg_connect(self.gsm_control_channels_decoder_0_0, "msgs", self.blocks_socket_pdu_0, "pdus") self.msg_connect(self.gsm_control_channels_decoder_0_0, "msgs", self.gsm_message_printer_1, "msgs") self.msg_connect(self.gsm_decryption_0, "bursts", self.gsm_control_channels_decoder_0_0, "bursts") self.msg_connect(self.gsm_receiver_0, "C0", self.gsm_bcch_ccch_demapper_0, "bursts") self.msg_connect(self.gsm_receiver_0, "C0", self.gsm_sdcch8_demapper_0, "bursts") self.msg_connect(self.gsm_receiver_0, "measurements", self.gsm_clock_offset_control_0, "measurements") self.msg_connect(self.gsm_sdcch8_demapper_0, "bursts", self.gsm_decryption_0, "bursts")
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
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, 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 __init__(self, fc=927.2e6): gr.top_block.__init__(self, "Gsm Reciever") ################################################## # Parameters ################################################## self.fc = fc ################################################## # Variables ################################################## self.f_symb = f_symb = 1625000.0/6.0 self.samp_rate = samp_rate = f_symb*4 self.f_900_e = f_900_e = 959.8e6 self.f_900_b = f_900_b = 921.2e6 self.f_1800_e = f_1800_e = 1879.8e6 self.f_1800_b = f_1800_b = 1805.2e6 self.OSR = OSR = 4 self.CCCH = CCCH = 2 self.BCCH = BCCH = 1 ################################################## # Blocks ################################################## self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=0" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(fc, 0) self.osmosdr_source_0.set_freq_corr(0, 0) self.osmosdr_source_0.set_dc_offset_mode(0, 0) self.osmosdr_source_0.set_iq_balance_mode(0, 0) self.osmosdr_source_0.set_gain_mode(True, 0) self.osmosdr_source_0.set_gain(30, 0) self.osmosdr_source_0.set_if_gain(30, 0) self.osmosdr_source_0.set_bb_gain(30, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(200000, 0) self.gsm_universal_ctrl_chans_demapper_0 = grgsm.universal_ctrl_chans_demapper(0, ([2,6,12,16,22,26,32,36,42,46]), ([BCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH])) self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) self.gsm_input_0 = grgsm.gsm_input( ppm=0, osr=4, fc=fc, samp_rate_in=samp_rate, ) self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) ################################################## # Connections ################################################## self.msg_connect((self.gsm_clock_offset_control_0, 'ppm'), (self.gsm_input_0, 'ppm_in')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.gsm_receiver_0, 'measurements'), (self.gsm_clock_offset_control_0, 'measurements')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_universal_ctrl_chans_demapper_0, 'bursts')) self.msg_connect((self.gsm_universal_ctrl_chans_demapper_0, 'bursts'), (self.gsm_control_channels_decoder_0, 'bursts')) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.gsm_input_0, 0))
def __init__(self, input_file_name="input.cfile", fc=937e6, samp_rate=1e6): gr.top_block.__init__(self, "Airprobe File") ################################################## # Parameters ################################################## self.input_file_name = input_file_name self.fc = fc self.samp_rate = samp_rate ################################################## # Variables ################################################## self.SDCCH = SDCCH = 6 self.RACH = RACH = 3 self.PCH = PCH = 5 self.CHANNEL_UNKNOWN = CHANNEL_UNKNOWN = 0 self.CCCH = CCCH = 2 self.BCCH = BCCH = 1 self.AGCH = AGCH = 4 ################################################## # Blocks ################################################## self.gsm_universal_ctrl_chans_demapper_0 = grgsm.universal_ctrl_chans_demapper( 0, ([2, 6, 12, 16, 22, 26, 32, 36, 42, 46]), ([BCCH, CCCH, CCCH, CCCH, CCCH, CCCH, CCCH, CCCH, CCCH, CCCH])) self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) self.gsm_message_printer_0 = grgsm.message_printer(pmt.intern("")) self.gsm_input_0 = grgsm.gsm_input( ppm=0, osr=4, fc=fc, samp_rate_in=samp_rate, ) self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, input_file_name, False) ################################################## # Connections ################################################## self.msg_connect(self.gsm_clock_offset_control_0, 'ppm', self.gsm_input_0, 'ppm_in') self.msg_connect(self.gsm_control_channels_decoder_0, 'msgs', self.blocks_socket_pdu_0, 'pdus') self.msg_connect(self.gsm_control_channels_decoder_0, 'msgs', self.gsm_message_printer_0, 'msgs') self.msg_connect(self.gsm_receiver_0, 'measurements', self.gsm_clock_offset_control_0, 'measurements') self.msg_connect(self.gsm_receiver_0, 'C0', self.gsm_universal_ctrl_chans_demapper_0, 'bursts') self.msg_connect(self.gsm_universal_ctrl_chans_demapper_0, 'bursts', self.gsm_control_channels_decoder_0, 'bursts') self.connect((self.blocks_file_source_0, 0), (self.gsm_input_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0))
def __init__(self, device=None, fc=943.6e6, shiftoff=400e3, ppm=0, gain=30, samp_rate=2000000.052982): gr.top_block.__init__(self, "Tmsi Print Nogui") ################################################## # Parameters ################################################## self.fc = fc self.shiftoff = shiftoff self.ppm = ppm self.gain = gain self.samp_rate = samp_rate if device: self.device = device else: self.device = '' ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + self.device ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(fc-shiftoff, 0) self.rtlsdr_source_0.set_freq_corr(ppm, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(250e3+abs(shiftoff), 0) self.gsm_tmsi_printer_0 = grgsm.tmsi_printer() self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) self.gsm_input_0 = grgsm.gsm_input( ppm=0, osr=4, fc=fc, samp_rate_in=samp_rate, ) self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc-shiftoff) self.gsm_bcch_ccch_demapper_0 = 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.blocks_rotator_cc_0 = blocks.rotator_cc(-2*pi*shiftoff/samp_rate) ################################################## # Connections ################################################## self.connect((self.blocks_rotator_cc_0, 0), (self.gsm_input_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_rotator_cc_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.gsm_bcch_ccch_demapper_0, "bursts", self.gsm_control_channels_decoder_0, "bursts") self.msg_connect(self.gsm_clock_offset_control_0, "ppm", self.gsm_input_0, "ppm_in") self.msg_connect(self.gsm_receiver_0, "C0", self.gsm_bcch_ccch_demapper_0, "bursts") self.msg_connect(self.gsm_receiver_0, "measurements", self.gsm_clock_offset_control_0, "measurements") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.gsm_tmsi_printer_0, "msgs")
def __init__(self, OSR=4, chan_num=0, fc=939.4e6, ppm=0, samp_rate=0.2e6): grgsm.hier_block.__init__( self, "Receiver With Decoder", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signature(0, 0, 0), ) self.message_port_register_hier_out("bursts") self.message_port_register_hier_out("msgs") ################################################## # Parameters ################################################## self.OSR = OSR self.chan_num = chan_num self.fc = fc self.ppm = ppm self.samp_rate = samp_rate ################################################## # Variables ################################################## self.samp_rate_out = samp_rate_out = 1625000.0 / 6.0 * OSR ################################################## # Blocks ################################################## self.gsm_receiver_0 = grgsm.receiver(OSR, ([chan_num]), ([])) self.gsm_input_0 = grgsm.gsm_input( ppm=ppm, osr=OSR, fc=fc, samp_rate_in=samp_rate, ) self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc, samp_rate, osr=4) self.gsm_bcch_ccch_demapper_0 = grgsm.gsm_bcch_ccch_demapper(0) ################################################## # Connections ################################################## self.msg_connect(self.gsm_bcch_ccch_demapper_0, 'bursts', self, 'bursts') self.msg_connect(self.gsm_bcch_ccch_demapper_0, 'bursts', self.gsm_control_channels_decoder_0, 'bursts') self.msg_connect(self.gsm_clock_offset_control_0, 'ctrl', self.gsm_input_0, 'ctrl_in') self.msg_connect(self.gsm_control_channels_decoder_0, 'msgs', self, 'msgs') self.msg_connect(self.gsm_receiver_0, 'C0', self.gsm_bcch_ccch_demapper_0, 'bursts') self.msg_connect(self.gsm_receiver_0, 'measurements', self.gsm_clock_offset_control_0, 'measurements') self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self, 0), (self.gsm_input_0, 0))
def __init__(self): gr.top_block.__init__(self, "Uplink decoding demo") ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 ################################################## # Blocks ################################################## self.gsm_sdcch8_demapper_0 = grgsm.gsm_sdcch8_demapper(timeslot_nr=1) self.gsm_receiver_with_uplink_0 = grgsm.receiver(4, ([0]), ([2]), True) self.gsm_message_printer_0_0 = grgsm.message_printer(pmt.intern(""), False, False, False) self.gsm_input_0_0 = grgsm.gsm_input(ppm=0, osr=4, fc=947.8e6 - 45e6, samp_rate_in=samp_rate) self.gsm_input_0 = grgsm.gsm_input(ppm=0, osr=4, fc=947.8e6, samp_rate_in=samp_rate) self.gsm_decryption_0_3 = grgsm.decryption(([0x46, 0x77, 0x2D, 0x54, 0xA3, 0xA3, 0xC3, 0x1C]), 1) self.gsm_control_channels_decoder_0_1_0 = grgsm.control_channels_decoder() self.gsm_control_channels_decoder_0_1 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(947.8e6) self.blocks_socket_pdu_0_0_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) self.blocks_file_source_0_0 = blocks.file_source(gr.sizeof_gr_complex * 1, "sms_multirtl_uplink_tail", False) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex * 1, "sms_multirtl_downlink_tail", False) ################################################## # Connections ################################################## self.msg_connect((self.gsm_clock_offset_control_0, "ppm"), (self.gsm_input_0, "ppm_in")) self.msg_connect((self.gsm_clock_offset_control_0, "ppm"), (self.gsm_input_0_0, "ppm_in")) self.msg_connect((self.gsm_control_channels_decoder_0_1, "msgs"), (self.blocks_socket_pdu_0_0_0, "pdus")) self.msg_connect((self.gsm_control_channels_decoder_0_1, "msgs"), (self.gsm_message_printer_0_0, "msgs")) self.msg_connect((self.gsm_control_channels_decoder_0_1_0, "msgs"), (self.blocks_socket_pdu_0_0_0, "pdus")) self.msg_connect((self.gsm_control_channels_decoder_0_1_0, "msgs"), (self.gsm_message_printer_0_0, "msgs")) self.msg_connect((self.gsm_decryption_0_3, "bursts"), (self.gsm_control_channels_decoder_0_1_0, "bursts")) self.msg_connect( (self.gsm_receiver_with_uplink_0, "measurements"), (self.gsm_clock_offset_control_0, "measurements") ) self.msg_connect((self.gsm_receiver_with_uplink_0, "C0"), (self.gsm_sdcch8_demapper_0, "bursts")) self.msg_connect((self.gsm_sdcch8_demapper_0, "bursts"), (self.gsm_control_channels_decoder_0_1, "bursts")) self.msg_connect((self.gsm_sdcch8_demapper_0, "bursts"), (self.gsm_decryption_0_3, "bursts")) self.connect((self.blocks_file_source_0, 0), (self.gsm_input_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.gsm_input_0_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_with_uplink_0, 0)) self.connect((self.gsm_input_0_0, 0), (self.gsm_receiver_with_uplink_0, 1))
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'))
def __init__(self, OSR=4, chan_num=0, fc=939.4e6, ppm=0, samp_rate=0.2e6): grgsm.hier_block.__init__( self, "Receiver With Decoder", gr.io_signature(1, 1, gr.sizeof_gr_complex * 1), gr.io_signature(0, 0, 0), ) self.message_port_register_hier_out("bursts") self.message_port_register_hier_out("msgs") ################################################## # Parameters ################################################## self.OSR = OSR self.chan_num = chan_num self.fc = fc self.ppm = ppm self.samp_rate = samp_rate ################################################## # Variables ################################################## self.samp_rate_out = 1625000.0 / 6.0 * OSR ################################################## # Blocks ################################################## self.gsm_receiver_0 = grgsm.receiver(OSR, ([chan_num]), ([])) self.gsm_input_0 = grgsm.gsm_input( ppm=ppm, osr=OSR, fc=fc, samp_rate_in=samp_rate, ) self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc) self.gsm_bcch_ccch_demapper_0 = grgsm.gsm_bcch_ccch_demapper(0) ################################################## # Connections ################################################## self.msg_connect(self.gsm_bcch_ccch_demapper_0, 'bursts', self, 'bursts') self.msg_connect(self.gsm_bcch_ccch_demapper_0, 'bursts', self.gsm_control_channels_decoder_0, 'bursts') self.msg_connect(self.gsm_clock_offset_control_0, 'ppm', self.gsm_input_0, 'ppm_in') self.msg_connect(self.gsm_control_channels_decoder_0, 'msgs', self, 'msgs') self.msg_connect(self.gsm_receiver_0, 'C0', self.gsm_bcch_ccch_demapper_0, 'bursts') self.msg_connect(self.gsm_receiver_0, 'measurements', self.gsm_clock_offset_control_0, 'measurements') self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self, 0), (self.gsm_input_0, 0))
def __init__(self, fc=943.6e6, shiftoff=400e3, ppm=0, gain=30, samp_rate=2000000.052982): gr.top_block.__init__(self, "Decode Bursts Nogui") ################################################## # Parameters ################################################## self.fc = fc self.shiftoff = shiftoff self.ppm = ppm self.gain = gain self.samp_rate = samp_rate ################################################## # Blocks ################################################## self.gsm_sdcch8_demapper_0 = grgsm.universal_ctrl_chans_demapper(1, ([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.gsm_message_printer_1 = grgsm.message_printer(pmt.intern(""), False, False, False) self.gsm_decryption_0 = grgsm.decryption(([]), 1) self.gsm_control_channels_decoder_0_0 = grgsm.control_channels_decoder() self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_burst_file_source_0 = grgsm.burst_file_source("/tmp/bursts") self.gsm_bcch_ccch_demapper_0 = 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.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "4729", 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.gsm_sdcch8_demapper_0, "bursts", self.gsm_decryption_0, "bursts") self.msg_connect(self.gsm_decryption_0, "bursts", self.gsm_control_channels_decoder_0_0, "bursts") self.msg_connect(self.gsm_control_channels_decoder_0_0, "msgs", self.gsm_message_printer_1, "msgs") self.msg_connect(self.gsm_control_channels_decoder_0_0, "msgs", self.blocks_socket_pdu_0, "pdus") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.gsm_message_printer_1, "msgs") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.blocks_socket_pdu_0, "pdus") self.msg_connect(self.gsm_bcch_ccch_demapper_0, "bursts", self.gsm_control_channels_decoder_0, "bursts") self.msg_connect(self.gsm_burst_file_source_0, "out", self.gsm_bcch_ccch_demapper_0, "bursts") self.msg_connect(self.gsm_burst_file_source_0, "out", self.gsm_sdcch8_demapper_0, "bursts")
def __init__(self, input_file_name="input.cfile", fc=937e6, samp_rate=1e6): gr.top_block.__init__(self, "Airprobe File") ################################################## # Parameters ################################################## self.input_file_name = input_file_name self.fc = fc self.samp_rate = samp_rate ################################################## # Variables ################################################## self.SDCCH = SDCCH = 6 self.RACH = RACH = 3 self.PCH = PCH = 5 self.CHANNEL_UNKNOWN = CHANNEL_UNKNOWN = 0 self.CCCH = CCCH = 2 self.BCCH = BCCH = 1 self.AGCH = AGCH = 4 ################################################## # Blocks ################################################## self.gsm_universal_ctrl_chans_demapper_0 = grgsm.universal_ctrl_chans_demapper(0, ([2,6,12,16,22,26,32,36,42,46]), ([BCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH])) self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) self.gsm_message_printer_0 = grgsm.message_printer(pmt.intern("")) self.gsm_input_0 = grgsm.gsm_input( ppm=0, osr=4, fc=fc, samp_rate_in=samp_rate, ) self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, input_file_name, False) ################################################## # Connections ################################################## self.msg_connect(self.gsm_clock_offset_control_0, 'ppm', self.gsm_input_0, 'ppm_in') self.msg_connect(self.gsm_control_channels_decoder_0, 'msgs', self.blocks_socket_pdu_0, 'pdus') self.msg_connect(self.gsm_control_channels_decoder_0, 'msgs', self.gsm_message_printer_0, 'msgs') self.msg_connect(self.gsm_receiver_0, 'measurements', self.gsm_clock_offset_control_0, 'measurements') self.msg_connect(self.gsm_receiver_0, 'C0', self.gsm_universal_ctrl_chans_demapper_0, 'bursts') self.msg_connect(self.gsm_universal_ctrl_chans_demapper_0, 'bursts', self.gsm_control_channels_decoder_0, 'bursts') self.connect((self.blocks_file_source_0, 0), (self.gsm_input_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0))
def __init__(self): gr.hier_block2.__init__( self, "Cmc Analyzer Block", gr.io_signature(0, 0, 0), gr.io_signature(0, 0, 0), ) self.message_port_register_hier_in("in") self.decoder = grgsm.control_channels_decoder() self.extract_system_info = grgsm.extract_system_info() self.extract_cmc = grgsm.extract_cmc() self.collect_system_info = grgsm.collect_system_info() self.msg_connect((self.decoder, 'msgs'), (self.extract_cmc, 'msgs')) self.msg_connect((self.decoder, 'msgs'), (self.extract_system_info, 'msgs')) self.msg_connect((self.decoder, 'msgs'), (self.collect_system_info, 'msgs')) self.msg_connect((self, 'in'), (self.decoder, 'bursts'))
def __init__(self, fc=937e6, input_file_name="input.cfile", samp_rate=100.0e6/174.0, osr=4): gr.top_block.__init__(self, "Get Bcch Msgs From Cfile") ################################################## # Parameters ################################################## self.fc = fc self.input_file_name = input_file_name self.samp_rate = samp_rate self.osr = osr ################################################## # Blocks ################################################## self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([]), False) self.gsm_message_printer_0 = grgsm.message_printer(pmt.intern(""), False, False, False) self.gsm_input_0 = grgsm.gsm_input( ppm=0, osr=osr, fc=fc, samp_rate_in=samp_rate, ) self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc, samp_rate, osr) self.gsm_bcch_ccch_demapper_0 = grgsm.gsm_bcch_ccch_demapper( timeslot_nr=0, ) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "4729", 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/home/piotr/Odbiornik_gsm/gr-gsm/test_data/vf_call6_a725_d174_g5_Kc1EF00BAB3BAC7002.cfile", False) ################################################## # Connections ################################################## self.msg_connect((self.gsm_bcch_ccch_demapper_0, 'bursts'), (self.gsm_control_channels_decoder_0, 'bursts')) self.msg_connect((self.gsm_clock_offset_control_0, 'ctrl'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.gsm_clock_offset_control_0, 'ctrl'), (self.gsm_input_0, 'ctrl_in')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.gsm_message_printer_0, 'msgs')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_bcch_ccch_demapper_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'measurements'), (self.gsm_clock_offset_control_0, 'measurements')) self.connect((self.blocks_file_source_0, 0), (self.gsm_input_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0))
def __init__(self, fc=939.4e6, gain=30, samp_rate=2000000.052982, ppm=0): gr.top_block.__init__(self, "Airprobe Rtlsdr") Qt.QWidget.__init__(self) self.setWindowTitle("Airprobe Rtlsdr") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "airprobe_rtlsdr") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.fc = fc self.gain = gain self.samp_rate = samp_rate self.ppm = ppm ################################################## # Variables ################################################## self.ppm_slider = ppm_slider = ppm self.g_slider = g_slider = gain self.fc_slider = fc_slider = fc self.SDCCH = SDCCH = 6 self.SACCH = SACCH = 0x80 self.RACH = RACH = 3 self.PCH = PCH = 5 self.CHANNEL_UNKNOWN = CHANNEL_UNKNOWN = 0 self.CCCH = CCCH = 2 self.BCCH = BCCH = 1 self.AGCH = AGCH = 4 ################################################## # Blocks ################################################## self._ppm_slider_layout = Qt.QHBoxLayout() self._ppm_slider_layout.addWidget(Qt.QLabel("PPM Offset" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._ppm_slider_counter = qwt_counter_pyslot() self._ppm_slider_counter.setRange(-150, 150, 1) self._ppm_slider_counter.setNumButtons(2) self._ppm_slider_counter.setMinimumWidth(100) self._ppm_slider_counter.setValue(self.ppm_slider) self._ppm_slider_layout.addWidget(self._ppm_slider_counter) self._ppm_slider_counter.valueChanged.connect(self.set_ppm_slider) self.top_layout.addLayout(self._ppm_slider_layout) self._g_slider_layout = Qt.QHBoxLayout() self._g_slider_layout.addWidget(Qt.QLabel("Gain" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._g_slider_counter = qwt_counter_pyslot() self._g_slider_counter.setRange(0, 50, 0.5) self._g_slider_counter.setNumButtons(2) self._g_slider_counter.setMinimumWidth(100) self._g_slider_counter.setValue(self.g_slider) self._g_slider_layout.addWidget(self._g_slider_counter) self._g_slider_counter.valueChanged.connect(self.set_g_slider) self.top_layout.addLayout(self._g_slider_layout) self._fc_slider_layout = Qt.QVBoxLayout() self._fc_slider_tool_bar = Qt.QToolBar(self) self._fc_slider_layout.addWidget(self._fc_slider_tool_bar) self._fc_slider_tool_bar.addWidget(Qt.QLabel("Frequency" + ": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._fc_slider_counter = qwt_counter_pyslot() self._fc_slider_counter.setRange(925e6, 1990e6, 2e5) self._fc_slider_counter.setNumButtons(2) self._fc_slider_counter.setValue(self.fc_slider) self._fc_slider_tool_bar.addWidget(self._fc_slider_counter) self._fc_slider_counter.valueChanged.connect(self.set_fc_slider) self._fc_slider_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._fc_slider_slider.setRange(925e6, 1990e6, 2e5) self._fc_slider_slider.setValue(self.fc_slider) self._fc_slider_slider.setMinimumWidth(100) self._fc_slider_slider.valueChanged.connect(self.set_fc_slider) self._fc_slider_layout.addWidget(self._fc_slider_slider) self.top_layout.addLayout(self._fc_slider_layout) self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(fc_slider, 0) self.rtlsdr_source_0.set_freq_corr(ppm_slider, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(True, 0) self.rtlsdr_source_0.set_gain(g_slider, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(250e3, 0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype fc_slider, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.gsm_universal_ctrl_chans_demapper_0 = grgsm.universal_ctrl_chans_demapper( 0, ([2, 6, 12, 16, 22, 26, 32, 36, 42, 46]), ([BCCH, CCCH, CCCH, CCCH, CCCH, CCCH, CCCH, CCCH, CCCH, CCCH])) self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) self.gsm_message_printer_1 = grgsm.message_printer(pmt.intern("")) self.gsm_input_0 = grgsm.gsm_input( ppm=0, osr=4, fc=fc, samp_rate_in=samp_rate, ) self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) ################################################## # Connections ################################################## self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.gsm_input_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.gsm_receiver_0, "C0", self.gsm_universal_ctrl_chans_demapper_0, "bursts") self.msg_connect(self.gsm_clock_offset_control_0, "ppm", self.gsm_input_0, "ppm_in") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.gsm_message_printer_1, "msgs") self.msg_connect(self.gsm_universal_ctrl_chans_demapper_0, "bursts", self.gsm_control_channels_decoder_0, "bursts") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.blocks_socket_pdu_0, "pdus") self.msg_connect(self.gsm_receiver_0, "measurements", self.gsm_clock_offset_control_0, "measurements")
def __init__(self, fc=943.6e6, shiftoff=400e3, ppm=0, gain=30, samp_rate=2000000.052982): gr.top_block.__init__(self, "Airprobe Rtlsdr Nogui") ################################################## # Parameters ################################################## self.fc = fc self.shiftoff = shiftoff self.ppm = ppm self.gain = gain self.samp_rate = samp_rate ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(fc-shiftoff, 0) self.rtlsdr_source_0.set_freq_corr(ppm, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(250e3+abs(shiftoff), 0) self.gsm_sdcch8_demapper_0 = grgsm.universal_ctrl_chans_demapper(1, ([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.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) self.gsm_message_printer_1 = grgsm.message_printer(pmt.intern(""), False, False, False) self.gsm_input_0 = grgsm.gsm_input( ppm=0, osr=4, fc=fc, samp_rate_in=samp_rate, ) self.gsm_decryption_0 = grgsm.decryption(([]), 1) self.gsm_control_channels_decoder_0_0 = grgsm.control_channels_decoder() self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc-shiftoff) self.gsm_bcch_ccch_demapper_0 = 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.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "4729", 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) self.blocks_rotator_cc_0 = blocks.rotator_cc(-2*pi*shiftoff/samp_rate) ################################################## # Connections ################################################## self.connect((self.blocks_rotator_cc_0, 0), (self.gsm_input_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_rotator_cc_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.gsm_bcch_ccch_demapper_0, "bursts", self.gsm_control_channels_decoder_0, "bursts") self.msg_connect(self.gsm_clock_offset_control_0, "ppm", self.gsm_input_0, "ppm_in") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.blocks_socket_pdu_0, "pdus") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.gsm_message_printer_1, "msgs") self.msg_connect(self.gsm_control_channels_decoder_0_0, "msgs", self.blocks_socket_pdu_0, "pdus") self.msg_connect(self.gsm_control_channels_decoder_0_0, "msgs", self.gsm_message_printer_1, "msgs") self.msg_connect(self.gsm_decryption_0, "bursts", self.gsm_control_channels_decoder_0_0, "bursts") self.msg_connect(self.gsm_receiver_0, "C0", self.gsm_bcch_ccch_demapper_0, "bursts") self.msg_connect(self.gsm_receiver_0, "C0", self.gsm_sdcch8_demapper_0, "bursts") self.msg_connect(self.gsm_receiver_0, "measurements", self.gsm_clock_offset_control_0, "measurements") self.msg_connect(self.gsm_sdcch8_demapper_0, "bursts", self.gsm_decryption_0, "bursts")
def __init__(self, gain=30, ppm=0, samp_rate=2000000.052982, shiftoff=400e3, fc=943.6e6): gr.top_block.__init__(self, "Decode Raw") Qt.QWidget.__init__(self) self.setWindowTitle("Decode Raw") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "decode_raw") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.gain = gain self.ppm = ppm self.samp_rate = samp_rate self.shiftoff = shiftoff self.fc = fc ################################################## # Variables ################################################## self.ppm_slider = ppm_slider = ppm self.g_slider = g_slider = gain self.fc_slider = fc_slider = fc ################################################## # Blocks ################################################## self._fc_slider_layout = Qt.QVBoxLayout() self._fc_slider_tool_bar = Qt.QToolBar(self) self._fc_slider_layout.addWidget(self._fc_slider_tool_bar) self._fc_slider_tool_bar.addWidget(Qt.QLabel("Frequency"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._fc_slider_counter = qwt_counter_pyslot() self._fc_slider_counter.setRange(925e6, 1990e6, 2e5) self._fc_slider_counter.setNumButtons(2) self._fc_slider_counter.setValue(self.fc_slider) self._fc_slider_tool_bar.addWidget(self._fc_slider_counter) self._fc_slider_counter.valueChanged.connect(self.set_fc_slider) self._fc_slider_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._fc_slider_slider.setRange(925e6, 1990e6, 2e5) self._fc_slider_slider.setValue(self.fc_slider) self._fc_slider_slider.setMinimumWidth(100) self._fc_slider_slider.valueChanged.connect(self.set_fc_slider) self._fc_slider_layout.addWidget(self._fc_slider_slider) self.top_layout.addLayout(self._fc_slider_layout) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype fc_slider, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self._ppm_slider_layout = Qt.QHBoxLayout() self._ppm_slider_layout.addWidget(Qt.QLabel("PPM Offset"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._ppm_slider_counter = qwt_counter_pyslot() self._ppm_slider_counter.setRange(-150, 150, 1) self._ppm_slider_counter.setNumButtons(2) self._ppm_slider_counter.setMinimumWidth(100) self._ppm_slider_counter.setValue(self.ppm_slider) self._ppm_slider_layout.addWidget(self._ppm_slider_counter) self._ppm_slider_counter.valueChanged.connect(self.set_ppm_slider) self.top_layout.addLayout(self._ppm_slider_layout) self.gsm_sdcch8_demapper_0 = grgsm.universal_ctrl_chans_demapper(1, ([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.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) self.gsm_message_printer_1 = grgsm.message_printer(pmt.intern(""), False, False, False) self.gsm_input_0 = grgsm.gsm_input( ppm=0, osr=4, fc=fc, samp_rate_in=samp_rate, ) self.gsm_decryption_0 = grgsm.decryption(([]), 1) self.gsm_control_channels_decoder_0_0 = grgsm.control_channels_decoder() self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc-shiftoff) self.gsm_bcch_ccch_demapper_0 = 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._g_slider_layout = Qt.QHBoxLayout() self._g_slider_layout.addWidget(Qt.QLabel("Gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._g_slider_counter = qwt_counter_pyslot() self._g_slider_counter.setRange(0, 50, 0.5) self._g_slider_counter.setNumButtons(2) self._g_slider_counter.setMinimumWidth(100) self._g_slider_counter.setValue(self.g_slider) self._g_slider_layout.addWidget(self._g_slider_counter) self._g_slider_counter.valueChanged.connect(self.set_g_slider) self.top_layout.addLayout(self._g_slider_layout) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "4729", 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) self.blocks_rotator_cc_0 = blocks.rotator_cc(-2*pi*shiftoff/samp_rate) self.blocks_file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, "/tmp/gsm_raw", False) ################################################## # Connections ################################################## self.connect((self.blocks_rotator_cc_0, 0), (self.gsm_input_0, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self.blocks_file_source_0, 0), (self.blocks_rotator_cc_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.gsm_bcch_ccch_demapper_0, "bursts", self.gsm_control_channels_decoder_0, "bursts") self.msg_connect(self.gsm_clock_offset_control_0, "ppm", self.gsm_input_0, "ppm_in") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.blocks_socket_pdu_0, "pdus") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.gsm_message_printer_1, "msgs") self.msg_connect(self.gsm_control_channels_decoder_0_0, "msgs", self.blocks_socket_pdu_0, "pdus") self.msg_connect(self.gsm_control_channels_decoder_0_0, "msgs", self.gsm_message_printer_1, "msgs") self.msg_connect(self.gsm_decryption_0, "bursts", self.gsm_control_channels_decoder_0_0, "bursts") self.msg_connect(self.gsm_receiver_0, "C0", self.gsm_bcch_ccch_demapper_0, "bursts") self.msg_connect(self.gsm_receiver_0, "C0", self.gsm_sdcch8_demapper_0, "bursts") self.msg_connect(self.gsm_receiver_0, "measurements", self.gsm_clock_offset_control_0, "measurements") self.msg_connect(self.gsm_sdcch8_demapper_0, "bursts", self.gsm_decryption_0, "bursts")
def __init__(self, gain=30, ppm=0, samp_rate=2000000.052982, shiftoff=400e3, fc=943.6e6): gr.top_block.__init__(self, "Decode Bursts") Qt.QWidget.__init__(self) self.setWindowTitle("Decode Bursts") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "decode_bursts") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.gain = gain self.ppm = ppm self.samp_rate = samp_rate self.shiftoff = shiftoff self.fc = fc ################################################## # Variables ################################################## self.ppm_slider = ppm_slider = ppm self.g_slider = g_slider = gain self.fc_slider = fc_slider = fc ################################################## # Blocks ################################################## self._ppm_slider_layout = Qt.QHBoxLayout() self._ppm_slider_layout.addWidget(Qt.QLabel("PPM Offset"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._ppm_slider_counter = qwt_counter_pyslot() self._ppm_slider_counter.setRange(-150, 150, 1) self._ppm_slider_counter.setNumButtons(2) self._ppm_slider_counter.setMinimumWidth(100) self._ppm_slider_counter.setValue(self.ppm_slider) self._ppm_slider_layout.addWidget(self._ppm_slider_counter) self._ppm_slider_counter.valueChanged.connect(self.set_ppm_slider) self.top_layout.addLayout(self._ppm_slider_layout) self.gsm_sdcch8_demapper_0 = grgsm.universal_ctrl_chans_demapper(1, ([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.gsm_message_printer_1 = grgsm.message_printer(pmt.intern(""), False, False, False) self.gsm_decryption_0 = grgsm.decryption(([]), 1) self.gsm_control_channels_decoder_0_0 = grgsm.control_channels_decoder() self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_burst_file_source_0 = grgsm.burst_file_source("/tmp/bursts") self.gsm_bcch_ccch_demapper_0 = 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._g_slider_layout = Qt.QHBoxLayout() self._g_slider_layout.addWidget(Qt.QLabel("Gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._g_slider_counter = qwt_counter_pyslot() self._g_slider_counter.setRange(0, 50, 0.5) self._g_slider_counter.setNumButtons(2) self._g_slider_counter.setMinimumWidth(100) self._g_slider_counter.setValue(self.g_slider) self._g_slider_layout.addWidget(self._g_slider_counter) self._g_slider_counter.valueChanged.connect(self.set_g_slider) self.top_layout.addLayout(self._g_slider_layout) self._fc_slider_layout = Qt.QVBoxLayout() self._fc_slider_tool_bar = Qt.QToolBar(self) self._fc_slider_layout.addWidget(self._fc_slider_tool_bar) self._fc_slider_tool_bar.addWidget(Qt.QLabel("Frequency"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._fc_slider_counter = qwt_counter_pyslot() self._fc_slider_counter.setRange(925e6, 1990e6, 2e5) self._fc_slider_counter.setNumButtons(2) self._fc_slider_counter.setValue(self.fc_slider) self._fc_slider_tool_bar.addWidget(self._fc_slider_counter) self._fc_slider_counter.valueChanged.connect(self.set_fc_slider) self._fc_slider_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._fc_slider_slider.setRange(925e6, 1990e6, 2e5) self._fc_slider_slider.setValue(self.fc_slider) self._fc_slider_slider.setMinimumWidth(100) self._fc_slider_slider.valueChanged.connect(self.set_fc_slider) self._fc_slider_layout.addWidget(self._fc_slider_slider) self.top_layout.addLayout(self._fc_slider_layout) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "4729", 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.gsm_burst_file_source_0, "out", self.gsm_sdcch8_demapper_0, "bursts") self.msg_connect(self.gsm_burst_file_source_0, "out", self.gsm_bcch_ccch_demapper_0, "bursts") self.msg_connect(self.gsm_bcch_ccch_demapper_0, "bursts", self.gsm_control_channels_decoder_0, "bursts") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.blocks_socket_pdu_0, "pdus") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.gsm_message_printer_1, "msgs") self.msg_connect(self.gsm_control_channels_decoder_0_0, "msgs", self.blocks_socket_pdu_0, "pdus") self.msg_connect(self.gsm_control_channels_decoder_0_0, "msgs", self.gsm_message_printer_1, "msgs") self.msg_connect(self.gsm_decryption_0, "bursts", self.gsm_control_channels_decoder_0_0, "bursts") self.msg_connect(self.gsm_sdcch8_demapper_0, "bursts", self.gsm_decryption_0, "bursts")
def __init__(self, gain=None, samp_rate=None, ppm=None, arfcn=None, capture_id=None, udp_ports=[], max_timeslot=0, store_capture=True, verbose=False, band=None, rec_length=None, test=False, args=""): """ capture_id = identifier for the capture used to store the files (e.g. <capture_id>.cfile) store_capture = boolean indicating if the capture should be stored on disk or not rec_length = capture time in seconds max_timeslot = timeslot 0...max_timeslot will be decoded udp_ports = a list of udp ports to send the captured GSMTap frames to """ gr.top_block.__init__(self, "Gr-gsm Capture") ################################################## # 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.gain = gain self.samp_rate = samp_rate self.ppm = ppm self.arfcn = arfcn self.band = band self.shiftoff = shiftoff = 400e3 self.rec_length = rec_length self.store_capture = store_capture self.capture_id = capture_id self.udp_ports = udp_ports self.verbose = verbose ################################################## # Processing Blocks ################################################## self.rtlsdr_source = osmosdr.source(args="numchan=" + str(1) + " " + "") self.rtlsdr_source.set_sample_rate(samp_rate) self.rtlsdr_source.set_center_freq(self.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) #RUn for the specified amount of seconds or indefenitely if self.rec_length is not None: self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex, int(samp_rate * rec_length)) self.gsm_receiver = grgsm.receiver(4, ([self.arfcn]), ([])) self.gsm_input = grgsm.gsm_input( ppm=0, osr=4, fc=self.fc, samp_rate_in=samp_rate, ) self.gsm_clock_offset_control = grgsm.clock_offset_control(self.fc - shiftoff) #Control channel demapper for timeslot 0 #self.gsm_bcch_ccch_demapper_0 = 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.gsm_bcch_ccch_demapper_0 = grgsm.gsm_bcch_ccch_demapper(0) #For all other timeslots are assumed to contain sdcch8 logical channels, this demapping may be incorrect if max_timeslot >= 1 and max_timeslot <= 8: self.gsm_sdcch8_demappers = [] for i in range(1, max_timeslot + 1): #self.gsm_sdcch8_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.gsm_sdcch8_demappers.append(grgsm.gsm_sdcch8_demapper(i)) #Control channel decoder (extracts the packets), one for each timeslot self.gsm_control_channels_decoders = [] for i in range(0, max_timeslot + 1): self.gsm_control_channels_decoders.append( grgsm.control_channels_decoder()) # self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False)# self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) #UDP client that sends all decoded C0T0 packets to the specified port on localhost if requested self.client_sockets = [] self.server_sockets = [] for udp_port in self.udp_ports: #The server is for testing only #WARNING remove the server if you want connect to a different one if test: self.server_sockets.append( blocks.socket_pdu("UDP_SERVER", "127.0.0.1", str(udp_port), 10000)) self.client_sockets.append( blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", str(udp_port), 10000)) #Sinks to store the capture file if requested if self.store_capture: self.gsm_burst_file_sink = grgsm.burst_file_sink( str(self.capture_id) + ".burstfile") self.blocks_file_sink = blocks.file_sink( gr.sizeof_gr_complex * 1, str(self.capture_id) + ".cfile", False) self.blocks_file_sink.set_unbuffered(False) #Printer for printing messages when verbose flag is True if self.verbose: self.gsm_message_printer = grgsm.message_printer( pmt.intern(""), False) """ if self.verbose: self.gsm_bursts_printer_0 = grgsm.bursts_printer(pmt.intern(""), False, False, False, False) """ ################################################## # Connections ################################################## if self.rec_length is not None: #if recording length is defined connect head block after the source self.connect((self.rtlsdr_source, 0), (self.blocks_head_0, 0)) self.connect((self.blocks_head_0, 0), (self.blocks_rotator, 0)) else: self.connect((self.rtlsdr_source, 0), (self.blocks_rotator, 0)) #Connect the file sinks if self.store_capture: self.connect((self.blocks_rotator, 0), (self.blocks_file_sink, 0)) self.msg_connect(self.gsm_receiver, "C0", self.gsm_burst_file_sink, "in") #Connect the GSM receiver 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, "ppm", self.gsm_input, "ppm_in") self.msg_connect(self.gsm_receiver, "measurements", self.gsm_clock_offset_control, "measurements") #Connect the demapper and decoder for timeslot 0 self.msg_connect((self.gsm_receiver, 'C0'), (self.gsm_bcch_ccch_demapper_0, 'bursts')) self.msg_connect((self.gsm_bcch_ccch_demapper_0, 'bursts'), (self.gsm_control_channels_decoders[0], 'bursts')) #Connect the demapper and decoders for the other timeslots for i in range(1, max_timeslot + 1): self.msg_connect((self.gsm_receiver, 'C0'), (self.gsm_sdcch8_demappers[i - 1], 'bursts')) self.msg_connect((self.gsm_sdcch8_demappers[i - 1], 'bursts'), (self.gsm_control_channels_decoders[i], 'bursts')) #Connect the UDP clients if requested for client_socket in self.client_sockets: for i in range(0, max_timeslot + 1): self.msg_connect( (self.gsm_control_channels_decoders[i], 'msgs'), (client_socket, 'pdus')) #Connect the printer is self.verbose is True if self.verbose: for i in range(0, max_timeslot + 1): self.msg_connect( (self.gsm_control_channels_decoders[i], 'msgs'), (self.gsm_message_printer, 'msgs')) """
def __init__(self, gain=30, ppm=0, samp_rate=2000000.052982, shiftoff=400e3, fc=939.4e6*0+948e6): gr.top_block.__init__(self, "Airprobe Bladerf") Qt.QWidget.__init__(self) self.setWindowTitle("Airprobe Bladerf") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "airprobe_bladerf") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.gain = gain self.ppm = ppm self.samp_rate = samp_rate self.shiftoff = shiftoff self.fc = fc ################################################## # Variables ################################################## self.ppm_slider = ppm_slider = ppm self.g_slider = g_slider = gain self.fc_slider = fc_slider = fc ################################################## # Blocks ################################################## self._ppm_slider_range = Range(-150, 150, 1, ppm, 100) self._ppm_slider_win = RangeWidget(self._ppm_slider_range, self.set_ppm_slider, "PPM Offset", "counter") self.top_layout.addWidget(self._ppm_slider_win) self._g_slider_range = Range(0, 50, 0.5, gain, 100) self._g_slider_win = RangeWidget(self._g_slider_range, self.set_g_slider, "Gain", "counter") self.top_layout.addWidget(self._g_slider_win) self._fc_slider_range = Range(925e6, 1990e6, 2e5, fc, 100) self._fc_slider_win = RangeWidget(self._fc_slider_range, self.set_fc_slider, "Frequency", "counter_slider") self.top_layout.addWidget(self._fc_slider_win) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype fc_slider, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.osmosdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "bladerf=0" ) self.osmosdr_source_0.set_sample_rate(samp_rate) self.osmosdr_source_0.set_center_freq(fc_slider-shiftoff, 0) self.osmosdr_source_0.set_freq_corr(ppm_slider, 0) self.osmosdr_source_0.set_dc_offset_mode(2, 0) self.osmosdr_source_0.set_iq_balance_mode(2, 0) self.osmosdr_source_0.set_gain_mode(False, 0) self.osmosdr_source_0.set_gain(g_slider, 0) self.osmosdr_source_0.set_if_gain(20, 0) self.osmosdr_source_0.set_bb_gain(20, 0) self.osmosdr_source_0.set_antenna("", 0) self.osmosdr_source_0.set_bandwidth(250e3+abs(shiftoff), 0) self.gsm_sdcch8_demapper_0 = grgsm.universal_ctrl_chans_demapper(1, ([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.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) self.gsm_message_printer_1 = grgsm.message_printer(pmt.intern(""), False, False, False) self.gsm_input_0 = grgsm.gsm_input( ppm=0, osr=4, fc=fc, samp_rate_in=samp_rate, ) self.gsm_decryption_0 = grgsm.decryption(([]), 1) self.gsm_control_channels_decoder_0_0 = grgsm.control_channels_decoder() self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc-shiftoff) self.gsm_bcch_ccch_demapper_0 = 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.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "4729", 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) self.blocks_rotator_cc_0 = blocks.rotator_cc(-2*pi*shiftoff/samp_rate) ################################################## # Connections ################################################## self.msg_connect((self.gsm_bcch_ccch_demapper_0, 'bursts'), (self.gsm_control_channels_decoder_0, 'bursts')) self.msg_connect((self.gsm_clock_offset_control_0, 'ppm'), (self.gsm_input_0, 'ppm_in')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.gsm_message_printer_1, 'msgs')) self.msg_connect((self.gsm_control_channels_decoder_0_0, 'msgs'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0_0, 'msgs'), (self.gsm_message_printer_1, 'msgs')) self.msg_connect((self.gsm_decryption_0, 'bursts'), (self.gsm_control_channels_decoder_0_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_bcch_ccch_demapper_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'measurements'), (self.gsm_clock_offset_control_0, 'measurements')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_sdcch8_demapper_0, 'bursts')) self.msg_connect((self.gsm_sdcch8_demapper_0, 'bursts'), (self.gsm_decryption_0, 'bursts')) self.connect((self.blocks_rotator_cc_0, 0), (self.gsm_input_0, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self.osmosdr_source_0, 0), (self.blocks_rotator_cc_0, 0))
def __init__(self, fc=939.4e6, gain=30, samp_rate=2000000.052982, ppm=0): gr.top_block.__init__(self, "Airprobe Rtlsdr") Qt.QWidget.__init__(self) self.setWindowTitle("Airprobe Rtlsdr") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "airprobe_rtlsdr") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.fc = fc self.gain = gain self.samp_rate = samp_rate self.ppm = ppm ################################################## # Variables ################################################## self.ppm_slider = ppm_slider = ppm self.g_slider = g_slider = gain self.fc_slider = fc_slider = fc self.SDCCH = SDCCH = 6 self.SACCH = SACCH = 0x80 self.RACH = RACH = 3 self.PCH = PCH = 5 self.CHANNEL_UNKNOWN = CHANNEL_UNKNOWN = 0 self.CCCH = CCCH = 2 self.BCCH = BCCH = 1 self.AGCH = AGCH = 4 ################################################## # Blocks ################################################## self._ppm_slider_layout = Qt.QHBoxLayout() self._ppm_slider_layout.addWidget(Qt.QLabel("PPM Offset"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._ppm_slider_counter = qwt_counter_pyslot() self._ppm_slider_counter.setRange(-150, 150, 1) self._ppm_slider_counter.setNumButtons(2) self._ppm_slider_counter.setMinimumWidth(100) self._ppm_slider_counter.setValue(self.ppm_slider) self._ppm_slider_layout.addWidget(self._ppm_slider_counter) self._ppm_slider_counter.valueChanged.connect(self.set_ppm_slider) self.top_layout.addLayout(self._ppm_slider_layout) self._g_slider_layout = Qt.QHBoxLayout() self._g_slider_layout.addWidget(Qt.QLabel("Gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._g_slider_counter = qwt_counter_pyslot() self._g_slider_counter.setRange(0, 50, 0.5) self._g_slider_counter.setNumButtons(2) self._g_slider_counter.setMinimumWidth(100) self._g_slider_counter.setValue(self.g_slider) self._g_slider_layout.addWidget(self._g_slider_counter) self._g_slider_counter.valueChanged.connect(self.set_g_slider) self.top_layout.addLayout(self._g_slider_layout) self._fc_slider_layout = Qt.QVBoxLayout() self._fc_slider_tool_bar = Qt.QToolBar(self) self._fc_slider_layout.addWidget(self._fc_slider_tool_bar) self._fc_slider_tool_bar.addWidget(Qt.QLabel("Frequency"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._fc_slider_counter = qwt_counter_pyslot() self._fc_slider_counter.setRange(925e6, 960e6, 2e5) self._fc_slider_counter.setNumButtons(2) self._fc_slider_counter.setValue(self.fc_slider) self._fc_slider_tool_bar.addWidget(self._fc_slider_counter) self._fc_slider_counter.valueChanged.connect(self.set_fc_slider) self._fc_slider_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._fc_slider_slider.setRange(925e6, 960e6, 2e5) self._fc_slider_slider.setValue(self.fc_slider) self._fc_slider_slider.setMinimumWidth(100) self._fc_slider_slider.valueChanged.connect(self.set_fc_slider) self._fc_slider_layout.addWidget(self._fc_slider_slider) self.top_layout.addLayout(self._fc_slider_layout) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(fc_slider, 0) self.rtlsdr_source_0.set_freq_corr(ppm_slider, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(True, 0) self.rtlsdr_source_0.set_gain(g_slider, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(250e3, 0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype fc_slider, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.gsm_universal_ctrl_chans_demapper_0 = grgsm.universal_ctrl_chans_demapper(0, ([2,6,12,16,22,26,32,36,42,46]), ([BCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH])) self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) self.gsm_message_printer_1 = grgsm.message_printer(pmt.intern("")) self.gsm_input_0 = grgsm.gsm_input( ppm=0, osr=4, fc=fc, samp_rate_in=samp_rate, ) self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000) ################################################## # Connections ################################################## self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.gsm_input_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) ################################################## # Message Connections ################################################## self.msg_connect(self.gsm_receiver_0, "C0", self.gsm_universal_ctrl_chans_demapper_0, "bursts") self.msg_connect(self.gsm_clock_offset_control_0, "ppm", self.gsm_input_0, "ppm_in") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.gsm_message_printer_1, "msgs") self.msg_connect(self.gsm_universal_ctrl_chans_demapper_0, "bursts", self.gsm_control_channels_decoder_0, "bursts") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.blocks_socket_pdu_0, "pdus") self.msg_connect(self.gsm_receiver_0, "measurements", self.gsm_clock_offset_control_0, "measurements")
def __init__(self, args="", collector="localhost", collectorport='4729', fc=941.8e6, gain=30, osr=4, ppm=0, samp_rate=2000000.052982, serverport='4729', shiftoff=400e3): gr.top_block.__init__(self, "Gr-gsm Livemon") Qt.QWidget.__init__(self) self.setWindowTitle("Gr-gsm Livemon") qtgui.util.check_set_qss() try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "grgsm_livemon") try: if StrictVersion(Qt.qVersion()) < StrictVersion("5.0.0"): self.restoreGeometry( self.settings.value("geometry").toByteArray()) else: self.restoreGeometry(self.settings.value("geometry")) except: pass ################################################## # Parameters ################################################## self.args = args self.collector = collector self.collectorport = collectorport self.fc = fc self.gain = gain self.osr = osr self.ppm = ppm self.samp_rate = samp_rate self.serverport = serverport self.shiftoff = shiftoff ################################################## # Variables ################################################## self.ppm_slider = ppm_slider = ppm self.gain_slider = gain_slider = gain self.fc_slider = fc_slider = fc ################################################## # Blocks ################################################## self._ppm_slider_range = Range(-150, 150, 0.1, ppm, 100) self._ppm_slider_win = RangeWidget(self._ppm_slider_range, self.set_ppm_slider, 'PPM Offset', "counter", float) self.top_grid_layout.addWidget(self._ppm_slider_win) self._gain_slider_range = Range(0, 100, 0.5, gain, 100) self._gain_slider_win = RangeWidget(self._gain_slider_range, self.set_gain_slider, 'Gain', "counter", float) self.top_grid_layout.addWidget(self._gain_slider_win) self._fc_slider_range = Range(800e6, 1990e6, 2e5, fc, 100) self._fc_slider_win = RangeWidget(self._fc_slider_range, self.set_fc_slider, 'Frequency', "counter_slider", float) self.top_grid_layout.addWidget(self._fc_slider_win) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + 'str(grgsm.device.get_default_args(args))') self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(fc_slider - shiftoff, 0) self.rtlsdr_source_0.set_freq_corr(ppm_slider, 0) self.rtlsdr_source_0.set_gain(gain_slider, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna('', 0) self.rtlsdr_source_0.set_bandwidth(250e3 + abs(shiftoff), 0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype fc_slider, #fc samp_rate, #bw "", #name 1) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_y_label('Relative Gain', 'dB') self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_axis_labels(True) self.qtgui_freq_sink_x_0.enable_control_panel(False) labels = ['', '', '', '', '', '', '', '', '', ''] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = [ "blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue" ] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in range(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label( i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_grid_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.gsm_sdcch8_demapper_0 = grgsm.gsm_sdcch8_demapper(timeslot_nr=1, ) self.gsm_receiver_0 = grgsm.receiver(osr, [1022], [], False) self.gsm_message_printer_1 = grgsm.message_printer( pmt.intern(""), False, False, False) self.gsm_input_0 = grgsm.gsm_input( ppm=ppm - int(ppm), osr=osr, fc=fc_slider - shiftoff, samp_rate_in=samp_rate, ) self.gsm_decryption_0 = grgsm.decryption([], 1) self.gsm_control_channels_decoder_0_0 = grgsm.control_channels_decoder( ) self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control( fc_slider - shiftoff, samp_rate, osr) self.gsm_bcch_ccch_demapper_0 = grgsm.gsm_bcch_ccch_demapper( timeslot_nr=0, ) self.blocks_socket_pdu_0_1 = blocks.socket_pdu('UDP_CLIENT', collector, collectorport, 1500, False) self.blocks_socket_pdu_0_0 = blocks.socket_pdu('UDP_SERVER', '127.0.0.1', serverport, 10000, False) self.blocks_rotator_cc_0 = blocks.rotator_cc(-2 * pi * shiftoff / samp_rate) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'), (self.gsm_message_printer_1, 'msgs')) self.msg_connect((self.gsm_bcch_ccch_demapper_0, 'bursts'), (self.gsm_control_channels_decoder_0, 'bursts')) self.msg_connect((self.gsm_clock_offset_control_0, 'ctrl'), (self.gsm_input_0, 'ctrl_in')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.blocks_socket_pdu_0_1, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0_0, 'msgs'), (self.blocks_socket_pdu_0_1, 'pdus')) self.msg_connect((self.gsm_decryption_0, 'bursts'), (self.gsm_control_channels_decoder_0_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_bcch_ccch_demapper_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'measurements'), (self.gsm_clock_offset_control_0, 'measurements')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_sdcch8_demapper_0, 'bursts')) self.msg_connect((self.gsm_sdcch8_demapper_0, 'bursts'), (self.gsm_decryption_0, 'bursts')) self.connect((self.blocks_rotator_cc_0, 0), (self.gsm_input_0, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_rotator_cc_0, 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, osr=4): gr.top_block.__init__(self, "Uplink decoding demo") ################################################## # Parameters ################################################## self.osr = osr ################################################## # Variables ################################################## self.samp_rate = samp_rate = 1e6 ################################################## # Blocks ################################################## self.socket_pdu_server = blocks.socket_pdu("UDP_SERVER", '127.0.0.1', '4729', 10000, False) self.gsm_sdcch8_demapper_0 = grgsm.gsm_sdcch8_demapper(timeslot_nr=1, ) self.gsm_receiver_with_uplink_0 = grgsm.receiver( 4, ([22]), ([2]), True) self.gsm_message_printer_0_0 = grgsm.message_printer( pmt.intern(""), False, False, False) self.gsm_input_0_0 = grgsm.gsm_input( ppm=0, osr=4, fc=947.8e6 - 45e6, samp_rate_in=samp_rate, ) self.gsm_input_0 = grgsm.gsm_input( ppm=0, osr=4, fc=947.8e6, samp_rate_in=samp_rate, ) self.gsm_decryption_0_3 = grgsm.decryption( ([0x46, 0x77, 0x2d, 0x54, 0xa3, 0xa3, 0xc3, 0x1c]), 1) self.gsm_control_channels_decoder_0_1_0 = grgsm.control_channels_decoder( ) self.gsm_control_channels_decoder_0_1 = grgsm.control_channels_decoder( ) self.gsm_clock_offset_control_0 = grgsm.clock_offset_control( 947.8e6, samp_rate, osr) self.blocks_socket_pdu_0_0_0 = blocks.socket_pdu( "UDP_CLIENT", '127.0.0.1', '4729', 10000, False) self.blocks_file_source_0_0 = blocks.file_source( gr.sizeof_gr_complex * 1, 'sms_multirtl_uplink_tail.cfile', False) self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, 'sms_multirtl_downlink_tail.cfile', False) ################################################## # Connections ################################################## self.msg_connect((self.gsm_clock_offset_control_0, 'ctrl'), (self.gsm_input_0, 'ctrl_in')) self.msg_connect((self.gsm_clock_offset_control_0, 'ctrl'), (self.gsm_input_0_0, 'ctrl_in')) self.msg_connect((self.gsm_control_channels_decoder_0_1, 'msgs'), (self.blocks_socket_pdu_0_0_0, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0_1, 'msgs'), (self.gsm_message_printer_0_0, 'msgs')) self.msg_connect((self.gsm_control_channels_decoder_0_1_0, 'msgs'), (self.blocks_socket_pdu_0_0_0, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0_1_0, 'msgs'), (self.gsm_message_printer_0_0, 'msgs')) self.msg_connect((self.gsm_decryption_0_3, 'bursts'), (self.gsm_control_channels_decoder_0_1_0, 'bursts')) self.msg_connect((self.gsm_receiver_with_uplink_0, 'measurements'), (self.gsm_clock_offset_control_0, 'measurements')) self.msg_connect((self.gsm_receiver_with_uplink_0, 'C0'), (self.gsm_sdcch8_demapper_0, 'bursts')) self.msg_connect((self.gsm_sdcch8_demapper_0, 'bursts'), (self.gsm_control_channels_decoder_0_1, 'bursts')) self.msg_connect((self.gsm_sdcch8_demapper_0, 'bursts'), (self.gsm_decryption_0_3, 'bursts')) self.connect((self.blocks_file_source_0, 0), (self.gsm_input_0, 0)) self.connect((self.blocks_file_source_0_0, 0), (self.gsm_input_0_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_with_uplink_0, 0)) self.connect((self.gsm_input_0_0, 0), (self.gsm_receiver_with_uplink_0, 1))
def __init__(self, rec_len=1000000, samp_rate=2000000.052982, fc=941.8e6, shiftoff=400e3, args="", osr=4, collector="localhost", collectorport="4729", serverport="4729", gain=30, ppm=0): gr.top_block.__init__(self, "Gr-gsm Livemon") ################################################## # Parameters ################################################## self.rec_len = rec_len self.samp_rate = samp_rate self.fc = fc self.shiftoff = shiftoff self.args = args self.osr = osr self.collector = collector self.collectorport = collectorport self.serverport = serverport self.gain = gain self.ppm = ppm ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + args) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(fc - shiftoff, 0) self.rtlsdr_source_0.set_freq_corr(ppm, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(250e3 + abs(shiftoff), 0) self.gsm_sdcch8_demapper_0 = grgsm.gsm_sdcch8_demapper(timeslot_nr=1, ) self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([]), False) self.gsm_message_printer_1 = grgsm.message_printer( pmt.intern(""), False, False, False) self.gsm_input_0 = grgsm.gsm_input( ppm=ppm - int(ppm), osr=4, fc=fc, samp_rate_in=samp_rate, ) self.gsm_decryption_0 = grgsm.decryption(([]), 1) self.gsm_control_channels_decoder_0_0 = grgsm.control_channels_decoder( ) self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control( fc - shiftoff, samp_rate, osr) self.gsm_bcch_ccch_sdcch4_demapper_0 = grgsm.gsm_bcch_ccch_sdcch4_demapper( timeslot_nr=0, ) self.blocks_socket_pdu_0_1 = blocks.socket_pdu("UDP_CLIENT", collector, collectorport, 1500, False) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", serverport, 10000, False) self.blocks_rotator_cc_0 = blocks.rotator_cc(-2 * pi * shiftoff / samp_rate) self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex * 1, int(rec_len * samp_rate)) ################################################## # Connections ################################################## self.msg_connect((self.blocks_socket_pdu_0_0, 'pdus'), (self.gsm_message_printer_1, 'msgs')) self.msg_connect((self.gsm_bcch_ccch_sdcch4_demapper_0, 'bursts'), (self.gsm_control_channels_decoder_0, 'bursts')) self.msg_connect((self.gsm_clock_offset_control_0, 'ctrl'), (self.gsm_input_0, 'ctrl_in')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.blocks_socket_pdu_0_1, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0_0, 'msgs'), (self.blocks_socket_pdu_0_1, 'pdus')) self.msg_connect((self.gsm_decryption_0, 'bursts'), (self.gsm_control_channels_decoder_0_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_bcch_ccch_sdcch4_demapper_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'measurements'), (self.gsm_clock_offset_control_0, 'measurements')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_sdcch8_demapper_0, 'bursts')) self.msg_connect((self.gsm_sdcch8_demapper_0, 'bursts'), (self.gsm_decryption_0, 'bursts')) self.connect((self.blocks_head_0, 0), (self.blocks_rotator_cc_0, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.gsm_input_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_head_0, 0))
def __init__(self, fc, gain, samp_rate, ppm, arfcn, cfile=None, burst_file=None, band=None, verbose=False, gsmtap=False, rec_length=None, args=""): gr.top_block.__init__(self, "Gr-gsm Capture") ################################################## # Parameters ################################################## self.fc = fc self.gain = gain self.samp_rate = samp_rate self.ppm = ppm self.arfcn = arfcn self.cfile = cfile self.burst_file = burst_file self.band = band self.verbose = verbose self.gsmtap = gsmtap self.shiftoff = shiftoff = 400e3 self.rec_length = rec_length ################################################## # Processing Blocks ################################################## self.rtlsdr_source = osmosdr.source(args="numchan=" + str(1) + " " + 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) if self.rec_length is not None: self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex, int(samp_rate * rec_length)) if self.verbose or self.burst_file: 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) if self.burst_file: self.gsm_burst_file_sink = grgsm.burst_file_sink(self.burst_file) if self.cfile: self.blocks_file_sink = blocks.file_sink(gr.sizeof_gr_complex * 1, self.cfile, False) self.blocks_file_sink.set_unbuffered(False) if self.verbose: self.gsm_bursts_printer_0 = grgsm.bursts_printer( pmt.intern(""), False, False, False, False) if self.gsmtap: self.bcch_demapper = grgsm.gsm_bcch_ccch_demapper(0) self.cch_decoder = grgsm.control_channels_decoder() 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) ################################################## # Connections ################################################## if self.rec_length is not None: # if recording length is defined connect head block after the source self.connect((self.rtlsdr_source, 0), (self.blocks_head_0, 0)) self.connect((self.blocks_head_0, 0), (self.blocks_rotator, 0)) else: self.connect((self.rtlsdr_source, 0), (self.blocks_rotator, 0)) if self.cfile: self.connect((self.blocks_rotator, 0), (self.blocks_file_sink, 0)) if self.verbose or self.burst_file: 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") if self.burst_file: self.msg_connect(self.gsm_receiver, "C0", self.gsm_burst_file_sink, "in") if self.verbose: self.msg_connect(self.gsm_receiver, "C0", self.gsm_bursts_printer_0, "bursts") if self.gsmtap: self.msg_connect(self.gsm_receiver, "C0", 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")
def __init__(self, gain=None, samp_rate=None, ppm=None, arfcn=None, capture_id=None, udp_ports=[], max_timeslot=0, store_capture=True, verbose=False, band=None, rec_length=None, test=False, args=""): """ capture_id = identifier for the capture used to store the files (e.g. <capture_id>.cfile) store_capture = boolean indicating if the capture should be stored on disk or not rec_length = capture time in seconds max_timeslot = timeslot 0...max_timeslot will be decoded udp_ports = a list of udp ports to send the captured GSMTap frames to """ gr.top_block.__init__(self, "Gr-gsm Capture") ################################################## # 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.gain = gain self.samp_rate = samp_rate self.ppm = ppm self.arfcn = arfcn self.band = band self.shiftoff = shiftoff = 400e3 self.rec_length = rec_length self.store_capture = store_capture self.capture_id = capture_id self.udp_ports = udp_ports self.verbose = verbose ################################################## # Processing Blocks ################################################## self.rtlsdr_source = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source.set_sample_rate(samp_rate) self.rtlsdr_source.set_center_freq(self.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) #RUn for the specified amount of seconds or indefenitely if self.rec_length is not None: self.blocks_head_0 = blocks.head(gr.sizeof_gr_complex, int(samp_rate*rec_length)) self.gsm_receiver = grgsm.receiver(4, ([self.arfcn]), ([])) self.gsm_input = grgsm.gsm_input( ppm=0, osr=4, fc=self.fc, samp_rate_in=samp_rate, ) self.gsm_clock_offset_control = grgsm.clock_offset_control(self.fc-shiftoff) #Control channel demapper for timeslot 0 #self.gsm_bcch_ccch_demapper_0 = 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.gsm_bcch_ccch_demapper_0 = grgsm.gsm_bcch_ccch_demapper(0) #For all other timeslots are assumed to contain sdcch8 logical channels, this demapping may be incorrect if max_timeslot >= 1 and max_timeslot <= 8: self.gsm_sdcch8_demappers = [] for i in range(1,max_timeslot + 1): #self.gsm_sdcch8_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.gsm_sdcch8_demappers.append(grgsm.gsm_sdcch8_demapper(i)) #Control channel decoder (extracts the packets), one for each timeslot self.gsm_control_channels_decoders = [] for i in range(0,max_timeslot + 1): self.gsm_control_channels_decoders.append(grgsm.control_channels_decoder()) # self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False)# self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) #UDP client that sends all decoded C0T0 packets to the specified port on localhost if requested self.client_sockets = [] self.server_sockets = [] for udp_port in self.udp_ports: #The server is for testing only #WARNING remove the server if you want connect to a different one if test: self.server_sockets.append(blocks.socket_pdu("UDP_SERVER", "127.0.0.1", str(udp_port), 10000)) self.client_sockets.append(blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", str(udp_port), 10000)) #Sinks to store the capture file if requested if self.store_capture: self.gsm_burst_file_sink = grgsm.burst_file_sink(str(self.capture_id) + ".burstfile") self.blocks_file_sink = blocks.file_sink(gr.sizeof_gr_complex*1, str(self.capture_id) + ".cfile", False) self.blocks_file_sink.set_unbuffered(False) #Printer for printing messages when verbose flag is True if self.verbose: self.gsm_message_printer = grgsm.message_printer(pmt.intern(""), False) """ if self.verbose: self.gsm_bursts_printer_0 = grgsm.bursts_printer(pmt.intern(""), False, False, False, False) """ ################################################## # Connections ################################################## if self.rec_length is not None: #if recording length is defined connect head block after the source self.connect((self.rtlsdr_source, 0), (self.blocks_head_0, 0)) self.connect((self.blocks_head_0, 0), (self.blocks_rotator, 0)) else: self.connect((self.rtlsdr_source, 0), (self.blocks_rotator, 0)) #Connect the file sinks if self.store_capture: self.connect((self.blocks_rotator, 0), (self.blocks_file_sink, 0)) self.msg_connect(self.gsm_receiver, "C0", self.gsm_burst_file_sink, "in") #Connect the GSM receiver 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, "ppm", self.gsm_input, "ppm_in") self.msg_connect(self.gsm_receiver, "measurements", self.gsm_clock_offset_control, "measurements") #Connect the demapper and decoder for timeslot 0 self.msg_connect((self.gsm_receiver, 'C0'), (self.gsm_bcch_ccch_demapper_0, 'bursts')) self.msg_connect((self.gsm_bcch_ccch_demapper_0, 'bursts'), (self.gsm_control_channels_decoders[0], 'bursts')) #Connect the demapper and decoders for the other timeslots for i in range(1,max_timeslot +1): self.msg_connect((self.gsm_receiver, 'C0'), (self.gsm_sdcch8_demappers[i-1], 'bursts')) self.msg_connect((self.gsm_sdcch8_demappers[i-1], 'bursts'), (self.gsm_control_channels_decoders[i], 'bursts')) #Connect the UDP clients if requested for client_socket in self.client_sockets: for i in range(0,max_timeslot + 1): self.msg_connect((self.gsm_control_channels_decoders[i], 'msgs'), (client_socket, 'pdus')) #Connect the printer is self.verbose is True if self.verbose: for i in range(0,max_timeslot + 1): self.msg_connect((self.gsm_control_channels_decoders[i], 'msgs'), (self.gsm_message_printer, 'msgs')) """
def __init__(self, phy_device_args, phy_subdev_spec, phy_sample_rate, phy_gain, phy_ppm, sock_port): printl(DGSM, DINFO, "Init Radio interface") self.device_args = phy_device_args self.subdev_spec = phy_subdev_spec self.samp_rate = phy_sample_rate self.gain = phy_gain self.ppm = phy_ppm gr.top_block.__init__(self, "GR-GSM TMSI sniffer") shift_fc = self.fc - self.shiftoff ################################################## # PHY Definition ################################################## self.phy = osmosdr.source( args = "numchan=%d %s" % (1, self.device_args)) self.phy.set_bandwidth(250e3 + abs(self.shiftoff), 0) self.phy.set_center_freq(shift_fc, 0) self.phy.set_sample_rate(self.samp_rate) self.phy.set_freq_corr(self.ppm, 0) self.phy.set_iq_balance_mode(2, 0) self.phy.set_dc_offset_mode(2, 0) self.phy.set_gain_mode(False, 0) self.phy.set_gain(self.gain, 0) self.phy.set_if_gain(20, 0) self.phy.set_bb_gain(20, 0) self.phy.set_antenna("", 0) ################################################## # GR-GSM Magic ################################################## self.gsm_bcch_ccch_demapper = grgsm.gsm_bcch_ccch_demapper( timeslot_nr = 0) self.blocks_rotator = blocks.rotator_cc( -2 * pi * self.shiftoff / self.samp_rate) self.gsm_input = grgsm.gsm_input( ppm = self.ppm, osr = 4, fc = self.fc, samp_rate_in = self.samp_rate) self.socket_pdu = blocks.socket_pdu( "UDP_CLIENT", "127.0.0.1", str(sock_port), 10000, False) self.gsm_clck_ctrl = grgsm.clock_offset_control( shift_fc, self.samp_rate, osr = 4) self.gsm_ccch_decoder = grgsm.control_channels_decoder() self.gsm_receiver = grgsm.receiver(4, ([0]), ([])) ################################################## # Connections ################################################## self.connect((self.phy, 0), (self.blocks_rotator, 0)) self.connect((self.blocks_rotator, 0), (self.gsm_input, 0)) self.connect((self.gsm_input, 0), (self.gsm_receiver, 0)) self.msg_connect((self.gsm_receiver, 'C0'), (self.gsm_bcch_ccch_demapper, 'bursts')) self.msg_connect((self.gsm_receiver, 'measurements'), (self.gsm_clck_ctrl, 'measurements')) self.msg_connect((self.gsm_clck_ctrl, 'ctrl'), (self.gsm_input, 'ctrl_in')) self.msg_connect((self.gsm_bcch_ccch_demapper, 'bursts'), (self.gsm_ccch_decoder, 'bursts')) self.msg_connect((self.gsm_ccch_decoder, 'msgs'), (self.socket_pdu, 'pdus'))
def __init__(self, fc, gain, ppm, samp_rate, shiftoff): # Initiating the herited top_block class of the gnuradio project gr.top_block.__init__(self, "Airprobe Rtlsdr") # Settting parameters of the class self.fc = fc self.gain = gain self.ppm = ppm self.samp_rate = samp_rate self.shiftoff = shiftoff # Initialisation of the rtlsdr module to communicate with the device self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.rtlsdr_source_0.set_sample_rate(self.samp_rate) self.rtlsdr_source_0.set_center_freq(self.fc - self.shiftoff, 0) self.rtlsdr_source_0.set_freq_corr(self.ppm, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(self.gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(250e3 + abs(self.shiftoff), 0) self.gsm_sdcch8_demapper_0 = grgsm.universal_ctrl_chans_demapper( 1, ([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.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) # Setting block to display received packets in the terminal self.gsm_message_printer_1 = grgsm.message_printer( pmt.intern(""), False) # Setting gr-gsm parameters to listen the network self.gsm_input_0 = grgsm.gsm_input( ppm=self.ppm, osr=4, fc=self.fc, samp_rate_in=self.samp_rate, ) # Getting the GSM packet decoder self.gsm_decryption_0 = grgsm.decryption(([]), 1) # Create the control channel decoder to receive GSM packets self.gsm_control_channels_decoder_0_0 = grgsm.control_channels_decoder( ) # Create a duplicate control channel to display in the terminal self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() # TODO comment self.gsm_clock_offset_control_0 = grgsm.clock_offset_control( self.fc - self.shiftoff) # Create the BCCH and CCCH channel "parser?" self.gsm_bcch_ccch_demapper_0 = 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])) # Creating a client socket connected to the loopback interface self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000) # Creating a server socket to use GSM packets without Wireshark or other traffic analyser #self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "4729", 10000) self.blocks_rotator_cc_0 = blocks.rotator_cc(-2 * pi * self.shiftoff / self.samp_rate) # Sending received traffic from the device to the BCCH and CCCH channel mapper self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_bcch_ccch_demapper_0, 'bursts')) # Sending received traffic from the device to the Clock Offset controler self.msg_connect((self.gsm_receiver_0, 'measurements'), (self.gsm_clock_offset_control_0, 'measurements')) # Sending received traffic from the device to the SDCCH channel mapper self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_sdcch8_demapper_0, 'bursts')) # TODO comment self.msg_connect((self.gsm_clock_offset_control_0, 'ppm'), (self.gsm_input_0, 'ppm_in')) # Sending SDCCH channel packets decoded to the GSM decrypter self.msg_connect((self.gsm_sdcch8_demapper_0, 'bursts'), (self.gsm_decryption_0, 'bursts')) # Sending decrypted GSM packets to the channel decoder self.msg_connect((self.gsm_decryption_0, 'bursts'), (self.gsm_control_channels_decoder_0, 'bursts')) # Connecting the BCCH and CCCH channel mapper to the channel decoder self.msg_connect((self.gsm_bcch_ccch_demapper_0, 'bursts'), (self.gsm_control_channels_decoder_0, 'bursts')) # Sending readable GSM packets to the client socket self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.blocks_socket_pdu_0, 'pdus')) self.connect((self.rtlsdr_source_0, 0), (self.blocks_rotator_cc_0, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.gsm_input_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0))
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")
def __init__(self): # Graphical initialisation gr.top_block.__init__(self, "Airprobe Rtlsdr") Qt.QWidget.__init__(self) self.setWindowTitle("Airprobe Rtlsdr") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass # Logging system (to specific file) logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', filename='graphical_sniffing_log', filemod='w', level=logging.INFO) # Windows setting self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "airprobe_rtlsdr") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.fc = 937755550 #937.7e6 self.gain = 30 self.ppm = 0 self.samp_rate = 2000000.052982 self.shiftoff = 400e3 ################################################## # Blocks ################################################## # Order : min value, max value, step, default value and ?) self._ppm_slider_range = Range(-150, 150, 1, self.ppm, 100) self._ppm_slider_win = RangeWidget(self._ppm_slider_range, self.set_ppm, "PPM Offset", "counter", float) self.top_layout.addWidget(self._ppm_slider_win) self._g_slider_range = Range(0, 50, 0.5, self.gain, 100) self._g_slider_win = RangeWidget(self._g_slider_range, self.set_gain, "Gain", "counter", float) self.top_layout.addWidget(self._g_slider_win) self._fc_slider_range = Range(925e6, 1990e6, 2e5, self.fc, 100) self._fc_slider_win = RangeWidget(self._fc_slider_range, self.set_fc, "Frequency", "counter_slider", float) self.top_layout.addWidget(self._fc_slider_win) # Initialisation of the rtlsdr module to communicate with the device self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(self.samp_rate) self.rtlsdr_source_0.set_center_freq(self.fc-self.shiftoff, 0) self.rtlsdr_source_0.set_freq_corr(self.ppm, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(self.gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(250e3+abs(self.shiftoff), 0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype self.fc, self.samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.gsm_sdcch8_demapper_0 = grgsm.universal_ctrl_chans_demapper(1, ([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.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) self.gsm_message_printer_1 = grgsm.message_printer(pmt.intern(""), False) self.gsm_input_0 = grgsm.gsm_input( ppm=self.ppm, osr=4, fc=self.fc, samp_rate_in=self.samp_rate, ) self.gsm_decryption_0 = grgsm.decryption(([]), 1) self.gsm_control_channels_decoder_0_0 = grgsm.control_channels_decoder() self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(self.fc-self.shiftoff) self.gsm_bcch_ccch_demapper_0 = 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.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "4729", 10000) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000) self.blocks_rotator_cc_0 = blocks.rotator_cc(-2*pi*self.shiftoff/self.samp_rate) ################################################## # Connections ################################################## self.msg_connect((self.gsm_bcch_ccch_demapper_0, 'bursts'), (self.gsm_control_channels_decoder_0, 'bursts')) self.msg_connect((self.gsm_clock_offset_control_0, 'ppm'), (self.gsm_input_0, 'ppm_in')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.gsm_message_printer_1, 'msgs')) self.msg_connect((self.gsm_control_channels_decoder_0_0, 'msgs'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0_0, 'msgs'), (self.gsm_message_printer_1, 'msgs')) self.msg_connect((self.gsm_decryption_0, 'bursts'), (self.gsm_control_channels_decoder_0_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_bcch_ccch_demapper_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'measurements'), (self.gsm_clock_offset_control_0, 'measurements')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_sdcch8_demapper_0, 'bursts')) self.msg_connect((self.gsm_sdcch8_demapper_0, 'bursts'), (self.gsm_decryption_0, 'bursts')) self.connect((self.blocks_rotator_cc_0, 0), (self.gsm_input_0, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_rotator_cc_0, 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, ppm_param=0): gr.top_block.__init__(self, "Airprobe Rtlsdr") Qt.QWidget.__init__(self) self.setWindowTitle("Airprobe Rtlsdr") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "airprobe_rtlsdr") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.ppm_param = args.ppm_param ################################################## # Variables ################################################## self.samp_rate = samp_rate = args.sample_rate self.ppm = ppm = ppm_param self.g = g = args.gain self.fc = fc = args.frequency self.SDCCH = SDCCH = 6 self.RACH = RACH = 3 self.PCH = PCH = 5 self.CHANNEL_UNKNOWN = CHANNEL_UNKNOWN = 0 self.CCCH = CCCH = 2 self.BCCH = BCCH = 1 self.AGCH = AGCH = 4 ################################################## # Blocks ################################################## self._ppm_layout = Qt.QHBoxLayout() self._ppm_layout.addWidget(Qt.QLabel("clock_correction [ppm]"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._ppm_counter = qwt_counter_pyslot() self._ppm_counter.setRange(-150, 150, 1) self._ppm_counter.setNumButtons(2) self._ppm_counter.setMinimumWidth(100) self._ppm_counter.setValue(self.ppm) self._ppm_layout.addWidget(self._ppm_counter) self._ppm_counter.valueChanged.connect(self.set_ppm) self.top_layout.addLayout(self._ppm_layout) self._g_layout = Qt.QHBoxLayout() self._g_layout.addWidget(Qt.QLabel("gain"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._g_counter = qwt_counter_pyslot() self._g_counter.setRange(0, 50, 0.5) self._g_counter.setNumButtons(2) self._g_counter.setMinimumWidth(100) self._g_counter.setValue(self.g) self._g_layout.addWidget(self._g_counter) self._g_counter.valueChanged.connect(self.set_g) self.top_layout.addLayout(self._g_layout) self._fc_layout = Qt.QVBoxLayout() self._fc_tool_bar = Qt.QToolBar(self) self._fc_layout.addWidget(self._fc_tool_bar) self._fc_tool_bar.addWidget(Qt.QLabel("center_frequency"+": ")) class qwt_counter_pyslot(Qwt.QwtCounter): def __init__(self, parent=None): Qwt.QwtCounter.__init__(self, parent) @pyqtSlot('double') def setValue(self, value): super(Qwt.QwtCounter, self).setValue(value) self._fc_counter = qwt_counter_pyslot() self._fc_counter.setRange(925e6, 960e6, 2e5) self._fc_counter.setNumButtons(2) self._fc_counter.setValue(self.fc) self._fc_tool_bar.addWidget(self._fc_counter) self._fc_counter.valueChanged.connect(self.set_fc) self._fc_slider = Qwt.QwtSlider(None, Qt.Qt.Horizontal, Qwt.QwtSlider.BottomScale, Qwt.QwtSlider.BgSlot) self._fc_slider.setRange(925e6, 960e6, 2e5) self._fc_slider.setValue(self.fc) self._fc_slider.setMinimumWidth(100) self._fc_slider.valueChanged.connect(self.set_fc) self._fc_layout.addWidget(self._fc_slider) self.top_layout.addLayout(self._fc_layout) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(fc, 0) self.rtlsdr_source_0.set_freq_corr(ppm, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(True, 0) self.rtlsdr_source_0.set_gain(g, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(250e3, 0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype fc, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.gsm_universal_ctrl_chans_demapper_0 = grgsm.universal_ctrl_chans_demapper(([2,6,12,16,22,26,32,36,42,46]), ([BCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH])) self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) self.gsm_message_printer_1 = grgsm.message_printer() self.gsm_input_0 = grgsm.gsm_input( ppm=0, osr=4, fc=fc, samp_rate_in=samp_rate, ) self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) ################################################## # Connections ################################################## self.connect((self.rtlsdr_source_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.gsm_input_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) ################################################## # Asynch Message Connections ################################################## self.msg_connect(self.gsm_clock_offset_control_0, "ppm", self.gsm_input_0, "ppm_in") self.msg_connect(self.gsm_receiver_0, "C0", self.gsm_universal_ctrl_chans_demapper_0, "bursts") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.gsm_message_printer_1, "msgs") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.blocks_socket_pdu_0, "pdus") self.msg_connect(self.gsm_universal_ctrl_chans_demapper_0, "bursts", self.gsm_control_channels_decoder_0, "bursts") self.msg_connect(self.gsm_receiver_0, "measurements", self.gsm_clock_offset_control_0, "measurements")
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): # Graphical initialisation gr.top_block.__init__(self, "Airprobe Rtlsdr") Qt.QWidget.__init__(self) self.setWindowTitle("Airprobe Rtlsdr") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass # Logging system (to specific file) logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s', filename='graphical_sniffing_log', filemod='w', level=logging.INFO) # Windows setting self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "airprobe_rtlsdr") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.fc = 937755550 #937.7e6 self.gain = 30 self.ppm = 0 self.samp_rate = 2000000.052982 self.shiftoff = 400e3 ################################################## # Blocks ################################################## # Order : min value, max value, step, default value and ?) self._ppm_slider_range = Range(-150, 150, 1, self.ppm, 100) self._ppm_slider_win = RangeWidget(self._ppm_slider_range, self.set_ppm, "PPM Offset", "counter", float) self.top_layout.addWidget(self._ppm_slider_win) self._g_slider_range = Range(0, 50, 0.5, self.gain, 100) self._g_slider_win = RangeWidget(self._g_slider_range, self.set_gain, "Gain", "counter", float) self.top_layout.addWidget(self._g_slider_win) self._fc_slider_range = Range(925e6, 1990e6, 2e5, self.fc, 100) self._fc_slider_win = RangeWidget(self._fc_slider_range, self.set_fc, "Frequency", "counter_slider", float) self.top_layout.addWidget(self._fc_slider_win) # Initialisation of the rtlsdr module to communicate with the device self.rtlsdr_source_0 = osmosdr.source(args="numchan=" + str(1) + " " + "") self.rtlsdr_source_0.set_sample_rate(self.samp_rate) self.rtlsdr_source_0.set_center_freq(self.fc - self.shiftoff, 0) self.rtlsdr_source_0.set_freq_corr(self.ppm, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(self.gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(250e3 + abs(self.shiftoff), 0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype self.fc, self.samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self._qtgui_freq_sink_x_0_win = sip.wrapinstance( self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.gsm_sdcch8_demapper_0 = grgsm.universal_ctrl_chans_demapper( 1, ([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.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) self.gsm_message_printer_1 = grgsm.message_printer( pmt.intern(""), False) self.gsm_input_0 = grgsm.gsm_input( ppm=self.ppm, osr=4, fc=self.fc, samp_rate_in=self.samp_rate, ) self.gsm_decryption_0 = grgsm.decryption(([]), 1) self.gsm_control_channels_decoder_0_0 = grgsm.control_channels_decoder( ) self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control( self.fc - self.shiftoff) self.gsm_bcch_ccch_demapper_0 = 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.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "4729", 10000) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000) self.blocks_rotator_cc_0 = blocks.rotator_cc(-2 * pi * self.shiftoff / self.samp_rate) ################################################## # Connections ################################################## self.msg_connect((self.gsm_bcch_ccch_demapper_0, 'bursts'), (self.gsm_control_channels_decoder_0, 'bursts')) self.msg_connect((self.gsm_clock_offset_control_0, 'ppm'), (self.gsm_input_0, 'ppm_in')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.gsm_message_printer_1, 'msgs')) self.msg_connect((self.gsm_control_channels_decoder_0_0, 'msgs'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0_0, 'msgs'), (self.gsm_message_printer_1, 'msgs')) self.msg_connect((self.gsm_decryption_0, 'bursts'), (self.gsm_control_channels_decoder_0_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_bcch_ccch_demapper_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'measurements'), (self.gsm_clock_offset_control_0, 'measurements')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_sdcch8_demapper_0, 'bursts')) self.msg_connect((self.gsm_sdcch8_demapper_0, 'bursts'), (self.gsm_decryption_0, 'bursts')) self.connect((self.blocks_rotator_cc_0, 0), (self.gsm_input_0, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_rotator_cc_0, 0))
def __init__(self, fc=939.4e6, gain=30, samp_rate=2000000.052982, ppm=0): gr.top_block.__init__(self, "Airprobe Rtlsdr") ################################################## # Parameters ################################################## self.fc = fc self.gain = gain self.samp_rate = samp_rate self.ppm = ppm ################################################## # Variables ################################################## self.ppm_slider = ppm_slider = ppm self.g_slider = g_slider = gain self.fc_slider = fc_slider = fc self.SDCCH = SDCCH = 6 self.SACCH = SACCH = 0x80 self.RACH = RACH = 3 self.PCH = PCH = 5 self.CHANNEL_UNKNOWN = CHANNEL_UNKNOWN = 0 self.CCCH = CCCH = 2 self.BCCH = BCCH = 1 self.AGCH = AGCH = 4 ################################################## # Blocks ################################################## self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(fc_slider, 0) self.rtlsdr_source_0.set_freq_corr(ppm_slider, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(True, 0) self.rtlsdr_source_0.set_gain(g_slider, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(250e3, 0) self.gsm_universal_ctrl_chans_demapper_0 = grgsm.universal_ctrl_chans_demapper(0, ([2,6,12,16,22,26,32,36,42,46]), ([BCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH,CCCH])) self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) self.gsm_message_printer_1 = grgsm.message_printer(pmt.intern("")) self.gsm_input_0 = grgsm.gsm_input( ppm=0, osr=4, fc=fc, samp_rate_in=samp_rate, ) self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "rabbitmq", "4729", 10000) ################################################## # Connections ################################################## self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.gsm_input_0, 0)) ################################################## # Message Connections ################################################## self.msg_connect(self.gsm_receiver_0, "C0", self.gsm_universal_ctrl_chans_demapper_0, "bursts") self.msg_connect(self.gsm_clock_offset_control_0, "ppm", self.gsm_input_0, "ppm_in") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.gsm_message_printer_1, "msgs") self.msg_connect(self.gsm_universal_ctrl_chans_demapper_0, "bursts", self.gsm_control_channels_decoder_0, "bursts") self.msg_connect(self.gsm_control_channels_decoder_0, "msgs", self.blocks_socket_pdu_0, "pdus") self.msg_connect(self.gsm_receiver_0, "measurements", self.gsm_clock_offset_control_0, "measurements")
def __init__(self, fc=937e6, input_file_name="input.cfile", samp_rate=100.0e6 / 174.0, osr=4): gr.top_block.__init__(self, "Get Bcch Msgs From Cfile") ################################################## # Parameters ################################################## self.fc = fc self.input_file_name = input_file_name self.samp_rate = samp_rate self.osr = osr ################################################## # Blocks ################################################## self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([]), False) self.gsm_message_printer_0 = grgsm.message_printer( pmt.intern(""), False, False, False) self.gsm_input_0 = grgsm.gsm_input( ppm=0, osr=osr, fc=fc, samp_rate_in=samp_rate, ) self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control( fc, samp_rate, osr) self.gsm_bcch_ccch_demapper_0 = grgsm.gsm_bcch_ccch_demapper( timeslot_nr=0, ) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "4729", 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_file_source_0 = blocks.file_source( gr.sizeof_gr_complex * 1, "/home/piotr/Odbiornik_gsm/gr-gsm/test_data/vf_call6_a725_d174_g5_Kc1EF00BAB3BAC7002.cfile", False) ################################################## # Connections ################################################## self.msg_connect((self.gsm_bcch_ccch_demapper_0, 'bursts'), (self.gsm_control_channels_decoder_0, 'bursts')) self.msg_connect((self.gsm_clock_offset_control_0, 'ctrl'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.gsm_clock_offset_control_0, 'ctrl'), (self.gsm_input_0, 'ctrl_in')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.gsm_message_printer_0, 'msgs')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_bcch_ccch_demapper_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'measurements'), (self.gsm_clock_offset_control_0, 'measurements')) self.connect((self.blocks_file_source_0, 0), (self.gsm_input_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_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")
def __init__(self, fc=939.4e6, gain=30, ppm=0, samp_rate=2000000.052982, shiftoff=400e3): gr.top_block.__init__(self, "Airprobe Rtlsdr") Qt.QWidget.__init__(self) self.setWindowTitle("Airprobe Rtlsdr") try: self.setWindowIcon(Qt.QIcon.fromTheme('gnuradio-grc')) except: pass self.top_scroll_layout = Qt.QVBoxLayout() self.setLayout(self.top_scroll_layout) self.top_scroll = Qt.QScrollArea() self.top_scroll.setFrameStyle(Qt.QFrame.NoFrame) self.top_scroll_layout.addWidget(self.top_scroll) self.top_scroll.setWidgetResizable(True) self.top_widget = Qt.QWidget() self.top_scroll.setWidget(self.top_widget) self.top_layout = Qt.QVBoxLayout(self.top_widget) self.top_grid_layout = Qt.QGridLayout() self.top_layout.addLayout(self.top_grid_layout) self.settings = Qt.QSettings("GNU Radio", "airprobe_rtlsdr") self.restoreGeometry(self.settings.value("geometry").toByteArray()) ################################################## # Parameters ################################################## self.fc = fc self.gain = gain self.ppm = ppm self.samp_rate = samp_rate self.shiftoff = shiftoff ################################################## # Variables ################################################## self.ppm_slider = ppm_slider = ppm self.g_slider = g_slider = gain self.fc_slider = fc_slider = fc ################################################## # Blocks ################################################## self._ppm_slider_range = Range(-150, 150, 1, ppm, 100) self._ppm_slider_win = RangeWidget(self._ppm_slider_range, self.set_ppm_slider, "PPM Offset", "counter", float) self.top_layout.addWidget(self._ppm_slider_win) self._g_slider_range = Range(0, 50, 0.5, gain, 100) self._g_slider_win = RangeWidget(self._g_slider_range, self.set_g_slider, "Gain", "counter", float) self.top_layout.addWidget(self._g_slider_win) self._fc_slider_range = Range(925e6, 1990e6, 2e5, fc, 100) self._fc_slider_win = RangeWidget(self._fc_slider_range, self.set_fc_slider, "Frequency", "counter_slider", float) self.top_layout.addWidget(self._fc_slider_win) self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(fc_slider-shiftoff, 0) self.rtlsdr_source_0.set_freq_corr(ppm_slider, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(g_slider, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(250e3+abs(shiftoff), 0) self.qtgui_freq_sink_x_0 = qtgui.freq_sink_c( 1024, #size firdes.WIN_BLACKMAN_hARRIS, #wintype fc_slider, #fc samp_rate, #bw "", #name 1 #number of inputs ) self.qtgui_freq_sink_x_0.set_update_time(0.10) self.qtgui_freq_sink_x_0.set_y_axis(-140, 10) self.qtgui_freq_sink_x_0.set_trigger_mode(qtgui.TRIG_MODE_FREE, 0.0, 0, "") self.qtgui_freq_sink_x_0.enable_autoscale(False) self.qtgui_freq_sink_x_0.enable_grid(False) self.qtgui_freq_sink_x_0.set_fft_average(1.0) self.qtgui_freq_sink_x_0.enable_control_panel(False) if not True: self.qtgui_freq_sink_x_0.disable_legend() if complex == type(float()): self.qtgui_freq_sink_x_0.set_plot_pos_half(not True) labels = ["", "", "", "", "", "", "", "", "", ""] widths = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] colors = ["blue", "red", "green", "black", "cyan", "magenta", "yellow", "dark red", "dark green", "dark blue"] alphas = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0] for i in xrange(1): if len(labels[i]) == 0: self.qtgui_freq_sink_x_0.set_line_label(i, "Data {0}".format(i)) else: self.qtgui_freq_sink_x_0.set_line_label(i, labels[i]) self.qtgui_freq_sink_x_0.set_line_width(i, widths[i]) self.qtgui_freq_sink_x_0.set_line_color(i, colors[i]) self.qtgui_freq_sink_x_0.set_line_alpha(i, alphas[i]) self._qtgui_freq_sink_x_0_win = sip.wrapinstance(self.qtgui_freq_sink_x_0.pyqwidget(), Qt.QWidget) self.top_layout.addWidget(self._qtgui_freq_sink_x_0_win) self.gsm_sdcch8_demapper_0 = grgsm.universal_ctrl_chans_demapper(1, ([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.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) self.gsm_message_printer_1 = grgsm.message_printer(pmt.intern(""), False) self.gsm_input_0 = grgsm.gsm_input( ppm=0, osr=4, fc=fc, samp_rate_in=samp_rate, ) self.gsm_decryption_0 = grgsm.decryption(([]), 1) self.gsm_control_channels_decoder_0_0 = grgsm.control_channels_decoder() self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc-shiftoff) self.gsm_bcch_ccch_demapper_0 = 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.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "4729", 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) self.blocks_rotator_cc_0 = blocks.rotator_cc(-2*pi*shiftoff/samp_rate) ################################################## # Connections ################################################## self.msg_connect((self.gsm_bcch_ccch_demapper_0, 'bursts'), (self.gsm_control_channels_decoder_0, 'bursts')) self.msg_connect((self.gsm_clock_offset_control_0, 'ppm'), (self.gsm_input_0, 'ppm_in')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.gsm_message_printer_1, 'msgs')) self.msg_connect((self.gsm_control_channels_decoder_0_0, 'msgs'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0_0, 'msgs'), (self.gsm_message_printer_1, 'msgs')) self.msg_connect((self.gsm_decryption_0, 'bursts'), (self.gsm_control_channels_decoder_0_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_bcch_ccch_demapper_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'measurements'), (self.gsm_clock_offset_control_0, 'measurements')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_sdcch8_demapper_0, 'bursts')) self.msg_connect((self.gsm_sdcch8_demapper_0, 'bursts'), (self.gsm_decryption_0, 'bursts')) self.connect((self.blocks_rotator_cc_0, 0), (self.gsm_input_0, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.qtgui_freq_sink_x_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_rotator_cc_0, 0))
def __init__(self, fc, gain, ppm, samp_rate, shiftoff): # Initiating the herited top_block class of the gnuradio project gr.top_block.__init__(self, "Airprobe Rtlsdr") # Settting parameters of the class self.fc = fc self.gain = gain self.ppm = ppm self.samp_rate = samp_rate self.shiftoff = shiftoff # Initialisation of the rtlsdr module to communicate with the device self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + "" ) self.rtlsdr_source_0.set_sample_rate(self.samp_rate) self.rtlsdr_source_0.set_center_freq(self.fc-self.shiftoff, 0) self.rtlsdr_source_0.set_freq_corr(self.ppm, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(False, 0) self.rtlsdr_source_0.set_gain(self.gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(250e3+abs(self.shiftoff), 0) self.gsm_sdcch8_demapper_0 = grgsm.universal_ctrl_chans_demapper(1, ([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.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([])) # Setting block to display received packets in the terminal self.gsm_message_printer_1 = grgsm.message_printer(pmt.intern(""), False) # Setting gr-gsm parameters to listen the network self.gsm_input_0 = grgsm.gsm_input( ppm=self.ppm, osr=4, fc=self.fc, samp_rate_in=self.samp_rate, ) # Getting the GSM packet decoder self.gsm_decryption_0 = grgsm.decryption(([]), 1) # Create the control channel decoder to receive GSM packets self.gsm_control_channels_decoder_0_0 = grgsm.control_channels_decoder() # Create a duplicate control channel to display in the terminal self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() # TODO comment self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(self.fc-self.shiftoff) # Create the BCCH and CCCH channel "parser?" self.gsm_bcch_ccch_demapper_0 = 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])) # Creating a client socket connected to the loopback interface self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000) # Creating a server socket to use GSM packets without Wireshark or other traffic analyser #self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "4729", 10000) self.blocks_rotator_cc_0 = blocks.rotator_cc(-2*pi*self.shiftoff/self.samp_rate) # Sending received traffic from the device to the BCCH and CCCH channel mapper self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_bcch_ccch_demapper_0, 'bursts')) # Sending received traffic from the device to the Clock Offset controler self.msg_connect((self.gsm_receiver_0, 'measurements'), (self.gsm_clock_offset_control_0, 'measurements')) # Sending received traffic from the device to the SDCCH channel mapper self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_sdcch8_demapper_0, 'bursts')) # TODO comment self.msg_connect((self.gsm_clock_offset_control_0, 'ppm'), (self.gsm_input_0, 'ppm_in')) # Sending SDCCH channel packets decoded to the GSM decrypter self.msg_connect((self.gsm_sdcch8_demapper_0, 'bursts'), (self.gsm_decryption_0, 'bursts')) # Sending decrypted GSM packets to the channel decoder self.msg_connect((self.gsm_decryption_0, 'bursts'), (self.gsm_control_channels_decoder_0, 'bursts')) # Connecting the BCCH and CCCH channel mapper to the channel decoder self.msg_connect((self.gsm_bcch_ccch_demapper_0, 'bursts'), (self.gsm_control_channels_decoder_0, 'bursts')) # Sending readable GSM packets to the client socket self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.blocks_socket_pdu_0, 'pdus')) self.connect((self.rtlsdr_source_0, 0), (self.blocks_rotator_cc_0, 0)) self.connect((self.blocks_rotator_cc_0, 0), (self.gsm_input_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0))
def __init__(self, args="", fc=939.4e6, gain=30, ppm=0, samp_rate=2000000.052982, shiftoff=400e3, osr=4): gr.top_block.__init__(self, "Gr-gsm Livemon") ################################################## # Parameters ################################################## self.args = args self.fc = fc self.gain = gain self.ppm = ppm self.samp_rate = samp_rate self.shiftoff = shiftoff self.osr = osr print " [+] starting grgsm_livemon_headless..." print " [>] frequency: %s Hz (specify with -fc)" % fc print " [>] gain: %s dB (specify with --gain)" % gain print " [>] ppm: %s (specify with --ppm)" % ppm print " [>] sample rate: %s (specify with --samp_rate)" % samp_rate print " [>] shift offset: %s Hz (specify with --shiftoff)" % shiftoff self.rtlsdr_source_0 = osmosdr.source( args="numchan=" + str(1) + " " + args ) self.rtlsdr_source_0.set_sample_rate(samp_rate) self.rtlsdr_source_0.set_center_freq(fc-shiftoff, 0) self.rtlsdr_source_0.set_freq_corr(self.ppm, 0) self.rtlsdr_source_0.set_dc_offset_mode(2, 0) self.rtlsdr_source_0.set_iq_balance_mode(2, 0) self.rtlsdr_source_0.set_gain_mode(True, 0) self.rtlsdr_source_0.set_gain(self.gain, 0) self.rtlsdr_source_0.set_if_gain(20, 0) self.rtlsdr_source_0.set_bb_gain(20, 0) self.rtlsdr_source_0.set_antenna("", 0) self.rtlsdr_source_0.set_bandwidth(250e3+abs(shiftoff), 0) self.gsm_sdcch8_demapper_0 = grgsm.gsm_sdcch8_demapper( timeslot_nr=1, ) self.gsm_receiver_0 = grgsm.receiver(4, ([0]), ([]), False) self.gsm_message_printer_1 = grgsm.message_printer(pmt.intern(""), False, False, False) self.gsm_input_0 = grgsm.gsm_input( ppm=0, osr=4, fc=fc, samp_rate_in=samp_rate, ) self.gsm_decryption_0 = grgsm.decryption(([]), 1) self.gsm_control_channels_decoder_0_0 = grgsm.control_channels_decoder() self.gsm_control_channels_decoder_0 = grgsm.control_channels_decoder() self.gsm_clock_offset_control_0 = grgsm.clock_offset_control(fc-shiftoff, samp_rate, osr) self.gsm_bcch_ccch_demapper_0 = grgsm.gsm_bcch_ccch_demapper( timeslot_nr=0, ) self.blocks_socket_pdu_0_0 = blocks.socket_pdu("UDP_SERVER", "127.0.0.1", "4730", 10000, False) self.blocks_socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) self.blocks_rotator_cc_0 = blocks.rotator_cc(-2*pi*shiftoff/samp_rate) ################################################## # Connections ################################################## self.msg_connect((self.gsm_bcch_ccch_demapper_0, 'bursts'), (self.gsm_control_channels_decoder_0, 'bursts')) self.msg_connect((self.gsm_clock_offset_control_0, 'ctrl'), (self.gsm_input_0, 'ctrl_in')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0, 'msgs'), (self.gsm_message_printer_1, 'msgs')) self.msg_connect((self.gsm_control_channels_decoder_0_0, 'msgs'), (self.blocks_socket_pdu_0, 'pdus')) self.msg_connect((self.gsm_control_channels_decoder_0_0, 'msgs'), (self.gsm_message_printer_1, 'msgs')) self.msg_connect((self.gsm_decryption_0, 'bursts'), (self.gsm_control_channels_decoder_0_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_bcch_ccch_demapper_0, 'bursts')) self.msg_connect((self.gsm_receiver_0, 'measurements'), (self.gsm_clock_offset_control_0, 'measurements')) self.msg_connect((self.gsm_receiver_0, 'C0'), (self.gsm_sdcch8_demapper_0, 'bursts')) self.msg_connect((self.gsm_sdcch8_demapper_0, 'bursts'), (self.gsm_decryption_0, 'bursts')) self.connect((self.blocks_rotator_cc_0, 0), (self.gsm_input_0, 0)) self.connect((self.gsm_input_0, 0), (self.gsm_receiver_0, 0)) self.connect((self.rtlsdr_source_0, 0), (self.blocks_rotator_cc_0, 0)) print " [+] go!"
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")