|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
21 #include "ns3/simulator.h"
24 #include "ns3/lte-rlc-header.h"
25 #include "ns3/lte-rlc-um.h"
26 #include "ns3/lte-rlc-sdu-status-tag.h"
27 #include "ns3/lte-rlc-tag.h"
36 : m_maxTxBufferSize (10 * 1024),
43 m_expectedSeqNumber (0)
61 .AddAttribute (
"MaxTxBufferSize",
62 "Maximum Size of the Transmission Buffer (in Bytes)",
65 MakeUintegerChecker<uint32_t> ())
66 .AddAttribute (
"ReorderingTimer",
67 "Value of the t-Reordering timer (See section 7.3 of 3GPP TS 36.322)",
132 if (txOpParams.
bytes <= 2)
143 uint32_t nextSegmentSize = txOpParams.
bytes - 2;
144 uint32_t nextSegmentId = 1;
145 uint32_t dataFieldTotalSize = 0;
146 uint32_t dataFieldAddedSize = 0;
147 std::vector < Ptr<Packet> > dataField;
163 NS_LOG_LOGIC (
"Next segment size = " << nextSegmentSize);
169 while ( firstSegment && (firstSegment->
GetSize () > 0) && (nextSegmentSize > 0) )
171 NS_LOG_LOGIC (
"WHILE ( firstSegment && firstSegment->GetSize > 0 && nextSegmentSize > 0 )");
173 NS_LOG_LOGIC (
" nextSegmentSize = " << nextSegmentSize);
174 if ( (firstSegment->
GetSize () > nextSegmentSize) ||
176 (firstSegment->
GetSize () > 2047)
181 uint32_t currSegmentSize =
std::min (firstSegment->
GetSize (), nextSegmentSize);
183 NS_LOG_LOGIC (
" IF ( firstSegment > nextSegmentSize ||");
211 if (firstSegment->
GetSize () > 0)
218 NS_LOG_LOGIC (
" TX buffer: Give back the remaining segment");
243 dataFieldAddedSize = newSegment->
GetSize ();
244 dataFieldTotalSize += dataFieldAddedSize;
245 dataField.push_back (newSegment);
253 nextSegmentSize -= dataFieldAddedSize;
261 else if ( (nextSegmentSize - firstSegment->
GetSize () <= 2) || (
m_txBuffer.size () == 0) )
263 NS_LOG_LOGIC (
" IF nextSegmentSize - firstSegment->GetSize () <= 2 || txBuffer.size == 0");
265 dataFieldAddedSize = firstSegment->
GetSize ();
266 dataFieldTotalSize += dataFieldAddedSize;
267 dataField.push_back (firstSegment);
275 nextSegmentSize -= dataFieldAddedSize;
284 NS_LOG_LOGIC (
" Next segment size = " << nextSegmentSize);
293 NS_LOG_LOGIC (
" IF firstSegment < NextSegmentSize && txBuffer.size > 0");
295 dataFieldAddedSize = firstSegment->
GetSize ();
296 dataFieldTotalSize += dataFieldAddedSize;
297 dataField.push_back (firstSegment);
305 nextSegmentSize -= ((nextSegmentId % 2) ? (2) : (1)) + dataFieldAddedSize;
314 NS_LOG_LOGIC (
" Next segment size = " << nextSegmentSize);
318 firstSegment =
m_txBuffer.begin ()->m_pdu->Copy ();
319 firstSegmentTime =
m_txBuffer.begin ()->m_waitingSince;
331 std::vector< Ptr<Packet> >::iterator it;
332 it = dataField.begin ();
334 uint8_t framingInfo = 0;
338 NS_ASSERT_MSG ((*it)->PeekPacketTag (tag),
"LteRlcSduStatusTag is missing");
339 (*it)->PeekPacketTag (tag);
350 while (it < dataField.end ())
352 NS_LOG_LOGIC (
"Adding SDU/segment to packet, length = " << (*it)->GetSize ());
354 NS_ASSERT_MSG ((*it)->PeekPacketTag (tag),
"LteRlcSduStatusTag is missing");
355 (*it)->RemovePacketTag (tag);
502 NS_LOG_LOGIC (
"VR(UR) is outside the reordering window");
517 std::map <uint16_t, Ptr<Packet> >::iterator it;
522 newVrUr = (it->first) + 1;
589 NS_LOG_LOGIC (seqNumber <<
" is INSIDE the reordering window");
594 NS_LOG_LOGIC (seqNumber <<
" is OUTSIDE the reordering window");
611 expectedSnLost =
true;
617 expectedSnLost =
false;
623 uint8_t extensionBit;
624 uint16_t lengthIndicator;
630 if ( extensionBit == 0 )
640 if ( lengthIndicator >= packet->
GetSize () )
642 NS_LOG_LOGIC (
"INTERNAL ERROR: Not enough data in the packet (" << packet->
GetSize () <<
"). Needed LI=" << lengthIndicator);
652 while ( extensionBit == 1 );
654 std::list < Ptr<Packet> >::iterator it;
659 else NS_LOG_LOGIC (
"Reassembling State = Unknown state");
662 NS_LOG_LOGIC (
"Framing Info = " << (uint16_t)framingInfo);
760 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
831 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
936 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
1053 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
1072 std::map <uint16_t, Ptr<Packet> >::iterator it;
1082 std::map <uint16_t, Ptr<Packet> >::iterator it_tmp = it;
1089 NS_LOG_LOGIC (
"(SN = " << it->first <<
") is inside the reordering window");
1096 NS_LOG_LOGIC (
"Reassemble SN between " << lowSeqNumber <<
" and " << highSeqNumber);
1098 std::map <uint16_t, Ptr<Packet> >::iterator it;
1103 while (reassembleSn < highSeqNumber)
1128 uint32_t queueSize = 0;
1166 std::map <uint16_t, Ptr<Packet> >::iterator it;
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.
Store an incoming (from layer above us) PDU, waiting to transmit it.
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.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
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
virtual void DoDispose()
Destructor implementation.
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.
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 Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Parameters for LteMacSapUser::NotifyTxOpportunity.
void SetModulusBase(SequenceNumber10 modulusBase)
Set modulus base.
void ReassembleOutsideWindow(void)
Reassemble outside window.
EventId m_rbsTimer
RBS timer.
void ReassembleSnInterval(SequenceNumber10 lowSeqNumber, SequenceNumber10 highSeqNumber)
Reassemble SN interval function.
ReassemblingState_t m_reassemblingState
reassembling state
TracedCallback< Ptr< const Packet > > m_txDropTrace
The trace source fired when the RLC drops a packet before transmission.
SequenceNumber10 m_vrUh
VR(UH)
std::map< uint16_t, Ptr< Packet > > m_rxBuffer
Reception buffer.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Ptr< Packet > pdu
the RLC PDU
void ExpireReorderingTimer(void)
Expire reordering timer.
virtual void DoTransmitPdcpPdu(Ptr< Packet > p)
RLC SAP.
SequenceNumber10 m_sequenceNumber
State variables.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Ptr< Packet > m_keepS0
keep S0
uint8_t componentCarrierId
the component carrier id corresponding to the sending Mac istance
virtual void DoDispose()
Destructor implementation.
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,...
void RemoveAtStart(uint32_t size)
Remove size bytes from the start of the current packet.
Parameters for LteMacSapProvider::ReportBufferStatus.
std::vector< TxPdu > m_txBuffer
Transmission buffer.
uint16_t txQueueHolDelay
the Head Of Line delay of the transmission queue
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
uint8_t GetStatus(void) const
Get status function.
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.
void ExpireRbsTimer(void)
Expire RBS timer.
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
uint16_t m_windowSize
Constants.
Simulation virtual time values and global simulation resolution.
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...
SequenceNumber10 m_expectedSeqNumber
Expected Sequence Number.
LteMacSapProvider * m_macSapProvider
MAC SAP provider.
static TypeId GetTypeId(void)
Get the type ID.
std::list< Ptr< Packet > > m_sdusBuffer
List of SDUs in a packet.
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
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
void ReassembleAndDeliver(Ptr< Packet > packet)
Reassemble and deliver function.
SequenceNumber10 m_vrUr
VR(UR)
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.
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
bool IsInsideReorderingWindow(SequenceNumber10 seqNumber)
Is inside reordering window function.
virtual void ReportBufferStatus(ReportBufferStatusParameters params)=0
Report the RLC buffer status to the MAC.
virtual void DoNotifyHarqDeliveryFailure()
Notify HARQ delivery failure.
virtual void DoReceivePdu(LteMacSapUser::ReceivePduParameters rxPduParams)
Receive PDU function.
uint8_t componentCarrierId
the component carrier id
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 ",...
EventId m_reorderingTimer
reordering timer
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
virtual void DoNotifyTxOpportunity(LteMacSapUser::TxOpportunityParameters txOpParams)
MAC SAP.
Hold an unsigned integer type.
uint8_t lcid
the logical channel id corresponding to the sending RLC instance
Time m_reorderingTimerValue
Timers.
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
uint32_t m_txBufferSize
transmit buffer size
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 Unacknowledged Mode (UM), see 3GPP TS 36.322.
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.
uint32_t m_maxTxBufferSize
maximum transmit buffer status
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.
void DoReportBufferStatus()
Report buffer status.
SequenceNumber10 m_vrUx
VR(UX)
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.
Tag to calculate the per-PDU delay from eNb RLC to UE RLC.