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 ();
82 .SetGroupName(
"Wimax")
89 MakeUintegerChecker<uint32_t> ())
90 .AddTraceSource (
"Enqueue",
93 "ns3::Packet::TracedCallback")
94 .AddTraceSource (
"Dequeue",
97 "ns3::Packet::TracedCallback")
98 .AddTraceSource (
"Drop",
101 "ns3::Packet::TracedCallback")
115 : m_maxSize (maxSize),
118 m_nrRequestPackets (0)
179 "Can not enqueue more packets: no space left in the queue");
184 NS_LOG_INFO (
"Enqueued Packet IS A Request BW packet");
186 "Can not enqueue more packets: no space left in the queue");
194 NS_LOG_INFO (
"FRAG_DEBUG: Enqueued Packet IS NOT a fragment" << std::endl);
214 NS_LOG_INFO (
"\t Enqueued Packet IS a fragment, add subhdr" << std::endl);
221 "\n\t\t fragmentOffset=" << fragmentOffset <<
223 "\n\t\t fragmentSize=" << fragmentSize << std::endl);
229 fragmentSubhdr.
SetFc (2);
232 NS_LOG_INFO (
"\t FragmentSize=" << fragment->GetSize () << std::endl);
233 fragment->AddHeader (fragmentSubhdr);
248 fragment->AddHeader (element.
m_hdr);
265 NS_LOG_INFO (
"FRAG_DEBUG: Dequeue function" << std::endl);
272 uint32_t maxFragmentSize = availableByte - headerSize;
277 "\n\t\t availableByte=" << availableByte <<
278 "\n\t\t headerSize=" << headerSize <<
279 "\n\t\t maxFragmentSize=" << maxFragmentSize <<
"" 280 "\n\t\t fragmentOffset=" << fragmentOffset <<
281 "\n\t\t payloadSize=" << packet->
GetSize ()
292 fragmentSubhdr.
SetFc (1);
297 fragmentSubhdr.
SetFc (3);
300 NS_LOG_INFO (
"\t FragmentSize=" << fragment->GetSize () << std::endl);
301 fragment->AddHeader (fragmentSubhdr);
319 fragment->AddHeader (element.
m_hdr);
387 Time &timeStamp)
const 438 for (std::deque<QueueElement>::const_iterator iter =
m_queue.begin (); iter
456 for (std::deque<QueueElement>::iterator iter =
m_queue.begin (); iter
499 for (std::deque<QueueElement>::const_iterator iter =
m_queue.begin (); iter
512 "\n\t\t m_fragmentation is true " << std::endl);
522 for (std::deque<QueueElement>::const_iterator iter =
m_queue.begin (); iter
534 uint32_t hdrSize = 0;
543 NS_LOG_INFO (
"\t\t\t m_hdrType.GetSerializedSize=" <<
561 for (std::deque<QueueElement>::const_iterator iter =
m_queue.begin (); iter
577 <<
"\n\t\t\t (fragment)payloadSize=" <<
596 NS_LOG_INFO (
"\t Required Bytes = " << requiredByte << std::endl);
604 for (std::deque<QueueElement>::iterator iter =
m_queue.begin (); iter
607 if (iter->m_hdrType.GetType () == packetType)
609 iter->SetFragmentation ();
618 for (std::deque<QueueElement>::iterator iter =
m_queue.begin (); iter
621 if (iter->m_hdrType.GetType () == packetType)
623 iter->SetFragmentNumber ();
632 for (std::deque<QueueElement>::iterator iter =
m_queue.begin (); iter
635 if (iter->m_hdrType.GetType () == packetType)
637 iter->SetFragmentOffset (offset);
658 m_fragmentOffset += offset;
uint32_t GetSize(void) const
Get size of queue.
const WimaxMacQueue::PacketQueue & GetPacketQueue(void) const
Get packet queue function.
uint32_t GetFirstPacketHdrSize(MacHeaderType::HeaderType packetType)
Get first packet header size of the specified type.
void SetFragmentOffset(MacHeaderType::HeaderType packetType, uint32_t offset)
Set fragment offset for first packet of type packetType.
Simulation virtual time values and global simulation resolution.
Ptr< Packet > m_packet
packet
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
TracedCallback< Ptr< const Packet > > m_traceDrop
drop trace callback
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
std::deque< QueueElement > PacketQueue
PacketQueue typedef.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
TracedCallback< Ptr< const Packet > > m_traceDequeue
dequeue trace callback
uint32_t GetSize(void) const
Get size function.
Ptr< Packet > CreateFragment(uint32_t start, uint32_t length) const
Create a new packet which contains a fragment of the original packet.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
uint32_t GetNBytes(void) const
Get number of bytes in queue.
GenericMacHeader m_hdr
header
void SetFragmentOffset(uint32_t offset)
Set fragment offset.
uint32_t GetMaxSize(void) const
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Ptr< Packet > Peek(GenericMacHeader &hdr) const
Exclusively for BS.
Hold an unsigned integer type.
void SetFragmentation(void)
Set fragmentation.
TracedCallback< Ptr< const Packet > > m_traceEnqueue
enqueue trace callback
void SetFragmentNumber(void)
Set fragment number.
uint32_t GetQueueLengthWithMACOverhead(void)
Get queue length considering also the MAC overhead.
bool CheckForFragmentation(MacHeaderType::HeaderType packetType)
Check for fragmentation of the first packet of the specified type.
uint32_t m_fragmentNumber
incremented when a new fragment is sent
bool Enqueue(Ptr< Packet > packet, const MacHeaderType &hdrType, const GenericMacHeader &hdr)
Enqueue a packet.
uint32_t GetFirstPacketRequiredByte(MacHeaderType::HeaderType packetType)
Get required number of bytes to hold first packet of packetType.
PacketQueue m_queue
the queue
Time m_timeStamp
timestamp
uint32_t m_nrRequestPackets
number request packets
MacHeaderType m_hdrType
header type
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t m_fragmentOffset
tracks the start of the next fragment into the packet
Ptr< Packet > Copy(void) const
performs a COW copy of the packet.
uint32_t m_nrDataPackets
number data packets
void SetFragmentation(MacHeaderType::HeaderType packetType)
Set fragmentation function.
bool IsEmpty(void) const
Check if queue is empty.
WimaxMacQueue::QueueElement Front(MacHeaderType::HeaderType packetType) const
In the case of non-UGS service flows at the SS side the queue will store both data packets and bandw...
bool m_fragmentation
To manage fragmentation feature, each QueueElement have 3 new fields: m_fragmentation that becomes ...
Ptr< T > Create(void)
Create class instances by constructors with varying numbers of arguments and return them by Ptr...
static Time Now(void)
Return the current simulation virtual time.
void SetMaxSize(uint32_t maxSize)
set the maximum queue size
Time Seconds(double value)
Construct a Time in the indicated unit.
static TypeId GetTypeId(void)
Get the type ID.
void Pop(MacHeaderType::HeaderType packetType)
Pop function.
void SetFragmentNumber(MacHeaderType::HeaderType packetType)
Set fragment number for first packet of type 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)
Get first packet payload size of the specified type.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
uint32_t m_maxSize
maximum size
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void AddHeader(const Header &header)
Add header to this packet.