Esempio n. 1
0
    def __init__(self, timeslot, burst_file, mode, show_gprs):
        gr.top_block.__init__(self, "Top Block")

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

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

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

        self.msg_connect((self.gsm_burst_file_source, 'out'),
                         (self.gsm_burst_timeslot_filter, 'in'))
        self.msg_connect((self.gsm_burst_timeslot_filter, 'out'),
                         (self.demapper, 'bursts'))
        self.msg_connect((self.demapper, 'bursts'),
                         (self.gsm_control_channels_decoder, 'bursts'))
        self.msg_connect((self.gsm_control_channels_decoder, 'msgs'),
                         (self.gsm_extract_cmc, 'msgs'))
        self.msg_connect((self.gsm_control_channels_decoder, 'msgs'),
                         (self.gsm_extract_immediate_assignment, 'msgs'))
        self.msg_connect((self.gsm_control_channels_decoder, 'msgs'),
                         (self.gsm_extract_system_info, 'msgs'))
Esempio n. 2
0
    def __init__(self,
                 rec_len=3,
                 sample_rate=2e6,
                 carrier_frequency=939e6,
                 gain=24,
                 ppm=0,
                 args=""):
        gr.top_block.__init__(self, "Wideband Scanner")

        self.rec_len = rec_len
        self.sample_rate = sample_rate
        self.carrier_frequency = carrier_frequency
        self.ppm = ppm

        # if no file name is given process data from rtl_sdr source
        print "Args=", args
        self.rtlsdr_source = osmosdr.source(
            args="numchan=" + str(1) + " " +
            str(grgsm.device.get_default_args(args)))
        #self.rtlsdr_source.set_min_output_buffer(int(sample_rate*rec_len)) #this line causes segfaults on HackRF
        self.rtlsdr_source.set_sample_rate(sample_rate)

        # capture half of GSM channel lower than channel center (-0.1MHz)
        # this is needed when even number of channels is captured in order to process full captured bandwidth

        self.rtlsdr_source.set_center_freq(carrier_frequency - 0.1e6, 0)

        # correction of central frequency
        # if the receiver has large frequency offset
        # the value of this variable should be set close to that offset in ppm
        self.rtlsdr_source.set_freq_corr(ppm, 0)

        self.rtlsdr_source.set_dc_offset_mode(2, 0)
        self.rtlsdr_source.set_iq_balance_mode(0, 0)
        self.rtlsdr_source.set_gain_mode(True, 0)
        self.rtlsdr_source.set_bandwidth(sample_rate, 0)
        self.rtlsdr_source.set_gain(gain, 0)
        self.rtlsdr_source.set_if_gain(32, 0)
        self.rtlsdr_source.set_bb_gain(30, 0)
        self.head = blocks.head(gr.sizeof_gr_complex * 1,
                                int(rec_len * sample_rate))

        # shift again by -0.1MHz in order to align channel center in 0Hz
        self.blocks_rotator_cc = blocks.rotator_cc(-2 * pi * 0.1e6 /
                                                   sample_rate)

        self.wideband_receiver = wideband_receiver(OSR=4,
                                                   fc=carrier_frequency,
                                                   samp_rate=sample_rate)
        self.gsm_extract_system_info = grgsm.extract_system_info()

        self.connect((self.rtlsdr_source, 0), (self.head, 0))
        self.connect((self.head, 0), (self.blocks_rotator_cc, 0))
        self.connect((self.blocks_rotator_cc, 0), (self.wideband_receiver, 0))
        self.msg_connect(self.wideband_receiver, 'msgs',
                         self.gsm_extract_system_info, 'msgs')
    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'))
Esempio n. 4
0
    def __init__(self, rec_len=3, sample_rate=2e6, carrier_frequency=939e6, ppm=0, args=""):

        gr.top_block.__init__(self, "Wideband Scanner")

        self.rec_len = rec_len
        self.sample_rate = sample_rate
        self.carrier_frequency = carrier_frequency
        self.ppm = ppm

        # if no file name is given process data from rtl_sdr source
        print "Args=",args
        self.rtlsdr_source = osmosdr.source( args="numchan=" + str(1) + " " + args )

        self.rtlsdr_source.set_sample_rate(sample_rate)

        # capture half of GSM channel lower than channel center (-0.1MHz)
        # this is needed when even number of channels is captured in order to process full captured bandwidth

        self.rtlsdr_source.set_center_freq(carrier_frequency - 0.1e6, 0)

        # correction of central frequency
        # if the receiver has large frequency offset
        # the value of this variable should be set close to that offset in ppm
        self.rtlsdr_source.set_freq_corr(ppm, 0)

        self.rtlsdr_source.set_dc_offset_mode(2, 0)
        self.rtlsdr_source.set_iq_balance_mode(0, 0)
        self.rtlsdr_source.set_gain_mode(True, 0)
        self.rtlsdr_source.set_bandwidth(sample_rate, 0)

        self.head = blocks.head(gr.sizeof_gr_complex * 1, int(rec_len * sample_rate))

        # shift again by -0.1MHz in order to align channel center in 0Hz
        self.blocks_rotator_cc = blocks.rotator_cc(-2 * pi * 0.1e6 / sample_rate)

        self.wideband_receiver = wideband_receiver(OSR=4, fc=carrier_frequency, samp_rate=sample_rate)
        self.gsm_extract_system_info = grgsm.extract_system_info()


        self.connect((self.rtlsdr_source, 0), (self.head, 0))
        self.connect((self.head, 0), (self.blocks_rotator_cc, 0))
        self.connect((self.blocks_rotator_cc, 0), (self.wideband_receiver,0))
        self.msg_connect(self.wideband_receiver, 'msgs', self.gsm_extract_system_info, 'msgs')
    rtlsdr_source_0.set_gain_mode(True, 0)
    rtlsdr_source_0.set_bandwidth(options.samp_rate, 0)
    
    head_0 = blocks.head(gr.sizeof_gr_complex*1, int(rec_len*options.samp_rate))
    blocks_rotator_cc_0 = blocks.rotator_cc(-2*pi*0.1e6/options.samp_rate) #shift again by -0.1MHz in order to align channel center in 0Hz
    file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex*1, options.file_name)
    file_sink_0.set_unbuffered(False)
    recorder.connect((rtlsdr_source_0, 0), (head_0, 0))
    recorder.connect((head_0, 0), (blocks_rotator_cc_0, 0))
    recorder.connect((blocks_rotator_cc_0, 0), (file_sink_0, 0))
    
    #setup processing part
    processing = gr.top_block()
    file_source_0 = blocks.file_source(gr.sizeof_gr_complex*1, options.file_name, False) #if file name is given process data from file
    wideband_receiver_0 = wideband_receiver(OSR=4, fc=options.carrier_frequency, samp_rate=options.samp_rate)
    gsm_extract_system_info_0 = grgsm.extract_system_info()
#    socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) #for some reason creation of this object prevents flowgraph from finishing
#    gsm_message_printer_0 = grgsm.message_printer(pmt.intern(""), False)   #might be useful for debuggin
    
    processing.connect((file_source_0, 0), (wideband_receiver_0,0))
    processing.msg_connect(wideband_receiver_0, 'msgs', gsm_extract_system_info_0, 'msgs')
#    processing.msg_connect(wideband_receiver_0, 'msgs', gsm_message_printer_0, 'msgs')
#    processing.msg_connect(wideband_receiver_0, 'msgs', socket_pdu_0, 'pdus')

    recorder.start()
    recorder.wait()
    processing.start()
    processing.wait()
    
#   analysis of gathered data
    channels_num = int(options.samp_rate/0.2e6)
    )  #shift again by -0.1MHz in order to align channel center in 0Hz
    file_sink_0 = blocks.file_sink(gr.sizeof_gr_complex * 1, options.file_name)
    file_sink_0.set_unbuffered(False)
    recorder.connect((rtlsdr_source_0, 0), (head_0, 0))
    recorder.connect((head_0, 0), (blocks_rotator_cc_0, 0))
    recorder.connect((blocks_rotator_cc_0, 0), (file_sink_0, 0))

    #setup processing part
    processing = gr.top_block()
    file_source_0 = blocks.file_source(
        gr.sizeof_gr_complex * 1, options.file_name,
        False)  #if file name is given process data from file
    wideband_receiver_0 = wideband_receiver(OSR=4,
                                            fc=options.carrier_frequency,
                                            samp_rate=options.samp_rate)
    gsm_extract_system_info_0 = grgsm.extract_system_info()
    #    socket_pdu_0 = blocks.socket_pdu("UDP_CLIENT", "127.0.0.1", "4729", 10000, False) #for some reason creation of this object prevents flowgraph from finishing
    #    gsm_message_printer_0 = grgsm.message_printer(pmt.intern(""), False)   #might be useful for debuggin

    processing.connect((file_source_0, 0), (wideband_receiver_0, 0))
    processing.msg_connect(wideband_receiver_0, 'msgs',
                           gsm_extract_system_info_0, 'msgs')
    #    processing.msg_connect(wideband_receiver_0, 'msgs', gsm_message_printer_0, 'msgs')
    #    processing.msg_connect(wideband_receiver_0, 'msgs', socket_pdu_0, 'pdus')

    recorder.start()
    recorder.wait()
    processing.start()
    processing.wait()

    #   analysis of gathered data
Esempio n. 7
0
    def __init__(
        self, rec_len=3, sample_rate=2e6, carrier_frequency=939e6,
        ppm=0, gain=None, if_gain=None, bb_gain=None, offset=None, args=""
    ):
        if offset is None:
            offset = -0.1e6

        gr.top_block.__init__(self, "Wideband Scanner")

        self.rec_len = rec_len
        self.sample_rate = sample_rate
        self.carrier_frequency = carrier_frequency
        self.ppm = ppm

        # if no file name is given process data from rtl_sdr source
        print "Args=", args
        self.osmosdr_source = osmosdr.source(
            args="numchan=" + str(1) + " " + args
        )

        self.osmosdr_source.set_sample_rate(sample_rate)

        # capture half of GSM channel lower than channel center (-0.1MHz)
        # this is needed when even number of channels is captured in order to
        # process full captured bandwidth

        self.osmosdr_source.set_center_freq(carrier_frequency + offset, 0)

        # correction of central frequency
        # if the receiver has large frequency offset
        # the value of this variable should be set close to that offset in ppm
        self.osmosdr_source.set_freq_corr(ppm, 0)

        self.osmosdr_source.set_dc_offset_mode(2, 0)
        self.osmosdr_source.set_iq_balance_mode(0, 0)
        if reduce(lambda _, y: y is not None, [gain, if_gain, bb_gain]):
            self.osmosdr_source.set_gain_mode(False, 0)
            self.osmosdr_source.set_gain(gain or 24, 0)
            self.osmosdr_source.set_if_gain(if_gain or 20, 0)
            self.osmosdr_source.set_bb_gain(bb_gain or 20, 0)
        else:
            self.osmosdr_source.set_gain_mode(True, 0)

        self.osmosdr_source.set_bandwidth(sample_rate, 0)

        self.head = blocks.head(gr.sizeof_gr_complex * 1,
                                int(rec_len * sample_rate))

        # shift again by -0.1MHz in order to align channel center in 0Hz
        if offset:
            self.blocks_rotator_cc = blocks.rotator_cc(
                2 * pi * offset / sample_rate
            )

        self.wideband_receiver = wideband_receiver(
            OSR=4, fc=carrier_frequency, samp_rate=sample_rate)
        self.system_info = grgsm.extract_system_info()

        self.connect((self.osmosdr_source, 0), (self.head, 0))
        if offset:
            self.connect((self.head, 0), (self.blocks_rotator_cc, 0))
            self.connect(
                (self.blocks_rotator_cc, 0), (self.wideband_receiver, 0)
            )
        else:
            self.connect(
                (self.head, 0), (self.wideband_receiver, 0)
            )

        self.msg_connect(self.wideband_receiver, 'msgs',
                         self.system_info, 'msgs')