A Discrete-Event Network Simulator
API
bs-scheduler-rtps.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007,2008 INRIA
4  * 2009 TELEMATICS LAB, Politecnico di Bari
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation;
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Author: Giuseppe Piro <g.piro@poliba.it>
20  */
21 
22 #include "bs-scheduler-rtps.h"
23 #include "ns3/simulator.h"
24 #include "bs-net-device.h"
25 #include "ns3/packet-burst.h"
26 #include "cid.h"
27 #include "wimax-mac-header.h"
28 #include "ss-record.h"
29 #include "wimax-mac-queue.h"
30 #include "ns3/log.h"
31 #include "burst-profile-manager.h"
32 #include "wimax-connection.h"
33 #include "connection-manager.h"
34 #include "ss-manager.h"
35 #include "service-flow.h"
36 #include "service-flow-record.h"
37 #include "service-flow-manager.h"
38 #include "wimax-mac-queue.h"
39 
40 namespace ns3 {
41 
42 NS_LOG_COMPONENT_DEFINE ("BSSchedulerRtps");
43 
44 NS_OBJECT_ENSURE_REGISTERED (BSSchedulerRtps);
45 
46 TypeId
48 {
49  static TypeId tid = TypeId ("ns3::BSSchedulerRtps")
51  .SetGroupName("Wimax")
52  .AddConstructor<BSSchedulerRtps> ()
53  ;
54  return tid;
55 }
56 
58  : m_downlinkBursts (new std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > > ())
59 {
60  SetBs (0);
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 
74  std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > > *downlinkBursts = m_downlinkBursts;
75  std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > pair;
76  while (downlinkBursts->size ())
77  {
78  pair = downlinkBursts->front ();
79  pair.second = 0;
80  delete pair.first;
81  }
82 
83  SetBs (0);
84  delete m_downlinkBursts;
85  m_downlinkBursts = 0;
86 }
87 
88 std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > >*
90 {
91  return m_downlinkBursts;
92 }
93 
94 void
96  uint8_t diuc,
97  WimaxPhy::ModulationType modulationType,
98  Ptr<PacketBurst> burst)
99 {
100  OfdmDlMapIe *dlMapIe = new OfdmDlMapIe ();
101  dlMapIe->SetCid (connection->GetCid ());
102  dlMapIe->SetDiuc (diuc);
103 
104  NS_LOG_INFO ("BS scheduler, burst size: " << burst->GetSize () << " bytes" << ", pkts: " << burst->GetNPackets ()
105  << ", connection: " << connection->GetTypeStr () << ", CID: "
106  << 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->push_back (std::make_pair (dlMapIe, burst));
115 }
116 
131 void
133 {
134 
135  uint32_t availableSymbols = GetBs ()->GetNrDlSymbols ();
136 
137  BSSchedulerBroadcastConnection (availableSymbols);
138 
139  BSSchedulerInitialRangingConnection (availableSymbols);
140 
141  BSSchedulerBasicConnection (availableSymbols);
142 
143  BSSchedulerPrimaryConnection (availableSymbols);
144 
145  BSSchedulerUGSConnection (availableSymbols);
146 
147  BSSchedulerRTPSConnection (availableSymbols);
148 
149  BSSchedulerNRTPSConnection (availableSymbols);
150 
151  BSSchedulerBEConnection (availableSymbols);
152 
153  if (m_downlinkBursts->size ())
154  {
155  NS_LOG_DEBUG ("BS scheduler, number of bursts: " << m_downlinkBursts->size () << ", symbols left: "
156  << availableSymbols << std::endl << "BS scheduler, queues:" << " IR "
157  << GetBs ()->GetInitialRangingConnection ()->GetQueue ()->GetSize ()
158  << " broadcast "
159  << 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, ServiceFlow::SF_TYPE_ALL));
166  }
167 }
168 
169 
171  WimaxPhy::ModulationType modulationType,
172  uint32_t availableSymbols)
173 {
174  Time timeStamp;
175  GenericMacHeader hdr;
176  Ptr<Packet> packet;
177  Ptr<PacketBurst> burst = Create<PacketBurst> ();
178  uint32_t nrSymbolsRequired = 0;
179 
180  // serviceFlow->CleanUpQueue ();
181  Ptr<WimaxConnection> connection = serviceFlow->GetConnection ();
182  while (serviceFlow->HasPackets ())
183  {
184  uint32_t FirstPacketSize = connection->GetQueue ()->GetFirstPacketRequiredByte (MacHeaderType::HEADER_TYPE_GENERIC);
185  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (FirstPacketSize,modulationType);
186  if (availableSymbols < nrSymbolsRequired && CheckForFragmentation (connection,
187  availableSymbols,
188  modulationType))
189  {
190  uint32_t availableByte = GetBs ()->GetPhy ()->GetNrBytes (availableSymbols, modulationType);
191  packet = connection->Dequeue (MacHeaderType::HEADER_TYPE_GENERIC, availableByte);
192  availableSymbols = 0;
193  }
194  else
195  {
196  packet = connection->Dequeue ();
197  availableSymbols -= nrSymbolsRequired;
198  }
199  burst->AddPacket (packet);
200  if (availableSymbols <= 0)
201  {
202  break;
203  }
204  }
205  return burst;
206 }
207 
208 
209 bool
211 {
212  return false;
213 }
214 
215 void
217 {
218  Ptr<WimaxConnection> connection;
221  uint32_t nrSymbolsRequired = 0;
222  GenericMacHeader hdr;
223  Ptr<Packet> packet;
224  Ptr<PacketBurst> burst = Create<PacketBurst> ();
225 
226  while (GetBs ()->GetBroadcastConnection ()->HasPackets () && availableSymbols > 0)
227  {
228  connection = GetBs ()->GetBroadcastConnection ();
229 
230  packet = connection->GetQueue ()->Peek (hdr);
231  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (packet->GetSize (), modulationType);
232 
233  if (availableSymbols < nrSymbolsRequired
234  && !CheckForFragmentation (connection, availableSymbols, modulationType))
235  {
236  break;
237  }
238  else if (availableSymbols < nrSymbolsRequired
239  && CheckForFragmentation (connection, availableSymbols, modulationType))
240  {
241  uint32_t availableByte = GetBs ()->GetPhy ()->
242  GetNrBytes (availableSymbols, modulationType);
243  packet = connection->Dequeue (MacHeaderType::HEADER_TYPE_GENERIC,
244  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 != connection CID");
253  burst->AddPacket (packet);
254  availableSymbols -= nrSymbolsRequired;
255  }
256  if (burst->GetNPackets () != 0)
257  {
258  AddDownlinkBurst (connection, diuc, modulationType, burst);
259  }
260 }
261 
262 void
264 {
265  Ptr<WimaxConnection> connection;
268  uint32_t nrSymbolsRequired = 0;
269  GenericMacHeader hdr;
270  Ptr<Packet> packet;
271  Ptr<PacketBurst> burst = Create<PacketBurst> ();
272 
273  while (GetBs ()->GetInitialRangingConnection ()->HasPackets () && availableSymbols > 0)
274  {
275  connection = GetBs ()->GetInitialRangingConnection ();
276 
277  packet = connection->GetQueue ()->Peek (hdr);
278  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (packet->GetSize (), modulationType);
279 
280  // PIRO: check for fragmentation
281  if (availableSymbols < nrSymbolsRequired
282  && !CheckForFragmentation (connection, availableSymbols, modulationType))
283  {
284  break;
285  }
286  else if (availableSymbols < nrSymbolsRequired
287  && CheckForFragmentation (connection, availableSymbols, modulationType))
288  {
289  uint32_t availableByte = GetBs ()->GetPhy ()->
290  GetNrBytes (availableSymbols, modulationType);
291  packet = connection->Dequeue (MacHeaderType::HEADER_TYPE_GENERIC,
292  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 != connection CID");
301  burst->AddPacket (packet);
302  availableSymbols -= nrSymbolsRequired;
303  }
304  if (burst->GetNPackets ())
305  {
306  AddDownlinkBurst (connection, diuc, modulationType, burst);
307  }
308 }
309 
310 void
312 {
313  Ptr<WimaxConnection> connection;
316  uint32_t nrSymbolsRequired = 0;
317  GenericMacHeader hdr;
318  Ptr<Packet> packet;
319  Ptr<PacketBurst> burst = Create<PacketBurst> ();
320 
321  std::vector<Ptr<WimaxConnection> >::const_iterator iter;
322  std::vector<Ptr<WimaxConnection> > connections;
323 
324  connections = GetBs ()->GetConnectionManager ()->GetConnections (Cid::BASIC);
325  for (iter = connections.begin (); iter != connections.end (); ++iter)
326  {
327  while ((*iter)->HasPackets () && availableSymbols > 0)
328  {
329  connection = *iter;
330 
331  modulationType = GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
332  diuc = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
334 
335  packet = connection->GetQueue ()->Peek (hdr);
336  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (packet->GetSize (), modulationType);
337 
338  // PIRO: check for fragmentation
339  if (availableSymbols < nrSymbolsRequired
340  && !CheckForFragmentation (connection, availableSymbols, modulationType))
341  {
342  break;
343  }
344  else if (availableSymbols < nrSymbolsRequired
345  && CheckForFragmentation (connection, availableSymbols, modulationType))
346  {
347  uint32_t availableByte = GetBs ()->GetPhy ()->
348  GetNrBytes (availableSymbols, modulationType);
349  packet = connection->Dequeue (MacHeaderType::HEADER_TYPE_GENERIC, availableByte);
350  }
351  else
352  {
353  packet = connection->Dequeue ();
354  }
355 
356  NS_ASSERT_MSG (hdr.GetCid () == connection->GetCid (),
357  "Base station: Error while scheduling basic connection: header CID != connection CID");
358  burst->AddPacket (packet);
359  availableSymbols -= nrSymbolsRequired;
360  }
361  if (burst->GetNPackets () != 0)
362  {
363  AddDownlinkBurst (connection, diuc, modulationType, burst);
364  burst = Create<PacketBurst> ();
365  }
366  }
367 }
368 
369 void
371 {
372  Ptr<WimaxConnection> connection;
374  uint8_t diuc = 0;
375  uint32_t nrSymbolsRequired = 0;
376  GenericMacHeader hdr;
377  Ptr<Packet> packet;
378  Ptr<PacketBurst> burst = Create<PacketBurst> ();
379 
380  std::vector<Ptr<WimaxConnection> >::const_iterator iter;
381  std::vector<Ptr<WimaxConnection> > connections;
382 
383  connections = GetBs ()->GetConnectionManager ()->GetConnections (Cid::PRIMARY);
384  for (iter = connections.begin (); iter != connections.end (); ++iter)
385  {
386  while ((*iter)->HasPackets () && availableSymbols > 0)
387  {
388  connection = *iter;
389 
390  modulationType = GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
391  diuc = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
393 
394  packet = connection->GetQueue ()->Peek (hdr);
395  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (packet->GetSize (), modulationType);
396 
397  // PIRO: check for fragmentation
398  if (availableSymbols < nrSymbolsRequired
399  && !CheckForFragmentation (connection, availableSymbols, modulationType))
400  {
401  break;
402  }
403  else if (availableSymbols < nrSymbolsRequired
404  && CheckForFragmentation (connection, availableSymbols, modulationType))
405  {
406  uint32_t availableByte = GetBs ()->GetPhy ()->
407  GetNrBytes (availableSymbols, modulationType);
408  packet = connection->Dequeue (MacHeaderType::HEADER_TYPE_GENERIC, availableByte);
409  }
410  else
411  {
412  packet = connection->Dequeue ();
413  }
414 
415  NS_ASSERT_MSG (hdr.GetCid () == connection->GetCid (),
416  "Base station: Error while scheduling primary connection: header CID != connection CID");
417  burst->AddPacket (packet);
418  availableSymbols -= nrSymbolsRequired;
419  }
420  if (burst->GetNPackets () != 0)
421  {
422  AddDownlinkBurst (connection, diuc, modulationType, burst);
423  }
424  }
425 }
426 
427 void
428 BSSchedulerRtps::BSSchedulerUGSConnection (uint32_t &availableSymbols)
429 {
430  Ptr<WimaxConnection> connection;
432  uint8_t diuc;
433  uint32_t nrSymbolsRequired = 0;
434  GenericMacHeader hdr;
435  Ptr<Packet> packet;
436  Ptr<PacketBurst> burst = Create<PacketBurst> ();
437 
438  Time currentTime = Simulator::Now ();
439 
440  std::vector<ServiceFlow*>::iterator iter;
441  ServiceFlowRecord *serviceFlowRecord;
442  std::vector<ServiceFlow*> serviceFlows;
443 
444  serviceFlows = GetBs ()->GetServiceFlowManager ()->GetServiceFlows (ServiceFlow::SF_TYPE_UGS);
445  for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
446  {
447  serviceFlowRecord = (*iter)->GetRecord ();
448  // if latency would exceed in case grant is allocated in next frame then allocate in current frame
449  if ((*iter)->HasPackets () && ((currentTime - serviceFlowRecord->GetDlTimeStamp ())
450  + GetBs ()->GetPhy ()->GetFrameDuration ()) > MilliSeconds ((*iter)->GetMaximumLatency ()))
451  {
452  connection = (*iter)->GetConnection ();
453  if (connection->GetType () == Cid::MULTICAST)
454  {
455  modulationType = connection->GetServiceFlow ()->GetModulation ();
456  }
457  else
458  {
459  modulationType = GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
460  }
461  diuc = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
463 
464  nrSymbolsRequired = connection->GetServiceFlow ()->GetRecord ()->GetGrantSize ();
465 
466  // Packet fragmentation for UGS connections has not been implemented yet!
467  if (availableSymbols > nrSymbolsRequired)
468  {
469  availableSymbols -= nrSymbolsRequired;
470  burst = CreateUgsBurst (connection->GetServiceFlow (), modulationType, nrSymbolsRequired);
471  if (burst->GetNPackets () != 0)
472  {
473  AddDownlinkBurst (connection, diuc, modulationType, burst);
474  currentTime = Simulator::Now ();
475  serviceFlowRecord->SetDlTimeStamp (currentTime);
476  burst = Create<PacketBurst> ();
477  }
478  }
479  }
480  }
481 
482 }
483 
484 void
485 BSSchedulerRtps::BSSchedulerRTPSConnection (uint32_t &availableSymbols)
486 {
487 
488  Ptr<WimaxConnection> connection;
489  GenericMacHeader hdr;
490  Ptr<Packet> packet;
491  Ptr<PacketBurst> burst = Create<PacketBurst> ();
492 
493  Time currentTime = Simulator::Now ();
494 
495  std::vector<Ptr<WimaxConnection> >::const_iterator iter;
496  std::vector<Ptr<WimaxConnection> > connections;
497  std::vector<ServiceFlow*>::iterator iter2;
498  ServiceFlowRecord *serviceFlowRecord;
499  std::vector<ServiceFlow*> serviceFlows;
500 
501  uint32_t symbolsRequired[100];
502  WimaxPhy::ModulationType modulationType_[100];
503  uint8_t diuc_[100];
504  Ptr<WimaxConnection> rtPSConnection[100];
505  uint32_t dataToSend;
506  uint32_t totSymbolsRequired = 0;
507  int nbConnection = 0;
508 
509  NS_LOG_INFO ("\tDL Scheduler for rtPS flows \n" << "\t\tavailableSymbols = " << availableSymbols);
510 
511  serviceFlows = GetBs ()->GetServiceFlowManager ()->GetServiceFlows (ServiceFlow::SF_TYPE_RTPS);
512  nbConnection = 0;
513  for (iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
514  {
515  // DL RTPS Scheduler works for all rtPS connection that have packets to transmitt!!!
516  serviceFlowRecord = (*iter2)->GetRecord ();
517 
518  if ((*iter2)->HasPackets ())
519  {
520  currentTime = Simulator::Now ();
521  serviceFlowRecord->SetDlTimeStamp (currentTime);
522  rtPSConnection[nbConnection] = (*iter2)->GetConnection ();
523  if (rtPSConnection[nbConnection]->GetType () == Cid::MULTICAST)
524  {
525  modulationType_[nbConnection] = rtPSConnection[nbConnection]->GetServiceFlow ()->GetModulation ();
526  }
527  else
528  {
529  modulationType_[nbConnection]
530  = GetBs ()->GetSSManager ()->GetSSRecord (rtPSConnection[nbConnection]->GetCid ())->GetModulationType ();
531  }
532  diuc_[nbConnection]
533  = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType_[nbConnection],
535 
536  dataToSend = rtPSConnection[nbConnection]->GetQueue ()->GetQueueLengthWithMACOverhead ();
537  NS_LOG_INFO ("\t\tRTPS DL Scheduler for CID = " << rtPSConnection[nbConnection]->GetCid ()
538  << "\n\t\t\t dataToSend = " << dataToSend);
539 
540  symbolsRequired[nbConnection] = GetBs ()->GetPhy ()->GetNrSymbols (dataToSend,
541  modulationType_[nbConnection]);
542 
543  totSymbolsRequired += symbolsRequired[nbConnection];
544  nbConnection++;
545  }
546  }
547 
548  NS_LOG_INFO ("\t\ttotSymbolsRequired = " << totSymbolsRequired);
549 
550  // Channel Saturation
551  while (totSymbolsRequired > availableSymbols)
552  {
553  NS_LOG_INFO ("\tDL Channel Saturation: totSymbolsRequired > availableSymbols_rtPS");
554  double delta = double(availableSymbols) / double(totSymbolsRequired);
555  NS_LOG_INFO ("\t\tdelta = " << delta);
556  totSymbolsRequired = 0;
557  for (int i = 0; i < nbConnection; i++)
558  {
559  NS_LOG_INFO ("\t\tprevious symbolsRequired[" << i << "] = " << symbolsRequired[i]);
560  symbolsRequired[i] = (uint32_t) std::floor (symbolsRequired[i] * delta);
561  totSymbolsRequired += symbolsRequired[i];
562  NS_LOG_INFO ("\t\tnew symbolsRequired[" << i << "] = " << symbolsRequired[i]);
563  }
564  NS_LOG_INFO ("\t\ttotSymbolsRequired = " << totSymbolsRequired);
565  }
566 
567  // Downlink Bandwidth Allocation
568  for (int i = 0; i < nbConnection; i++)
569  {
570 
571  packet = rtPSConnection[i]->GetQueue ()->Peek (hdr);
572  uint32_t symbolsForPacketTransmission = 0;
573  burst = Create<PacketBurst> ();
574  NS_LOG_INFO ("\t\tCID = " << rtPSConnection[i]->GetCid () << " assignedSymbols = " << symbolsRequired[i]);
575 
576  while (symbolsRequired[i] > 0)
577  {
578  symbolsForPacketTransmission = GetBs ()->GetPhy ()
579  ->GetNrSymbols (rtPSConnection[i]->GetQueue ()
580  ->GetFirstPacketRequiredByte (MacHeaderType::HEADER_TYPE_GENERIC),
581  modulationType_[i]);
582 
583  // PIRO: check for fragmentation
584  if (symbolsForPacketTransmission > symbolsRequired[i]
585  && !CheckForFragmentation (rtPSConnection[i],
586  symbolsRequired[i],
587  modulationType_[i]))
588  {
589  break;
590  }
591  else if (symbolsForPacketTransmission > symbolsRequired[i]
592  && CheckForFragmentation (rtPSConnection[i],
593  symbolsRequired[i],
594  modulationType_[i]))
595  {
596  uint32_t availableByte = GetBs ()->GetPhy ()->
597  GetNrBytes (symbolsRequired[i], modulationType_[i]);
598  packet = rtPSConnection[i]->Dequeue (MacHeaderType::HEADER_TYPE_GENERIC, availableByte);
599  symbolsRequired[i] = 0;
600  }
601  else
602  {
603  packet = rtPSConnection[i]->Dequeue ();
604  symbolsRequired[i] -= symbolsForPacketTransmission;
605  }
606 
607  NS_ASSERT_MSG (hdr.GetCid () == rtPSConnection[i]->GetCid (),
608  "Base station: Error while scheduling RTPs connection: header CID != connection CID");
609  burst->AddPacket (packet);
610  }
611 
612  if (burst->GetNPackets () != 0)
613  {
614  AddDownlinkBurst (rtPSConnection[i], diuc_[i], modulationType_[i], burst);
615  }
616  }
617 
618  availableSymbols -= totSymbolsRequired;
619 }
620 
621 void
623 {
624  Ptr<WimaxConnection> connection;
626  uint8_t diuc = 0;
627  uint32_t nrSymbolsRequired = 0;
628  GenericMacHeader hdr;
629  Ptr<Packet> packet;
630  Ptr<PacketBurst> burst = Create<PacketBurst> ();
631 
632  std::vector<ServiceFlow*>::iterator iter;
633  std::vector<ServiceFlow*> serviceFlows;
634 
635  serviceFlows = GetBs ()->GetServiceFlowManager ()->GetServiceFlows (ServiceFlow::SF_TYPE_NRTPS);
636  for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
637  {
638  connection = (*iter)->GetConnection ();
639 
640  while ((*iter)->HasPackets () && availableSymbols > 0)
641  {
642  if (connection->GetType () == Cid::MULTICAST)
643  {
644  modulationType = connection->GetServiceFlow ()->GetModulation ();
645  }
646  else
647  {
648  modulationType = GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
649  }
650 
651  diuc = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
653 
654  packet = connection->GetQueue ()->Peek (hdr);
655  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (packet->GetSize (), modulationType);
656 
657  if (availableSymbols < nrSymbolsRequired)
658  {
659  break;
660  }
661 
662  packet = connection->Dequeue ();
663  NS_ASSERT_MSG (hdr.GetCid () == connection->GetCid (),
664  "Base station: Error while scheduling NRTPs connection: header CID != connection CID");
665  burst->AddPacket (packet);
666  availableSymbols -= nrSymbolsRequired;
667  }
668  if (burst->GetNPackets () != 0)
669  {
670  AddDownlinkBurst (connection, diuc, modulationType, burst);
671  burst = Create<PacketBurst> ();
672  }
673  }
674 }
675 
676 void
677 BSSchedulerRtps::BSSchedulerBEConnection (uint32_t &availableSymbols)
678 {
679  Ptr<WimaxConnection> connection;
681  uint8_t diuc = 0;
682  uint32_t nrSymbolsRequired = 0;
683  GenericMacHeader hdr;
684  Ptr<Packet> packet;
685  Ptr<PacketBurst> burst = Create<PacketBurst> ();
686 
687  std::vector<ServiceFlow*>::iterator iter;
688  std::vector<ServiceFlow*> serviceFlows;
689 
690  serviceFlows = GetBs ()->GetServiceFlowManager ()->GetServiceFlows (ServiceFlow::SF_TYPE_BE);
691  for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
692  {
693  connection = (*iter)->GetConnection ();
694 
695  while ((*iter)->HasPackets () && availableSymbols > 0)
696  {
697  if (connection->GetType () == Cid::MULTICAST)
698  {
699  modulationType = connection->GetServiceFlow ()->GetModulation ();
700  }
701  else
702  {
703  modulationType = GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
704  }
705  diuc = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
707 
708  packet = connection->GetQueue ()->Peek (hdr);
709  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (packet->GetSize (), modulationType);
710 
711  if (availableSymbols < nrSymbolsRequired)
712  {
713  break;
714  }
715 
716  packet = connection->Dequeue ();
717  NS_ASSERT_MSG (hdr.GetCid () == connection->GetCid (),
718  "Base station: Error while scheduling BE connection: header CID != connection CID");
719  burst->AddPacket (packet);
720  availableSymbols -= nrSymbolsRequired;
721  }
722  if (burst->GetNPackets () != 0)
723  {
724  AddDownlinkBurst (connection, diuc, modulationType, burst);
725  burst = Create<PacketBurst> ();
726  }
727  }
728 }
729 
730 } // namespace ns3
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.
Definition: nstime.h:102
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
this class implements a structure to manage some parameters and statistics related to a service flow ...
void BSSchedulerInitialRangingConnection(uint32_t &availableSymbols)
schedules the IR connections
void BSSchedulerUGSConnection(uint32_t &availableSymbols)
schedules the UGS connection
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1001
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:796
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:277
STL namespace.
void BSSchedulerBroadcastConnection(uint32_t &availableSymbols)
schedules the broadcast connections
Ptr< WimaxConnection > GetConnection(void) const
Can return a null connection is this service flow has not been associated yet to a connection...
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 the Generic mac Header as described by IEEE Standard for Local and metropolitan...
void SetDiuc(uint8_t diuc)
Set DIUC field.
static TypeId GetTypeId(void)
Get the type ID.
Cid GetCid(void) const
Get CID field.
void BSSchedulerRTPSConnection(uint32_t &availableSymbols)
Downlink Scheduler for rtPS connections.
Ptr< PacketBurst > CreateUgsBurst(ServiceFlow *serviceFlow, WimaxPhy::ModulationType modulationType, uint32_t availableSymbols)
Creates a downlink UGS burst.
ModulationType
ModulationType enumeration.
Definition: wimax-phy.h:49
#define list
This class implements a simple downlink scheduler for rtPS flows.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void BSSchedulerBasicConnection(uint32_t &availableSymbols)
schedules the basic connections
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:39
virtual Ptr< BaseStationNetDevice > GetBs(void)
Get the base station.
Definition: bs-scheduler.cc:89
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:249
bool SelectConnection(Ptr< WimaxConnection > &connection)
Selects a connection from the list of connections having packets to be sent .
virtual void SetBs(Ptr< BaseStationNetDevice > bs)
Set the base station.
Definition: bs-scheduler.cc:84
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...
#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:90
void BSSchedulerPrimaryConnection(uint32_t &availableSymbols)
schedules the primary connection
void Schedule(void)
Schedule function.
void SetDlTimeStamp(Time dlTimeStamp)
Set the DlTimeStamp.
this class implement a burst as a list of packets
Definition: packet-burst.h:35
Time GetDlTimeStamp(void) const
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:269
std::list< std::pair< OfdmDlMapIe *, Ptr< PacketBurst > > > * m_downlinkBursts
down link bursts
uint16_t GetIdentifier(void) const
Definition: cid.cc:45
void SetCid(Cid cid)
Set CID functon.
void BSSchedulerNRTPSConnection(uint32_t &availableSymbols)
schedules the NRTPS connections
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:914
This class implements the OFDM DL-MAP information element as described by "IEEE Standard for Local an...
void BSSchedulerBEConnection(uint32_t &availableSymbols)
schedules the BE connection
bool HasPackets(void) const
Check if packets are present.