def std_test (self, src_data, soff, expected): src = blocks.vector_source_c (src_data,False,1) interp = moms(2,1) dst = blocks.vector_sink_c (1) self.tb.connect (src, interp) self.tb.connect (interp, dst) self.tb.run () result_data = dst.data () print result_data self.assertEqual(expected, result_data)
def std_test(self, src_data, soff, expected): src = blocks.vector_source_c(src_data, False, 1) interp = moms(2, 1) dst = blocks.vector_sink_c(1) self.tb.connect(src, interp) self.tb.connect(interp, dst) self.tb.run() result_data = dst.data() print result_data self.assertEqual(expected, result_data)
def test_100(self): vlen = 256 N = int( 5e5 ) soff=40 taps = [1.0,0.0,2e-1+0.1j,1e-4-0.04j] freqoff = 0.0 snr_db = 10 rms_amplitude = 8000 data = [1 + 1j] * vlen #data2 = [2] * vlen src = gr.vector_source_c( data, True, vlen ) v2s = gr.vector_to_stream(gr.sizeof_gr_complex,vlen) #interp = gr.fractional_interpolator_cc(0.0,soff) interp = moms(1000000,1000000+soff) fad_chan = gr.fir_filter_ccc(1,taps) freq_shift = gr.multiply_cc() norm_freq = freqoff / vlen freq_off_src = gr.sig_source_c(1.0, gr.GR_SIN_WAVE, norm_freq, 1.0, 0.0 ) snr = 10.0**(snr_db/10.0) noise_sigma = sqrt( rms_amplitude**2 / snr) awgn_chan = gr.add_cc() awgn_noise_src = ofdm.complex_white_noise( 0.0, noise_sigma ) dst = gr.null_sink( gr.sizeof_gr_complex ) limit = gr.head( gr.sizeof_gr_complex * vlen, N ) self.tb.connect( src, limit, v2s, interp, fad_chan,freq_shift, awgn_chan, dst ) self.tb.connect( freq_off_src,(freq_shift,1)) self.tb.connect( awgn_noise_src,(awgn_chan,1)) r = time_it( self.tb ) print "Rate: %s Samples/second" \ % eng_notation.num_to_str( float(N) * vlen / r )
def test_100(self): vlen = 256 N = int(5e5) soff = 40 taps = [1.0, 0.0, 2e-1 + 0.1j, 1e-4 - 0.04j] freqoff = 0.0 snr_db = 10 rms_amplitude = 8000 data = [1 + 1j] * vlen #data2 = [2] * vlen src = gr.vector_source_c(data, True, vlen) v2s = gr.vector_to_stream(gr.sizeof_gr_complex, vlen) #interp = gr.fractional_interpolator_cc(0.0,soff) interp = moms(1000000, 1000000 + soff) fad_chan = gr.fir_filter_ccc(1, taps) freq_shift = gr.multiply_cc() norm_freq = freqoff / vlen freq_off_src = gr.sig_source_c(1.0, gr.GR_SIN_WAVE, norm_freq, 1.0, 0.0) snr = 10.0**(snr_db / 10.0) noise_sigma = sqrt(rms_amplitude**2 / snr) awgn_chan = gr.add_cc() awgn_noise_src = ofdm.complex_white_noise(0.0, noise_sigma) dst = gr.null_sink(gr.sizeof_gr_complex) limit = gr.head(gr.sizeof_gr_complex * vlen, N) self.tb.connect(src, limit, v2s, interp, fad_chan, freq_shift, awgn_chan, dst) self.tb.connect(freq_off_src, (freq_shift, 1)) self.tb.connect(awgn_noise_src, (awgn_chan, 1)) r = time_it(self.tb) print "Rate: %s Samples/second" \ % eng_notation.num_to_str( float(N) * vlen / r )
def __init__(self, options): gr.top_block.__init__(self, "ofdm_benchmark") self._bandwidth = options.bandwidth self.servants = [] self._verbose = options.verbose self._options = copy.copy(options) self.ideal = options.ideal self.ideal2 = options.ideal2 rms_amp = options.rms_amplitude self._interpolation = 1 f1 = numpy.array([ -107, 0, 445, 0, -1271, 0, 2959, 0, -6107, 0, 11953, 0, -24706, 0, 82359, 262144 / 2, 82359, 0, -24706, 0, 11953, 0, -6107, 0, 2959, 0, -1271, 0, 445, 0, -107 ], numpy.float64) / 262144. print "Software interpolation: %d" % (self._interpolation) bw = 1.0 / self._interpolation tb = bw / 5 if self._interpolation > 1: self.tx_filter = gr.hier_block2( "filter", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_gr_complex)) self.tx_filter.connect(self.tx_filter, gr.interp_fir_filter_ccf(2, f1), gr.interp_fir_filter_ccf(2, f1), self.tx_filter) print "New" else: self.tx_filter = None self.decimation = 1 if self.decimation > 1: bw = 0.5 / self.decimation * 1 tb = bw / 5 # gain, sampling rate, passband cutoff, stopband cutoff # passband ripple in dB, stopband attenuation in dB # extra taps filt_coeff = optfir.low_pass(1.0, 1.0, bw, bw + tb, 0.1, 60.0, 1) print "Software decimation filter length: %d" % (len(filt_coeff)) self.rx_filter = gr.fir_filter_ccf(self.decimation, filt_coeff) else: self.rx_filter = None self._setup_tx_path(options) self._setup_rx_path(options) self._setup_rpc_manager() config = self.config = station_configuration() if options.imgxfer: self.rxpath.setup_imgtransfer_sink() if not options.no_decoding: self.rxpath.publish_rx_performance_measure() # capture transmitter's stream to disk #self.dst = gr.file_sink(gr.sizeof_gr_complex,options.to_file) self.dst = self.rxpath if options.force_rx_filter: print "Forcing rx filter usage" self.connect(self.rx_filter, self.dst) self.dst = self.rx_filter if options.ideal or self.ideal2: self._amplifier = ofdm.multiply_const_ccf(1.0) self.connect(self._amplifier, self.dst) self.dst = self._amplifier self.set_rms_amplitude(rms_amp) if options.measure: self.m = throughput_measure(gr.sizeof_gr_complex) self.connect(self.m, self.dst) self.dst = self.m if options.snr is not None: if options.berm is not None: noise_sigma = 380 / 32767.0 #empirically given, gives the received SNR range of (1:28) for tx amp. range of (500:10000) which is set in rm_ber_measurement.py #check for fading channel else: snr_db = options.snr snr = 10.0**(snr_db / 10.0) noise_sigma = sqrt(config.rms_amplitude**2 / snr) print " Noise St. Dev. %f" % (noise_sigma) awgn_chan = blocks.add_cc() #awgn_noise_src = ofdm.complex_white_noise( 0.0, noise_sigma ) awgn_noise_src = analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise_sigma, 0, 8192) self.connect(awgn_noise_src, (awgn_chan, 1)) self.connect(awgn_chan, self.dst) self.dst = awgn_chan if options.freqoff is not None: freq_off = self.freq_off = channel.freq_offset(options.freqoff) dst = self.dst self.connect(freq_off, dst) self.dst = freq_off self.rpc_mgr_tx.add_interface("set_freq_offset", self.freq_off.set_freqoff) if options.multipath: if options.itu_channel: self.fad_chan = channel.itpp_channel(options.bandwidth) self.rpc_mgr_tx.add_interface( "set_channel_profile", self.fad_chan.set_channel_profile) self.rpc_mgr_tx.add_interface("set_norm_doppler", self.fad_chan.set_norm_doppler) else: #self.fad_chan = filter.fir_filter_ccc(1,[1.0,0.0,2e-1+0.1j,1e-4-0.04j]) # filter coefficients for the lab exercise self.fad_chan = filter.fir_filter_ccc(1, [0.3267, 0.8868, 0.3267]) #self.fad_chan = filter.fir_filter_ccc(1,[0,0,0.1,0.2,0.01,0.3])#0.3267,0.8868,0.3267]) #self.fad_chan = channels.selective_fading_model(5, 0.1, False, 1, -1, [0, 0, 0], [0.3267,0.8868,0.3267], 10 ) #self.fad_chan = channels.fading_model(6, 0.05, False); #self.fad_chan = channels.dynamic_channel_model(1000000, 0, 0, 0, 0, 3, 0.01, False, 0, [2e-6,4e-6,8e-6],[0.3267,0.8868,0.3267], 20, 0, 0) self.connect(self.fad_chan, self.dst) self.dst = self.fad_chan if options.samplingoffset is not None: soff = options.samplingoffset interp = moms(1000000 * (1.0 + soff), 1000000) #interp = filter.fractional_resampler_cc(0,1000000*(1.0+soff)/1000000.0) self.connect(interp, self.dst) self.dst = interp if options.record: log_to_file(self, interp, "data/interp_out.compl") tmm = blocks.throttle(gr.sizeof_gr_complex, options.bandwidth) self.connect(tmm, self.dst) self.dst = tmm if options.force_tx_filter: print "Forcing tx filter usage" self.connect(self.tx_filter, self.dst) self.dst = self.tx_filter if options.record: log_to_file(self, self.txpath, "data/txpath_out.compl") if options.scatterplot: print "Scatterplot enabled" self.connect(self.txpath, self.dst) print "Hit Strg^C to terminate" print "Hit Strg^C to terminate" # Display some information about the setup if self._verbose: self._print_verbage()
def __init__ (self, options): gr.top_block.__init__(self, "ofdm_benchmark") ##self._tx_freq = options.tx_freq # tranmitter's center frequency ##self._tx_subdev_spec = options.tx_subdev_spec # daughterboard to use ##self._fusb_block_size = options.fusb_block_size # usb info for USRP ##self._fusb_nblocks = options.fusb_nblocks # usb info for USRP ##self._which = options.which_usrp self._bandwidth = options.bandwidth self.servants = [] self._verbose = options.verbose ##self._interface = options.interface ##self._mac_addr = options.mac_addr self._options = copy.copy( options ) self._interpolation = 1 f1 = numpy.array([-107,0,445,0,-1271,0,2959,0,-6107,0,11953, 0,-24706,0,82359,262144/2,82359,0,-24706,0, 11953,0,-6107,0,2959,0,-1271,0,445,0,-107], numpy.float64)/262144. print "Software interpolation: %d" % (self._interpolation) bw = 1.0/self._interpolation tb = bw/5 if self._interpolation > 1: self.tx_filter = gr.hier_block2("filter", gr.io_signature(1,1,gr.sizeof_gr_complex), gr.io_signature(1,1,gr.sizeof_gr_complex)) self.tx_filter2 = gr.hier_block2("filter", gr.io_signature(1,1,gr.sizeof_gr_complex), gr.io_signature(1,1,gr.sizeof_gr_complex)) self.tx_filter.connect( self.tx_filter, gr.interp_fir_filter_ccf(2,f1), gr.interp_fir_filter_ccf(2,f1), self.tx_filter ) self.tx_filter2.connect( self.tx_filter2, gr.interp_fir_filter_ccf(2,f1), gr.interp_fir_filter_ccf(2,f1), self.tx_filter2 ) print "New" else: self.tx_filter = None self.tx_filter2 = None self.decimation = 1 if self.decimation > 1: bw = 0.5/self.decimation * 1 tb = bw/5 # gain, sampling rate, passband cutoff, stopband cutoff # passband ripple in dB, stopband attenuation in dB # extra taps filt_coeff = optfir.low_pass(1.0, 1.0, bw, bw+tb, 0.1, 60.0, 1) print "Software decimation filter length: %d" % (len(filt_coeff)) self.rx_filter = gr.fir_filter_ccf(self.decimation,filt_coeff) self.rx_filter2 = gr.fir_filter_ccf(self.decimation,filt_coeff) else: self.rx_filter = None self.rx_filter2 = None ## if not options.from_file is None: ## # sent captured file to usrp ## self.src = gr.file_source(gr.sizeof_gr_complex,options.from_file) ## self._setup_usrp_sink() ## if hasattr(self, "filter"): ## self.connect(self.src,self.filter,self.u) #,self.filter ## else: ## self.connect(self.src,self.u) ## ## return self._setup_tx_path(options) self._setup_rx_path(options) config = station_configuration() self.enable_info_tx("info_tx", "pa_user") # if not options.no_cheat: # self.txpath.enable_channel_cheating("channelcheat") self.txpath.enable_txpower_adjust("txpower") self.txpath.publish_txpower("txpower_info") if options.disable_equalization or options.ideal: #print "CHANGE set_k" self.rxpath.enable_estim_power_adjust("estim_power") #self.rxpath.publish_estim_power("txpower_info") #self.enable_txfreq_adjust("txfreq") if options.imgxfer: self.rxpath.setup_imgtransfer_sink() if not options.no_decoding: self.rxpath.publish_rx_performance_measure() self.dst = (self.rxpath,0) self.dst2 = (self.rxpath,1) if options.force_rx_filter: print "Forcing rx filter usage" self.connect( self.rx_filter, self.dst ) self.connect( self.rx_filter2, self.dst2 ) self.dst = self.rx_filter self.dst2 = self.rx_filter2 if options.measure: self.m = throughput_measure(gr.sizeof_gr_complex) self.m2 = throughput_measure(gr.sizeof_gr_complex) self.connect( self.m, self.dst ) self.connect( self.m2, self.dst2 ) self.dst = self.m self.dst2 = self.m2 if options.snr is not None: if options.berm is not False: noise_sigma = 380 #empirically given, gives the received SNR range of (1:28) for tx amp. range of (500:10000) which is set in rm_ber_measurement.py #check for fading channel else: snr_db = options.snr snr = 10.0**(snr_db/10.0) noise_sigma = sqrt( config.rms_amplitude**2 / snr ) print " Noise St. Dev. %d" % (noise_sigma) awgn_chan = blocks.add_cc() awgn_chan2 = blocks.add_cc() awgn_noise_src = ofdm.complex_white_noise( 0.0, noise_sigma ) awgn_noise_src2 = ofdm.complex_white_noise( 0.0, noise_sigma ) self.connect( awgn_chan, self.dst ) self.connect( awgn_chan2, self.dst2 ) self.connect( awgn_noise_src, (awgn_chan,1) ) self.connect( awgn_noise_src2, (awgn_chan2,1) ) self.dst = awgn_chan self.dst2 = awgn_chan2 if options.freqoff is not None: freq_shift = blocks.multiply_cc() freq_shift2 = blocks.multiply_cc() norm_freq = options.freqoff / config.fft_length freq_off_src = analog.sig_source_c(1.0, analog.GR_SIN_WAVE, norm_freq, 1.0, 0.0 ) freq_off_src2 = analog.sig_source_c(1.0, analog.GR_SIN_WAVE, norm_freq, 1.0, 0.0 ) self.connect( freq_off_src, ( freq_shift, 1 ) ) self.connect( freq_off_src2, ( freq_shift2, 1 ) ) dst = self.dst dst2 = self.dst2 self.connect( freq_shift, dst ) self.connect( freq_shift2, dst2 ) self.dst = freq_shift self.dst2 = freq_shift2 if options.multipath: if options.itu_channel: fad_chan = itpp.tdl_channel( ) #[0, -7, -20], [0, 2, 6] #fad_chan.set_norm_doppler( 1e-9 ) #fad_chan.set_LOS( [500.,0,0] ) fad_chan2 = itpp.tdl_channel( ) fad_chan.set_channel_profile( itpp.ITU_Pedestrian_A, 5e-8 ) fad_chan.set_norm_doppler( 1e-8 ) fad_chan2.set_channel_profile( itpp.ITU_Pedestrian_A, 5e-8 ) fad_chan2.set_norm_doppler( 1e-8 ) else: fad_chan = gr.fir_filter_ccc(1,[1.0,0.0,2e-1+0.1j,1e-4-0.04j]) fad_chan2 = gr.fir_filter_ccc(1,[1.0,0.0,2e-1+0.1j,1e-4-0.04j]) self.connect( fad_chan, self.dst ) self.connect( fad_chan2, self.dst2 ) self.dst = fad_chan self.dst2 = fad_chan2 if options.samplingoffset is not None: soff = options.samplingoffset interp = moms(1000000+soff,1000000) interp2 = moms(1000000+soff,1000000) self.connect( interp, self.dst ) self.connect( interp2, self.dst2 ) self.dst = interp self.dst2 = interp2 if options.record: log_to_file( self, interp, "data/interp_out.compl" ) log_to_file( self, interp2, "data/interp2_out.compl" ) tmm =blocks.throttle(gr.sizeof_gr_complex,self._bandwidth) tmm2 =blocks.throttle(gr.sizeof_gr_complex,self._bandwidth) tmm_add = blocks.add_cc() tmm2_add = blocks.add_cc() self.connect( tmm, tmm_add ) self.connect( tmm2, (tmm_add,1) ) self.connect( tmm, tmm2_add ) self.connect( tmm2, (tmm2_add,1) ) self.connect( tmm_add, self.dst ) self.connect( tmm2_add, self.dst2 ) self.dst = tmm self.dst2 = tmm2 inter = blocks.interleave(gr.sizeof_gr_complex) deinter = blocks.deinterleave(gr.sizeof_gr_complex) self.connect(inter, deinter) self.connect((deinter,0),self.dst) self.connect((deinter,1),self.dst2) self.dst = inter self.dst2 = (inter,1) if options.force_tx_filter: print "Forcing tx filter usage" self.connect( self.tx_filter, self.dst ) self.connect( self.tx_filter2, self.dst2 ) self.dst = self.tx_filter self.dst2 = self.tx_filter2 if options.record: log_to_file( self, self.txpath, "data/txpath_out.compl" ) log_to_file( self, self.txpath2, "data/txpath2_out.compl" ) if options.nullsink: self.connect(gr.null_source(gr.sizeof_gr_complex), self.dst) self.connect(gr.null_source(gr.sizeof_gr_complex), self.dst2) self.dst = gr.null_sink(gr.sizeof_gr_complex) self.dst2 = gr.null_sink(gr.sizeof_gr_complex) self.connect( self.txpath,self.dst ) self.connect( (self.txpath,1),self.dst2 ) if options.cheat: self.txpath.enable_channel_cheating("channelcheat") print "Hit Strg^C to terminate" if options.event_rxbaseband: self.publish_rx_baseband_measure() if options.with_old_gui: self.publish_spectrum(256) self.rxpath.publish_ctf("ctf_display") self.rxpath.publish_ber_measurement(["ber"]) self.rxpath.publish_average_snr(["totalsnr"]) if options.sinr_est: self.rxpath.publish_sinrsc("sinrsc_display") print "Hit Strg^C to terminate" # Display some information about the setup if self._verbose: self._print_verbage()
def __init__ (self, options): gr.top_block.__init__(self, "ofdm_mrrc_benchmark") ##self._tx_freq = options.tx_freq # tranmitter's center frequency ##self._tx_subdev_spec = options.tx_subdev_spec # daughterboard to use ##self._fusb_block_size = options.fusb_block_size # usb info for USRP ##self._fusb_nblocks = options.fusb_nblocks # usb info for USRP ##self._which = options.which_usrp self._bandwidth = options.bandwidth self.servants = [] self._verbose = options.verbose ##self._interface = options.interface ##self._mac_addr = options.mac_addr self._options = copy.copy( options ) self._interpolation = 1 f1 = numpy.array([-107,0,445,0,-1271,0,2959,0,-6107,0,11953, 0,-24706,0,82359,262144/2,82359,0,-24706,0, 11953,0,-6107,0,2959,0,-1271,0,445,0,-107], numpy.float64)/262144. print "Software interpolation: %d" % (self._interpolation) bw = 1.0/self._interpolation tb = bw/5 if self._interpolation > 1: self.tx_filter = gr.hier_block2("filter", gr.io_signature(1,1,gr.sizeof_gr_complex), gr.io_signature(1,1,gr.sizeof_gr_complex)) self.tx_filter2 = gr.hier_block2("filter", gr.io_signature(1,1,gr.sizeof_gr_complex), gr.io_signature(1,1,gr.sizeof_gr_complex)) self.tx_filter.connect( self.tx_filter, gr.interp_fir_filter_ccf(2,f1), gr.interp_fir_filter_ccf(2,f1), self.tx_filter ) self.tx_filter2.connect( self.tx_filter2, gr.interp_fir_filter_ccf(2,f1), gr.interp_fir_filter_ccf(2,f1), self.tx_filter2 ) print "New" else: self.tx_filter = None self.tx_filter2 = None self.decimation = 1 if self.decimation > 1: bw = 0.5/self.decimation * 1 tb = bw/5 # gain, sampling rate, passband cutoff, stopband cutoff # passband ripple in dB, stopband attenuation in dB # extra taps filt_coeff = optfir.low_pass(1.0, 1.0, bw, bw+tb, 0.1, 60.0, 1) print "Software decimation filter length: %d" % (len(filt_coeff)) self.rx_filter = gr.fir_filter_ccf(self.decimation,filt_coeff) self.rx_filter2 = gr.fir_filter_ccf(self.decimation,filt_coeff) else: self.rx_filter = None self.rx_filter2 = None ## if not options.from_file is None: ## # sent captured file to usrp ## self.src = gr.file_source(gr.sizeof_gr_complex,options.from_file) ## self._setup_usrp_sink() ## if hasattr(self, "filter"): ## self.connect(self.src,self.filter,self.u) #,self.filter ## else: ## self.connect(self.src,self.u) ## ## return self._setup_tx_path(options) self._setup_rx_path(options) self._setup_rpc_manager() config = self.config = station_configuration() #self.enable_txfreq_adjust("txfreq") if options.imgxfer: self.rxpath.setup_imgtransfer_sink() if not options.no_decoding: self.rxpath.publish_rx_performance_measure() self.dst = (self.rxpath,0) self.dst2 = (self.rxpath,1) if options.force_rx_filter: print "Forcing rx filter usage" self.connect( self.rx_filter, self.dst ) self.connect( self.rx_filter2, self.dst2 ) self.dst = self.rx_filter self.dst2 = self.rx_filter2 if options.measure: self.m = throughput_measure(gr.sizeof_gr_complex) self.m2 = throughput_measure(gr.sizeof_gr_complex) self.connect( self.m, self.dst ) self.connect( self.m2, self.dst2 ) self.dst = self.m self.dst2 = self.m2 if options.snr is not None: if options.berm is not None: noise_sigma = 380/32767.0 #empirically given, gives the received SNR range of (1:28) for tx amp. range of (500:10000) which is set in rm_ber_measurement.py print " Noise St. Dev. %f" % (noise_sigma)#check for fading channel else: snr_db = options.snr snr = 10.0**(snr_db/10.0) noise_sigma = sqrt( config.rms_amplitude**2 / snr ) print " Noise St. Dev. %f" % (noise_sigma) awgn_chan = blocks.add_cc() awgn_chan2 = blocks.add_cc() awgn_noise_src = analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise_sigma, 0, 8192) awgn_noise_src2 = analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise_sigma*2, 0, 2192) self.connect( awgn_chan, self.dst ) self.connect( awgn_chan2, self.dst2 ) self.connect( awgn_noise_src, (awgn_chan,1) ) self.connect( awgn_noise_src2, (awgn_chan2,1) ) self.dst = awgn_chan self.dst2 = awgn_chan2 if options.freqoff is not None: freq_off = self.freq_off = channel.freq_offset(options.freqoff ) freq_off2 = self.freq_off2 = channel.freq_offset(options.freqoff ) dst = self.dst dst2 = self.dst2 self.connect( freq_off, dst ) self.connect( freq_off2, dst2 ) self.dst = freq_off self.dst2 = freq_off2 self.rpc_mgr_tx.add_interface("set_freq_offset",self.freq_off.set_freqoff) self.rpc_mgr_tx.add_interface("set_freq_offset2",self.freq_off2.set_freqoff) if options.multipath: if options.itu_channel: self.fad_chan = channel.itpp_channel(options.bandwidth) #fad_chan.set_norm_doppler( 1e-9 ) #fad_chan.set_LOS( [500.,0,0] ) self.fad_chan2 = channel.itpp_channel(options.bandwidth) self.fad_chan.set_channel_profile( itpp.ITU_Pedestrian_A, 5e-8 ) self.fad_chan.set_norm_doppler( 1e-8 ) self.fad_chan2.set_channel_profile( itpp.ITU_Pedestrian_A, 5e-8 ) self.fad_chan2.set_norm_doppler( 1e-8 ) self.rpc_mgr_tx.add_interface("set_channel_profile",self.fad_chan.set_channel_profile) self.rpc_mgr_tx.add_interface("set_channel_profile",self.fad_chan2.set_channel_profile) else: fad_chan = filter.fir_filter_ccc(1,[1.0,0.0,2e-1+0.1j,1e-4-0.04j]) fad_chan2 = filter.fir_filter_ccc(1,[1.0,0.0,2e-1+0.1j,1e-4-0.04j]) self.connect( self.fad_chan, self.dst ) self.connect( self.fad_chan2, self.dst2 ) self.dst = self.fad_chan self.dst2 = self.fad_chan2 if options.samplingoffset is not None: soff = options.samplingoffset interp = moms(1000000*(1.0+soff),1000000) interp2 = moms(1000000*(1.0+soff),1000000) self.connect( interp, self.dst ) self.connect( interp2, self.dst2 ) self.dst = interp self.dst2 = interp2 if options.record: log_to_file( self, interp, "data/interp_out.compl" ) log_to_file( self, interp2, "data/interp2_out.compl" ) tmm =blocks.throttle(gr.sizeof_gr_complex, 1e6) #tmm2 =blocks.throttle(gr.sizeof_gr_complex, 1e6) #self.connect( tmm, self.dst ) #self.connect( tmm2, self.dst2 ) #self.dst = tmm #self.dst2 = tmm2 #inter = blocks.interleave(gr.sizeof_gr_complex) #deinter = blocks.deinterleave(gr.sizeof_gr_complex) # Interleaving input/output streams ##self.connect(inter, deinter) #self.connect((deinter,0),self.dst) #self.connect((deinter,1),self.dst2) #self.dst = inter #self.dst2 = (inter,1) if options.force_tx_filter: print "Forcing tx filter usage" self.connect( self.tx_filter, self.dst ) self.connect( self.tx_filter2, self.dst2 ) self.dst = self.tx_filter self.dst2 = self.tx_filter2 if options.record: log_to_file( self, self.txpath, "data/txpath_out.compl" ) log_to_file( self, self.txpath2, "data/txpath2_out.compl" ) if options.nullsink: self.connect(gr.null_source(gr.sizeof_gr_complex), self.dst) self.connect(gr.null_source(gr.sizeof_gr_complex), self.dst2) self.dst = gr.null_sink(gr.sizeof_gr_complex) self.dst2 = gr.null_sink(gr.sizeof_gr_complex) self.connect( self.txpath,tmm,self.dst ) self.connect( tmm,self.dst2 ) #self.connect( self.txpath,self.dst2 ) print "Hit Strg^C to terminate" if self._verbose: self._print_verbage()
def __init__ (self, options): gr.top_block.__init__(self, "fbmc_benchmark") self._bandwidth = options.bandwidth self.servants = [] self._verbose = options.verbose self._options = copy.copy( options ) self.ideal = options.ideal self.ideal2 = options.ideal2 rms_amp = options.rms_amplitude #Disable OFDM channel estimation preamble -> Still experimental options.est_preamble = 0 self._interpolation = 1 f1 = numpy.array([-107,0,445,0,-1271,0,2959,0,-6107,0,11953, 0,-24706,0,82359,262144/2,82359,0,-24706,0, 11953,0,-6107,0,2959,0,-1271,0,445,0,-107], numpy.float64)/262144. print "Software interpolation: %d" % (self._interpolation) bw = 1.0/self._interpolation tb = bw/5 if self._interpolation > 1: self.tx_filter = gr.hier_block2("filter", gr.io_signature(1,1,gr.sizeof_gr_complex), gr.io_signature(1,1,gr.sizeof_gr_complex)) self.tx_filter.connect( self.tx_filter, gr.interp_fir_filter_ccf(2,f1), gr.interp_fir_filter_ccf(2,f1), self.tx_filter ) print "New" else: self.tx_filter = None self.decimation = 1 if self.decimation > 1: bw = 0.5/self.decimation * 1 tb = bw/5 # gain, sampling rate, passband cutoff, stopband cutoff # passband ripple in dB, stopband attenuation in dB # extra taps filt_coeff = optfir.low_pass(1.0, 1.0, bw, bw+tb, 0.1, 60.0, 1) print "Software decimation filter length: %d" % (len(filt_coeff)) self.rx_filter = gr.fir_filter_ccf(self.decimation,filt_coeff) else: self.rx_filter = None self._setup_tx_path(options) self._setup_rx_path(options) self._setup_rpc_manager() config = self.config = station_configuration() if options.imgxfer: self.rxpath.setup_imgtransfer_sink() if not options.no_decoding: self.rxpath.publish_rx_performance_measure() # capture transmitter's stream to disk #self.dst = gr.file_sink(gr.sizeof_gr_complex,options.to_file) self.dst= self.rxpath if options.force_rx_filter: print "Forcing rx filter usage" self.connect( self.rx_filter, self.dst ) self.dst = self.rx_filter if options.ideal or self.ideal2: self._amplifier = ofdm.multiply_const_ccf( 1.0 ) self.connect( self._amplifier, self.dst ) self.dst = self._amplifier self.set_rms_amplitude(rms_amp) if options.measure: self.m = throughput_measure(gr.sizeof_gr_complex) self.connect( self.m, self.dst ) self.dst = self.m if options.snr is not None: if options.berm is not None: #noise_sigma = 0.0001/32767.0 noise_sigma = 380/32767.0#250/32767.0 #380/32767.0 #empirically given, gives the received SNR range of (1:28) for tx amp. range of (500:10000) which is set in rm_ber_measurement.py #check for fading channel else: snr_db = options.snr snr = 10.0**(snr_db/10.0) noise_sigma = sqrt( config.rms_amplitude**2 / snr ) print " Noise St. Dev. %d" % (noise_sigma) awgn_chan = blocks.add_cc() #awgn_noise_src = ofdm.complex_white_noise( 0.0, noise_sigma ) #noise_sigma = 0.000000000001 awgn_noise_src = analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise_sigma, 0, 8192) self.connect( awgn_noise_src, (awgn_chan,1) ) self.connect( awgn_chan,self.dst ) #self.connect( awgn_chan, blocks.skiphead( gr.sizeof_gr_complex, 3* config.fft_length ),self.dst ) self.dst = awgn_chan if options.freqoff is not None: freq_off = self.freq_off = channel.freq_offset(options.freqoff ) dst = self.dst self.connect(freq_off, dst) self.dst = freq_off self.rpc_mgr_tx.add_interface("set_freq_offset",self.freq_off.set_freqoff) #log_to_file( self, self.freq_off, "data/TRANSMITTER_OUT.compl" ) if options.multipath: if options.itu_channel: self.fad_chan = channel.itpp_channel(options.bandwidth) self.rpc_mgr_tx.add_interface("set_channel_profile",self.fad_chan.set_channel_profile) else: #self.fad_chan = filter.fir_filter_ccc(1,[1.0,0.0,2e-1+0.1j,1e-4-0.04j]) # filter coefficients for the lab exercise self.fad_chan = filter.fir_filter_ccc(1,[0,0,0.3267,0.8868,0.3267]) self.connect(self.fad_chan, self.dst) self.dst = self.fad_chan if options.samplingoffset is not None: soff = options.samplingoffset interp = moms(1000000*(1.0+soff),1000000) self.connect( interp, self.dst ) self.dst = interp if options.record: log_to_file( self, interp, "data/interp_out.compl" ) tmm =blocks.throttle(gr.sizeof_gr_complex,1e6) self.connect( tmm, self.dst ) self.dst = tmm if options.force_tx_filter: print "Forcing tx filter usage" self.connect( self.tx_filter, self.dst ) self.dst = self.tx_filter if options.record: log_to_file( self, self.txpath, "data/txpath_out.compl" ) if options.scatterplot: print "Scatterplot enabled" self.connect( self.txpath,self.dst ) #log_to_file( self, self.txpath, "data/fbmc_rx_input.compl" ) print "Hit Strg^C to terminate" print "Hit Strg^C to terminate" # Display some information about the setup if self._verbose: self._print_verbage()
def __init__ (self, options): gr.top_block.__init__(self, "ofdm_benchmark") self._bandwidth = options.bandwidth self.servants = [] self._verbose = options.verbose self._options = copy.copy( options ) self.ideal = options.ideal self.ideal2 = options.ideal2 rms_amp = options.rms_amplitude self._interpolation = 1 f1 = numpy.array([-107,0,445,0,-1271,0,2959,0,-6107,0,11953, 0,-24706,0,82359,262144/2,82359,0,-24706,0, 11953,0,-6107,0,2959,0,-1271,0,445,0,-107], numpy.float64)/262144. print "Software interpolation: %d" % (self._interpolation) bw = 1.0/self._interpolation tb = bw/5 if self._interpolation > 1: self.tx_filter = gr.hier_block2("filter", gr.io_signature(1,1,gr.sizeof_gr_complex), gr.io_signature(1,1,gr.sizeof_gr_complex)) self.tx_filter.connect( self.tx_filter, gr.interp_fir_filter_ccf(2,f1), gr.interp_fir_filter_ccf(2,f1), self.tx_filter ) print "New" else: self.tx_filter = None self.decimation = 1 if self.decimation > 1: bw = 0.5/self.decimation * 1 tb = bw/5 # gain, sampling rate, passband cutoff, stopband cutoff # passband ripple in dB, stopband attenuation in dB # extra taps filt_coeff = optfir.low_pass(1.0, 1.0, bw, bw+tb, 0.1, 60.0, 1) print "Software decimation filter length: %d" % (len(filt_coeff)) self.rx_filter = gr.fir_filter_ccf(self.decimation,filt_coeff) else: self.rx_filter = None self._setup_tx_path(options) self._setup_rx_path(options) self._setup_rpc_manager() config = self.config = station_configuration() if options.imgxfer: self.rxpath.setup_imgtransfer_sink() if not options.no_decoding: self.rxpath.publish_rx_performance_measure() # capture transmitter's stream to disk #self.dst = gr.file_sink(gr.sizeof_gr_complex,options.to_file) self.dst= self.rxpath if options.force_rx_filter: print "Forcing rx filter usage" self.connect( self.rx_filter, self.dst ) self.dst = self.rx_filter if options.ideal or self.ideal2: self._amplifier = ofdm.multiply_const_ccf( 1.0 ) self.connect( self._amplifier, self.dst ) self.dst = self._amplifier self.set_rms_amplitude(rms_amp) if options.measure: self.m = throughput_measure(gr.sizeof_gr_complex) self.connect( self.m, self.dst ) self.dst = self.m if options.snr is not None: if options.berm is not None: # empirically determined to reach 30db SNR max in simulation mode noise_sigma = 0.0035 else: snr_db = options.snr snr = 10.0**(snr_db/10.0) noise_sigma = sqrt( config.rms_amplitude**2 / snr ) print " Noise St. Dev. %f" % (noise_sigma) awgn_chan = blocks.add_cc() #awgn_noise_src = ofdm.complex_white_noise( 0.0, noise_sigma ) awgn_noise_src = analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise_sigma, 0, 8192) self.connect( awgn_noise_src, (awgn_chan,1) ) self.connect( awgn_chan, self.dst ) self.dst = awgn_chan if options.freqoff is not None: freq_off = self.freq_off = channel.freq_offset(options.freqoff ) dst = self.dst self.connect(freq_off, dst) self.dst = freq_off self.rpc_mgr_tx.add_interface("set_freq_offset",self.freq_off.set_freqoff) if options.multipath: if options.itu_channel: self.fad_chan = channel.itpp_channel(options.bandwidth) self.rpc_mgr_tx.add_interface("set_channel_profile",self.fad_chan.set_channel_profile) self.rpc_mgr_tx.add_interface("set_norm_doppler",self.fad_chan.set_norm_doppler) else: #self.fad_chan = filter.fir_filter_ccc(1,[1.0,0.0,2e-1+0.1j,1e-4-0.04j]) # filter coefficients for the lab exercise self.fad_chan = filter.fir_filter_ccc(1,[0.3267,0.8868,0.3267]) #self.fad_chan = filter.fir_filter_ccc(1,[0,0,0.1,0.2,0.01,0.3])#0.3267,0.8868,0.3267]) #self.fad_chan = channels.selective_fading_model(5, 0.1, False, 1, -1, [0, 0, 0], [0.3267,0.8868,0.3267], 10 ) #self.fad_chan = channels.fading_model(6, 0.05, False); #self.fad_chan = channels.dynamic_channel_model(1000000, 0, 0, 0, 0, 3, 0.01, False, 0, [2e-6,4e-6,8e-6],[0.3267,0.8868,0.3267], 20, 0, 0) self.connect(self.fad_chan, self.dst) self.dst = self.fad_chan if options.samplingoffset is not None: soff = options.samplingoffset interp = moms(1000000*(1.0+soff),1000000) #interp = filter.fractional_resampler_cc(0,1000000*(1.0+soff)/1000000.0) self.connect( interp, self.dst ) self.dst = interp if options.record: log_to_file( self, interp, "data/interp_out.compl" ) tmm =blocks.throttle(gr.sizeof_gr_complex,options.bandwidth) self.connect( tmm, self.dst ) self.dst = tmm if options.force_tx_filter: print "Forcing tx filter usage" self.connect( self.tx_filter, self.dst ) self.dst = self.tx_filter if options.record: log_to_file( self, self.txpath, "data/txpath_out.compl" ) if options.scatterplot: print "Scatterplot enabled" self.connect( self.txpath,self.dst ) print "Hit Strg^C to terminate" print "Hit Strg^C to terminate" # Display some information about the setup if self._verbose: self._print_verbage()
def __init__(self, options): gr.top_block.__init__(self, "ofdm_mrrc_benchmark") ##self._tx_freq = options.tx_freq # tranmitter's center frequency ##self._tx_subdev_spec = options.tx_subdev_spec # daughterboard to use ##self._fusb_block_size = options.fusb_block_size # usb info for USRP ##self._fusb_nblocks = options.fusb_nblocks # usb info for USRP ##self._which = options.which_usrp self._bandwidth = options.bandwidth self.servants = [] self._verbose = options.verbose ##self._interface = options.interface ##self._mac_addr = options.mac_addr self._options = copy.copy(options) self._interpolation = 1 f1 = numpy.array([ -107, 0, 445, 0, -1271, 0, 2959, 0, -6107, 0, 11953, 0, -24706, 0, 82359, 262144 / 2, 82359, 0, -24706, 0, 11953, 0, -6107, 0, 2959, 0, -1271, 0, 445, 0, -107 ], numpy.float64) / 262144. print "Software interpolation: %d" % (self._interpolation) bw = 1.0 / self._interpolation tb = bw / 5 if self._interpolation > 1: self.tx_filter = gr.hier_block2( "filter", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_gr_complex)) self.tx_filter2 = gr.hier_block2( "filter", gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(1, 1, gr.sizeof_gr_complex)) self.tx_filter.connect(self.tx_filter, gr.interp_fir_filter_ccf(2, f1), gr.interp_fir_filter_ccf(2, f1), self.tx_filter) self.tx_filter2.connect(self.tx_filter2, gr.interp_fir_filter_ccf(2, f1), gr.interp_fir_filter_ccf(2, f1), self.tx_filter2) print "New" else: self.tx_filter = None self.tx_filter2 = None self.decimation = 1 if self.decimation > 1: bw = 0.5 / self.decimation * 1 tb = bw / 5 # gain, sampling rate, passband cutoff, stopband cutoff # passband ripple in dB, stopband attenuation in dB # extra taps filt_coeff = optfir.low_pass(1.0, 1.0, bw, bw + tb, 0.1, 60.0, 1) print "Software decimation filter length: %d" % (len(filt_coeff)) self.rx_filter = gr.fir_filter_ccf(self.decimation, filt_coeff) self.rx_filter2 = gr.fir_filter_ccf(self.decimation, filt_coeff) else: self.rx_filter = None self.rx_filter2 = None ## if not options.from_file is None: ## # sent captured file to usrp ## self.src = gr.file_source(gr.sizeof_gr_complex,options.from_file) ## self._setup_usrp_sink() ## if hasattr(self, "filter"): ## self.connect(self.src,self.filter,self.u) #,self.filter ## else: ## self.connect(self.src,self.u) ## ## return self._setup_tx_path(options) self._setup_rx_path(options) self._setup_rpc_manager() config = self.config = station_configuration() #self.enable_txfreq_adjust("txfreq") if options.imgxfer: self.rxpath.setup_imgtransfer_sink() if not options.no_decoding: self.rxpath.publish_rx_performance_measure() self.dst = (self.rxpath, 0) self.dst2 = (self.rxpath, 1) if options.force_rx_filter: print "Forcing rx filter usage" self.connect(self.rx_filter, self.dst) self.connect(self.rx_filter2, self.dst2) self.dst = self.rx_filter self.dst2 = self.rx_filter2 if options.measure: self.m = throughput_measure(gr.sizeof_gr_complex) self.m2 = throughput_measure(gr.sizeof_gr_complex) self.connect(self.m, self.dst) self.connect(self.m2, self.dst2) self.dst = self.m self.dst2 = self.m2 if options.snr is not None: if options.berm is not None: noise_sigma = 380 / 32767.0 #empirically given, gives the received SNR range of (1:28) for tx amp. range of (500:10000) which is set in rm_ber_measurement.py print " Noise St. Dev. %f" % (noise_sigma ) #check for fading channel else: snr_db = options.snr snr = 10.0**(snr_db / 10.0) noise_sigma = sqrt(config.rms_amplitude**2 / snr) print " Noise St. Dev. %f" % (noise_sigma) awgn_chan = blocks.add_cc() awgn_chan2 = blocks.add_cc() awgn_noise_src = analog.fastnoise_source_c(analog.GR_GAUSSIAN, noise_sigma, 0, 8192) awgn_noise_src2 = analog.fastnoise_source_c( analog.GR_GAUSSIAN, noise_sigma * 2, 0, 2192) self.connect(awgn_chan, self.dst) self.connect(awgn_chan2, self.dst2) self.connect(awgn_noise_src, (awgn_chan, 1)) self.connect(awgn_noise_src2, (awgn_chan2, 1)) self.dst = awgn_chan self.dst2 = awgn_chan2 if options.freqoff is not None: freq_off = self.freq_off = channel.freq_offset(options.freqoff) freq_off2 = self.freq_off2 = channel.freq_offset(options.freqoff) dst = self.dst dst2 = self.dst2 self.connect(freq_off, dst) self.connect(freq_off2, dst2) self.dst = freq_off self.dst2 = freq_off2 self.rpc_mgr_tx.add_interface("set_freq_offset", self.freq_off.set_freqoff) self.rpc_mgr_tx.add_interface("set_freq_offset2", self.freq_off2.set_freqoff) if options.multipath: if options.itu_channel: self.fad_chan = channel.itpp_channel(options.bandwidth) #fad_chan.set_norm_doppler( 1e-9 ) #fad_chan.set_LOS( [500.,0,0] ) self.fad_chan2 = channel.itpp_channel(options.bandwidth) self.fad_chan.set_channel_profile(itpp.ITU_Pedestrian_A, 5e-8) self.fad_chan.set_norm_doppler(1e-8) self.fad_chan2.set_channel_profile(itpp.ITU_Pedestrian_A, 5e-8) self.fad_chan2.set_norm_doppler(1e-8) self.rpc_mgr_tx.add_interface( "set_channel_profile", self.fad_chan.set_channel_profile) self.rpc_mgr_tx.add_interface( "set_channel_profile", self.fad_chan2.set_channel_profile) else: fad_chan = filter.fir_filter_ccc( 1, [1.0, 0.0, 2e-1 + 0.1j, 1e-4 - 0.04j]) fad_chan2 = filter.fir_filter_ccc( 1, [1.0, 0.0, 2e-1 + 0.1j, 1e-4 - 0.04j]) self.connect(self.fad_chan, self.dst) self.connect(self.fad_chan2, self.dst2) self.dst = self.fad_chan self.dst2 = self.fad_chan2 if options.samplingoffset is not None: soff = options.samplingoffset interp = moms(1000000 * (1.0 + soff), 1000000) interp2 = moms(1000000 * (1.0 + soff), 1000000) self.connect(interp, self.dst) self.connect(interp2, self.dst2) self.dst = interp self.dst2 = interp2 if options.record: log_to_file(self, interp, "data/interp_out.compl") log_to_file(self, interp2, "data/interp2_out.compl") tmm = blocks.throttle(gr.sizeof_gr_complex, 1e6) #tmm2 =blocks.throttle(gr.sizeof_gr_complex, 1e6) #self.connect( tmm, self.dst ) #self.connect( tmm2, self.dst2 ) #self.dst = tmm #self.dst2 = tmm2 #inter = blocks.interleave(gr.sizeof_gr_complex) #deinter = blocks.deinterleave(gr.sizeof_gr_complex) # Interleaving input/output streams ##self.connect(inter, deinter) #self.connect((deinter,0),self.dst) #self.connect((deinter,1),self.dst2) #self.dst = inter #self.dst2 = (inter,1) if options.force_tx_filter: print "Forcing tx filter usage" self.connect(self.tx_filter, self.dst) self.connect(self.tx_filter2, self.dst2) self.dst = self.tx_filter self.dst2 = self.tx_filter2 if options.record: log_to_file(self, self.txpath, "data/txpath_out.compl") log_to_file(self, self.txpath2, "data/txpath2_out.compl") if options.nullsink: self.connect(gr.null_source(gr.sizeof_gr_complex), self.dst) self.connect(gr.null_source(gr.sizeof_gr_complex), self.dst2) self.dst = gr.null_sink(gr.sizeof_gr_complex) self.dst2 = gr.null_sink(gr.sizeof_gr_complex) self.connect(self.txpath, tmm, self.dst) self.connect(tmm, self.dst2) #self.connect( self.txpath,self.dst2 ) print "Hit Strg^C to terminate" if self._verbose: self._print_verbage()