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"
37 : m_maxTxBufferSize (10 * 1024),
44 m_expectedSeqNumber (0)
60 .AddConstructor<LteRlcUm> ()
61 .AddAttribute (
"MaxTxBufferSize",
62 "Maximum Size of the Transmission Buffer (in Bytes)",
65 MakeUintegerChecker<uint32_t> ())
142 uint32_t nextSegmentSize = bytes - 2;
143 uint32_t nextSegmentId = 1;
144 uint32_t dataFieldTotalSize = 0;
145 uint32_t dataFieldAddedSize = 0;
146 std::vector < Ptr<Packet> > dataField;
159 NS_LOG_LOGIC (
"Next segment size = " << nextSegmentSize);
166 while ( firstSegment && (firstSegment->
GetSize () > 0) && (nextSegmentSize > 0) )
168 NS_LOG_LOGIC (
"WHILE ( firstSegment && firstSegment->GetSize > 0 && nextSegmentSize > 0 )");
170 NS_LOG_LOGIC (
" nextSegmentSize = " << nextSegmentSize);
171 if ( (firstSegment->
GetSize () > nextSegmentSize) ||
173 (firstSegment->
GetSize () > 2047)
178 uint32_t currSegmentSize = std::min (firstSegment->
GetSize (), nextSegmentSize);
180 NS_LOG_LOGIC (
" IF ( firstSegment > nextSegmentSize ||");
208 if (firstSegment->
GetSize () > 0)
215 NS_LOG_LOGIC (
" TX buffer: Give back the remaining segment");
240 dataFieldAddedSize = newSegment->
GetSize ();
241 dataFieldTotalSize += dataFieldAddedSize;
242 dataField.push_back (newSegment);
250 nextSegmentSize -= dataFieldAddedSize;
258 else if ( (nextSegmentSize - firstSegment->
GetSize () <= 2) || (
m_txBuffer.size () == 0) )
260 NS_LOG_LOGIC (
" IF nextSegmentSize - firstSegment->GetSize () <= 2 || txBuffer.size == 0");
262 dataFieldAddedSize = firstSegment->
GetSize ();
263 dataFieldTotalSize += dataFieldAddedSize;
264 dataField.push_back (firstSegment);
272 nextSegmentSize -= dataFieldAddedSize;
281 NS_LOG_LOGIC (
" Next segment size = " << nextSegmentSize);
290 NS_LOG_LOGIC (
" IF firstSegment < NextSegmentSize && txBuffer.size > 0");
292 dataFieldAddedSize = firstSegment->
GetSize ();
293 dataFieldTotalSize += dataFieldAddedSize;
294 dataField.push_back (firstSegment);
300 rlcHeader.PushLengthIndicator (firstSegment->
GetSize ());
302 nextSegmentSize -= ((nextSegmentId % 2) ? (2) : (1)) + dataFieldAddedSize;
311 NS_LOG_LOGIC (
" Next segment size = " << nextSegmentSize);
327 std::vector< Ptr<Packet> >::iterator it;
328 it = dataField.begin ();
330 uint8_t framingInfo = 0;
334 (*it)->RemovePacketTag (tag);
344 (*it)->AddPacketTag (tag);
346 while (it < dataField.end ())
348 NS_LOG_LOGIC (
"Adding SDU/segment to packet, length = " << (*it)->GetSize ());
356 (*it)->RemovePacketTag (tag);
366 (*it)->AddPacketTag (tag);
368 rlcHeader.SetFramingInfo (framingInfo);
383 params.layer = layer;
384 params.harqProcessId = harqId;
489 NS_LOG_LOGIC (
"VR(UR) is outside the reordering window");
504 std::map <uint16_t, Ptr<Packet> >::iterator it;
509 newVrUr = (it->first) + 1;
576 NS_LOG_LOGIC (seqNumber <<
" is INSIDE the reordering window");
581 NS_LOG_LOGIC (seqNumber <<
" is OUTSIDE the reordering window");
598 expectedSnLost =
true;
604 expectedSnLost =
false;
610 uint8_t extensionBit;
611 uint16_t lengthIndicator;
617 if ( extensionBit == 0 )
627 if ( lengthIndicator >= packet->
GetSize () )
629 NS_LOG_LOGIC (
"INTERNAL ERROR: Not enough data in the packet (" << packet->
GetSize () <<
"). Needed LI=" << lengthIndicator);
639 while ( extensionBit == 1 );
641 std::list < Ptr<Packet> >::iterator it;
646 else NS_LOG_LOGIC (
"Reassembling State = Unknown state");
649 NS_LOG_LOGIC (
"Framing Info = " << (uint16_t)framingInfo);
747 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
818 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
923 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
1040 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
1059 std::map <uint16_t, Ptr<Packet> >::iterator it;
1069 std::map <uint16_t, Ptr<Packet> >::iterator it_tmp = it;
1076 NS_LOG_LOGIC (
"(SN = " << it->first <<
") is inside the reordering window");
1083 NS_LOG_LOGIC (
"Reassemble SN between " << lowSeqNumber <<
" and " << highSeqNumber);
1085 std::map <uint16_t, Ptr<Packet> >::iterator it;
1090 while (reassembleSn < highSeqNumber)
1115 uint32_t queueSize = 0;
1120 m_txBuffer.front ()->PeekPacketTag (holTimeTag);
1155 std::map <uint16_t, Ptr<Packet> >::iterator it;
uint32_t m_maxTxBufferSize
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
#define NS_LOG_FUNCTION(parameters)
uint16_t GetValue() const
Extracts the numeric value of the sequence number.
void ReassembleAndDeliver(Ptr< Packet > packet)
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)
uint32_t GetSize(void) const
uint32_t retxQueueSize
the current size of the RLC retransmission queue in bytes
virtual void DoTransmitPdcpPdu(Ptr< Packet > p)
RLC SAP.
bool IsRunning(void) const
This method is syntactic sugar for the ns3::Simulator::isExpired method.
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
virtual void DoNotifyHarqDeliveryFailure()
uint16_t rnti
the C-RNTI identifying the UE
SequenceNumber10 m_sequenceNumber
State variables.
void ReassembleSnInterval(SequenceNumber10 lowSeqNumber, SequenceNumber10 highSeqNumber)
void SetModulusBase(SequenceNumber10 modulusBase)
Parameters for LteMacSapProvider::ReportBufferStatus.
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.
virtual void DoReceivePdu(Ptr< Packet > p)
void AddAtEnd(Ptr< const Packet > packet)
Concatenate the input packet at the end of the current packet.
LteRlcSapUser * m_rlcSapUser
SequenceNumber10 m_expectedSeqNumber
Expected Sequence Number.
std::vector< Ptr< Packet > > m_txBuffer
void RemoveAtStart(uint32_t size)
Remove size bytes from the start of the current packet.
NS_LOG_COMPONENT_DEFINE("LteRlcUm")
virtual void DoNotifyTxOpportunity(uint32_t bytes, uint8_t layer, uint8_t harqId)
MAC SAP.
static TypeId GetTypeId(void)
Hold an unsigned integer type.
ReassemblingState_t m_reassemblingState
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...
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.
uint16_t m_windowSize
Constants.
void ExpireReorderingTimer(void)
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 txQueueSize
the current size of the RLC transmission queue
static Time Now(void)
Return the "current simulation time".
std::map< uint16_t, Ptr< Packet > > m_rxBuffer
EventId m_reorderingTimer
Timers.
int64_t GetNanoSeconds(void) const
uint16_t statusPduSize
the current size of the pending STATUS RLC PDU message in bytes
std::list< Ptr< Packet > > m_sdusBuffer
This class implements a tag that carries the status of a RLC SDU for the fragmentation process Status...
bool RemovePacketTag(Tag &tag)
Remove a packet tag.
void ReassembleOutsideWindow(void)
bool IsInsideReorderingWindow(SequenceNumber10 seqNumber)
void SetStatus(uint8_t status)
virtual void DoDispose()
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
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.
void ExpireRbsTimer(void)
TracedCallback< uint16_t, uint8_t, uint32_t, uint64_t > m_rxPdu
Used to inform of a PDU reception from the MAC SAP user.
virtual void TransmitPdu(TransmitPduParameters params)=0
send an RLC PDU to the MAC for transmission.
This abstract base class defines the API to interact with the Radio Link Control (LTE_RLC) in LTE...
a unique identifier for an interface.
int64_t GetMilliSeconds(void) const
TypeId SetParent(TypeId tid)
void AddHeader(const Header &header)
Add header to this packet.
void AddByteTag(const Tag &tag) const
Tag each byte included in this packet with a new byte tag.
Parameters for LteMacSapProvider::TransmitPdu.