A Discrete-Event Network Simulator
API
bs-uplink-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 
23 #include "bs-net-device.h"
24 #include "ns3/simulator.h"
25 #include "cid.h"
26 #include "burst-profile-manager.h"
27 #include "ss-manager.h"
28 #include "ns3/log.h"
29 #include "ns3/uinteger.h"
30 #include "ss-record.h"
31 #include "service-flow.h"
32 #include "service-flow-record.h"
33 #include "bs-link-manager.h"
34 #include "bandwidth-manager.h"
35 
36 namespace ns3 {
37 
38 NS_LOG_COMPONENT_DEFINE ("UplinkSchedulerRtps");
39 
40 NS_OBJECT_ENSURE_REGISTERED (UplinkSchedulerRtps);
41 
42 
44 {
45  SetBs (0);
48  SetIsIrIntrvlAllocated (false);
52 }
53 
55 {
56  SetBs (bs);
59  SetIsIrIntrvlAllocated (false);
63 }
64 
66 {
67  SetBs (0);
68  m_uplinkAllocations.clear ();
69 }
70 
71 TypeId
73 {
74  static TypeId tid = TypeId ("ns3::UplinkSchedulerRtps")
76  .SetGroupName("Wimax")
77  .AddConstructor<UplinkSchedulerRtps> ()
78  ;
79  return tid;
80 }
81 
82 std::list<OfdmUlMapIe>
84 {
85  return m_uplinkAllocations;
86 }
87 
88 void
89 UplinkSchedulerRtps::GetChannelDescriptorsToUpdate (bool &updateDcd, bool &updateUcd, bool &sendDcd, bool &sendUcd)
90 {
91  /*DCD and UCD shall actually be updated when channel or burst profile definitions
92  change. burst profiles are updated based on number of SSs, network conditions and etc.
93  for now temporarily assuming DCD/UCD shall be updated every time */
94 
95  uint32_t randNr = rand ();
96  if (randNr % 5 == 0 || GetBs ()->GetNrDcdSent () == 0)
97  {
98  sendDcd = true;
99  }
100 
101  randNr = rand ();
102  if (randNr % 5 == 0 || GetBs ()->GetNrUcdSent () == 0)
103  {
104  sendUcd = true;
105  }
106 
107  // -------------------------------------
108  // additional, just to send more frequently
109  if (!sendDcd)
110  {
111  randNr = rand ();
112  if (randNr % 4 == 0)
113  {
114  sendDcd = true;
115  }
116  }
117 
118  if (!sendUcd)
119  {
120  randNr = rand ();
121  if (randNr % 4 == 0)
122  {
123  sendUcd = true;
124  }
125  }
126  // -------------------------------------
127 
128  Time timeSinceLastDcd = Simulator::Now () - GetDcdTimeStamp ();
129  Time timeSinceLastUcd = Simulator::Now () - GetUcdTimeStamp ();
130 
131  if (timeSinceLastDcd > GetBs ()->GetDcdInterval ())
132  {
133  sendDcd = true;
135  }
136 
137  if (timeSinceLastUcd > GetBs ()->GetUcdInterval ())
138  {
139  sendUcd = true;
141  }
142 }
143 
144 uint32_t
146 {
147  return GetBs ()->GetNrDlSymbols () * GetBs ()->GetPhy ()->GetPsPerSymbol () + GetBs ()->GetTtg ();
148 }
149 
150 void
152  const uint32_t &allocationSize,
153  uint32_t &symbolsToAllocation,
154  uint32_t &availableSymbols)
155 {
156  ulMapIe.SetDuration (allocationSize);
157  ulMapIe.SetStartTime (symbolsToAllocation);
158  m_uplinkAllocations.push_back (ulMapIe);
159  symbolsToAllocation += allocationSize;
160  availableSymbols -= allocationSize;
161 }
162 
163 void
165 {
166  m_uplinkAllocations.clear ();
167  SetIsIrIntrvlAllocated (false);
169  bool allocationForDsa = false;
170 
171  uint32_t symbolsToAllocation = 0;
172  uint32_t allocationSize = 0; // size in symbols
173  uint32_t availableSymbols = GetBs ()->GetNrUlSymbols ();
174 
175  WimaxPhy::ModulationType modulationType;
176  Cid cid;
177 
178  AllocateInitialRangingInterval (symbolsToAllocation, availableSymbols);
179 
180  std::vector<SSRecord*> *ssRecords = GetBs ()->GetSSManager ()->GetSSRecords ();
181  NS_LOG_INFO ("UL Scheduler start, availableSymbols = " << availableSymbols);
182 
183  for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
184  {
185  SSRecord *ssRecord = *iter;
186  if (ssRecord->GetIsBroadcastSS ())
187  {
188  continue;
189  }
190  cid = ssRecord->GetBasicCid ();
191  OfdmUlMapIe ulMapIe;
192  ulMapIe.SetCid (cid);
193 
195  {
196  // SS's ranging is not yet complete
197  // allocating invited initial ranging interval
199  allocationSize = GetBs ()->GetRangReqOppSize ();
201 
202  if (availableSymbols >= allocationSize)
203  {
204  AddUplinkAllocation (ulMapIe, allocationSize, symbolsToAllocation, availableSymbols);
205  }
206  else
207  {
208  break;
209  }
210  }
211  else
212  {
213  modulationType = ssRecord->GetModulationType ();
214 
215  // need to update because modulation/FEC to UIUC mapping may vary over time
216  ulMapIe.SetUiuc (GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
218 
219  // establish service flows for SS
221  && !ssRecord->GetAreServiceFlowsAllocated ())
222  {
223  // allocating grant (with arbitrary size) to allow SS to send DSA messages DSA-REQ and DSA-ACK
224  // only one DSA allocation per frame
225  if (!allocationForDsa)
226  {
227  allocationSize = GetBs ()->GetPhy ()->GetNrSymbols (sizeof(DsaReq), modulationType);
228  if (availableSymbols >= allocationSize)
229  {
230  AddUplinkAllocation (ulMapIe, allocationSize, symbolsToAllocation, availableSymbols);
231  allocationForDsa = true;
232  }
233  else
234  {
235  break;
236  }
237  }
238  }
239  else
240  {
241  // all service flows associated to SS are established now
242 
243  /*allocating grants for data transmission for UGS flows (Data Grant Burst Type IEs, 6.3.7.4.3.3)
244  (grant has been referred by different names e.g. transmission opportunity, slot, uplink allocation, etc)*/
245  ServiceUnsolicitedGrants (ssRecord,
247  ulMapIe,
248  modulationType,
249  symbolsToAllocation,
250  availableSymbols);
251 
252  // allocate unicast polls for rtPS flows if bandwidth is available
253  if (availableSymbols)
254  {
255  ServiceUnsolicitedGrants (ssRecord,
257  ulMapIe,
258  modulationType,
259  symbolsToAllocation,
260  availableSymbols);
261  }
262  // allocate unicast polls for nrtPS flows if bandwidth is available
263  if (availableSymbols)
264  {
265  ServiceUnsolicitedGrants (ssRecord,
267  ulMapIe,
268  modulationType,
269  symbolsToAllocation,
270  availableSymbols);
271  }
272  // finally allocate unicast polls for BE flows if bandwidth is available
273  if (availableSymbols)
274  {
275  ServiceUnsolicitedGrants (ssRecord,
277  ulMapIe,
278  modulationType,
279  symbolsToAllocation,
280  availableSymbols);
281  }
282  }
283  }
284  }
285 
286  /*
287  * Uplink Scheduler for rtPS Connection
288  */
289  if (availableSymbols)
290  {
291  ULSchedulerRTPSConnection (symbolsToAllocation, availableSymbols);
292  }
293 
294  // UL Scheduler for nrtPS and BE flows
295  if (availableSymbols)
296  {
297  for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
298  {
299  SSRecord *ssRecord = *iter;
300  if (ssRecord->GetIsBroadcastSS ())
301  {
302  continue;
303  }
304  if (!ssRecord->GetPollForRanging () && ssRecord->GetRangingStatus ()
306  {
307  OfdmUlMapIe ulMapIe;
308  cid = ssRecord->GetBasicCid ();
309  ulMapIe.SetCid (cid);
310  modulationType = ssRecord->GetModulationType ();
311  ulMapIe.SetUiuc (GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
313 
314  // allocate unicast polls for nrtPS flows if bandwidth is available
315  if (availableSymbols)
316  {
317  ServiceBandwidthRequests (ssRecord,
319  ulMapIe,
320  modulationType,
321  symbolsToAllocation,
322  availableSymbols);
323  }
324  // finally allocate unicast polls for BE flows if bandwidth is available
325  if (availableSymbols)
326  {
327  ServiceBandwidthRequests (ssRecord,
329  ulMapIe,
330  modulationType,
331  symbolsToAllocation,
332  availableSymbols);
333  }
334  }
335  }
336  }
337 
338  OfdmUlMapIe ulMapIeEnd;
339  ulMapIeEnd.SetCid (Cid::InitialRanging ());
340  ulMapIeEnd.SetStartTime (symbolsToAllocation);
342  ulMapIeEnd.SetDuration (0);
343  m_uplinkAllocations.push_back (ulMapIeEnd);
344 
345  // setting DL/UL subframe allocation for the next frame
346  GetBs ()->GetBandwidthManager ()->SetSubframeRatio ();
347 }
348 
349 void
351  enum ServiceFlow::SchedulingType schedulingType,
352  OfdmUlMapIe &ulMapIe,
353  const WimaxPhy::ModulationType modulationType,
354  uint32_t &symbolsToAllocation,
355  uint32_t &availableSymbols)
356 {
357  uint32_t allocationSize = 0; // size in symbols
358  uint8_t uiuc = ulMapIe.GetUiuc (); // SS's burst profile
359  std::vector<ServiceFlow*> serviceFlows = ssRecord->GetServiceFlows (schedulingType);
360 
361  for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
362  {
363  ServiceFlow *serviceFlow = *iter;
364 
365  /* in case of rtPS, nrtPS and BE, allocating unicast polls for bandwidth requests (Request IEs, 6.3.7.4.3.1).
366  in case of UGS, allocating grants for data transmission (Data Grant Burst Type IEs, 6.3.7.4.3.3) (grant has
367  been referred in this code by different names e.g. transmission opportunity, slot, allocation, etc) */
368 
369  allocationSize = GetBs ()->GetBandwidthManager ()->CalculateAllocationSize (ssRecord, serviceFlow);
370 
371  // verifying that minimum reserved traffic rate of nrtPS flow is maintained
372  if (serviceFlow->GetSchedulingType () == ServiceFlow::SF_TYPE_NRTPS)
373  {
374  Time currentTime = Simulator::Now ();
375  ServiceFlowRecord *record = serviceFlow->GetRecord ();
376  if (currentTime - record->GetGrantTimeStamp () > Seconds (1))
377  {
378  uint32_t bps = (record->GetBwSinceLastExpiry () * 8);
379  if (bps < serviceFlow->GetMinReservedTrafficRate ())
380  {
381  ServiceBandwidthRequests (serviceFlow,
382  schedulingType,
383  ulMapIe,
384  modulationType,
385  symbolsToAllocation,
386  availableSymbols);
387  record->SetBwSinceLastExpiry (0);
388  record->SetGrantTimeStamp (currentTime);
389  }
390  }
391  }
392 
393  if (availableSymbols < allocationSize)
394  {
395  break;
396  }
397 
398  if (allocationSize > 0)
399  {
400  ulMapIe.SetStartTime (symbolsToAllocation);
401  if (serviceFlow->GetSchedulingType () != ServiceFlow::SF_TYPE_UGS)
402  {
403  // special burst profile with most robust modulation type is used for unicast polls (Request IEs)
405  }
406  }
407  else
408  {
409  continue;
410  }
411 
412  if (serviceFlow->GetSchedulingType () == ServiceFlow::SF_TYPE_UGS)
413  {
414  NS_LOG_DEBUG ("BS uplink scheduler, UGS allocation, size: " << allocationSize << " symbols");
415  }
416  else
417  {
418  NS_LOG_DEBUG ("BS uplink scheduler, " << serviceFlow->GetSchedulingTypeStr () << " unicast poll, size: "
419  << allocationSize << " symbols" << ", modulation: BPSK 1/2");
420  }
421 
422  NS_LOG_DEBUG (", CID: " << serviceFlow->GetConnection ()->GetCid () << ", SFID: " << serviceFlow->GetSfid ());
423 
424  AddUplinkAllocation (ulMapIe, allocationSize, symbolsToAllocation, availableSymbols);
425  ulMapIe.SetUiuc (uiuc);
426  }
427 }
428 
429 void
431  enum ServiceFlow::SchedulingType schedulingType,
432  OfdmUlMapIe &ulMapIe,
433  const WimaxPhy::ModulationType modulationType,
434  uint32_t &symbolsToAllocation,
435  uint32_t &availableSymbols)
436 {
437  std::vector<ServiceFlow*> serviceFlows = ssRecord->GetServiceFlows (schedulingType);
438 
439  for (std::vector<ServiceFlow*>::iterator iter = serviceFlows.begin (); iter != serviceFlows.end (); ++iter)
440  {
441  if (!ServiceBandwidthRequests (*iter,
442  schedulingType,
443  ulMapIe,
444  modulationType,
445  symbolsToAllocation,
446  availableSymbols))
447  {
448  break;
449  }
450  }
451 }
452 
453 bool
455  enum ServiceFlow::SchedulingType schedulingType,
456  OfdmUlMapIe &ulMapIe,
457  const WimaxPhy::ModulationType modulationType,
458  uint32_t &symbolsToAllocation,
459  uint32_t &availableSymbols)
460 {
461  uint32_t allocSizeBytes = 0;
462  uint32_t allocSizeSymbols = 0;
463  uint16_t sduSize = 0;
464 
465  ServiceFlowRecord *record = serviceFlow->GetRecord ();
466  sduSize = serviceFlow->GetSduSize ();
467 
468  uint32_t requiredBandwidth = record->GetRequestedBandwidth () - record->GetGrantedBandwidth ();
469  if (requiredBandwidth > 0)
470  {
471  if (sduSize > 0)
472  {
473  // if SDU size is mentioned, allocate grant of that size
474  allocSizeBytes = sduSize;
475  allocSizeSymbols = GetBs ()->GetPhy ()->GetNrSymbols (sduSize, modulationType);
476  }
477  else
478  {
479  allocSizeBytes = requiredBandwidth;
480  allocSizeSymbols = GetBs ()->GetPhy ()->GetNrSymbols (requiredBandwidth, modulationType);
481  }
482 
483  if (availableSymbols >= allocSizeSymbols)
484  {
485 
486  NS_LOG_DEBUG ("BS uplink scheduler, " << serviceFlow->GetSchedulingTypeStr () << " allocation, size: "
487  << allocSizeSymbols << " symbols" << ", CID: " << serviceFlow->GetConnection ()->GetCid () << ", SFID: "
488  << serviceFlow->GetSfid () << ", bw requested: " << record->GetRequestedBandwidth () << ", bw granted: "
489  << record->GetGrantedBandwidth ());
490 
491  record->UpdateGrantedBandwidth (allocSizeBytes);
492 
493  if (schedulingType == ServiceFlow::SF_TYPE_NRTPS)
494  {
495  record->SetBwSinceLastExpiry (allocSizeBytes);
496  }
497 
498  AddUplinkAllocation (ulMapIe, allocSizeSymbols, symbolsToAllocation, availableSymbols);
499  }
500  else
501  {
502  return false;
503  }
504  }
505  return true;
506 }
507 
508 void
509 UplinkSchedulerRtps::ULSchedulerRTPSConnection (uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
510 {
511  NS_LOG_INFO ("\tUL Scheduler for rtPS flows");
512  NS_LOG_INFO ("\t\tavailableSymbols = " << availableSymbols);
513  ServiceFlowRecord *record_[100];
514  uint32_t allocSizeSymbols_[100]; // symbolsRequired for each SSRecord
515  OfdmUlMapIe ulMapIe_[100];
516  OfdmUlMapIe ulMapIe;
517  WimaxPhy::ModulationType modulationType_[100];
518  WimaxPhy::ModulationType modulationType;
519  int nbAllocation = 0;
520  uint32_t allocSizeBytes;
521  uint32_t totAllocSizeSymbols = 0;
522 
523  Cid cid;
524  std::vector<SSRecord*> *ssRecords = GetBs ()->GetSSManager ()->GetSSRecords ();
525 
526  for (std::vector<SSRecord*>::iterator iter = ssRecords->begin (); iter != ssRecords->end (); ++iter)
527  {
528  SSRecord *ssRecord = *iter;
529  if (ssRecord->GetIsBroadcastSS ())
530  {
531  continue;
532  }
534  && ssRecord->GetAreServiceFlowsAllocated ())
535  {
536  cid = ssRecord->GetBasicCid ();
537  ulMapIe.SetCid (cid);
538  modulationType = ssRecord->GetModulationType ();
539  ulMapIe.SetUiuc (GetBs ()->GetBurstProfileManager ()->GetBurstProfile (modulationType,
541 
542  std::vector<ServiceFlow*> serviceFlows = ssRecord->GetServiceFlows (ServiceFlow::SF_TYPE_RTPS);
543  for (std::vector<ServiceFlow*>::iterator iter2 = serviceFlows.begin (); iter2 != serviceFlows.end (); ++iter2)
544  {
545  record_[nbAllocation] = (*iter2)->GetRecord ();
546  uint32_t requiredBandwidth = record_[nbAllocation]->GetRequestedBandwidth ()
547  - record_[nbAllocation]->GetGrantedBandwidth ();
548 
549  if (requiredBandwidth > 0)
550  {
551  modulationType_[nbAllocation] = modulationType;
552  ulMapIe_[nbAllocation] = ulMapIe;
553  allocSizeBytes = requiredBandwidth;
554  allocSizeSymbols_[nbAllocation] = GetBs ()->GetPhy ()->GetNrSymbols (allocSizeBytes,
555  modulationType_[nbAllocation]);
556  totAllocSizeSymbols += allocSizeSymbols_[nbAllocation];
557 
558  NS_LOG_INFO ("\t\tUL Scheduler for CID = " << (*iter2)->GetConnection ()->GetCid ());
559  NS_LOG_INFO ("\t\t\trequiredBandwidth = " << record_[nbAllocation]->GetRequestedBandwidth ()
560  << ", allocSizeSymbols = " << allocSizeSymbols_[nbAllocation] << ", modulationType = "
561  << modulationType_[nbAllocation]);
562 
563  nbAllocation += 1;
564  }
565  }
566  }
567  }
568 
569  NS_LOG_INFO ("\t\ttotAllocSizeSymbols = " << totAllocSizeSymbols);
570 
571  // Channel Saturation
572  while (totAllocSizeSymbols > availableSymbols)
573  {
574  NS_LOG_INFO ("\tUL Channel Saturation: totAllocSizeSymbols > availableSymbols");
575  double delta = double(availableSymbols) / double(totAllocSizeSymbols);
576  NS_LOG_INFO ("\t\tdelta = " << delta);
577  totAllocSizeSymbols = 0;
578  for (int i = 0; i < nbAllocation; i++)
579  {
580  NS_LOG_INFO ("\t\tprevious allocSizeSymbols_[" << i << "] = " << allocSizeSymbols_[i]);
581  allocSizeSymbols_[i] = (uint32_t) std::floor (allocSizeSymbols_[i] * delta);
582  totAllocSizeSymbols += allocSizeSymbols_[i];
583  NS_LOG_INFO ("\t\tnew allocSizeSymbols_[" << i << "] = " << allocSizeSymbols_[i]);
584  }
585  NS_LOG_INFO ("\t\ttotAllocSizeSymbols = " << totAllocSizeSymbols);
586  }
587 
588  // Uplink Bandwidth Allocation
589  for (int i = 0; i < nbAllocation; i++)
590  {
591  AddUplinkAllocation (ulMapIe_[i], allocSizeSymbols_[i], symbolsToAllocation, availableSymbols);
592  allocSizeBytes = GetBs ()->GetPhy ()->GetNrBytes (allocSizeSymbols_[i], modulationType_[i]);
593  NS_LOG_INFO ("\t\tUpdateGrantedBandwidth for " << i << " = " << allocSizeBytes);
594  if (record_[i]->GetRequestedBandwidth () < allocSizeBytes)
595  {
596  // the flow need new poll to set the newer requredBandwidth
597  record_[i]->SetGrantedBandwidth (0);
598  record_[i]->SetRequestedBandwidth (0);
599  }
600  else
601  {
602  record_[i]->UpdateGrantedBandwidth (allocSizeBytes);
603  }
604  }
605 }
606 
607 void
608 UplinkSchedulerRtps::AllocateInitialRangingInterval (uint32_t &symbolsToAllocation, uint32_t &availableSymbols)
609 {
610  Time ssUlStartTime = Seconds (CalculateAllocationStartTime () * GetBs ()->GetPsDuration ().GetSeconds ());
611  SetNrIrOppsAllocated (GetBs ()->GetLinkManager ()->CalculateRangingOppsToAllocate ());
612  uint32_t allocationSize = GetNrIrOppsAllocated () * GetBs ()->GetRangReqOppSize ();
613  Time timeSinceLastIrInterval = Simulator::Now () - GetTimeStampIrInterval ();
614 
615  // adding one frame because may be the time has not elapsed now but will elapse before the next frame is sent
616  if (timeSinceLastIrInterval + GetBs ()->GetPhy ()->GetFrameDuration () > GetBs ()->GetInitialRangingInterval ()
617  && availableSymbols >= allocationSize)
618  {
619  SetIsIrIntrvlAllocated (true);
620  OfdmUlMapIe ulMapIeIr;
621  ulMapIeIr.SetCid (GetBs ()->GetBroadcastConnection ()->GetCid ());
622  ulMapIeIr.SetStartTime (symbolsToAllocation);
624 
625  NS_LOG_DEBUG ("BS uplink scheduler, initial ranging allocation, size: " << allocationSize << " symbols"
626  << ", modulation: BPSK 1/2");
627 
628  // marking start and end of each TO, only for debugging
629  for (uint8_t i = 0; i < GetNrIrOppsAllocated (); i++)
630  {
631  GetBs ()->MarkRangingOppStart (ssUlStartTime + Seconds (symbolsToAllocation
632  * GetBs ()->GetSymbolDuration ().GetSeconds ()) + Seconds (i * GetBs ()->GetRangReqOppSize ()
633  * GetBs ()->GetSymbolDuration ().GetSeconds ()));
634  }
635 
636  AddUplinkAllocation (ulMapIeIr, allocationSize, symbolsToAllocation, availableSymbols);
638  }
639 }
640 
641 void
643 {
644  uint8_t delayNrFrames = 1;
645  uint32_t bitsPerSecond = serviceFlow->GetMinReservedTrafficRate ();
646  WimaxPhy::ModulationType modulation;
647  uint32_t bytesPerFrame =
648  (uint32_t ((double)(bitsPerSecond) * GetBs ()->GetPhy ()->GetFrameDuration ().GetSeconds ())) / 8;
649  uint32_t frameDurationMSec = GetBs ()->GetPhy ()->GetFrameDuration ().GetMilliSeconds ();
650 
651  switch (serviceFlow->GetSchedulingType ())
652  {
654  {
655  if (serviceFlow->GetIsMulticast () == true)
656  {
657  modulation = serviceFlow->GetModulation ();
658  }
659  else
660  {
661  modulation = ssRecord->GetModulationType ();
662  }
663  uint32_t grantSize = GetBs ()->GetPhy ()->GetNrSymbols (bytesPerFrame, modulation);
664  serviceFlow->GetRecord ()->SetGrantSize (grantSize);
665 
666  uint32_t toleratedJitter = serviceFlow->GetToleratedJitter ();
667 
668  if (toleratedJitter > frameDurationMSec)
669  {
670  delayNrFrames = (uint8_t)(toleratedJitter / frameDurationMSec);
671  }
672 
673  uint16_t interval = delayNrFrames * frameDurationMSec;
674  serviceFlow->SetUnsolicitedGrantInterval (interval);
675  }
676  break;
678  {
679  if (serviceFlow->GetSduSize () > bytesPerFrame)
680  {
681  delayNrFrames = (uint8_t)(serviceFlow->GetSduSize () / bytesPerFrame);
682  }
683 
684  uint16_t interval = delayNrFrames * frameDurationMSec;
685  serviceFlow->SetUnsolicitedPollingInterval (interval);
686  }
687  break;
689  {
690  // no real-time guarantees are given to NRTPS, serviced based on available bandwidth
691  }
692  break;
694  {
695  // no real-time guarantees are given to BE, serviced based on available bandwidth
696  }
697  break;
698  default:
699  NS_FATAL_ERROR ("Invalid scheduling type");
700  }
701 }
702 
703 void
705 {
706 }
707 
708 void
710 {
711 }
712 
713 void
715 {
716  // m_grantedBandwidth must be reset to zero
717  uint32_t grantedBandwidth = 0;
718  sfr->SetGrantedBandwidth (grantedBandwidth);
719 }
720 
721 } // namespace ns3
void SetCid(const Cid &cid)
Set CID.
bool GetIsMulticast(void) const
Get is multicast.
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
Time GetGrantTimeStamp(void) const
uint32_t GetRequestedBandwidth(void)
WimaxPhy::ModulationType GetModulationType(void) const
Get modulation type.
Definition: ss-record.cc:164
this class implements a structure to manage some parameters and statistics related to a service flow ...
void SetRequestedBandwidth(uint32_t requestedBandwidth)
set the requested bandwidth
std::vector< ServiceFlow * > GetServiceFlows(enum ServiceFlow::SchedulingType schedulingType) const
Get service flows.
Definition: ss-record.cc:229
uint8_t GetSduSize(void) const
Get SDU size.
void SetGrantedBandwidth(uint32_t grantedBandwidth)
set the granted bandwidth
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:281
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
Definition: fatal-error.h:162
enum WimaxPhy::ModulationType GetModulation(void) const
Get modulation.
bool GetPollForRanging(void) const
Get poll for ranging.
Definition: ss-record.cc:194
uint32_t GetSfid(void) const
Get SFID.
uint8_t GetUiuc(void) const
Get UIUC.
SchedulingType
section 11.13.11 Service flow scheduling type, page 701
Definition: service-flow.h:58
Ptr< WimaxConnection > GetConnection(void) const
Can return a null connection is this service flow has not been associated yet to a connection...
char * GetSchedulingTypeStr(void) const
Get scheduling type string.
bool GetAreServiceFlowsAllocated(void) const
Check if service flows are allocated.
Definition: ss-record.cc:206
uint32_t GetToleratedJitter(void) const
Get tolerated jitter.
uint32_t GetBwSinceLastExpiry(void)
static Cid InitialRanging(void)
Definition: cid.cc:82
void SetGrantTimeStamp(Time grantTimeStamp)
Set the grant time stamp.
void SetDuration(uint16_t duration)
Set duration.
void SetUnsolicitedGrantInterval(uint16_t unsolicitedGrantInterval)
Set unsolicied grant interval.
void SetGrantSize(uint32_t grantSize)
Set the grant size (only for UGS service flows)
ServiceFlowRecord * GetRecord(void) const
Get service flow record.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
This class implements the bandwidth-request mac Header as described by IEEE Standard for Local and me...
Cid class.
Definition: cid.h:37
This class implements service flows as described by the IEEE-802.16 standard.
Definition: service-flow.h:39
uint32_t GetMinReservedTrafficRate(void) const
Get minimum reserved traffic rate.
void SetStartTime(uint16_t startTime)
Set start time.
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:193
WimaxNetDevice::RangingStatus GetRangingStatus(void) const
Get ranging status.
Definition: ss-record.cc:176
bool GetIsBroadcastSS(void)
Get is broadcast SS.
Definition: ss-record.cc:249
ModulationType
ModulationType enumeration.
Definition: wimax-phy.h:49
enum ServiceFlow::SchedulingType GetSchedulingType(void) const
Get scheduling type.
void SetUnsolicitedPollingInterval(uint16_t unsolicitedPollingInterval)
Set unsolicited polling interval.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:273
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1070
void SetBwSinceLastExpiry(uint32_t bwSinceLastExpiry)
set BW since last expiry
This class is used by the base station to store some information related to subscriber station in the...
Definition: ss-record.h:43
Cid GetBasicCid(void) const
Get basic CID.
Definition: ss-record.cc:92
void UpdateGrantedBandwidth(uint32_t grantedBandwidth)
update the granted bandwidth
uint32_t GetGrantedBandwidth(void)
This class implements the DSA-REQ message described by "IEEE Standard for Local and metropolitan area...
Definition: mac-messages.h:373
This class implements the UL-MAP_IE message as described by "IEEE Standard for Local and metropolitan...
a unique identifier for an interface.
Definition: type-id.h:58
void SetUiuc(uint8_t uiuc)
Set UIUC.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923