|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
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.",
122 .AddAttribute (
"MaxTxBufferSize",
123 "Maximum Size of the Transmission Buffer (in Bytes). If zero is configured, the buffer is unlimited.",
126 MakeUintegerChecker<uint32_t> ())
204 if (txOpParams.
bytes < 4)
209 NS_ASSERT_MSG (
false,
"TxOpportunity (size = " << txOpParams.
bytes <<
") too small.\n"
210 <<
"Your MAC scheduler is assigned too few resource blocks.");
221 <<
"Your MAC scheduler is assigned too few resource blocks.");
234 std::map<uint16_t, PduBuffer>::iterator pduIt;
244 if (pduIt ==
m_rxonBuffer.end () || (!(pduIt->second.m_pduComplete)))
255 while ((sn <
m_vrMs) && (pduIt !=
m_rxonBuffer.end ()) && (pduIt->second.m_pduComplete))
295 NS_LOG_LOGIC (
"Sending data from Retransmission Buffer");
301 uint16_t seqNumberValue = sn.
GetValue ();
321 <<
" packet->GetSize ()=" << packet->
GetSize ());
375 NS_LOG_INFO (
"Incr RETX_COUNT for SN = " << seqNumberValue);
378 NS_LOG_INFO (
"Max RETX_COUNT for SN = " << seqNumberValue);
381 NS_LOG_INFO (
"Move SN = " << seqNumberValue <<
" back to txedBuffer");
398 NS_LOG_LOGIC (
"TxOpportunity (size = " << txOpParams.
bytes <<
") too small for retransmission of the packet (size = " << packet->
GetSize () <<
")");
404 NS_ASSERT_MSG (
false,
"m_retxBufferSize > 0, but no PDU considered for retx found");
408 if (txOpParams.
bytes < 7)
411 NS_LOG_LOGIC (
"TxOpportunity (size = " << txOpParams.
bytes <<
") too small for DATA PDU");
412 NS_ASSERT_MSG (
false,
"TxOpportunity (size = " << txOpParams.
bytes <<
") too small for DATA PDU\n"
413 <<
"Your MAC scheduler is assigned too few resource blocks.");
420 NS_LOG_INFO (
"cannot transmit new RLC PDU due to window stalling");
443 uint32_t nextSegmentSize = txOpParams.
bytes - 4;
444 uint32_t nextSegmentId = 1;
445 uint32_t dataFieldTotalSize = 0;
446 uint32_t dataFieldAddedSize = 0;
447 std::vector < Ptr<Packet> > dataField;
460 NS_LOG_LOGIC (
"Next segment size = " << nextSegmentSize);
468 while ( firstSegment && (firstSegment->
GetSize () > 0) && (nextSegmentSize > 0) )
470 NS_LOG_LOGIC (
"WHILE ( firstSegment && firstSegment->GetSize > 0 && nextSegmentSize > 0 )");
472 NS_LOG_LOGIC (
" nextSegmentSize = " << nextSegmentSize);
473 if ( (firstSegment->
GetSize () > nextSegmentSize) ||
475 (firstSegment->
GetSize () > 2047)
480 uint32_t currSegmentSize =
std::min (firstSegment->
GetSize (), nextSegmentSize);
482 NS_LOG_LOGIC (
" IF ( firstSegment > nextSegmentSize ||");
510 if (firstSegment->
GetSize () > 0)
517 NS_LOG_LOGIC (
" Txon buffer: Give back the remaining segment");
542 dataFieldAddedSize = newSegment->
GetSize ();
543 dataFieldTotalSize += dataFieldAddedSize;
544 dataField.push_back (newSegment);
552 nextSegmentSize -= dataFieldAddedSize;
560 else if ( (nextSegmentSize - firstSegment->
GetSize () <= 2) || (
m_txonBuffer.size () == 0) )
562 NS_LOG_LOGIC (
" IF nextSegmentSize - firstSegment->GetSize () <= 2 || txonBuffer.size == 0");
565 dataFieldAddedSize = firstSegment->
GetSize ();
566 dataFieldTotalSize += dataFieldAddedSize;
567 dataField.push_back (firstSegment);
575 nextSegmentSize -= dataFieldAddedSize;
584 NS_LOG_LOGIC (
" Next segment size = " << nextSegmentSize);
593 NS_LOG_LOGIC (
" IF firstSegment < NextSegmentSize && txonBuffer.size > 0");
595 dataFieldAddedSize = firstSegment->
GetSize ();
596 dataFieldTotalSize += dataFieldAddedSize;
597 dataField.push_back (firstSegment);
605 nextSegmentSize -= ((nextSegmentId % 2) ? (2) : (1)) + dataFieldAddedSize;
614 NS_LOG_LOGIC (
" Next segment size = " << nextSegmentSize);
619 firstSegmentTime =
m_txonBuffer.begin ()->m_waitingSince;
640 uint8_t framingInfo = 0;
641 std::vector< Ptr<Packet> >::iterator it;
642 it = dataField.begin ();
646 NS_ASSERT_MSG ((*it)->PeekPacketTag (tag),
"LteRlcSduStatusTag is missing");
647 (*it)->PeekPacketTag (tag);
660 while (it < dataField.end ())
662 NS_LOG_LOGIC (
"Adding SDU/segment to packet, length = " << (*it)->GetSize ());
664 NS_ASSERT_MSG ((*it)->PeekPacketTag (tag),
"LteRlcSduStatusTag is missing");
665 (*it)->RemovePacketTag (tag);
785 NS_ASSERT_MSG(ret,
"RlcTag not found in RLC Header. The packet went into a real network?");
849 NS_LOG_LOGIC (
"PDU segment received ( SN = " << seqNumber <<
" )");
853 NS_LOG_LOGIC (
"PDU received ( SN = " << seqNumber <<
" )");
857 NS_ASSERT_MSG (
false,
"Neither a PDU segment nor a PDU received");
907 NS_ASSERT (it->second.m_byteSegments.size () > 0);
908 NS_ASSERT_MSG (it->second.m_byteSegments.size () == 1,
"re-segmentation not supported");
909 NS_LOG_LOGIC (
"PDU segment already received, discarded");
913 NS_LOG_LOGIC (
"Place PDU in the reception buffer ( SN = " << seqNumber <<
" )");
928 if ( seqNumber >=
m_vrH )
930 m_vrH = seqNumber + 1;
940 it->second.m_pduComplete )
944 it->second.m_pduComplete )
961 if ( seqNumber ==
m_vrR )
965 it->second.m_pduComplete )
970 it->second.m_pduComplete )
974 "Too many segments. PDU Reassembly process didn't work");
1050 bool incrementVtA =
true;
1052 for (sn =
m_vtA; sn < ackSn && sn <
m_vtS; sn++)
1056 uint16_t seqNumberValue = sn.
GetValue ();
1068 incrementVtA =
false;
1072 NS_LOG_INFO (
"Move SN = " << seqNumberValue <<
" to retxBuffer");
1093 NS_LOG_INFO (
"ACKed SN = " << seqNumberValue <<
" from txedBuffer");
1103 NS_LOG_INFO (
"ACKed SN = " << seqNumberValue <<
" from retxBuffer");
1146 m_vrR <<
" <= " << seqNumber <<
" <= " <<
m_vrMr);
1152 if ( (
m_vrR <= seqNumber) && (seqNumber <
m_vrMr ) )
1154 NS_LOG_LOGIC (seqNumber <<
" is INSIDE the receiving window");
1159 NS_LOG_LOGIC (seqNumber <<
" is OUTSIDE the receiving window");
1177 bool expectedSnLost;
1181 expectedSnLost =
true;
1187 expectedSnLost =
false;
1193 uint8_t extensionBit;
1194 uint16_t lengthIndicator;
1200 if ( extensionBit == 0 )
1210 if ( lengthIndicator >= packet->
GetSize () )
1212 NS_LOG_LOGIC (
"INTERNAL ERROR: Not enough data in the packet (" << packet->
GetSize () <<
"). Needed LI=" << lengthIndicator);
1223 while ( extensionBit == 1 );
1225 std::list < Ptr<Packet> >::iterator it;
1230 else NS_LOG_LOGIC (
"Reassembling State = Unknown state");
1234 NS_LOG_LOGIC (
"Framing Info = " << (uint16_t)framingInfo);
1238 if (!expectedSnLost)
1243 switch (framingInfo)
1283 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
1289 switch (framingInfo)
1354 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
1369 switch (framingInfo)
1459 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
1465 switch (framingInfo)
1576 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
1603 Time txonQueueHolDelay (0);
1606 txonQueueHolDelay = now -
m_txonBuffer.front ().m_waitingSince;
1610 Time retxQueueHolDelay;
1613 Time senderTimestamp;
1622 retxQueueHolDelay = now - senderTimestamp;
1626 retxQueueHolDelay =
Seconds (0);
1678 it->second.m_pduComplete )
1724 bool pduAvailable =
m_txedBuffer.at (sn.GetValue ()).m_pdu != 0;
1728 uint16_t snValue = sn.GetValue ();
1729 NS_LOG_INFO (
"Move PDU " << sn <<
" from txedBuffer to retxBuffer");
Parameters for LteMacSapProvider::TransmitPdu.
uint8_t harqProcessId
the HARQ process id that was passed by the MAC in the call to NotifyTxOpportunity that generated this...
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void ExpireRbsTimer(void)
Expire RBS timer.
SequenceNumber10 m_vrH
VR(H)
uint32_t retxQueueSize
the current size of the RLC retransmission queue in bytes
uint16_t rnti
the C-RNTI identifying the UE
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
uint32_t m_pduWithoutPoll
Counters.
SequenceNumber10 m_vtMs
VT(MS)
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
AttributeValue implementation for Boolean.
uint32_t PeekHeader(Header &header) const
Deserialize but does not remove the header from the internal buffer.
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 > p
the RLC PDU to be received
bool IsInsideReceivingWindow(SequenceNumber10 seqNumber)
method called when the T_status_prohibit timer expires
TracedCallback< uint16_t, uint8_t, uint32_t > m_txPdu
Used to inform of a PDU delivery to the MAC SAP provider.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
virtual void TransmitPdu(TransmitPduParameters params)=0
send an RLC PDU to the MAC for transmission.
std::map< uint16_t, PduBuffer > m_rxonBuffer
Reception buffer.
void AddHeader(const Header &header)
Add header to this packet.
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
static TypeId GetTypeId(void)
Get the type ID.
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Time m_statusProhibitTimerValue
status prohibit timer value
Parameters for LteMacSapUser::NotifyTxOpportunity.
void SetModulusBase(SequenceNumber10 modulusBase)
Set modulus base.
uint32_t m_retxBufferSize
retransmit buffer size
virtual void DoDispose()
Destructor implementation.
virtual void DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParams)
MAC SAP.
SequenceNumber10 m_vrX
VR(X)
Ptr< Packet > m_controlPduBuffer
Control PDU buffer (just one PDU)
#define NS_LOG_WARN(msg)
Use NS_LOG to output a message of level LOG_WARN.
uint32_t m_statusPduBufferSize
status PDU buffer size
EventId m_rbsTimer
RBS timer.
TracedCallback< Ptr< const Packet > > m_txDropTrace
The trace source fired when the RLC drops a packet before transmission.
bool m_txOpportunityForRetxAlwaysBigEnough
transmit opportunity for retransmit?
uint16_t m_windowSize
Constants.
virtual void DoNotifyHarqDeliveryFailure()
Notify HARQ delivery failure.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
bool m_statusPduRequested
status PDU requested
Ptr< Packet > pdu
the RLC PDU
Ptr< const AttributeAccessor > MakeBooleanAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
bool m_pollRetransmitTimerJustExpired
poll retransmit timer just expired?
TypeId SetParent(TypeId tid)
Set the parent TypeId.
SequenceNumber10 m_vtS
VT(S)
SequenceNumber10 m_vrMr
VR(MR)
uint8_t componentCarrierId
the component carrier id corresponding to the sending Mac istance
LTE RLC Acknowledged Mode (AM), see 3GPP TS 36.322.
virtual void DoDispose()
Destructor implementation.
SequenceNumber10 m_vtA
State variables.
void DoReportBufferStatus()
Report buffer status.
std::list< Ptr< Packet > > m_sdusBuffer
List of SDUs in a packet (PDU)
SequenceNumber10 m_vrMs
VR(MS)
EventId m_reorderingTimer
reordering timer
Time m_rbsTimerValue
RBS timer value.
bool IsRunning(void) const
This method is syntactic sugar for !IsExpired().
This abstract base class defines the API to interact with the Radio Link Control (LTE_RLC) in LTE,...
Store an incoming (from layer above us) PDU, waiting to transmit it.
void RemoveAtStart(uint32_t size)
Remove size bytes from the start of the current packet.
uint16_t m_maxRetxThreshold
Configurable parameters.
Parameters for LteMacSapProvider::ReportBufferStatus.
uint16_t m_pollByte
poll byte
uint32_t m_txedBufferSize
transmit ed buffer size
std::vector< RetxPdu > m_retxBuffer
Buffer for PDUs considered for retransmission.
uint16_t txQueueHolDelay
the Head Of Line delay of the transmission queue
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Time m_pollRetransmitTimerValue
poll retransmit time value
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
uint8_t GetStatus(void) const
Get status function.
std::vector< TxPdu > m_txonBuffer
Transmission buffer.
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
uint32_t txQueueSize
the current size of the RLC transmission queue
Parameters for LteMacSapUser::ReceivePdu.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Time GetSenderTimestamp(void) const
Get the instant when the RLC delivers the PDU to the MAC SAP provider.
uint16_t retxQueueHolDelay
the Head Of Line delay of the retransmission queue
SequenceNumber10 m_vrR
VR(R)
SequenceNumber10 m_expectedSeqNumber
Expected Sequence Number.
Simulation virtual time values and global simulation resolution.
uint32_t m_txonBufferSize
transmit on buffer size
int64_t GetNanoSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
LteMacSapProvider * m_macSapProvider
MAC SAP provider.
virtual void DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams)
Receive PDU function.
void ExpirePollRetransmitTimer(void)
Expire poll retransmitter.
uint16_t m_pollPdu
poll PDU
void ReassembleAndDeliver(Ptr< Packet > packet)
Reassemble and deliver.
uint8_t harqId
the HARQ ID
uint8_t layer
the layer value that was passed by the MAC in the call to NotifyTxOpportunity that generated this PDU
void SetSenderTimestamp(Time senderTimestamp)
Set the sender timestamp.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
void AddPacketTag(const Tag &tag) const
Add a packet tag.
int64_t GetMilliSeconds(void) const
Get an approximation of the time stored in this instance in the indicated unit.
virtual void DoTransmitPdcpPdu(Ptr< Packet > p)
RLC SAP.
ReassemblingState_t m_reassemblingState
reassembling state
uint32_t m_maxTxBufferSize
maximum transmission buffer size
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
Ptr< Packet > m_keepS0
keep S0
virtual void ReportBufferStatus(ReportBufferStatusParameters params)=0
Report the RLC buffer status to the MAC.
SequenceNumber10 m_pollSn
POLL_SN.
Time Seconds(double value)
Construct a Time in the indicated unit.
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
uint8_t componentCarrierId
the component carrier id
Time m_reorderingTimerValue
reordering timer value
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
AttributeValue implementation for Time.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
This class implements a tag that carries the status of a RLC SDU for the fragmentation process Status...
uint32_t bytes
the number of bytes to transmit
uint16_t rnti
the C-RNTI identifying the UE
void ExpireReorderingTimer(void)
This method will schedule a timeout at WaitReplyTimeout interval in the future, unless a timer is alr...
Hold an unsigned integer type.
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
void ExpireStatusProhibitTimer(void)
method called when the T_status_prohibit timer expires
LteRlcSapUser * m_rlcSapUser
RLC SAP user.
bool FindFirstMatchingByteTag(Tag &tag) const
Finds the first tag matching the parameter Tag type.
uint8_t layer
the layer of transmission (MIMO)
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
TracedCallback< uint16_t, uint8_t, uint32_t, uint64_t > m_rxPdu
Used to inform of a PDU reception from the MAC SAP user.
EventId m_statusProhibitTimer
status prohibit timer
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.
uint32_t m_byteWithoutPoll
byte without poll
uint16_t statusPduSize
the current size of the pending STATUS RLC PDU message in bytes
uint16_t GetValue() const
Extracts the numeric value of the sequence number.
std::vector< RetxPdu > m_txedBuffer
Buffer for transmitted and retransmitted PDUs that have not been acked but are not considered for ret...
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
void SetStatus(uint8_t status)
Set status function.
EventId m_pollRetransmitTimer
Timers.
Tag to calculate the per-PDU delay from eNb RLC to UE RLC.