LteTypes.h Source File

Simu5G: LteTypes.h Source File
Simu5G
LteTypes.h
1//
2// Simu5G
3//
4// Authors: Giovanni Nardini, Giovanni Stea, Antonio Virdis (University of Pisa)
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//
13// This file contains fundamental LTE type definitions that are used both
14// in MSG files (via cplusplus {{ #include }}) and in C++ code.
15//
16
17#ifndef _LTE_LTETYPES_H_
18#define _LTE_LTETYPES_H_
19
20#include <map>
21#include <ostream>
22#include <string>
23
24#include <omnetpp.h>
25#include <inet/common/Units.h>
26
27#include "simu5g/common/LteCommonEnum_m.h"
28
29using namespace omnetpp;
30
31namespace simu5g {
32
43#define SIMU5G_STRONG_TYPEDEF(TypeName, UnderlyingType) \
44 enum class TypeName : UnderlyingType {}; \
45 inline UnderlyingType num(TypeName id) { return static_cast<UnderlyingType>(id); } \
46 inline std::ostream& operator<<(std::ostream& os, TypeName id) { os << +static_cast<UnderlyingType>(id); return os; } /* unary + : a uint8_t id is a number, not a character */ \
47 inline void doParsimPacking(omnetpp::cCommBuffer *buffer, TypeName d) { buffer->pack(num(d)); } \
48 inline void doParsimUnpacking(omnetpp::cCommBuffer *buffer, TypeName& d) { UnderlyingType tmp; buffer->unpack(tmp); d = TypeName(tmp); }
49
51SIMU5G_STRONG_TYPEDEF(MacNodeId, unsigned short)
52
53
54constexpr MacNodeId NODEID_NONE = MacNodeId(0);
55constexpr unsigned short ENB_MIN_ID = 1;
56constexpr unsigned short ENB_MAX_ID = 1023;
57constexpr unsigned short BGUE_ID = 1024;
58constexpr unsigned short UE_MIN_ID = 1025;
59constexpr unsigned short NR_UE_MIN_ID = 2049;
60constexpr unsigned short BGUE_MIN_ID = 4097;
61constexpr unsigned short UE_MAX_ID = 32767;
62constexpr unsigned short MULTICAST_DEST_MIN_ID = 32768;
63
64
66typedef MacNodeId MacCellId;
67
69typedef MacNodeId X2NodeId;
70
72SIMU5G_STRONG_TYPEDEF(LogicalCid, unsigned short)
73
75SIMU5G_STRONG_TYPEDEF(DrbId, unsigned short)
76
78SIMU5G_STRONG_TYPEDEF(Qfi, uint8_t)
79// "no QFI": out of the 6-bit QFI value range (TS 38.331: 0..63), because 0 is a real
80// QFI -- the default QoS flow's -- and a sentinel that collides with it cannot be told
81// apart from a packet classified onto the default flow
82constexpr Qfi QFI_NONE = Qfi(255);
83
85SIMU5G_STRONG_TYPEDEF(Teid, uint32_t)
86// "no tunnel": TEIDs are handed out from 1 (see UserPlaneNodeControl::allocateTeid() and ConnectionControlEnb::allocateTeid())
87constexpr Teid TEID_NONE = Teid(0);
88
91SIMU5G_STRONG_TYPEDEF(SessionId, uint8_t)
92
94SIMU5G_STRONG_TYPEDEF(Lcg, uint8_t)
95// LTE has 4 LCGs (TS 36.321), NR allows up to 8 (TS 38.321); the LCG schedulers serve
96// this many, in increasing-index priority order (lower LCG index is served first)
97constexpr unsigned short NUM_LCGS = 4;
98
99
101constexpr LogicalCid LCID_NONE = LogicalCid(65535);
102constexpr DrbId DRBID_NONE = DrbId(65535);
103
107constexpr unsigned short MAX_DRB_ID = 32;
108
110// TODO add LONG/TRUNCATED BSR
111// TODO FIXME these conflict with DRB LCIDs (1..), and also 0 is reserved for CCCH (common control channel)
112constexpr LogicalCid SHORT_BSR = LogicalCid(0); // should be 62 (NR)
113constexpr LogicalCid D2D_SHORT_BSR = LogicalCid(1); // Simu5G-specific
114constexpr LogicalCid D2D_MULTI_SHORT_BSR = LogicalCid(2); // Simu5G-specific
115
121constexpr unsigned short BSR_UL_LCID_BASE = 64;
122inline LogicalCid bsrLcidForLcg(Lcg lcg) { return LogicalCid(BSR_UL_LCID_BASE + num(lcg)); }
123inline bool isUlBsrLcid(LogicalCid lcid) { return num(lcid) >= BSR_UL_LCID_BASE && num(lcid) < BSR_UL_LCID_BASE + NUM_LCGS; }
124inline Lcg lcgFromBsrLcid(LogicalCid lcid) { ASSERT(isUlBsrLcid(lcid)); return Lcg(num(lcid) - BSR_UL_LCID_BASE); }
125
127// MacCid is now a class with separate fields instead of a packed integer
128
130typedef unsigned short Rank;
131
133typedef unsigned short Cqi;
134
135
137typedef unsigned short Tbs;
138
140typedef unsigned short Band;
141
145typedef std::map<Remote, std::map<Band, unsigned int>> RbMap;
146
152class MacCid
153{
154private:
155 MacNodeId nodeId_;
156 LogicalCid lcid_;
157
158public:
159 // Default constructor
160 MacCid() : nodeId_(NODEID_NONE), lcid_(LCID_NONE) {}
161
162 // Constructor
163 MacCid(MacNodeId nodeId, LogicalCid lcid) : nodeId_(nodeId), lcid_(lcid) {}
164
165 // Getters
166 MacNodeId getNodeId() const { return nodeId_; }
167 LogicalCid getLcid() const { return lcid_; }
168 unsigned int asPackedInt() const { return (num(nodeId_) << 16) | num(lcid_); }
169
170 // Check if this is an empty/invalid MacCid (default constructed)
171 bool isEmpty() const { return nodeId_ == NODEID_NONE && lcid_ == LCID_NONE; }
172
173 // String representation
174 std::string str() const { return "MacCid(nodeId=" + std::to_string(num(nodeId_)) + ", lcid=" + std::to_string(num(lcid_)) + ")"; }
175
176 // Comparison operators for std::map compatibility
177 bool operator<(const MacCid& other) const { return asPackedInt() < other.asPackedInt(); }
178 bool operator==(const MacCid& other) const { return nodeId_ == other.nodeId_ && lcid_ == other.lcid_; }
179 bool operator!=(const MacCid& other) const { return nodeId_ != other.nodeId_ || lcid_ != other.lcid_; }
180
181 // Stream output operator
182 friend std::ostream& operator<<(std::ostream& os, const MacCid& cid) { return os << cid.str(); }
183};
184
190class DrbKey
191{
192private:
193 MacNodeId nodeId_;
194 DrbId drbId_;
195
196public:
197 // Default constructor
198 DrbKey() : nodeId_(NODEID_NONE), drbId_(DRBID_NONE) {}
199
200 // Constructor
201 DrbKey(MacNodeId nodeId, DrbId drbId) : nodeId_(nodeId), drbId_(drbId) {}
202
203 // Getters
204 MacNodeId getNodeId() const { return nodeId_; }
205 DrbId getDrbId() const { return drbId_; }
206 unsigned int asPackedInt() const { return (num(nodeId_) << 16) | num(drbId_); }
207
208 // Check if this is an empty/invalid DrbKey (default constructed)
209 bool isEmpty() const { return nodeId_ == NODEID_NONE && drbId_ == DRBID_NONE; }
210
211 // String representation
212 std::string str() const { return "DrbKey(nodeId=" + std::to_string(num(nodeId_)) + ", drbId=" + std::to_string(num(drbId_)) + ")"; }
213
214 // Comparison operators for std::map compatibility
215 bool operator<(const DrbKey& other) const { return asPackedInt() < other.asPackedInt(); }
216 bool operator==(const DrbKey& other) const { return nodeId_ == other.nodeId_ && drbId_ == other.drbId_; }
217 bool operator!=(const DrbKey& other) const { return nodeId_ != other.nodeId_ || drbId_ != other.drbId_; }
218
219 // Stream output operator
220 friend std::ostream& operator<<(std::ostream& os, const DrbKey& id) { return os << id.str(); }
221};
222
223} // namespace simu5g
224
225#endif
Definition AlertReceiver.h:24
unsigned short Tbs
Transport Block Size.
Definition LteTypes.h:137
constexpr LogicalCid SHORT_BSR
Special LogicalCid values for Buffer Status Reports.
Definition LteTypes.h:112
MacNodeId X2NodeId
X2 node ID. It is equal to the eNodeB MAC Cell ID.
Definition LteTypes.h:69
unsigned short Band
Logical band.
Definition LteTypes.h:140
constexpr Teid TEID_NONE
GTP-U Tunnel Endpoint Identifier (TS 29.281), chosen by the receiving end of the tunnel.
Definition LteTypes.h:87
constexpr unsigned short MAX_DRB_ID
Definition LteTypes.h:107
constexpr LogicalCid LCID_NONE
Invalid/uninitialized LCID and DRB ID values.
Definition LteTypes.h:101
MacNodeId MacCellId
Cell node ID. It is numerically equal to eNodeB MAC node ID.
Definition LteTypes.h:66
unsigned short Cqi
Channel Quality Indicator.
Definition LteTypes.h:133
unsigned short Rank
Connection Identifier: <MacNodeId,LogicalCid>
Definition LteTypes.h:130
std::map< Remote, std::map< Band, unsigned int > > RbMap
Definition LteTypes.h:145
constexpr Qfi QFI_NONE
Logical Connection Identifier (used in MAC layer)
Definition LteTypes.h:82
constexpr unsigned short NUM_LCGS
Logical Channel Group id, as reported in Buffer Status Reports.
Definition LteTypes.h:97
constexpr MacNodeId NODEID_NONE
MAC node ID.
Definition LteTypes.h:54
constexpr unsigned short BSR_UL_LCID_BASE
Definition LteTypes.h:121