BearerConfigurator.h Source File

Simu5G: BearerConfigurator.h Source File
Simu5G
BearerConfigurator.h
1//
2// Simu5G
3//
4// Authors: Andras Varga (OpenSim Ltd)
5//
6// This file is part of a software released under the license included in file
7// "license.pdf". Please read LICENSE and README files before using it.
8// The above files and the present reference are part of the software itself,
9// and cannot be removed from it.
10//
11
12#ifndef _BEARERCONFIGURATOR_H_
13#define _BEARERCONFIGURATOR_H_
14
15#include <map>
16#include <memory>
17#include <set>
18#include <vector>
19
20#include <inet/common/ModuleRefByPar.h>
21#include <inet/common/packet/PacketFilter.h>
22
23#include "simu5g/common/LteCommon.h"
24#include "simu5g/common/binder/Binder.h"
25#include "simu5g/common/QfiRuleSet.h"
26#include "simu5g/stack/rrc/DrbDesc.h"
27
28namespace simu5g {
29
30using namespace omnetpp;
31
39class BearerConfigurator : public cSimpleModule
40{
41 public:
42 ~BearerConfigurator() override;
43
44 // A bearer definition retained for establishment-time authoring: the UE it belongs
45 // to, the descriptor delivered to the RRCs, and its compiled packet filters. One
46 // record per (entry x matched UE); records keep table order, staticDrbs before
47 // onDemandDrbs, which is the match order of ConnectionControlEnb::establishBearer().
48 // An onDemandDrbs record carries no DRB id of its own (desc.key stays DRBID_NONE):
49 // like every DRB id, an on-demand bearer's identity is pair-scoped, assigned by
50 // the base station at the definition's first match within each node pair and
51 // returned to the pair's pool with the bearer -- so a UE that moves to another
52 // serving node materializes the definition afresh there.
53 struct AuthoredBearer {
54 cModule *ueModule = nullptr;
55 SessionId sessionId = SessionId(0); // the UE's session the bearer belongs to (see assignSession())
56 DrbDesc desc; // key = (NODEID_NONE, drbId); DRBID_NONE for onDemand
57 bool onDemand = false; // true = onDemandDrbs entry (ids assigned at first match, per pair)
58 bool rohcByPolicy = false; // desc.rohcProfiles come from the rohcForDrbProfiles policy, not from the entry's "rohc" field
59 std::vector<std::unique_ptr<inet::PacketFilter>> filters; // compiled desc.filters
60
61 friend std::ostream& operator<<(std::ostream& os, const AuthoredBearer& e)
62 {
63 // ueModule is not dereferenced here: it is not reset when a UE departs the
64 // simulation, so it can go stale while this record is still in authoredBearers_
65 os << "ue=" << static_cast<const void *>(e.ueModule) << " drbKey=" << e.desc.key
66 << " onDemand=" << e.onDemand << " filters=" << e.filters.size();
67 return os;
68 }
69 };
70
71 protected:
72 inet::ModuleRefByPar<Binder> binder_;
73
74 // QoS-derived RAN defaults for definitions that state no rlcMode/lcg themselves:
75 // the amPerThreshold and lcgPriorityBounds parameters (see the NED documentation)
76 double amPerThreshold_ = 0;
77 std::vector<long> lcgPriorityBounds_;
78
79 // Header compression policy for definitions that do not state "rohc": the profile
80 // names whose bearers get ROHC (the rohcForDrbProfiles parameter)
81 std::set<std::string> rohcForDrbProfiles_;
82
83 std::vector<AuthoredBearer> authoredBearers_;
84
85 protected:
86 void initialize(int stage) override;
87 int numInitStages() const override { return inet::NUM_INIT_STAGES; }
88 void handleMessage(cMessage *msg) override { throw cRuntimeError("This module does not process messages"); }
89
90 // The policy: the session of the UE that a bearer definition belongs to. Every
91 // definition belongs to session 1, the UE's one session under the one-session-per-UE
92 // policy of CoreControl::sessionsToEstablish(); a subclass that establishes several
93 // sessions per UE assigns the definitions among them.
94 virtual SessionId assignSession(const AuthoredBearer& definition) const;
95
96 // The policy: whether an entry of the ulQfiRules table that applies to the UE
97 // belongs to the given session of it. Every entry belongs to session 1 (see
98 // assignSession()).
99 virtual bool isUplinkQfiRuleOfSession(const cValueMap *entry, const cModule *ue, SessionId session) const;
100
101 // Parse the data radio bearers described by the staticDrbs and onDemandDrbs
102 // parameters (see NED documentation) into authoredBearers_. Nothing is pushed
103 // from here: the base station serving a UE installs and establishes the UE's
104 // static bearers when the UE attaches (ConnectionControlEnb::sessionResourceSetup()).
105 virtual void configureDrbs();
106
107 // A static definition's UE must be attached on some stack at the end of
108 // initialization, or its bearer has nowhere to be established: a configuration error
109 virtual void validateStaticDrbs();
110
111 // The standardized QoS characteristics rows as built-in drbProfiles entries
112 // ("qci-1".."qci-9", "5qi-1".."5qi-9"); built lazily, owned by this module
113 omnetpp::cValueMap *predefinedDrbProfiles_ = nullptr;
114 virtual const omnetpp::cValueMap *getPredefinedDrbProfiles();
115
116 // Settle the SDAP header decision of one bearer record (TS 38.331 sdap-HeaderDL/UL,
117 // stored in DrbDesc::useSdapHeader): a header is needed exactly when the bearer
118 // alone cannot name the arriving QFI on the RX side -- it is the default bearer or
119 // several QFIs map to it -- unless the configuration suppresses it, asserting that
120 // a single QoS flow rides the bearer (which SDAP verifies per packet). Called once
121 // the UE's default bearer is settled, since the decision hangs on isDefault.
122 virtual void computeUseSdapHeader(DrbDesc& drb);
123
124 // Parse one bearer-definition table (staticDrbs or onDemandDrbs) into
125 // authoredBearers_, and, for staticDrbs, into drbsOfUe, where the UE's default
126 // bearer is settled.
127 virtual void parseDrbDefinitions(const char *paramName, bool onDemand,
128 const std::map<cModule *, std::vector<MacNodeId>>& ueNodeIds, const std::string& networkPrefix,
129 std::map<cModule *, std::map<DrbId, DrbDesc>>& drbsOfUe);
130
131 // Validate the two QFI rule tables at initialization: every entry's field vocabulary
132 // and grammar, and that every scoped entry matches a site -- a "node" pattern a
133 // user plane node (registered with the Binder), a "ue" pattern a
134 // registered UE with SDAP -- since a pattern that matches nothing is a typo the
135 // per-site compilation (getDownlinkQfiRules() etc.) would never surface.
136 virtual void validateQfiRules();
137
138 // A module's path relative to the network, which the tables' patterns are matched against
139 virtual std::string relativeToNetwork(const cModule *module) const;
140
141 public:
142 // Whether the UE's stack contains SDAP. Structure, not configuration: the sdap
143 // submodule exists iff the NIC's hasSdap is set, the same resolvability test
144 // BearerManagement::configureDrb() applies on its own side.
145 static bool ueStackHasSdap(const cModule *ueModule);
146
147 // ---- the bearer definitions, read by the base stations ----
148
149 // Every retained definition, in table order (staticDrbs before onDemandDrbs), of
150 // every UE; the records keep their addresses for the whole run
151 virtual const std::vector<AuthoredBearer>& getBearerDefinitions() const { return authoredBearers_; }
152
153 // The "epc" definition of the session of the UE that an uplink or downlink packet
154 // of the session matches: the first of the session's entries, in table order,
155 // whose packet filter matches; failing that, the session's default entry; nullptr
156 // if none covers it
157 virtual const AuthoredBearer *findDrbDefinition(const cModule *ueModule, SessionId session, const inet::Packet *pkt) const;
158
159 // The "5gc" definition of the session of the UE that maps the QFI: the first of
160 // the session's entries, in table order, that names it; failing that, the
161 // session's default entry (it carries the QFIs no other bearer of the session
162 // maps); nullptr if none
163 virtual const AuthoredBearer *findDrbDefinitionForQfi(const cModule *ueModule, SessionId session, Qfi qfi) const;
164
165 // The staticDrbs entry of the UE that names the DRB id, or nullptr. A static
166 // definition owns its id for the whole run, so teardown must not release it.
167 virtual const AuthoredBearer *findStaticDrbDefinition(const cModule *ueModule, DrbId drbId) const;
168
169 // ---- the QFI rule tables, read by CoreControl ----
170
171 // The downlink QFI classification rules of a user plane node: the dlQfiRules
172 // entries whose "node" pattern matches the node's path relative to the network (an
173 // entry without one matches every node), in table order. Read by CoreControl, which
174 // installs them into the node over N4; this module delivers nothing itself.
175 virtual QfiRuleSet getDownlinkQfiRules(const cModule *node) const;
176
177 // The uplink QFI classification rules of a session of a UE: the ulQfiRules entries
178 // scoped to the UE, likewise, that belong to the session (see
179 // isUplinkQfiRuleOfSession()). Read by CoreControl, which delivers them to the UE's
180 // classifier as the QoS rules of the session's establishment.
181 virtual QfiRuleSet getUplinkQfiRules(const cModule *ue, SessionId session) const;
182
183 // Whether an entry of the ulQfiRules table that belongs to the session names the
184 // given UE by its "ue" scope, i.e. a QoS rule authored for the UE rather than for
185 // every UE
186 virtual bool hasUplinkQfiRulesScopedTo(const cModule *ue, SessionId session) const;
187
188 // Whether such an entry, scoped to the given UE, is a dscpAsQfi rule
189 virtual bool hasUplinkDscpAsQfiRuleScopedTo(const cModule *ue, SessionId session) const;
190};
191
192} //namespace
193
194#endif
Definition BearerConfigurator.h:40
An ordered set of QFI-assignment rules, shared by every module that classifies packets to QoS flows.
Definition QfiRuleSet.h:57
Definition AlertReceiver.h:24