A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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);
66
Ptr<Packet>
Dequeue
(
MacHeaderType::HeaderType
packetType);
74
Ptr<Packet>
Dequeue
(
MacHeaderType::HeaderType
packetType,
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
110
bool
CheckForFragmentation
(
MacHeaderType::HeaderType
packetType);
111
uint32_t
GetFirstPacketHdrSize
(
MacHeaderType::HeaderType
packetType);
112
uint32_t
GetFirstPacketPayloadSize
(
MacHeaderType::HeaderType
packetType);
113
uint32_t
GetFirstPacketRequiredByte
(
MacHeaderType::HeaderType
packetType);
114
115
uint32_t
GetQueueLengthWithMACOverhead
(
void
);
116
117
void
SetFragmentation
(
MacHeaderType::HeaderType
packetType);
118
void
SetFragmentNumber
(
MacHeaderType::HeaderType
packetType);
119
void
SetFragmentOffset
(
MacHeaderType::HeaderType
packetType, uint32_t offset);
120
121
struct
QueueElement
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
;
129
Ptr<Packet>
m_packet
;
130
MacHeaderType
m_hdrType
;
131
GenericMacHeader
m_hdr
;
132
Time
m_timeStamp
;
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
*/
140
bool
m_fragmentation
;
141
uint32_t
m_fragmentNumber
;
142
uint32_t
m_fragmentOffset
;
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
*/
158
WimaxMacQueue::QueueElement
Front
(
MacHeaderType::HeaderType
packetType)
const
;
159
void
Pop
(
MacHeaderType::HeaderType
packetType);
160
161
typedef
std::deque<QueueElement>
PacketQueue
;
162
PacketQueue
m_queue
;
163
uint32_t
m_maxSize
;
164
uint32_t
m_bytes
;
165
uint32_t
m_nrDataPackets
;
166
uint32_t
m_nrRequestPackets
;
167
168
TracedCallback<Ptr<const Packet>
>
m_traceEnqueue
;
169
TracedCallback<Ptr<const Packet>
>
m_traceDequeue
;
170
TracedCallback<Ptr<const Packet>
>
m_traceDrop
;
171
public
:
172
const
WimaxMacQueue::PacketQueue
&
GetPacketQueue
(
void
)
const
;
173
};
174
175
}
// namespace ns3
176
177
#endif
/* WIMAX_MAC_QUEUE_H */
src
wimax
model
wimax-mac-queue.h
Generated on Tue Nov 13 2012 10:32:26 for ns-3 by
1.8.1.2