def set_increment_usrp_address_bool(self, increment_usrp_address_bool): self.increment_usrp_address_bool = increment_usrp_address_bool self.set_usrp_ip_list( temp_py_mod.make_usrp_ip_list(self.increment_usrp_address_bool, self.usrp_ip_prefix_str, self.usrp_ip_base, self.num_nodes))
def __init__(self, config_file='envsim.ini'): gr.top_block.__init__(self, "Env Sim Server") ################################################## # Parameters ################################################## self.config_file = config_file ################################################## # Variables ################################################## self._usrp_ip_prefix_str_config = ConfigParser.ConfigParser() self._usrp_ip_prefix_str_config.read(config_file) try: usrp_ip_prefix_str = self._usrp_ip_prefix_str_config.get( 'main', 'usrp_ip_prefix') except: usrp_ip_prefix_str = '192.168.40.' self.usrp_ip_prefix_str = usrp_ip_prefix_str self._usrp_ip_base_config = ConfigParser.ConfigParser() self._usrp_ip_base_config.read(config_file) try: usrp_ip_base = self._usrp_ip_base_config.getint( 'main', 'usrp_ip_base') except: usrp_ip_base = 101 self.usrp_ip_base = usrp_ip_base self.num_nodes = num_nodes = 6 self.now = now = time.time() self._increment_usrp_address_bool_config = ConfigParser.ConfigParser() self._increment_usrp_address_bool_config.read(config_file) try: increment_usrp_address_bool = self._increment_usrp_address_bool_config.getboolean( 'main', 'increment_usrp_address') except: increment_usrp_address_bool = True self.increment_usrp_address_bool = increment_usrp_address_bool self.zmq_base_addr = zmq_base_addr = "tcp://10.169.25.150:" self.usrp_ip_list = usrp_ip_list = temp_py_mod.make_usrp_ip_list( increment_usrp_address_bool, usrp_ip_prefix_str, usrp_ip_base, num_nodes) self._samp_rate_config = ConfigParser.ConfigParser() self._samp_rate_config.read(config_file) try: samp_rate = self._samp_rate_config.getfloat('main', 'samp_rate') except: samp_rate = 2e6 self.samp_rate = samp_rate self._port_num_base_config = ConfigParser.ConfigParser() self._port_num_base_config.read(config_file) try: port_num_base = self._port_num_base_config.getint( 'main', 'port_num_base') except: port_num_base = 52001 self.port_num_base = port_num_base self._noise_amp_config = ConfigParser.ConfigParser() self._noise_amp_config.read(config_file) try: noise_amp = self._noise_amp_config.getfloat('main', 'noise_amp') except: noise_amp = .001 self.noise_amp = noise_amp self._host_config = ConfigParser.ConfigParser() self._host_config.read(config_file) try: host = self._host_config.get('main', 'host_ip') except: host = '192.168.40.2' self.host = host self.env_time_int_s = env_time_int_s = int(now) self.env_time_frac_s = env_time_frac_s = now - int(now) self._channel_gain_linear_config = ConfigParser.ConfigParser() self._channel_gain_linear_config.read(config_file) try: channel_gain_linear = self._channel_gain_linear_config.getfloat( 'main', 'channel_gain_linear') except: channel_gain_linear = .01 self.channel_gain_linear = channel_gain_linear ################################################## # Blocks ################################################## self.envsim_zmq_envsim_source_0_2_0_0 = envsim.zmq_envsim_source( "tcp://" + usrp_ip_list[2] + ":" + str(port_num_base + 2), 10, 100, samp_rate, env_time_int_s, env_time_frac_s) self.envsim_zmq_envsim_source_0_2_0 = envsim.zmq_envsim_source( "tcp://" + usrp_ip_list[1] + ":" + str(port_num_base + 1), 10, 100, samp_rate, env_time_int_s, env_time_frac_s) self.envsim_zmq_envsim_source_0_2 = envsim.zmq_envsim_source( "tcp://" + usrp_ip_list[0] + ":" + str(port_num_base + 0), 10, 100, samp_rate, env_time_int_s, env_time_frac_s) self.envsim_zmq_envsim_source_0_1 = envsim.zmq_envsim_source( "tcp://" + usrp_ip_list[3] + ":" + str(port_num_base + 3), 10, 100, samp_rate, env_time_int_s, env_time_frac_s) self.envsim_zmq_envsim_source_0_0 = envsim.zmq_envsim_source( "tcp://" + usrp_ip_list[4] + ":" + str(port_num_base + 4), 10, 100, samp_rate, env_time_int_s, env_time_frac_s) self.envsim_zmq_envsim_source_0 = envsim.zmq_envsim_source( "tcp://" + usrp_ip_list[5] + ":" + str(port_num_base + 5), 10, 100, samp_rate, env_time_int_s, env_time_frac_s) self.envsim_socket_meta_pdu_0_2 = envsim.socket_meta_pdu( "UDP_CLIENT", usrp_ip_list[0], str(port_num_base + 0), 40000, False) self.envsim_socket_meta_pdu_0_1_3 = envsim.socket_meta_pdu( "UDP_CLIENT", usrp_ip_list[2], str(port_num_base + 2), 40000, False) self.envsim_socket_meta_pdu_0_1_2_0 = envsim.socket_meta_pdu( "UDP_CLIENT", usrp_ip_list[5], str(port_num_base + 5), 40000, False) self.envsim_socket_meta_pdu_0_1_1_0 = envsim.socket_meta_pdu( "UDP_CLIENT", usrp_ip_list[4], str(port_num_base + 4), 40000, False) self.envsim_socket_meta_pdu_0_1_0_0 = envsim.socket_meta_pdu( "UDP_CLIENT", usrp_ip_list[3], str(port_num_base + 3), 40000, False) self.envsim_socket_meta_pdu_0_0_0 = envsim.socket_meta_pdu( "UDP_CLIENT", usrp_ip_list[1], str(port_num_base + 1), 40000, False) self.channels_sro_model_0_1 = channels.sro_model( samp_rate, 0.01, 1e3, 2) self.channels_sro_model_0_0 = channels.sro_model( samp_rate, 0.01, 1e3, 1) self.channels_sro_model_0 = channels.sro_model(samp_rate, 0.01, 1e3, 0) self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex * 1, samp_rate, True) self.blocks_tagged_stream_to_pdu_0_0 = blocks.tagged_stream_to_pdu( blocks.complex_t, 'packet_len') self.blocks_tagged_stream_to_pdu_0 = blocks.tagged_stream_to_pdu( blocks.complex_t, 'packet_len') self.blocks_stream_to_tagged_stream_0_0 = blocks.stream_to_tagged_stream( gr.sizeof_gr_complex, 1, 2048, "packet_len") self.blocks_stream_to_tagged_stream_0 = blocks.stream_to_tagged_stream( gr.sizeof_gr_complex, 1, 2048, "packet_len") self.blocks_probe_rate_0 = blocks.probe_rate(gr.sizeof_gr_complex * 1, 5000.0, 0.15) self.blocks_multiply_const_xx_0_0 = blocks.multiply_const_cc( channel_gain_linear) self.blocks_multiply_const_xx_0 = blocks.multiply_const_cc( channel_gain_linear) self.blocks_message_debug_0 = blocks.message_debug() self.blocks_float_to_complex_0_1 = blocks.float_to_complex(1) self.blocks_float_to_complex_0_0 = blocks.float_to_complex(1) self.blocks_float_to_complex_0 = blocks.float_to_complex(1) self.blocks_complex_to_float_0_1 = blocks.complex_to_float(1) self.blocks_complex_to_float_0_0 = blocks.complex_to_float(1) self.blocks_complex_to_float_0 = blocks.complex_to_float(1) self.blocks_add_xx_0_1 = blocks.add_vcc(1) self.blocks_add_xx_0_0_0 = blocks.add_vcc(1) self.blocks_add_xx_0_0 = blocks.add_vcc(1) self.blocks_add_xx_0 = blocks.add_vcc(1) self.analog_rail_ff_0_2 = analog.rail_ff(-1.0, 1.0) self.analog_rail_ff_0_1 = analog.rail_ff(-1.0, 1.0) self.analog_rail_ff_0_0_1 = analog.rail_ff(-1.0, 1.0) self.analog_rail_ff_0_0_0 = analog.rail_ff(-1.0, 1.0) self.analog_rail_ff_0_0 = analog.rail_ff(-1.0, 1.0) self.analog_rail_ff_0 = analog.rail_ff(-1.0, 1.0) self.analog_noise_source_x_0 = analog.noise_source_c( analog.GR_GAUSSIAN, noise_amp, 0) ################################################## # Connections ################################################## self.msg_connect((self.blocks_probe_rate_0, 'rate'), (self.blocks_message_debug_0, 'print')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.envsim_socket_meta_pdu_0_1_0_0, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.envsim_socket_meta_pdu_0_1_1_0, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0, 'pdus'), (self.envsim_socket_meta_pdu_0_1_2_0, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.envsim_socket_meta_pdu_0_0_0, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.envsim_socket_meta_pdu_0_1_3, 'pdus')) self.msg_connect((self.blocks_tagged_stream_to_pdu_0_0, 'pdus'), (self.envsim_socket_meta_pdu_0_2, 'pdus')) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0_0, 0)) self.connect((self.analog_noise_source_x_0, 0), (self.blocks_add_xx_0_0_0, 1)) self.connect((self.analog_rail_ff_0, 0), (self.blocks_float_to_complex_0, 1)) self.connect((self.analog_rail_ff_0_0, 0), (self.blocks_float_to_complex_0, 0)) self.connect((self.analog_rail_ff_0_0_0, 0), (self.blocks_float_to_complex_0_0, 0)) self.connect((self.analog_rail_ff_0_0_1, 0), (self.blocks_float_to_complex_0_1, 0)) self.connect((self.analog_rail_ff_0_1, 0), (self.blocks_float_to_complex_0_0, 1)) self.connect((self.analog_rail_ff_0_2, 0), (self.blocks_float_to_complex_0_1, 1)) self.connect((self.blocks_add_xx_0, 0), (self.blocks_multiply_const_xx_0, 0)) self.connect((self.blocks_add_xx_0_0, 0), (self.blocks_throttle_0, 0)) self.connect((self.blocks_add_xx_0_0_0, 0), (self.blocks_stream_to_tagged_stream_0_0, 0)) self.connect((self.blocks_add_xx_0_1, 0), (self.blocks_add_xx_0, 0)) self.connect((self.blocks_add_xx_0_1, 0), (self.blocks_multiply_const_xx_0_0, 0)) self.connect((self.blocks_complex_to_float_0, 1), (self.analog_rail_ff_0, 0)) self.connect((self.blocks_complex_to_float_0, 0), (self.analog_rail_ff_0_0, 0)) self.connect((self.blocks_complex_to_float_0_0, 0), (self.analog_rail_ff_0_0_0, 0)) self.connect((self.blocks_complex_to_float_0_0, 1), (self.analog_rail_ff_0_1, 0)) self.connect((self.blocks_complex_to_float_0_1, 0), (self.analog_rail_ff_0_0_1, 0)) self.connect((self.blocks_complex_to_float_0_1, 1), (self.analog_rail_ff_0_2, 0)) self.connect((self.blocks_float_to_complex_0, 0), (self.channels_sro_model_0_1, 0)) self.connect((self.blocks_float_to_complex_0_0, 0), (self.channels_sro_model_0_0, 0)) self.connect((self.blocks_float_to_complex_0_1, 0), (self.channels_sro_model_0, 0)) self.connect((self.blocks_multiply_const_xx_0, 0), (self.blocks_add_xx_0_0, 1)) self.connect((self.blocks_multiply_const_xx_0_0, 0), (self.blocks_add_xx_0_0_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0, 0), (self.blocks_tagged_stream_to_pdu_0, 0)) self.connect((self.blocks_stream_to_tagged_stream_0_0, 0), (self.blocks_tagged_stream_to_pdu_0_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_probe_rate_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.blocks_stream_to_tagged_stream_0, 0)) self.connect((self.channels_sro_model_0, 0), (self.blocks_add_xx_0, 1)) self.connect((self.channels_sro_model_0_0, 0), (self.blocks_add_xx_0, 2)) self.connect((self.channels_sro_model_0_1, 0), (self.blocks_add_xx_0, 3)) self.connect((self.envsim_zmq_envsim_source_0, 0), (self.blocks_complex_to_float_0, 0)) self.connect((self.envsim_zmq_envsim_source_0_0, 0), (self.blocks_complex_to_float_0_0, 0)) self.connect((self.envsim_zmq_envsim_source_0_1, 0), (self.blocks_complex_to_float_0_1, 0)) self.connect((self.envsim_zmq_envsim_source_0_2, 0), (self.blocks_add_xx_0_1, 0)) self.connect((self.envsim_zmq_envsim_source_0_2_0, 0), (self.blocks_add_xx_0_1, 1)) self.connect((self.envsim_zmq_envsim_source_0_2_0_0, 0), (self.blocks_add_xx_0_1, 2))