Exemplo n.º 1
0
    def _create_devices(self) -> Devices:
        """Initialise small base stations, cellular UE & D2D UE pairs in the simulator as per the env config.

        :returns: A tuple containing a list of base station, CUE & a dict of DUE pair IDs created.
        """

        base_cfg = {
            'num_subcarriers': self.config.num_subcarriers,
            'subcarrier_spacing_kHz': self.config.subcarrier_spacing_kHz,
        }

        # create macro base station
        config = self.config.devices[BASE_STATION_ID][
            'config'] if BASE_STATION_ID in self.config.devices else base_cfg
        bs = BaseStation(Id(BASE_STATION_ID), config)

        # create cellular UEs
        cues = {}
        default_cue_cfg = {
            **base_cfg,
            **{
                'max_tx_power_dBm': self.config.cue_max_tx_power_dBm
            }
        }
        for i in range(self.config.num_cellular_users):
            cue_id = Id(f'cue{i:02d}')
            config = self.config.devices[cue_id][
                'config'] if cue_id in self.config.devices else default_cue_cfg
            cues[cue_id] = UserEquipment(cue_id, config)

        # create D2D UEs
        dues = {}
        due_cfg = {
            **base_cfg,
            **{
                'max_tx_power_dBm': self.config.due_max_tx_power_dBm
            }
        }
        for i in range(0, (self.config.num_d2d_pairs * 2), 2):
            due_tx_id, due_rx_id = Id(f'due{i:02d}'), Id(f'due{i + 1:02d}')

            due_tx_config = self.config.devices[due_tx_id][
                'config'] if due_tx_id in self.config.devices else due_cfg
            due_tx = UserEquipment(due_tx_id, due_tx_config)

            due_rx_config = self.config.devices[due_rx_id][
                'config'] if due_rx_id in self.config.devices else due_cfg
            due_rx = UserEquipment(due_rx_id, due_rx_config)

            dues[(due_tx.id, due_rx.id)] = due_tx, due_rx

        return Devices(bs, cues, dues)
Exemplo n.º 2
0
    def test_eirp_dBm(self):
        ue = UserEquipment('ue')
        assert ue.eirp_dBm(
            12) == approx(12 + DEFAULT_UE_CONFIG['tx_antenna_gain_dBi'] -
                          DEFAULT_UE_CONFIG['ix_margin_dB'] -
                          DEFAULT_UE_CONFIG['body_loss_dB'])

        bs = BaseStation('bs')
        assert bs.eirp_dBm(46) == approx(
            46 + DEFAULT_BASE_STATION_CONFIG['tx_antenna_gain_dBi'] -
            DEFAULT_BASE_STATION_CONFIG['ix_margin_dB'] -
            DEFAULT_BASE_STATION_CONFIG['cable_loss_dB'] +
            DEFAULT_BASE_STATION_CONFIG['masthead_amplifier_gain_dB'])
Exemplo n.º 3
0
 def test_rx_sensitivity_dBm(self):
     ue = UserEquipment('ue')
     bs = BaseStation('bs')
     assert ue.rx_sensitivity_dBm == approx(ue.rx_noise_floor_dBm +
                                            DEFAULT_UE_CONFIG['sinr_dB'])
     assert bs.rx_sensitivity_dBm == approx(
         bs.rx_noise_floor_dBm + DEFAULT_BASE_STATION_CONFIG['sinr_dB'])
Exemplo n.º 4
0
    def test_init_has_default_config(self):
        ue = UserEquipment('ue')
        assert ue.max_tx_power_dBm == DEFAULT_UE_CONFIG['max_tx_power_dBm']
        assert ue.antenna_height_m == DEFAULT_UE_CONFIG['antenna_height_m']
        assert ue.tx_antenna_gain_dBi == DEFAULT_UE_CONFIG[
            'tx_antenna_gain_dBi']
        assert ue.rx_antenna_gain_dBi == DEFAULT_UE_CONFIG[
            'rx_antenna_gain_dBi']
        assert ue.thermal_noise_dBm == DEFAULT_UE_CONFIG['thermal_noise_dBm']
        assert ue.noise_figure_dB == DEFAULT_UE_CONFIG['noise_figure_dB']
        assert ue.sinr_dB == DEFAULT_UE_CONFIG['sinr_dB']
        assert ue.ix_margin_dB == DEFAULT_UE_CONFIG['ix_margin_dB']
        assert ue.control_channel_overhead_dB == DEFAULT_UE_CONFIG[
            'control_channel_overhead_dB']
        assert ue.body_loss_dB == DEFAULT_UE_CONFIG['body_loss_dB']

        bs = BaseStation('bs')
        assert bs.max_tx_power_dBm == DEFAULT_BASE_STATION_CONFIG[
            'max_tx_power_dBm']
        assert bs.antenna_height_m == DEFAULT_BASE_STATION_CONFIG[
            'antenna_height_m']
        assert bs.tx_antenna_gain_dBi == DEFAULT_BASE_STATION_CONFIG[
            'tx_antenna_gain_dBi']
        assert bs.rx_antenna_gain_dBi == DEFAULT_BASE_STATION_CONFIG[
            'rx_antenna_gain_dBi']
        assert bs.thermal_noise_dBm == DEFAULT_BASE_STATION_CONFIG[
            'thermal_noise_dBm']
        assert bs.noise_figure_dB == DEFAULT_BASE_STATION_CONFIG[
            'noise_figure_dB']
        assert bs.sinr_dB == DEFAULT_BASE_STATION_CONFIG['sinr_dB']
        assert bs.ix_margin_dB == DEFAULT_BASE_STATION_CONFIG['ix_margin_dB']
        assert bs.cable_loss_dB == DEFAULT_BASE_STATION_CONFIG['cable_loss_dB']
        assert bs.masthead_amplifier_gain_dB == DEFAULT_BASE_STATION_CONFIG[
            'masthead_amplifier_gain_dB']
Exemplo n.º 5
0
 def test_rx_noise_floor_dBm(self):
     ue = UserEquipment('ue')
     bs = BaseStation('bs')
     assert ue.rx_noise_floor_dBm == approx(
         DEFAULT_UE_CONFIG['noise_figure_dB'] +
         DEFAULT_UE_CONFIG['thermal_noise_dBm'])
     assert bs.rx_noise_floor_dBm == approx(
         DEFAULT_BASE_STATION_CONFIG['noise_figure_dB'] +
         DEFAULT_BASE_STATION_CONFIG['thermal_noise_dBm'])
Exemplo n.º 6
0
 def test_call(self):
     pl = LogDistancePathLoss(2.1)
     bs = BaseStation('bs')
     ue = UserEquipment('ue')
     ue.set_position(Position(250, 0))
     assert pl(ue, bs) == approx(86.85097)
     ue.set_position(Position(0, 500))
     assert pl(ue, bs) == approx(92.87156)
Exemplo n.º 7
0
 def test_call(self):
     pl = CostHataPathLoss(2.1, AreaType.URBAN)
     bs = BaseStation('bs')
     ue = UserEquipment('ue')
     ue.set_position(Position(250, 0))
     assert pl(bs, ue) == approx(121.44557455875727)
     assert pl(ue, bs) == approx(114.35415557446962)
     ue.set_position(Position(0, 500))
     assert pl(bs, ue) == approx(132.2768393081241)
     assert pl(ue, bs) == approx(127.5231950610599)
Exemplo n.º 8
0
    def test_init_merges_override_config(self):
        ue_pwr = random.uniform(0, 23)
        ue_ant_height = random.uniform(0, 200)
        ue = UserEquipment('ue', {
            'antenna_height_m': ue_ant_height,
            'max_tx_power_dBm': ue_pwr,
        })
        assert ue.max_tx_power_dBm == ue_pwr
        assert ue.antenna_height_m == ue_ant_height

        bs_pwr = random.uniform(0, 50)
        bs_tx_ant_gain = random.uniform(0, 50)
        bs = BaseStation('bs', {
            'max_tx_power_dBm': bs_pwr,
            'tx_antenna_gain_dBi': bs_tx_ant_gain,
        })
        assert bs.max_tx_power_dBm == bs_pwr
        assert bs.tx_antenna_gain_dBi == bs_tx_ant_gain
Exemplo n.º 9
0
 def test_set_position(self):
     ue = UserEquipment('ue')
     ue.set_position(Position(-123.45, 78.9))
     assert ue.position.as_tuple() == (-123.45, 78.9)
Exemplo n.º 10
0
 def test_init_creates_default_position(self):
     ue = UserEquipment('ue')
     assert isinstance(ue.position, Position)
     assert ue.position.as_tuple() == (0, 0)
Exemplo n.º 11
0
 def test_init_has_id(self):
     ue = UserEquipment('ue')
     bs = BaseStation('bs')
     assert ue.id == Id('ue')
     assert bs.id == Id('bs')