A Discrete-Event Network Simulator
API
burst-profile-manager.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 INRIA
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  * Author: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
19  */
20 
21 #include <stdint.h>
22 #include "burst-profile-manager.h"
23 #include "bs-net-device.h"
24 #include "ss-net-device.h"
25 #include "ss-record.h"
26 #include "ss-manager.h"
27 #include "ns3/log.h"
28 #include "mac-messages.h"
29 
30 namespace ns3 {
31 
32 NS_LOG_COMPONENT_DEFINE ("BurstProfileManager");
33 
34 NS_OBJECT_ENSURE_REGISTERED (BurstProfileManager);
35 
37 {
38  static TypeId tid = TypeId ("ns3::BurstProfileManager")
39  .SetParent<Object> ()
40  .SetGroupName("Wimax");
41  return tid;
42 }
43 
45  : m_device (device)
46 {
47 }
48 
50 {
51  m_device = 0;
52 }
53 
54 void
56 {
57  m_device = 0;
58 }
59 
60 
62 {
63  /*
64  * 7 modulation types
65  */
66  return 7;
67 }
68 
71  WimaxNetDevice::Direction direction) const
72 {
73  if (direction == WimaxNetDevice::DIRECTION_DOWNLINK)
74  {
75  std::vector<OfdmDlBurstProfile> dlBurstProfiles =
76  m_device->GetCurrentDcd ().GetDlBurstProfiles ();
77  for (std::vector<OfdmDlBurstProfile>::iterator iter =
78  dlBurstProfiles.begin (); iter != dlBurstProfiles.end (); ++iter)
79  {
80  if (iter->GetDiuc () == iuc)
81  {
82  return (WimaxPhy::ModulationType) iter->GetFecCodeType ();
83  }
84  }
85  }
86  else
87  {
88  std::vector<OfdmUlBurstProfile> ulBurstProfiles =
89  m_device->GetCurrentUcd ().GetUlBurstProfiles ();
90  for (std::vector<OfdmUlBurstProfile>::iterator iter =
91  ulBurstProfiles.begin (); iter != ulBurstProfiles.end (); ++iter)
92  {
93  if (iter->GetUiuc () == iuc)
94  {
95  return (WimaxPhy::ModulationType) iter->GetFecCodeType ();
96  }
97  }
98  }
99 
100  // burst profile got to be there in DCD/UCD, assuming always all profiles are defined in DCD/UCD
101  NS_FATAL_ERROR ("burst profile got to be there in DCD/UCD");
102 
103  return (WimaxPhy::ModulationType) -1;
104 }
105 
106 uint8_t
108  WimaxPhy::ModulationType modulationType,
109  WimaxNetDevice::Direction direction) const
110 {
111  if (direction == WimaxNetDevice::DIRECTION_DOWNLINK)
112  {
113  std::vector<OfdmDlBurstProfile> dlBurstProfiles =
114  m_device->GetCurrentDcd ().GetDlBurstProfiles ();
115  for (std::vector<OfdmDlBurstProfile>::iterator iter =
116  dlBurstProfiles.begin (); iter != dlBurstProfiles.end (); ++iter)
117  {
118  if (iter->GetFecCodeType () == modulationType)
119  {
120  return iter->GetDiuc ();
121  }
122  }
123  }
124  else
125  {
126  std::vector<OfdmUlBurstProfile> ulBurstProfiles =
127  m_device->GetCurrentUcd ().GetUlBurstProfiles ();
128  for (std::vector<OfdmUlBurstProfile>::iterator iter =
129  ulBurstProfiles.begin (); iter != ulBurstProfiles.end (); ++iter)
130  {
131  if (iter->GetFecCodeType () == modulationType)
132  {
133  return iter->GetUiuc ();
134  }
135  }
136  }
137 
138  // burst profile got to be there in DCD/UCD, assuming always all profiles are defined in DCD/UCD
139  NS_FATAL_ERROR ("burst profile got to be there in DCD/UCD");
140 
141  return ~0;
142 }
143 
144 uint8_t
146  const RngReq *rngreq, WimaxPhy::ModulationType &modulationType)
147 {
148  /*during initial ranging or periodic ranging (or when RNG-REQ is used instead of
149  DBPC) calculates the least robust burst profile for SS, e.g., based on distance,
150  power, signal etc, temporarily choosing same burst profile SS requested in RNG-REQ*/
151 
152  modulationType = GetModulationTypeForSS (ssRecord, rngreq);
153  return GetBurstProfile (modulationType, WimaxNetDevice::DIRECTION_DOWNLINK);
154 }
155 
158 {
159 
160  return GetModulationType (rngreq->GetReqDlBurstProfile (),
162 }
163 
164 uint8_t
166 {
167  /*modulation type is currently set by user in simulation script, shall
168  actually be determined based on SS's distance, power, signal etc*/
169 
170  return GetBurstProfile (
173 }
174 
175 } // namespace ns3
Ptr< WimaxNetDevice > m_device
the device
void DoDispose(void)
Destructor implementation.
uint16_t GetNrBurstProfilesToDefine(void)
uint8_t GetBurstProfileForSS(const SSRecord *ssRecord, const RngReq *rngreq, WimaxPhy::ModulationType &modulationType)
Get burst profile for SS.
BurstProfileManager(Ptr< WimaxNetDevice > device)
Constructor.
uint8_t GetBurstProfile(WimaxPhy::ModulationType modulationType, WimaxNetDevice::Direction direction) const
returns the burst profile
uint8_t GetBurstProfileToRequest(void)
Get burst profile to request.
WimaxPhy::ModulationType GetModulationTypeForSS(const SSRecord *ssRecord, const RngReq *rngreq)
Get module ation type for SS.
static TypeId GetTypeId(void)
Get the type ID.
WimaxPhy::ModulationType GetModulationType(uint8_t iuc, WimaxNetDevice::Direction direction) const
returns the modulation type of a given iuc
A base class which provides memory management and object aggregation.
Definition: object.h:88
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
This class implements the ranging request message described by "IEEE Standard for Local and metropoli...
Definition: mac-messages.h:643
uint8_t GetReqDlBurstProfile(void) const
Get request DL burst profile field.
This class is used by the base station to store some information related to subscriber station in the...
Definition: ss-record.h:44
SubscriberStationNetDevice subclass of WimaxNetDevice.
Definition: ss-net-device.h:49
WimaxPhy::ModulationType GetModulationType(void) const
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Direction
Direction enumeration.
ModulationType
ModulationType enumeration.
Definition: wimax-phy.h:52
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:165
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#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.