A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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",
46 MakeEnumAccessor<Cid::Type>(&WimaxConnection::GetType),
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
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";
165 return "Initial Ranging";
166 case Cid::BASIC:
167 return "Basic";
168 case Cid::PRIMARY:
169 return "Primary";
170 case Cid::TRANSPORT:
171 return "Transport";
172 case Cid::MULTICAST:
173 return "Multicast";
174 default:
175 NS_FATAL_ERROR("Invalid connection type");
176 }
177
178 return "";
179}
180
181// Defragmentation Function
184{
185 return m_fragmentsQueue;
186}
187
188void
190{
191 m_fragmentsQueue.push_back(fragment);
192}
193
194void
196{
197 m_fragmentsQueue.clear();
198}
199} // 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:62
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
AttributeValue implementation for Pointer.
Definition: pointer.h:48
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:43
ServiceFlow::SchedulingType GetSchedulingType() const
Get scheduling type.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
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
std::string GetTypeStr() const
Get type string.
ServiceFlow * GetServiceFlow() const
void DoDispose() override
Destructor implementation.
Cid::Type GetType() const
Get type function.
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
WimaxConnection(Cid cid, Cid::Type type)
Constructor.
void SetServiceFlow(ServiceFlow *serviceFlow)
set the service flow associated to this connection
Ptr< WimaxMacQueue > GetQueue() const
Ptr< WimaxMacQueue > m_queue
queue
Cid::Type m_cidType
CID type.
static TypeId GetTypeId()
Get the type ID.
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 > MakePointerAccessor(T1 a1)
Definition: pointer.h:259
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:179
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition: object.h:630
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition: enum.h:189