![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /******************************************************************************* 00002 * This file is part of openWNS (open Wireless Network Simulator) 00003 * _____________________________________________________________________________ 00004 * 00005 * Copyright (C) 2004-2009 00006 * Chair of Communication Networks (ComNets) 00007 * Kopernikusstr. 5, D-52074 Aachen, Germany 00008 * phone: ++49-241-80-27910, 00009 * fax: ++49-241-80-22242 00010 * email: info@openwns.org 00011 * www: http://www.openwns.org 00012 * _____________________________________________________________________________ 00013 * 00014 * openWNS is free software; you can redistribute it and/or modify it under the 00015 * terms of the GNU Lesser General Public License version 2 as published by the 00016 * Free Software Foundation; 00017 * 00018 * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY 00019 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 00020 * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 00021 * details. 00022 * 00023 * You should have received a copy of the GNU Lesser General Public License 00024 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00025 * 00026 ******************************************************************************/ 00027 00028 #ifndef WNS_SCHEDULER_SCHEDULINGMAP_HPP 00029 #define WNS_SCHEDULER_SCHEDULINGMAP_HPP 00030 00031 #include <WNS/scheduler/SchedulerTypes.hpp> 00032 #include <WNS/scheduler/MapInfoEntry.hpp> 00033 #include <WNS/service/phy/phymode/PhyModeInterface.hpp> 00034 #include <WNS/ldk/Compound.hpp> 00035 #include <WNS/simulator/Time.hpp> 00036 #include <WNS/SmartPtr.hpp> 00037 #include <vector> 00038 #include <list> 00039 00040 namespace wns { namespace scheduler { 00041 namespace strategy { 00042 class RequestForResource; 00043 } 00044 00045 struct HARQInfo { 00046 HARQInfo() : NDI(true), reservedForRetransmission(false), processID(0), rv(0), retryCounter(0), successfullyDecoded(false), transportBlockID(0) {} 00047 00051 bool NDI; 00052 bool reservedForRetransmission; 00053 int processID; 00054 int rv; 00055 int retryCounter; 00056 bool successfullyDecoded; 00057 long int transportBlockID; 00058 int tbPos; 00059 boost::function<void ()> ackCallback; 00060 boost::function<void ()> nackCallback; 00061 }; 00062 00063 00065 class SchedulingCompound 00066 { 00067 public: 00068 SchedulingCompound(); 00069 SchedulingCompound(const SchedulingCompound& other); 00070 SchedulingCompound(int _subChannel, 00071 int _timeSlot, 00072 int _spatialLayer, 00073 simTimeType _startTime, 00074 simTimeType _endTime, 00075 wns::scheduler::ConnectionID _connectionID, 00076 wns::scheduler::UserID _userID, 00077 wns::scheduler::UserID _sourceUserID, 00078 wns::ldk::CompoundPtr _compoundPtr, 00079 wns::service::phy::phymode::PhyModeInterfacePtr _phyModePtr, 00080 wns::Power _txPower, 00081 wns::service::phy::ofdma::PatternPtr _pattern, 00082 ChannelQualityOnOneSubChannel estimatedCQI, 00083 bool _harqEnabled 00084 ); 00085 //SchedulingCompound(const SchedulingCompound&); 00086 00087 ~SchedulingCompound(); 00088 simTimeType getCompoundDuration() { return endTime-startTime; }; 00089 std::string toString() const; 00090 public: 00092 int subChannel; 00094 int timeSlot; 00096 int spatialLayer; 00097 simTimeType startTime; 00098 simTimeType endTime; 00099 wns::scheduler::ConnectionID connectionID; 00101 wns::scheduler::UserID userID; 00102 wns::scheduler::UserID sourceUserID; 00103 wns::ldk::CompoundPtr compoundPtr; 00105 wns::service::phy::phymode::PhyModeInterfacePtr phyModePtr; 00107 wns::Power txPower; 00111 wns::service::phy::ofdma::PatternPtr pattern; 00115 mutable ChannelQualityOnOneSubChannel estimatedCQI; 00116 00117 bool harqEnabled; 00118 }; // SchedulingCompound 00119 00120 typedef SmartPtr<SchedulingCompound> SchedulingCompoundPtr; 00121 typedef std::list<SchedulingCompound> ScheduledCompoundsList; 00122 00126 class PhysicalResourceBlock // PRB 00127 { 00128 public: 00129 PhysicalResourceBlock(); 00130 PhysicalResourceBlock(const PhysicalResourceBlock& other); 00131 PhysicalResourceBlock(int _subChannelIndex, int _timeSlotIndex, int _spatialLayer, simTimeType _slotLength); 00132 //PhysicalResourceBlock(const PhysicalResourceBlock&); 00133 00134 ~PhysicalResourceBlock(); 00136 simTimeType getUsedTime() const; 00138 simTimeType getFreeTime() const; 00140 //void setNextPosition(simTimeType _nextPosition); 00141 00142 void 00143 consistencyCheck(); 00144 00146 simTimeType getNextPosition() const; 00147 00149 bool pduFitsInto(strategy::RequestForResource& request, 00150 MapInfoEntryPtr mapInfoEntry) const; 00151 00154 int getFreeBitsOnPhysicalResourceBlock(MapInfoEntryPtr mapInfoEntry) const; 00155 00157 bool addCompound(simTimeType compoundDuration, 00158 wns::scheduler::ConnectionID connectionID, 00159 wns::scheduler::UserID userID, 00160 wns::scheduler::UserID sourceUserID, 00161 wns::ldk::CompoundPtr compoundPtr, 00162 wns::service::phy::phymode::PhyModeInterfacePtr phyModePtr, 00163 wns::Power txPower, 00164 wns::service::phy::ofdma::PatternPtr pattern, 00165 ChannelQualityOnOneSubChannel _estimatedCQI, 00166 bool _useHARQ 00167 ); 00168 00174 bool addCompound(strategy::RequestForResource& request, 00175 MapInfoEntryPtr mapInfoEntry, // <- must not contain compounds yet 00176 wns::ldk::CompoundPtr compoundPtr, 00177 bool _useHARQ 00178 ); 00179 00181 std::string toString() const; 00183 std::string dumpContents(const std::string& prefix) const; 00184 00186 int countScheduledCompounds() const; 00190 bool isEmpty() const; 00192 wns::scheduler::UserID getUserID() const; 00193 wns::scheduler::UserID getSourceUserID() const; 00196 wns::Power getTxPower() const; 00201 void setTxPower(wns::Power power); 00202 00207 void deleteCompounds(); 00210 void grantFullResources(); 00213 void processMasterMap(); 00215 bool hasResourcesForUser(wns::scheduler::UserID user) const; 00217 int getNetBlockSizeInBits() const; 00218 00219 wns::service::phy::phymode::PhyModeInterfacePtr 00220 getPhyMode() { return phyModePtr; } 00221 00222 wns::Power 00223 getTxPower() { return txPower; } 00224 00225 int 00226 getSubChannelIndex() const { return subChannelIndex; } 00227 00228 void 00229 setSubChannelIndex(int scindex) { subChannelIndex = scindex; } 00230 00231 int 00232 getTimeSlotIndex() const { return timeSlotIndex; } 00233 00234 void 00235 setTimeSlotIndex(int tsindex) { timeSlotIndex = tsindex; } 00236 00237 int 00238 getSpatialLayerIndex() const { return spatialIndex; } 00239 00240 bool 00241 hasScheduledCompounds() const { return !scheduledCompounds.empty(); } 00242 00243 wns::scheduler::UserID 00244 getUserIDOfScheduledCompounds() 00245 { 00246 if (hasScheduledCompounds()) 00247 { 00248 return scheduledCompounds.begin()->userID; 00249 } 00250 return wns::scheduler::UserID(); 00251 } 00252 00253 wns::scheduler::UserID 00254 getSourceUserIDOfScheduledCompounds() 00255 { 00256 if (hasScheduledCompounds()) 00257 { 00258 return scheduledCompounds.begin()->sourceUserID; 00259 } 00260 return wns::scheduler::UserID(); 00261 } 00262 00263 ScheduledCompoundsList::const_iterator 00264 scheduledCompoundsBegin() 00265 { 00266 return scheduledCompounds.begin(); 00267 } 00268 00269 ScheduledCompoundsList::const_iterator 00270 scheduledCompoundsEnd() 00271 { 00272 return scheduledCompounds.end(); 00273 } 00274 00275 void 00276 clearScheduledCompounds() 00277 { 00278 scheduledCompounds.clear(); 00279 } 00280 00281 ChannelQualityOnOneSubChannel 00282 getEstimatedCQI() const 00283 { 00284 return estimatedCQI; 00285 }; 00286 00287 bool 00288 isHARQEnabled() const; 00289 00290 private: 00292 int subChannelIndex; 00294 int timeSlotIndex; 00297 int spatialIndex; 00299 simTimeType slotLength; 00301 simTimeType freeTime; 00303 simTimeType nextPosition; 00305 ScheduledCompoundsList scheduledCompounds; 00307 wns::scheduler::UserID userID; 00308 wns::scheduler::UserID sourceUserID; 00310 wns::service::phy::phymode::PhyModeInterfacePtr phyModePtr; 00312 wns::Power txPower; 00313 //wns::CandI estimatedCandI; // not supported yet 00316 wns::service::phy::ofdma::PatternPtr antennaPattern; 00317 00319 ChannelQualityOnOneSubChannel estimatedCQI; 00320 }; // PhysicalResourceBlock 00321 00323 typedef std::vector<PhysicalResourceBlock> PhysicalResourceBlockVector; 00324 00328 class SchedulingTimeSlot 00329 : virtual public wns::RefCountable // for SmartPtr 00330 { 00331 public: 00332 SchedulingTimeSlot(); 00333 SchedulingTimeSlot(const SchedulingTimeSlot& other); 00334 SchedulingTimeSlot(int _subChannel, int _timeSlot, int _numSpatialLayers, simTimeType _slotLength); 00335 //SchedulingTimeSlot(const SchedulingTimeSlot&); 00336 00337 ~SchedulingTimeSlot(); 00338 void 00339 consistencyCheck(); 00340 00342 simTimeType getUsedTime() const; 00344 simTimeType getFreeTime() const; 00346 int countScheduledCompounds() const; 00350 bool isEmpty() const; 00353 wns::scheduler::UserID getUserID() const; 00354 wns::scheduler::UserID getSourceUserID() const; 00357 wns::Power getTxPower() const; 00362 void setTxPower(wns::Power power); 00364 bool pduFitsInto(strategy::RequestForResource& request, 00365 MapInfoEntryPtr mapInfoEntry) const; 00367 std::string dumpContents(const std::string& prefix) const; 00369 std::string toString() const; 00373 void deleteCompounds(); 00375 void grantFullResources(); 00377 void processMasterMap(); 00379 bool hasResourcesForUser(wns::scheduler::UserID user) const; 00381 int getNetBlockSizeInBits() const; 00382 bool isHARQEnabled() const; 00383 wns::scheduler::ChannelQualityOnOneSubChannel getEstimatedCQI(wns::scheduler::UserID user) const; 00384 public: 00386 PhysicalResourceBlockVector physicalResources; // [0..M-1] for MIMO 00388 int subChannelIndex; 00390 int timeSlotIndex; 00394 int numSpatialLayers; 00396 simTimeType slotLength; 00398 simTimeType timeSlotStartTime; 00400 bool timeSlotIsUsable; 00401 00402 HARQInfo harq; 00403 00404 }; // SchedulingTimeSlot 00405 00407 typedef SmartPtr<SchedulingTimeSlot> SchedulingTimeSlotPtr; 00408 00410 //typedef std::vector<SchedulingTimeSlot> SchedulingTimeSlotVector; 00412 typedef std::vector<SchedulingTimeSlotPtr> SchedulingTimeSlotPtrVector; 00413 00418 class SchedulingSubChannel 00419 : virtual public wns::RefCountable // for SmartPtr 00420 { 00421 public: 00422 SchedulingSubChannel(); 00423 SchedulingSubChannel(int _subChannelIndex, int _numberOfTimeSlots, int _numSpatialLayers, simTimeType _slotLength); 00424 ~SchedulingSubChannel(); 00426 std::string toString() const; 00428 std::string dumpContents(const std::string& prefix) const; 00430 simTimeType getUsedTime() const; 00432 simTimeType getFreeTime() const; 00433 //void setNextPosition(simTimeType _nextPosition); 00434 00436 //simTimeType getNextPosition() const; 00437 00439 bool pduFitsInto(strategy::RequestForResource& request, 00440 MapInfoEntryPtr mapInfoEntry) const; 00441 00444 int getFreeBitsOnSubChannel(MapInfoEntryPtr mapInfoEntry) const; 00445 00446 //wns::service::phy::phymode::PhyModeInterfacePtr 00447 //getPhyModeUsedInResource(int timeSlot, int spatialLayer) const; 00448 //wns::Power 00449 //getTxPowerUsedInResource(int timeSlot, int spatialLayer) const; 00450 00454 bool isEmpty() const; 00455 00459 void deleteCompounds(); 00461 void grantFullResources(); 00463 void processMasterMap(); 00465 bool hasResourcesForUser(wns::scheduler::UserID user) const; 00466 00467 wns::scheduler::ChannelQualityOnOneSubChannel getEstimatedCQI(wns::scheduler::UserID user) const; 00468 public: 00470 int subChannelIndex; 00472 int numberOfTimeSlots; 00476 int numSpatialLayers; 00478 simTimeType slotLength; 00480 bool subChannelIsUsable; 00482 //PhysicalResourceBlockVector physicalResources; // [0..M-1] for MIMO 00484 SchedulingTimeSlotPtrVector temporalResources; 00485 }; // SchedulingSubChannel 00486 00488 typedef SmartPtr<SchedulingSubChannel> SchedulingSubChannelPtr; 00489 00491 typedef std::vector<SchedulingSubChannel> SubChannelVector; 00493 //typedef std::vector<SchedulingSubChannelPtr> SubChannelPtrVector; // TODO? 00494 00496 class SchedulingMap : 00497 public wns::IOutputStreamable, 00498 virtual public wns::RefCountable // for SmartPtr 00499 { 00500 public: 00501 SchedulingMap() {}; 00502 00504 SchedulingMap(simTimeType _slotLength, int _numberOfSubChannels, int _numberOfTimeSlots, int _numSpatialLayers, int _frameNr); 00505 00506 ~SchedulingMap(); 00507 00509 bool pduFitsInto(strategy::RequestForResource& request, 00510 MapInfoEntryPtr mapInfoEntry) const; 00511 00514 int getFreeBitsOnSubChannel(MapInfoEntryPtr mapInfoEntry) const; 00515 00519 bool addCompound(int subChannelIndex, 00520 int timeSlot, 00521 int spatialLayer, 00522 simTimeType compoundDuration, 00523 wns::scheduler::ConnectionID connectionID, 00524 wns::scheduler::UserID userID, 00525 wns::scheduler::UserID sourceUserID, 00526 wns::ldk::CompoundPtr compoundPtr, 00527 wns::service::phy::phymode::PhyModeInterfacePtr phyModePtr, 00528 wns::Power txPower, 00529 wns::service::phy::ofdma::PatternPtr pattern, 00530 ChannelQualityOnOneSubChannel _estimatedCQI, 00531 bool useHARQ 00532 ); 00533 00539 bool addCompound(strategy::RequestForResource& request, 00540 MapInfoEntryPtr mapInfoEntry, // <- must not contain compounds yet 00541 wns::ldk::CompoundPtr compoundPtr, 00542 bool useHARQ 00543 ); 00544 00546 simTimeType getNextPosition(int subChannel, int timeSlot, int spatialLayer) const; 00547 00553 double 00554 getResourceUsage(); 00555 00557 simTimeType 00558 getUsedTime() const; 00559 00561 simTimeType 00562 getFreeTime() const; 00563 00566 wns::Power 00567 getUsedPower(int timeSlot) const; 00568 00571 wns::Power 00572 getRemainingPower(wns::Power totalPower, int timeSlot) const; 00573 00574 simTimeType getSlotLength() const { return slotLength; } 00575 int getNumberOfSubChannels() const { return numberOfSubChannels; } 00576 int getNumberOfTimeSlots() const { return numberOfTimeSlots; } 00577 int getNumberOfSpatialLayers() const { return numSpatialLayers; } 00578 int getNumberOfCompounds() const { return numberOfCompounds; } 00579 00580 wns::service::phy::phymode::PhyModeInterfacePtr 00581 getPhyModeUsedInResource(int subChannelIndex, int timeSlot, int spatialLayer) const; 00582 wns::Power 00583 getTxPowerUsedInResource(int subChannelIndex, int timeSlot, int spatialLayer) const; 00584 00586 void maskOutSubChannels(const UsableSubChannelVector& usableSubChannels); 00587 00589 void convertToMapInfoCollection(MapInfoCollectionPtr collection /*return value*/); 00590 00592 bool isEmpty() const; 00596 int 00597 getFrameNr() const; 00598 00602 void deleteCompounds(); 00604 void grantFullResources(); 00606 void processMasterMap(); 00608 bool hasResourcesForUser(wns::scheduler::UserID user) const; 00609 00611 std::string 00612 dumpContents(const std::string& prefix) const; 00613 00615 std::string 00616 toString(); 00617 00619 virtual std::string 00620 doToString() const; 00621 00623 static void writeHeaderToFile(std::ofstream& f); 00624 00626 void writeToFile(std::ofstream& f, const std::string& prefix) const; 00627 00629 void writeFile(std::string fileName) const; 00630 00631 public: 00633 SubChannelVector subChannels; 00634 wns::scheduler::ChannelQualityOnOneSubChannel getEstimatedCQI(wns::scheduler::UserID user) const; 00635 private: 00637 int frameNr; 00639 simTimeType slotLength; 00641 int numberOfSubChannels; 00643 int numberOfTimeSlots; 00647 int numSpatialLayers; 00649 int numberOfCompounds; 00651 double resourceUsage; 00653 //wns::Power totalRemainingPower 00654 }; // SchedulingMap 00655 00657 typedef SmartPtr<SchedulingMap> SchedulingMapPtr; 00658 00660 inline std::ostream& 00661 operator<< (std::ostream& s, const SchedulingCompound& object) { 00662 s << object.toString(); 00663 return s; 00664 } 00666 inline std::ostream& 00667 operator<< (std::ostream& s, const PhysicalResourceBlock& object) { 00668 s << object.toString(); 00669 return s; 00670 } 00672 inline std::ostream& 00673 operator<< (std::ostream& s, const SchedulingSubChannel& object) { 00674 s << object.toString(); 00675 return s; 00676 } 00678 inline std::ostream& 00679 operator<< (std::ostream& s, SchedulingMap& object) { 00680 s << object.toString(); 00681 return s; 00682 } 00683 //}}}} 00684 }} 00685 #endif //WNS_SCHEDULER_SCHEDULINGMAP_HPP
1.5.5