![]() |
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 #ifndef WNS_SCHEDULER_HARQ_HARQ_HPP 00029 #define WNS_SCHEDULER_HARQ_HARQ_HPP 00030 00031 #include <WNS/scheduler/harq/HARQInterface.hpp> 00032 #include <WNS/service/phy/power/PowerMeasurement.hpp> 00033 #include <WNS/ldk/harq/softcombining/Container.hpp> 00034 #include <WNS/distribution/Uniform.hpp> 00035 #include <WNS/probe/bus/ContextCollector.hpp> 00036 00037 #include <WNS/logger/Logger.hpp> 00038 #include <WNS/container/Registry.hpp> 00039 #include <WNS/Cloneable.hpp> 00040 00041 namespace wns { namespace scheduler { namespace harq { 00042 00043 class SchedulingTimeSlotInfo 00044 { 00045 public: 00046 SchedulingTimeSlotInfo(wns::scheduler::SchedulingTimeSlotPtr timeSlot, wns::service::phy::power::PowerMeasurementPtr measurement): 00047 timeSlot_(timeSlot), 00048 measurement_(measurement) 00049 {} 00050 00051 SchedulingTimeSlotPtr timeSlot_; 00052 wns::service::phy::power::PowerMeasurementPtr measurement_; 00053 }; 00054 00055 typedef wns::ldk::harq::softcombining::Container<SchedulingTimeSlotInfo> SoftCombiningContainer; 00056 00057 class HARQEntity; 00058 00059 class IDecoder: 00060 public virtual wns::CloneableInterface 00061 { 00062 public: 00063 00064 virtual bool 00065 canDecode(SoftCombiningContainer) = 0; 00066 }; 00067 STATIC_FACTORY_DEFINE(IDecoder, wns::PyConfigViewCreator); 00068 00072 class UniformRandomDecoder: 00073 public IDecoder, 00074 public wns::Cloneable<UniformRandomDecoder> 00075 { 00076 public: 00077 UniformRandomDecoder(const wns::pyconfig::View&); 00078 00079 UniformRandomDecoder(const UniformRandomDecoder& other); 00080 00081 virtual ~UniformRandomDecoder() {} 00082 00083 virtual bool 00084 canDecode(SoftCombiningContainer); 00085 private: 00086 00087 std::auto_ptr<wns::distribution::Distribution> dis_; 00088 00089 double initialPER_; 00090 00091 double rolloffFactor_; 00092 00093 wns::logger::Logger logger_; 00094 }; 00095 00099 class ChaseCombiningDecoder: 00100 public IDecoder, 00101 public wns::Cloneable<ChaseCombiningDecoder> 00102 { 00103 public: 00104 ChaseCombiningDecoder(const wns::pyconfig::View&); 00105 00106 ChaseCombiningDecoder(const ChaseCombiningDecoder&); 00107 00108 virtual ~ChaseCombiningDecoder() {} 00109 00110 virtual bool 00111 canDecode(SoftCombiningContainer); 00112 private: 00113 00114 std::auto_ptr<wns::distribution::Distribution> dis_; 00115 00116 wns::logger::Logger logger_; 00117 00118 wns::probe::bus::ContextCollector effSINRCC_; 00119 }; 00120 00125 class HARQReceiverProcess 00126 { 00127 class Feedback 00128 { 00129 public: 00130 boost::function<void ()> callback_; 00131 bool retransmissionLimitHit_; 00132 }; 00133 00134 public: 00135 HARQReceiverProcess(const wns::pyconfig::View&, HARQEntity*, int processID, int numRVs, int retransmissionLimit, const wns::logger::Logger); 00136 00137 HARQReceiverProcess(const HARQReceiverProcess&); 00138 00139 void 00140 setEntity(HARQEntity*); 00141 00142 void 00143 onTimeSlotReceived(const wns::scheduler::SchedulingTimeSlotPtr&, HARQInterface::TimeSlotInfo); 00144 00145 HARQInterface::DecodeStatusContainer 00146 decode(); 00147 00148 void 00149 sendPendingFeedback(); 00150 00151 int 00152 numPendingPeerRetransmissions() const; 00153 00154 void 00155 setNumPendingPeerRetransmissions(int num); 00156 00157 void 00158 schedulePeerRetransmissions(); 00159 00160 int 00161 processID() const; 00162 00163 SoftCombiningContainer 00164 receptionBuffer() const; 00165 00166 wns::scheduler::SchedulingTimeSlotPtr 00167 schedulingTimeSlot() const; 00168 00169 bool 00170 isFree() const; 00171 00172 private: 00173 00174 void 00175 endReception(); 00176 00177 HARQEntity* entity_; 00178 00179 int processID_; 00180 00181 int numRVs_; 00182 00183 int retransmissionLimit_; 00184 00185 wns::logger::Logger logger_; 00186 00187 SoftCombiningContainer receptionBuffer_; 00188 00189 int numPendingPeerRetransmissions_; 00190 00191 wns::events::scheduler::IEventPtr receptionDelta_; 00192 00193 std::list<Feedback> pendingFeedback_; 00194 00195 bool waitingForRetransmissions_; 00196 }; 00197 00203 class HARQSenderProcess 00204 { 00205 public: 00206 HARQSenderProcess(HARQEntity*, int processID, int numRVs, int retransmissionLimit, const wns::logger::Logger); 00207 00208 void 00209 setEntity(HARQEntity*); 00210 00211 bool 00212 hasCapacity(long int transportBlockID); 00213 00214 void 00215 newTransmission(long int transportBlockID, const wns::scheduler::SchedulingTimeSlotPtr&); 00216 00217 void 00218 ACK(); 00219 00220 void 00221 NACK(); 00222 00223 void 00224 postDecodingACK(); 00225 00226 void 00227 postDecodingNACK(); 00228 00229 int 00230 getNumberOfRetransmissions() const; 00231 00232 wns::scheduler::SchedulingTimeSlotPtr 00233 getNextRetransmission(); 00234 00235 wns::scheduler::SchedulingTimeSlotPtr 00236 peekNextRetransmission() const; 00237 00238 int 00239 processID() const; 00240 00241 private: 00242 HARQEntity* entity_; 00243 00244 int processID_; 00245 00246 int numRVs_; 00247 00248 int retransmissionLimit_; 00249 00250 long int transportBlockID_; 00251 00252 int retransmissionCounter_; 00253 00254 bool NDI_; 00255 00256 typedef std::list<wns::scheduler::SchedulingTimeSlotPtr> TimeSlotList; 00257 00258 TimeSlotList timeslots_; 00259 00260 wns::logger::Logger logger_; 00261 00262 int nextPositionInTB_; 00263 00264 std::list<wns::scheduler::SchedulingTimeSlotPtr> pendingRetransmissions_; 00265 }; 00266 00270 class HARQEntity: 00271 public wns::Cloneable<HARQEntity> 00272 { 00273 public: 00274 HARQEntity(const wns::pyconfig::View&, int numSenderProcesses, int numReceiverProcesses, int numRVs, int retransmissionLimit, wns::logger::Logger logger); 00275 00276 HARQEntity(const HARQEntity&); 00277 00278 void 00279 newTransmission(long int transportBlockID, const wns::scheduler::SchedulingTimeSlotPtr&); 00280 00281 bool 00282 hasCapacity(long int transportBlockID); 00283 00284 void 00285 onTimeSlotReceived(const wns::scheduler::SchedulingTimeSlotPtr&, HARQInterface::TimeSlotInfo); 00286 00287 HARQInterface::DecodeStatusContainer 00288 decode(); 00289 00290 void 00291 enqueueRetransmission(wns::scheduler::SchedulingTimeSlotPtr&); 00292 00293 std::list<int> 00294 getProcessesWithRetransmissions() const; 00295 00296 int 00297 getNumberOfRetransmissions(int processID); 00298 00299 bool 00300 hasRetransmissions(); 00301 00302 bool 00303 hasReceiverCapacity(); 00304 00312 wns::scheduler::SchedulingTimeSlotPtr 00313 getNextRetransmission(int processID); 00314 00322 virtual wns::scheduler::SchedulingTimeSlotPtr 00323 peekNextRetransmission(int processID) const; 00324 00325 std::list<int> 00326 getPeerProcessesWithRetransmissions() const; 00327 00328 int 00329 getNumberOfPeerRetransmissions(int processID) const; 00330 00331 void 00332 schedulePeerRetransmissions(int processID); 00333 00334 void 00335 sendPendingFeedback(); 00336 00337 std::auto_ptr<IDecoder> decoder_; 00338 00339 private: 00340 std::vector<HARQSenderProcess> senderProcesses_; 00341 00342 std::vector<HARQReceiverProcess> receiverProcesses_; 00343 00344 int numSenderProcesses_; 00345 00346 int numReceiverProcesses_; 00347 00348 int numRVs_; 00349 00350 int retransmissionLimit_; 00351 00352 wns::logger::Logger logger_; 00353 00354 int scheduledPeerRetransmissionCounter_; 00355 00356 //typedef std::map<long int, IDecoder::DecoderInput> TBContainer; 00357 //TBContainer perTB; 00358 }; 00359 00364 class HARQ: 00365 public wns::scheduler::harq::HARQInterface 00366 { 00367 public: 00368 HARQ(const wns::pyconfig::View&); 00369 00370 virtual ~HARQ(); 00371 00375 virtual void 00376 storeSchedulingTimeSlot(long int transportBlockID, const wns::scheduler::SchedulingTimeSlotPtr&); 00377 00381 virtual void 00382 onTimeSlotReceived(const wns::scheduler::SchedulingTimeSlotPtr&, HARQInterface::TimeSlotInfo); 00383 00387 virtual HARQInterface::DecodeStatusContainer 00388 decode(); 00389 00390 virtual wns::scheduler::UserSet 00391 getUsersWithRetransmissions() const; 00392 00393 std::list<int> 00394 getProcessesWithRetransmissions(wns::scheduler::UserID peer) const; 00395 00399 virtual int 00400 getNumberOfRetransmissions(wns::scheduler::UserID, int processID); 00401 00402 virtual bool 00403 hasFreeSenderProcess(wns::scheduler::UserID peer); 00404 00405 virtual bool 00406 hasFreeReceiverProcess(wns::scheduler::UserID peer); 00407 00415 virtual wns::scheduler::SchedulingTimeSlotPtr 00416 getNextRetransmission(wns::scheduler::UserID user, int processID); 00417 00425 virtual wns::scheduler::SchedulingTimeSlotPtr 00426 peekNextRetransmission(wns::scheduler::UserID user, int processID) const; 00427 00428 virtual void 00429 setDownlinkHARQ(HARQInterface* downlinkHARQ); 00430 00435 virtual wns::scheduler::UserSet 00436 getPeersWithPendingRetransmissions() const; 00437 00438 std::list<int> 00439 getPeerProcessesWithRetransmissions(wns::scheduler::UserID peer) const; 00440 00441 int 00442 getNumberOfPeerRetransmissions(wns::scheduler::UserID peer, int processID) const; 00443 00444 void 00445 schedulePeerRetransmissions(wns::scheduler::UserID peer, int processID); 00446 00447 virtual void 00448 sendPendingFeedback(); 00449 00450 private: 00451 HARQEntity* 00452 findEntity(wns::scheduler::UserID userID); 00453 00454 wns::logger::Logger logger_; 00455 00456 typedef wns::container::Registry<wns::scheduler::UserID, HARQEntity*> HARQEntityContainer; 00457 00461 HARQEntityContainer harqEntities_; 00462 00466 int numSenderProcesses_; 00467 00472 int numReceiverProcesses_; 00473 00477 int numRVs_; 00478 00479 int retransmissionLimit_; 00480 00481 HARQEntity* harqEntityPrototype_; 00482 00483 wns::probe::bus::ContextCollector numRetransmissionsProbeCC; 00484 }; 00485 00486 } // harq 00487 } // scheduler 00488 } // wns 00489 00490 #endif // WNS_SCHEDULER_HARQ_HARQ_HPP
1.5.5