A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("BurstProfileManager");
31 
32 namespace ns3 {
33 
34 NS_OBJECT_ENSURE_REGISTERED (BurstProfileManager);
35 
37 {
38  static TypeId tid = TypeId ("ns3::BurstProfileManager")
39  .SetParent<Object> ();
40  return tid;
41 }
42 
44  : m_device (device)
45 {
46 }
47 
49 {
50  m_device = 0;
51 }
52 
53 void
55 {
56  m_device = 0;
57 }
58 
59 
61 {
62  /*
63  * 7 modulation types
64  */
65  return 7;
66 }
67 
70  WimaxNetDevice::Direction direction) const
71 {
72  if (direction == WimaxNetDevice::DIRECTION_DOWNLINK)
73  {
74  std::vector<OfdmDlBurstProfile> dlBurstProfiles =
76  for (std::vector<OfdmDlBurstProfile>::iterator iter =
77  dlBurstProfiles.begin (); iter != dlBurstProfiles.end (); ++iter)
78  {
79  if (iter->GetDiuc () == iuc)
80  {
81  return (WimaxPhy::ModulationType) iter->GetFecCodeType ();
82  }
83  }
84  }
85  else
86  {
87  std::vector<OfdmUlBurstProfile> ulBurstProfiles =
89  for (std::vector<OfdmUlBurstProfile>::iterator iter =
90  ulBurstProfiles.begin (); iter != ulBurstProfiles.end (); ++iter)
91  {
92  if (iter->GetUiuc () == iuc)
93  {
94  return (WimaxPhy::ModulationType) iter->GetFecCodeType ();
95  }
96  }
97  }
98 
99  // burst profile got to be there in DCD/UCD, assuming always all profiles are defined in DCD/UCD
100  NS_FATAL_ERROR ("burst profile got to be there in DCD/UCD");
101 
102  return (WimaxPhy::ModulationType) -1;
103 }
104 
105 uint8_t
107  WimaxPhy::ModulationType modulationType,
108  WimaxNetDevice::Direction direction) const
109 {
110  if (direction == WimaxNetDevice::DIRECTION_DOWNLINK)
111  {
112  std::vector<OfdmDlBurstProfile> dlBurstProfiles =
114  for (std::vector<OfdmDlBurstProfile>::iterator iter =
115  dlBurstProfiles.begin (); iter != dlBurstProfiles.end (); ++iter)
116  {
117  if (iter->GetFecCodeType () == modulationType)
118  {
119  return iter->GetDiuc ();
120  }
121  }
122  }
123  else
124  {
125  std::vector<OfdmUlBurstProfile> ulBurstProfiles =
127  for (std::vector<OfdmUlBurstProfile>::iterator iter =
128  ulBurstProfiles.begin (); iter != ulBurstProfiles.end (); ++iter)
129  {
130  if (iter->GetFecCodeType () == modulationType)
131  {
132  return iter->GetUiuc ();
133  }
134  }
135  }
136 
137  // burst profile got to be there in DCD/UCD, assuming always all profiles are defined in DCD/UCD
138  NS_FATAL_ERROR ("burst profile got to be there in DCD/UCD");
139 
140  return ~0;
141 }
142 
143 uint8_t
145  const RngReq *rngreq, WimaxPhy::ModulationType &modulationType)
146 {
147  /*during initial ranging or periodic ranging (or when RNG-REQ is used instead of
148  DBPC) calculates the least robust burst profile for SS, e.g., based on distance,
149  power, signal etc, temporarily choosing same burst profile SS requested in RNG-REQ*/
150 
151  modulationType = GetModulationTypeForSS (ssRecord, rngreq);
152  return GetBurstProfile (modulationType, WimaxNetDevice::DIRECTION_DOWNLINK);
153 }
154 
157 {
158 
159  return GetModulationType (rngreq->GetReqDlBurstProfile (),
161 }
162 
163 uint8_t
165 {
166  /*modulation type is currently set by user in simulation script, shall
167  actually be determined based on SS's distance, power, signal etc*/
168 
169  return GetBurstProfile (
172 }
173 
174 } // namespace ns3