User Manual, Developers Guide and API Documentation

FSMFU.hpp

Go to the documentation of this file.
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 GLUE_ARQFSM_SELECTIVEREPEAT_FSMFU_HPP
00014 #define GLUE_ARQFSM_SELECTIVEREPEAT_FSMFU_HPP
00015 
00016 #include <WNS/ldk/fsm/FunctionalUnit.hpp>
00017 #include <WNS/ldk/CommandTypeSpecifier.hpp>
00018 #include <WNS/ldk/HasReceptor.hpp>
00019 #include <WNS/ldk/HasConnector.hpp>
00020 #include <WNS/ldk/HasDeliverer.hpp>
00021 #include <WNS/ldk/fun/Main.hpp>
00022 #include <WNS/ldk/Compound.hpp>
00023 #include <WNS/ldk/SuspendableInterface.hpp>
00024 #include <WNS/ldk/SuspendSupport.hpp>
00025 #include <WNS/ldk/DelayedDeliveryInterface.hpp>
00026 
00027 #include <WNS/events/MultipleTimeout.hpp>
00028 #include <WNS/Cloneable.hpp>
00029 #include <WNS/pyconfig/View.hpp>
00030 #include <WNS/module/Base.hpp>
00031 
00032 #include <vector>
00033 #include <queue>
00034 
00035 namespace glue { namespace arqfsm { namespace selectiverepeat {
00036 
00041     class SelectiveRepeatCommand :
00042         public wns::ldk::Command
00043     {
00044     public:
00045         typedef enum {I, ACK} FrameType;
00046 
00047         SelectiveRepeatCommand()
00048         {
00049             peer.type = I;
00050             peer.NS = 0;
00051         } // SelectiveRepeatCommand
00052 
00053         /*
00054          * I - Information Frame
00055          * ACK - received Packet (ACK)
00056          */
00057         struct {} local;
00058         struct {
00059             FrameType type;
00060             int NS;
00061         } peer;
00062         struct {} magic;
00063     };
00064 
00065 
00069     class Variables
00070     {
00071     public:
00072         typedef std::list<wns::ldk::CompoundPtr> CompoundQueue;
00073         typedef std::vector<wns::ldk::CompoundPtr> CompoundContainer;
00074 
00075         Variables(const wns::pyconfig::View& config) :
00076             windowSize(config.get<int>("windowSize")),
00077             sequenceNumberSize(config.get<int>("sequenceNumberSize")),
00078             resendTimeout(config.get<double>("resendTimeout")),
00079             NS(0),
00080             lowerBoundNS(0),
00081             levelSendBuffer(0),
00082             leastNR(0),
00083             sentCompounds(),
00084             pendingCompoundsQueue(),
00085             receivedCompounds(),
00086             pendingACKsQueue(),
00087             delayingDelivery(false),
00088             logger(config.get<wns::pyconfig::View>("logger"))
00089         {
00094             if (sequenceNumberSize < 2*windowSize)
00095                 throw wns::Exception("SequenceNumberSize is to small for chosen windowSize.");
00096 
00097             sentCompounds.resize(sequenceNumberSize);
00098             receivedCompounds.resize(sequenceNumberSize);
00099         } // Variables
00100 
00101         virtual
00102         ~Variables()
00103         {} // ~Variables
00104 
00108         int windowSize;
00109 
00113         int sequenceNumberSize;
00114 
00118         double resendTimeout;
00119 
00123         int NS;
00124 
00129         int lowerBoundNS;
00130 
00134         int levelSendBuffer;
00135 
00140         int leastNR;
00141 
00145         CompoundContainer sentCompounds;
00146 
00150         CompoundQueue pendingCompoundsQueue;
00151 
00156         CompoundContainer receivedCompounds;
00157 
00161         CompoundQueue pendingACKsQueue;
00162 
00163         bool delayingDelivery;
00164 
00168         wns::logger::Logger logger;
00169     };
00170 
00171     typedef wns::ldk::fsm::FunctionalUnit<Variables> MyFUInterface;
00172 
00173     typedef MyFUInterface::BaseFSM::StateInterface StateInterface;
00174 
00175     class FSMFU :
00176         public MyFUInterface,
00177         public wns::ldk::CommandTypeSpecifier<SelectiveRepeatCommand>,
00178         public wns::ldk::HasReceptor<>,
00179         public wns::ldk::HasConnector<>,
00180         public wns::ldk::HasDeliverer<>,
00181         virtual public wns::ldk::SuspendableInterface,
00182         public wns::ldk::SuspendSupport,
00183         virtual public wns::ldk::DelayedDeliveryInterface,
00184         public wns::Cloneable<FSMFU>,
00185         public wns::events::MultipleTimeout<wns::ldk::CompoundPtr>
00186     {
00187     public:
00188         FSMFU(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& _config);
00189 
00190         virtual
00191         ~FSMFU()
00192         {} // ~FSMFU
00193 
00194         // SDU and PCI size calculation
00195         virtual void
00196         calculateSizes(const wns::ldk::CommandPool* commandPool, Bit& commandPoolSize, Bit& dataSize) const;
00197 
00198         virtual bool
00199         onSuspend() const;
00200 
00201     private:
00202         virtual void
00203         onTimeout(const wns::ldk::CompoundPtr& compound);
00204 
00205         virtual void
00206         doDelayDelivery();
00207 
00208         virtual void
00209         doDeliver();
00210 
00211         wns::pyconfig::View config;
00212 
00216         int bitsPerIFrame;
00217 
00221         int bitsPerACKFrame;
00222     };
00223 
00224 } // selectiverepeat
00225 } // arqfsm
00226 } // glue
00227 
00228 #endif // GLUE_ARQFSM_SELECTIVEREPEAT_FSMFU_HPP
00229 
00230 

Generated on Sun May 27 03:31:58 2012 for openWNS by  doxygen 1.5.5