22 #include "ns3/simulator.h" 24 #include "ns3/packet-burst.h" 48 .SetGroupName(
"Wimax")
70 std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > > *downlinkBursts =
m_downlinkBursts;
71 std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > pair;
72 while (downlinkBursts->size ())
74 pair = downlinkBursts->front ();
83 std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > >*
95 dlMapIe->
SetCid (connection->GetCid ());
98 NS_LOG_INFO (
"BS scheduler, burst size: " << burst->GetSize () <<
" bytes" <<
", pkts: " << burst->GetNPackets ()
99 <<
", connection: " << connection->GetTypeStr () <<
", CID: " << connection->GetCid ());
102 NS_LOG_INFO (
", SFID: " << connection->GetServiceFlow ()->GetSfid () <<
", service: " 103 << connection->GetServiceFlow ()->GetSchedulingTypeStr ());
105 NS_LOG_INFO (
", modulation: " << modulationType <<
", DIUC: " << (uint32_t) diuc);
115 uint32_t nrSymbolsRequired = 0;
120 uint32_t availableSymbols =
GetBs ()->GetNrDlSymbols ();
124 if (connection !=
GetBs ()->GetInitialRangingConnection () && connection !=
GetBs ()->GetBroadcastConnection ())
129 modulationType = connection->GetServiceFlow ()->GetModulation ();
133 modulationType =
GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
135 diuc =
GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
138 else if (connection ==
GetBs ()->GetInitialRangingConnection () || connection
139 ==
GetBs ()->GetBroadcastConnection ())
153 nrSymbolsRequired = connection->GetServiceFlow ()->GetRecord ()->GetGrantSize ();
154 if (nrSymbolsRequired < availableSymbols)
156 burst =
CreateUgsBurst (connection->GetServiceFlow (), modulationType, nrSymbolsRequired);
160 burst =
CreateUgsBurst (connection->GetServiceFlow (), modulationType, availableSymbols);
162 if (burst->GetNPackets () != 0)
164 uint32_t BurstSizeSymbols =
GetBs ()->GetPhy ()->GetNrSymbols (burst->GetSize (), modulationType);
167 if (availableSymbols <= BurstSizeSymbols)
169 availableSymbols -= BurstSizeSymbols;
176 burst = Create<PacketBurst> ();
177 while (connection->HasPackets () ==
true)
180 nrSymbolsRequired =
GetBs ()->GetPhy ()->GetNrSymbols (FirstPacketSize, modulationType);
185 uint32_t availableByte =
GetBs ()->GetPhy ()->GetNrBytes (availableSymbols, modulationType);
187 availableSymbols = 0;
189 else if (availableSymbols >= nrSymbolsRequired)
191 packet = connection->Dequeue ();
192 availableSymbols -= nrSymbolsRequired;
198 burst->AddPacket (packet);
202 if (availableSymbols == 0)
212 << availableSymbols << std::endl <<
"BS scheduler, queues:" <<
" IR " 213 <<
GetBs ()->GetInitialRangingConnection ()->GetQueue ()->GetSize () <<
" broadcast " 214 <<
GetBs ()->GetBroadcastConnection ()->GetQueue ()->GetSize () <<
" basic " 225 std::vector<Ptr<WimaxConnection> >::const_iterator iter1;
226 std::vector<ServiceFlow*>::iterator iter2;
228 NS_LOG_INFO (
"BS Scheduler: Selecting connection...");
229 if (
GetBs ()->GetBroadcastConnection ()->HasPackets ())
232 connection =
GetBs ()->GetBroadcastConnection ();
235 else if (
GetBs ()->GetInitialRangingConnection ()->HasPackets ())
237 NS_LOG_INFO (
"Return GetInitialRangingConnection");
238 connection =
GetBs ()->GetInitialRangingConnection ();
243 std::vector<Ptr<WimaxConnection> > connections;
244 std::vector<ServiceFlow*> serviceFlows;
246 connections =
GetBs ()->GetConnectionManager ()->GetConnections (
Cid::BASIC);
247 for (iter1 = connections.begin (); iter1 != connections.end (); ++iter1)
249 if ((*iter1)->HasPackets ())
258 for (iter1 = connections.begin (); iter1 != connections.end (); ++iter1)
260 if ((*iter1)->HasPackets ())
269 for (iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
271 serviceFlowRecord = (*iter2)->GetRecord ();
272 NS_LOG_INFO (
"processing UGS: HAS PACKET=" << (*iter2)->HasPackets () <<
"max Latency = " 273 <<
MilliSeconds ((*iter2)->GetMaximumLatency ()) <<
"Delay = " << ((currentTime
276 if ((*iter2)->HasPackets () && ((currentTime - serviceFlowRecord->
GetDlTimeStamp ())
277 +
GetBs ()->GetPhy ()->GetFrameDuration ()) >
MilliSeconds ((*iter2)->GetMaximumLatency ()))
280 connection = (*iter2)->GetConnection ();
281 NS_LOG_INFO (
"Return UGS SF: CID = " << (*iter2)->GetCid () <<
"SFID = " << (*iter2)->GetSfid ());
287 for (iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
289 serviceFlowRecord = (*iter2)->GetRecord ();
291 if ((*iter2)->HasPackets () && ((currentTime - serviceFlowRecord->
GetDlTimeStamp ())
292 +
GetBs ()->GetPhy ()->GetFrameDuration ()) >
MilliSeconds ((*iter2)->GetMaximumLatency ()))
295 connection = (*iter2)->GetConnection ();
296 NS_LOG_INFO (
"Return RTPS SF: CID = " << (*iter2)->GetCid () <<
"SFID = " << (*iter2)->GetSfid ());
302 for (iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
305 if ((*iter2)->HasPackets ())
307 NS_LOG_INFO (
"Return NRTPS SF: CID = " << (*iter2)->GetCid () <<
"SFID = " << (*iter2)->GetSfid ());
308 connection = (*iter2)->GetConnection ();
314 for (iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
317 if ((*iter2)->HasPackets ())
319 NS_LOG_INFO (
"Return BE SF: CID = " << (*iter2)->GetCid () <<
"SFID = " << (*iter2)->GetSfid ());
320 connection = (*iter2)->GetConnection ();
331 uint32_t availableSymbols)
337 uint32_t nrSymbolsRequired = 0;
344 nrSymbolsRequired =
GetBs ()->GetPhy ()->GetNrSymbols (FirstPacketSize,modulationType);
349 uint32_t availableByte =
GetBs ()->GetPhy ()->GetNrBytes (availableSymbols, modulationType);
351 availableSymbols = 0;
355 packet = connection->Dequeue ();
356 availableSymbols -= nrSymbolsRequired;
358 burst->AddPacket (packet);
359 if (availableSymbols <= 0)
std::list< std::pair< OfdmDlMapIe *, Ptr< PacketBurst > > > * GetDownlinkBursts(void) const
This function returns all the downlink bursts scheduled for the next downlink sub-frame.
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)
Creates a downlink UGS burst.
#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)
Selects a connection from the list of connections having packets to be sent .
bool CheckForFragmentation(Ptr< WimaxConnection > connection, int availableSymbols, WimaxPhy::ModulationType modulationType)
Check if the packet fragmentation is possible for transport connection.
SchedulingType
section 11.13.11 Service flow scheduling type, page 701
Ptr< WimaxConnection > GetConnection(void) const
Can return a null connection is this service flow has not been associated yet to a connection...
void SetDiuc(uint8_t diuc)
Set DIUC field.
void Schedule(void)
the scheduling function for the downlink subframe.
std::list< std::pair< OfdmDlMapIe *, Ptr< PacketBurst > > > * m_downlinkBursts
down link bursts
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)
Get the base station.
void AddDownlinkBurst(Ptr< const WimaxConnection > connection, uint8_t diuc, WimaxPhy::ModulationType modulationType, Ptr< PacketBurst > burst)
This function adds a downlink burst to the list of downlink bursts scheduled for the next downlink su...
static Time Now(void)
Return the current simulation virtual time.
virtual void SetBs(Ptr< BaseStationNetDevice > bs)
Set the base station.
ModulationType
ModulationType enumeration.
void SetDlTimeStamp(Time dlTimeStamp)
Set the DlTimeStamp.
this class implement a burst as a list of packets
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time GetDlTimeStamp(void) const
bool HasPackets(void) const
Check if packets are present.
void SetCid(Cid cid)
Set CID function.
static TypeId GetTypeId(void)
Get the type ID.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
This class implements the OFDM DL-MAP information element as described by "IEEE Standard for Local an...