![]() |
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 CUMULATIVEACK_HPP 00029 #define CUMULATIVEACK_HPP 00030 00031 #include <WNS/ldk/arq/ARQ.hpp> 00032 #include <WNS/ldk/fu/Plain.hpp> 00033 #include <WNS/ldk/Delayed.hpp> 00034 #include <WNS/ldk/SuspendableInterface.hpp> 00035 #include <WNS/ldk/SuspendSupport.hpp> 00036 #include <WNS/ldk/DelayedDeliveryInterface.hpp> 00037 00038 #include <WNS/ldk/fun/FUN.hpp> 00039 00040 #include <WNS/events/CanTimeout.hpp> 00041 00042 #include <WNS/pyconfig/View.hpp> 00043 #include <WNS/SmartPtr.hpp> 00044 #include <WNS/logger/Logger.hpp> 00045 00046 #include <vector> 00047 00048 namespace wns { namespace ldk { namespace arq { 00049 00051 class CumulativeACKCommand : 00052 public ARQCommand 00053 { 00054 public: 00055 CumulativeACKCommand() 00056 { 00057 peer.type = I; 00058 peer.NS = 0; 00059 peer.NR = 0; 00060 } 00062 typedef enum {I, RR, SREJ} FrameType; 00063 00064 bool isACK() const 00065 { 00066 return (peer.type == RR) || (peer.type == SREJ); 00067 } 00068 00069 struct {} local; 00070 struct { 00071 FrameType type; 00072 unsigned long int NS; 00073 unsigned long int NR; 00074 } peer; 00075 struct {} magic; 00076 00077 }; 00078 00080 00085 class CumulativeACK : 00086 public ARQ, 00087 public wns::ldk::fu::Plain<CumulativeACK, CumulativeACKCommand>, 00088 public Delayed<CumulativeACK>, 00089 virtual public SuspendableInterface, 00090 public SuspendSupport, 00091 virtual public DelayedDeliveryInterface, 00092 public events::CanTimeout 00093 { 00094 private: 00096 class CAElement: 00097 public events::CanTimeout 00098 { 00099 public: 00100 CAElement(); 00101 CAElement(CumulativeACK* _parent, unsigned int Time=1 ): 00102 parent(_parent), 00103 resendTimeout(Time), 00104 compound(CompoundPtr()), 00105 sendNow(false), 00106 logger("WNS", "CumulativeACK") {}; 00107 00108 ~CAElement() 00109 { 00110 //std::cout<<" Jawoi CAEl destructor has been called ! "<<std::endl; 00111 parent = NULL; 00112 } 00113 00114 void onTimeout(){ 00115 assure(compound, "no PDU during onTimeout."); 00116 parent->statusCollector->onFailedTransmission(this->compound); 00117 sendNow = true; 00118 MESSAGE_BEGIN(NORMAL, logger, m, parent->getFUN()->getName()); 00119 m << " Timeout of CAElement NS -> " << parent->getCommand(compound->getCommandPool())->peer.NS; 00120 MESSAGE_END(); 00121 parent->tryToSend(); 00122 } 00123 00124 wns::ldk::CompoundPtr getCompound(){return compound;}; 00125 00126 CumulativeACK* parent; 00127 unsigned int resendTimeout; 00128 wns::ldk::CompoundPtr compound; 00129 //true if PDU is supposed to be sent. Not being used in case of receiving 00130 bool sendNow; 00131 logger::Logger logger; 00132 00133 }; 00135 typedef std::vector<CAElement> CAElements; 00136 public: 00138 CumulativeACK(fun::FUN* fuNet, const wns::pyconfig::View& config); 00139 00140 ~CumulativeACK(); 00141 00143 virtual void onTimeout(){} 00144 00145 // Delayed interface realisation 00146 virtual bool hasCapacity() const; 00147 virtual void processOutgoing(const CompoundPtr& sdu); 00148 // virtual const CompoundPtr hasSomethingToSend() const; // implemented by ARQ 00149 // virtual CompoundPtr getSomethingToSend(); // implemented by ARQ 00150 virtual void processIncoming(const CompoundPtr& compound); 00151 00153 virtual const wns::ldk::CompoundPtr hasACK() const; 00154 virtual const wns::ldk::CompoundPtr hasData() const; 00155 virtual wns::ldk::CompoundPtr getACK(); 00156 virtual wns::ldk::CompoundPtr getData(); 00157 00158 // Overload of CommandTypeSpecifier Interface 00159 void calculateSizes(const CommandPool* commandPool, Bit& commandPoolSize, Bit& sduSize) const; 00160 00161 virtual bool onSuspend() const; 00162 00163 protected: 00164 virtual void doDelayDelivery(); 00165 virtual void doDeliver(); 00166 00168 wns::ldk::CompoundPtr ackCompound; 00170 unsigned long int wS; 00172 unsigned long int NS; 00174 unsigned long int NSack; 00176 unsigned long int NR; 00178 int sequenceNumberSize; 00180 CAElements receivingCompounds; 00181 CAElements sendingCompounds; 00183 double resendTimeout; 00184 00185 bool delayingDelivery; 00186 int delayedDeliveryNR; 00187 00188 logger::Logger logger; 00189 }; 00190 }}} 00191 #endif 00192 00193
1.5.5