A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("BSSchedulerRtps");
41 
42 namespace ns3 {
43 
44 NS_OBJECT_ENSURE_REGISTERED (BSSchedulerRtps)
45  ;
46 
47 TypeId
49 {
50  static TypeId tid = TypeId ("ns3::BSSchedulerRtps").SetParent<Object> ().AddConstructor<BSSchedulerRtps> ();
51  return tid;
52 }
53 
55  : m_downlinkBursts (new std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > > ())
56 {
57  SetBs (0);
58 }
59 
61  : m_downlinkBursts (new std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > > ())
62 {
63  // m_downlinkBursts is filled by AddDownlinkBurst and emptied by
64  // wimax-bs-net-device::sendBurst and wimax-ss-net-device::sendBurst
65  SetBs (bs);
66 }
67 
69 {
70 
71  std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > > *downlinkBursts = m_downlinkBursts;
72  std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > pair;
73  while (downlinkBursts->size ())
74  {
75  pair = downlinkBursts->front ();
76  pair.second = 0;
77  delete pair.first;
78  }
79 
80  SetBs (0);
81  delete m_downlinkBursts;
82  m_downlinkBursts = 0;
83 }
84 
85 std::list<std::pair<OfdmDlMapIe*, Ptr<PacketBurst> > >*
87 {
88  return m_downlinkBursts;
89 }
90 
91 void
93  uint8_t diuc,
94  WimaxPhy::ModulationType modulationType,
95  Ptr<PacketBurst> burst)
96 {
97  OfdmDlMapIe *dlMapIe = new OfdmDlMapIe ();
98  dlMapIe->SetCid (connection->GetCid ());
99  dlMapIe->SetDiuc (diuc);
100 
101  NS_LOG_INFO ("BS scheduler, burst size: " << burst->GetSize () << " bytes" << ", pkts: " << burst->GetNPackets ()
102  << ", connection: " << connection->GetTypeStr () << ", CID: "
103  << connection->GetCid ());
104  if (connection->GetType () == Cid::TRANSPORT)
105  {
106  NS_LOG_INFO (", SFID: " << connection->GetServiceFlow ()->GetSfid () << ", service: "
107  << connection->GetServiceFlow ()->GetSchedulingTypeStr ());
108  }
109  NS_LOG_INFO (", modulation: " << modulationType << ", DIUC: " << (uint32_t) diuc);
110 
111  m_downlinkBursts->push_back (std::make_pair (dlMapIe, burst));
112 }
113 
128 void
130 {
131 
132  uint32_t availableSymbols = GetBs ()->GetNrDlSymbols ();
133 
134  BSSchedulerBroadcastConnection (availableSymbols);
135 
136  BSSchedulerInitialRangingConnection (availableSymbols);
137 
138  BSSchedulerBasicConnection (availableSymbols);
139 
140  BSSchedulerPrimaryConnection (availableSymbols);
141 
142  BSSchedulerUGSConnection (availableSymbols);
143 
144  BSSchedulerRTPSConnection (availableSymbols);
145 
146  BSSchedulerNRTPSConnection (availableSymbols);
147 
148  BSSchedulerBEConnection (availableSymbols);
149 
150  if (m_downlinkBursts->size ())
151  {
152  NS_LOG_DEBUG ("BS scheduler, number of bursts: " << m_downlinkBursts->size () << ", symbols left: "
153  << availableSymbols << std::endl << "BS scheduler, queues:" << " IR "
154  << GetBs ()->GetInitialRangingConnection ()->GetQueue ()->GetSize ()
155  << " broadcast "
156  << GetBs ()->GetBroadcastConnection ()->GetQueue ()->GetSize ()
157  << " basic "
158  << GetBs ()->GetConnectionManager ()->GetNPackets (Cid::BASIC, ServiceFlow::SF_TYPE_NONE)
159  << " primary "
160  << GetBs ()->GetConnectionManager ()->GetNPackets (Cid::PRIMARY, ServiceFlow::SF_TYPE_NONE)
161  << " transport "
162  << GetBs ()->GetConnectionManager ()->GetNPackets (Cid::TRANSPORT, ServiceFlow::SF_TYPE_ALL));
163  }
164 }
165 
166 
168  WimaxPhy::ModulationType modulationType,
169  uint32_t availableSymbols)
170 {
171  Time timeStamp;
172  GenericMacHeader hdr;
173  Ptr<Packet> packet;
174  Ptr<PacketBurst> burst = Create<PacketBurst> ();
175  uint32_t nrSymbolsRequired = 0;
176 
177  // serviceFlow->CleanUpQueue ();
178  Ptr<WimaxConnection> connection = serviceFlow->GetConnection ();
179  while (serviceFlow->HasPackets ())
180  {
181  uint32_t FirstPacketSize = connection->GetQueue ()->GetFirstPacketRequiredByte (MacHeaderType::HEADER_TYPE_GENERIC);
182  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (FirstPacketSize,modulationType);
183  if (availableSymbols < nrSymbolsRequired && CheckForFragmentation (connection,
184  availableSymbols,
185  modulationType))
186  {
187  uint32_t availableByte = GetBs ()->GetPhy ()->GetNrBytes (availableSymbols, modulationType);
188  packet = connection->Dequeue (MacHeaderType::HEADER_TYPE_GENERIC, availableByte);
189  availableSymbols = 0;
190  }
191  else
192  {
193  packet = connection->Dequeue ();
194  availableSymbols -= nrSymbolsRequired;
195  }
196  burst->AddPacket (packet);
197  if (availableSymbols <= 0)
198  {
199  break;
200  }
201  }
202  return burst;
203 }
204 
205 
206 bool
208 {
209  return false;
210 }
211 
212 void
214 {
215  Ptr<WimaxConnection> connection;
218  uint32_t nrSymbolsRequired = 0;
219  GenericMacHeader hdr;
220  Ptr<Packet> packet;
221  Ptr<PacketBurst> burst = Create<PacketBurst> ();
222 
223  while (GetBs ()->GetBroadcastConnection ()->HasPackets () && availableSymbols > 0)
224  {
225  connection = GetBs ()->GetBroadcastConnection ();
226 
227  packet = connection->GetQueue ()->Peek (hdr);
228  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (packet->GetSize (), modulationType);
229 
230  if (availableSymbols < nrSymbolsRequired
231  && !CheckForFragmentation (connection, availableSymbols, modulationType))
232  {
233  break;
234  }
235  else if (availableSymbols < nrSymbolsRequired
236  && CheckForFragmentation (connection, availableSymbols, modulationType))
237  {
238  uint32_t availableByte = GetBs ()->GetPhy ()->
239  GetNrBytes (availableSymbols, modulationType);
240  packet = connection->Dequeue (MacHeaderType::HEADER_TYPE_GENERIC,
241  availableByte);
242  }
243  else
244  {
245  packet = connection->Dequeue ();
246  }
247 
248  NS_ASSERT_MSG (hdr.GetCid ().GetIdentifier () == connection->GetCid (),
249  "Base station: Error while scheduling broadcast connection: header CID != connection CID");
250  burst->AddPacket (packet);
251  availableSymbols -= nrSymbolsRequired;
252  }
253  if (burst->GetNPackets () != 0)
254  {
255  AddDownlinkBurst (connection, diuc, modulationType, burst);
256  }
257 }
258 
259 void
261 {
262  Ptr<WimaxConnection> connection;
265  uint32_t nrSymbolsRequired = 0;
266  GenericMacHeader hdr;
267  Ptr<Packet> packet;
268  Ptr<PacketBurst> burst = Create<PacketBurst> ();
269 
270  while (GetBs ()->GetInitialRangingConnection ()->HasPackets () && availableSymbols > 0)
271  {
272  connection = GetBs ()->GetInitialRangingConnection ();
273 
274  packet = connection->GetQueue ()->Peek (hdr);
275  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (packet->GetSize (), modulationType);
276 
277  // PIRO: check for fragmentation
278  if (availableSymbols < nrSymbolsRequired
279  && !CheckForFragmentation (connection, availableSymbols, modulationType))
280  {
281  break;
282  }
283  else if (availableSymbols < nrSymbolsRequired
284  && CheckForFragmentation (connection, availableSymbols, modulationType))
285  {
286  uint32_t availableByte = GetBs ()->GetPhy ()->
287  GetNrBytes (availableSymbols, modulationType);
288  packet = connection->Dequeue (MacHeaderType::HEADER_TYPE_GENERIC,
289  availableByte);
290  }
291  else
292  {
293  packet = connection->Dequeue ();
294  }
295 
296  NS_ASSERT_MSG (hdr.GetCid () == connection->GetCid (),
297  "Base station: Error while scheduling initial ranging connection: header CID != connection CID");
298  burst->AddPacket (packet);
299  availableSymbols -= nrSymbolsRequired;
300  }
301  if (burst->GetNPackets ())
302  {
303  AddDownlinkBurst (connection, diuc, modulationType, burst);
304  }
305 }
306 
307 void
309 {
310  Ptr<WimaxConnection> connection;
313  uint32_t nrSymbolsRequired = 0;
314  GenericMacHeader hdr;
315  Ptr<Packet> packet;
316  Ptr<PacketBurst> burst = Create<PacketBurst> ();
317 
318  std::vector<Ptr<WimaxConnection> >::const_iterator iter;
319  std::vector<Ptr<WimaxConnection> > connections;
320 
321  connections = GetBs ()->GetConnectionManager ()->GetConnections (Cid::BASIC);
322  for (iter = connections.begin (); iter != connections.end (); ++iter)
323  {
324  while ((*iter)->HasPackets () && availableSymbols > 0)
325  {
326  connection = *iter;
327 
328  modulationType = GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
329  diuc = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
331 
332  packet = connection->GetQueue ()->Peek (hdr);
333  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (packet->GetSize (), modulationType);
334 
335  // PIRO: check for fragmentation
336  if (availableSymbols < nrSymbolsRequired
337  && !CheckForFragmentation (connection, availableSymbols, modulationType))
338  {
339  break;
340  }
341  else if (availableSymbols < nrSymbolsRequired
342  && CheckForFragmentation (connection, availableSymbols, modulationType))
343  {
344  uint32_t availableByte = GetBs ()->GetPhy ()->
345  GetNrBytes (availableSymbols, modulationType);
346  packet = connection->Dequeue (MacHeaderType::HEADER_TYPE_GENERIC, availableByte);
347  }
348  else
349  {
350  packet = connection->Dequeue ();
351  }
352 
353  NS_ASSERT_MSG (hdr.GetCid () == connection->GetCid (),
354  "Base station: Error while scheduling basic connection: header CID != connection CID");
355  burst->AddPacket (packet);
356  availableSymbols -= nrSymbolsRequired;
357  }
358  if (burst->GetNPackets () != 0)
359  {
360  AddDownlinkBurst (connection, diuc, modulationType, burst);
361  burst = Create<PacketBurst> ();
362  }
363  }
364 }
365 
366 void
368 {
369  Ptr<WimaxConnection> connection;
371  uint8_t diuc = 0;
372  uint32_t nrSymbolsRequired = 0;
373  GenericMacHeader hdr;
374  Ptr<Packet> packet;
375  Ptr<PacketBurst> burst = Create<PacketBurst> ();
376 
377  std::vector<Ptr<WimaxConnection> >::const_iterator iter;
378  std::vector<Ptr<WimaxConnection> > connections;
379 
380  connections = GetBs ()->GetConnectionManager ()->GetConnections (Cid::PRIMARY);
381  for (iter = connections.begin (); iter != connections.end (); ++iter)
382  {
383  while ((*iter)->HasPackets () && availableSymbols > 0)
384  {
385  connection = *iter;
386 
387  modulationType = GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
388  diuc = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
390 
391  packet = connection->GetQueue ()->Peek (hdr);
392  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (packet->GetSize (), modulationType);
393 
394  // PIRO: check for fragmentation
395  if (availableSymbols < nrSymbolsRequired
396  && !CheckForFragmentation (connection, availableSymbols, modulationType))
397  {
398  break;
399  }
400  else if (availableSymbols < nrSymbolsRequired
401  && CheckForFragmentation (connection, availableSymbols, modulationType))
402  {
403  uint32_t availableByte = GetBs ()->GetPhy ()->
404  GetNrBytes (availableSymbols, modulationType);
405  packet = connection->Dequeue (MacHeaderType::HEADER_TYPE_GENERIC, availableByte);
406  }
407  else
408  {
409  packet = connection->Dequeue ();
410  }
411 
412  NS_ASSERT_MSG (hdr.GetCid () == connection->GetCid (),
413  "Base station: Error while scheduling primary connection: header CID != connection CID");
414  burst->AddPacket (packet);
415  availableSymbols -= nrSymbolsRequired;
416  }
417  if (burst->GetNPackets () != 0)
418  {
419  AddDownlinkBurst (connection, diuc, modulationType, burst);
420  }
421  }
422 }
423 
424 void
425 BSSchedulerRtps::BSSchedulerUGSConnection (uint32_t &availableSymbols)
426 {
427  Ptr<WimaxConnection> connection;
429  uint8_t diuc;
430  uint32_t nrSymbolsRequired = 0;
431  GenericMacHeader hdr;
432  Ptr<Packet> packet;
433  Ptr<PacketBurst> burst = Create<PacketBurst> ();
434 
435  Time currentTime = Simulator::Now ();
436 
437  std::vector<ServiceFlow*>::iterator iter;
438  ServiceFlowRecord *serviceFlowRecord;
439  std::vector<ServiceFlow*> serviceFlows;
440 
441  serviceFlows = GetBs ()->GetServiceFlowManager ()->GetServiceFlows (ServiceFlow::SF_TYPE_UGS);
442  for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
443  {
444  serviceFlowRecord = (*iter)->GetRecord ();
445  // if latency would exceed in case grant is allocated in next frame then allocate in current frame
446  if ((*iter)->HasPackets () && ((currentTime - serviceFlowRecord->GetDlTimeStamp ())
447  + GetBs ()->GetPhy ()->GetFrameDuration ()) > MilliSeconds ((*iter)->GetMaximumLatency ()))
448  {
449  connection = (*iter)->GetConnection ();
450  if (connection->GetType () == Cid::MULTICAST)
451  {
452  modulationType = connection->GetServiceFlow ()->GetModulation ();
453  }
454  else
455  {
456  modulationType = GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
457  }
458  diuc = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
460 
461  nrSymbolsRequired = connection->GetServiceFlow ()->GetRecord ()->GetGrantSize ();
462 
463  // Packet fragmentation for UGS connections has not been implemented yet!
464  if (availableSymbols > nrSymbolsRequired)
465  {
466  availableSymbols -= nrSymbolsRequired;
467  burst = CreateUgsBurst (connection->GetServiceFlow (), modulationType, nrSymbolsRequired);
468  if (burst->GetNPackets () != 0)
469  {
470  AddDownlinkBurst (connection, diuc, modulationType, burst);
471  currentTime = Simulator::Now ();
472  serviceFlowRecord->SetDlTimeStamp (currentTime);
473  burst = Create<PacketBurst> ();
474  }
475  }
476  }
477  }
478 
479 }
480 
481 void
482 BSSchedulerRtps::BSSchedulerRTPSConnection (uint32_t &availableSymbols)
483 {
484 
485  Ptr<WimaxConnection> connection;
486  GenericMacHeader hdr;
487  Ptr<Packet> packet;
488  Ptr<PacketBurst> burst = Create<PacketBurst> ();
489 
490  Time currentTime = Simulator::Now ();
491 
492  std::vector<Ptr<WimaxConnection> >::const_iterator iter;
493  std::vector<Ptr<WimaxConnection> > connections;
494  std::vector<ServiceFlow*>::iterator iter2;
495  ServiceFlowRecord *serviceFlowRecord;
496  std::vector<ServiceFlow*> serviceFlows;
497 
498  uint32_t symbolsRequired[100];
499  WimaxPhy::ModulationType modulationType_[100];
500  uint8_t diuc_[100];
501  Ptr<WimaxConnection> rtPSConnection[100];
502  uint32_t dataToSend;
503  uint32_t totSymbolsRequired = 0;
504  int nbConnection = 0;
505 
506  NS_LOG_INFO ("\tDL Scheduler for rtPS flows \n" << "\t\tavailableSymbols = " << availableSymbols);
507 
508  serviceFlows = GetBs ()->GetServiceFlowManager ()->GetServiceFlows (ServiceFlow::SF_TYPE_RTPS);
509  nbConnection = 0;
510  for (iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
511  {
512  // DL RTPS Scheduler works for all rtPS connection that have packets to transmitt!!!
513  serviceFlowRecord = (*iter2)->GetRecord ();
514 
515  if ((*iter2)->HasPackets ())
516  {
517  currentTime = Simulator::Now ();
518  serviceFlowRecord->SetDlTimeStamp (currentTime);
519  rtPSConnection[nbConnection] = (*iter2)->GetConnection ();
520  if (rtPSConnection[nbConnection]->GetType () == Cid::MULTICAST)
521  {
522  modulationType_[nbConnection] = rtPSConnection[nbConnection]->GetServiceFlow ()->GetModulation ();
523  }
524  else
525  {
526  modulationType_[nbConnection]
527  = GetBs ()->GetSSManager ()->GetSSRecord (rtPSConnection[nbConnection]->GetCid ())->GetModulationType ();
528  }
529  diuc_[nbConnection]
530  = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType_[nbConnection],
532 
533  dataToSend = rtPSConnection[nbConnection]->GetQueue ()->GetQueueLengthWithMACOverhead ();
534  NS_LOG_INFO ("\t\tRTPS DL Scheduler for CID = " << rtPSConnection[nbConnection]->GetCid ()
535  << "\n\t\t\t dataToSend = " << dataToSend);
536 
537  symbolsRequired[nbConnection] = GetBs ()->GetPhy ()->GetNrSymbols (dataToSend,
538  modulationType_[nbConnection]);
539 
540  totSymbolsRequired += symbolsRequired[nbConnection];
541  nbConnection++;
542  }
543  }
544 
545  NS_LOG_INFO ("\t\ttotSymbolsRequired = " << totSymbolsRequired);
546 
547  // Channel Saturation
548  while (totSymbolsRequired > availableSymbols)
549  {
550  NS_LOG_INFO ("\tDL Channel Saturation: totSymbolsRequired > availableSymbols_rtPS");
551  double delta = double(availableSymbols) / double(totSymbolsRequired);
552  NS_LOG_INFO ("\t\tdelta = " << delta);
553  totSymbolsRequired = 0;
554  for (int i = 0; i < nbConnection; i++)
555  {
556  NS_LOG_INFO ("\t\tprevious symbolsRequired[" << i << "] = " << symbolsRequired[i]);
557  symbolsRequired[i] = (uint32_t) std::floor (symbolsRequired[i] * delta);
558  totSymbolsRequired += symbolsRequired[i];
559  NS_LOG_INFO ("\t\tnew symbolsRequired[" << i << "] = " << symbolsRequired[i]);
560  }
561  NS_LOG_INFO ("\t\ttotSymbolsRequired = " << totSymbolsRequired);
562  }
563 
564  // Downlink Bandwidth Allocation
565  for (int i = 0; i < nbConnection; i++)
566  {
567 
568  packet = rtPSConnection[i]->GetQueue ()->Peek (hdr);
569  uint32_t symbolsForPacketTransmission = 0;
570  burst = Create<PacketBurst> ();
571  NS_LOG_INFO ("\t\tCID = " << rtPSConnection[i]->GetCid () << " assignedSymbols = " << symbolsRequired[i]);
572 
573  while (symbolsRequired[i] > 0)
574  {
575  symbolsForPacketTransmission = GetBs ()->GetPhy ()
576  ->GetNrSymbols (rtPSConnection[i]->GetQueue ()
577  ->GetFirstPacketRequiredByte (MacHeaderType::HEADER_TYPE_GENERIC),
578  modulationType_[i]);
579 
580  // PIRO: check for fragmentation
581  if (symbolsForPacketTransmission > symbolsRequired[i]
582  && !CheckForFragmentation (rtPSConnection[i],
583  symbolsRequired[i],
584  modulationType_[i]))
585  {
586  break;
587  }
588  else if (symbolsForPacketTransmission > symbolsRequired[i]
589  && CheckForFragmentation (rtPSConnection[i],
590  symbolsRequired[i],
591  modulationType_[i]))
592  {
593  uint32_t availableByte = GetBs ()->GetPhy ()->
594  GetNrBytes (symbolsRequired[i], modulationType_[i]);
595  packet = rtPSConnection[i]->Dequeue (MacHeaderType::HEADER_TYPE_GENERIC, availableByte);
596  symbolsRequired[i] = 0;
597  }
598  else
599  {
600  packet = rtPSConnection[i]->Dequeue ();
601  symbolsRequired[i] -= symbolsForPacketTransmission;
602  }
603 
604  NS_ASSERT_MSG (hdr.GetCid () == rtPSConnection[i]->GetCid (),
605  "Base station: Error while scheduling RTPs connection: header CID != connection CID");
606  burst->AddPacket (packet);
607  }
608 
609  if (burst->GetNPackets () != 0)
610  {
611  AddDownlinkBurst (rtPSConnection[i], diuc_[i], modulationType_[i], burst);
612  }
613  }
614 
615  availableSymbols -= totSymbolsRequired;
616 }
617 
618 void
620 {
621  Ptr<WimaxConnection> connection;
623  uint8_t diuc = 0;
624  uint32_t nrSymbolsRequired = 0;
625  GenericMacHeader hdr;
626  Ptr<Packet> packet;
627  Ptr<PacketBurst> burst = Create<PacketBurst> ();
628 
629  std::vector<ServiceFlow*>::iterator iter;
630  std::vector<ServiceFlow*> serviceFlows;
631 
632  serviceFlows = GetBs ()->GetServiceFlowManager ()->GetServiceFlows (ServiceFlow::SF_TYPE_NRTPS);
633  for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
634  {
635  connection = (*iter)->GetConnection ();
636 
637  while ((*iter)->HasPackets () && availableSymbols > 0)
638  {
639  if (connection->GetType () == Cid::MULTICAST)
640  {
641  modulationType = connection->GetServiceFlow ()->GetModulation ();
642  }
643  else
644  {
645  modulationType = GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
646  }
647 
648  diuc = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
650 
651  packet = connection->GetQueue ()->Peek (hdr);
652  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (packet->GetSize (), modulationType);
653 
654  if (availableSymbols < nrSymbolsRequired)
655  {
656  break;
657  }
658 
659  packet = connection->Dequeue ();
660  NS_ASSERT_MSG (hdr.GetCid () == connection->GetCid (),
661  "Base station: Error while scheduling NRTPs connection: header CID != connection CID");
662  burst->AddPacket (packet);
663  availableSymbols -= nrSymbolsRequired;
664  }
665  if (burst->GetNPackets () != 0)
666  {
667  AddDownlinkBurst (connection, diuc, modulationType, burst);
668  burst = Create<PacketBurst> ();
669  }
670  }
671 }
672 
673 void
674 BSSchedulerRtps::BSSchedulerBEConnection (uint32_t &availableSymbols)
675 {
676  Ptr<WimaxConnection> connection;
678  uint8_t diuc = 0;
679  uint32_t nrSymbolsRequired = 0;
680  GenericMacHeader hdr;
681  Ptr<Packet> packet;
682  Ptr<PacketBurst> burst = Create<PacketBurst> ();
683 
684  std::vector<ServiceFlow*>::iterator iter;
685  std::vector<ServiceFlow*> serviceFlows;
686 
687  serviceFlows = GetBs ()->GetServiceFlowManager ()->GetServiceFlows (ServiceFlow::SF_TYPE_BE);
688  for (iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
689  {
690  connection = (*iter)->GetConnection ();
691 
692  while ((*iter)->HasPackets () && availableSymbols > 0)
693  {
694  if (connection->GetType () == Cid::MULTICAST)
695  {
696  modulationType = connection->GetServiceFlow ()->GetModulation ();
697  }
698  else
699  {
700  modulationType = GetBs ()->GetSSManager ()->GetSSRecord (connection->GetCid ())->GetModulationType ();
701  }
702  diuc = GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
704 
705  packet = connection->GetQueue ()->Peek (hdr);
706  nrSymbolsRequired = GetBs ()->GetPhy ()->GetNrSymbols (packet->GetSize (), modulationType);
707 
708  if (availableSymbols < nrSymbolsRequired)
709  {
710  break;
711  }
712 
713  packet = connection->Dequeue ();
714  NS_ASSERT_MSG (hdr.GetCid () == connection->GetCid (),
715  "Base station: Error while scheduling BE connection: header CID != connection CID");
716  burst->AddPacket (packet);
717  availableSymbols -= nrSymbolsRequired;
718  }
719  if (burst->GetNPackets () != 0)
720  {
721  AddDownlinkBurst (connection, diuc, modulationType, burst);
722  burst = Create<PacketBurst> ();
723  }
724  }
725 }
726 
727 } // namespace ns3
std::list< std::pair< OfdmDlMapIe *, Ptr< PacketBurst > > > * GetDownlinkBursts(void) const
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
smart pointer class similar to boost::intrusive_ptr
Definition: ptr.h:59
this class implements a structure to manage some parameters and statistics related to a service flow ...
void BSSchedulerInitialRangingConnection(uint32_t &availableSymbols)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
void BSSchedulerUGSConnection(uint32_t &availableSymbols)
uint32_t GetSize(void) const
Definition: packet.h:650
#define NS_LOG_INFO(msg)
Definition: log.h:298
void BSSchedulerBroadcastConnection(uint32_t &availableSymbols)
Ptr< WimaxConnection > GetConnection(void) const
bool CheckForFragmentation(Ptr< WimaxConnection > connection, int availableSymbols, WimaxPhy::ModulationType modulationType)
Definition: bs-scheduler.cc:91
this class implements the Generic mac Header as described by IEEE Standard for Local and metropolitan...
void SetDiuc(uint8_t diuc)
static TypeId GetTypeId(void)
Cid GetCid(void) const
void BSSchedulerRTPSConnection(uint32_t &availableSymbols)
Downlink Scheduler for rtPS connections.
Ptr< PacketBurst > CreateUgsBurst(ServiceFlow *serviceFlow, WimaxPhy::ModulationType modulationType, uint32_t availableSymbols)
#define list
NS_LOG_COMPONENT_DEFINE("BSSchedulerRtps")
void BSSchedulerBasicConnection(uint32_t &availableSymbols)
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:39
virtual Ptr< BaseStationNetDevice > GetBs(void)
Definition: bs-scheduler.cc:85
static Time Now(void)
Return the "current simulation time".
Definition: simulator.cc:180
bool SelectConnection(Ptr< WimaxConnection > &connection)
virtual void SetBs(Ptr< BaseStationNetDevice > bs)
Definition: bs-scheduler.cc:80
void AddDownlinkBurst(Ptr< const WimaxConnection > connection, uint8_t diuc, WimaxPhy::ModulationType modulationType, Ptr< PacketBurst > burst)
#define NS_ASSERT_MSG(condition, message)
Definition: assert.h:86
void BSSchedulerPrimaryConnection(uint32_t &availableSymbols)
void Schedule(void)
Schedule function.
void SetDlTimeStamp(Time dlTimeStamp)
Set the DlTimeStamp.
Doxygen introspection did not find any typical Config paths.
Definition: packet-burst.h:32
Time GetDlTimeStamp(void) const
#define NS_LOG_DEBUG(msg)
Definition: log.h:289
std::list< std::pair< OfdmDlMapIe *, Ptr< PacketBurst > > > * m_downlinkBursts
uint16_t GetIdentifier(void) const
Definition: cid.cc:45
void SetCid(Cid cid)
a base class which provides memory management and object aggregation
Definition: object.h:63
void BSSchedulerNRTPSConnection(uint32_t &availableSymbols)
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
void BSSchedulerBEConnection(uint32_t &availableSymbols)
bool HasPackets(void) const