blob: 34ab5c1cbb38966bc13817f0dde5ee12a9e2464a [file] [log] [blame]
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +02001# 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
20import os
21import pprint
22
Pau Espin Pedrole1a58bd2020-04-10 20:46:07 +020023from ..core import log, util, config, template, process, remote
Pau Espin Pedrolea8c3d42020-05-04 12:05:05 +020024from ..core import schema
Andre Puschmann6e081aa2021-05-04 16:56:25 +020025from ..core.event_loop import MainLoop
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020026from . import enb
Pau Espin Pedrold4404d52020-04-20 13:29:31 +020027from . import rfemu
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020028
Pau Espin Pedrolea8c3d42020-05-04 12:05:05 +020029def on_register_schemas():
30 config_schema = {
31 'license_server_addr': schema.IPV4,
32 }
33 schema.register_config_schema('amarisoft', config_schema)
34
Andre Puschmann2ebcff92020-07-01 12:28:31 +020035 config_schema = {
36 'log_options': schema.STR,
Andre Puschmann6e081aa2021-05-04 16:56:25 +020037 'nr_bandwidth': schema.INT,
Andre Puschmann2ebcff92020-07-01 12:28:31 +020038 }
39 schema.register_config_schema('amarisoftenb', config_schema)
40
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020041def rf_type_valid(rf_type_str):
Andre Puschmann5e080752021-04-14 21:30:08 +020042 return rf_type_str in ('uhd', 'zmq', 'sdr')
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020043
Andre Puschmann6e081aa2021-05-04 16:56:25 +020044def ran_type_valid(ran_type_str):
45 return ran_type_str in ('lte', '5g_nsa')
46
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020047class AmarisoftENB(enb.eNodeB):
48
49 REMOTE_DIR = '/osmo-gsm-tester-amarisoftenb'
50 BINFILE = 'lteenb'
Andre Puschmanne4d5a132020-04-14 22:23:06 +020051 CFGFILE = 'amarisoft_enb.cfg'
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020052 CFGFILE_SIB1 = 'amarisoft_sib1.asn'
53 CFGFILE_SIB23 = 'amarisoft_sib23.asn'
54 CFGFILE_RF = 'amarisoft_rf_driver.cfg'
55 CFGFILE_DRB = 'amarisoft_drb.cfg'
Andre Puschmann6e081aa2021-05-04 16:56:25 +020056 CFGFILE_DRB_NR = 'amarisoft_drb_nr.cfg'
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020057 LOGFILE = 'lteenb.log'
Andre Puschmann008fd312020-07-06 12:28:43 +020058 PHY_SIGNAL_FILE = 'lteenb.log.bin'
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020059
Pau Espin Pedrola442cb82020-05-05 12:54:37 +020060 def __init__(self, testenv, conf):
61 super().__init__(testenv, conf, 'amarisoftenb')
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020062 self.ue = None
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020063 self.run_dir = None
Pau Espin Pedrol214f15e2020-04-03 16:56:12 +020064 self.inst = None
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020065 self._bin_prefix = None
Pau Espin Pedrold4404d52020-04-20 13:29:31 +020066 self.gen_conf = None
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020067 self.config_file = None
68 self.config_sib1_file = None
69 self.config_sib23_file = None
70 self.config_rf_file = None
71 self.config_drb_file = None
Andre Puschmann6e081aa2021-05-04 16:56:25 +020072 self.config_drb_nr_file = None
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020073 self.log_file = None
74 self.process = None
75 self.rem_host = None
Pau Espin Pedrol214f15e2020-04-03 16:56:12 +020076 self.remote_inst = None
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020077 self.remote_config_file = None
78 self.remote_config_sib1_file = None
79 self.remote_config_sib23_file = None
80 self.remote_config_rf_file = None
81 self.remote_config_drb_file = None
Andre Puschmann6e081aa2021-05-04 16:56:25 +020082 self.remote_config_drb_nr_file = None
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020083 self.remote_log_file = None
Andre Puschmanna7f19832020-04-07 14:38:27 +020084 self.enable_measurements = False
Andre Puschmann6e081aa2021-05-04 16:56:25 +020085 self.nr_bandwidth = None
86 self.ran_type = None
Pau Espin Pedrola442cb82020-05-05 12:54:37 +020087 self.testenv = testenv
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020088 if not rf_type_valid(conf.get('rf_dev_type', None)):
89 raise log.Error('Invalid rf_dev_type=%s' % conf.get('rf_dev_type', None))
90
91 def bin_prefix(self):
92 if self._bin_prefix is None:
Pau Espin Pedrol17253af2020-04-02 21:11:19 +020093 self._bin_prefix = os.getenv('AMARISOFT_PATH_ENB', None)
94 if self._bin_prefix == None:
Pau Espin Pedrolb452ed62020-05-26 12:51:44 +020095 self._bin_prefix = self.testenv.suite().trial().get_inst('amarisoftenb', self._run_node.run_label())
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020096 return self._bin_prefix
97
98 def cleanup(self):
99 if self.process is None:
100 return
Pau Espin Pedrol1abff4e2020-05-26 12:32:19 +0200101 if self._run_node.is_local():
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200102 return
103 # copy back files (may not exist, for instance if there was an early error of process):
104 try:
105 self.rem_host.scpfrom('scp-back-log', self.remote_log_file, self.log_file)
106 except Exception as e:
107 self.log(repr(e))
108
Andre Puschmann008fd312020-07-06 12:28:43 +0200109 try:
110 self.rem_host.scpfrom('scp-back-phy-signal-log', self.remote_phy_signal_file, self.phy_signal_file)
111 except Exception as e:
112 self.log(repr(e))
Pau Espin Pedrol41091232020-10-05 19:23:38 +0200113 # Clean up for parent class:
114 super().cleanup()
Andre Puschmann008fd312020-07-06 12:28:43 +0200115
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200116 def start(self, epc):
117 self.log('Starting AmarisoftENB')
Pau Espin Pedrole44e76a2020-03-31 12:35:19 +0200118 self._epc = epc
Pau Espin Pedrol2a2d8462020-05-11 10:56:52 +0200119 self.run_dir = util.Dir(self.testenv.test().get_run_dir().new_dir(self.name()))
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200120 self.configure()
121 self._start()
122
123 # send t+Enter to enable console trace
124 self.dbg('Enabling console trace')
125 self.process.stdin_write('t\n')
126
127 def _start(self):
Pau Espin Pedrol1abff4e2020-05-26 12:32:19 +0200128 if self._run_node.is_local():
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200129 env = { 'LD_LIBRARY_PATH': util.prepend_library_path(self.inst) }
130 binary = self.inst.child('.', AmarisoftENB.BINFILE)
131 self.dbg(run_dir=self.run_dir, binary=binary, env=env)
132 args = (binary, os.path.abspath(self.config_file))
133 self.process = process.Process(self.name(), self.run_dir, args, env=env)
134 else:
135 remote_env = { 'LD_LIBRARY_PATH': self.remote_inst }
136 remote_binary = self.remote_inst.child('', AmarisoftENB.BINFILE)
137 args = (remote_binary, self.remote_config_file)
138 self.process = self.rem_host.RemoteProcess(AmarisoftENB.BINFILE, args, remote_env=remote_env)
139
Pau Espin Pedrola442cb82020-05-05 12:54:37 +0200140 self.testenv.remember_to_stop(self.process)
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200141 self.process.launch()
142
Andre Puschmann215bec22021-01-08 12:34:48 +0100143 def stop(self):
Andre Puschmann6e081aa2021-05-04 16:56:25 +0200144 # Allow for some time to flush logs
145 MainLoop.sleep(5)
Andre Puschmann215bec22021-01-08 12:34:48 +0100146
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200147 def gen_conf_file(self, path, filename, values):
148 self.dbg('AmarisoftENB ' + filename + ':\n' + pprint.pformat(values))
149 with open(path, 'w') as f:
150 r = template.render(filename, values)
151 self.dbg(r)
152 f.write(r)
153
154 def configure(self):
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200155 self.inst = util.Dir(os.path.abspath(self.bin_prefix()))
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200156 if not self.inst.isfile('', AmarisoftENB.BINFILE):
157 raise log.Error('No %s binary in' % AmarisoftENB.BINFILE, self.inst)
158
159 self.config_file = self.run_dir.child(AmarisoftENB.CFGFILE)
160 self.config_sib1_file = self.run_dir.child(AmarisoftENB.CFGFILE_SIB1)
161 self.config_sib23_file = self.run_dir.child(AmarisoftENB.CFGFILE_SIB23)
162 self.config_rf_file = self.run_dir.child(AmarisoftENB.CFGFILE_RF)
163 self.config_drb_file = self.run_dir.child(AmarisoftENB.CFGFILE_DRB)
Andre Puschmann6e081aa2021-05-04 16:56:25 +0200164 self.config_drb_nr_file = self.run_dir.child(AmarisoftENB.CFGFILE_DRB_NR)
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200165 self.log_file = self.run_dir.child(AmarisoftENB.LOGFILE)
Andre Puschmann008fd312020-07-06 12:28:43 +0200166 self.phy_signal_file = self.run_dir.child(AmarisoftENB.PHY_SIGNAL_FILE)
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200167
Pau Espin Pedrol1abff4e2020-05-26 12:32:19 +0200168 if not self._run_node.is_local():
169 self.rem_host = remote.RemoteHost(self.run_dir, self._run_node.ssh_user(), self._run_node.ssh_addr())
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200170 remote_prefix_dir = util.Dir(AmarisoftENB.REMOTE_DIR)
171 self.remote_inst = util.Dir(remote_prefix_dir.child(os.path.basename(str(self.inst))))
172 remote_run_dir = util.Dir(remote_prefix_dir.child(AmarisoftENB.BINFILE))
173
174 self.remote_config_file = remote_run_dir.child(AmarisoftENB.CFGFILE)
175 self.remote_config_sib1_file = remote_run_dir.child(AmarisoftENB.CFGFILE_SIB1)
176 self.remote_config_sib23_file = remote_run_dir.child(AmarisoftENB.CFGFILE_SIB23)
177 self.remote_config_rf_file = remote_run_dir.child(AmarisoftENB.CFGFILE_RF)
178 self.remote_config_drb_file = remote_run_dir.child(AmarisoftENB.CFGFILE_DRB)
Andre Puschmann6e081aa2021-05-04 16:56:25 +0200179 self.remote_config_drb_nr_file = remote_run_dir.child(AmarisoftENB.CFGFILE_DRB_NR)
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200180 self.remote_log_file = remote_run_dir.child(AmarisoftENB.LOGFILE)
Andre Puschmann008fd312020-07-06 12:28:43 +0200181 self.remote_phy_signal_file = remote_run_dir.child(AmarisoftENB.PHY_SIGNAL_FILE)
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200182
Pau Espin Pedrolc04528c2020-04-01 13:55:51 +0200183 values = super().configure(['amarisoft', 'amarisoftenb'])
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200184
Andre Puschmanna7f19832020-04-07 14:38:27 +0200185 # Convert parsed boolean string to Python boolean:
186 self.enable_measurements = util.str2bool(values['enb'].get('enable_measurements', 'false'))
187 config.overlay(values, dict(enb={'enable_measurements': self.enable_measurements}))
188
Andre Puschmann955249d2020-07-01 15:44:09 +0200189 config.overlay(values, dict(enb={'enable_dl_awgn': util.str2bool(values['enb'].get('enable_dl_awgn', 'false'))}))
190
Andre Puschmann6e081aa2021-05-04 16:56:25 +0200191 self.nr_bandwidth = int(values['enb'].get('nr_bandwidth', 10))
192 config.overlay(values, dict(enb={'nr_bandwidth': self.nr_bandwidth}))
193
194 if (self._num_cells > 0):
195 if (self._num_nr_cells <= 0):
196 self.ran_type = "lte"
197 else:
198 self.ran_type = "nsa"
199 else:
200 raise log.Error('5G SA not supported yet')
201
Nils Fürstea8180152020-12-03 14:14:31 +0100202 # Remove EEA0 from cipher list, if specified, as it's always assumed as default
203 cipher_list = values['enb'].get('cipher_list', None)
204 if "eea0" in cipher_list: cipher_list.remove("eea0")
205
Pau Espin Pedrold45a29e2020-04-02 17:21:47 +0200206 # We need to set some specific variables programatically here to match IP addresses:
207 if self._conf.get('rf_dev_type') == 'zmq':
Andre Puschmanne2a6da62020-04-20 20:39:34 +0200208 base_srate = self.num_prb2base_srate(self.num_prb())
Pau Espin Pedrol41091232020-10-05 19:23:38 +0200209 rf_dev_args = self.get_zmq_rf_dev_args(values)
Pau Espin Pedrold45a29e2020-04-02 17:21:47 +0200210 config.overlay(values, dict(enb=dict(sample_rate = base_srate / (1000*1000),
Andre Puschmanne2a6da62020-04-20 20:39:34 +0200211 rf_dev_args = rf_dev_args)))
Pau Espin Pedrold45a29e2020-04-02 17:21:47 +0200212
213 # Set UHD frame size as a function of the cell bandwidth on B2XX
Pau Espin Pedrol6b8f5ae2020-04-07 18:51:57 +0200214 if self._conf.get('rf_dev_type') == 'uhd' and values['enb'].get('rf_dev_args', None) is not None:
Pau Espin Pedrold45a29e2020-04-02 17:21:47 +0200215 if 'b200' in values['enb'].get('rf_dev_args'):
216 rf_dev_args = values['enb'].get('rf_dev_args', '')
217 rf_dev_args += ',' if rf_dev_args != '' and not rf_dev_args.endswith(',') else ''
218
Andre Puschmann0e00f382020-09-23 17:07:07 +0200219 if self._txmode == 1:
220 # SISO config
221 if self._num_prb < 25:
222 rf_dev_args += 'send_frame_size=512,recv_frame_size=512'
223 elif self._num_prb == 25:
224 rf_dev_args += 'send_frame_size=1024,recv_frame_size=1024'
225 else:
226 rf_dev_args += ''
227 else:
228 # MIMO config
229 if self._num_prb == 6:
230 rf_dev_args += 'send_frame_size=512,recv_frame_size=512'
231 else:
232 rf_dev_args += 'num_recv_frames=64,num_send_frames=64'
Pau Espin Pedrold45a29e2020-04-02 17:21:47 +0200233
Andre Puschmann0e00f382020-09-23 17:07:07 +0200234 if self._num_prb > 50:
235 # Reduce over the wire format to sc12
236 rf_dev_args += ',otw_format=sc12'
Pau Espin Pedrold45a29e2020-04-02 17:21:47 +0200237
238 config.overlay(values, dict(enb=dict(rf_dev_args=rf_dev_args)))
239
Pau Espin Pedrol1abff4e2020-05-26 12:32:19 +0200240 logfile = self.log_file if self._run_node.is_local() else self.remote_log_file
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200241 config.overlay(values, dict(enb=dict(log_filename=logfile)))
242
Andre Puschmann008fd312020-07-06 12:28:43 +0200243 phy_signal_file = self.phy_signal_file if self._run_node.is_local() else self.remote_phy_signal_file
244 config.overlay(values, dict(enb=dict(phy_signal_file=phy_signal_file)))
245
Pau Espin Pedrol65beb8f2020-03-31 12:03:19 +0200246 # rf driver is shared between amarisoft enb and ue, so it has a
247 # different cfg namespace 'trx'. Copy needed values over there:
248 config.overlay(values, dict(trx=dict(rf_dev_type=values['enb'].get('rf_dev_type', None),
Pau Espin Pedrola6d63042020-04-20 15:14:51 +0200249 rf_dev_args=values['enb'].get('rf_dev_args', None),
Andre Puschmannc489f192020-10-09 14:46:38 +0200250 rf_dev_sync=values['enb'].get('rf_dev_sync', None),
Pau Espin Pedrola6d63042020-04-20 15:14:51 +0200251 rx_gain=values['enb'].get('rx_gain', None),
252 tx_gain=values['enb'].get('tx_gain', None),
Andre Puschmanna54ca0b2021-04-14 23:24:04 +0200253 rx_ant=values['enb'].get('rx_ant', None),
Pau Espin Pedrola6d63042020-04-20 15:14:51 +0200254 )))
Pau Espin Pedrol65beb8f2020-03-31 12:03:19 +0200255
Pau Espin Pedrold4404d52020-04-20 13:29:31 +0200256 self.gen_conf = values
257
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200258 self.gen_conf_file(self.config_file, AmarisoftENB.CFGFILE, values)
259 self.gen_conf_file(self.config_sib1_file, AmarisoftENB.CFGFILE_SIB1, values)
260 self.gen_conf_file(self.config_sib23_file, AmarisoftENB.CFGFILE_SIB23, values)
261 self.gen_conf_file(self.config_rf_file, AmarisoftENB.CFGFILE_RF, values)
262 self.gen_conf_file(self.config_drb_file, AmarisoftENB.CFGFILE_DRB, values)
Andre Puschmann6e081aa2021-05-04 16:56:25 +0200263 self.gen_conf_file(self.config_drb_nr_file, AmarisoftENB.CFGFILE_DRB_NR, values)
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200264
Pau Espin Pedrol1abff4e2020-05-26 12:32:19 +0200265 if not self._run_node.is_local():
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200266 self.rem_host.recreate_remote_dir(self.remote_inst)
267 self.rem_host.scp('scp-inst-to-remote', str(self.inst), remote_prefix_dir)
268 self.rem_host.recreate_remote_dir(remote_run_dir)
269 self.rem_host.scp('scp-cfg-to-remote', self.config_file, self.remote_config_file)
270 self.rem_host.scp('scp-cfg-sib1-to-remote', self.config_sib1_file, self.remote_config_sib1_file)
271 self.rem_host.scp('scp-cfg-sib23-to-remote', self.config_sib23_file, self.remote_config_sib23_file)
272 self.rem_host.scp('scp-cfg-rr-to-remote', self.config_rf_file, self.remote_config_rf_file)
273 self.rem_host.scp('scp-cfg-drb-to-remote', self.config_drb_file, self.remote_config_drb_file)
Andre Puschmann6e081aa2021-05-04 16:56:25 +0200274 self.rem_host.scp('scp-cfg-drb-nr-to-remote', self.config_drb_nr_file, self.remote_config_drb_nr_file)
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200275
276 def ue_add(self, ue):
277 if self.ue is not None:
278 raise log.Error("More than one UE per ENB not yet supported (ZeroMQ)")
279 self.ue = ue
280
281 def running(self):
282 return not self.process.terminated()
283
Andre Puschmannf249a022021-01-05 14:14:48 +0100284 def get_counter(self, counter_name):
285 if counter_name == 'prach_received':
286 return self.process.get_counter_stdout('PRACH:')
287 raise log.Error('counter %s not implemented!' % counter_name)
288
Andre Puschmann3ce67252021-01-29 17:45:18 +0100289 def get_kpis(self):
290 return {}
291
Pau Espin Pedrold4404d52020-04-20 13:29:31 +0200292 def get_rfemu(self, cell=0, dl=True):
293 cell_list = self.gen_conf['enb'].get('cell_list', None)
294 if cell_list is None or len(cell_list) < cell + 1:
295 raise log.Error('cell_list attribute or subitem not found!')
296 rfemu_cfg = cell_list[cell].get('dl_rfemu', None)
Andre Puschmannccb63202020-06-12 15:09:00 +0200297 if rfemu_cfg is None: # craft amarisoft by default:
Pau Espin Pedrold4404d52020-04-20 13:29:31 +0200298 rfemu_cfg = {'type': 'amarisoftctl',
299 'addr': self.addr(),
300 'ports': [9001]
301 }
302 if rfemu_cfg['type'] == 'amarisoftctl': # this one requires extra config:
303 config.overlay(rfemu_cfg, dict(cell_id=cell_list[cell]['cell_id']))
304 rfemu_obj = rfemu.get_instance_by_type(rfemu_cfg['type'], rfemu_cfg)
305 return rfemu_obj
306
Andre Puschmann6e081aa2021-05-04 16:56:25 +0200307 def get_nr_bandwidth(self):
308 return self.nr_bandwidth
309
Andre Puschmann7d3b83e2020-09-02 22:17:54 +0200310 def ue_max_rate(self, downlink=True, num_carriers=1):
Andre Puschmann6e081aa2021-05-04 16:56:25 +0200311 if self.ran_type == 'lte':
312 if self._duplex == 'fdd':
313 return self.ue_max_rate_fdd(downlink, num_carriers)
314 else:
315 return self.ue_max_rate_tdd(downlink, num_carriers)
Andre Puschmannd0682ba2020-10-15 15:46:29 +0200316 else:
Andre Puschmann6e081aa2021-05-04 16:56:25 +0200317 return self.ue_max_rate_nsa_tdd(downlink)
Andre Puschmannd0682ba2020-10-15 15:46:29 +0200318
319 def ue_max_rate_fdd(self, downlink, num_carriers):
Andre Puschmann61d150b2020-05-27 10:37:46 +0200320 # The max rate for a single UE per PRB configuration in TM1 with MCS 28 QAM64
321 max_phy_rate_tm1_dl = { 6 : 3.2e6,
322 15 : 9.2e6,
323 25 : 18e6,
324 50 : 36e6,
325 75 : 55e6,
326 100 : 75e6 }
327 max_phy_rate_tm1_ul = { 6 : 2.0e6,
328 15 : 5.1e6,
329 25 : 10e6,
330 50 : 21e6,
331 75 : 32e6,
Andre Puschmannc1c2f3d2020-09-30 14:41:11 +0200332 100 : 47e6 }
Andre Puschmann61d150b2020-05-27 10:37:46 +0200333 if downlink:
334 max_rate = max_phy_rate_tm1_dl[self.num_prb()]
335 else:
336 max_rate = max_phy_rate_tm1_ul[self.num_prb()]
337
338 # MIMO only supported for Downlink
Andre Puschmannacdf4162020-06-05 14:25:11 +0200339 if downlink:
340 if self._txmode > 2:
341 max_rate *= 2
342 # Lower max MCS for TM2 and above results in lower max rate
343 if self._txmode >= 2 and self.num_prb() <= 25:
344 max_rate *= 0.85
Andre Puschmann61d150b2020-05-27 10:37:46 +0200345
Andre Puschmann7d3b83e2020-09-02 22:17:54 +0200346 # Assume we schedule all carriers
347 max_rate *= num_carriers
348
Andre Puschmann645b5cc2020-09-02 23:02:23 +0200349 # Reduce expected UL rate due to bug in UCI scheduling in Amarisoft eNB
350 if downlink == False and num_carriers == 2:
351 # 2nd carrier @ 25%
352 max_rate = max_rate / 2 + (.25 * max_rate / 2)
353
Andre Puschmann61d150b2020-05-27 10:37:46 +0200354 return max_rate
355
Andre Puschmannd0682ba2020-10-15 15:46:29 +0200356 def ue_max_rate_tdd(self, downlink, num_carriers):
Andre Puschmann6e081aa2021-05-04 16:56:25 +0200357 # Max rate calculation for TDD depends on the actual TDD configuration
Andre Puschmannd0682ba2020-10-15 15:46:29 +0200358 # See: https://www.sharetechnote.com/html/Handbook_LTE_ThroughputCalculationExample_TDD.html
359 # and https://i0.wp.com/www.techtrained.com/wp-content/uploads/2017/09/Blog_Post_1_TDD_Max_Throughput_Theoretical.jpg
360 max_phy_rate_tdd_uldl_config0_sp0 = { 6 : 1.5e6,
361 15 : 3.7e6,
362 25 : 6.1e6,
363 50 : 12.2e6,
364 75 : 18.4e6,
365 100 : 54.5e6 }
366 if downlink:
Andre Puschmann6e081aa2021-05-04 16:56:25 +0200367 return max_phy_rate_tdd_uldl_config0_sp0[self.num_prb()]
Andre Puschmannd0682ba2020-10-15 15:46:29 +0200368 else:
369 return 1e6 # dummy value, we need to replace that later
370
Andre Puschmann6e081aa2021-05-04 16:56:25 +0200371 def ue_max_rate_nsa_tdd(self, downlink):
372 # Max rate calculation based on https://5g-tools.com/5g-nr-throughput-calculator/
373 # Only FR1 15kHz SCS, QAM64, 6 DL slots, 3 UL slots
374 max_phy_rate_nsa_dl_fr1_15khz = { 10: 18.4e6,
375 20: 38.0e6 }
376 max_phy_rate_nsa_ul_fr1_15khz = { 10: 10.7e6,
377 20: 23.0e6 }
378
379 if downlink:
380 return max_phy_rate_nsa_dl_fr1_15khz[self.get_nr_bandwidth()]
381 else:
382 return max_phy_rate_nsa_ul_fr1_15khz[self.get_nr_bandwidth()]
383
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200384# vim: expandtab tabstop=4 shiftwidth=4