24 #include "ns3/packet.h"
25 #include "ns3/trace-source-accessor.h"
26 #include "ns3/uinteger.h"
27 #include "ns3/simulator.h"
42 m_fragmentation (false),
54 m_timeStamp (timeStamp),
55 m_fragmentation (false),
64 uint32_t size = m_packet->GetSize () + m_hdrType.GetSerializedSize ();
71 size += m_hdr.GetSerializedSize ();
88 MakeUintegerChecker<uint32_t> ())
89 .AddTraceSource (
"Enqueue",
92 .AddTraceSource (
"Dequeue",
95 .AddTraceSource (
"Drop",
111 : m_maxSize (maxSize),
114 m_nrRequestPackets (0)
175 "Can not enqueue more packets: no space left in the queue");
180 NS_LOG_INFO (
"Enqueued Packet IS A Request BW packet");
182 "Can not enqueue more packets: no space left in the queue");
190 NS_LOG_INFO (
"FRAG_DEBUG: Enqueued Packet IS NOT a fragment" << std::endl);
210 NS_LOG_INFO (
"\t Enqueued Packet IS a fragment, add subhdr" << std::endl);
217 "\n\t\t fragmentOffset=" << fragmentOffset <<
219 "\n\t\t fragmentSize=" << fragmentSize << std::endl);
225 fragmentSubhdr.
SetFc (2);
228 NS_LOG_INFO (
"\t FragmentSize=" << fragment->GetSize () << std::endl);
229 fragment->AddHeader (fragmentSubhdr);
244 fragment->AddHeader (element.
m_hdr);
261 NS_LOG_INFO (
"FRAG_DEBUG: Dequeue function" << std::endl);
268 uint32_t maxFragmentSize = availableByte - headerSize;
273 "\n\t\t availableByte=" << availableByte <<
274 "\n\t\t headerSize=" << headerSize <<
275 "\n\t\t maxFragmentSize=" << maxFragmentSize <<
""
276 "\n\t\t fragmentOffset=" << fragmentOffset <<
277 "\n\t\t payloadSize=" << packet->
GetSize ()
288 fragmentSubhdr.
SetFc (1);
293 fragmentSubhdr.
SetFc (3);
296 NS_LOG_INFO (
"\t FragmentSize=" << fragment->GetSize () << std::endl);
297 fragment->AddHeader (fragmentSubhdr);
315 fragment->AddHeader (element.
m_hdr);
383 Time &timeStamp)
const
434 for (std::deque<QueueElement>::const_iterator iter =
m_queue.begin (); iter
452 for (std::deque<QueueElement>::iterator iter =
m_queue.begin (); iter
495 for (std::deque<QueueElement>::const_iterator iter =
m_queue.begin (); iter
508 "\n\t\t m_fragmentation is true " << std::endl);
518 for (std::deque<QueueElement>::const_iterator iter =
m_queue.begin (); iter
530 uint32_t hdrSize = 0;
539 NS_LOG_INFO (
"\t\t\t m_hdrType.GetSerializedSize=" <<
557 for (std::deque<QueueElement>::const_iterator iter =
m_queue.begin (); iter
573 <<
"\n\t\t\t (fragment)payloadSize=" <<
592 NS_LOG_INFO (
"\t Required Bytes = " << requiredByte << std::endl);
600 for (std::deque<QueueElement>::iterator iter =
m_queue.begin (); iter
603 if (iter->m_hdrType.GetType () == packetType)
605 iter->SetFragmentation ();
614 for (std::deque<QueueElement>::iterator iter =
m_queue.begin (); iter
617 if (iter->m_hdrType.GetType () == packetType)
619 iter->SetFragmentNumber ();
628 for (std::deque<QueueElement>::iterator iter =
m_queue.begin (); iter
631 if (iter->m_hdrType.GetType () == packetType)
633 iter->SetFragmentOffset (offset);
654 m_fragmentOffset += offset;
uint32_t GetFirstPacketHdrSize(MacHeaderType::HeaderType packetType)
void SetFragmentOffset(MacHeaderType::HeaderType packetType, uint32_t offset)
Simulation virtual time values and global simulation resolution.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register the class in the ns-3 factory.
TracedCallback< Ptr< const Packet > > m_traceDrop
std::deque< QueueElement > PacketQueue
TracedCallback< Ptr< const Packet > > m_traceDequeue
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
uint32_t GetSize(void) const
uint32_t GetNBytes(void) const
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Ptr< Packet > Peek(GenericMacHeader &hdr) const
Same as Dequeue but does not pop from queue.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
void SetFragmentOffset(uint32_t offset)
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
uint32_t GetSize(void) const
Hold an unsigned integer type.
void SetFragmentation(void)
TracedCallback< Ptr< const Packet > > m_traceEnqueue
void SetFragmentNumber(void)
uint32_t GetQueueLengthWithMACOverhead(void)
bool CheckForFragmentation(MacHeaderType::HeaderType packetType)
Fragmentation utilities.
uint32_t m_fragmentNumber
bool Enqueue(Ptr< Packet > packet, const MacHeaderType &hdrType, const GenericMacHeader &hdr)
Enqueue a packet.
uint32_t GetFirstPacketRequiredByte(MacHeaderType::HeaderType packetType)
uint32_t m_nrRequestPackets
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
uint32_t m_fragmentOffset
WimaxMacQueue::QueueElement Front(MacHeaderType::HeaderType packetType) const
void SetFragmentation(MacHeaderType::HeaderType packetType)
static Time Now(void)
Return the "current simulation time".
uint32_t GetMaxSize(void) const
void SetMaxSize(uint32_t maxSize)
set the maximum queue size
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
const WimaxMacQueue::PacketQueue & GetPacketQueue(void) const
Time Seconds(double value)
Construct a Time in the indicated unit.
static TypeId GetTypeId(void)
void Pop(MacHeaderType::HeaderType packetType)
void SetFragmentNumber(MacHeaderType::HeaderType packetType)
a base class which provides memory management and object aggregation
Ptr< Packet > Dequeue(MacHeaderType::HeaderType packetType)
Dequeue a packet of type packetType from the queue.
uint32_t GetFirstPacketPayloadSize(MacHeaderType::HeaderType packetType)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
void AddHeader(const Header &header)
Add header to this packet.