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> > connections;
495  std::vector<ServiceFlow*>::iterator iter2;
496  ServiceFlowRecord *serviceFlowRecord;
497  std::vector<ServiceFlow*> serviceFlows;
498 
499  uint32_t symbolsRequired[100];
500  WimaxPhy::ModulationType modulationType_[100];
501  uint8_t diuc_[100];
502  Ptr<WimaxConnection> rtPSConnection[100];
503  uint32_t dataToSend;
504  uint32_t totSymbolsRequired = 0;
505  int nbConnection = 0;
506 
507  NS_LOG_INFO ("\tDL Scheduler for rtPS flows \n" << "\t\tavailableSymbols = " << availableSymbols);
508 
509  serviceFlows = GetBs ()->GetServiceFlowManager ()->GetServiceFlows (ServiceFlow::SF_TYPE_RTPS);
510  nbConnection = 0;
511  for (iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
512  {
513  // DL RTPS Scheduler works for all rtPS connection that have packets to transmitt!!!
514  serviceFlowRecord = (*iter2)->GetRecord ();
515 
516  if ((*iter2)->HasPackets ())
517  {
518  currentTime = Simulator::Now ();
519  serviceFlowRecord->SetDlTimeStamp (currentTime);
520  rtPSConnection[nbConnection] = (*iter2)->GetConnection ();
521  if (rtPSConnection[nbConnection]->GetType () == Cid::MULTICAST)
522  {
523  modulationType_[nbConnection] = rtPSConnection[nbConnection]->GetServiceFlow ()->GetModulation ();
524  }
525  else
526  {
527  modulationType_[nbConnection]
528  = GetBs ()->GetSSManager ()->GetSSRecord (rtPSConnection[nbConnection]->GetCid ())->GetModulationType ();
529  }
530  diuc_[nbConnection]
531  = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType_[nbConnection],
533 
534  dataToSend = rtPSConnection[nbConnection]->GetQueue ()->GetQueueLengthWithMACOverhead ();
535  NS_LOG_INFO ("\t\tRTPS DL Scheduler for CID = " << rtPSConnection[nbConnection]->GetCid ()
536  << "\n\t\t\t dataToSend = " << dataToSend);
537 
538  symbolsRequired[nbConnection] = GetBs ()->GetPhy ()->GetNrSymbols (dataToSend,
539  modulationType_[nbConnection]);
540 
541  totSymbolsRequired += symbolsRequired[nbConnection];
542  nbConnection++;
543  }
544  }
545 
546  NS_LOG_INFO ("\t\ttotSymbolsRequired = " << totSymbolsRequired);
547 
548  // Channel Saturation
549  while (totSymbolsRequired > availableSymbols)
550  {
551  NS_LOG_INFO ("\tDL Channel Saturation: totSymbolsRequired > availableSymbols_rtPS");
552  double delta = double(availableSymbols) / double(totSymbolsRequired);
553  NS_LOG_INFO ("\t\tdelta = " << delta);
554  totSymbolsRequired = 0;
555  for (int i = 0; i < nbConnection; i++)
556  {
557  NS_LOG_INFO ("\t\tprevious symbolsRequired[" << i << "] = " << symbolsRequired[i]);
558  symbolsRequired[i] = (uint32_t) std::floor (symbolsRequired[i] * delta);
559  totSymbolsRequired += symbolsRequired[i];
560  NS_LOG_INFO ("\t\tnew symbolsRequired[" << i << "] = " << symbolsRequired[i]);
561  }
562  NS_LOG_INFO ("\t\ttotSymbolsRequired = " << totSymbolsRequired);
563  }
564 
565  // Downlink Bandwidth Allocation
566  for (int i = 0; i < nbConnection; i++)
567  {
568 
569  packet = rtPSConnection[i]->GetQueue ()->Peek (hdr);
570  uint32_t symbolsForPacketTransmission = 0;
571  burst = Create<PacketBurst> ();
572  NS_LOG_INFO ("\t\tCID = " << rtPSConnection[i]->GetCid () << " assignedSymbols = " << symbolsRequired[i]);
573 
574  while (symbolsRequired[i] > 0)
575  {
576  symbolsForPacketTransmission = GetBs ()->GetPhy ()
577  ->GetNrSymbols (rtPSConnection[i]->GetQueue ()
578  ->GetFirstPacketRequiredByte (MacHeaderType::HEADER_TYPE_GENERIC),
579  modulationType_[i]);
580 
581  // PIRO: check for fragmentation
582  if (symbolsForPacketTransmission > symbolsRequired[i]
583  && !CheckForFragmentation (rtPSConnection[i],
584  symbolsRequired[i],
585  modulationType_[i]))
586  {
587  break;
588  }
589  else if (symbolsForPacketTransmission > symbolsRequired[i]
590  && CheckForFragmentation (rtPSConnection[i],
591  symbolsRequired[i],
592  modulationType_[i]))
593  {
594  uint32_t availableByte = GetBs ()->GetPhy ()->
595  GetNrBytes (symbolsRequired[i], modulationType_[i]);
596  packet = rtPSConnection[i]->Dequeue (MacHeaderType::HEADER_TYPE_GENERIC, availableByte);
597  symbolsRequired[i] = 0;
598  }
599  else
600  {
601  packet = rtPSConnection[i]->Dequeue ();
602  symbolsRequired[i] -= symbolsForPacketTransmission;
603  }
604 
605  NS_ASSERT_MSG (hdr.GetCid () == rtPSConnection[i]->GetCid (),
606  "Base station: Error while scheduling RTPs connection: header CID != connection CID");
607  burst->AddPacket (packet);
608  }
609 
610  if (burst->GetNPackets () != 0)
611  {
612  AddDownlinkBurst (rtPSConnection[i], diuc_[i], modulationType_[i], burst);
613  }
614  }
615 
616  availableSymbols -= totSymbolsRequired;
617 }
618 
619 void
621 {
622  Ptr<WimaxConnection> connection;
624  uint8_t diuc = 0;
625  uint32_t nrSymbolsRequired = 0;
626  GenericMacHeader hdr;
627  Ptr<Packet> packet;
628  Ptr<PacketBurst> burst = Create<PacketBurst> ();
629 
630  std::vector<ServiceFlow*>::iterator iter;
631  std::vector<ServiceFlow*> serviceFlows;
632 
633  serviceFlows = GetBs ()->GetServiceFlowManager ()->GetServiceFlows (ServiceFlow::SF_TYPE_NRTPS);
634  for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
635  {
636  connection = (*iter)->GetConnection ();
637 
638  while ((*iter)->HasPackets () && availableSymbols > 0)
639  {
640  if (connection->GetType () == Cid::MULTICAST)
641  {
642  modulationType = connection->GetServiceFlow ()->GetModulation ();
643  }
644  else
645  {
646  modulationType = GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
647  }
648 
649  diuc = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
651 
652  packet = connection->GetQueue ()->Peek (hdr);
653  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (packet->GetSize (), modulationType);
654 
655  if (availableSymbols < nrSymbolsRequired)
656  {
657  break;
658  }
659 
660  packet = connection->Dequeue ();
661  NS_ASSERT_MSG (hdr.GetCid () == connection->GetCid (),
662  "Base station: Error while scheduling NRTPs connection: header CID != connection CID");
663  burst->AddPacket (packet);
664  availableSymbols -= nrSymbolsRequired;
665  }
666  if (burst->GetNPackets () != 0)
667  {
668  AddDownlinkBurst (connection, diuc, modulationType, burst);
669  burst = Create<PacketBurst> ();
670  }
671  }
672 }
673 
674 void
675 BSSchedulerRtps::BSSchedulerBEConnection (uint32_t &availableSymbols)
676 {
677  Ptr<WimaxConnection> connection;
679  uint8_t diuc = 0;
680  uint32_t nrSymbolsRequired = 0;
681  GenericMacHeader hdr;
682  Ptr<Packet> packet;
683  Ptr<PacketBurst> burst = Create<PacketBurst> ();
684 
685  std::vector<ServiceFlow*>::iterator iter;
686  std::vector<ServiceFlow*> serviceFlows;
687 
688  serviceFlows = GetBs ()->GetServiceFlowManager ()->GetServiceFlows (ServiceFlow::SF_TYPE_BE);
689  for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
690  {
691  connection = (*iter)->GetConnection ();
692 
693  while ((*iter)->HasPackets () && availableSymbols > 0)
694  {
695  if (connection->GetType () == Cid::MULTICAST)
696  {
697  modulationType = connection->GetServiceFlow ()->GetModulation ();
698  }
699  else
700  {
701  modulationType = GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
702  }
703  diuc = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
705 
706  packet = connection->GetQueue ()->Peek (hdr);
707  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (packet->GetSize (), modulationType);
708 
709  if (availableSymbols < nrSymbolsRequired)
710  {
711  break;
712  }
713 
714  packet = connection->Dequeue ();
715  NS_ASSERT_MSG (hdr.GetCid () == connection->GetCid (),
716  "Base station: Error while scheduling BE connection: header CID != connection CID");
717  burst->AddPacket (packet);
718  availableSymbols -= nrSymbolsRequired;
719  }
720  if (burst->GetNPackets () != 0)
721  {
722  AddDownlinkBurst (connection, diuc, modulationType, burst);
723  burst = Create<PacketBurst> ();
724  }
725  }
726 }
727 
728 } // namespace ns3
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
std::list< std::pair< OfdmDlMapIe *, Ptr< PacketBurst > > > * GetDownlinkBursts(void) const
This function returns all the downlink bursts scheduled for the next downlink sub-frame.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
Definition: packet.h:852
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
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:205
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Definition: nstime.h:1078
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
Cid GetCid(void) const
Get CID field.
STL namespace.
void BSSchedulerBroadcastConnection(uint32_t &availableSymbols)
schedules the broadcast connections
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...
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.
static TypeId GetTypeId(void)
Get the type ID.
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.
#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:193
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.
ModulationType
ModulationType enumeration.
Definition: wimax-phy.h:49
void SetDlTimeStamp(Time dlTimeStamp)
Set the DlTimeStamp.
this class implement a burst as a list of packets
Definition: packet-burst.h:35
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
Time GetDlTimeStamp(void) const
bool HasPackets(void) const
Check if packets are present.
std::list< std::pair< OfdmDlMapIe *, Ptr< PacketBurst > > > * m_downlinkBursts
down link bursts
void SetCid(Cid cid)
Set CID function.
void BSSchedulerNRTPSConnection(uint32_t &availableSymbols)
schedules the NRTPS connections
uint16_t GetIdentifier(void) const
Definition: cid.cc:45
a unique identifier for an interface.
Definition: type-id.h:58
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
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