![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /****************************************************************************** 00002 * WNS (Wireless Network Simulator) * 00003 * __________________________________________________________________________ * 00004 * * 00005 * Copyright (C) 2004-2006 * 00006 * Chair of Communication Networks (ComNets) * 00007 * Kopernikusstr. 16, D-52074 Aachen, Germany * 00008 * phone: ++49-241-80-27910 (phone), fax: ++49-241-80-22242 * 00009 * email: wns@comnets.rwth-aachen.de * 00010 * www: http://wns.comnets.rwth-aachen.de * 00011 ******************************************************************************/ 00012 00013 #ifndef WNS_LDK_ARQ_STOPANDWAITRC_HPP 00014 #define WNS_LDK_ARQ_STOPANDWAITRC_HPP 00015 00016 #include <WNS/ldk/arq/ARQ.hpp> 00017 00018 #include <WNS/ldk/FunctionalUnitRC.hpp> 00019 #include <WNS/ldk/CommandTypeSpecifier.hpp> 00020 #include <WNS/ldk/IPortID.hpp> 00021 #include <WNS/ldk/HasDownPort.hpp> 00022 #include <WNS/ldk/HasUpPort.hpp> 00023 00024 #include <WNS/events/CanTimeout.hpp> 00025 #include <WNS/pyconfig/View.hpp> 00026 #include <WNS/logger/Logger.hpp> 00027 00028 #include <string> 00029 00030 namespace wns { namespace ldk { namespace arq { 00031 00032 00033 class Data 00034 : public virtual IPortID 00035 { 00036 public: 00037 static const std::string name; 00038 }; 00039 00040 class Ack 00041 : public virtual IPortID 00042 { 00043 public: 00044 static const std::string name; 00045 }; 00046 00047 00048 class StopAndWaitRCCommand 00049 : public ARQCommand 00050 { 00051 public: 00056 typedef enum {I, RR} FrameType; 00057 00058 StopAndWaitRCCommand() 00059 { 00060 peer.type = I; 00061 peer.NS = 0; 00062 } 00063 00064 struct { 00065 } local; 00066 00067 struct { 00068 // Typically 1 Bit in reality 00069 FrameType type; 00070 // Typically 1 Bit in reality 00071 SequenceNumber NS; 00072 } peer; 00073 00074 struct {} magic; 00075 00076 // ARQCommand interface realization 00077 virtual bool 00078 isACK() const 00079 { 00080 return peer.type == RR; 00081 } 00082 }; 00083 00084 00085 class StopAndWaitRC 00086 : public FunctionalUnitRC< StopAndWaitRC >, 00087 public CommandTypeSpecifier<StopAndWaitRCCommand>, 00088 public HasUpPort< StopAndWaitRC >, 00089 public HasDownPort< StopAndWaitRC, Port<Data> >, 00090 public HasDownPort< StopAndWaitRC, Port<Ack> >, 00091 public Cloneable< StopAndWaitRC >, 00092 public events::CanTimeout 00093 { 00094 public: 00095 // FUNConfigCreator interface realisation 00096 StopAndWaitRC(fun::FUN* fuNet, const wns::pyconfig::View& config); 00097 00098 virtual 00099 ~StopAndWaitRC(); 00100 00101 // SDU and PCI size calculation 00102 void 00103 calculateSizes(const CommandPool* commandPool, Bit& commandPoolSize, Bit& dataSize) const; 00104 00105 template <typename PORTID> 00106 void 00107 doWakeup(PORTID); 00108 00109 template <typename PORTID> 00110 void 00111 doOnData(const CompoundPtr& compound, PORTID); 00112 00113 virtual bool 00114 doIsAccepting(const CompoundPtr& compound) const; 00115 00116 virtual void 00117 doSendData(const CompoundPtr& compound); 00118 00119 private: 00120 StopAndWaitRC(); 00121 00122 // CanTimeout interface realisation 00123 virtual void 00124 onTimeout(); 00125 00129 double resendTimeout; 00130 00134 int bitsPerIFrame; 00135 00139 int bitsPerRRFrame; 00140 00144 ARQCommand::SequenceNumber NS; 00145 00149 ARQCommand::SequenceNumber NR; 00150 00157 CompoundPtr activeCompound; 00158 00162 CompoundPtr ackCompound; 00163 00167 bool sendNowData; 00168 00169 00170 logger::Logger logger; 00171 }; 00172 00173 /* template <> 00174 void 00175 StopAndWaitRC::doWakeup(Port<Data>); 00176 00177 template <> 00178 void 00179 StopAndWaitRC::doWakeup(Port<Ack>); 00180 00181 template <> 00182 void 00183 StopAndWaitRC::doOnData(const CompoundPtr& compound, Port<Data>); 00184 00185 template <> 00186 void 00187 StopAndWaitRC::doOnData(const CompoundPtr& compound, Port<Ack>);*/ 00188 00189 } //arq 00190 } //ldk 00191 } //wns 00192 00193 #endif // NOT defined WNS_LDK_ARQ_STOPANDWAITRC_HPP 00194
1.5.5