LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2007,2008 INRIA | 3 * Copyright (c) 2007,2008 INRIA |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 { | 88 { |
89 return m_uplinkAllocations; | 89 return m_uplinkAllocations; |
90 } | 90 } |
91 | 91 |
92 void | 92 void |
93 UplinkSchedulerSimple::GetChannelDescriptorsToUpdate (bool &updateDcd, | 93 UplinkSchedulerSimple::GetChannelDescriptorsToUpdate (bool &updateDcd, |
94 bool &updateUcd, | 94 bool &updateUcd, |
95 bool &sendDcd, | 95 bool &sendDcd, |
96 bool &sendUcd) | 96 bool &sendUcd) |
97 { | 97 { |
98 NS_UNUSED(updateDcd); | 98 NS_UNUSED (updateDcd); |
99 NS_UNUSED(updateUcd); | 99 NS_UNUSED (updateUcd); |
100 /*DCD and UCD shall actually be updated when channel or burst profile definiti
ons | 100 /*DCD and UCD shall actually be updated when channel or burst profile definiti
ons |
101 change. burst profiles are updated based on number of SSs, network conditions
and etc. | 101 change. burst profiles are updated based on number of SSs, network conditions
and etc. |
102 for now temporarily assuming DCD/UCD shall be updated everytime */ | 102 for now temporarily assuming DCD/UCD shall be updated everytime */ |
103 | 103 |
104 uint32_t randNr = rand (); | 104 uint32_t randNr = rand (); |
105 if (randNr % 5 == 0 || GetBs ()->GetNrDcdSent () == 0) | 105 if (randNr % 5 == 0 || GetBs ()->GetNrDcdSent () == 0) |
106 { | 106 { |
107 sendDcd = true; | 107 sendDcd = true; |
108 } | 108 } |
109 | 109 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 { | 155 { |
156 return GetBs ()->GetNrDlSymbols () * GetBs ()->GetPhy ()->GetPsPerSymbol () +
GetBs ()->GetTtg (); | 156 return GetBs ()->GetNrDlSymbols () * GetBs ()->GetPhy ()->GetPsPerSymbol () +
GetBs ()->GetTtg (); |
157 } | 157 } |
158 | 158 |
159 void | 159 void |
160 UplinkSchedulerSimple::AddUplinkAllocation (OfdmUlMapIe &ulMapIe, | 160 UplinkSchedulerSimple::AddUplinkAllocation (OfdmUlMapIe &ulMapIe, |
161 const uint32_t &allocationSize, | 161 const uint32_t &allocationSize, |
162 uint32_t &symbolsToAllocation, | 162 uint32_t &symbolsToAllocation, |
163 uint32_t &availableSymbols) | 163 uint32_t &availableSymbols) |
164 { | 164 { |
165 ulMapIe.SetDuration (static_cast<uint16_t>(allocationSize)); | 165 ulMapIe.SetDuration (static_cast<uint16_t> (allocationSize)); |
166 ulMapIe.SetStartTime (static_cast<uint16_t>(symbolsToAllocation)); | 166 ulMapIe.SetStartTime (static_cast<uint16_t> (symbolsToAllocation)); |
167 m_uplinkAllocations.push_back (ulMapIe); | 167 m_uplinkAllocations.push_back (ulMapIe); |
168 symbolsToAllocation += allocationSize; | 168 symbolsToAllocation += allocationSize; |
169 availableSymbols -= allocationSize; | 169 availableSymbols -= allocationSize; |
170 } | 170 } |
171 | 171 |
172 void | 172 void |
173 UplinkSchedulerSimple::Schedule (void) | 173 UplinkSchedulerSimple::Schedule (void) |
174 { | 174 { |
175 m_uplinkAllocations.clear (); | 175 m_uplinkAllocations.clear (); |
176 SetIsIrIntrvlAllocated (false); | 176 SetIsIrIntrvlAllocated (false); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 | 225 |
226 // establish service flows for SS | 226 // establish service flows for SS |
227 if (ssRecord->GetRangingStatus () == WimaxNetDevice::RANGING_STATUS_SU
CCESS | 227 if (ssRecord->GetRangingStatus () == WimaxNetDevice::RANGING_STATUS_SU
CCESS |
228 && !ssRecord->GetAreServiceFlowsAllocated ()) | 228 && !ssRecord->GetAreServiceFlowsAllocated ()) |
229 { | 229 { |
230 | 230 |
231 // allocating grant (with arbitrary size) to allow SS to send DSA
messages DSA-REQ and DSA-ACK | 231 // allocating grant (with arbitrary size) to allow SS to send DSA
messages DSA-REQ and DSA-ACK |
232 // only one DSA allocation per frame | 232 // only one DSA allocation per frame |
233 if (!allocationForDsa) | 233 if (!allocationForDsa) |
234 { | 234 { |
235 allocationSize = static_cast<uint32_t>(GetBs ()->GetPhy ()->Ge
tNrSymbols (sizeof(DsaReq), modulationType)); | 235 allocationSize = static_cast<uint32_t> (GetBs ()->GetPhy ()->G
etNrSymbols (sizeof(DsaReq), modulationType)); |
236 | 236 |
237 if (availableSymbols >= allocationSize) | 237 if (availableSymbols >= allocationSize) |
238 { | 238 { |
239 AddUplinkAllocation (ulMapIe, allocationSize, symbolsToAll
ocation, availableSymbols); | 239 AddUplinkAllocation (ulMapIe, allocationSize, symbolsToAll
ocation, availableSymbols); |
240 allocationForDsa = true; | 240 allocationForDsa = true; |
241 } | 241 } |
242 else | 242 else |
243 { | 243 { |
244 break; | 244 break; |
245 } | 245 } |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 modulationType, | 319 modulationType, |
320 symbolsToAllocation, | 320 symbolsToAllocation, |
321 availableSymbols); | 321 availableSymbols); |
322 } | 322 } |
323 } | 323 } |
324 } | 324 } |
325 } | 325 } |
326 OfdmUlMapIe ulMapIeEnd; | 326 OfdmUlMapIe ulMapIeEnd; |
327 | 327 |
328 ulMapIeEnd.SetCid (Cid::InitialRanging ()); | 328 ulMapIeEnd.SetCid (Cid::InitialRanging ()); |
329 ulMapIeEnd.SetStartTime (static_cast<uint16_t>(symbolsToAllocation)); | 329 ulMapIeEnd.SetStartTime (static_cast<uint16_t> (symbolsToAllocation)); |
330 ulMapIeEnd.SetUiuc (OfdmUlBurstProfile::UIUC_END_OF_MAP); | 330 ulMapIeEnd.SetUiuc (OfdmUlBurstProfile::UIUC_END_OF_MAP); |
331 ulMapIeEnd.SetDuration (0); | 331 ulMapIeEnd.SetDuration (0); |
332 m_uplinkAllocations.push_back (ulMapIeEnd); | 332 m_uplinkAllocations.push_back (ulMapIeEnd); |
333 | 333 |
334 // setting DL/UL subframe allocation for the next frame | 334 // setting DL/UL subframe allocation for the next frame |
335 GetBs ()->GetBandwidthManager ()->SetSubframeRatio (); | 335 GetBs ()->GetBandwidthManager ()->SetSubframeRatio (); |
336 } | 336 } |
337 | 337 |
338 void | 338 void |
339 UplinkSchedulerSimple::ServiceUnsolicitedGrants (const SSRecord *ssRecord, | 339 UplinkSchedulerSimple::ServiceUnsolicitedGrants (const SSRecord *ssRecord, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 } | 378 } |
379 } | 379 } |
380 | 380 |
381 if (availableSymbols < allocationSize) | 381 if (availableSymbols < allocationSize) |
382 { | 382 { |
383 break; | 383 break; |
384 } | 384 } |
385 | 385 |
386 if (allocationSize > 0) | 386 if (allocationSize > 0) |
387 { | 387 { |
388 ulMapIe.SetStartTime (static_cast<uint16_t>(symbolsToAllocation)); | 388 ulMapIe.SetStartTime (static_cast<uint16_t> (symbolsToAllocation)); |
389 if (serviceFlow->GetSchedulingType () != ServiceFlow::SF_TYPE_UGS) | 389 if (serviceFlow->GetSchedulingType () != ServiceFlow::SF_TYPE_UGS) |
390 { | 390 { |
391 // special burst profile with most robust modulation type is used
for unicast polls (Request IEs) | 391 // special burst profile with most robust modulation type is used
for unicast polls (Request IEs) |
392 ulMapIe.SetUiuc (OfdmUlBurstProfile::UIUC_REQ_REGION_FULL); | 392 ulMapIe.SetUiuc (OfdmUlBurstProfile::UIUC_REQ_REGION_FULL); |
393 } | 393 } |
394 } | 394 } |
395 else | 395 else |
396 { | 396 { |
397 continue; | 397 continue; |
398 } | 398 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 ServiceFlowRecord *record = serviceFlow->GetRecord (); | 443 ServiceFlowRecord *record = serviceFlow->GetRecord (); |
444 sduSize = serviceFlow->GetSduSize (); | 444 sduSize = serviceFlow->GetSduSize (); |
445 | 445 |
446 uint32_t requiredBandwidth = record->GetRequestedBandwidth () - record->GetGra
ntedBandwidth (); | 446 uint32_t requiredBandwidth = record->GetRequestedBandwidth () - record->GetGra
ntedBandwidth (); |
447 if (requiredBandwidth > 0) | 447 if (requiredBandwidth > 0) |
448 { | 448 { |
449 if (sduSize > 0) | 449 if (sduSize > 0) |
450 { | 450 { |
451 // if SDU size is mentioned, allocate grant of that size | 451 // if SDU size is mentioned, allocate grant of that size |
452 allocSizeBytes = sduSize; | 452 allocSizeBytes = sduSize; |
453 allocSizeSymbols = static_cast<uint32_t>(GetBs ()->GetPhy ()->GetNrSym
bols (sduSize, modulationType)); | 453 allocSizeSymbols = static_cast<uint32_t> (GetBs ()->GetPhy ()->GetNrSy
mbols (sduSize, modulationType)); |
454 } | 454 } |
455 else | 455 else |
456 { | 456 { |
457 allocSizeBytes = requiredBandwidth; | 457 allocSizeBytes = requiredBandwidth; |
458 allocSizeSymbols = static_cast<uint32_t>(GetBs ()->GetPhy ()->GetNrSym
bols (requiredBandwidth, modulationType)); | 458 allocSizeSymbols = static_cast<uint32_t> (GetBs ()->GetPhy ()->GetNrSy
mbols (requiredBandwidth, modulationType)); |
459 } | 459 } |
460 | 460 |
461 if (availableSymbols >= allocSizeSymbols) | 461 if (availableSymbols >= allocSizeSymbols) |
462 { | 462 { |
463 record->UpdateGrantedBandwidth (allocSizeBytes); | 463 record->UpdateGrantedBandwidth (allocSizeBytes); |
464 | 464 |
465 if (schedulingType == ServiceFlow::SF_TYPE_NRTPS) | 465 if (schedulingType == ServiceFlow::SF_TYPE_NRTPS) |
466 { | 466 { |
467 record->SetBwSinceLastExpiry (allocSizeBytes); | 467 record->SetBwSinceLastExpiry (allocSizeBytes); |
468 } | 468 } |
(...skipping 16 matching lines...) Expand all Loading... |
485 uint32_t allocationSize = GetNrIrOppsAllocated () * GetBs ()->GetRangReqOppSiz
e (); | 485 uint32_t allocationSize = GetNrIrOppsAllocated () * GetBs ()->GetRangReqOppSiz
e (); |
486 Time timeSinceLastIrInterval = Simulator::Now () - GetTimeStampIrInterval (); | 486 Time timeSinceLastIrInterval = Simulator::Now () - GetTimeStampIrInterval (); |
487 | 487 |
488 // adding one frame because may be the time has not elapsed now but will elaps
e before the next frame is sent | 488 // adding one frame because may be the time has not elapsed now but will elaps
e before the next frame is sent |
489 if (timeSinceLastIrInterval + GetBs ()->GetPhy ()->GetFrameDuration () > GetBs
()->GetInitialRangingInterval () | 489 if (timeSinceLastIrInterval + GetBs ()->GetPhy ()->GetFrameDuration () > GetBs
()->GetInitialRangingInterval () |
490 && availableSymbols >= allocationSize) | 490 && availableSymbols >= allocationSize) |
491 { | 491 { |
492 SetIsIrIntrvlAllocated (true); | 492 SetIsIrIntrvlAllocated (true); |
493 OfdmUlMapIe ulMapIeIr; | 493 OfdmUlMapIe ulMapIeIr; |
494 ulMapIeIr.SetCid ((GetBs ()->GetBroadcastConnection ())->GetCid ()); | 494 ulMapIeIr.SetCid ((GetBs ()->GetBroadcastConnection ())->GetCid ()); |
495 ulMapIeIr.SetStartTime (static_cast<uint16_t>(symbolsToAllocation)); | 495 ulMapIeIr.SetStartTime (static_cast<uint16_t> (symbolsToAllocation)); |
496 ulMapIeIr.SetUiuc (OfdmUlBurstProfile::UIUC_INITIAL_RANGING); | 496 ulMapIeIr.SetUiuc (OfdmUlBurstProfile::UIUC_INITIAL_RANGING); |
497 | 497 |
498 NS_LOG_DEBUG ("BS uplink scheduler, initial ranging allocation, size: " <<
allocationSize << " symbols" | 498 NS_LOG_DEBUG ("BS uplink scheduler, initial ranging allocation, size: " <<
allocationSize << " symbols" |
499 <<
", modulation: BPSK 1/2"); | 499 <<
", modulation: BPSK 1/2"); |
500 | 500 |
501 // marking start and end of each TO, only for debugging | 501 // marking start and end of each TO, only for debugging |
502 for (uint8_t i = 0; i < GetNrIrOppsAllocated (); i++) | 502 for (uint8_t i = 0; i < GetNrIrOppsAllocated (); i++) |
503 { | 503 { |
504 GetBs ()->MarkRangingOppStart (ssUlStartTime + Seconds (symbolsToAlloc
ation | 504 GetBs ()->MarkRangingOppStart (ssUlStartTime + Seconds (symbolsToAlloc
ation |
505 * GetBs ()->Ge
tSymbolDuration ().GetSeconds ()) + Seconds (i * GetBs ()->GetRangReqOppSize () | 505 * GetBs ()->Ge
tSymbolDuration ().GetSeconds ()) + Seconds (i * GetBs ()->GetRangReqOppSize () |
506
* GetBs ()->GetSymbolDuration ().Ge
tSeconds ())); | 506
* GetBs ()->GetSymbolDuration ().Ge
tSeconds ())); |
507 } | 507 } |
508 | 508 |
509 AddUplinkAllocation (ulMapIeIr, allocationSize, symbolsToAllocation, avail
ableSymbols); | 509 AddUplinkAllocation (ulMapIeIr, allocationSize, symbolsToAllocation, avail
ableSymbols); |
510 SetTimeStampIrInterval (Simulator::Now ()); | 510 SetTimeStampIrInterval (Simulator::Now ()); |
511 } | 511 } |
512 } | 512 } |
513 | 513 |
514 void | 514 void |
515 UplinkSchedulerSimple::SetupServiceFlow (SSRecord *ssRecord, ServiceFlow *servic
eFlow) | 515 UplinkSchedulerSimple::SetupServiceFlow (SSRecord *ssRecord, ServiceFlow *servic
eFlow) |
516 { | 516 { |
517 uint8_t delayNrFrames = 1; | 517 uint8_t delayNrFrames = 1; |
518 uint32_t bitsPerSecond = serviceFlow->GetMinReservedTrafficRate (); | 518 uint32_t bitsPerSecond = serviceFlow->GetMinReservedTrafficRate (); |
519 WimaxPhy::ModulationType modulation; | 519 WimaxPhy::ModulationType modulation; |
520 uint32_t bytesPerFrame = | 520 uint32_t bytesPerFrame = |
521 (uint32_t ((double)(bitsPerSecond) * GetBs ()->GetPhy ()->GetFrameDuration (
).GetSeconds ())) / 8; | 521 (uint32_t ((double)(bitsPerSecond) * GetBs ()->GetPhy ()->GetFrameDuration (
).GetSeconds ())) / 8; |
522 uint32_t frameDurationMSec = static_cast<uint32_t>(GetBs ()->GetPhy ()->GetFra
meDuration ().GetMilliSeconds ()); | 522 uint32_t frameDurationMSec = static_cast<uint32_t> (GetBs ()->GetPhy ()->GetFr
ameDuration ().GetMilliSeconds ()); |
523 | 523 |
524 switch (serviceFlow->GetSchedulingType ()) | 524 switch (serviceFlow->GetSchedulingType ()) |
525 { | 525 { |
526 case ServiceFlow::SF_TYPE_UGS: | 526 case ServiceFlow::SF_TYPE_UGS: |
527 { | 527 { |
528 if (serviceFlow->GetIsMulticast () == true) | 528 if (serviceFlow->GetIsMulticast () == true) |
529 { | 529 { |
530 modulation = serviceFlow->GetModulation (); | 530 modulation = serviceFlow->GetModulation (); |
531 } | 531 } |
532 else | 532 else |
533 { | 533 { |
534 modulation = ssRecord->GetModulationType (); | 534 modulation = ssRecord->GetModulationType (); |
535 } | 535 } |
536 uint32_t grantSize = static_cast<uint32_t>(GetBs ()->GetPhy ()->GetNrSym
bols (bytesPerFrame, modulation)); | 536 uint32_t grantSize = static_cast<uint32_t> (GetBs ()->GetPhy ()->GetNrSy
mbols (bytesPerFrame, modulation)); |
537 serviceFlow->GetRecord ()->SetGrantSize (grantSize); | 537 serviceFlow->GetRecord ()->SetGrantSize (grantSize); |
538 | 538 |
539 uint32_t toleratedJitter = serviceFlow->GetToleratedJitter (); | 539 uint32_t toleratedJitter = serviceFlow->GetToleratedJitter (); |
540 | 540 |
541 if (toleratedJitter > frameDurationMSec) | 541 if (toleratedJitter > frameDurationMSec) |
542 { | 542 { |
543 delayNrFrames = (uint8_t)(toleratedJitter / frameDurationMSec); | 543 delayNrFrames = (uint8_t)(toleratedJitter / frameDurationMSec); |
544 } | 544 } |
545 | 545 |
546 uint16_t interval = static_cast<uint16_t>(delayNrFrames * frameDurationM
Sec); | 546 uint16_t interval = static_cast<uint16_t> (delayNrFrames * frameDuration
MSec); |
547 serviceFlow->SetUnsolicitedGrantInterval (interval); | 547 serviceFlow->SetUnsolicitedGrantInterval (interval); |
548 } | 548 } |
549 break; | 549 break; |
550 case ServiceFlow::SF_TYPE_RTPS: | 550 case ServiceFlow::SF_TYPE_RTPS: |
551 { | 551 { |
552 if (serviceFlow->GetSduSize () > bytesPerFrame) | 552 if (serviceFlow->GetSduSize () > bytesPerFrame) |
553 { | 553 { |
554 delayNrFrames = (uint8_t)(serviceFlow->GetSduSize () / bytesPerFrame
); | 554 delayNrFrames = (uint8_t)(serviceFlow->GetSduSize () / bytesPerFrame
); |
555 } | 555 } |
556 | 556 |
557 uint16_t interval = static_cast<uint16_t>(delayNrFrames * frameDurationM
Sec); | 557 uint16_t interval = static_cast<uint16_t> (delayNrFrames * frameDuration
MSec); |
558 serviceFlow->SetUnsolicitedPollingInterval (interval); | 558 serviceFlow->SetUnsolicitedPollingInterval (interval); |
559 } | 559 } |
560 break; | 560 break; |
561 case ServiceFlow::SF_TYPE_NRTPS: | 561 case ServiceFlow::SF_TYPE_NRTPS: |
562 { | 562 { |
563 // no real-time guarantees are given to NRTPS, serviced based on availab
le bandwidth | 563 // no real-time guarantees are given to NRTPS, serviced based on availab
le bandwidth |
564 } | 564 } |
565 break; | 565 break; |
566 case ServiceFlow::SF_TYPE_BE: | 566 case ServiceFlow::SF_TYPE_BE: |
567 { | 567 { |
568 // no real-time guarantees are given to BE, serviced based on available
bandwidth | 568 // no real-time guarantees are given to BE, serviced based on available
bandwidth |
569 } | 569 } |
570 break; | 570 break; |
571 default: | 571 default: |
572 NS_FATAL_ERROR ("Invalid scheduling type"); | 572 NS_FATAL_ERROR ("Invalid scheduling type"); |
573 } | 573 } |
574 } | 574 } |
575 | 575 |
576 void | 576 void |
577 UplinkSchedulerSimple::ProcessBandwidthRequest (const BandwidthRequestHeader &bw
RequestHdr) | 577 UplinkSchedulerSimple::ProcessBandwidthRequest (const BandwidthRequestHeader &bw
RequestHdr) |
578 { | 578 { |
579 NS_UNUSED(bwRequestHdr); | 579 NS_UNUSED (bwRequestHdr); |
580 // virtual function on UplinkScheduler | 580 // virtual function on UplinkScheduler |
581 // this is not necessary on this implementation | 581 // this is not necessary on this implementation |
582 } | 582 } |
583 | 583 |
584 void | 584 void |
585 UplinkSchedulerSimple::OnSetRequestedBandwidth (ServiceFlowRecord *sfr) | 585 UplinkSchedulerSimple::OnSetRequestedBandwidth (ServiceFlowRecord *sfr) |
586 { | 586 { |
587 // m_grantedBandwidth must be reset to zero | 587 // m_grantedBandwidth must be reset to zero |
588 uint32_t grantedBandwidth = 0; | 588 uint32_t grantedBandwidth = 0; |
589 sfr->SetGrantedBandwidth (grantedBandwidth); | 589 sfr->SetGrantedBandwidth (grantedBandwidth); |
590 } | 590 } |
591 | 591 |
592 } // namespace ns3 | 592 } // namespace ns3 |
LEFT | RIGHT |