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