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 
28 namespace ns3 {
29 
30 NS_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",
48  Cid::BASIC,
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 
79 void
81 {
82  m_queue = 0;
83  // m_serviceFlow = 0;
84 }
85 
86 Cid
88 {
89  return m_cid;
90 }
91 
92 enum Cid::Type
94 {
95  return m_cidType;
96 }
97 
100 {
101  return m_queue;
102 }
103 
104 void
106 {
107  m_serviceFlow = serviceFlow;
108 }
109 
112 {
113  return m_serviceFlow;
114 }
115 
116 uint8_t
118 {
119  return m_serviceFlow->GetSchedulingType ();
120 }
121 
122 bool
124 {
125 
126  return m_queue->Enqueue (packet, hdrType, hdr);
127 }
128 
131 {
132  return m_queue->Dequeue (packetType);
133 }
134 
136 WimaxConnection::Dequeue (MacHeaderType::HeaderType packetType, uint32_t availableByte)
137 {
138  return m_queue->Dequeue (packetType, availableByte);
139 }
140 
141 bool
143 {
144  return !m_queue->IsEmpty ();
145 }
146 
147 bool
149 {
150  return !m_queue->IsEmpty (packetType);
151 }
152 
153 std::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
184 const
186 {
187  return m_fragmentsQueue;
188 }
189 
190 void
192 {
193  m_fragmentsQueue.push_back (fragment);
194 }
195 
196 void
198 {
199  m_fragmentsQueue.clear ();
200 }
201 } // namespace ns3
HeaderType
Header type enumeration.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
const FragmentsQueue GetFragmentsQueue(void) const
get a queue of received fragments
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Type
Type enumeration.
Definition: cid.h:41
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: enum.h:209
void FragmentEnqueue(Ptr< const Packet > fragment)
enqueue a received packet (that is a fragment) into the fragments queue
ServiceFlow * m_serviceFlow
service flow
enum Cid::Type m_cidType
CID type.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
uint8_t GetSchedulingType(void) const
Class implementing the device packet queue.
This class implements the Generic mac Header as described by IEEE Standard for Local and metropolitan...
ServiceFlow * GetServiceFlow(void) const
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
Definition: pointer.h:220
Hold variables of type enum.
Definition: enum.h:54
Cid GetCid(void) const
Get CID function.
WimaxConnection(Cid cid, enum Cid::Type type)
Constructor.
Ptr< WimaxMacQueue > GetQueue(void) const
virtual void DoDispose(void)
Destructor implementation.
This class Represents the HT (Header Type) field of generic MAC and bandwidth request headers...
void ClearFragmentsQueue(void)
delete all enqueued fragments
bool Enqueue(Ptr< Packet > packet, const MacHeaderType &hdrType, const GenericMacHeader &hdr)
enqueue a packet in the queue of the connection
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hold objects of type Ptr<T>.
Definition: pointer.h:36
Cid class.
Definition: cid.h:37
std::string GetTypeStr(void) const
Get type string.
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:39
std::list< Ptr< const Packet > > FragmentsQueue
Definition of Fragments Queue data type.
Ptr< Packet > Dequeue(MacHeaderType::HeaderType packetType=MacHeaderType::HEADER_TYPE_GENERIC)
dequeue a packet from the queue of the connection
Ptr< const AttributeChecker > MakeEnumChecker(int v1, std::string n1, int v2, std::string n2, int v3, std::string n3, int v4, std::string n4, int v5, std::string n5, int v6, std::string n6, int v7, std::string n7, int v8, std::string n8, int v9, std::string n9, int v10, std::string n10, int v11, std::string n11, int v12, std::string n12, int v13, std::string n13, int v14, std::string n14, int v15, std::string n15, int v16, std::string n16, int v17, std::string n17, int v18, std::string n18, int v19, std::string n19, int v20, std::string n20, int v21, std::string n21, int v22, std::string n22)
Make an EnumChecker pre-configured with a set of allowed values by name.
Definition: enum.cc:184
enum ServiceFlow::SchedulingType GetSchedulingType(void) const
Get scheduling type.
void SetServiceFlow(ServiceFlow *serviceFlow)
set the service flow associated to this connection
FragmentsQueue m_fragmentsQueue
fragments queue
static TypeId GetTypeId(void)
Get the type ID.
Ptr< T > CreateObject(void)
Create an object by type, with varying number of constructor parameters.
Definition: object.h:528
A base class which provides memory management and object aggregation.
Definition: object.h:87
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:915
enum Cid::Type GetType(void) const
Get type function.
bool HasPackets(void) const
Ptr< WimaxMacQueue > m_queue
queue