22 #include "ns3/simulator.h" 25 #include "ns3/lte-rlc-am-header.h" 26 #include "ns3/lte-rlc-am.h" 27 #include "ns3/lte-rlc-sdu-status-tag.h" 28 #include "ns3/lte-rlc-tag.h" 94 .AddAttribute (
"PollRetransmitTimer",
95 "Value of the t-PollRetransmit timer (See section 7.3 of 3GPP TS 36.322)",
99 .AddAttribute (
"ReorderingTimer",
100 "Value of the t-Reordering timer (See section 7.3 of 3GPP TS 36.322)",
104 .AddAttribute (
"StatusProhibitTimer",
105 "Value of the t-StatusProhibit timer (See section 7.3 of 3GPP TS 36.322)",
109 .AddAttribute (
"ReportBufferStatusTimer",
110 "How much to wait to issue a new Report Buffer Status since the last time " 111 "a new SDU was received",
115 .AddAttribute (
"TxOpportunityForRetxAlwaysBigEnough",
116 "If true, always pretend that the size of a TxOpportunity is big enough " 117 "for retransmission. If false (default and realistic behavior), no retx " 118 "is performed unless the corresponding TxOpportunity is big enough.",
188 if (txOpParams.
bytes < 4)
193 NS_ASSERT_MSG (
false,
"TxOpportunity (size = " << txOpParams.
bytes <<
") too small.\n" 194 <<
"Your MAC scheduler is assigned too few resource blocks.");
205 <<
"Your MAC scheduler is assigned too few resource blocks.");
218 std::map<uint16_t, PduBuffer>::iterator pduIt;
222 if (!rlcAmHeader.OneMoreNackWouldFitIn (txOpParams.
bytes))
228 if (pduIt ==
m_rxonBuffer.end () || (!(pduIt->second.m_pduComplete)))
231 rlcAmHeader.PushNack (sn.GetValue ());
239 while ((sn <
m_vrMs) && (pduIt !=
m_rxonBuffer.end ()) && (pduIt->second.m_pduComplete))
248 rlcAmHeader.SetAckSn (sn);
264 params.layer = txOpParams.
layer;
265 params.harqProcessId = txOpParams.
harqId;
279 NS_LOG_LOGIC (
"Sending data from Retransmission Buffer");
285 uint16_t seqNumberValue = sn.
GetValue ();
305 <<
" packet->GetSize ()=" << packet->
GetSize ());
351 params.layer = txOpParams.
layer;
352 params.harqProcessId = txOpParams.
harqId;
359 NS_LOG_INFO (
"Incr RETX_COUNT for SN = " << seqNumberValue);
362 NS_LOG_INFO (
"Max RETX_COUNT for SN = " << seqNumberValue);
365 NS_LOG_INFO (
"Move SN = " << seqNumberValue <<
" back to txedBuffer");
382 NS_LOG_LOGIC (
"TxOpportunity (size = " << txOpParams.
bytes <<
") too small for retransmission of the packet (size = " << packet->
GetSize () <<
")");
388 NS_ASSERT_MSG (
false,
"m_retxBufferSize > 0, but no PDU considered for retx found");
392 if (txOpParams.
bytes < 7)
395 NS_LOG_LOGIC (
"TxOpportunity (size = " << txOpParams.
bytes <<
") too small for DATA PDU");
396 NS_ASSERT_MSG (
false,
"TxOpportunity (size = " << txOpParams.
bytes <<
") too small for DATA PDU\n" 397 <<
"Your MAC scheduler is assigned too few resource blocks.");
404 NS_LOG_INFO (
"cannot transmit new RLC PDU due to window stalling");
427 uint32_t nextSegmentSize = txOpParams.
bytes - 4;
428 uint32_t nextSegmentId = 1;
429 uint32_t dataFieldTotalSize = 0;
430 uint32_t dataFieldAddedSize = 0;
431 std::vector < Ptr<Packet> > dataField;
444 NS_LOG_LOGIC (
"Next segment size = " << nextSegmentSize);
452 while ( firstSegment && (firstSegment->
GetSize () > 0) && (nextSegmentSize > 0) )
454 NS_LOG_LOGIC (
"WHILE ( firstSegment && firstSegment->GetSize > 0 && nextSegmentSize > 0 )");
456 NS_LOG_LOGIC (
" nextSegmentSize = " << nextSegmentSize);
457 if ( (firstSegment->
GetSize () > nextSegmentSize) ||
459 (firstSegment->
GetSize () > 2047)
464 uint32_t currSegmentSize =
std::min (firstSegment->
GetSize (), nextSegmentSize);
466 NS_LOG_LOGIC (
" IF ( firstSegment > nextSegmentSize ||");
494 if (firstSegment->
GetSize () > 0)
501 NS_LOG_LOGIC (
" Txon buffer: Give back the remaining segment");
526 dataFieldAddedSize = newSegment->
GetSize ();
527 dataFieldTotalSize += dataFieldAddedSize;
528 dataField.push_back (newSegment);
536 nextSegmentSize -= dataFieldAddedSize;
544 else if ( (nextSegmentSize - firstSegment->
GetSize () <= 2) || (
m_txonBuffer.size () == 0) )
546 NS_LOG_LOGIC (
" IF nextSegmentSize - firstSegment->GetSize () <= 2 || txonBuffer.size == 0");
549 dataFieldAddedSize = firstSegment->
GetSize ();
550 dataFieldTotalSize += dataFieldAddedSize;
551 dataField.push_back (firstSegment);
559 nextSegmentSize -= dataFieldAddedSize;
568 NS_LOG_LOGIC (
" Next segment size = " << nextSegmentSize);
577 NS_LOG_LOGIC (
" IF firstSegment < NextSegmentSize && txonBuffer.size > 0");
579 dataFieldAddedSize = firstSegment->
GetSize ();
580 dataFieldTotalSize += dataFieldAddedSize;
581 dataField.push_back (firstSegment);
587 rlcAmHeader.PushLengthIndicator (firstSegment->
GetSize ());
589 nextSegmentSize -= ((nextSegmentId % 2) ? (2) : (1)) + dataFieldAddedSize;
598 NS_LOG_LOGIC (
" Next segment size = " << nextSegmentSize);
603 firstSegmentTime =
m_txonBuffer.begin ()->m_waitingSince;
615 rlcAmHeader.SetSequenceNumber (
m_vtS++ );
618 rlcAmHeader.SetSegmentOffset (0);
624 uint8_t framingInfo = 0;
625 std::vector< Ptr<Packet> >::iterator it;
626 it = dataField.begin ();
630 NS_ASSERT_MSG ((*it)->PeekPacketTag (tag),
"LteRlcSduStatusTag is missing");
631 (*it)->PeekPacketTag (tag);
644 while (it < dataField.end ())
646 NS_LOG_LOGIC (
"Adding SDU/segment to packet, length = " << (*it)->GetSize ());
648 NS_ASSERT_MSG ((*it)->PeekPacketTag (tag),
"LteRlcSduStatusTag is missing");
649 (*it)->RemovePacketTag (tag);
674 rlcAmHeader.SetFramingInfo (framingInfo);
729 m_txedBuffer.at ( rlcAmHeader.GetSequenceNumber ().GetValue () ).m_pdu = packet->
Copy ();
730 m_txedBuffer.at ( rlcAmHeader.GetSequenceNumber ().GetValue () ).m_retxCount = 0;
740 params.layer = txOpParams.
layer;
741 params.harqProcessId = txOpParams.
harqId;
769 NS_ASSERT_MSG(ret,
"RlcTag not found in RLC Header. The packet went into a real network?");
775 if ( rlcAmHeader.IsDataPdu () )
833 NS_LOG_LOGIC (
"PDU segment received ( SN = " << seqNumber <<
" )");
837 NS_LOG_LOGIC (
"PDU received ( SN = " << seqNumber <<
" )");
841 NS_ASSERT_MSG (
false,
"Neither a PDU segment nor a PDU received");
891 NS_ASSERT (it->second.m_byteSegments.size () > 0);
892 NS_ASSERT_MSG (it->second.m_byteSegments.size () == 1,
"re-segmentation not supported");
893 NS_LOG_LOGIC (
"PDU segment already received, discarded");
897 NS_LOG_LOGIC (
"Place PDU in the reception buffer ( SN = " << seqNumber <<
" )");
912 if ( seqNumber >=
m_vrH )
914 m_vrH = seqNumber + 1;
924 it->second.m_pduComplete )
928 it->second.m_pduComplete )
945 if ( seqNumber ==
m_vrR )
949 it->second.m_pduComplete )
954 it->second.m_pduComplete )
958 "Too many segments. PDU Reassembly process didn't work");
1015 else if ( rlcAmHeader.IsControlPdu () )
1034 bool incrementVtA =
true;
1036 for (sn =
m_vtA; sn < ackSn && sn <
m_vtS; sn++)
1040 uint16_t seqNumberValue = sn.
GetValue ();
1048 if (rlcAmHeader.IsNackPresent (sn))
1052 incrementVtA =
false;
1056 NS_LOG_INFO (
"Move SN = " << seqNumberValue <<
" to retxBuffer");
1077 NS_LOG_INFO (
"ACKed SN = " << seqNumberValue <<
" from txedBuffer");
1087 NS_LOG_INFO (
"ACKed SN = " << seqNumberValue <<
" from retxBuffer");
1130 m_vrR <<
" <= " << seqNumber <<
" <= " <<
m_vrMr);
1136 if ( (
m_vrR <= seqNumber) && (seqNumber <
m_vrMr ) )
1138 NS_LOG_LOGIC (seqNumber <<
" is INSIDE the receiving window");
1143 NS_LOG_LOGIC (seqNumber <<
" is OUTSIDE the receiving window");
1161 bool expectedSnLost;
1165 expectedSnLost =
true;
1171 expectedSnLost =
false;
1177 uint8_t extensionBit;
1178 uint16_t lengthIndicator;
1184 if ( extensionBit == 0 )
1194 if ( lengthIndicator >= packet->
GetSize () )
1196 NS_LOG_LOGIC (
"INTERNAL ERROR: Not enough data in the packet (" << packet->
GetSize () <<
"). Needed LI=" << lengthIndicator);
1207 while ( extensionBit == 1 );
1209 std::list < Ptr<Packet> >::iterator it;
1214 else NS_LOG_LOGIC (
"Reassembling State = Unknown state");
1218 NS_LOG_LOGIC (
"Framing Info = " << (uint16_t)framingInfo);
1222 if (!expectedSnLost)
1227 switch (framingInfo)
1267 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
1273 switch (framingInfo)
1338 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
1353 switch (framingInfo)
1443 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
1449 switch (framingInfo)
1560 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
1587 Time txonQueueHolDelay (0);
1590 txonQueueHolDelay = now -
m_txonBuffer.front ().m_waitingSince;
1594 Time retxQueueHolDelay;
1597 Time senderTimestamp;
1606 retxQueueHolDelay = now - senderTimestamp;
1610 retxQueueHolDelay =
Seconds (0);
1662 it->second.m_pduComplete )
1708 bool pduAvailable =
m_txedBuffer.at (sn.GetValue ()).m_pdu != 0;
1712 uint16_t snValue = sn.GetValue ();
1713 NS_LOG_INFO (
"Move PDU " << sn <<
" from txedBuffer to retxBuffer");
bool FindFirstMatchingByteTag(Tag &tag) const
Finds the first tag matching the parameter Tag type.
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.
virtual uint32_t GetSerializedSize() const
Simulation virtual time values and global simulation resolution.
EventId m_statusProhibitTimer
status prohibit timer
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
Parameters for LteMacSapUser::NotifyTxOpportunity.
uint32_t m_byteWithoutPoll
byte without poll
uint16_t GetValue() const
Extracts the numeric value of the sequence number.
AttributeValue implementation for Boolean.
virtual void DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParams)
MAC SAP.
EventId m_rbsTimer
RBS timer.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
uint32_t m_statusPduBufferSize
status PDU buffer size
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
SequenceNumber10 m_vtS
VT(S)
void DoReportBufferStatus()
Report buffer status.
Tag to calculate the per-PDU delay from eNb RLC to UE RLC.
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
SequenceNumber10 m_vtMs
VT(MS)
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Time m_reorderingTimerValue
reordering timer value
SequenceNumber10 m_vrMs
VR(MS)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time m_pollRetransmitTimerValue
poll retransmit time value
SequenceNumber10 m_vrR
VR(R)
EventId m_reorderingTimer
reordering timer
Time m_rbsTimerValue
RBS timer value.
uint32_t retxQueueSize
the current size of the RLC retransmission queue in bytes
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
bool IsInsideReceivingWindow(SequenceNumber10 seqNumber)
method called when the T_status_prohibit timer expires
std::vector< RetxPdu > m_txedBuffer
Buffer for transmitted and retransmitted PDUs that have not been acked but are not considered for ret...
uint16_t rnti
the C-RNTI identifying the UE
uint8_t harqId
the HARQ ID
EventId m_pollRetransmitTimer
Timers.
void SetModulusBase(SequenceNumber10 modulusBase)
Set modulus base.
void ExpireRbsTimer(void)
Expire RBS timer.
Parameters for LteMacSapProvider::ReportBufferStatus.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
void SetSenderTimestamp(Time senderTimestamp)
Set the sender timestamp.
uint32_t m_txonBufferSize
transmit on buffer size
uint16_t txQueueHolDelay
the Head Of Line delay of the transmission queue
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
SequenceNumber10 m_expectedSeqNumber
Expected Sequence Number.
uint8_t GetStatus(void) const
Get status function.
LteRlcSapUser * m_rlcSapUser
RLC SAP user.
void RemoveAtStart(uint32_t size)
Remove size bytes from the start of the current packet.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
std::map< uint16_t, PduBuffer > m_rxonBuffer
Reception buffer.
AttributeValue implementation for Time.
uint16_t m_pollPdu
poll PDU
uint8_t componentCarrierId
the component carrier id
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...
Ptr< Packet > m_keepS0
keep S0
virtual void DoDispose()
Destructor implementation.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
SequenceNumber10 m_pollSn
POLL_SN.
LteMacSapProvider * m_macSapProvider
MAC SAP provider.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::list< Ptr< Packet > > m_sdusBuffer
List of SDUs in a packet (PDU)
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
uint16_t m_pollByte
poll byte
SequenceNumber10 m_vrH
VR(H)
Ptr< const AttributeChecker > MakeBooleanChecker(void)
bool m_pollRetransmitTimerJustExpired
poll retransmit timer just expired?
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
SequenceNumber10 m_vrMr
VR(MR)
Time GetSenderTimestamp(void) const
Get the instant when the RLC delivers the PDU to the MAC SAP provider.
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
SequenceNumber10 m_vrX
VR(X)
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 virtual time.
uint32_t m_txedBufferSize
transmit ed buffer size
Time m_statusProhibitTimerValue
status prohibit timer value
NS_LOG_LOGIC("Net device "<< nd<< " is not bridged")
virtual void DoNotifyHarqDeliveryFailure()
Notify HARQ delivery failure
uint16_t m_maxRetxThreshold
Configurable parameters.
uint32_t bytes
the number of bytes to transmit
uint16_t statusPduSize
the current size of the pending STATUS RLC PDU message in bytes
uint8_t layer
the layer of transmission (MIMO)
void AddPacketTag(const Tag &tag) const
Add a packet tag.
This class implements a tag that carries the status of a RLC SDU for the fragmentation process Status...
virtual void DoDispose()
Destructor implementation.
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
void ExpireStatusProhibitTimer(void)
method called when the T_status_prohibit timer expires
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
void ExpirePollRetransmitTimer(void)
Expire poll retransmitter.
SequenceNumber10 m_vtA
State variables.
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
Time Seconds(double value)
Construct a Time in the indicated unit.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
std::vector< RetxPdu > m_retxBuffer
Buffer for PDUs considered for retransmission.
void SetStatus(uint8_t status)
Set status function.
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.
Parameters for LteMacSapUser::ReceivePdu.
TracedCallback< uint16_t, uint8_t, uint32_t, uint64_t > m_rxPdu
Used to inform of a PDU reception from the MAC SAP user.
LTE RLC Acknowledged Mode (AM), see 3GPP TS 36.322.
Ptr< Packet > m_controlPduBuffer
Control PDU buffer (just one PDU)
void ReassembleAndDeliver(Ptr< Packet > packet)
Reassemble and deliver.
Store an incoming (from layer above us) PDU, waiting to transmit it.
uint16_t m_windowSize
Constants.
bool m_txOpportunityForRetxAlwaysBigEnough
transmit opportunity for retransmit?
virtual void TransmitPdu(TransmitPduParameters params)=0
send an RLC PDU to the MAC for transmission.
ReassemblingState_t m_reassemblingState
reassembling state
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
retransmit buffer size
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.
static TypeId GetTypeId(void)
Get the type ID.
std::vector< TxPdu > m_txonBuffer
Transmission buffer.
bool m_statusPduRequested
status PDU requested
void ExpireReorderingTimer(void)
This method will schedule a timeout at WaitReplyTimeout interval in the future, unless a timer is alr...
virtual void DoTransmitPdcpPdu(Ptr< Packet > p)
RLC SAP.
void AddHeader(const Header &header)
Add header to this packet.
virtual void DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams)
Receive PDU function.
Ptr< Packet > p
the RLC PDU to be received
Parameters for LteMacSapProvider::TransmitPdu.