A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
bs-scheduler-rtps.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007,2008 INRIA
3 * 2009 TELEMATICS LAB, Politecnico di Bari
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: Giuseppe Piro <g.piro@poliba.it>
19 */
20
21#include "bs-scheduler-rtps.h"
22
23#include "bs-net-device.h"
25#include "cid.h"
26#include "connection-manager.h"
28#include "service-flow-record.h"
29#include "service-flow.h"
30#include "ss-manager.h"
31#include "ss-record.h"
32#include "wimax-connection.h"
33#include "wimax-mac-header.h"
34#include "wimax-mac-queue.h"
35
36#include "ns3/log.h"
37#include "ns3/packet-burst.h"
38#include "ns3/simulator.h"
39
40namespace ns3
41{
42
43NS_LOG_COMPONENT_DEFINE("BSSchedulerRtps");
44
45NS_OBJECT_ENSURE_REGISTERED(BSSchedulerRtps);
46
47TypeId
49{
50 static TypeId tid = TypeId("ns3::BSSchedulerRtps")
52 .SetGroupName("Wimax")
53 .AddConstructor<BSSchedulerRtps>();
54 return tid;
55}
56
58 : m_downlinkBursts(new std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst>>>())
59{
60 SetBs(nullptr);
61}
62
64 : m_downlinkBursts(new std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst>>>())
65{
66 // m_downlinkBursts is filled by AddDownlinkBurst and emptied by
67 // wimax-bs-net-device::sendBurst and wimax-ss-net-device::sendBurst
68 SetBs(bs);
69}
70
72{
73 std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst>>>* downlinkBursts = m_downlinkBursts;
74 std::pair<OfdmDlMapIe*, Ptr<PacketBurst>> pair;
75 while (!downlinkBursts->empty())
76 {
77 pair = downlinkBursts->front();
78 pair.second = nullptr;
79 delete pair.first;
80 }
81
82 SetBs(nullptr);
83 delete m_downlinkBursts;
84 m_downlinkBursts = nullptr;
85}
86
87std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst>>>*
89{
90 return m_downlinkBursts;
91}
92
93void
95 uint8_t diuc,
96 WimaxPhy::ModulationType modulationType,
97 Ptr<PacketBurst> burst)
98{
99 OfdmDlMapIe* dlMapIe = new OfdmDlMapIe();
100 dlMapIe->SetCid(connection->GetCid());
101 dlMapIe->SetDiuc(diuc);
102
103 NS_LOG_INFO("BS scheduler, burst size: " << burst->GetSize() << " bytes"
104 << ", pkts: " << burst->GetNPackets()
105 << ", connection: " << connection->GetTypeStr()
106 << ", CID: " << connection->GetCid());
107 if (connection->GetType() == Cid::TRANSPORT)
108 {
109 NS_LOG_INFO(", SFID: " << connection->GetServiceFlow()->GetSfid() << ", service: "
110 << connection->GetServiceFlow()->GetSchedulingTypeStr());
111 }
112 NS_LOG_INFO(", modulation: " << modulationType << ", DIUC: " << (uint32_t)diuc);
113
114 m_downlinkBursts->emplace_back(dlMapIe, burst);
115}
116
131void
133{
134 uint32_t availableSymbols = GetBs()->GetNrDlSymbols();
135
136 BSSchedulerBroadcastConnection(availableSymbols);
137
138 BSSchedulerInitialRangingConnection(availableSymbols);
139
140 BSSchedulerBasicConnection(availableSymbols);
141
142 BSSchedulerPrimaryConnection(availableSymbols);
143
144 BSSchedulerUGSConnection(availableSymbols);
145
146 BSSchedulerRTPSConnection(availableSymbols);
147
148 BSSchedulerNRTPSConnection(availableSymbols);
149
150 BSSchedulerBEConnection(availableSymbols);
151
152 if (!m_downlinkBursts->empty())
153 {
155 "BS scheduler, number of bursts: "
156 << m_downlinkBursts->size() << ", symbols left: " << availableSymbols << std::endl
157 << "BS scheduler, queues:"
158 << " IR " << GetBs()->GetInitialRangingConnection()->GetQueue()->GetSize()
159 << " broadcast " << GetBs()->GetBroadcastConnection()->GetQueue()->GetSize()
160 << " basic "
161 << GetBs()->GetConnectionManager()->GetNPackets(Cid::BASIC, ServiceFlow::SF_TYPE_NONE)
162 << " primary "
163 << GetBs()->GetConnectionManager()->GetNPackets(Cid::PRIMARY, ServiceFlow::SF_TYPE_NONE)
164 << " transport "
165 << GetBs()->GetConnectionManager()->GetNPackets(Cid::TRANSPORT,
167 }
168}
169
172 WimaxPhy::ModulationType modulationType,
173 uint32_t availableSymbols)
174{
175 Time timeStamp;
177 Ptr<Packet> packet;
178 Ptr<PacketBurst> burst = Create<PacketBurst>();
179 uint32_t nrSymbolsRequired = 0;
180
181 // serviceFlow->CleanUpQueue ();
182 Ptr<WimaxConnection> connection = serviceFlow->GetConnection();
183 while (serviceFlow->HasPackets())
184 {
185 uint32_t FirstPacketSize =
186 connection->GetQueue()->GetFirstPacketRequiredByte(MacHeaderType::HEADER_TYPE_GENERIC);
187 nrSymbolsRequired = GetBs()->GetPhy()->GetNrSymbols(FirstPacketSize, modulationType);
188 if (availableSymbols < nrSymbolsRequired &&
189 CheckForFragmentation(connection, availableSymbols, modulationType))
190 {
191 uint32_t availableByte =
192 GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType);
193 packet = connection->Dequeue(MacHeaderType::HEADER_TYPE_GENERIC, availableByte);
194 availableSymbols = 0;
195 }
196 else
197 {
198 packet = connection->Dequeue();
199 availableSymbols -= nrSymbolsRequired;
200 }
201 burst->AddPacket(packet);
202 if (availableSymbols <= 0)
203 {
204 break;
205 }
206 }
207 return burst;
208}
209
210bool
212{
213 return false;
214}
215
216void
218{
219 Ptr<WimaxConnection> connection;
222 uint32_t nrSymbolsRequired = 0;
224 Ptr<Packet> packet;
225 Ptr<PacketBurst> burst = Create<PacketBurst>();
226
227 while (GetBs()->GetBroadcastConnection()->HasPackets() && availableSymbols > 0)
228 {
229 connection = GetBs()->GetBroadcastConnection();
230
231 packet = connection->GetQueue()->Peek(hdr);
232 nrSymbolsRequired = GetBs()->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType);
233
234 if (availableSymbols < nrSymbolsRequired &&
235 !CheckForFragmentation(connection, availableSymbols, modulationType))
236 {
237 break;
238 }
239 else if (availableSymbols < nrSymbolsRequired &&
240 CheckForFragmentation(connection, availableSymbols, modulationType))
241 {
242 uint32_t availableByte =
243 GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType);
244 packet = connection->Dequeue(MacHeaderType::HEADER_TYPE_GENERIC, availableByte);
245 }
246 else
247 {
248 packet = connection->Dequeue();
249 }
250
251 NS_ASSERT_MSG(hdr.GetCid().GetIdentifier() == connection->GetCid(),
252 "Base station: Error while scheduling broadcast connection: header CID != "
253 "connection CID");
254 burst->AddPacket(packet);
255 availableSymbols -= nrSymbolsRequired;
256 }
257 if (burst->GetNPackets() != 0)
258 {
259 AddDownlinkBurst(connection, diuc, modulationType, burst);
260 }
261}
262
263void
265{
266 Ptr<WimaxConnection> connection;
269 uint32_t nrSymbolsRequired = 0;
271 Ptr<Packet> packet;
272 Ptr<PacketBurst> burst = Create<PacketBurst>();
273
274 while (GetBs()->GetInitialRangingConnection()->HasPackets() && availableSymbols > 0)
275 {
276 connection = GetBs()->GetInitialRangingConnection();
277
278 packet = connection->GetQueue()->Peek(hdr);
279 nrSymbolsRequired = GetBs()->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType);
280
281 // PIRO: check for fragmentation
282 if (availableSymbols < nrSymbolsRequired &&
283 !CheckForFragmentation(connection, availableSymbols, modulationType))
284 {
285 break;
286 }
287 else if (availableSymbols < nrSymbolsRequired &&
288 CheckForFragmentation(connection, availableSymbols, modulationType))
289 {
290 uint32_t availableByte =
291 GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType);
292 packet = connection->Dequeue(MacHeaderType::HEADER_TYPE_GENERIC, availableByte);
293 }
294 else
295 {
296 packet = connection->Dequeue();
297 }
298
299 NS_ASSERT_MSG(hdr.GetCid() == connection->GetCid(),
300 "Base station: Error while scheduling initial ranging connection: header CID "
301 "!= connection CID");
302 burst->AddPacket(packet);
303 availableSymbols -= nrSymbolsRequired;
304 }
305 if (burst->GetNPackets())
306 {
307 AddDownlinkBurst(connection, diuc, modulationType, burst);
308 }
309}
310
311void
313{
314 Ptr<WimaxConnection> connection;
317 uint32_t nrSymbolsRequired = 0;
319 Ptr<Packet> packet;
320 Ptr<PacketBurst> burst = Create<PacketBurst>();
321
322 std::vector<Ptr<WimaxConnection>>::const_iterator iter;
323 std::vector<Ptr<WimaxConnection>> connections;
324
325 connections = GetBs()->GetConnectionManager()->GetConnections(Cid::BASIC);
326 for (iter = connections.begin(); iter != connections.end(); ++iter)
327 {
328 while ((*iter)->HasPackets() && availableSymbols > 0)
329 {
330 connection = *iter;
331
332 modulationType =
333 GetBs()->GetSSManager()->GetSSRecord(connection->GetCid())->GetModulationType();
334 diuc = GetBs()->GetBurstProfileManager()->GetBurstProfile(
335 modulationType,
337
338 packet = connection->GetQueue()->Peek(hdr);
339 nrSymbolsRequired = GetBs()->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType);
340
341 // PIRO: check for fragmentation
342 if (availableSymbols < nrSymbolsRequired &&
343 !CheckForFragmentation(connection, availableSymbols, modulationType))
344 {
345 break;
346 }
347 else if (availableSymbols < nrSymbolsRequired &&
348 CheckForFragmentation(connection, availableSymbols, modulationType))
349 {
350 uint32_t availableByte =
351 GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType);
352 packet = connection->Dequeue(MacHeaderType::HEADER_TYPE_GENERIC, availableByte);
353 }
354 else
355 {
356 packet = connection->Dequeue();
357 }
358
359 NS_ASSERT_MSG(hdr.GetCid() == connection->GetCid(),
360 "Base station: Error while scheduling basic connection: header CID != "
361 "connection CID");
362 burst->AddPacket(packet);
363 availableSymbols -= nrSymbolsRequired;
364 }
365 if (burst->GetNPackets() != 0)
366 {
367 AddDownlinkBurst(connection, diuc, modulationType, burst);
368 burst = Create<PacketBurst>();
369 }
370 }
371}
372
373void
375{
376 Ptr<WimaxConnection> connection;
378 uint8_t diuc = 0;
379 uint32_t nrSymbolsRequired = 0;
381 Ptr<Packet> packet;
382 Ptr<PacketBurst> burst = Create<PacketBurst>();
383
384 std::vector<Ptr<WimaxConnection>>::const_iterator iter;
385 std::vector<Ptr<WimaxConnection>> connections;
386
387 connections = GetBs()->GetConnectionManager()->GetConnections(Cid::PRIMARY);
388 for (iter = connections.begin(); iter != connections.end(); ++iter)
389 {
390 while ((*iter)->HasPackets() && availableSymbols > 0)
391 {
392 connection = *iter;
393
394 modulationType =
395 GetBs()->GetSSManager()->GetSSRecord(connection->GetCid())->GetModulationType();
396 diuc = GetBs()->GetBurstProfileManager()->GetBurstProfile(
397 modulationType,
399
400 packet = connection->GetQueue()->Peek(hdr);
401 nrSymbolsRequired = GetBs()->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType);
402
403 // PIRO: check for fragmentation
404 if (availableSymbols < nrSymbolsRequired &&
405 !CheckForFragmentation(connection, availableSymbols, modulationType))
406 {
407 break;
408 }
409 else if (availableSymbols < nrSymbolsRequired &&
410 CheckForFragmentation(connection, availableSymbols, modulationType))
411 {
412 uint32_t availableByte =
413 GetBs()->GetPhy()->GetNrBytes(availableSymbols, modulationType);
414 packet = connection->Dequeue(MacHeaderType::HEADER_TYPE_GENERIC, availableByte);
415 }
416 else
417 {
418 packet = connection->Dequeue();
419 }
420
421 NS_ASSERT_MSG(hdr.GetCid() == connection->GetCid(),
422 "Base station: Error while scheduling primary connection: header CID != "
423 "connection CID");
424 burst->AddPacket(packet);
425 availableSymbols -= nrSymbolsRequired;
426 }
427 if (burst->GetNPackets() != 0)
428 {
429 AddDownlinkBurst(connection, diuc, modulationType, burst);
430 }
431 }
432}
433
434void
436{
437 Ptr<WimaxConnection> connection;
439 uint8_t diuc;
440 uint32_t nrSymbolsRequired = 0;
442 Ptr<Packet> packet;
443 Ptr<PacketBurst> burst = Create<PacketBurst>();
444
445 Time currentTime = Simulator::Now();
446
447 std::vector<ServiceFlow*>::iterator iter;
448 ServiceFlowRecord* serviceFlowRecord;
449 std::vector<ServiceFlow*> serviceFlows;
450
451 serviceFlows = GetBs()->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_UGS);
452 for (iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter)
453 {
454 serviceFlowRecord = (*iter)->GetRecord();
455 // if latency would exceed in case grant is allocated in next frame then allocate in current
456 // frame
457 if ((*iter)->HasPackets() &&
458 ((currentTime - serviceFlowRecord->GetDlTimeStamp()) +
459 GetBs()->GetPhy()->GetFrameDuration()) > MilliSeconds((*iter)->GetMaximumLatency()))
460 {
461 connection = (*iter)->GetConnection();
462 if (connection->GetType() == Cid::MULTICAST)
463 {
464 modulationType = connection->GetServiceFlow()->GetModulation();
465 }
466 else
467 {
468 modulationType =
469 GetBs()->GetSSManager()->GetSSRecord(connection->GetCid())->GetModulationType();
470 }
471 diuc = GetBs()->GetBurstProfileManager()->GetBurstProfile(
472 modulationType,
474
475 nrSymbolsRequired = connection->GetServiceFlow()->GetRecord()->GetGrantSize();
476
477 // Packet fragmentation for UGS connections has not been implemented yet!
478 if (availableSymbols > nrSymbolsRequired)
479 {
480 availableSymbols -= nrSymbolsRequired;
481 burst =
482 CreateUgsBurst(connection->GetServiceFlow(), modulationType, nrSymbolsRequired);
483 if (burst->GetNPackets() != 0)
484 {
485 AddDownlinkBurst(connection, diuc, modulationType, burst);
486 currentTime = Simulator::Now();
487 serviceFlowRecord->SetDlTimeStamp(currentTime);
488 burst = Create<PacketBurst>();
489 }
490 }
491 }
492 }
493}
494
495void
497{
498 Ptr<WimaxConnection> connection;
500 Ptr<Packet> packet;
501 Ptr<PacketBurst> burst = Create<PacketBurst>();
502
503 Time currentTime = Simulator::Now();
504
505 std::vector<Ptr<WimaxConnection>> connections;
506 std::vector<ServiceFlow*>::iterator iter2;
507 ServiceFlowRecord* serviceFlowRecord;
508 std::vector<ServiceFlow*> serviceFlows;
509
510 uint32_t symbolsRequired[100];
511 WimaxPhy::ModulationType modulationType_[100];
512 uint8_t diuc_[100];
513 Ptr<WimaxConnection> rtPSConnection[100];
514 uint32_t dataToSend;
515 uint32_t totSymbolsRequired = 0;
516 int nbConnection = 0;
517
518 NS_LOG_INFO("\tDL Scheduler for rtPS flows \n"
519 << "\t\tavailableSymbols = " << availableSymbols);
520
521 serviceFlows = GetBs()->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_RTPS);
522 nbConnection = 0;
523 for (iter2 = serviceFlows.begin(); iter2 != serviceFlows.end(); ++iter2)
524 {
525 // DL RTPS Scheduler works for all rtPS connection that have packets to transmitt!!!
526 serviceFlowRecord = (*iter2)->GetRecord();
527
528 if ((*iter2)->HasPackets())
529 {
530 currentTime = Simulator::Now();
531 serviceFlowRecord->SetDlTimeStamp(currentTime);
532 rtPSConnection[nbConnection] = (*iter2)->GetConnection();
533 if (rtPSConnection[nbConnection]->GetType() == Cid::MULTICAST)
534 {
535 modulationType_[nbConnection] =
536 rtPSConnection[nbConnection]->GetServiceFlow()->GetModulation();
537 }
538 else
539 {
540 modulationType_[nbConnection] =
541 GetBs()
542 ->GetSSManager()
543 ->GetSSRecord(rtPSConnection[nbConnection]->GetCid())
544 ->GetModulationType();
545 }
546 diuc_[nbConnection] = GetBs()->GetBurstProfileManager()->GetBurstProfile(
547 modulationType_[nbConnection],
549
550 dataToSend = rtPSConnection[nbConnection]->GetQueue()->GetQueueLengthWithMACOverhead();
551 NS_LOG_INFO("\t\tRTPS DL Scheduler for CID = " << rtPSConnection[nbConnection]->GetCid()
552 << "\n\t\t\t dataToSend = "
553 << dataToSend);
554
555 symbolsRequired[nbConnection] =
556 GetBs()->GetPhy()->GetNrSymbols(dataToSend, modulationType_[nbConnection]);
557
558 totSymbolsRequired += symbolsRequired[nbConnection];
559 nbConnection++;
560 }
561 }
562
563 NS_LOG_INFO("\t\ttotSymbolsRequired = " << totSymbolsRequired);
564
565 // Channel Saturation
566 while (totSymbolsRequired > availableSymbols)
567 {
568 NS_LOG_INFO("\tDL Channel Saturation: totSymbolsRequired > availableSymbols_rtPS");
569 double delta = double(availableSymbols) / double(totSymbolsRequired);
570 NS_LOG_INFO("\t\tdelta = " << delta);
571 totSymbolsRequired = 0;
572 for (int i = 0; i < nbConnection; i++)
573 {
574 NS_LOG_INFO("\t\tprevious symbolsRequired[" << i << "] = " << symbolsRequired[i]);
575 symbolsRequired[i] = (uint32_t)std::floor(symbolsRequired[i] * delta);
576 totSymbolsRequired += symbolsRequired[i];
577 NS_LOG_INFO("\t\tnew symbolsRequired[" << i << "] = " << symbolsRequired[i]);
578 }
579 NS_LOG_INFO("\t\ttotSymbolsRequired = " << totSymbolsRequired);
580 }
581
582 // Downlink Bandwidth Allocation
583 for (int i = 0; i < nbConnection; i++)
584 {
585 packet = rtPSConnection[i]->GetQueue()->Peek(hdr);
586 uint32_t symbolsForPacketTransmission = 0;
587 burst = Create<PacketBurst>();
588 NS_LOG_INFO("\t\tCID = " << rtPSConnection[i]->GetCid()
589 << " assignedSymbols = " << symbolsRequired[i]);
590
591 while (symbolsRequired[i] > 0)
592 {
593 symbolsForPacketTransmission = GetBs()->GetPhy()->GetNrSymbols(
594 rtPSConnection[i]->GetQueue()->GetFirstPacketRequiredByte(
596 modulationType_[i]);
597
598 // PIRO: check for fragmentation
599 if (symbolsForPacketTransmission > symbolsRequired[i] &&
600 !CheckForFragmentation(rtPSConnection[i], symbolsRequired[i], modulationType_[i]))
601 {
602 break;
603 }
604 else if (symbolsForPacketTransmission > symbolsRequired[i] &&
605 CheckForFragmentation(rtPSConnection[i],
606 symbolsRequired[i],
607 modulationType_[i]))
608 {
609 uint32_t availableByte =
610 GetBs()->GetPhy()->GetNrBytes(symbolsRequired[i], modulationType_[i]);
611 packet =
612 rtPSConnection[i]->Dequeue(MacHeaderType::HEADER_TYPE_GENERIC, availableByte);
613 symbolsRequired[i] = 0;
614 }
615 else
616 {
617 packet = rtPSConnection[i]->Dequeue();
618 symbolsRequired[i] -= symbolsForPacketTransmission;
619 }
620
621 NS_ASSERT_MSG(hdr.GetCid() == rtPSConnection[i]->GetCid(),
622 "Base station: Error while scheduling RTPs connection: header CID != "
623 "connection CID");
624 burst->AddPacket(packet);
625 }
626
627 if (burst->GetNPackets() != 0)
628 {
629 AddDownlinkBurst(rtPSConnection[i], diuc_[i], modulationType_[i], burst);
630 }
631 }
632
633 availableSymbols -= totSymbolsRequired;
634}
635
636void
638{
639 Ptr<WimaxConnection> connection;
641 uint8_t diuc = 0;
642 uint32_t nrSymbolsRequired = 0;
644 Ptr<Packet> packet;
645 Ptr<PacketBurst> burst = Create<PacketBurst>();
646
647 std::vector<ServiceFlow*>::iterator iter;
648 std::vector<ServiceFlow*> serviceFlows;
649
650 serviceFlows = GetBs()->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_NRTPS);
651 for (iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter)
652 {
653 connection = (*iter)->GetConnection();
654
655 while ((*iter)->HasPackets() && availableSymbols > 0)
656 {
657 if (connection->GetType() == Cid::MULTICAST)
658 {
659 modulationType = connection->GetServiceFlow()->GetModulation();
660 }
661 else
662 {
663 modulationType =
664 GetBs()->GetSSManager()->GetSSRecord(connection->GetCid())->GetModulationType();
665 }
666
667 diuc = GetBs()->GetBurstProfileManager()->GetBurstProfile(
668 modulationType,
670
671 packet = connection->GetQueue()->Peek(hdr);
672 nrSymbolsRequired = GetBs()->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType);
673
674 if (availableSymbols < nrSymbolsRequired)
675 {
676 break;
677 }
678
679 packet = connection->Dequeue();
680 NS_ASSERT_MSG(hdr.GetCid() == connection->GetCid(),
681 "Base station: Error while scheduling NRTPs connection: header CID != "
682 "connection CID");
683 burst->AddPacket(packet);
684 availableSymbols -= nrSymbolsRequired;
685 }
686 if (burst->GetNPackets() != 0)
687 {
688 AddDownlinkBurst(connection, diuc, modulationType, burst);
689 burst = Create<PacketBurst>();
690 }
691 }
692}
693
694void
696{
697 Ptr<WimaxConnection> connection;
699 uint8_t diuc = 0;
700 uint32_t nrSymbolsRequired = 0;
702 Ptr<Packet> packet;
703 Ptr<PacketBurst> burst = Create<PacketBurst>();
704
705 std::vector<ServiceFlow*>::iterator iter;
706 std::vector<ServiceFlow*> serviceFlows;
707
708 serviceFlows = GetBs()->GetServiceFlowManager()->GetServiceFlows(ServiceFlow::SF_TYPE_BE);
709 for (iter = serviceFlows.begin(); iter != serviceFlows.end(); ++iter)
710 {
711 connection = (*iter)->GetConnection();
712
713 while ((*iter)->HasPackets() && availableSymbols > 0)
714 {
715 if (connection->GetType() == Cid::MULTICAST)
716 {
717 modulationType = connection->GetServiceFlow()->GetModulation();
718 }
719 else
720 {
721 modulationType =
722 GetBs()->GetSSManager()->GetSSRecord(connection->GetCid())->GetModulationType();
723 }
724 diuc = GetBs()->GetBurstProfileManager()->GetBurstProfile(
725 modulationType,
727
728 packet = connection->GetQueue()->Peek(hdr);
729 nrSymbolsRequired = GetBs()->GetPhy()->GetNrSymbols(packet->GetSize(), modulationType);
730
731 if (availableSymbols < nrSymbolsRequired)
732 {
733 break;
734 }
735
736 packet = connection->Dequeue();
738 hdr.GetCid() == connection->GetCid(),
739 "Base station: Error while scheduling BE connection: header CID != connection CID");
740 burst->AddPacket(packet);
741 availableSymbols -= nrSymbolsRequired;
742 }
743 if (burst->GetNPackets() != 0)
744 {
745 AddDownlinkBurst(connection, diuc, modulationType, burst);
746 burst = Create<PacketBurst>();
747 }
748 }
749}
750
751} // namespace ns3
BaseStation Scheduler.
Definition: bs-scheduler.h:48
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
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
This class implements a simple downlink scheduler for rtPS flows.
static TypeId GetTypeId()
Get the type ID.
void Schedule() override
Schedule function.
void BSSchedulerPrimaryConnection(uint32_t &availableSymbols)
schedules the primary connection
std::list< std::pair< OfdmDlMapIe *, Ptr< PacketBurst > > > * GetDownlinkBursts() const override
This function returns all the downlink bursts scheduled for the next downlink sub-frame.
void BSSchedulerUGSConnection(uint32_t &availableSymbols)
schedules the UGS connection
void BSSchedulerBEConnection(uint32_t &availableSymbols)
schedules the BE connection
void BSSchedulerBasicConnection(uint32_t &availableSymbols)
schedules the basic connections
void AddDownlinkBurst(Ptr< const WimaxConnection > connection, uint8_t diuc, WimaxPhy::ModulationType modulationType, Ptr< PacketBurst > burst) override
This function adds a downlink burst to the list of downlink bursts scheduled for the next downlink su...
void BSSchedulerInitialRangingConnection(uint32_t &availableSymbols)
schedules the IR connections
void BSSchedulerRTPSConnection(uint32_t &availableSymbols)
Downlink Scheduler for rtPS connections.
void BSSchedulerBroadcastConnection(uint32_t &availableSymbols)
schedules the broadcast connections
void BSSchedulerNRTPSConnection(uint32_t &availableSymbols)
schedules the NRTPS connections
Ptr< PacketBurst > CreateUgsBurst(ServiceFlow *serviceFlow, WimaxPhy::ModulationType modulationType, uint32_t availableSymbols) override
Creates a downlink UGS burst.
bool SelectConnection(Ptr< WimaxConnection > &connection) override
Selects a connection from the list of connections having packets to be sent .
std::list< std::pair< OfdmDlMapIe *, Ptr< PacketBurst > > > * m_downlinkBursts
down link bursts
@ PRIMARY
Definition: cid.h:45
@ TRANSPORT
Definition: cid.h:46
@ MULTICAST
Definition: cid.h:47
@ BASIC
Definition: cid.h:44
uint16_t GetIdentifier() const
Definition: cid.cc:45
This class implements the Generic mac Header as described by IEEE Standard for Local and metropolitan...
Cid GetCid() const
Get CID field.
This class implements the OFDM DL-MAP information element as described by "IEEE Standard for Local an...
void SetCid(Cid cid)
Set CID function.
void SetDiuc(uint8_t diuc)
Set DIUC field.
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:78
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:43
bool HasPackets() const
Check if packets are present.
Ptr< WimaxConnection > GetConnection() const
Can return a null connection is this service flow has not been associated yet to a connection.
this class implements a structure to manage some parameters and statistics related to a service flow
void SetDlTimeStamp(Time dlTimeStamp)
Set the DlTimeStamp.
static Time Now()
Return the current simulation virtual time.
Definition: simulator.cc:199
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:936
ModulationType
ModulationType enumeration.
Definition: wimax-phy.h:54
@ MODULATION_TYPE_BPSK_12
Definition: wimax-phy.h:55
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:86
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:268
#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
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1348
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t GetSize(Ptr< const Packet > packet, const WifiMacHeader *hdr, bool isAmpdu)
Return the total size of the packet after WifiMacHeader and FCS trailer have been added.
Definition: wifi-utils.cc:132
STL namespace.
#define list