A Discrete-Event Network Simulator
API
bs-scheduler.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2007,2008 INRIA
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
18  */
19 
20 #include "bs-scheduler.h"
21 
22 #include "bs-net-device.h"
23 #include "burst-profile-manager.h"
24 #include "cid.h"
25 #include "connection-manager.h"
26 #include "service-flow-manager.h"
27 #include "service-flow-record.h"
28 #include "service-flow.h"
29 #include "ss-manager.h"
30 #include "ss-record.h"
31 #include "wimax-connection.h"
32 #include "wimax-mac-header.h"
33 #include "wimax-mac-queue.h"
34 
35 #include "ns3/log.h"
36 #include "ns3/packet-burst.h"
37 #include "ns3/simulator.h"
38 
39 namespace ns3
40 {
41 
42 NS_LOG_COMPONENT_DEFINE("BSScheduler");
43 
44 NS_OBJECT_ENSURE_REGISTERED(BSScheduler);
45 
46 TypeId
48 {
49  static TypeId tid = TypeId("ns3::BSScheduler").SetParent<Object>().SetGroupName("Wimax")
50  // No AddConstructor because this is an abstract class.
51  ;
52  return tid;
53 }
54 
56  : m_downlinkBursts(new std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst>>>())
57 {
58  // m_downlinkBursts is filled by AddDownlinkBurst and emptied by
59  // wimax-bs-net-device::sendBurst and wimax-ss-net-device::sendBurst
60 }
61 
63  : m_downlinkBursts(new std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst>>>())
64 {
65 }
66 
68 {
69  std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst>>>* downlinkBursts = m_downlinkBursts;
70  std::pair<OfdmDlMapIe*, Ptr<PacketBurst>> pair;
71  while (!downlinkBursts->empty())
72  {
73  pair = downlinkBursts->front();
74  pair.second = nullptr;
75  delete pair.first;
76  }
77  SetBs(nullptr);
78  delete m_downlinkBursts;
79  m_downlinkBursts = nullptr;
80 }
81 
82 void
84 {
85  m_bs = bs;
86 }
87 
90 {
91  return m_bs;
92 }
93 
94 bool
96  int availableSymbols,
97  WimaxPhy::ModulationType modulationType)
98 {
99  NS_LOG_INFO("BS Scheduler, CheckForFragmentation");
100  if (connection->GetType() != Cid::TRANSPORT)
101  {
102  NS_LOG_INFO("\t No Transport connection, Fragmentation IS NOT possible");
103  return false;
104  }
105  uint32_t availableByte = GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType);
106 
107  uint32_t headerSize =
108  connection->GetQueue()->GetFirstPacketHdrSize(MacHeaderType::HEADER_TYPE_GENERIC);
109  NS_LOG_INFO("\t availableByte = " << availableByte << " headerSize = " << headerSize);
110 
111  if (availableByte > headerSize)
112  {
113  NS_LOG_INFO("\t Fragmentation IS possible");
114  return true;
115  }
116  else
117  {
118  NS_LOG_INFO("\t Fragmentation IS NOT possible");
119  return false;
120  }
121 }
122 } // namespace ns3
~BSScheduler() override
Definition: bs-scheduler.cc:67
virtual Ptr< BaseStationNetDevice > GetBs()
Get the base station.
Definition: bs-scheduler.cc:89
virtual void SetBs(Ptr< BaseStationNetDevice > bs)
Set the base station.
Definition: bs-scheduler.cc:83
Ptr< BaseStationNetDevice > m_bs
base station
Definition: bs-scheduler.h:129
static TypeId GetTypeId()
Get the type ID.
Definition: bs-scheduler.cc:47
std::list< std::pair< OfdmDlMapIe *, Ptr< PacketBurst > > > * m_downlinkBursts
down link bursts
Definition: bs-scheduler.h:130
bool CheckForFragmentation(Ptr< WimaxConnection > connection, int availableSymbols, WimaxPhy::ModulationType modulationType)
Check if the packet fragmentation is possible for transport connection.
Definition: bs-scheduler.cc:95
@ TRANSPORT
Definition: cid.h:46
A base class which provides memory management and object aggregation.
Definition: object.h:89
This class implements the OFDM DL-MAP information element as described by "IEEE Standard for Local an...
this class implement a burst as a list of packets
Definition: packet-burst.h:37
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:931
ModulationType
ModulationType enumeration.
Definition: wimax-phy.h:54
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:275
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:46
Every class exported by the ns3 library is enclosed in the ns3 namespace.
#define list