RlcRetransmissionBuffer.h Source File

Simu5G: RlcRetransmissionBuffer.h Source File
Simu5G
RlcRetransmissionBuffer.h
1//
2// Simu5G
3//
4// Authors: Esteban Egea Lopez (Universidad Politecnica de Cartagena)
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 STACK_RLC_AM_BUFFER_RLCRETRANSMISSIONBUFFER_H_
13#define STACK_RLC_AM_BUFFER_RLCRETRANSMISSIONBUFFER_H_
14
15#include <omnetpp.h>
16
17#include <map>
18#include <set>
19
20namespace simu5g {
21
27struct RetxTask {
28 uint32_t sn;
29 uint32_t soStart;
30 uint32_t soEnd;
31 bool isWholeUnit;
32
33 bool operator<(const RetxTask &other) const {
34 if (sn != other.sn) return sn < other.sn;
35 if (soStart != other.soStart) return soStart < other.soStart;
36 return soEnd < other.soEnd;
37 }
38};
39
40class RlcRetransmissionBuffer
41{
42 public:
43 RlcRetransmissionBuffer(uint32_t threshold);
44 virtual ~RlcRetransmissionBuffer();
45
56 virtual void beginRetxRound() {
57 for (auto &[sn, state] : retxCounters_)
58 state.incrementedInCurrentRound = false;
59 }
60
67 virtual bool addNack(uint32_t sn, bool isWhole, uint32_t start, uint32_t end);
68
70 virtual bool getNextRetxTask(RetxTask &outTask) {
71 if (pendingRetx_.empty())
72 return false;
73 outTask = *pendingRetx_.begin();
74 return true;
75 }
76
78 virtual uint64_t getRetxPendingBytes();
79
81 const std::set<RetxTask>& getPendingRetx() const { return pendingRetx_; }
82
84 void markRetransmitted(const RetxTask &task) { pendingRetx_.erase(task); }
85
87 virtual void clearSn(uint32_t sn);
88
89 protected:
90 struct RetxState {
91 uint32_t retxCount = 0;
92 bool incrementedInCurrentRound = false;
93 };
94
95 std::map<uint32_t, RetxState> retxCounters_;
96 std::set<RetxTask> pendingRetx_;
97 uint32_t maxRetxThreshold_;
98};
99
100} // namespace simu5g
101
102#endif // STACK_RLC_AM_BUFFER_RLCRETRANSMISSIONBUFFER_H_
Definition AlertReceiver.h:24
Represents a specific segment or a whole data unit pending for retransmission. The unit the sequence ...
Definition RlcRetransmissionBuffer.h:27