User Manual, Developers Guide and API Documentation

HARQUplinkRetransmission.cpp

Go to the documentation of this file.
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/HARQUplinkRetransmission.hpp>
00029 #include <WNS/scheduler/strategy/dsastrategy/DSAStrategyInterface.hpp>
00030 
00031 using namespace wns::scheduler::strategy::staticpriority;
00032 
00033 STATIC_FACTORY_REGISTER_WITH_CREATOR(
00034     HARQUplinkRetransmission,
00035     SubStrategyInterface,
00036     "HARQUplinkRetransmission",
00037     wns::PyConfigViewCreator);
00038 
00039 HARQUplinkRetransmission::HARQUplinkRetransmission(const wns::pyconfig::View& config):
00040     logger_(config.get("logger"))
00041 {
00042     MESSAGE_SINGLE(NORMAL, logger, "HARQUplinkRetransmission(): constructed");
00043 }
00044 
00045 HARQUplinkRetransmission::~HARQUplinkRetransmission()
00046 {
00047 }
00048 
00049 void
00050 HARQUplinkRetransmission::initialize()
00051 {
00052 }
00053 
00054 std::vector<int>
00055 HARQUplinkRetransmission::getUsableSubChannelsIDs(wns::scheduler::UserID user, const wns::scheduler::SchedulingMapPtr& schedulingMap)
00056 {
00057     std::vector<int> result;
00058 
00059     for (wns::scheduler::SubChannelVector::const_iterator iterSubChannel = schedulingMap->subChannels.begin();
00060          iterSubChannel != schedulingMap->subChannels.end();
00061          ++iterSubChannel
00062         )
00063     {
00064         const SchedulingSubChannel& subChannel = *iterSubChannel;
00065         int subChannelIndex = subChannel.subChannelIndex;
00066 
00067         // Is it blocked?
00068         if (!subChannel.subChannelIsUsable) continue;
00069 
00070         for ( SchedulingTimeSlotPtrVector::const_iterator iterTimeSlot = subChannel.temporalResources.begin();
00071               iterTimeSlot != subChannel.temporalResources.end(); ++iterTimeSlot)
00072         {
00073             const SchedulingTimeSlotPtr timeSlotPtr = *iterTimeSlot;
00074             int timeSlotIndex = timeSlotPtr->timeSlotIndex;
00075             if ( ((!timeSlotPtr->getUserID().isValid()) ||
00076                   timeSlotPtr->getUserID() == user) &&
00077                  timeSlotPtr->countScheduledCompounds()==0)
00078             { // free space found. Pack it into.
00079                 result.push_back(subChannel.subChannelIndex);
00080             }
00081         }
00082     }
00083     return result;
00084 }
00085 
00086 wns::scheduler::MapInfoCollectionPtr
00087 HARQUplinkRetransmission::doStartSubScheduling(SchedulerStatePtr schedulerState,
00088                                                wns::scheduler::SchedulingMapPtr schedulingMap)
00089 {
00090     MapInfoCollectionPtr mapInfoCollection = MapInfoCollectionPtr(new wns::scheduler::MapInfoCollection);
00091 
00092     if (colleagues.harq->getPeersWithPendingRetransmissions().size() == 0)
00093     {
00094         return mapInfoCollection;
00095     }
00096 
00097     wns::scheduler::UserSet us = colleagues.harq->getPeersWithPendingRetransmissions();
00098 
00099     wns::scheduler::UserSet::iterator user;
00100 
00101     for(user = us.begin(); user!=us.end(); ++user)
00102     {
00103         RequestForResource request(0,*user, 0, 0, true);
00104         dsastrategy::DSAResult resource;
00105 
00106         MESSAGE_SINGLE(NORMAL, logger, "HARQUplinkRetransmission(): Trying uplink retransmission for user " << user->getName());
00107 
00108         int processToSchedule = colleagues.harq->getPeerProcessesWithRetransmissions(*user).front();
00109 
00110         MESSAGE_BEGIN(NORMAL, logger, m, "HARQUplinkRetransmission(): user " << user->getName());
00111         m << " has " << colleagues.harq->getPeerProcessesWithRetransmissions(*user).size() << " processes with retransmissions";
00112         m << " choosing PID=" << processToSchedule;
00113         MESSAGE_END();
00114 
00115         std::vector<int> subchannels = getUsableSubChannelsIDs(*user, schedulingMap);
00116 
00117         size_t numAvailable = subchannels.size();
00118 
00119         int numRetransmissionsForUser = colleagues.harq->getNumberOfPeerRetransmissions(*user, processToSchedule);
00120 
00121         MESSAGE_SINGLE(NORMAL, logger, "HARQUplinkRetransmission(): need to schedule " << numRetransmissionsForUser << " on " << numAvailable << " available SCs");
00122 
00123         assure(numRetransmissionsForUser <= numAvailable, "Not enough resources available");
00124 
00125         colleagues.harq->schedulePeerRetransmissions(*user, processToSchedule);
00126 
00127         while ( (numRetransmissionsForUser > 0) && (numAvailable > 0) )
00128         {
00129             resource = colleagues.strategy->getDSAStrategy()->getSubChannelWithDSA(request, schedulerState, schedulingMap);
00130             int sc = resource.subChannel;
00131             int ts = resource.timeSlot;
00132             int numberOfSpatialLayers = schedulingMap->subChannels[sc].temporalResources[ts]->numSpatialLayers;
00133             for ( int spatialIndex = 0; spatialIndex < numberOfSpatialLayers; ++spatialIndex )
00134             { // only for MIMO. For SISO simply spatialIndex=0
00135                 PhysicalResourceBlock& prbDescriptor =
00136                     schedulingMap->subChannels[sc].temporalResources[ts]->physicalResources[spatialIndex];
00137 
00138                 if (prbDescriptor.hasScheduledCompounds())
00139                 {
00140                     continue;
00141                 }
00142                 else
00143                 {
00144                     MESSAGE_SINGLE(NORMAL, logger, "HARQUplinkRetransmission(): Scheduling uplink retransmission for user " << user->getName() << " on SC " << sc);
00145                     wns::service::phy::phymode::PhyModeInterfacePtr pm = colleagues.registry->getPhyModeMapper()->getLowestPhyMode();
00146                     prbDescriptor.getNetBlockSizeInBits();
00147                     prbDescriptor.addCompound(0.001, 0, *user, colleagues.registry->getMyUserID(), wns::ldk::CompoundPtr(), pm, wns::Power(), wns::service::phy::ofdma::PatternPtr(), wns::scheduler::ChannelQualityOnOneSubChannel(), true);
00148 
00149                     prbDescriptor.grantFullResources();
00150 
00151                     // Set flag so slave strategy can find TimeSlotPtrs for HARQ Retransmissions
00152                     schedulingMap->subChannels[sc].temporalResources[ts]->harq.reservedForRetransmission = true;
00153                     schedulingMap->subChannels[sc].temporalResources[ts]->harq.processID = processToSchedule;
00154                     numRetransmissionsForUser--;
00155                 }
00156             }
00157             subchannels = getUsableSubChannelsIDs(*user, schedulingMap);
00158             numAvailable = subchannels.size();
00159         }
00160     }
00161 
00162     return mapInfoCollection;
00163 }

Generated on Thu May 24 03:31:51 2012 for openWNS by  doxygen 1.5.5