![]() |
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-2007 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 #include <WNS/scheduler/strategy/staticpriority/HARQUplinkSlaveRetransmission.hpp> 00029 00030 using namespace wns::scheduler::strategy::staticpriority; 00031 00032 STATIC_FACTORY_REGISTER_WITH_CREATOR( 00033 HARQUplinkSlaveRetransmission, 00034 SubStrategyInterface, 00035 "HARQUplinkSlaveRetransmission", 00036 wns::PyConfigViewCreator); 00037 00038 HARQUplinkSlaveRetransmission::HARQUplinkSlaveRetransmission(const wns::pyconfig::View& config): 00039 logger_(config.get("logger")) 00040 { 00041 MESSAGE_SINGLE(NORMAL, logger, "HARQUplinkSlaveRetransmission(): constructed"); 00042 } 00043 00044 HARQUplinkSlaveRetransmission::~HARQUplinkSlaveRetransmission() 00045 { 00046 } 00047 00048 void 00049 HARQUplinkSlaveRetransmission::initialize() 00050 { 00051 } 00052 00053 void 00054 HARQUplinkSlaveRetransmission::checkInputMap(SchedulerStatePtr schedulerState, 00055 wns::scheduler::SchedulingMapPtr schedulingMap) const 00056 { 00057 int scheduledRetransmissions = 0; 00058 00059 int processID = 8855994; 00060 00061 int numSC = schedulerState->currentState->strategyInput->getFChannels(); 00062 00063 int numberOfSpatialLayers = schedulerState->currentState->strategyInput->getMaxSpatialLayers(); 00064 00065 wns::scheduler::UserID peerUser; 00066 00067 for (int sc=0; sc < numSC; sc++) 00068 { 00069 if (!schedulingMap->subChannels[sc].subChannelIsUsable) continue; 00070 00071 for ( SchedulingTimeSlotPtrVector::iterator iterTimeSlot = schedulingMap->subChannels[sc].temporalResources.begin(); 00072 iterTimeSlot != schedulingMap->subChannels[sc].temporalResources.end(); ++iterTimeSlot) 00073 { 00074 SchedulingTimeSlotPtr timeSlotPtr = *iterTimeSlot; 00075 int timeSlotIndex = timeSlotPtr->timeSlotIndex; 00076 00077 if (timeSlotPtr->harq.reservedForRetransmission && 00078 timeSlotPtr->getUserID().isValid() && 00079 timeSlotPtr->getUserID() == colleagues.registry->getMyUserID() && 00080 timeSlotPtr->countScheduledCompounds()==0) 00081 { 00082 scheduledRetransmissions++; 00083 if (processID == 8855994) 00084 { 00085 processID = timeSlotPtr->harq.processID; 00086 } 00087 else 00088 { 00089 assure(timeSlotPtr->harq.processID == processID, "More than one process scheduled " << timeSlotPtr->harq.processID << "/" << processID); 00090 } 00091 00092 if (peerUser.isValid()) 00093 { 00094 assure(peerUser == timeSlotPtr->getSourceUserID(), "Mismatch in UserID " << timeSlotPtr->getSourceUserID().getName() << "/" << peerUser.getName()); 00095 } 00096 else 00097 { 00098 peerUser = timeSlotPtr->getSourceUserID(); 00099 assure(peerUser.isValid(), "Invalid UserID"); 00100 } 00101 } 00102 00103 } 00104 } 00105 00106 if (scheduledRetransmissions > 0) 00107 { 00108 assure(peerUser.isValid(), "Invalid UserID"); 00109 00110 int numberOfRetransmissions = colleagues.harq->getNumberOfRetransmissions(peerUser, processID); 00111 00112 MESSAGE_BEGIN(NORMAL, logger, m, "Scheduled Retransmissions " << scheduledRetransmissions); 00113 m << " Available Retransmissions " << numberOfRetransmissions; 00114 MESSAGE_END(); 00115 assure(scheduledRetransmissions <= numberOfRetransmissions, "More retransmissions scheduled than available"); 00116 } 00117 } 00118 00119 wns::scheduler::UserID 00120 HARQUplinkSlaveRetransmission::getSourceUserID(SchedulerStatePtr schedulerState, 00121 wns::scheduler::SchedulingMapPtr schedulingMap) 00122 { 00123 int numSC = schedulerState->currentState->strategyInput->getFChannels(); 00124 00125 int numberOfSpatialLayers = schedulerState->currentState->strategyInput->getMaxSpatialLayers(); 00126 00127 for (int sc=0; sc < numSC; sc++) 00128 { 00129 if (!schedulingMap->subChannels[sc].subChannelIsUsable) continue; 00130 00131 for ( SchedulingTimeSlotPtrVector::iterator iterTimeSlot = schedulingMap->subChannels[sc].temporalResources.begin(); 00132 iterTimeSlot != schedulingMap->subChannels[sc].temporalResources.end(); ++iterTimeSlot) 00133 { 00134 SchedulingTimeSlotPtr timeSlotPtr = *iterTimeSlot; 00135 int timeSlotIndex = timeSlotPtr->timeSlotIndex; 00136 00137 if (timeSlotPtr->harq.reservedForRetransmission && 00138 timeSlotPtr->getUserID().isValid() && 00139 timeSlotPtr->getUserID() == colleagues.registry->getMyUserID() && 00140 timeSlotPtr->countScheduledCompounds()==0) 00141 { 00142 return timeSlotPtr->getSourceUserID(); 00143 } 00144 } 00145 } 00146 // If consistency check is good, this should never happen 00147 return wns::scheduler::UserID(); 00148 } 00149 00150 int 00151 HARQUplinkSlaveRetransmission::getProcessID(SchedulerStatePtr schedulerState, 00152 wns::scheduler::SchedulingMapPtr schedulingMap) 00153 { 00154 int numSC = schedulerState->currentState->strategyInput->getFChannels(); 00155 00156 int numberOfSpatialLayers = schedulerState->currentState->strategyInput->getMaxSpatialLayers(); 00157 00158 for (int sc=0; sc < numSC; sc++) 00159 { 00160 if (!schedulingMap->subChannels[sc].subChannelIsUsable) continue; 00161 00162 for ( SchedulingTimeSlotPtrVector::iterator iterTimeSlot = schedulingMap->subChannels[sc].temporalResources.begin(); 00163 iterTimeSlot != schedulingMap->subChannels[sc].temporalResources.end(); ++iterTimeSlot) 00164 { 00165 SchedulingTimeSlotPtr timeSlotPtr = *iterTimeSlot; 00166 int timeSlotIndex = timeSlotPtr->timeSlotIndex; 00167 00168 if (timeSlotPtr->harq.reservedForRetransmission && 00169 timeSlotPtr->getUserID().isValid() && 00170 timeSlotPtr->getUserID() == colleagues.registry->getMyUserID() && 00171 timeSlotPtr->countScheduledCompounds()==0) 00172 { 00173 return timeSlotPtr->harq.processID; 00174 } 00175 } 00176 } 00177 // If consistency check is good, this should never happen 00178 return -1; 00179 } 00180 00181 wns::scheduler::MapInfoCollectionPtr 00182 HARQUplinkSlaveRetransmission::doStartSubScheduling(SchedulerStatePtr schedulerState, 00183 wns::scheduler::SchedulingMapPtr schedulingMap) 00184 { 00185 #ifndef NDEBUG 00186 checkInputMap(schedulerState, schedulingMap); 00187 #endif 00188 00189 MapInfoCollectionPtr mapInfoCollection = MapInfoCollectionPtr(new wns::scheduler::MapInfoCollection); 00190 00191 wns::scheduler::UserID sourceUserID = getSourceUserID(schedulerState, schedulingMap); 00192 00193 if (!sourceUserID.isValid()) 00194 { 00195 return mapInfoCollection; 00196 } 00197 00198 int processID = getProcessID(schedulerState, schedulingMap); 00199 00200 assure(processID >= 0, "Invalid processID in HARQUplinkSlaveRetransmission"); 00201 00202 int numberOfRetransmissions = colleagues.harq->getNumberOfRetransmissions(sourceUserID, processID); 00203 00204 MESSAGE_SINGLE(NORMAL, logger, "doStartSubScheduling: "<<numberOfRetransmissions<<" HARQ retransmission(s) waiting"); 00205 00206 if (numberOfRetransmissions>0) 00207 { 00208 int numSC = schedulerState->currentState->strategyInput->getFChannels(); 00209 00210 int numberOfSpatialLayers = schedulerState->currentState->strategyInput->getMaxSpatialLayers(); 00211 00212 wns::scheduler::SchedulingTimeSlotPtr resourceBlock = colleagues.harq->peekNextRetransmission(sourceUserID, processID); 00213 00214 assure(resourceBlock != NULL, "resourceBlock == NULL although numberOfRetransmissions="<<numberOfRetransmissions); 00215 00216 bool found = false; 00217 bool giveUp = false; 00218 00219 while(!giveUp && resourceBlock != NULL) 00220 { 00221 found = false; 00222 for (int sc=0; !found && sc < numSC; sc++) 00223 { 00224 if (!schedulingMap->subChannels[sc].subChannelIsUsable) continue; 00225 00226 for ( SchedulingTimeSlotPtrVector::iterator iterTimeSlot = schedulingMap->subChannels[sc].temporalResources.begin(); 00227 iterTimeSlot != schedulingMap->subChannels[sc].temporalResources.end(); ++iterTimeSlot) 00228 { 00229 SchedulingTimeSlotPtr timeSlotPtr = *iterTimeSlot; 00230 int timeSlotIndex = timeSlotPtr->timeSlotIndex; 00231 00232 if (timeSlotPtr->harq.reservedForRetransmission && 00233 timeSlotPtr->getUserID().isValid() && 00234 timeSlotPtr->getUserID() == resourceBlock->getUserID() && 00235 timeSlotPtr->countScheduledCompounds()==0) 00236 { // free space found. Pack it into. 00237 resourceBlock = colleagues.harq->getNextRetransmission(sourceUserID, processID); 00238 MESSAGE_BEGIN(NORMAL, logger, m, "Retransmitting"); 00239 m << " HARQ block ("<<resourceBlock->getUserID().getName()<<",processID=" << resourceBlock->harq.processID; 00240 m << ",Retry="<<resourceBlock->harq.retryCounter<<", TxPwr=" << resourceBlock->getTxPower() << ")"; 00241 m << " inside subchannel.timeslot=" <<sc<<"."<<timeSlotIndex; 00242 m << " (ex "<<resourceBlock->subChannelIndex<<"."<<resourceBlock->timeSlotIndex<<")"; 00243 MESSAGE_END(); 00244 assure(resourceBlock->subChannelIndex==resourceBlock->physicalResources[0].getSubChannelIndex(), 00245 "mismatch of subChannelIndex: "<<resourceBlock->subChannelIndex<<"!="<<resourceBlock->physicalResources[0].getSubChannelIndex()); 00246 assure(resourceBlock->timeSlotIndex==resourceBlock->physicalResources[0].getTimeSlotIndex(), 00247 "mismatch of timeSlotIndex: "<<resourceBlock->timeSlotIndex<<"!="<<resourceBlock->physicalResources[0].getTimeSlotIndex()); 00248 assure (resourceBlock != wns::scheduler::SchedulingTimeSlotPtr(),"resourceBlock==NULL"); 00249 00250 if (resourceBlock->harq.ackCallback.empty()) 00251 { 00252 std::cout << "Trying to retransmit resource block with empty ack callback in HARQUplinkSlaveRetransmission" << std::endl; 00253 exit(1); 00254 } 00255 00256 if (resourceBlock->harq.nackCallback.empty()) 00257 { 00258 std::cout << "Trying to retransmit resource block with empty nack callback in HARQUplinkSlaveRetransmission" << std::endl; 00259 exit(1); 00260 } 00261 00262 schedulingMap->subChannels[sc].temporalResources[timeSlotIndex] = resourceBlock; // copy Smartptr over 00263 // at this point timeSlotPtr is no longer valid for use! Only resourceBlock 00264 resourceBlock->subChannelIndex = sc; 00265 resourceBlock->timeSlotIndex = timeSlotIndex; 00266 assure(resourceBlock->physicalResources.size()==resourceBlock->numSpatialLayers, 00267 "mismatch in spatial domain: "<<resourceBlock->physicalResources.size()<<"!="<<resourceBlock->numSpatialLayers); 00268 // foreach PRB... fix subChannelIndex 00269 for ( PhysicalResourceBlockVector::iterator iterPRB = resourceBlock->physicalResources.begin(); 00270 iterPRB != resourceBlock->physicalResources.end(); ++iterPRB) 00271 { 00272 int spatialIndex = iterPRB->getSpatialLayerIndex(); 00273 MESSAGE_SINGLE(NORMAL, logger, sc<<"."<<timeSlotIndex<<".PRB["<<spatialIndex<<"]: Adjusting subChannelIndex from "<<iterPRB->getSubChannelIndex()<<" to "<<sc); 00274 iterPRB->setSubChannelIndex(sc); 00275 iterPRB->setTimeSlotIndex(timeSlotIndex); 00276 } 00277 MESSAGE_SINGLE(NORMAL, logger, schedulingMap->subChannels[sc].temporalResources[timeSlotIndex]->toString()); 00278 resourceBlock = colleagues.harq->peekNextRetransmission(sourceUserID, processID); 00279 found = true; 00280 break; 00281 } 00282 } // timeslots 00283 } // subcarriers 00284 00285 if (!found) 00286 giveUp = true; 00287 00288 } // while resource blocks 00289 } // if there are retransmissions 00290 /* 00291 #ifndef NDEBUG 00292 else 00293 { 00294 int numSC = schedulerState->currentState->strategyInput->getFChannels(); 00295 00296 int numberOfBeams = schedulerState->currentState->strategyInput->getMaxBeams(); 00297 */ 00298 // int numberOfRetransmissions = colleagues.harq->getNumberOfRetransmissions(/* @todo peer */); 00299 00300 /* int scheduledRetransmissions = 0; 00301 for (int sc=0; sc < numSC; sc++) 00302 { 00303 if (!schedulingMap->subChannels[sc].subChannelIsUsable) continue; 00304 00305 for ( SchedulingTimeSlotPtrVector::iterator iterTimeSlot = schedulingMap->subChannels[sc].temporalResources.begin(); 00306 iterTimeSlot != schedulingMap->subChannels[sc].temporalResources.end(); ++iterTimeSlot) 00307 { 00308 SchedulingTimeSlotPtr timeSlotPtr = *iterTimeSlot; 00309 int timeSlotIndex = timeSlotPtr->timeSlotIndex; 00310 00311 if (timeSlotPtr->harq.reservedForRetransmission && 00312 timeSlotPtr->getUserID().isValid() && 00313 timeSlotPtr->getUserID() == colleagues.registry->getMyUserID() && 00314 timeSlotPtr->countScheduledCompounds()==0) 00315 { // free space found. Pack it into. 00316 scheduledRetransmissions++; 00317 } 00318 00319 } 00320 } 00321 MESSAGE_BEGIN(NORMAL, logger, m, "Scheduled Retransmissions " << scheduledRetransmissions); 00322 m << " Available Retransmissions " << numberOfRetransmissions; 00323 MESSAGE_END(); 00324 assure(scheduledRetransmissions <= numberOfRetransmissions, "More retransmissions scheduled than available"); 00325 } 00326 #endif 00327 */ 00328 return mapInfoCollection; 00329 }
1.5.5