blob: d1f868721f5f8c12cb6fb18ab7714c30f4b1c9ad [file] [log] [blame]
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +02001# osmo_gsm_tester: base classes to share code among eNodeB subclasses.
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
20from abc import ABCMeta, abstractmethod
Pau Espin Pedrole1a58bd2020-04-10 20:46:07 +020021from ..core import log, config
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020022
23
24class eNodeB(log.Origin, metaclass=ABCMeta):
25
26##############
27# PROTECTED
28##############
29 def __init__(self, suite_run, conf, name):
30 super().__init__(log.C_RUN, '%s' % name)
31 self._conf = conf
32 self._addr = conf.get('addr', None)
33 if self._addr is None:
34 raise log.Error('addr not set')
Andre Puschmann4b5a09a2020-04-14 22:24:00 +020035 self._gtp_bind_addr = conf.get('gtp_bind_addr', None)
36 if self._gtp_bind_addr is None:
37 self._gtp_bind_addr = self._addr
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020038 self.set_name('%s_%s' % (name, self._addr))
Pau Espin Pedrole44e76a2020-03-31 12:35:19 +020039 self._txmode = 0
40 self._num_prb = 0
41 self._epc = None
42
Pau Espin Pedrolc04528c2020-04-01 13:55:51 +020043 def configure(self, config_specifics_li):
Pau Espin Pedrole44e76a2020-03-31 12:35:19 +020044 values = dict(enb=config.get_defaults('enb'))
Pau Espin Pedrolc04528c2020-04-01 13:55:51 +020045 for config_specifics in config_specifics_li:
46 config.overlay(values, dict(enb=config.get_defaults(config_specifics)))
Pau Espin Pedrole44e76a2020-03-31 12:35:19 +020047 config.overlay(values, dict(enb=self.suite_run.config().get('enb', {})))
Pau Espin Pedrolc04528c2020-04-01 13:55:51 +020048 for config_specifics in config_specifics_li:
49 config.overlay(values, dict(enb=self.suite_run.config().get(config_specifics, {})))
Pau Espin Pedrole44e76a2020-03-31 12:35:19 +020050 config.overlay(values, dict(enb=self._conf))
51 self._num_prb = int(values['enb'].get('num_prb', None))
52 assert self._num_prb
53 self._txmode = int(values['enb'].get('transmission_mode', None))
54 assert self._txmode
55 config.overlay(values, dict(enb={ 'num_ports': self.num_ports() }))
56 assert self._epc is not None
57 config.overlay(values, dict(enb={ 'mme_addr': self._epc.addr() }))
Andre Puschmann4b5a09a2020-04-14 22:24:00 +020058 config.overlay(values, dict(enb={ 'gtp_bind_addr': self._gtp_bind_addr }))
Pau Espin Pedrole44e76a2020-03-31 12:35:19 +020059 return values
60
61 def num_ports(self):
62 if self._txmode == 1:
63 return 1
64 return 2
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020065
66########################
67# PUBLIC - INTERNAL API
68########################
69 def cleanup(self):
70 'Nothing to do by default. Subclass can override if required.'
71 pass
72
Pau Espin Pedrole44e76a2020-03-31 12:35:19 +020073 def num_prb(self):
74 return self._num_prb
75
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +020076###################
77# PUBLIC (test API included)
78###################
79 @abstractmethod
80 def start(self, epc):
81 'Starts ENB, it will connect to "epc"'
82 pass
83
84 @abstractmethod
85 def ue_add(self, ue):
86 pass
87
88 @abstractmethod
89 def running(self):
90 pass
91
92 @abstractmethod
93 def ue_max_rate(self, downlink=True):
94 pass
95
96 def addr(self):
97 return self._addr
98
Pau Espin Pedrole44e76a2020-03-31 12:35:19 +020099 def ue_max_rate(self, downlink=True):
100 # The max rate for a single UE per PRB configuration in TM1
101 max_phy_rate_tm1_dl = { 6 : 3.5e6,
102 15 : 11e6,
103 25 : 18e6,
104 50 : 36e6,
105 75 : 55e6,
106 100 : 75e6 }
107 max_phy_rate_tm1_ul = { 6 : 0.9e6,
108 15 : 4.7e6,
109 25 : 10e6,
110 50 : 23e6,
111 75 : 34e6,
112 100 : 51e6 }
113 if downlink:
114 max_rate = max_phy_rate_tm1_dl[self.num_prb()]
115 else:
116 max_rate = max_phy_rate_tm1_ul[self.num_prb()]
117 #TODO: calculate for non-standard prb numbers.
118 if self._txmode > 2:
119 max_rate *= 2
120 # We use 3 control symbols for 6, 15 and 25 PRBs which results in lower max rate
121 if self.num_prb() < 50:
122 max_rate *= 0.9
123 return max_rate
124
Pau Espin Pedrol786a6bc2020-03-30 13:51:21 +0200125# vim: expandtab tabstop=4 shiftwidth=4