A Discrete-Event Network Simulator
API
wimax-connection.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2007,2008, 2009 INRIA, UDcast
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 * Authors: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
19 * Mohamed Amine Ismail <amine.ismail@sophia.inria.fr>
20 */
21
22#include "wimax-connection.h"
23#include "ns3/pointer.h"
24#include "ns3/enum.h"
25#include "ns3/uinteger.h"
26#include "service-flow.h"
27
28namespace ns3 {
29
30NS_OBJECT_ENSURE_REGISTERED (WimaxConnection);
31
33{
34 static TypeId tid = TypeId ("ns3::WimaxConnection")
35
36 .SetParent<Object> ()
37
38 .SetGroupName("Wimax")
39
40 .AddAttribute ("Type",
41 "Connection type",
45 "Broadcast",
47 "InitialRanging",
49 "Basic",
51 "Primary",
53 "Transport",
55 "Multicast",
57 "Padding"))
58
59 .AddAttribute ("TxQueue",
60 "Transmit queue",
61 PointerValue (),
63 MakePointerChecker<WimaxMacQueue> ());
64 return tid;
65}
66
68 : m_cid (cid),
69 m_cidType (type),
70 m_queue (CreateObject<WimaxMacQueue> (1024)),
71 m_serviceFlow (0)
72{
73}
74
76{
77}
78
79void
81{
82 m_queue = 0;
83 // m_serviceFlow = 0;
84}
85
86Cid
88{
89 return m_cid;
90}
91
92enum Cid::Type
94{
95 return m_cidType;
96}
97
100{
101 return m_queue;
102}
103
104void
106{
107 m_serviceFlow = serviceFlow;
108}
109
112{
113 return m_serviceFlow;
114}
115
116uint8_t
118{
120}
121
122bool
124{
125
126 return m_queue->Enqueue (packet, hdrType, hdr);
127}
128
131{
132 return m_queue->Dequeue (packetType);
133}
134
137{
138 return m_queue->Dequeue (packetType, availableByte);
139}
140
141bool
143{
144 return !m_queue->IsEmpty ();
145}
146
147bool
149{
150 return !m_queue->IsEmpty (packetType);
151}
152
153std::string
155{
156 switch (m_cidType)
157 {
158 case Cid::BROADCAST:
159 return "Broadcast";
160 break;
162 return "Initial Ranging";
163 break;
164 case Cid::BASIC:
165 return "Basic";
166 break;
167 case Cid::PRIMARY:
168 return "Primary";
169 break;
170 case Cid::TRANSPORT:
171 return "Transport";
172 break;
173 case Cid::MULTICAST:
174 return "Multicast";
175 break;
176 default:
177 NS_FATAL_ERROR ("Invalid connection type");
178 }
179
180 return "";
181}
182
183// Defragmentation Function
184const
186{
187 return m_fragmentsQueue;
188}
189
190void
192{
193 m_fragmentsQueue.push_back (fragment);
194}
195
196void
198{
199 m_fragmentsQueue.clear ();
200}
201} // namespace ns3
Cid class.
Definition: cid.h:38
Type
Type enumeration.
Definition: cid.h:42
@ PRIMARY
Definition: cid.h:46
@ BROADCAST
Definition: cid.h:43
@ TRANSPORT
Definition: cid.h:47
@ MULTICAST
Definition: cid.h:48
@ BASIC
Definition: cid.h:45
@ PADDING
Definition: cid.h:49
@ INITIAL_RANGING
Definition: cid.h:44
Hold variables of type enum.
Definition: enum.h:55
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:88
Hold objects of type Ptr<T>.
Definition: pointer.h:37
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:40
enum ServiceFlow::SchedulingType GetSchedulingType(void) 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:922
virtual void DoDispose(void)
Destructor implementation.
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.
Ptr< WimaxMacQueue > GetQueue(void) const
Ptr< Packet > Dequeue(MacHeaderType::HeaderType packetType=MacHeaderType::HEADER_TYPE_GENERIC)
dequeue a packet from the queue of the connection
std::string GetTypeStr(void) const
Get type string.
void ClearFragmentsQueue(void)
delete all enqueued fragments
enum Cid::Type m_cidType
CID type.
uint8_t GetSchedulingType(void) const
void SetServiceFlow(ServiceFlow *serviceFlow)
set the service flow associated to this connection
Ptr< WimaxMacQueue > m_queue
queue
enum Cid::Type GetType(void) const
Get type function.
bool HasPackets(void) const
std::list< Ptr< const Packet > > FragmentsQueue
Definition of Fragments Queue data type.
const FragmentsQueue GetFragmentsQueue(void) const
get a queue of received fragments
FragmentsQueue m_fragmentsQueue
fragments queue
static TypeId GetTypeId(void)
Get the type ID.
Cid GetCid(void) const
Get CID function.
void FragmentEnqueue(Ptr< const Packet > fragment)
enqueue a received packet (that is a fragment) into the fragments queue
ServiceFlow * GetServiceFlow(void) const
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:227
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition: object.h:576
#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:162