22 #include "ns3/simulator.h"
24 #include "ns3/packet-burst.h"
66 std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > > *downlinkBursts =
m_downlinkBursts;
67 std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > pair;
68 while (downlinkBursts->size ())
70 pair = downlinkBursts->front ();
79 std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > >*
91 dlMapIe->
SetCid (connection->GetCid ());
94 NS_LOG_INFO (
"BS scheduler, burst size: " << burst->GetSize () <<
" bytes" <<
", pkts: " << burst->GetNPackets ()
95 <<
", connection: " << connection->GetTypeStr () <<
", CID: " << connection->GetCid ());
98 NS_LOG_INFO (
", SFID: " << connection->GetServiceFlow ()->GetSfid () <<
", service: "
99 << connection->GetServiceFlow ()->GetSchedulingTypeStr ());
101 NS_LOG_INFO (
", modulation: " << modulationType <<
", DIUC: " << (uint32_t) diuc);
111 uint32_t nrSymbolsRequired = 0;
116 uint32_t availableSymbols =
GetBs ()->GetNrDlSymbols ();
120 if (connection !=
GetBs ()->GetInitialRangingConnection () && connection !=
GetBs ()->GetBroadcastConnection ())
125 modulationType = connection->GetServiceFlow ()->GetModulation ();
129 modulationType =
GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
131 diuc =
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
134 else if (connection ==
GetBs ()->GetInitialRangingConnection () || connection
135 ==
GetBs ()->GetBroadcastConnection ())
149 nrSymbolsRequired = connection->GetServiceFlow ()->GetRecord ()->GetGrantSize ();
150 if (nrSymbolsRequired < availableSymbols)
152 burst =
CreateUgsBurst (connection->GetServiceFlow (), modulationType, nrSymbolsRequired);
156 burst =
CreateUgsBurst (connection->GetServiceFlow (), modulationType, availableSymbols);
158 if (burst->GetNPackets () != 0)
160 uint32_t BurstSizeSymbols =
GetBs ()->GetPhy ()->GetNrSymbols (burst->GetSize (), modulationType);
163 if (availableSymbols <= BurstSizeSymbols)
165 availableSymbols -= BurstSizeSymbols;
172 burst = Create<PacketBurst> ();
173 while (connection->HasPackets () ==
true)
176 nrSymbolsRequired =
GetBs ()->GetPhy ()->GetNrSymbols (FirstPacketSize, modulationType);
181 uint32_t availableByte =
GetBs ()->GetPhy ()->GetNrBytes (availableSymbols, modulationType);
183 availableSymbols = 0;
185 else if (availableSymbols >= nrSymbolsRequired)
187 packet = connection->Dequeue ();
188 availableSymbols -= nrSymbolsRequired;
194 burst->AddPacket (packet);
198 if (availableSymbols == 0)
208 << availableSymbols << std::endl <<
"BS scheduler, queues:" <<
" IR "
209 <<
GetBs ()->GetInitialRangingConnection ()->GetQueue ()->GetSize () <<
" broadcast "
210 <<
GetBs ()->GetBroadcastConnection ()->GetQueue ()->GetSize () <<
" basic "
221 std::vector<Ptr<WimaxConnection> >::const_iterator iter1;
222 std::vector<ServiceFlow*>::iterator iter2;
224 NS_LOG_INFO (
"BS Scheduler: Selecting connection...");
225 if (
GetBs ()->GetBroadcastConnection ()->HasPackets ())
228 connection =
GetBs ()->GetBroadcastConnection ();
231 else if (
GetBs ()->GetInitialRangingConnection ()->HasPackets ())
233 NS_LOG_INFO (
"Return GetInitialRangingConnection");
234 connection =
GetBs ()->GetInitialRangingConnection ();
239 std::vector<Ptr<WimaxConnection> > connections;
240 std::vector<ServiceFlow*> serviceFlows;
242 connections =
GetBs ()->GetConnectionManager ()->GetConnections (
Cid::BASIC);
243 for (iter1 = connections.begin (); iter1 != connections.end (); ++iter1)
245 if ((*iter1)->HasPackets ())
254 for (iter1 = connections.begin (); iter1 != connections.end (); ++iter1)
256 if ((*iter1)->HasPackets ())
265 for (iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
267 serviceFlowRecord = (*iter2)->GetRecord ();
268 NS_LOG_INFO (
"processing UGS: HAS PACKET=" << (*iter2)->HasPackets () <<
"max Latency = "
269 <<
MilliSeconds ((*iter2)->GetMaximumLatency ()) <<
"Delay = " << ((currentTime
272 if ((*iter2)->HasPackets () && ((currentTime - serviceFlowRecord->
GetDlTimeStamp ())
273 +
GetBs ()->GetPhy ()->GetFrameDuration ()) >
MilliSeconds ((*iter2)->GetMaximumLatency ()))
276 connection = (*iter2)->GetConnection ();
277 NS_LOG_INFO (
"Return UGS SF: CID = " << (*iter2)->GetCid () <<
"SFID = " << (*iter2)->GetSfid ());
283 for (iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
285 serviceFlowRecord = (*iter2)->GetRecord ();
287 if ((*iter2)->HasPackets () && ((currentTime - serviceFlowRecord->
GetDlTimeStamp ())
288 +
GetBs ()->GetPhy ()->GetFrameDuration ()) >
MilliSeconds ((*iter2)->GetMaximumLatency ()))
291 connection = (*iter2)->GetConnection ();
292 NS_LOG_INFO (
"Return RTPS SF: CID = " << (*iter2)->GetCid () <<
"SFID = " << (*iter2)->GetSfid ());
298 for (iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
301 if ((*iter2)->HasPackets ())
303 NS_LOG_INFO (
"Return NRTPS SF: CID = " << (*iter2)->GetCid () <<
"SFID = " << (*iter2)->GetSfid ());
304 connection = (*iter2)->GetConnection ();
310 for (iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
313 if ((*iter2)->HasPackets ())
315 NS_LOG_INFO (
"Return BE SF: CID = " << (*iter2)->GetCid () <<
"SFID = " << (*iter2)->GetSfid ());
316 connection = (*iter2)->GetConnection ();
327 uint32_t availableSymbols)
333 uint32_t nrSymbolsRequired = 0;
340 nrSymbolsRequired =
GetBs ()->GetPhy ()->GetNrSymbols (FirstPacketSize,modulationType);
345 uint32_t availableByte =
GetBs ()->GetPhy ()->GetNrBytes (availableSymbols, modulationType);
347 availableSymbols = 0;
351 packet = connection->Dequeue ();
352 availableSymbols -= nrSymbolsRequired;
354 burst->AddPacket (packet);
355 if (availableSymbols <= 0)
Simulation virtual time values and global simulation resolution.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
this class implements a structure to manage some parameters and statistics related to a service flow ...
Ptr< PacketBurst > CreateUgsBurst(ServiceFlow *serviceFlow, WimaxPhy::ModulationType modulationType, uint32_t availableSymbols)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
bool SelectConnection(Ptr< WimaxConnection > &connection)
Ptr< WimaxConnection > GetConnection(void) const
bool CheckForFragmentation(Ptr< WimaxConnection > connection, int availableSymbols, WimaxPhy::ModulationType modulationType)
std::list< std::pair< OfdmDlMapIe *, Ptr< PacketBurst > > > * GetDownlinkBursts(void) const
void SetDiuc(uint8_t diuc)
std::list< std::pair< OfdmDlMapIe *, Ptr< PacketBurst > > > * m_downlinkBursts
Every class exported by the ns3 library is enclosed in the ns3 namespace.
This class implements service flows as described by the IEEE-802.16 standard.
virtual Ptr< BaseStationNetDevice > GetBs(void)
void AddDownlinkBurst(Ptr< const WimaxConnection > connection, uint8_t diuc, WimaxPhy::ModulationType modulationType, Ptr< PacketBurst > burst)
static Time Now(void)
Return the current simulation virtual time.
virtual void SetBs(Ptr< BaseStationNetDevice > bs)
void SetDlTimeStamp(Time dlTimeStamp)
Set the DlTimeStamp.
this class implement a burst as a list of packets
Time GetDlTimeStamp(void) const
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
A base class which provides memory management and object aggregation.
static TypeId GetTypeId(void)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Introspection did not find any typical Config paths.
bool HasPackets(void) const