21 #include "ns3/simulator.h"
24 #include "ns3/lte-rlc-am-header.h"
25 #include "ns3/lte-rlc-am.h"
26 #include "ns3/lte-rlc-sdu-status-tag.h"
27 #include "ns3/lte-rlc-tag.h"
91 .AddConstructor<LteRlcAm> ()
92 .AddAttribute (
"PollRetransmitTimer",
93 "Value of the t-PollRetransmit (See section 7.3 of 3GPP TS 36.322)",
97 .AddAttribute (
"TxOpportunityForRetxAlwaysBigEnough",
98 "If true, always pretend that the size of a TxOpportunity is big enough "
99 "for retransmission. If false (default and realistic behavior), no retx "
100 "is performed unless the corresponding TxOpportunity is big enough.",
103 MakeBooleanChecker ())
176 NS_LOG_LOGIC (
"TxOpportunity (size = " << bytes <<
") too small");
177 NS_ASSERT_MSG (
false,
"TxOpportunity (size = " << bytes <<
") too small.\n"
178 <<
"Your MAC scheduler is assigned too few resource blocks.");
189 <<
"Your MAC scheduler is assigned too few resource blocks.");
198 rlcAmHeader.SetAckSn (
m_vrR);
208 params.
layer = layer;
219 NS_LOG_LOGIC (
"Sending data from Retransmission Buffer");
223 if (( packet->
GetSize () <= bytes )
235 params.
layer = layer;
243 NS_LOG_LOGIC (
"TxOpportunity (size = " << bytes <<
") too small for retransmission of the packet (size = " << packet->
GetSize () <<
")");
253 NS_LOG_LOGIC (
"TxOpportunity (size = " << bytes <<
") too small for DATA PDU");
254 NS_ASSERT_MSG (
false,
"TxOpportunity (size = " << bytes <<
") too small for DATA PDU\n"
255 <<
"Your MAC scheduler is assigned too few resource blocks.");
271 if (( packet->
GetSize () <= bytes )
274 NS_LOG_INFO (
"Move SN = " << vta <<
" to retxBuffer");
291 params.
layer = layer;
299 NS_LOG_LOGIC (
"TxOpportunity (size = " << bytes <<
") too small for retransmission of the packet (size = " << packet->
GetSize () <<
")");
321 uint32_t nextSegmentSize = bytes - 4;
322 uint32_t nextSegmentId = 1;
323 uint32_t dataFieldTotalSize = 0;
324 uint32_t dataFieldAddedSize = 0;
325 std::vector < Ptr<Packet> > dataField;
338 NS_LOG_LOGIC (
"Next segment size = " << nextSegmentSize);
345 while ( firstSegment && (firstSegment->
GetSize () > 0) && (nextSegmentSize > 0) )
347 NS_LOG_LOGIC (
"WHILE ( firstSegment && firstSegment->GetSize > 0 && nextSegmentSize > 0 )");
349 NS_LOG_LOGIC (
" nextSegmentSize = " << nextSegmentSize);
350 if ( (firstSegment->
GetSize () > nextSegmentSize) ||
352 (firstSegment->
GetSize () > 2047)
357 uint32_t currSegmentSize = std::min (firstSegment->
GetSize (), nextSegmentSize);
359 NS_LOG_LOGIC (
" IF ( firstSegment > nextSegmentSize ||");
387 if (firstSegment->
GetSize () > 0)
394 NS_LOG_LOGIC (
" Txon buffer: Give back the remaining segment");
419 dataFieldAddedSize = newSegment->
GetSize ();
420 dataFieldTotalSize += dataFieldAddedSize;
421 dataField.push_back (newSegment);
429 nextSegmentSize -= dataFieldAddedSize;
437 else if ( (nextSegmentSize - firstSegment->
GetSize () <= 2) || (
m_txonBuffer.size () == 0) )
439 NS_LOG_LOGIC (
" IF nextSegmentSize - firstSegment->GetSize () <= 2 || txonBuffer.size == 0");
442 dataFieldAddedSize = firstSegment->
GetSize ();
443 dataFieldTotalSize += dataFieldAddedSize;
444 dataField.push_back (firstSegment);
452 nextSegmentSize -= dataFieldAddedSize;
461 NS_LOG_LOGIC (
" Next segment size = " << nextSegmentSize);
470 NS_LOG_LOGIC (
" IF firstSegment < NextSegmentSize && txonBuffer.size > 0");
472 dataFieldAddedSize = firstSegment->
GetSize ();
473 dataFieldTotalSize += dataFieldAddedSize;
474 dataField.push_back (firstSegment);
480 rlcAmHeader.PushLengthIndicator (firstSegment->
GetSize ());
482 nextSegmentSize -= ((nextSegmentId % 2) ? (2) : (1)) + dataFieldAddedSize;
491 NS_LOG_LOGIC (
" Next segment size = " << nextSegmentSize);
507 rlcAmHeader.SetSequenceNumber (
m_vtS++ );
510 rlcAmHeader.SetSegmentOffset (0);
513 uint8_t framingInfo = 0;
514 std::vector< Ptr<Packet> >::iterator it;
515 it = dataField.begin ();
519 (*it)->RemovePacketTag (tag);
530 (*it)->AddPacketTag (tag);
533 while (it < dataField.end ())
535 NS_LOG_LOGIC (
"Adding SDU/segment to packet, length = " << (*it)->GetSize ());
543 (*it)->RemovePacketTag (tag);
553 (*it)->AddPacketTag (tag);
556 rlcAmHeader.SetFramingInfo (framingInfo);
604 m_txedBuffer.at ( rlcAmHeader.GetSequenceNumber ().GetValue () ) = packet->
Copy ();
616 params.layer = layer;
617 params.harqProcessId = harqId;
647 if ( rlcAmHeader.IsDataPdu () )
704 NS_LOG_LOGIC (
"PDU segment received ( SN = " << seqNumber <<
" )");
708 NS_LOG_LOGIC (
"PDU received ( SN = " << seqNumber <<
" )");
712 NS_ASSERT_MSG (
false,
"Neither a PDU segment nor a PDU received");
755 NS_LOG_LOGIC (
"Place PDU in the reception buffer ( SN = " << seqNumber <<
" )");
770 if ( seqNumber >=
m_vrH )
772 m_vrH = seqNumber + 1;
803 if ( seqNumber ==
m_vrR )
816 "Too many segments. PDU Reassembly process didn't work");
966 else if ( rlcAmHeader.IsControlPdu () )
994 NS_LOG_INFO (
"ACKed SN = " << seqNumberValue <<
" from txedBuffer");
1002 NS_LOG_INFO (
"ACKed SN = " << seqNumberValue <<
" from retxBuffer");
1017 uint16_t seqNumberValue;
1018 while (seqNumber <
m_vtS)
1020 seqNumberValue = seqNumber.
GetValue ();
1023 NS_LOG_INFO (
"Move SN = " << seqNumberValue <<
" to retxBuffer");
1034 NS_LOG_INFO (
"Incr RETX_COUNT for SN = " << seqNumberValue);
1037 NS_LOG_INFO (
"Max RETX_COUNT for SN = " << seqNumberValue);
1060 m_vrR <<
" <= " << seqNumber <<
" <= " <<
m_vrMr);
1066 if ( (
m_vrR <= seqNumber) && (seqNumber <
m_vrMr ) )
1068 NS_LOG_LOGIC (seqNumber <<
" is INSIDE the receiving window");
1073 NS_LOG_LOGIC (seqNumber <<
" is OUTSIDE the receiving window");
1086 bool expectedSnLost;
1090 expectedSnLost =
true;
1096 expectedSnLost =
false;
1102 uint8_t extensionBit;
1103 uint16_t lengthIndicator;
1109 if ( extensionBit == 0 )
1119 if ( lengthIndicator >= packet->
GetSize () )
1121 NS_LOG_LOGIC (
"INTERNAL ERROR: Not enough data in the packet (" << packet->
GetSize () <<
"). Needed LI=" << lengthIndicator);
1132 while ( extensionBit == 1 );
1134 std::list < Ptr<Packet> >::iterator it;
1139 else NS_LOG_LOGIC (
"Reassembling State = Unknown state");
1142 NS_LOG_LOGIC (
"Framing Info = " << (uint16_t)framingInfo);
1146 if (!expectedSnLost)
1151 switch (framingInfo)
1191 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
1197 switch (framingInfo)
1262 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
1277 switch (framingInfo)
1367 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
1373 switch (framingInfo)
1484 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
1564 Time txonQueueHolDelay (0);
1567 RlcTag txonQueueHolTimeTag;
1568 m_txonBuffer.front ()->PeekPacketTag (txonQueueHolTimeTag);
1573 Time retxQueueHolDelay (0);
1574 RlcTag retxQueueHolTimeTag;
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
TracedCallback< uint16_t, uint8_t, uint32_t > m_txPdu
Used to inform of a PDU delivery to the MAC SAP provider.
bool FindFirstMatchingByteTag(Tag &tag) const
keep track of time values and allow control of global simulation resolution
EventId m_statusProhibitTimer
#define NS_LOG_FUNCTION(parameters)
uint32_t m_byteWithoutPoll
uint16_t GetValue() const
Extracts the numeric value of the sequence number.
virtual void DoReceivePdu(Ptr< Packet > p)
std::vector< RetxBuffer > m_retxBuffer
virtual void DoNotifyTxOpportunity(uint32_t bytes, uint8_t layer, uint8_t harqId)
MAC SAP.
uint32_t m_statusPduBufferSize
void DoReportBufferStatus()
void AddPacketTag(const Tag &tag) const
Add a packet tag.
Tag to calculate the per-PDU delay from eNb RLC to UE RLC.
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
Time m_pollRetransmitTimerValue
uint32_t GetSize(void) const
EventId m_reorderingTimer
uint32_t retxQueueSize
the current size of the RLC retransmission queue in bytes
bool IsRunning(void) const
This method is syntactic sugar for the ns3::Simulator::isExpired method.
bool IsInsideReceivingWindow(SequenceNumber10 seqNumber)
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
uint16_t rnti
the C-RNTI identifying the UE
EventId m_pollRetransmitTimer
Timers.
void SetModulusBase(SequenceNumber10 modulusBase)
Parameters for LteMacSapProvider::ReportBufferStatus.
uint32_t m_txonBufferSize
uint16_t txQueueHolDelay
the Head Of Line delay of the transmission queue
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
SequenceNumber10 m_expectedSeqNumber
Expected Sequence Number.
LteRlcSapUser * m_rlcSapUser
void RemoveAtStart(uint32_t size)
Remove size bytes from the start of the current packet.
std::map< uint16_t, PduBuffer > m_rxonBuffer
hold objects of type ns3::Time
uint16_t rnti
the C-RNTI identifying the UE
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...
uint8_t GetStatus(void) const
virtual void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
SequenceNumber10 m_pollSn
LteMacSapProvider * m_macSapProvider
#define NS_LOG_LOGIC(msg)
Ptr< Packet > Copy(void) const
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
uint8_t layer
the layer value that was passed by the MAC in the call to NotifyTxOpportunity that generated this PDU...
std::list< Ptr< Packet > > m_sdusBuffer
Time GetSenderTimestamp(void) const
Get the instant when the RLC delivers the PDU to the MAC SAP provider.
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
uint32_t m_pduWithoutPoll
Counters.
uint32_t txQueueSize
the current size of the RLC transmission queue
static Time Now(void)
Return the "current simulation time".
uint32_t m_txedBufferSize
virtual void DoNotifyHarqDeliveryFailure()
uint16_t m_maxRetxThreshold
Configurable parameters.
#define NS_ASSERT_MSG(condition, message)
int64_t GetNanoSeconds(void) const
uint16_t statusPduSize
the current size of the pending STATUS RLC PDU message in bytes
This class implements a tag that carries the status of a RLC SDU for the fragmentation process Status...
virtual void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
void ExpirePollRetransmitTimer(void)
SequenceNumber10 m_vtA
State variables.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
void SetStatus(uint8_t status)
uint16_t retxQueueHolDelay
the Head Of Line delay of the retransmission queue
Ptr< Packet > pdu
the RLC PDU
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::cancel method.
virtual void ReportBufferStatus(ReportBufferStatusParameters params)=0
Report the RLC buffer status to the MAC.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
std::vector< Ptr< Packet > > m_txonBuffer
TracedCallback< uint16_t, uint8_t, uint32_t, uint64_t > m_rxPdu
Used to inform of a PDU reception from the MAC SAP user.
Ptr< Packet > m_controlPduBuffer
void ReassembleAndDeliver(Ptr< Packet > packet)
uint16_t m_windowSize
Constants.
uint8_t harqProcessId
the HARQ process id that was passed by the MAC in the call to NotifyTxOpportunity that generated this...
bool m_txOpportunityForRetxAlwaysBigEnough
virtual void TransmitPdu(TransmitPduParameters params)=0
send an RLC PDU to the MAC for transmission.
ReassemblingState_t m_reassemblingState
This abstract base class defines the API to interact with the Radio Link Control (LTE_RLC) in LTE...
a unique identifier for an interface.
uint32_t m_retxBufferSize
int64_t GetMilliSeconds(void) const
TypeId SetParent(TypeId tid)
static TypeId GetTypeId(void)
bool m_statusPduRequested
void ExpireReorderingTimer(void)
This method will schedule a timeout at WaitReplyTimeout interval in the future, unless a timer is alr...
std::vector< Ptr< Packet > > m_txedBuffer
virtual void DoTransmitPdcpPdu(Ptr< Packet > p)
RLC SAP.
void AddHeader(const Header &header)
Add header to this packet.
NS_LOG_COMPONENT_DEFINE("LteRlcAm")
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.
Parameters for LteMacSapProvider::TransmitPdu.