A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
37 class WimaxMacQueue : public Object
38 {
39 public:
40  static TypeId GetTypeId (void);
41  WimaxMacQueue (void);
42  WimaxMacQueue (uint32_t maxSize);
43  ~WimaxMacQueue (void);
48  void SetMaxSize (uint32_t maxSize);
52  uint32_t GetMaxSize (void) const;
59  bool Enqueue (Ptr<Packet> packet, const MacHeaderType &hdrType,
60  const GenericMacHeader &hdr);
75  uint32_t availableByte);
76 
86  Ptr<Packet> Peek (GenericMacHeader &hdr) const;
87  Ptr<Packet> Peek (GenericMacHeader &hdr, Time &timeStamp) const;
88 
93  Ptr<Packet> Peek (MacHeaderType::HeaderType packetType) const;
94  Ptr<Packet> Peek (MacHeaderType::HeaderType packetType, Time &timeStamp) const;
95 
96 
97  bool IsEmpty (void) const;
98 
99  /*
100  Exclusive for SS.
101  */
102  bool IsEmpty (MacHeaderType::HeaderType packetType) const;
103 
104  uint32_t GetSize (void) const;
105  uint32_t GetNBytes (void) const;
106 
111  uint32_t GetFirstPacketHdrSize (MacHeaderType::HeaderType packetType);
114 
115  uint32_t GetQueueLengthWithMACOverhead (void);
116 
119  void SetFragmentOffset (MacHeaderType::HeaderType packetType, uint32_t offset);
120 
122  {
123  QueueElement (void);
124  QueueElement (Ptr<Packet> packet,
125  const MacHeaderType &hdrType,
126  const GenericMacHeader &hdr,
127  Time timeStamp);
128  uint32_t GetSize (void) const;
133 
134  /*
135  To manage fragmentation feature, each QueueElement have 3 new fields:
136  m_fragmentation that became true when the fragmentation starts;
137  m_fragmentNumber that are incremented when a new fragment is sent
138  m_fragmentOffset that describe the start of the next fragment into the packet
139  */
143 
144  void SetFragmentation (void);
145  void SetFragmentNumber (void);
146  void SetFragmentOffset (uint32_t offset);
147  };
148 
149 private:
150 
151  /*
152  In the case of non-UGS service flows at the SS side the queue will store both data packets
153  and bandwidth request packets. The two are distinguished by their headers. The below two functions
154  are for this purpose exclusively. The Front function returns the first packet of a specific packet
155  type from the queue (which may not necessarily be at the front of the queue), and the Pop function
156  pops that elements.
157  */
159  void Pop (MacHeaderType::HeaderType packetType);
160 
161  typedef std::deque<QueueElement> PacketQueue;
163  uint32_t m_maxSize;
164  uint32_t m_bytes;
165  uint32_t m_nrDataPackets;
167 
171 public:
172  const WimaxMacQueue::PacketQueue & GetPacketQueue (void) const;
173 };
174 
175 } // namespace ns3
176 
177 #endif /* WIMAX_MAC_QUEUE_H */
HeaderType
this class implements the mac header type field.
uint32_t GetFirstPacketHdrSize(MacHeaderType::HeaderType packetType)
void SetFragmentOffset(MacHeaderType::HeaderType packetType, uint32_t offset)
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
TracedCallback< Ptr< const Packet > > m_traceDrop
std::deque< QueueElement > PacketQueue
TracedCallback< Ptr< const Packet > > m_traceDequeue
forward calls to a chain of CallbackAn ns3::TracedCallback has almost exactly the same API as a norma...
uint32_t GetNBytes(void) const
Ptr< Packet > Peek(GenericMacHeader &hdr) const
Same as Dequeue but does not pop from queue.
void SetFragmentOffset(uint32_t offset)
this class implements the Generic mac Header as described by IEEE Standard for Local and metropolitan...
uint32_t GetSize(void) const
TracedCallback< Ptr< const Packet > > m_traceEnqueue
uint32_t GetQueueLengthWithMACOverhead(void)
bool CheckForFragmentation(MacHeaderType::HeaderType packetType)
Fragmentation utilities.
bool Enqueue(Ptr< Packet > packet, const MacHeaderType &hdrType, const GenericMacHeader &hdr)
Enqueue a packet.
uint32_t GetFirstPacketRequiredByte(MacHeaderType::HeaderType packetType)
Represents the HT (Header Type) field of generic MAC and bandwidth request headers.
bool IsEmpty(void) const
WimaxMacQueue::QueueElement Front(MacHeaderType::HeaderType packetType) const
void SetFragmentation(MacHeaderType::HeaderType packetType)
uint32_t GetMaxSize(void) const
void SetMaxSize(uint32_t maxSize)
set the maximum queue size
const WimaxMacQueue::PacketQueue & GetPacketQueue(void) const
static TypeId GetTypeId(void)
void Pop(MacHeaderType::HeaderType packetType)
void SetFragmentNumber(MacHeaderType::HeaderType packetType)
a base class which provides memory management and object aggregation
Definition: object.h:64
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.
Definition: type-id.h:49