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)
59 .AddConstructor<LteRlcUm> ()
60 .AddAttribute (
"MaxTxBufferSize",
61 "Maximum Size of the Transmission Buffer (in Bytes)",
64 MakeUintegerChecker<uint32_t> ())
141 uint32_t nextSegmentSize = bytes - 2;
142 uint32_t nextSegmentId = 1;
143 uint32_t dataFieldTotalSize = 0;
144 uint32_t dataFieldAddedSize = 0;
145 std::vector < Ptr<Packet> > dataField;
158 NS_LOG_LOGIC (
"Next segment size = " << nextSegmentSize);
165 while ( firstSegment && (firstSegment->
GetSize () > 0) && (nextSegmentSize > 0) )
167 NS_LOG_LOGIC (
"WHILE ( firstSegment && firstSegment->GetSize > 0 && nextSegmentSize > 0 )");
169 NS_LOG_LOGIC (
" nextSegmentSize = " << nextSegmentSize);
170 if ( (firstSegment->
GetSize () > nextSegmentSize) ||
172 (firstSegment->
GetSize () > 2047)
177 uint32_t currSegmentSize = std::min (firstSegment->
GetSize (), nextSegmentSize);
179 NS_LOG_LOGIC (
" IF ( firstSegment > nextSegmentSize ||");
207 if (firstSegment->
GetSize () > 0)
214 NS_LOG_LOGIC (
" TX buffer: Give back the remaining segment");
239 dataFieldAddedSize = newSegment->
GetSize ();
240 dataFieldTotalSize += dataFieldAddedSize;
241 dataField.push_back (newSegment);
249 nextSegmentSize -= dataFieldAddedSize;
257 else if ( (nextSegmentSize - firstSegment->
GetSize () <= 2) || (
m_txBuffer.size () == 0) )
259 NS_LOG_LOGIC (
" IF nextSegmentSize - firstSegment->GetSize () <= 2 || txBuffer.size == 0");
261 dataFieldAddedSize = firstSegment->
GetSize ();
262 dataFieldTotalSize += dataFieldAddedSize;
263 dataField.push_back (firstSegment);
271 nextSegmentSize -= dataFieldAddedSize;
280 NS_LOG_LOGIC (
" Next segment size = " << nextSegmentSize);
289 NS_LOG_LOGIC (
" IF firstSegment < NextSegmentSize && txBuffer.size > 0");
291 dataFieldAddedSize = firstSegment->
GetSize ();
292 dataFieldTotalSize += dataFieldAddedSize;
293 dataField.push_back (firstSegment);
299 rlcHeader.PushLengthIndicator (firstSegment->
GetSize ());
301 nextSegmentSize -= ((nextSegmentId % 2) ? (2) : (1)) + dataFieldAddedSize;
310 NS_LOG_LOGIC (
" Next segment size = " << nextSegmentSize);
326 std::vector< Ptr<Packet> >::iterator it;
327 it = dataField.begin ();
329 uint8_t framingInfo = 0;
333 (*it)->RemovePacketTag (tag);
343 (*it)->AddPacketTag (tag);
345 while (it < dataField.end ())
347 NS_LOG_LOGIC (
"Adding SDU/segment to packet, length = " << (*it)->GetSize ());
355 (*it)->RemovePacketTag (tag);
365 (*it)->AddPacketTag (tag);
367 rlcHeader.SetFramingInfo (framingInfo);
382 params.layer = layer;
383 params.harqProcessId = harqId;
488 NS_LOG_LOGIC (
"VR(UR) is outside the reordering window");
503 std::map <uint16_t, Ptr<Packet> >::iterator it;
508 newVrUr = (it->first) + 1;
575 NS_LOG_LOGIC (seqNumber <<
" is INSIDE the reordering window");
580 NS_LOG_LOGIC (seqNumber <<
" is OUTSIDE the reordering window");
597 expectedSnLost =
true;
603 expectedSnLost =
false;
609 uint8_t extensionBit;
610 uint16_t lengthIndicator;
616 if ( extensionBit == 0 )
626 if ( lengthIndicator >= packet->
GetSize () )
628 NS_LOG_LOGIC (
"INTERNAL ERROR: Not enough data in the packet (" << packet->
GetSize () <<
"). Needed LI=" << lengthIndicator);
638 while ( extensionBit == 1 );
640 std::list < Ptr<Packet> >::iterator it;
645 else NS_LOG_LOGIC (
"Reassembling State = Unknown state");
648 NS_LOG_LOGIC (
"Framing Info = " << (uint16_t)framingInfo);
746 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
817 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
922 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
1039 NS_LOG_LOGIC (
"INTERNAL ERROR: Transition not possible. FI = " << (uint32_t) framingInfo);
1058 std::map <uint16_t, Ptr<Packet> >::iterator it;
1068 std::map <uint16_t, Ptr<Packet> >::iterator it_tmp = it;
1075 NS_LOG_LOGIC (
"(SN = " << it->first <<
") is inside the reordering window");
1082 NS_LOG_LOGIC (
"Reassemble SN between " << lowSeqNumber <<
" and " << highSeqNumber);
1084 std::map <uint16_t, Ptr<Packet> >::iterator it;
1089 while (reassembleSn < highSeqNumber)
1114 uint32_t queueSize = 0;
1119 m_txBuffer.front ()->PeekPacketTag (holTimeTag);
1154 std::map <uint16_t, Ptr<Packet> >::iterator it;
uint32_t m_maxTxBufferSize
uint32_t RemoveHeader(Header &header)
TracedCallback< uint16_t, uint8_t, uint32_t > m_txPdu
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
#define NS_LOG_COMPONENT_DEFINE(name)
uint32_t GetSize(void) const
virtual void DoTransmitPdcpPdu(Ptr< Packet > p)
bool IsRunning(void) const
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
virtual void DoNotifyHarqDeliveryFailure()
SequenceNumber10 m_sequenceNumber
void ReassembleSnInterval(SequenceNumber10 lowSeqNumber, SequenceNumber10 highSeqNumber)
void SetModulusBase(SequenceNumber10 modulusBase)
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
virtual void DoReceivePdu(Ptr< Packet > p)
void AddAtEnd(Ptr< const Packet > packet)
LteRlcSapUser * m_rlcSapUser
SequenceNumber10 m_expectedSeqNumber
std::vector< Ptr< Packet > > m_txBuffer
void RemoveAtStart(uint32_t size)
virtual void DoNotifyTxOpportunity(uint32_t bytes, uint8_t layer, uint8_t harqId)
static TypeId GetTypeId(void)
Hold an unsigned integer type.
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
ReassemblingState_t m_reassemblingState
virtual void ReceivePdcpPdu(Ptr< Packet > p)=0
uint8_t GetStatus(void) const
LteMacSapProvider * m_macSapProvider
#define NS_LOG_LOGIC(msg)
Ptr< Packet > Copy(void) const
uint32_t PeekHeader(Header &header) const
void ExpireReorderingTimer(void)
Time GetSenderTimestamp(void) const
std::map< uint16_t, Ptr< Packet > > m_rxBuffer
EventId m_reorderingTimer
int64_t GetNanoSeconds(void) const
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)
void ReassembleOutsideWindow(void)
bool IsInsideReorderingWindow(SequenceNumber10 seqNumber)
void SetStatus(uint8_t status)
uint16_t retxQueueHolDelay
virtual void ReportBufferStatus(ReportBufferStatusParameters params)=0
void ExpireRbsTimer(void)
TracedCallback< uint16_t, uint8_t, uint32_t, uint64_t > m_rxPdu
virtual void TransmitPdu(TransmitPduParameters params)=0
a unique identifier for an interface.
int64_t GetMilliSeconds(void) const
TypeId SetParent(TypeId tid)
void AddHeader(const Header &header)
void AddByteTag(const Tag &tag) const