Exemple #1
0
	def run(self):
		# Init shared clock generator
		self.clck_gen = CLCKGen([])

		# Power measurement emulation
		# Noise: -120 .. -105
		# BTS: -75 .. -50
		self.fake_pm = FakePM(-120, -105, -75, -50)

		# Init TRX instance for BTS
		self.bts_trx = FakeTRX(self.argv.trx_bind_addr,
			self.argv.bts_addr, self.argv.bts_base_port,
			clck_gen = self.clck_gen)

		# Init TRX instance for BB
		self.bb_trx = FakeTRX(self.argv.trx_bind_addr,
			self.argv.bb_addr, self.argv.bb_base_port,
			pwr_meas = self.fake_pm)

		# Burst forwarding between transceivers
		self.burst_fwd = BurstForwarder()
		self.burst_fwd.add_trx(self.bts_trx)
		self.burst_fwd.add_trx(self.bb_trx)

		log.info("Init complete")

		# Enter main loop
		while True:
			socks = [self.bts_trx.ctrl_if.sock, self.bb_trx.ctrl_if.sock,
				self.bts_trx.data_if.sock, self.bb_trx.data_if.sock]

			# Wait until we get any data on any socket
			r_event, w_event, x_event = select.select(socks, [], [])

			# Downlink: BTS -> BB
			if self.bts_trx.data_if.sock in r_event:
				msg = self.bts_trx.recv_data_msg()
				if msg is not None:
					self.burst_fwd.forward_msg(self.bts_trx, msg)

			# Uplink: BB -> BTS
			if self.bb_trx.data_if.sock in r_event:
				msg = self.bb_trx.recv_data_msg()
				if msg is not None:
					self.burst_fwd.forward_msg(self.bb_trx, msg)

			# CTRL commands from BTS
			if self.bts_trx.ctrl_if.sock in r_event:
				self.bts_trx.ctrl_if.handle_rx()

			# CTRL commands from BB
			if self.bb_trx.ctrl_if.sock in r_event:
				self.bb_trx.ctrl_if.handle_rx()
Exemple #2
0
    def __init__(self):
        self.app_print_copyright(APP_CR_HOLDERS)
        self.argv = self.parse_argv()

        # Set up signal handlers
        signal.signal(signal.SIGINT, self.sig_handler)

        # Configure logging
        self.app_init_logging(self.argv)

        # List of all transceivers
        self.trx_list = TRXList()

        # Init shared clock generator
        self.clck_gen = CLCKGen([])

        # Power measurement emulation
        # Noise: -120 .. -105
        # BTS: -75 .. -50
        self.fake_pm = FakePM(-120, -105, -75, -50)
        self.fake_pm.trx_list = self.trx_list

        # Init TRX instance for BTS
        self.append_trx(self.argv.bts_addr,
                        self.argv.bts_base_port,
                        name="BTS")

        # Init TRX instance for BB
        self.append_trx(self.argv.bb_addr, self.argv.bb_base_port, name="MS")

        # Additional transceivers (optional)
        if self.argv.trx_list is not None:
            for trx_def in self.argv.trx_list:
                (name, addr, port, idx) = trx_def
                self.append_child_trx(addr, port, idx, name)

        # Burst forwarding between transceivers
        self.burst_fwd = BurstForwarder(self.trx_list.trx_list)

        log.info("Init complete")
Exemple #3
0
    def run(self):
        # Init TRX CTRL interface for BTS
        self.bts_ctrl = CTRLInterfaceBTS(self.argv.bts_addr,
                                         self.argv.bts_base_port + 101,
                                         self.argv.trx_bind_addr,
                                         self.argv.bts_base_port + 1)

        # Init TRX CTRL interface for BB
        self.bb_ctrl = CTRLInterfaceBB(self.argv.bb_addr,
                                       self.argv.bb_base_port + 101,
                                       self.argv.trx_bind_addr,
                                       self.argv.bb_base_port + 1)

        # Power measurement emulation
        # Noise: -120 .. -105
        # BTS: -75 .. -50
        self.pm = FakePM(-120, -105, -75, -50)

        # Share a FakePM instance between both BTS and BB
        self.bts_ctrl.pm = self.pm
        self.bb_ctrl.pm = self.pm

        # Init DATA links
        self.bts_data = UDPLink(self.argv.bts_addr,
                                self.argv.bts_base_port + 102,
                                self.argv.trx_bind_addr,
                                self.argv.bts_base_port + 2)
        self.bb_data = UDPLink(self.argv.bb_addr, self.argv.bb_base_port + 102,
                               self.argv.trx_bind_addr,
                               self.argv.bb_base_port + 2)

        # BTS <-> BB burst forwarding
        self.burst_fwd = BurstForwarder(self.bts_data, self.bb_data)

        # Share a BurstForwarder instance between BTS and BB
        self.bts_ctrl.burst_fwd = self.burst_fwd
        self.bb_ctrl.burst_fwd = self.burst_fwd

        # Provide clock to BTS
        self.bts_clck = UDPLink(self.argv.bts_addr,
                                self.argv.bts_base_port + 100,
                                self.argv.trx_bind_addr,
                                self.argv.bts_base_port)
        self.clck_gen = CLCKGen([self.bts_clck])
        self.bts_ctrl.clck_gen = self.clck_gen

        log.info("Init complete")

        # Enter main loop
        while True:
            socks = [
                self.bts_ctrl.sock, self.bb_ctrl.sock, self.bts_data.sock,
                self.bb_data.sock
            ]

            # Wait until we get any data on any socket
            r_event, w_event, x_event = select.select(socks, [], [])

            # Downlink: BTS -> BB
            if self.bts_data.sock in r_event:
                self.burst_fwd.bts2bb()

            # Uplink: BB -> BTS
            if self.bb_data.sock in r_event:
                self.burst_fwd.bb2bts()

            # CTRL commands from BTS
            if self.bts_ctrl.sock in r_event:
                data, addr = self.bts_ctrl.sock.recvfrom(128)
                self.bts_ctrl.handle_rx(data.decode(), addr)

            # CTRL commands from BB
            if self.bb_ctrl.sock in r_event:
                data, addr = self.bb_ctrl.sock.recvfrom(128)
                self.bb_ctrl.handle_rx(data.decode(), addr)