16#include "ns3/simulator.h" 
   26    : m_maxTxBufferSize(10 * 1024),
 
   33      m_expectedSeqNumber(0)
 
 
   52            .AddAttribute(
"MaxTxBufferSize",
 
   53                          "Maximum Size of the Transmission Buffer (in Bytes)",
 
   57            .AddAttribute(
"ReorderingTimer",
 
   58                          "Value of the t-Reordering timer (See section 7.3 of 3GPP TS 36.322)",
 
   63                "EnablePdcpDiscarding",
 
   64                "Whether to use the PDCP discarding, i.e., perform discarding at the moment " 
   65                "of passing the PDCP SDU to RLC)",
 
   69            .AddAttribute(
"DiscardTimerMs",
 
   70                          "Discard timer in milliseconds to be used to discard packets. " 
   71                          "If set to 0 then packet delay budget will be used as the discard " 
   72                          "timer value, otherwise it will be used this value.",
 
 
  108                headOfLineDelayInMs =
 
  111            NS_LOG_DEBUG(
"head of line delay in MS:" << headOfLineDelayInMs);
 
  112            if (headOfLineDelayInMs > discardTimerMs)
 
  114                NS_LOG_INFO(
"Tx HOL is higher than this packet can allow. RLC SDU discarded");
 
  115                NS_LOG_DEBUG(
"headOfLineDelayInMs    = " << headOfLineDelayInMs);
 
  125        p->AddPacketTag(tag);
 
  126        NS_LOG_INFO(
"Adding RLC SDU to Tx Buffer after adding LteRlcSduStatusTag: FULL_SDU");
 
  135        NS_LOG_INFO(
"Tx Buffer is full. RLC SDU discarded");
 
 
  155    NS_LOG_INFO(
"RLC layer is preparing data for the following Tx opportunity of " 
  160    if (txOpParams.
bytes <= 2)
 
  163        NS_LOG_INFO(
"TX opportunity too small - Only " << txOpParams.
bytes << 
" bytes");
 
  174    std::vector<Ptr<Packet>> dataField;
 
  189    NS_LOG_LOGIC(
"First SDU size    = " << firstSegment->GetSize());
 
  190    NS_LOG_LOGIC(
"Next segment size = " << nextSegmentSize);
 
  196    while (firstSegment && (firstSegment->GetSize() > 0) && (nextSegmentSize > 0))
 
  198        NS_LOG_LOGIC(
"WHILE ( firstSegment && firstSegment->GetSize > 0 && nextSegmentSize > 0 )");
 
  199        NS_LOG_LOGIC(
"    firstSegment size = " << firstSegment->GetSize());
 
  201        if ((firstSegment->GetSize() > nextSegmentSize) ||
 
  203            (firstSegment->GetSize() > 2047))
 
  207            uint32_t currSegmentSize = std::min(firstSegment->GetSize(), nextSegmentSize);
 
  209            NS_LOG_LOGIC(
"    IF ( firstSegment > nextSegmentSize ||");
 
  214            Ptr<Packet> newSegment = firstSegment->CreateFragment(0, currSegmentSize);
 
  215            NS_LOG_LOGIC(
"    newSegment size   = " << newSegment->GetSize());
 
  222            firstSegment->RemovePacketTag(oldTag);
 
  223            newSegment->RemovePacketTag(newTag);
 
  236            firstSegment->RemoveAtStart(currSegmentSize);
 
  238                "    firstSegment size (after RemoveAtStart) = " << firstSegment->GetSize());
 
  239            if (firstSegment->GetSize() > 0)
 
  241                firstSegment->AddPacketTag(oldTag);
 
  246                NS_LOG_LOGIC(
"    TX buffer: Give back the remaining segment");
 
  265            firstSegment = 
nullptr;
 
  268            newSegment->AddPacketTag(newTag);
 
  271            dataFieldAddedSize = newSegment->GetSize();
 
  272            dataField.push_back(newSegment);
 
  273            newSegment = 
nullptr;
 
  280            nextSegmentSize -= dataFieldAddedSize;
 
  288        else if ((nextSegmentSize - firstSegment->GetSize() <= 2) || 
m_txBuffer.empty())
 
  291                "    IF nextSegmentSize - firstSegment->GetSize () <= 2 || txBuffer.size == 0");
 
  293            dataFieldAddedSize = firstSegment->GetSize();
 
  294            dataField.push_back(firstSegment);
 
  295            firstSegment = 
nullptr;
 
  302            nextSegmentSize -= dataFieldAddedSize;
 
  310                    "        First SDU size    = " << 
m_txBuffer.begin()->m_pdu->GetSize());
 
  312            NS_LOG_LOGIC(
"        Next segment size = " << nextSegmentSize);
 
  321            NS_LOG_LOGIC(
"    IF firstSegment < NextSegmentSize && txBuffer.size > 0");
 
  323            dataFieldAddedSize = firstSegment->GetSize();
 
  324            dataField.push_back(firstSegment);
 
  332            nextSegmentSize -= ((nextSegmentId % 2) ? (2) : (1)) + dataFieldAddedSize;
 
  340                    "        First SDU size    = " << 
m_txBuffer.begin()->m_pdu->GetSize());
 
  342            NS_LOG_LOGIC(
"        Next segment size = " << nextSegmentSize);
 
  346            firstSegment = 
m_txBuffer.begin()->m_pdu->Copy();
 
  347            firstSegmentTime = 
m_txBuffer.begin()->m_waitingSince;
 
  358    auto it = dataField.begin();
 
  360    uint8_t framingInfo = 0;
 
  364    NS_ASSERT_MSG((*it)->PeekPacketTag(tag), 
"LteRlcSduStatusTag is missing");
 
  365    (*it)->PeekPacketTag(tag);
 
  376    while (it < dataField.end())
 
  378        NS_LOG_LOGIC(
"Adding SDU/segment to packet, length = " << (*it)->GetSize());
 
  380        NS_ASSERT_MSG((*it)->PeekPacketTag(tag), 
"LteRlcSduStatusTag is missing");
 
  381        (*it)->RemovePacketTag(tag);
 
  382        if (packet->GetSize() > 0)
 
  384            packet->AddAtEnd(*it);
 
  408    packet->AddHeader(rlcHeader);
 
  420    params.layer = txOpParams.
layer;
 
  421    params.harqProcessId = txOpParams.
harqId;
 
 
  500        rxPduParams.
p = 
nullptr;
 
  534            NS_LOG_LOGIC(
"VR(UR) is outside the reordering window");
 
  555        newVrUr = (it->first) + 1;
 
 
  620        NS_LOG_LOGIC(seqNumber << 
" is INSIDE the reordering window");
 
  625        NS_LOG_LOGIC(seqNumber << 
" is OUTSIDE the reordering window");
 
 
  634    packet->RemoveHeader(rlcHeader);
 
  641        expectedSnLost = 
true;
 
  643                                                        << 
". Current SN = " << currSeqNumber);
 
  648        expectedSnLost = 
false;
 
  650                                                 << 
". Current SN = " << currSeqNumber);
 
  655    uint8_t extensionBit;
 
  656    uint16_t lengthIndicator;
 
  662        if (extensionBit == 0)
 
  672            if (lengthIndicator >= packet->GetSize())
 
  674                NS_LOG_LOGIC(
"INTERNAL ERROR: Not enough data in the packet (" 
  675                             << packet->GetSize() << 
"). Needed LI=" << lengthIndicator);
 
  679            Ptr<Packet> data_field = packet->CreateFragment(0, lengthIndicator);
 
  680            packet->RemoveAtStart(lengthIndicator);
 
  684    } 
while (extensionBit == 1);
 
  701    NS_LOG_LOGIC(
"Framing Info = " << (uint16_t)framingInfo);
 
  800                    "INTERNAL ERROR: Transition not possible. FI = " << (
uint32_t)framingInfo);
 
  872                    "INTERNAL ERROR: Transition not possible. FI = " << (
uint32_t)framingInfo);
 
  980                    "INTERNAL ERROR: Transition not possible. FI = " << (
uint32_t)framingInfo);
 
 1098                    "INTERNAL ERROR: Transition not possible. FI = " << (
uint32_t)framingInfo);
 
 
 1132        NS_LOG_LOGIC(
"(SN = " << it->first << 
") is inside the reordering window");
 
 
 1139    NS_LOG_LOGIC(
"Reassemble SN between " << lowSeqNumber << 
" and " << highSeqNumber);
 
 1144    while (reassembleSn < highSeqNumber)
 
 
AttributeValue implementation for Boolean.
void Cancel()
This method is syntactic sugar for the ns3::Simulator::Cancel method.
bool IsPending() const
This method is syntactic sugar for !IsExpired().
virtual void TransmitPdu(TransmitPduParameters params)=0
send an RLC PDU to the MAC for transmission.
virtual void ReportBufferStatus(ReportBufferStatusParameters params)=0
Report the RLC buffer status to the MAC.
This abstract base class defines the API to interact with the Radio Link Control (LTE_RLC) in LTE,...
LteRlcSapUser * m_rlcSapUser
RLC SAP user.
TracedCallback< Ptr< const Packet > > m_txDropTrace
The trace source fired when the RLC drops a packet before transmission.
TracedCallback< uint16_t, uint8_t, uint32_t, uint64_t > m_rxPdu
Used to inform of a PDU reception from the MAC SAP user.
void DoDispose() override
Destructor implementation.
LteMacSapProvider * m_macSapProvider
MAC SAP provider.
uint16_t m_packetDelayBudgetMs
the packet delay budget in ms of the corresponding logical channel
TracedCallback< uint16_t, uint8_t, uint32_t > m_txPdu
Used to inform of a PDU delivery to the MAC SAP provider.
virtual void ReceivePdcpPdu(Ptr< Packet > p)=0
Called by the RLC entity to notify the PDCP entity of the reception of a new PDCP PDU.
This class implements a tag that carries the status of a RLC SDU for the fragmentation process Status...
uint8_t GetStatus() const
Get status function.
void SetStatus(uint8_t status)
Set status function.
LTE RLC Unacknowledged Mode (UM), see 3GPP TS 36.322.
SequenceNumber10 m_vrUr
VR(UR)
Ptr< Packet > m_keepS0
keep S0
void ReassembleAndDeliver(Ptr< Packet > packet)
Reassemble and deliver function.
void DoReportBufferStatus()
Report buffer status.
uint32_t m_txBufferSize
transmit buffer size
static TypeId GetTypeId()
Get the type ID.
void ReassembleOutsideWindow()
Reassemble outside window.
void DoDispose() override
Destructor implementation.
void ExpireReorderingTimer()
Expire reordering timer.
Time m_reorderingTimerValue
Timers.
SequenceNumber10 m_expectedSeqNumber
Expected Sequence Number.
ReassemblingState_t m_reassemblingState
reassembling state
void ReassembleSnInterval(SequenceNumber10 lowSeqNumber, SequenceNumber10 highSeqNumber)
Reassemble SN interval function.
void ExpireRbsTimer()
Expire RBS timer.
EventId m_rbsTimer
RBS timer.
void DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParams) override
MAC SAP.
SequenceNumber10 m_vrUx
VR(UX)
uint16_t m_windowSize
Constants.
std::map< uint16_t, Ptr< Packet > > m_rxBuffer
Reception buffer.
uint32_t m_discardTimerMs
the discard timer value in milliseconds
void DoNotifyHarqDeliveryFailure() override
Notify HARQ delivery failure.
SequenceNumber10 m_vrUh
VR(UH)
void DoTransmitPdcpPdu(Ptr< Packet > p) override
RLC SAP.
void DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams) override
Receive PDU function.
uint32_t m_maxTxBufferSize
maximum transmit buffer status
std::deque< TxPdu > m_txBuffer
Transmission buffer.
std::list< Ptr< Packet > > m_sdusBuffer
List of SDUs in a packet.
EventId m_reorderingTimer
reordering timer
bool IsInsideReorderingWindow(SequenceNumber10 seqNumber)
Is inside reordering window function.
SequenceNumber10 m_sequenceNumber
State variables.
bool m_enablePdcpDiscarding
whether to use the PDCP discarding (perform discarding at the moment of passing the PDCP SDU to RLC)
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
uint32_t GetSize() const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
bool FindFirstMatchingByteTag(Tag &tag) const
Finds the first tag matching the parameter Tag type.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
Smart pointer class similar to boost::intrusive_ptr.
Tag to calculate the per-PDU delay from eNb RLC to UE RLC.
Time GetSenderTimestamp() const
Get the instant when the RLC delivers the PDU to the MAC SAP provider.
uint16_t GetValue() const
Extracts the numeric value of the sequence number.
void SetModulusBase(SequenceNumber10 modulusBase)
Set modulus base.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now()
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
int64_t GetNanoSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
int64_t GetMilliSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
AttributeValue implementation for Time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Ptr< const AttributeChecker > MakeBooleanChecker()
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeTimeChecker()
Helper to make an unbounded Time checker.
Ptr< const AttributeChecker > MakeUintegerChecker()
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Parameters for LteMacSapProvider::ReportBufferStatus.
uint32_t txQueueSize
the current size of the RLC transmission queue
uint16_t retxQueueHolDelay
the Head Of Line delay of the retransmission queue
uint16_t txQueueHolDelay
the Head Of Line delay of the transmission queue
uint32_t retxQueueSize
the current size of the RLC retransmission queue in bytes
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
uint16_t rnti
the C-RNTI identifying the UE
uint16_t statusPduSize
the current size of the pending STATUS RLC PDU message in bytes
Parameters for LteMacSapProvider::TransmitPdu.
Parameters for LteMacSapUser::ReceivePdu.
Ptr< Packet > p
the RLC PDU to be received
Parameters for LteMacSapUser::NotifyTxOpportunity.
uint8_t harqId
the HARQ ID
uint32_t bytes
the number of bytes to transmit
uint8_t componentCarrierId
the component carrier id
uint8_t layer
the layer of transmission (MIMO)
Store an incoming (from layer above us) PDU, waiting to transmit it.