PacketFlowObserverEnb.h Source File

Simu5G: PacketFlowObserverEnb.h Source File
Simu5G
PacketFlowObserverEnb.h
1//
2// Simu5G
3//
4// Copyright (C) 2019-2021 Giovanni Nardini, Giovanni Stea, Antonio Virdis et al. (University of Pisa)
5// Copyright (C) 2022-2026 Giovanni Nardini, Giovanni Stea et al. (University of Pisa)
6//
7// This file is part of a software released under the license included in file
8// "license.pdf". Please read LICENSE and README files before using it.
9// The above files and the present reference are part of the software itself,
10// and cannot be removed from it.
11//
12
13#ifndef _LTE_PacketFlowObserverENB_H_
14#define _LTE_PacketFlowObserverENB_H_
15
16#include "simu5g/common/LteCommon.h"
17#include "simu5g/mec/utils/MecCommon.h"
18
19#include "PacketFlowObserverBase.h"
20#include "simu5g/stack/packetFlowObserver/PacketFlowObserverBase.h"
21
22namespace simu5g {
23
24using namespace omnetpp;
25
26class LteRlcUmDataPdu;
27
32{
33 protected:
34
35 struct Grant {
36 unsigned int grantId;
37 simtime_t sendTimestamp;
38
39 friend std::ostream& operator<<(std::ostream& os, const Grant& e) {
40 os << "grantId=" << e.grantId << " sendTimestamp=" << e.sendTimestamp;
41 return os;
42 }
43 };
44
45 struct BurstStatus {
46 std::map<unsigned int, unsigned int> rlcPdu; // RLC PDU of the burst and the relative RLC SDU size
47 simtime_t startBurstTransmission; // moment of the first transmission of the burst
48 unsigned int burstSize; // PDCP SDU size of the burst
49 bool isCompleted;
50 };
51
52 struct PacketLoss {
53 int lastPdpcSno;
54 int totalLossPdcp;
55 unsigned int totalPdcpArrived;
56 unsigned int totalPdcpSno;
57
58 void clear()
59 {
60 lastPdpcSno = 0;
61 totalLossPdcp = 0;
62 totalPdcpArrived = 0;
63 totalPdcpSno = 0;
64 }
65
66 // resets the counters at the end of each period, i.e., lastPdcpSno remains
67 void reset()
68 {
69 totalLossPdcp = 0;
70 totalPdcpArrived = 0;
71 totalPdcpSno = 0;
72 }
73
74 friend std::ostream& operator<<(std::ostream& os, const PacketLoss& e) {
75 os << "lastPdcpSno=" << e.lastPdpcSno << " totalLossPdcp=" << e.totalLossPdcp
76 << " totalPdcpArrived=" << e.totalPdcpArrived << " totalPdcpSno=" << e.totalPdcpSno;
77 return os;
78 }
79 };
80
81 /*
82 * The node can have different active connections (DRB ID) at the same time, hence we need to
83 * maintain the status for each of them
84 */
85 struct StatusDescriptor {
86 MacNodeId nodeId_; // destination node of this DRB ID
87 bool burstState_; // control variable that controls one burst active at a time
88 BurstId burstId_; // separates the bursts
89 std::map<unsigned int, PdcpStatus> pdcpStatus_; // a PDCP PDU can be fragmented into many RLC PDUs that could be sent and acknowledged at different times (this prevents early removal on acknowledgment)
90 std::map<BurstId, BurstStatus> burstStatus_; // for each burst, stores relative information
91 std::map<unsigned int, SequenceNumberSet> rlcPdusPerSdu_; // for each RLC SDU, stores the RLC PDUs where the former was fragmented
92 std::map<unsigned int, SequenceNumberSet> rlcSdusPerPdu_; // for each RLC PDU, stores the included RLC SDUs
93 std::map<unsigned int, SequenceNumberSet> macSdusPerPdu_; // for each MAC PDU, stores the included MAC SDUs (should be a 1:1 association)
94 };
95
96 typedef std::map<DrbKey, StatusDescriptor> ConnectionMap;
97 ConnectionMap connectionMap_; // bearer (peer node + DRB ID) to the corresponding StatusDescriptor
98
99 std::map<MacNodeId, Delay> ULPktDelay_;
100 std::map<MacNodeId, std::vector<Grant>> ulGrants_;
101 std::map<MacNodeId, PacketLoss> packetLossRate_;
102 std::map<MacNodeId, Delay> pdcpDelay_; // map that sums all the delay times of a destination NodeId (UE) and the corresponding counter
103 std::map<MacNodeId, Throughput> pdcpThroughput_; // map that sums all the bytes sent by a destination NodeId (UE) and the corresponding time elapsed
104 std::map<MacNodeId, DiscardedPkts> pktDiscardCounterPerUe_; // discard counter per NodeId (UE)
105 std::map<MacNodeId, DataVolume> sduDataVolume_;
106 short int harqProcesses_; // number of HARQ processes
107
108 // debug variable that calculates DL delay of a UE (with id 2053)
109 // used to evaluate the delay with respect to the one reported by Simu5G
110 cOutVector timesUe_;
111
112 protected:
113 void initialize(int stage) override;
114
115 /*
116 * This method checks if a PDCP PDU of a DRB ID is part of a burst of data.
117 * In a positive case, according to the ack boolean its size is counted in the
118 * total of the burst size.
119 * It is called by macPduArrived (ack true) and rlcPduDiscarded (ack false)
120 * @param desc DRB ID descriptor
121 * @param rlcSno RLC sequence number
122 * @bool ack PDCP acknowledgment flag
123 */
124 virtual void removePdcpBurstRLC(StatusDescriptor *desc, unsigned int rlcSno, bool ack);
125 virtual void ensureMacPduMapping(MacNodeId peerId, const LteMacPdu *macPdu);
126
127 /*
128 * This method creates a pdcpStatus structure when a PDCP SDU arrives at the PDCP layer.
129 */
130 virtual void initPdcpStatus(StatusDescriptor *desc, unsigned int pdcp, unsigned int sduHeaderSize, simtime_t arrivalTime);
131
132 // return true if a structure for this DRB ID is present
133 bool hasDrbId(DrbKey drbKey) override;
134 // initialize a new structure for this DRB ID
135 void initDrbId(DrbKey drbKey, MacNodeId nodeId) override;
136 // reset the structure for this DRB ID
137 void clearDrbId(DrbKey drbKey) override;
138 // reset structures for all connections
139 void clearAllDrbIds() override;
140
141 public:
142 void insertPdcpSdu(inet::Packet *pdcpPkt) override;
143 void receivedPdcpSdu(inet::Packet *pdcpPkt) override;
144 void insertRlcPdu(DrbKey drbKey, const LteRlcUmDataPdu *rlcPdu, RlcBurstStatus status) override;
145 void macPduArrived(MacNodeId peerId, const LteMacPdu *macPdu) override;
146 void ulMacPduArrived(MacNodeId nodeId, unsigned int grantId) override;
147 void discardMacPdu(MacNodeId peerId, const LteMacPdu *macPdu) override;
148 void discardRlcPdu(DrbKey drbKey, unsigned int rlcSno, bool fromMac = false) override;
149 void grantSent(MacNodeId nodeId, unsigned int grantId) override;
150
154 virtual void deleteUe(MacNodeId id);
155
156 // Per-UE statistics
157
158 virtual uint64_t getDataVolume(MacNodeId nodeId, Direction dir);
159 virtual void resetDataVolume(MacNodeId nodeId, Direction dir);
160 virtual void resetDataVolume(MacNodeId nodeId);
161
162 virtual double getPdpcLossRate();
163 virtual double getPdpcLossRatePerUe(MacNodeId id);
164 virtual void resetPdpcLossRates();
165 virtual void resetPdpcLossRatePerUe(MacNodeId id);
166
167 virtual double getDiscardedPktPerUe(MacNodeId id);
168 virtual double getDiscardedPkt();
169 virtual void resetDiscardCounterPerUe(MacNodeId id);
170
171 virtual double getDelayStatsPerUe(MacNodeId id);
172 virtual void resetDelayCounterPerUe(MacNodeId id);
173
174 virtual double getUlDelayStatsPerUe(MacNodeId id);
175 virtual void resetUlDelayCounterPerUe(MacNodeId id);
176
177 virtual double getThroughputStatsPerUe(MacNodeId id);
178 virtual void resetThroughputCounterPerUe(MacNodeId id);
179};
180
181} //namespace
182
183#endif
184
Definition LteTypes.h:191
Definition PacketFlowObserverBase.h:53
Definition PacketFlowObserverEnb.h:32
void discardMacPdu(MacNodeId peerId, const LteMacPdu *macPdu) override
void ulMacPduArrived(MacNodeId nodeId, unsigned int grantId) override
void receivedPdcpSdu(inet::Packet *pdcpPkt) override
virtual void deleteUe(MacNodeId id)
void grantSent(MacNodeId nodeId, unsigned int grantId) override
void discardRlcPdu(DrbKey drbKey, unsigned int rlcSno, bool fromMac=false) override
void insertRlcPdu(DrbKey drbKey, const LteRlcUmDataPdu *rlcPdu, RlcBurstStatus status) override
void insertPdcpSdu(inet::Packet *pdcpPkt) override
void macPduArrived(MacNodeId peerId, const LteMacPdu *macPdu) override
Definition AlertReceiver.h:24