A Discrete-Event Network Simulator
API
wimax-mac-queue.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007,2008 INRIA
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
18  */
19 
20 #ifndef WIMAX_MAC_QUEUE_H
21 #define WIMAX_MAC_QUEUE_H
22 
23 #include "wimax-mac-header.h"
24 
25 #include "ns3/nstime.h"
26 #include "ns3/object.h"
27 #include "ns3/packet.h"
28 #include "ns3/traced-callback.h"
29 
30 #include <queue>
31 #include <stdint.h>
32 
33 namespace ns3
34 {
35 
40 class WimaxMacQueue : public Object
41 {
42  public:
47  static TypeId GetTypeId();
48  WimaxMacQueue();
54  WimaxMacQueue(uint32_t maxSize);
55  ~WimaxMacQueue() override;
60  void SetMaxSize(uint32_t maxSize);
64  uint32_t GetMaxSize() const;
72  bool Enqueue(Ptr<Packet> packet, const MacHeaderType& hdrType, const GenericMacHeader& hdr);
86  Ptr<Packet> Dequeue(MacHeaderType::HeaderType packetType, uint32_t availableByte);
87 
95  Ptr<Packet> Peek(GenericMacHeader& hdr) const;
104  Ptr<Packet> Peek(GenericMacHeader& hdr, Time& timeStamp) const;
105 
112  Ptr<Packet> Peek(MacHeaderType::HeaderType packetType) const;
120  Ptr<Packet> Peek(MacHeaderType::HeaderType packetType, Time& timeStamp) const;
121 
126  bool IsEmpty() const;
127 
133  bool IsEmpty(MacHeaderType::HeaderType packetType) const;
134 
139  uint32_t GetSize() const;
144  uint32_t GetNBytes() const;
145 
176 
191  void SetFragmentOffset(MacHeaderType::HeaderType packetType, uint32_t offset);
192 
195  {
196  QueueElement();
205  QueueElement(Ptr<Packet> packet,
206  const MacHeaderType& hdrType,
207  const GenericMacHeader& hdr,
208  Time timeStamp);
213  uint32_t GetSize() const;
218 
226  uint32_t m_fragmentNumber;
227  uint32_t m_fragmentOffset;
228 
230  void SetFragmentation();
232  void SetFragmentNumber();
237  void SetFragmentOffset(uint32_t offset);
238  };
239 
240  private:
255  void Pop(MacHeaderType::HeaderType packetType);
256 
258  typedef std::deque<QueueElement> PacketQueue;
260  uint32_t m_maxSize;
261  uint32_t m_bytes;
262  uint32_t m_nrDataPackets;
264 
268  public:
274 };
275 
276 } // namespace ns3
277 
278 #endif /* WIMAX_MAC_QUEUE_H */
This class implements the Generic mac Header as described by IEEE Standard for Local and metropolitan...
This class Represents the HT (Header Type) field of generic MAC and bandwidth request headers.
HeaderType
Header type enumeration.
A base class which provides memory management and object aggregation.
Definition: object.h:89
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
Class implementing the device packet queue.
std::deque< QueueElement > PacketQueue
PacketQueue typedef.
Ptr< Packet > Peek(GenericMacHeader &hdr) const
Exclusively for BS.
uint32_t GetFirstPacketPayloadSize(MacHeaderType::HeaderType packetType)
Get first packet payload size of the specified type.
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 bandwi...
void Pop(MacHeaderType::HeaderType packetType)
Pop function.
void SetMaxSize(uint32_t maxSize)
set the maximum queue size
TracedCallback< Ptr< const Packet > > m_traceDequeue
dequeue trace callback
uint32_t GetFirstPacketRequiredByte(MacHeaderType::HeaderType packetType)
Get required number of bytes to hold first packet of packetType.
Ptr< Packet > Dequeue(MacHeaderType::HeaderType packetType)
Dequeue a packet of type packetType from the queue.
TracedCallback< Ptr< const Packet > > m_traceEnqueue
enqueue trace callback
uint32_t GetNBytes() const
Get number of bytes in queue.
static TypeId GetTypeId()
Get the type ID.
uint32_t GetFirstPacketHdrSize(MacHeaderType::HeaderType packetType)
Get first packet header size of the specified type.
uint32_t m_bytes
bytes
void SetFragmentNumber(MacHeaderType::HeaderType packetType)
Set fragment number for first packet of type packetType.
void SetFragmentation(MacHeaderType::HeaderType packetType)
Set fragmentation function.
void SetFragmentOffset(MacHeaderType::HeaderType packetType, uint32_t offset)
Set fragment offset for first packet of type packetType.
bool CheckForFragmentation(MacHeaderType::HeaderType packetType)
Check for fragmentation of the first packet of the specified type.
uint32_t m_nrDataPackets
number data packets
uint32_t m_maxSize
maximum size
bool Enqueue(Ptr< Packet > packet, const MacHeaderType &hdrType, const GenericMacHeader &hdr)
Enqueue a packet.
PacketQueue m_queue
the queue
uint32_t m_nrRequestPackets
number request packets
uint32_t GetQueueLengthWithMACOverhead()
Get queue length considering also the MAC overhead.
bool IsEmpty() const
Check if queue is empty.
const WimaxMacQueue::PacketQueue & GetPacketQueue() const
Get packet queue function.
TracedCallback< Ptr< const Packet > > m_traceDrop
drop trace callback
uint32_t GetMaxSize() const
uint32_t GetSize() const
Get size of queue.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t m_fragmentNumber
incremented when a new fragment is sent
uint32_t GetSize() const
Get size function.
uint32_t m_fragmentOffset
tracks the start of the next fragment into the packet
bool m_fragmentation
To manage fragmentation feature, each QueueElement have 3 new fields: m_fragmentation that becomes tr...
void SetFragmentNumber()
Set fragment number.
MacHeaderType m_hdrType
header type
GenericMacHeader m_hdr
header
void SetFragmentOffset(uint32_t offset)
Set fragment offset.
void SetFragmentation()
Set fragmentation.