A Discrete-Event Network Simulator
API
wimax-connection.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008, 2009 INRIA, UDcast
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 * Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
18 * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
19 */
20
21#include "wimax-connection.h"
22
23#include "service-flow.h"
24
25#include "ns3/enum.h"
26#include "ns3/pointer.h"
27#include "ns3/uinteger.h"
28
29namespace ns3
30{
31
32NS_OBJECT_ENSURE_REGISTERED(WimaxConnection);
33
34TypeId
36{
37 static TypeId tid = TypeId("ns3::WimaxConnection")
38
40
41 .SetGroupName("Wimax")
42
43 .AddAttribute("Type",
44 "Connection type",
48 "Broadcast",
50 "InitialRanging",
52 "Basic",
54 "Primary",
56 "Transport",
58 "Multicast",
60 "Padding"))
61
62 .AddAttribute("TxQueue",
63 "Transmit queue",
66 MakePointerChecker<WimaxMacQueue>());
67 return tid;
68}
69
71 : m_cid(cid),
72 m_cidType(type),
73 m_queue(CreateObject<WimaxMacQueue>(1024)),
74 m_serviceFlow(nullptr)
75{
76}
77
79{
80}
81
82void
84{
85 m_queue = nullptr;
86 // m_serviceFlow = 0;
87}
88
89Cid
91{
92 return m_cid;
93}
94
95enum Cid::Type
97{
98 return m_cidType;
99}
100
103{
104 return m_queue;
105}
106
107void
109{
110 m_serviceFlow = serviceFlow;
111}
112
115{
116 return m_serviceFlow;
117}
118
119uint8_t
121{
123}
124
125bool
127 const MacHeaderType& hdrType,
128 const GenericMacHeader& hdr)
129{
130 return m_queue->Enqueue(packet, hdrType, hdr);
131}
132
135{
136 return m_queue->Dequeue(packetType);
137}
138
141{
142 return m_queue->Dequeue(packetType, availableByte);
143}
144
145bool
147{
148 return !m_queue->IsEmpty();
149}
150
151bool
153{
154 return !m_queue->IsEmpty(packetType);
155}
156
157std::string
159{
160 switch (m_cidType)
161 {
162 case Cid::BROADCAST:
163 return "Broadcast";
164 break;
166 return "Initial Ranging";
167 break;
168 case Cid::BASIC:
169 return "Basic";
170 break;
171 case Cid::PRIMARY:
172 return "Primary";
173 break;
174 case Cid::TRANSPORT:
175 return "Transport";
176 break;
177 case Cid::MULTICAST:
178 return "Multicast";
179 break;
180 default:
181 NS_FATAL_ERROR("Invalid connection type");
182 }
183
184 return "";
185}
186
187// Defragmentation Function
190{
191 return m_fragmentsQueue;
192}
193
194void
196{
197 m_fragmentsQueue.push_back(fragment);
198}
199
200void
202{
203 m_fragmentsQueue.clear();
204}
205} // namespace ns3
Cid class.
Definition: cid.h:37
Type
Type enumeration.
Definition: cid.h:41
@ PRIMARY
Definition: cid.h:45
@ BROADCAST
Definition: cid.h:42
@ TRANSPORT
Definition: cid.h:46
@ MULTICAST
Definition: cid.h:47
@ BASIC
Definition: cid.h:44
@ PADDING
Definition: cid.h:48
@ INITIAL_RANGING
Definition: cid.h:43
Hold variables of type enum.
Definition: enum.h:56
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
Hold objects of type Ptr<T>.
Definition: pointer.h:37
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:43
enum ServiceFlow::SchedulingType GetSchedulingType() const
Get scheduling type.
a unique identifier for an interface.
Definition: type-id.h:60
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:935
ServiceFlow * m_serviceFlow
service flow
bool Enqueue(Ptr< Packet > packet, const MacHeaderType &hdrType, const GenericMacHeader &hdr)
enqueue a packet in the queue of the connection
WimaxConnection(Cid cid, enum Cid::Type type)
Constructor.
std::string GetTypeStr() const
Get type string.
ServiceFlow * GetServiceFlow() const
void DoDispose() override
Destructor implementation.
Ptr< Packet > Dequeue(MacHeaderType::HeaderType packetType=MacHeaderType::HEADER_TYPE_GENERIC)
dequeue a packet from the queue of the connection
void ClearFragmentsQueue()
delete all enqueued fragments
Cid GetCid() const
Get CID function.
uint8_t GetSchedulingType() const
enum Cid::Type m_cidType
CID type.
void SetServiceFlow(ServiceFlow *serviceFlow)
set the service flow associated to this connection
Ptr< WimaxMacQueue > GetQueue() const
Ptr< WimaxMacQueue > m_queue
queue
static TypeId GetTypeId()
Get the type ID.
enum Cid::Type GetType() const
Get type function.
std::list< Ptr< const Packet > > FragmentsQueue
Definition of Fragments Queue data type.
FragmentsQueue m_fragmentsQueue
fragments queue
const FragmentsQueue GetFragmentsQueue() const
get a queue of received fragments
void FragmentEnqueue(Ptr< const Packet > fragment)
enqueue a received packet (that is a fragment) into the fragments queue
Class implementing the device packet queue.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition: enum.h:205
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Definition: pointer.h:230
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:160
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition: object.h:579
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeEnumChecker(int v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition: enum.h:163