A Discrete-Event Network Simulator
API
wimax-mac-queue.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007,2008 INRIA
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
19  */
20 
21 #ifndef WIMAX_MAC_QUEUE_H
22 #define WIMAX_MAC_QUEUE_H
23 
24 #include <queue>
25 #include <stdint.h>
26 #include "wimax-mac-header.h"
27 #include "ns3/packet.h"
28 #include "ns3/object.h"
29 #include "ns3/traced-callback.h"
30 #include "ns3/nstime.h"
31 
32 namespace ns3 {
33 
38 class WimaxMacQueue : public Object
39 {
40 public:
45  static TypeId GetTypeId (void);
46  WimaxMacQueue (void);
52  WimaxMacQueue (uint32_t maxSize);
53  ~WimaxMacQueue (void);
58  void SetMaxSize (uint32_t maxSize);
62  uint32_t GetMaxSize (void) const;
70  bool Enqueue (Ptr<Packet> packet, const MacHeaderType &hdrType,
71  const GenericMacHeader &hdr);
85  uint32_t availableByte);
86 
94  Ptr<Packet> Peek (GenericMacHeader &hdr) const;
103  Ptr<Packet> Peek (GenericMacHeader &hdr, Time &timeStamp) const;
104 
111  Ptr<Packet> Peek (MacHeaderType::HeaderType packetType) const;
119  Ptr<Packet> Peek (MacHeaderType::HeaderType packetType, Time &timeStamp) const;
120 
125  bool IsEmpty (void) const;
126 
132  bool IsEmpty (MacHeaderType::HeaderType packetType) const;
133 
138  uint32_t GetSize (void) const;
143  uint32_t GetNBytes (void) const;
144 
156  uint32_t GetFirstPacketHdrSize (MacHeaderType::HeaderType packetType);
173  uint32_t GetQueueLengthWithMACOverhead (void);
175 
190  void SetFragmentOffset (MacHeaderType::HeaderType packetType, uint32_t offset);
191 
194  {
195  QueueElement (void);
204  QueueElement (Ptr<Packet> packet,
205  const MacHeaderType &hdrType,
206  const GenericMacHeader &hdr,
207  Time timeStamp);
212  uint32_t GetSize (void) const;
217 
225  uint32_t m_fragmentNumber;
226  uint32_t m_fragmentOffset;
227 
229  void SetFragmentation (void);
231  void SetFragmentNumber (void);
236  void SetFragmentOffset (uint32_t offset);
237  };
238 
239 private:
240 
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:
273  const WimaxMacQueue::PacketQueue & GetPacketQueue (void) const;
274 };
275 
276 } // namespace ns3
277 
278 #endif /* WIMAX_MAC_QUEUE_H */
uint32_t GetSize(void) const
Get size of queue.
HeaderType
Header type enumeration.
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.
Definition: nstime.h:102
TracedCallback< Ptr< const Packet > > m_traceDrop
drop trace callback
std::deque< QueueElement > PacketQueue
PacketQueue typedef.
TracedCallback< Ptr< const Packet > > m_traceDequeue
dequeue trace callback
Forward calls to a chain of Callback.
uint32_t GetSize(void) const
Get size function.
uint32_t GetNBytes(void) const
Get number of bytes in queue.
GenericMacHeader m_hdr
header
void SetFragmentOffset(uint32_t offset)
Set fragment offset.
Class implementing the device packet queue.
This class implements the Generic mac Header as described by IEEE Standard for Local and metropolitan...
uint32_t GetMaxSize(void) const
Ptr< Packet > Peek(GenericMacHeader &hdr) const
Exclusively for BS.
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.
This class Represents the HT (Header Type) field of generic MAC and bandwidth request headers...
PacketQueue m_queue
the queue
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
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 ...
void SetMaxSize(uint32_t maxSize)
set the maximum queue size
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.
QueueElement structure.
A base class which provides memory management and object aggregation.
Definition: object.h:87
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.
uint32_t m_maxSize
maximum size
a unique identifier for an interface.
Definition: type-id.h:58
uint32_t m_bytes
bytes