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 
33 {
34  static TypeId tid = TypeId ("ns3::WimaxConnection")
35 
36  .SetParent<Object> ()
37 
38  .AddAttribute ("Type",
39  "Connection type",
43  "Broadcast",
45  "InitialRanging",
46  Cid::BASIC,
47  "Basic",
49  "Primary",
51  "Transport",
53  "Multicast",
55  "Padding"))
56 
57  .AddAttribute ("TxQueue",
58  "Transmit queue",
59  PointerValue (),
60  MakePointerAccessor (&WimaxConnection::GetQueue),
61  MakePointerChecker<WimaxMacQueue> ());
62  return tid;
63 }
64 
66  : m_cid (cid),
67  m_cidType (type),
68  m_queue (CreateObject<WimaxMacQueue> (1024)),
69  m_serviceFlow (0)
70 {
71 }
72 
74 {
75 }
76 
77 void
79 {
80  m_queue = 0;
81  // m_serviceFlow = 0;
82 }
83 
84 Cid
86 {
87  return m_cid;
88 }
89 
90 enum Cid::Type
92 {
93  return m_cidType;
94 }
95 
98 {
99  return m_queue;
100 }
101 
102 void
104 {
105  m_serviceFlow = serviceFlow;
106 }
107 
110 {
111  return m_serviceFlow;
112 }
113 
114 uint8_t
116 {
117  return m_serviceFlow->GetSchedulingType ();
118 }
119 
120 bool
122 {
123 
124  return m_queue->Enqueue (packet, hdrType, hdr);
125 }
126 
129 {
130  return m_queue->Dequeue (packetType);
131 }
132 
134 WimaxConnection::Dequeue (MacHeaderType::HeaderType packetType, uint32_t availableByte)
135 {
136  return m_queue->Dequeue (packetType, availableByte);
137 }
138 
139 bool
141 {
142  return !m_queue->IsEmpty ();
143 }
144 
145 bool
147 {
148  return !m_queue->IsEmpty (packetType);
149 }
150 
151 std::string
153 {
154  switch (m_cidType)
155  {
156  case Cid::BROADCAST:
157  return "Broadcast";
158  break;
160  return "Initial Ranging";
161  break;
162  case Cid::BASIC:
163  return "Basic";
164  break;
165  case Cid::PRIMARY:
166  return "Primary";
167  break;
168  case Cid::TRANSPORT:
169  return "Transport";
170  break;
171  case Cid::MULTICAST:
172  return "Multicast";
173  break;
174  default:
175  NS_FATAL_ERROR ("Invalid connection type");
176  }
177 
178  return "";
179 }
180 
181 // Defragmentation Function
182 const
184 {
185  return m_fragmentsQueue;
186 }
187 
188 void
190 {
191  m_fragmentsQueue.push_back (fragment);
192 }
193 
194 void
196 {
197  m_fragmentsQueue.clear ();
198 }
199 } // 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
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:419
Ptr< WimaxMacQueue > GetQueue(void) const
hold variables of type 'enum'
Definition: enum.h:37
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
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)
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
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:610
Ptr< WimaxMacQueue > m_queue