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)