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 
39 namespace ns3 {
40 
41 NS_LOG_COMPONENT_DEFINE ("BSSchedulerRtps");
42 
43 NS_OBJECT_ENSURE_REGISTERED (BSSchedulerRtps);
44 
45 TypeId
47 {
48  static TypeId tid = TypeId ("ns3::BSSchedulerRtps")
50  .SetGroupName("Wimax")
51  .AddConstructor<BSSchedulerRtps> ()
52  ;
53  return tid;
54 }
55 
57  : m_downlinkBursts (new std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > > ())
58 {
59  SetBs (0);
60 }
61 
63  : m_downlinkBursts (new std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > > ())
64 {
65  // m_downlinkBursts is filled by AddDownlinkBurst and emptied by
66  // wimax-bs-net-device::sendBurst and wimax-ss-net-device::sendBurst
67  SetBs (bs);
68 }
69 
71 {
72 
73  std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > > *downlinkBursts = m_downlinkBursts;
74  std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > pair;
75  while (downlinkBursts->size ())
76  {
77  pair = downlinkBursts->front ();
78  pair.second = 0;
79  delete pair.first;
80  }
81 
82  SetBs (0);
83  delete m_downlinkBursts;
84  m_downlinkBursts = 0;
85 }
86 
87 std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > >*
89 {
90  return m_downlinkBursts;
91 }
92 
93 void
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" << ", pkts: " << burst->GetNPackets ()
104  << ", connection: " << connection->GetTypeStr () << ", CID: "
105  << connection->GetCid ());
106  if (connection->GetType () == Cid::TRANSPORT)
107  {
108  NS_LOG_INFO (", SFID: " << connection->GetServiceFlow ()->GetSfid () << ", service: "
109  << connection->GetServiceFlow ()->GetSchedulingTypeStr ());
110  }
111  NS_LOG_INFO (", modulation: " << modulationType << ", DIUC: " << (uint32_t) diuc);
112 
113  m_downlinkBursts->push_back (std::make_pair (dlMapIe, burst));
114 }
115 
130 void
132 {
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->size ())
153  {
154  NS_LOG_DEBUG ("BS scheduler, number of bursts: " << m_downlinkBursts->size () << ", symbols left: "
155  << availableSymbols << std::endl << "BS scheduler, queues:" << " IR "
156  << GetBs ()->GetInitialRangingConnection ()->GetQueue ()->GetSize ()
157  << " broadcast "
158  << GetBs ()->GetBroadcastConnection ()->GetQueue ()->GetSize ()
159  << " basic "
160  << GetBs ()->GetConnectionManager ()->GetNPackets (Cid::BASIC, ServiceFlow::SF_TYPE_NONE)
161  << " primary "
162  << GetBs ()->GetConnectionManager ()->GetNPackets (Cid::PRIMARY, ServiceFlow::SF_TYPE_NONE)
163  << " transport "
164  << GetBs ()->GetConnectionManager ()->GetNPackets (Cid::TRANSPORT, ServiceFlow::SF_TYPE_ALL));
165  }
166 }
167 
168 
170  WimaxPhy::ModulationType modulationType,
171  uint32_t availableSymbols)
172 {
173  Time timeStamp;
174  GenericMacHeader hdr;
175  Ptr<Packet> packet;
176  Ptr<PacketBurst> burst = Create<PacketBurst> ();
177  uint32_t nrSymbolsRequired = 0;
178 
179  // serviceFlow->CleanUpQueue ();
180  Ptr<WimaxConnection> connection = serviceFlow->GetConnection ();
181  while (serviceFlow->HasPackets ())
182  {
183  uint32_t FirstPacketSize = connection->GetQueue ()->GetFirstPacketRequiredByte (MacHeaderType::HEADER_TYPE_GENERIC);
184  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (FirstPacketSize,modulationType);
185  if (availableSymbols < nrSymbolsRequired && CheckForFragmentation (connection,
186  availableSymbols,
187  modulationType))
188  {
189  uint32_t availableByte = GetBs ()->GetPhy ()->GetNrBytes (availableSymbols, modulationType);
190  packet = connection->Dequeue (MacHeaderType::HEADER_TYPE_GENERIC, availableByte);
191  availableSymbols = 0;
192  }
193  else
194  {
195  packet = connection->Dequeue ();
196  availableSymbols -= nrSymbolsRequired;
197  }
198  burst->AddPacket (packet);
199  if (availableSymbols <= 0)
200  {
201  break;
202  }
203  }
204  return burst;
205 }
206 
207 
208 bool
210 {
211  return false;
212 }
213 
214 void
216 {
217  Ptr<WimaxConnection> connection;
220  uint32_t nrSymbolsRequired = 0;
221  GenericMacHeader hdr;
222  Ptr<Packet> packet;
223  Ptr<PacketBurst> burst = Create<PacketBurst> ();
224 
225  while (GetBs ()->GetBroadcastConnection ()->HasPackets () && availableSymbols > 0)
226  {
227  connection = GetBs ()->GetBroadcastConnection ();
228 
229  packet = connection->GetQueue ()->Peek (hdr);
230  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (packet->GetSize (), modulationType);
231 
232  if (availableSymbols < nrSymbolsRequired
233  && !CheckForFragmentation (connection, availableSymbols, modulationType))
234  {
235  break;
236  }
237  else if (availableSymbols < nrSymbolsRequired
238  && CheckForFragmentation (connection, availableSymbols, modulationType))
239  {
240  uint32_t availableByte = GetBs ()->GetPhy ()->
241  GetNrBytes (availableSymbols, modulationType);
242  packet = connection->Dequeue (MacHeaderType::HEADER_TYPE_GENERIC,
243  availableByte);
244  }
245  else
246  {
247  packet = connection->Dequeue ();
248  }
249 
250  NS_ASSERT_MSG (hdr.GetCid ().GetIdentifier () == connection->GetCid (),
251  "Base station: Error while scheduling broadcast connection: header CID != connection CID");
252  burst->AddPacket (packet);
253  availableSymbols -= nrSymbolsRequired;
254  }
255  if (burst->GetNPackets () != 0)
256  {
257  AddDownlinkBurst (connection, diuc, modulationType, burst);
258  }
259 }
260 
261 void
263 {
264  Ptr<WimaxConnection> connection;
267  uint32_t nrSymbolsRequired = 0;
268  GenericMacHeader hdr;
269  Ptr<Packet> packet;
270  Ptr<PacketBurst> burst = Create<PacketBurst> ();
271 
272  while (GetBs ()->GetInitialRangingConnection ()->HasPackets () && availableSymbols > 0)
273  {
274  connection = GetBs ()->GetInitialRangingConnection ();
275 
276  packet = connection->GetQueue ()->Peek (hdr);
277  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (packet->GetSize (), modulationType);
278 
279  // PIRO: check for fragmentation
280  if (availableSymbols < nrSymbolsRequired
281  && !CheckForFragmentation (connection, availableSymbols, modulationType))
282  {
283  break;
284  }
285  else if (availableSymbols < nrSymbolsRequired
286  && CheckForFragmentation (connection, availableSymbols, modulationType))
287  {
288  uint32_t availableByte = GetBs ()->GetPhy ()->
289  GetNrBytes (availableSymbols, modulationType);
290  packet = connection->Dequeue (MacHeaderType::HEADER_TYPE_GENERIC,
291  availableByte);
292  }
293  else
294  {
295  packet = connection->Dequeue ();
296  }
297 
298  NS_ASSERT_MSG (hdr.GetCid () == connection->GetCid (),
299  "Base station: Error while scheduling initial ranging connection: header CID != connection CID");
300  burst->AddPacket (packet);
301  availableSymbols -= nrSymbolsRequired;
302  }
303  if (burst->GetNPackets ())
304  {
305  AddDownlinkBurst (connection, diuc, modulationType, burst);
306  }
307 }
308 
309 void
311 {
312  Ptr<WimaxConnection> connection;
315  uint32_t nrSymbolsRequired = 0;
316  GenericMacHeader hdr;
317  Ptr<Packet> packet;
318  Ptr<PacketBurst> burst = Create<PacketBurst> ();
319 
320  std::vector<Ptr<WimaxConnection> >::const_iterator iter;
321  std::vector<Ptr<WimaxConnection> > connections;
322 
323  connections = GetBs ()->GetConnectionManager ()->GetConnections (Cid::BASIC);
324  for (iter = connections.begin (); iter != connections.end (); ++iter)
325  {
326  while ((*iter)->HasPackets () && availableSymbols > 0)
327  {
328  connection = *iter;
329 
330  modulationType = GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
331  diuc = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
333 
334  packet = connection->GetQueue ()->Peek (hdr);
335  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (packet->GetSize (), modulationType);
336 
337  // PIRO: check for fragmentation
338  if (availableSymbols < nrSymbolsRequired
339  && !CheckForFragmentation (connection, availableSymbols, modulationType))
340  {
341  break;
342  }
343  else if (availableSymbols < nrSymbolsRequired
344  && CheckForFragmentation (connection, availableSymbols, modulationType))
345  {
346  uint32_t availableByte = GetBs ()->GetPhy ()->
347  GetNrBytes (availableSymbols, modulationType);
348  packet = connection->Dequeue (MacHeaderType::HEADER_TYPE_GENERIC, availableByte);
349  }
350  else
351  {
352  packet = connection->Dequeue ();
353  }
354 
355  NS_ASSERT_MSG (hdr.GetCid () == connection->GetCid (),
356  "Base station: Error while scheduling basic connection: header CID != connection CID");
357  burst->AddPacket (packet);
358  availableSymbols -= nrSymbolsRequired;
359  }
360  if (burst->GetNPackets () != 0)
361  {
362  AddDownlinkBurst (connection, diuc, modulationType, burst);
363  burst = Create<PacketBurst> ();
364  }
365  }
366 }
367 
368 void
370 {
371  Ptr<WimaxConnection> connection;
373  uint8_t diuc = 0;
374  uint32_t nrSymbolsRequired = 0;
375  GenericMacHeader hdr;
376  Ptr<Packet> packet;
377  Ptr<PacketBurst> burst = Create<PacketBurst> ();
378 
379  std::vector<Ptr<WimaxConnection> >::const_iterator iter;
380  std::vector<Ptr<WimaxConnection> > connections;
381 
382  connections = GetBs ()->GetConnectionManager ()->GetConnections (Cid::PRIMARY);
383  for (iter = connections.begin (); iter != connections.end (); ++iter)
384  {
385  while ((*iter)->HasPackets () && availableSymbols > 0)
386  {
387  connection = *iter;
388 
389  modulationType = GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
390  diuc = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
392 
393  packet = connection->GetQueue ()->Peek (hdr);
394  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (packet->GetSize (), modulationType);
395 
396  // PIRO: check for fragmentation
397  if (availableSymbols < nrSymbolsRequired
398  && !CheckForFragmentation (connection, availableSymbols, modulationType))
399  {
400  break;
401  }
402  else if (availableSymbols < nrSymbolsRequired
403  && CheckForFragmentation (connection, availableSymbols, modulationType))
404  {
405  uint32_t availableByte = GetBs ()->GetPhy ()->
406  GetNrBytes (availableSymbols, modulationType);
407  packet = connection->Dequeue (MacHeaderType::HEADER_TYPE_GENERIC, availableByte);
408  }
409  else
410  {
411  packet = connection->Dequeue ();
412  }
413 
414  NS_ASSERT_MSG (hdr.GetCid () == connection->GetCid (),
415  "Base station: Error while scheduling primary connection: header CID != connection CID");
416  burst->AddPacket (packet);
417  availableSymbols -= nrSymbolsRequired;
418  }
419  if (burst->GetNPackets () != 0)
420  {
421  AddDownlinkBurst (connection, diuc, modulationType, burst);
422  }
423  }
424 }
425 
426 void
427 BSSchedulerRtps::BSSchedulerUGSConnection (uint32_t &availableSymbols)
428 {
429  Ptr<WimaxConnection> connection;
431  uint8_t diuc;
432  uint32_t nrSymbolsRequired = 0;
433  GenericMacHeader hdr;
434  Ptr<Packet> packet;
435  Ptr<PacketBurst> burst = Create<PacketBurst> ();
436 
437  Time currentTime = Simulator::Now ();
438 
439  std::vector<ServiceFlow*>::iterator iter;
440  ServiceFlowRecord *serviceFlowRecord;
441  std::vector<ServiceFlow*> serviceFlows;
442 
443  serviceFlows = GetBs ()->GetServiceFlowManager ()->GetServiceFlows (ServiceFlow::SF_TYPE_UGS);
444  for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
445  {
446  serviceFlowRecord = (*iter)->GetRecord ();
447  // if latency would exceed in case grant is allocated in next frame then allocate in current frame
448  if ((*iter)->HasPackets () && ((currentTime - serviceFlowRecord->GetDlTimeStamp ())
449  + GetBs ()->GetPhy ()->GetFrameDuration ()) > MilliSeconds ((*iter)->GetMaximumLatency ()))
450  {
451  connection = (*iter)->GetConnection ();
452  if (connection->GetType () == Cid::MULTICAST)
453  {
454  modulationType = connection->GetServiceFlow ()->GetModulation ();
455  }
456  else
457  {
458  modulationType = GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
459  }
460  diuc = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
462 
463  nrSymbolsRequired = connection->GetServiceFlow ()->GetRecord ()->GetGrantSize ();
464 
465  // Packet fragmentation for UGS connections has not been implemented yet!
466  if (availableSymbols > nrSymbolsRequired)
467  {
468  availableSymbols -= nrSymbolsRequired;
469  burst = CreateUgsBurst (connection->GetServiceFlow (), modulationType, nrSymbolsRequired);
470  if (burst->GetNPackets () != 0)
471  {
472  AddDownlinkBurst (connection, diuc, modulationType, burst);
473  currentTime = Simulator::Now ();
474  serviceFlowRecord->SetDlTimeStamp (currentTime);
475  burst = Create<PacketBurst> ();
476  }
477  }
478  }
479  }
480 
481 }
482 
483 void
484 BSSchedulerRtps::BSSchedulerRTPSConnection (uint32_t &availableSymbols)
485 {
486 
487  Ptr<WimaxConnection> connection;
488  GenericMacHeader hdr;
489  Ptr<Packet> packet;
490  Ptr<PacketBurst> burst = Create<PacketBurst> ();
491 
492  Time currentTime = Simulator::Now ();
493 
494  std::vector<Ptr<WimaxConnection> >::const_iterator iter;
495  std::vector<Ptr<WimaxConnection> > connections;
496  std::vector<ServiceFlow*>::iterator iter2;
497  ServiceFlowRecord *serviceFlowRecord;
498  std::vector<ServiceFlow*> serviceFlows;
499 
500  uint32_t symbolsRequired[100];
501  WimaxPhy::ModulationType modulationType_[100];
502  uint8_t diuc_[100];
503  Ptr<WimaxConnection> rtPSConnection[100];
504  uint32_t dataToSend;
505  uint32_t totSymbolsRequired = 0;
506  int nbConnection = 0;
507 
508  NS_LOG_INFO ("\tDL Scheduler for rtPS flows \n" << "\t\tavailableSymbols = " << availableSymbols);
509 
510  serviceFlows = GetBs ()->GetServiceFlowManager ()->GetServiceFlows (ServiceFlow::SF_TYPE_RTPS);
511  nbConnection = 0;
512  for (iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
513  {
514  // DL RTPS Scheduler works for all rtPS connection that have packets to transmitt!!!
515  serviceFlowRecord = (*iter2)->GetRecord ();
516 
517  if ((*iter2)->HasPackets ())
518  {
519  currentTime = Simulator::Now ();
520  serviceFlowRecord->SetDlTimeStamp (currentTime);
521  rtPSConnection[nbConnection] = (*iter2)->GetConnection ();
522  if (rtPSConnection[nbConnection]->GetType () == Cid::MULTICAST)
523  {
524  modulationType_[nbConnection] = rtPSConnection[nbConnection]->GetServiceFlow ()->GetModulation ();
525  }
526  else
527  {
528  modulationType_[nbConnection]
529  = GetBs ()->GetSSManager ()->GetSSRecord (rtPSConnection[nbConnection]->GetCid ())->GetModulationType ();
530  }
531  diuc_[nbConnection]
532  = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType_[nbConnection],
534 
535  dataToSend = rtPSConnection[nbConnection]->GetQueue ()->GetQueueLengthWithMACOverhead ();
536  NS_LOG_INFO ("\t\tRTPS DL Scheduler for CID = " << rtPSConnection[nbConnection]->GetCid ()
537  << "\n\t\t\t dataToSend = " << dataToSend);
538 
539  symbolsRequired[nbConnection] = GetBs ()->GetPhy ()->GetNrSymbols (dataToSend,
540  modulationType_[nbConnection]);
541 
542  totSymbolsRequired += symbolsRequired[nbConnection];
543  nbConnection++;
544  }
545  }
546 
547  NS_LOG_INFO ("\t\ttotSymbolsRequired = " << totSymbolsRequired);
548 
549  // Channel Saturation
550  while (totSymbolsRequired > availableSymbols)
551  {
552  NS_LOG_INFO ("\tDL Channel Saturation: totSymbolsRequired > availableSymbols_rtPS");
553  double delta = double(availableSymbols) / double(totSymbolsRequired);
554  NS_LOG_INFO ("\t\tdelta = " << delta);
555  totSymbolsRequired = 0;
556  for (int i = 0; i < nbConnection; i++)
557  {
558  NS_LOG_INFO ("\t\tprevious symbolsRequired[" << i << "] = " << symbolsRequired[i]);
559  symbolsRequired[i] = (uint32_t) std::floor (symbolsRequired[i] * delta);
560  totSymbolsRequired += symbolsRequired[i];
561  NS_LOG_INFO ("\t\tnew symbolsRequired[" << i << "] = " << symbolsRequired[i]);
562  }
563  NS_LOG_INFO ("\t\ttotSymbolsRequired = " << totSymbolsRequired);
564  }
565 
566  // Downlink Bandwidth Allocation
567  for (int i = 0; i < nbConnection; i++)
568  {
569 
570  packet = rtPSConnection[i]->GetQueue ()->Peek (hdr);
571  uint32_t symbolsForPacketTransmission = 0;
572  burst = Create<PacketBurst> ();
573  NS_LOG_INFO ("\t\tCID = " << rtPSConnection[i]->GetCid () << " assignedSymbols = " << symbolsRequired[i]);
574 
575  while (symbolsRequired[i] > 0)
576  {
577  symbolsForPacketTransmission = GetBs ()->GetPhy ()
578  ->GetNrSymbols (rtPSConnection[i]->GetQueue ()
579  ->GetFirstPacketRequiredByte (MacHeaderType::HEADER_TYPE_GENERIC),
580  modulationType_[i]);
581 
582  // PIRO: check for fragmentation
583  if (symbolsForPacketTransmission > symbolsRequired[i]
584  && !CheckForFragmentation (rtPSConnection[i],
585  symbolsRequired[i],
586  modulationType_[i]))
587  {
588  break;
589  }
590  else if (symbolsForPacketTransmission > symbolsRequired[i]
591  && CheckForFragmentation (rtPSConnection[i],
592  symbolsRequired[i],
593  modulationType_[i]))
594  {
595  uint32_t availableByte = GetBs ()->GetPhy ()->
596  GetNrBytes (symbolsRequired[i], modulationType_[i]);
597  packet = rtPSConnection[i]->Dequeue (MacHeaderType::HEADER_TYPE_GENERIC, availableByte);
598  symbolsRequired[i] = 0;
599  }
600  else
601  {
602  packet = rtPSConnection[i]->Dequeue ();
603  symbolsRequired[i] -= symbolsForPacketTransmission;
604  }
605 
606  NS_ASSERT_MSG (hdr.GetCid () == rtPSConnection[i]->GetCid (),
607  "Base station: Error while scheduling RTPs connection: header CID != connection CID");
608  burst->AddPacket (packet);
609  }
610 
611  if (burst->GetNPackets () != 0)
612  {
613  AddDownlinkBurst (rtPSConnection[i], diuc_[i], modulationType_[i], burst);
614  }
615  }
616 
617  availableSymbols -= totSymbolsRequired;
618 }
619 
620 void
622 {
623  Ptr<WimaxConnection> connection;
625  uint8_t diuc = 0;
626  uint32_t nrSymbolsRequired = 0;
627  GenericMacHeader hdr;
628  Ptr<Packet> packet;
629  Ptr<PacketBurst> burst = Create<PacketBurst> ();
630 
631  std::vector<ServiceFlow*>::iterator iter;
632  std::vector<ServiceFlow*> serviceFlows;
633 
634  serviceFlows = GetBs ()->GetServiceFlowManager ()->GetServiceFlows (ServiceFlow::SF_TYPE_NRTPS);
635  for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
636  {
637  connection = (*iter)->GetConnection ();
638 
639  while ((*iter)->HasPackets () && availableSymbols > 0)
640  {
641  if (connection->GetType () == Cid::MULTICAST)
642  {
643  modulationType = connection->GetServiceFlow ()->GetModulation ();
644  }
645  else
646  {
647  modulationType = GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
648  }
649 
650  diuc = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
652 
653  packet = connection->GetQueue ()->Peek (hdr);
654  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (packet->GetSize (), modulationType);
655 
656  if (availableSymbols < nrSymbolsRequired)
657  {
658  break;
659  }
660 
661  packet = connection->Dequeue ();
662  NS_ASSERT_MSG (hdr.GetCid () == connection->GetCid (),
663  "Base station: Error while scheduling NRTPs connection: header CID != connection CID");
664  burst->AddPacket (packet);
665  availableSymbols -= nrSymbolsRequired;
666  }
667  if (burst->GetNPackets () != 0)
668  {
669  AddDownlinkBurst (connection, diuc, modulationType, burst);
670  burst = Create<PacketBurst> ();
671  }
672  }
673 }
674 
675 void
676 BSSchedulerRtps::BSSchedulerBEConnection (uint32_t &availableSymbols)
677 {
678  Ptr<WimaxConnection> connection;
680  uint8_t diuc = 0;
681  uint32_t nrSymbolsRequired = 0;
682  GenericMacHeader hdr;
683  Ptr<Packet> packet;
684  Ptr<PacketBurst> burst = Create<PacketBurst> ();
685 
686  std::vector<ServiceFlow*>::iterator iter;
687  std::vector<ServiceFlow*> serviceFlows;
688 
689  serviceFlows = GetBs ()->GetServiceFlowManager ()->GetServiceFlows (ServiceFlow::SF_TYPE_BE);
690  for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
691  {
692  connection = (*iter)->GetConnection ();
693 
694  while ((*iter)->HasPackets () && availableSymbols > 0)
695  {
696  if (connection->GetType () == Cid::MULTICAST)
697  {
698  modulationType = connection->GetServiceFlow ()->GetModulation ();
699  }
700  else
701  {
702  modulationType = GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
703  }
704  diuc = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
706 
707  packet = connection->GetQueue ()->Peek (hdr);
708  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (packet->GetSize (), modulationType);
709 
710  if (availableSymbols < nrSymbolsRequired)
711  {
712  break;
713  }
714 
715  packet = connection->Dequeue ();
716  NS_ASSERT_MSG (hdr.GetCid () == connection->GetCid (),
717  "Base station: Error while scheduling BE connection: header CID != connection CID");
718  burst->AddPacket (packet);
719  availableSymbols -= nrSymbolsRequired;
720  }
721  if (burst->GetNPackets () != 0)
722  {
723  AddDownlinkBurst (connection, diuc, modulationType, burst);
724  burst = Create<PacketBurst> ();
725  }
726  }
727 }
728 
729 } // 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:1015
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:821
#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...
NS_ASSERT_MSG(false,"Ipv4AddressGenerator::MaskToIndex(): Impossible")
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...
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.