![]() |
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_LDK_ARQ_STOPANDWAIT_HPP 00029 #define WNS_LDK_ARQ_STOPANDWAIT_HPP 00030 00031 #include <WNS/ldk/arq/ARQ.hpp> 00032 #include <WNS/ldk/Delayed.hpp> 00033 #include <WNS/ldk/SuspendableInterface.hpp> 00034 #include <WNS/ldk/SuspendSupport.hpp> 00035 #include <WNS/ldk/fu/Plain.hpp> 00036 00037 #include <WNS/events/CanTimeout.hpp> 00038 00039 #include <WNS/pyconfig/View.hpp> 00040 #include <WNS/logger/Logger.hpp> 00041 00042 namespace wns { namespace ldk { namespace arq { 00043 00047 class StopAndWaitCommand : 00048 public ARQCommand 00049 { 00050 public: 00055 typedef enum {I, RR} FrameType; 00056 00057 StopAndWaitCommand() 00058 { 00059 peer.type = I; 00060 peer.NS = 0; 00061 } 00062 00063 struct { 00064 } local; 00065 00066 struct { 00067 // Typically 1 Bit in reality 00068 FrameType type; 00069 // Typically 1 Bit in reality 00070 SequenceNumber NS; 00071 } peer; 00072 00073 struct {} magic; 00074 00075 // ARQCommand interface realization 00076 virtual bool 00077 isACK() const 00078 { 00079 return peer.type == RR; 00080 } 00081 }; 00082 00083 00087 class StopAndWait : 00088 public ARQ, 00089 public wns::ldk::fu::Plain<StopAndWait, StopAndWaitCommand>, 00090 public Delayed<StopAndWait>, 00091 virtual public SuspendableInterface, 00092 public SuspendSupport, 00093 public events::CanTimeout 00094 { 00095 public: 00096 // FUNConfigCreator interface realisation 00097 StopAndWait(fun::FUN* fuNet, const wns::pyconfig::View& config); 00098 00099 virtual 00100 ~StopAndWait(); 00101 00102 // CanTimeout interface realisation 00103 virtual void 00104 onTimeout(); 00105 00106 // Delayed interface realisation 00107 virtual bool 00108 hasCapacity() const; 00109 00110 virtual void 00111 processOutgoing(const CompoundPtr& sdu); 00112 00113 virtual void 00114 processIncoming(const CompoundPtr& compound); 00115 00116 // ARQ interface realization 00117 virtual const wns::ldk::CompoundPtr 00118 hasACK() const; 00119 00120 virtual const wns::ldk::CompoundPtr 00121 hasData() const; 00122 00123 virtual wns::ldk::CompoundPtr 00124 getACK(); 00125 00126 virtual wns::ldk::CompoundPtr 00127 getData(); 00128 00129 // SDU and PCI size calculation 00130 void 00131 calculateSizes(const CommandPool* commandPool, Bit& commandPoolSize, Bit& dataSize) const; 00132 00133 protected: 00134 virtual bool 00135 onSuspend() const; 00136 00140 double resendTimeout; 00141 00145 int bitsPerIFrame; 00146 00150 int bitsPerRRFrame; 00151 00155 ARQCommand::SequenceNumber NS; 00156 00160 ARQCommand::SequenceNumber NR; 00161 00168 CompoundPtr activeCompound; 00169 00173 CompoundPtr ackCompound; 00174 00178 bool sendNow; 00179 00180 logger::Logger logger; 00181 }; 00182 00183 }}} 00184 00185 #endif // NOT defined WNS_LDK_ARQ_STOPANDWAIT_HPP 00186 00187
1.5.5