Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 1 | # osmo_gsm_tester: specifics for running an SRS eNodeB process |
| 2 | # |
| 3 | # Copyright (C) 2020 by sysmocom - s.f.m.c. GmbH |
| 4 | # |
| 5 | # Author: Pau Espin Pedrol <pespin@sysmocom.de> |
| 6 | # |
| 7 | # This program is free software: you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as |
| 9 | # published by the Free Software Foundation, either version 3 of the |
| 10 | # License, or (at your option) any later version. |
| 11 | # |
| 12 | # This program is distributed in the hope that it will be useful, |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | # GNU General Public License for more details. |
| 16 | # |
| 17 | # You should have received a copy of the GNU General Public License |
| 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 19 | |
| 20 | import os |
| 21 | import pprint |
| 22 | |
Pau Espin Pedrol | e1a58bd | 2020-04-10 20:46:07 +0200 | [diff] [blame] | 23 | from ..core import log, util, config, template, process, remote |
Pau Espin Pedrol | ea8c3d4 | 2020-05-04 12:05:05 +0200 | [diff] [blame] | 24 | from ..core import schema |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 25 | from . import enb |
Pau Espin Pedrol | d4404d5 | 2020-04-20 13:29:31 +0200 | [diff] [blame] | 26 | from . import rfemu |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 27 | |
Pau Espin Pedrol | ea8c3d4 | 2020-05-04 12:05:05 +0200 | [diff] [blame] | 28 | def on_register_schemas(): |
| 29 | config_schema = { |
| 30 | 'license_server_addr': schema.IPV4, |
| 31 | } |
| 32 | schema.register_config_schema('amarisoft', config_schema) |
| 33 | |
Andre Puschmann | 2ebcff9 | 2020-07-01 12:28:31 +0200 | [diff] [blame] | 34 | config_schema = { |
| 35 | 'log_options': schema.STR, |
| 36 | } |
| 37 | schema.register_config_schema('amarisoftenb', config_schema) |
| 38 | |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 39 | def rf_type_valid(rf_type_str): |
Pau Espin Pedrol | d45a29e | 2020-04-02 17:21:47 +0200 | [diff] [blame] | 40 | return rf_type_str in ('uhd', 'zmq') |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 41 | |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 42 | class AmarisoftENB(enb.eNodeB): |
| 43 | |
| 44 | REMOTE_DIR = '/osmo-gsm-tester-amarisoftenb' |
| 45 | BINFILE = 'lteenb' |
Andre Puschmann | e4d5a13 | 2020-04-14 22:23:06 +0200 | [diff] [blame] | 46 | CFGFILE = 'amarisoft_enb.cfg' |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 47 | CFGFILE_SIB1 = 'amarisoft_sib1.asn' |
| 48 | CFGFILE_SIB23 = 'amarisoft_sib23.asn' |
| 49 | CFGFILE_RF = 'amarisoft_rf_driver.cfg' |
| 50 | CFGFILE_DRB = 'amarisoft_drb.cfg' |
| 51 | LOGFILE = 'lteenb.log' |
Andre Puschmann | 008fd31 | 2020-07-06 12:28:43 +0200 | [diff] [blame] | 52 | PHY_SIGNAL_FILE = 'lteenb.log.bin' |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 53 | |
Pau Espin Pedrol | a442cb8 | 2020-05-05 12:54:37 +0200 | [diff] [blame] | 54 | def __init__(self, testenv, conf): |
| 55 | super().__init__(testenv, conf, 'amarisoftenb') |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 56 | self.ue = None |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 57 | self.run_dir = None |
Pau Espin Pedrol | 214f15e | 2020-04-03 16:56:12 +0200 | [diff] [blame] | 58 | self.inst = None |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 59 | self._bin_prefix = None |
Pau Espin Pedrol | d4404d5 | 2020-04-20 13:29:31 +0200 | [diff] [blame] | 60 | self.gen_conf = None |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 61 | self.config_file = None |
| 62 | self.config_sib1_file = None |
| 63 | self.config_sib23_file = None |
| 64 | self.config_rf_file = None |
| 65 | self.config_drb_file = None |
| 66 | self.log_file = None |
| 67 | self.process = None |
| 68 | self.rem_host = None |
Pau Espin Pedrol | 214f15e | 2020-04-03 16:56:12 +0200 | [diff] [blame] | 69 | self.remote_inst = None |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 70 | self.remote_config_file = None |
| 71 | self.remote_config_sib1_file = None |
| 72 | self.remote_config_sib23_file = None |
| 73 | self.remote_config_rf_file = None |
| 74 | self.remote_config_drb_file = None |
| 75 | self.remote_log_file = None |
Andre Puschmann | a7f1983 | 2020-04-07 14:38:27 +0200 | [diff] [blame] | 76 | self.enable_measurements = False |
Pau Espin Pedrol | a442cb8 | 2020-05-05 12:54:37 +0200 | [diff] [blame] | 77 | self.testenv = testenv |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 78 | if not rf_type_valid(conf.get('rf_dev_type', None)): |
| 79 | raise log.Error('Invalid rf_dev_type=%s' % conf.get('rf_dev_type', None)) |
| 80 | |
| 81 | def bin_prefix(self): |
| 82 | if self._bin_prefix is None: |
Pau Espin Pedrol | 17253af | 2020-04-02 21:11:19 +0200 | [diff] [blame] | 83 | self._bin_prefix = os.getenv('AMARISOFT_PATH_ENB', None) |
| 84 | if self._bin_prefix == None: |
Pau Espin Pedrol | b452ed6 | 2020-05-26 12:51:44 +0200 | [diff] [blame] | 85 | self._bin_prefix = self.testenv.suite().trial().get_inst('amarisoftenb', self._run_node.run_label()) |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 86 | return self._bin_prefix |
| 87 | |
| 88 | def cleanup(self): |
| 89 | if self.process is None: |
| 90 | return |
Pau Espin Pedrol | 1abff4e | 2020-05-26 12:32:19 +0200 | [diff] [blame] | 91 | if self._run_node.is_local(): |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 92 | return |
| 93 | # copy back files (may not exist, for instance if there was an early error of process): |
| 94 | try: |
| 95 | self.rem_host.scpfrom('scp-back-log', self.remote_log_file, self.log_file) |
| 96 | except Exception as e: |
| 97 | self.log(repr(e)) |
| 98 | |
Andre Puschmann | 008fd31 | 2020-07-06 12:28:43 +0200 | [diff] [blame] | 99 | try: |
| 100 | self.rem_host.scpfrom('scp-back-phy-signal-log', self.remote_phy_signal_file, self.phy_signal_file) |
| 101 | except Exception as e: |
| 102 | self.log(repr(e)) |
Pau Espin Pedrol | 4109123 | 2020-10-05 19:23:38 +0200 | [diff] [blame] | 103 | # Clean up for parent class: |
| 104 | super().cleanup() |
Andre Puschmann | 008fd31 | 2020-07-06 12:28:43 +0200 | [diff] [blame] | 105 | |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 106 | def start(self, epc): |
| 107 | self.log('Starting AmarisoftENB') |
Pau Espin Pedrol | e44e76a | 2020-03-31 12:35:19 +0200 | [diff] [blame] | 108 | self._epc = epc |
Pau Espin Pedrol | 2a2d846 | 2020-05-11 10:56:52 +0200 | [diff] [blame] | 109 | self.run_dir = util.Dir(self.testenv.test().get_run_dir().new_dir(self.name())) |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 110 | self.configure() |
| 111 | self._start() |
| 112 | |
| 113 | # send t+Enter to enable console trace |
| 114 | self.dbg('Enabling console trace') |
| 115 | self.process.stdin_write('t\n') |
| 116 | |
| 117 | def _start(self): |
Pau Espin Pedrol | 1abff4e | 2020-05-26 12:32:19 +0200 | [diff] [blame] | 118 | if self._run_node.is_local(): |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 119 | env = { 'LD_LIBRARY_PATH': util.prepend_library_path(self.inst) } |
| 120 | binary = self.inst.child('.', AmarisoftENB.BINFILE) |
| 121 | self.dbg(run_dir=self.run_dir, binary=binary, env=env) |
| 122 | args = (binary, os.path.abspath(self.config_file)) |
| 123 | self.process = process.Process(self.name(), self.run_dir, args, env=env) |
| 124 | else: |
| 125 | remote_env = { 'LD_LIBRARY_PATH': self.remote_inst } |
| 126 | remote_binary = self.remote_inst.child('', AmarisoftENB.BINFILE) |
| 127 | args = (remote_binary, self.remote_config_file) |
| 128 | self.process = self.rem_host.RemoteProcess(AmarisoftENB.BINFILE, args, remote_env=remote_env) |
| 129 | |
Pau Espin Pedrol | a442cb8 | 2020-05-05 12:54:37 +0200 | [diff] [blame] | 130 | self.testenv.remember_to_stop(self.process) |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 131 | self.process.launch() |
| 132 | |
| 133 | def gen_conf_file(self, path, filename, values): |
| 134 | self.dbg('AmarisoftENB ' + filename + ':\n' + pprint.pformat(values)) |
| 135 | with open(path, 'w') as f: |
| 136 | r = template.render(filename, values) |
| 137 | self.dbg(r) |
| 138 | f.write(r) |
| 139 | |
| 140 | def configure(self): |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 141 | self.inst = util.Dir(os.path.abspath(self.bin_prefix())) |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 142 | if not self.inst.isfile('', AmarisoftENB.BINFILE): |
| 143 | raise log.Error('No %s binary in' % AmarisoftENB.BINFILE, self.inst) |
| 144 | |
| 145 | self.config_file = self.run_dir.child(AmarisoftENB.CFGFILE) |
| 146 | self.config_sib1_file = self.run_dir.child(AmarisoftENB.CFGFILE_SIB1) |
| 147 | self.config_sib23_file = self.run_dir.child(AmarisoftENB.CFGFILE_SIB23) |
| 148 | self.config_rf_file = self.run_dir.child(AmarisoftENB.CFGFILE_RF) |
| 149 | self.config_drb_file = self.run_dir.child(AmarisoftENB.CFGFILE_DRB) |
| 150 | self.log_file = self.run_dir.child(AmarisoftENB.LOGFILE) |
Andre Puschmann | 008fd31 | 2020-07-06 12:28:43 +0200 | [diff] [blame] | 151 | self.phy_signal_file = self.run_dir.child(AmarisoftENB.PHY_SIGNAL_FILE) |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 152 | |
Pau Espin Pedrol | 1abff4e | 2020-05-26 12:32:19 +0200 | [diff] [blame] | 153 | if not self._run_node.is_local(): |
| 154 | self.rem_host = remote.RemoteHost(self.run_dir, self._run_node.ssh_user(), self._run_node.ssh_addr()) |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 155 | remote_prefix_dir = util.Dir(AmarisoftENB.REMOTE_DIR) |
| 156 | self.remote_inst = util.Dir(remote_prefix_dir.child(os.path.basename(str(self.inst)))) |
| 157 | remote_run_dir = util.Dir(remote_prefix_dir.child(AmarisoftENB.BINFILE)) |
| 158 | |
| 159 | self.remote_config_file = remote_run_dir.child(AmarisoftENB.CFGFILE) |
| 160 | self.remote_config_sib1_file = remote_run_dir.child(AmarisoftENB.CFGFILE_SIB1) |
| 161 | self.remote_config_sib23_file = remote_run_dir.child(AmarisoftENB.CFGFILE_SIB23) |
| 162 | self.remote_config_rf_file = remote_run_dir.child(AmarisoftENB.CFGFILE_RF) |
| 163 | self.remote_config_drb_file = remote_run_dir.child(AmarisoftENB.CFGFILE_DRB) |
| 164 | self.remote_log_file = remote_run_dir.child(AmarisoftENB.LOGFILE) |
Andre Puschmann | 008fd31 | 2020-07-06 12:28:43 +0200 | [diff] [blame] | 165 | self.remote_phy_signal_file = remote_run_dir.child(AmarisoftENB.PHY_SIGNAL_FILE) |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 166 | |
Pau Espin Pedrol | c04528c | 2020-04-01 13:55:51 +0200 | [diff] [blame] | 167 | values = super().configure(['amarisoft', 'amarisoftenb']) |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 168 | |
Andre Puschmann | a7f1983 | 2020-04-07 14:38:27 +0200 | [diff] [blame] | 169 | # Convert parsed boolean string to Python boolean: |
| 170 | self.enable_measurements = util.str2bool(values['enb'].get('enable_measurements', 'false')) |
| 171 | config.overlay(values, dict(enb={'enable_measurements': self.enable_measurements})) |
| 172 | |
Andre Puschmann | 955249d | 2020-07-01 15:44:09 +0200 | [diff] [blame] | 173 | config.overlay(values, dict(enb={'enable_dl_awgn': util.str2bool(values['enb'].get('enable_dl_awgn', 'false'))})) |
| 174 | |
Pau Espin Pedrol | d45a29e | 2020-04-02 17:21:47 +0200 | [diff] [blame] | 175 | # We need to set some specific variables programatically here to match IP addresses: |
| 176 | if self._conf.get('rf_dev_type') == 'zmq': |
Andre Puschmann | e2a6da6 | 2020-04-20 20:39:34 +0200 | [diff] [blame] | 177 | base_srate = self.num_prb2base_srate(self.num_prb()) |
Pau Espin Pedrol | 4109123 | 2020-10-05 19:23:38 +0200 | [diff] [blame] | 178 | rf_dev_args = self.get_zmq_rf_dev_args(values) |
Pau Espin Pedrol | d45a29e | 2020-04-02 17:21:47 +0200 | [diff] [blame] | 179 | config.overlay(values, dict(enb=dict(sample_rate = base_srate / (1000*1000), |
Andre Puschmann | e2a6da6 | 2020-04-20 20:39:34 +0200 | [diff] [blame] | 180 | rf_dev_args = rf_dev_args))) |
Pau Espin Pedrol | d45a29e | 2020-04-02 17:21:47 +0200 | [diff] [blame] | 181 | |
| 182 | # Set UHD frame size as a function of the cell bandwidth on B2XX |
Pau Espin Pedrol | 6b8f5ae | 2020-04-07 18:51:57 +0200 | [diff] [blame] | 183 | if self._conf.get('rf_dev_type') == 'uhd' and values['enb'].get('rf_dev_args', None) is not None: |
Pau Espin Pedrol | d45a29e | 2020-04-02 17:21:47 +0200 | [diff] [blame] | 184 | if 'b200' in values['enb'].get('rf_dev_args'): |
| 185 | rf_dev_args = values['enb'].get('rf_dev_args', '') |
| 186 | rf_dev_args += ',' if rf_dev_args != '' and not rf_dev_args.endswith(',') else '' |
| 187 | |
Andre Puschmann | 0e00f38 | 2020-09-23 17:07:07 +0200 | [diff] [blame] | 188 | if self._txmode == 1: |
| 189 | # SISO config |
| 190 | if self._num_prb < 25: |
| 191 | rf_dev_args += 'send_frame_size=512,recv_frame_size=512' |
| 192 | elif self._num_prb == 25: |
| 193 | rf_dev_args += 'send_frame_size=1024,recv_frame_size=1024' |
| 194 | else: |
| 195 | rf_dev_args += '' |
| 196 | else: |
| 197 | # MIMO config |
| 198 | if self._num_prb == 6: |
| 199 | rf_dev_args += 'send_frame_size=512,recv_frame_size=512' |
| 200 | else: |
| 201 | rf_dev_args += 'num_recv_frames=64,num_send_frames=64' |
Pau Espin Pedrol | d45a29e | 2020-04-02 17:21:47 +0200 | [diff] [blame] | 202 | |
Andre Puschmann | 0e00f38 | 2020-09-23 17:07:07 +0200 | [diff] [blame] | 203 | if self._num_prb > 50: |
| 204 | # Reduce over the wire format to sc12 |
| 205 | rf_dev_args += ',otw_format=sc12' |
Pau Espin Pedrol | d45a29e | 2020-04-02 17:21:47 +0200 | [diff] [blame] | 206 | |
| 207 | config.overlay(values, dict(enb=dict(rf_dev_args=rf_dev_args))) |
| 208 | |
Pau Espin Pedrol | 1abff4e | 2020-05-26 12:32:19 +0200 | [diff] [blame] | 209 | logfile = self.log_file if self._run_node.is_local() else self.remote_log_file |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 210 | config.overlay(values, dict(enb=dict(log_filename=logfile))) |
| 211 | |
Andre Puschmann | 008fd31 | 2020-07-06 12:28:43 +0200 | [diff] [blame] | 212 | phy_signal_file = self.phy_signal_file if self._run_node.is_local() else self.remote_phy_signal_file |
| 213 | config.overlay(values, dict(enb=dict(phy_signal_file=phy_signal_file))) |
| 214 | |
Pau Espin Pedrol | 65beb8f | 2020-03-31 12:03:19 +0200 | [diff] [blame] | 215 | # rf driver is shared between amarisoft enb and ue, so it has a |
| 216 | # different cfg namespace 'trx'. Copy needed values over there: |
| 217 | config.overlay(values, dict(trx=dict(rf_dev_type=values['enb'].get('rf_dev_type', None), |
Pau Espin Pedrol | a6d6304 | 2020-04-20 15:14:51 +0200 | [diff] [blame] | 218 | rf_dev_args=values['enb'].get('rf_dev_args', None), |
Andre Puschmann | c489f19 | 2020-10-09 14:46:38 +0200 | [diff] [blame] | 219 | rf_dev_sync=values['enb'].get('rf_dev_sync', None), |
Pau Espin Pedrol | a6d6304 | 2020-04-20 15:14:51 +0200 | [diff] [blame] | 220 | rx_gain=values['enb'].get('rx_gain', None), |
| 221 | tx_gain=values['enb'].get('tx_gain', None), |
| 222 | ))) |
Pau Espin Pedrol | 65beb8f | 2020-03-31 12:03:19 +0200 | [diff] [blame] | 223 | |
Pau Espin Pedrol | d4404d5 | 2020-04-20 13:29:31 +0200 | [diff] [blame] | 224 | self.gen_conf = values |
| 225 | |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 226 | self.gen_conf_file(self.config_file, AmarisoftENB.CFGFILE, values) |
| 227 | self.gen_conf_file(self.config_sib1_file, AmarisoftENB.CFGFILE_SIB1, values) |
| 228 | self.gen_conf_file(self.config_sib23_file, AmarisoftENB.CFGFILE_SIB23, values) |
| 229 | self.gen_conf_file(self.config_rf_file, AmarisoftENB.CFGFILE_RF, values) |
| 230 | self.gen_conf_file(self.config_drb_file, AmarisoftENB.CFGFILE_DRB, values) |
| 231 | |
Pau Espin Pedrol | 1abff4e | 2020-05-26 12:32:19 +0200 | [diff] [blame] | 232 | if not self._run_node.is_local(): |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 233 | self.rem_host.recreate_remote_dir(self.remote_inst) |
| 234 | self.rem_host.scp('scp-inst-to-remote', str(self.inst), remote_prefix_dir) |
| 235 | self.rem_host.recreate_remote_dir(remote_run_dir) |
| 236 | self.rem_host.scp('scp-cfg-to-remote', self.config_file, self.remote_config_file) |
| 237 | self.rem_host.scp('scp-cfg-sib1-to-remote', self.config_sib1_file, self.remote_config_sib1_file) |
| 238 | self.rem_host.scp('scp-cfg-sib23-to-remote', self.config_sib23_file, self.remote_config_sib23_file) |
| 239 | self.rem_host.scp('scp-cfg-rr-to-remote', self.config_rf_file, self.remote_config_rf_file) |
| 240 | self.rem_host.scp('scp-cfg-drb-to-remote', self.config_drb_file, self.remote_config_drb_file) |
| 241 | |
| 242 | def ue_add(self, ue): |
| 243 | if self.ue is not None: |
| 244 | raise log.Error("More than one UE per ENB not yet supported (ZeroMQ)") |
| 245 | self.ue = ue |
| 246 | |
| 247 | def running(self): |
| 248 | return not self.process.terminated() |
| 249 | |
Pau Espin Pedrol | d4404d5 | 2020-04-20 13:29:31 +0200 | [diff] [blame] | 250 | def get_rfemu(self, cell=0, dl=True): |
| 251 | cell_list = self.gen_conf['enb'].get('cell_list', None) |
| 252 | if cell_list is None or len(cell_list) < cell + 1: |
| 253 | raise log.Error('cell_list attribute or subitem not found!') |
| 254 | rfemu_cfg = cell_list[cell].get('dl_rfemu', None) |
Andre Puschmann | ccb6320 | 2020-06-12 15:09:00 +0200 | [diff] [blame] | 255 | if rfemu_cfg is None: # craft amarisoft by default: |
Pau Espin Pedrol | d4404d5 | 2020-04-20 13:29:31 +0200 | [diff] [blame] | 256 | rfemu_cfg = {'type': 'amarisoftctl', |
| 257 | 'addr': self.addr(), |
| 258 | 'ports': [9001] |
| 259 | } |
| 260 | if rfemu_cfg['type'] == 'amarisoftctl': # this one requires extra config: |
| 261 | config.overlay(rfemu_cfg, dict(cell_id=cell_list[cell]['cell_id'])) |
| 262 | rfemu_obj = rfemu.get_instance_by_type(rfemu_cfg['type'], rfemu_cfg) |
| 263 | return rfemu_obj |
| 264 | |
Andre Puschmann | 7d3b83e | 2020-09-02 22:17:54 +0200 | [diff] [blame] | 265 | def ue_max_rate(self, downlink=True, num_carriers=1): |
Andre Puschmann | d0682ba | 2020-10-15 15:46:29 +0200 | [diff] [blame] | 266 | if self._duplex == 'fdd': |
| 267 | return self.ue_max_rate_fdd(downlink, num_carriers) |
| 268 | else: |
| 269 | return self.ue_max_rate_tdd(downlink, num_carriers) |
| 270 | |
| 271 | def ue_max_rate_fdd(self, downlink, num_carriers): |
Andre Puschmann | 61d150b | 2020-05-27 10:37:46 +0200 | [diff] [blame] | 272 | # The max rate for a single UE per PRB configuration in TM1 with MCS 28 QAM64 |
| 273 | max_phy_rate_tm1_dl = { 6 : 3.2e6, |
| 274 | 15 : 9.2e6, |
| 275 | 25 : 18e6, |
| 276 | 50 : 36e6, |
| 277 | 75 : 55e6, |
| 278 | 100 : 75e6 } |
| 279 | max_phy_rate_tm1_ul = { 6 : 2.0e6, |
| 280 | 15 : 5.1e6, |
| 281 | 25 : 10e6, |
| 282 | 50 : 21e6, |
| 283 | 75 : 32e6, |
Andre Puschmann | c1c2f3d | 2020-09-30 14:41:11 +0200 | [diff] [blame] | 284 | 100 : 47e6 } |
Andre Puschmann | 61d150b | 2020-05-27 10:37:46 +0200 | [diff] [blame] | 285 | if downlink: |
| 286 | max_rate = max_phy_rate_tm1_dl[self.num_prb()] |
| 287 | else: |
| 288 | max_rate = max_phy_rate_tm1_ul[self.num_prb()] |
| 289 | |
| 290 | # MIMO only supported for Downlink |
Andre Puschmann | acdf416 | 2020-06-05 14:25:11 +0200 | [diff] [blame] | 291 | if downlink: |
| 292 | if self._txmode > 2: |
| 293 | max_rate *= 2 |
| 294 | # Lower max MCS for TM2 and above results in lower max rate |
| 295 | if self._txmode >= 2 and self.num_prb() <= 25: |
| 296 | max_rate *= 0.85 |
Andre Puschmann | 61d150b | 2020-05-27 10:37:46 +0200 | [diff] [blame] | 297 | |
Andre Puschmann | 7d3b83e | 2020-09-02 22:17:54 +0200 | [diff] [blame] | 298 | # Assume we schedule all carriers |
| 299 | max_rate *= num_carriers |
| 300 | |
Andre Puschmann | 645b5cc | 2020-09-02 23:02:23 +0200 | [diff] [blame] | 301 | # Reduce expected UL rate due to bug in UCI scheduling in Amarisoft eNB |
| 302 | if downlink == False and num_carriers == 2: |
| 303 | # 2nd carrier @ 25% |
| 304 | max_rate = max_rate / 2 + (.25 * max_rate / 2) |
| 305 | |
Andre Puschmann | 61d150b | 2020-05-27 10:37:46 +0200 | [diff] [blame] | 306 | return max_rate |
| 307 | |
Andre Puschmann | d0682ba | 2020-10-15 15:46:29 +0200 | [diff] [blame] | 308 | def ue_max_rate_tdd(self, downlink, num_carriers): |
| 309 | # Max rate calculation for TDD depends on the acutal TDD configuration |
| 310 | # See: https://www.sharetechnote.com/html/Handbook_LTE_ThroughputCalculationExample_TDD.html |
| 311 | # and https://i0.wp.com/www.techtrained.com/wp-content/uploads/2017/09/Blog_Post_1_TDD_Max_Throughput_Theoretical.jpg |
| 312 | max_phy_rate_tdd_uldl_config0_sp0 = { 6 : 1.5e6, |
| 313 | 15 : 3.7e6, |
| 314 | 25 : 6.1e6, |
| 315 | 50 : 12.2e6, |
| 316 | 75 : 18.4e6, |
| 317 | 100 : 54.5e6 } |
| 318 | if downlink: |
| 319 | max_rate = max_phy_rate_tdd_uldl_config0_sp0[self.num_prb()] |
| 320 | else: |
| 321 | return 1e6 # dummy value, we need to replace that later |
| 322 | |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 323 | # vim: expandtab tabstop=4 shiftwidth=4 |