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 |
Andre Puschmann | 6e081aa | 2021-05-04 16:56:25 +0200 | [diff] [blame] | 25 | from ..core.event_loop import MainLoop |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 26 | from . import enb |
Pau Espin Pedrol | d4404d5 | 2020-04-20 13:29:31 +0200 | [diff] [blame] | 27 | from . import rfemu |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 28 | |
Pau Espin Pedrol | ea8c3d4 | 2020-05-04 12:05:05 +0200 | [diff] [blame] | 29 | def on_register_schemas(): |
| 30 | config_schema = { |
| 31 | 'license_server_addr': schema.IPV4, |
| 32 | } |
| 33 | schema.register_config_schema('amarisoft', config_schema) |
| 34 | |
Andre Puschmann | 2ebcff9 | 2020-07-01 12:28:31 +0200 | [diff] [blame] | 35 | config_schema = { |
| 36 | 'log_options': schema.STR, |
Andre Puschmann | 6e081aa | 2021-05-04 16:56:25 +0200 | [diff] [blame] | 37 | 'nr_bandwidth': schema.INT, |
Andre Puschmann | 2ebcff9 | 2020-07-01 12:28:31 +0200 | [diff] [blame] | 38 | } |
| 39 | schema.register_config_schema('amarisoftenb', config_schema) |
| 40 | |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 41 | def rf_type_valid(rf_type_str): |
Andre Puschmann | 5e08075 | 2021-04-14 21:30:08 +0200 | [diff] [blame] | 42 | return rf_type_str in ('uhd', 'zmq', 'sdr') |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 43 | |
Andre Puschmann | 6e081aa | 2021-05-04 16:56:25 +0200 | [diff] [blame] | 44 | def ran_type_valid(ran_type_str): |
| 45 | return ran_type_str in ('lte', '5g_nsa') |
| 46 | |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 47 | class AmarisoftENB(enb.eNodeB): |
| 48 | |
| 49 | REMOTE_DIR = '/osmo-gsm-tester-amarisoftenb' |
| 50 | BINFILE = 'lteenb' |
Andre Puschmann | e4d5a13 | 2020-04-14 22:23:06 +0200 | [diff] [blame] | 51 | CFGFILE = 'amarisoft_enb.cfg' |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 52 | 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 Puschmann | 6e081aa | 2021-05-04 16:56:25 +0200 | [diff] [blame] | 56 | CFGFILE_DRB_NR = 'amarisoft_drb_nr.cfg' |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 57 | LOGFILE = 'lteenb.log' |
Andre Puschmann | 008fd31 | 2020-07-06 12:28:43 +0200 | [diff] [blame] | 58 | PHY_SIGNAL_FILE = 'lteenb.log.bin' |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 59 | |
Pau Espin Pedrol | a442cb8 | 2020-05-05 12:54:37 +0200 | [diff] [blame] | 60 | def __init__(self, testenv, conf): |
| 61 | super().__init__(testenv, conf, 'amarisoftenb') |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 62 | self.ue = None |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 63 | self.run_dir = None |
Pau Espin Pedrol | 214f15e | 2020-04-03 16:56:12 +0200 | [diff] [blame] | 64 | self.inst = None |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 65 | self._bin_prefix = None |
Pau Espin Pedrol | d4404d5 | 2020-04-20 13:29:31 +0200 | [diff] [blame] | 66 | self.gen_conf = None |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 67 | 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 Puschmann | 6e081aa | 2021-05-04 16:56:25 +0200 | [diff] [blame] | 72 | self.config_drb_nr_file = None |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 73 | self.log_file = None |
| 74 | self.process = None |
| 75 | self.rem_host = None |
Pau Espin Pedrol | 214f15e | 2020-04-03 16:56:12 +0200 | [diff] [blame] | 76 | self.remote_inst = None |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 77 | 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 Puschmann | 6e081aa | 2021-05-04 16:56:25 +0200 | [diff] [blame] | 82 | self.remote_config_drb_nr_file = None |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 83 | self.remote_log_file = None |
Andre Puschmann | a7f1983 | 2020-04-07 14:38:27 +0200 | [diff] [blame] | 84 | self.enable_measurements = False |
Andre Puschmann | 6e081aa | 2021-05-04 16:56:25 +0200 | [diff] [blame] | 85 | self.nr_bandwidth = None |
| 86 | self.ran_type = None |
Pau Espin Pedrol | a442cb8 | 2020-05-05 12:54:37 +0200 | [diff] [blame] | 87 | self.testenv = testenv |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 88 | 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 Pedrol | 17253af | 2020-04-02 21:11:19 +0200 | [diff] [blame] | 93 | self._bin_prefix = os.getenv('AMARISOFT_PATH_ENB', None) |
| 94 | if self._bin_prefix == None: |
Pau Espin Pedrol | b452ed6 | 2020-05-26 12:51:44 +0200 | [diff] [blame] | 95 | 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] | 96 | return self._bin_prefix |
| 97 | |
| 98 | def cleanup(self): |
| 99 | if self.process is None: |
| 100 | return |
Pau Espin Pedrol | 1abff4e | 2020-05-26 12:32:19 +0200 | [diff] [blame] | 101 | if self._run_node.is_local(): |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 102 | 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 Puschmann | 008fd31 | 2020-07-06 12:28:43 +0200 | [diff] [blame] | 109 | 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 Pedrol | 4109123 | 2020-10-05 19:23:38 +0200 | [diff] [blame] | 113 | # Clean up for parent class: |
| 114 | super().cleanup() |
Andre Puschmann | 008fd31 | 2020-07-06 12:28:43 +0200 | [diff] [blame] | 115 | |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 116 | def start(self, epc): |
| 117 | self.log('Starting AmarisoftENB') |
Pau Espin Pedrol | e44e76a | 2020-03-31 12:35:19 +0200 | [diff] [blame] | 118 | self._epc = epc |
Pau Espin Pedrol | 2a2d846 | 2020-05-11 10:56:52 +0200 | [diff] [blame] | 119 | 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] | 120 | 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 Pedrol | 1abff4e | 2020-05-26 12:32:19 +0200 | [diff] [blame] | 128 | if self._run_node.is_local(): |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 129 | 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 Pedrol | a442cb8 | 2020-05-05 12:54:37 +0200 | [diff] [blame] | 140 | self.testenv.remember_to_stop(self.process) |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 141 | self.process.launch() |
| 142 | |
Andre Puschmann | 215bec2 | 2021-01-08 12:34:48 +0100 | [diff] [blame] | 143 | def stop(self): |
Andre Puschmann | 6e081aa | 2021-05-04 16:56:25 +0200 | [diff] [blame] | 144 | # Allow for some time to flush logs |
| 145 | MainLoop.sleep(5) |
Andre Puschmann | 215bec2 | 2021-01-08 12:34:48 +0100 | [diff] [blame] | 146 | |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 147 | 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 Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 155 | self.inst = util.Dir(os.path.abspath(self.bin_prefix())) |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 156 | 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 Puschmann | 6e081aa | 2021-05-04 16:56:25 +0200 | [diff] [blame] | 164 | self.config_drb_nr_file = self.run_dir.child(AmarisoftENB.CFGFILE_DRB_NR) |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 165 | self.log_file = self.run_dir.child(AmarisoftENB.LOGFILE) |
Andre Puschmann | 008fd31 | 2020-07-06 12:28:43 +0200 | [diff] [blame] | 166 | 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] | 167 | |
Pau Espin Pedrol | 1abff4e | 2020-05-26 12:32:19 +0200 | [diff] [blame] | 168 | 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 Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 170 | 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 Puschmann | 6e081aa | 2021-05-04 16:56:25 +0200 | [diff] [blame] | 179 | self.remote_config_drb_nr_file = remote_run_dir.child(AmarisoftENB.CFGFILE_DRB_NR) |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 180 | self.remote_log_file = remote_run_dir.child(AmarisoftENB.LOGFILE) |
Andre Puschmann | 008fd31 | 2020-07-06 12:28:43 +0200 | [diff] [blame] | 181 | 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] | 182 | |
Pau Espin Pedrol | c04528c | 2020-04-01 13:55:51 +0200 | [diff] [blame] | 183 | values = super().configure(['amarisoft', 'amarisoftenb']) |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 184 | |
Andre Puschmann | a7f1983 | 2020-04-07 14:38:27 +0200 | [diff] [blame] | 185 | # 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 Puschmann | 955249d | 2020-07-01 15:44:09 +0200 | [diff] [blame] | 189 | config.overlay(values, dict(enb={'enable_dl_awgn': util.str2bool(values['enb'].get('enable_dl_awgn', 'false'))})) |
| 190 | |
Andre Puschmann | 6e081aa | 2021-05-04 16:56:25 +0200 | [diff] [blame] | 191 | 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ürste | a818015 | 2020-12-03 14:14:31 +0100 | [diff] [blame] | 202 | # 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 Pedrol | d45a29e | 2020-04-02 17:21:47 +0200 | [diff] [blame] | 206 | # We need to set some specific variables programatically here to match IP addresses: |
| 207 | if self._conf.get('rf_dev_type') == 'zmq': |
Andre Puschmann | e2a6da6 | 2020-04-20 20:39:34 +0200 | [diff] [blame] | 208 | base_srate = self.num_prb2base_srate(self.num_prb()) |
Pau Espin Pedrol | 4109123 | 2020-10-05 19:23:38 +0200 | [diff] [blame] | 209 | rf_dev_args = self.get_zmq_rf_dev_args(values) |
Pau Espin Pedrol | d45a29e | 2020-04-02 17:21:47 +0200 | [diff] [blame] | 210 | config.overlay(values, dict(enb=dict(sample_rate = base_srate / (1000*1000), |
Andre Puschmann | e2a6da6 | 2020-04-20 20:39:34 +0200 | [diff] [blame] | 211 | rf_dev_args = rf_dev_args))) |
Pau Espin Pedrol | d45a29e | 2020-04-02 17:21:47 +0200 | [diff] [blame] | 212 | |
| 213 | # 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] | 214 | 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] | 215 | 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 Puschmann | 0e00f38 | 2020-09-23 17:07:07 +0200 | [diff] [blame] | 219 | 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 Pedrol | d45a29e | 2020-04-02 17:21:47 +0200 | [diff] [blame] | 233 | |
Andre Puschmann | 0e00f38 | 2020-09-23 17:07:07 +0200 | [diff] [blame] | 234 | if self._num_prb > 50: |
| 235 | # Reduce over the wire format to sc12 |
| 236 | rf_dev_args += ',otw_format=sc12' |
Pau Espin Pedrol | d45a29e | 2020-04-02 17:21:47 +0200 | [diff] [blame] | 237 | |
| 238 | config.overlay(values, dict(enb=dict(rf_dev_args=rf_dev_args))) |
| 239 | |
Pau Espin Pedrol | 1abff4e | 2020-05-26 12:32:19 +0200 | [diff] [blame] | 240 | 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] | 241 | config.overlay(values, dict(enb=dict(log_filename=logfile))) |
| 242 | |
Andre Puschmann | 008fd31 | 2020-07-06 12:28:43 +0200 | [diff] [blame] | 243 | 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 Pedrol | 65beb8f | 2020-03-31 12:03:19 +0200 | [diff] [blame] | 246 | # 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 Pedrol | a6d6304 | 2020-04-20 15:14:51 +0200 | [diff] [blame] | 249 | rf_dev_args=values['enb'].get('rf_dev_args', None), |
Andre Puschmann | c489f19 | 2020-10-09 14:46:38 +0200 | [diff] [blame] | 250 | rf_dev_sync=values['enb'].get('rf_dev_sync', None), |
Pau Espin Pedrol | a6d6304 | 2020-04-20 15:14:51 +0200 | [diff] [blame] | 251 | rx_gain=values['enb'].get('rx_gain', None), |
| 252 | tx_gain=values['enb'].get('tx_gain', None), |
Andre Puschmann | a54ca0b | 2021-04-14 23:24:04 +0200 | [diff] [blame] | 253 | rx_ant=values['enb'].get('rx_ant', None), |
Pau Espin Pedrol | a6d6304 | 2020-04-20 15:14:51 +0200 | [diff] [blame] | 254 | ))) |
Pau Espin Pedrol | 65beb8f | 2020-03-31 12:03:19 +0200 | [diff] [blame] | 255 | |
Pau Espin Pedrol | d4404d5 | 2020-04-20 13:29:31 +0200 | [diff] [blame] | 256 | self.gen_conf = values |
| 257 | |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 258 | 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 Puschmann | 6e081aa | 2021-05-04 16:56:25 +0200 | [diff] [blame] | 263 | self.gen_conf_file(self.config_drb_nr_file, AmarisoftENB.CFGFILE_DRB_NR, values) |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 264 | |
Pau Espin Pedrol | 1abff4e | 2020-05-26 12:32:19 +0200 | [diff] [blame] | 265 | if not self._run_node.is_local(): |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 266 | 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 Puschmann | 6e081aa | 2021-05-04 16:56:25 +0200 | [diff] [blame] | 274 | self.rem_host.scp('scp-cfg-drb-nr-to-remote', self.config_drb_nr_file, self.remote_config_drb_nr_file) |
Pau Espin Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 275 | |
| 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 Puschmann | f249a02 | 2021-01-05 14:14:48 +0100 | [diff] [blame] | 284 | 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 Puschmann | 3ce6725 | 2021-01-29 17:45:18 +0100 | [diff] [blame] | 289 | def get_kpis(self): |
| 290 | return {} |
| 291 | |
Pau Espin Pedrol | d4404d5 | 2020-04-20 13:29:31 +0200 | [diff] [blame] | 292 | 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 Puschmann | ccb6320 | 2020-06-12 15:09:00 +0200 | [diff] [blame] | 297 | if rfemu_cfg is None: # craft amarisoft by default: |
Pau Espin Pedrol | d4404d5 | 2020-04-20 13:29:31 +0200 | [diff] [blame] | 298 | 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 Puschmann | 6e081aa | 2021-05-04 16:56:25 +0200 | [diff] [blame] | 307 | def get_nr_bandwidth(self): |
| 308 | return self.nr_bandwidth |
| 309 | |
Andre Puschmann | 7d3b83e | 2020-09-02 22:17:54 +0200 | [diff] [blame] | 310 | def ue_max_rate(self, downlink=True, num_carriers=1): |
Andre Puschmann | 6e081aa | 2021-05-04 16:56:25 +0200 | [diff] [blame] | 311 | 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 Puschmann | d0682ba | 2020-10-15 15:46:29 +0200 | [diff] [blame] | 316 | else: |
Andre Puschmann | 6e081aa | 2021-05-04 16:56:25 +0200 | [diff] [blame] | 317 | return self.ue_max_rate_nsa_tdd(downlink) |
Andre Puschmann | d0682ba | 2020-10-15 15:46:29 +0200 | [diff] [blame] | 318 | |
| 319 | def ue_max_rate_fdd(self, downlink, num_carriers): |
Andre Puschmann | 61d150b | 2020-05-27 10:37:46 +0200 | [diff] [blame] | 320 | # 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 Puschmann | c1c2f3d | 2020-09-30 14:41:11 +0200 | [diff] [blame] | 332 | 100 : 47e6 } |
Andre Puschmann | 61d150b | 2020-05-27 10:37:46 +0200 | [diff] [blame] | 333 | 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 Puschmann | acdf416 | 2020-06-05 14:25:11 +0200 | [diff] [blame] | 339 | 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 Puschmann | 61d150b | 2020-05-27 10:37:46 +0200 | [diff] [blame] | 345 | |
Andre Puschmann | 7d3b83e | 2020-09-02 22:17:54 +0200 | [diff] [blame] | 346 | # Assume we schedule all carriers |
| 347 | max_rate *= num_carriers |
| 348 | |
Andre Puschmann | 645b5cc | 2020-09-02 23:02:23 +0200 | [diff] [blame] | 349 | # 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 Puschmann | 61d150b | 2020-05-27 10:37:46 +0200 | [diff] [blame] | 354 | return max_rate |
| 355 | |
Andre Puschmann | d0682ba | 2020-10-15 15:46:29 +0200 | [diff] [blame] | 356 | def ue_max_rate_tdd(self, downlink, num_carriers): |
Andre Puschmann | 6e081aa | 2021-05-04 16:56:25 +0200 | [diff] [blame] | 357 | # Max rate calculation for TDD depends on the actual TDD configuration |
Andre Puschmann | d0682ba | 2020-10-15 15:46:29 +0200 | [diff] [blame] | 358 | # 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 Puschmann | 6e081aa | 2021-05-04 16:56:25 +0200 | [diff] [blame] | 367 | return max_phy_rate_tdd_uldl_config0_sp0[self.num_prb()] |
Andre Puschmann | d0682ba | 2020-10-15 15:46:29 +0200 | [diff] [blame] | 368 | else: |
| 369 | return 1e6 # dummy value, we need to replace that later |
| 370 | |
Andre Puschmann | 6e081aa | 2021-05-04 16:56:25 +0200 | [diff] [blame] | 371 | 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 Pedrol | 786a6bc | 2020-03-30 13:51:21 +0200 | [diff] [blame] | 384 | # vim: expandtab tabstop=4 shiftwidth=4 |