LteRlcAmTxEntity.h Source File

Simu5G: LteRlcAmTxEntity.h Source File
Simu5G
LteRlcAmTxEntity.h
1//
2// Simu5G
3//
4// Authors: Esteban Egea Lopez (Universidad Politécnica de Cartagena), 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 _SIMU5G_LTERLCAMTXENTITY_H_
13#define _SIMU5G_LTERLCAMTXENTITY_H_
14
15#include <list>
16#include <map>
17
18#include <inet/common/packet/Packet.h>
19
20#include "simu5g/common/LteCommon.h"
21#include "simu5g/stack/rlc/am/RlcAmTxEntityBase.h"
22#include "simu5g/stack/rlc/am/RlcRetransmissionBuffer.h"
23
24namespace simu5g {
25
26using namespace omnetpp;
27using namespace inet;
28
44{
45 // configuration
46 unsigned int amWindowSize_ = 512; // TS 36.322: 512 (10-bit SN space)
47 unsigned int pollPdu_ = 0;
48 unsigned int pollByte_ = 0;
49 simtime_t tPollRetransmit_;
50
51 // SDUs not yet (fully) put into a PDU; frontOffset_ bytes of the front SDU
52 // are already carried by previously built PDUs (TS 36.322 concatenation).
53 std::list<inet::Packet *> sduQueue_;
54 unsigned int frontOffset_ = 0;
55 unsigned int sduQueueBytes_ = 0; // pending payload bytes, incl. the partial front SDU
56
57 // Built AMD PDUs retained until acknowledged: the ARQ unit. VT(A) =
58 // txNextAck_, VT(S) = txNext_ (TS 36.322 5.1.3.1). An entry is erased when
59 // its SN is acknowledged, so map presence == not yet acknowledged.
60 struct TxPdu {
61 inet::Packet *pdu = nullptr; // the built LteRlcAmDataPdu packet
62 uint32_t payloadLength = 0; // data-field length in bytes
63
64 friend std::ostream& operator<<(std::ostream& os, const TxPdu& e) {
65 os << "pdu=" << (e.pdu ? e.pdu->getName() : "null") << " len=" << e.payloadLength;
66 return os;
67 }
68 };
69 std::map<uint32_t, TxPdu> txWindow_;
70 uint32_t txNext_ = 0;
71 uint32_t txNextAck_ = 0;
72
73 RlcRetransmissionBuffer *rtxBuffer_ = nullptr;
74 std::list<omnetpp::cPacket *> controlBuffer_;
75
76 // polling state (TS 36.322 5.2.2)
77 unsigned int pduWithoutPoll_ = 0;
78 unsigned int byteWithoutPoll_ = 0;
79 uint32_t pollSn_ = 0;
80 bool pollPending_ = false;
81 omnetpp::cMessage *tPollRetransmitTimer_ = nullptr;
82
83 // enqueued-SDU rate sampling (statistics)
84 simtime_t lastSduSample_;
85 unsigned int sduSampleBytes_ = 0;
86
87 public:
88 ~LteRlcAmTxEntity() override;
89
90 void enque(inet::Packet *sdu) override;
91 void sendPdus(int size) override;
92 void bufferControlPdu(cPacket *pkt) override;
93 void handleControlPacket(cPacket *pkt) override;
94 unsigned int getPendingDataVolume() const override;
95
96 protected:
97 void initialize(int stage) override;
98 void handleMessage(cMessage *msg) override;
99
100 private:
101 virtual void processControlPacket(inet::Packet *pkt);
102 virtual void bufferControlPduInternal(inet::Packet *pkt);
103 virtual bool sendRetransmission(int pduSize);
104 virtual void buildAndSendPdu(int pduSize);
105 virtual bool checkPolling(uint32_t sn);
106 virtual void sendEmptyPdu();
107 virtual void sendPduToMac(inet::Packet *pkt);
108 virtual void sendNewDataNotification(inet::Packet *pkt);
109 virtual void reportBufferStatus();
110
111 bool windowFull() const { return txNext_ - txNextAck_ >= amWindowSize_; }
112};
113
114} //namespace
115
116#endif
LTE (TS 36.322) RLC AM transmission entity.
Definition LteRlcAmTxEntity.h:44
Common shell of the RLC AM transmission entity.
Definition RlcAmTxEntityBase.h:41
Definition AlertReceiver.h:24