A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  ;
32 
34 {
35  static TypeId tid = TypeId ("ns3::WimaxConnection")
36 
37  .SetParent<Object> ()
38 
39  .AddAttribute ("Type",
40  "Connection type",
44  "Broadcast",
46  "InitialRanging",
47  Cid::BASIC,
48  "Basic",
50  "Primary",
52  "Transport",
54  "Multicast",
56  "Padding"))
57 
58  .AddAttribute ("TxQueue",
59  "Transmit queue",
60  PointerValue (),
61  MakePointerAccessor (&WimaxConnection::GetQueue),
62  MakePointerChecker<WimaxMacQueue> ());
63  return tid;
64 }
65 
67  : m_cid (cid),
68  m_cidType (type),
69  m_queue (CreateObject<WimaxMacQueue> (1024)),
70  m_serviceFlow (0)
71 {
72 }
73 
75 {
76 }
77 
78 void
80 {
81  m_queue = 0;
82  // m_serviceFlow = 0;
83 }
84 
85 Cid
87 {
88  return m_cid;
89 }
90 
91 enum Cid::Type
93 {
94  return m_cidType;
95 }
96 
99 {
100  return m_queue;
101 }
102 
103 void
105 {
106  m_serviceFlow = serviceFlow;
107 }
108 
111 {
112  return m_serviceFlow;
113 }
114 
115 uint8_t
117 {
118  return m_serviceFlow->GetSchedulingType ();
119 }
120 
121 bool
123 {
124 
125  return m_queue->Enqueue (packet, hdrType, hdr);
126 }
127 
130 {
131  return m_queue->Dequeue (packetType);
132 }
133 
135 WimaxConnection::Dequeue (MacHeaderType::HeaderType packetType, uint32_t availableByte)
136 {
137  return m_queue->Dequeue (packetType, availableByte);
138 }
139 
140 bool
142 {
143  return !m_queue->IsEmpty ();
144 }
145 
146 bool
148 {
149  return !m_queue->IsEmpty (packetType);
150 }
151 
152 std::string
154 {
155  switch (m_cidType)
156  {
157  case Cid::BROADCAST:
158  return "Broadcast";
159  break;
161  return "Initial Ranging";
162  break;
163  case Cid::BASIC:
164  return "Basic";
165  break;
166  case Cid::PRIMARY:
167  return "Primary";
168  break;
169  case Cid::TRANSPORT:
170  return "Transport";
171  break;
172  case Cid::MULTICAST:
173  return "Multicast";
174  break;
175  default:
176  NS_FATAL_ERROR ("Invalid connection type");
177  }
178 
179  return "";
180 }
181 
182 // Defragmentation Function
183 const
185 {
186  return m_fragmentsQueue;
187 }
188 
189 void
191 {
192  m_fragmentsQueue.push_back (fragment);
193 }
194 
195 void
197 {
198  m_fragmentsQueue.clear ();
199 }
200 } // namespace ns3
HeaderType
this class implements the mac header type field.
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
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)
Definition: enum.cc:178
enum ServiceFlow::SchedulingType GetSchedulingType(void) const
Type
Definition: cid.h:38
void FragmentEnqueue(Ptr< const Packet > fragment)
enqueue a received packet (that is a fragment) into the fragments queue
ServiceFlow * m_serviceFlow
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
enum Cid::Type m_cidType
uint8_t GetSchedulingType(void) const
ServiceFlow * GetServiceFlow(void) const
this class implements the Generic mac Header as described by IEEE Standard for Local and metropolitan...
#define NS_FATAL_ERROR(msg)
fatal error handling
Definition: fatal-error.h:72
Ptr< T > CreateObject(void)
Definition: object.h:420
Ptr< WimaxMacQueue > GetQueue(void) const
hold variables of type 'enum'
Definition: enum.h:37
WimaxConnection(Cid cid, enum Cid::Type type)
const FragmentsQueue GetFragmentsQueue(void) const
get a queue of received fragments
enum Cid::Type GetType(void) const
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
bool HasPackets(void) const
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
hold objects of type Ptr
Definition: pointer.h:33
Definition: cid.h:35
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:39
Cid GetCid(void) const
std::list< Ptr< const Packet > > FragmentsQueue
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Definition: enum.h:118
Ptr< Packet > Dequeue(MacHeaderType::HeaderType packetType=MacHeaderType::HEADER_TYPE_GENERIC)
dequeue a packet from the queue of the connection
void SetServiceFlow(ServiceFlow *serviceFlow)
set the service flow associated to this connection
FragmentsQueue m_fragmentsQueue
static TypeId GetTypeId(void)
std::string GetTypeStr(void) const
a base class which provides memory management and object aggregation
Definition: object.h:63
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
Ptr< WimaxMacQueue > m_queue