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_STOPANDWAIT_FSMFU_HPP
00014 #define GLUE_ARQFSM_STOPANDWAIT_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/SuspendableInterface.hpp>
00023 #include <WNS/ldk/SuspendSupport.hpp>
00024 
00025 #include <WNS/events/CanTimeout.hpp>
00026 #include <WNS/Cloneable.hpp>
00027 #include <WNS/pyconfig/View.hpp>
00028 #include <WNS/module/Base.hpp>
00029 
00030 namespace glue { namespace arqfsm { namespace stopandwait {
00031 
00036     class StopAndWaitCommand :
00037         public wns::ldk::Command
00038     {
00039     public:
00040         typedef enum {I, ACK} FrameType;
00041 
00042         StopAndWaitCommand()
00043         {
00044             peer.type = I;
00045             peer.NS = 0;
00046         }
00047 
00048         /*
00049          * I - Information Frame
00050          * ACK - Receiver Ready (ACK)
00051          */
00052         struct {} local;
00053         struct {
00054             FrameType type;
00055             int NS;
00056         } peer;
00057         struct {} magic;
00058     };
00059 
00060 
00064     class Variables
00065     {
00066     public:
00067         Variables(const wns::pyconfig::View& config) :
00068             resendTimeout(config.get<double>("resendTimeout")),
00069             modulo(2),
00070             NS(0),
00071             NR(0),
00072             activeCompound(wns::ldk::CompoundPtr()),
00073             ackCompound(wns::ldk::CompoundPtr()),
00074             sendNow(false),
00075             logger("GLUE", "StopAndWait")
00076         {
00077             assure(modulo >= 2, "Invalid modulo.");
00078         }
00079 
00084         double resendTimeout;
00085 
00090         const int modulo;
00091 
00096         int NS;
00097 
00102         int NR;
00103 
00108         wns::ldk::CompoundPtr activeCompound;
00109 
00114         wns::ldk::CompoundPtr ackCompound;
00115 
00120         bool sendNow;
00121 
00122         wns::logger::Logger logger;
00123     };
00124 
00125     typedef wns::ldk::fsm::FunctionalUnit<Variables> MyFUInterface;
00126 
00127     typedef MyFUInterface::BaseFSM::StateInterface StateInterface;
00128 
00129     class FSMFU :
00130         public MyFUInterface,
00131         public wns::ldk::CommandTypeSpecifier<StopAndWaitCommand>,
00132         public wns::ldk::HasReceptor<>,
00133         public wns::ldk::HasConnector<>,
00134         public wns::ldk::HasDeliverer<>,
00135         virtual public wns::ldk::SuspendableInterface,
00136         public wns::ldk::SuspendSupport,
00137         public wns::Cloneable<FSMFU>,
00138         public wns::events::CanTimeout
00139     {
00140     public:
00141         FSMFU(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& _config);
00142 
00143         virtual
00144         ~FSMFU()
00145         {}
00146 
00147         // SDU and PCI size calculation
00148         void
00149         calculateSizes(const wns::ldk::CommandPool* commandPool, Bit& commandPoolSize, Bit& dataSize) const;
00150 
00151         virtual bool
00152         onSuspend() const;
00153 
00154     private:
00155         virtual void
00156         onTimeout();
00157 
00158         wns::pyconfig::View config;
00159 
00164         int bitsPerIFrame;
00165 
00170         int bitsPerRRFrame;
00171     };
00172 
00173 } // stopandwait
00174 } // arqfsm
00175 } // glue
00176 
00177 #endif // GLUE_ARQFSM_STOPANDWAIT_FSMFU_HPP
00178 
00179 

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