User Manual, Developers Guide and API Documentation

CumulativeACK.hpp

Go to the documentation of this file.
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. 16, 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 TCP_CUMULATIVEACK_HPP
00029 #define TCP_CUMULATIVEACK_HPP
00030 
00031 
00032 #include <WNS/ldk/CommandTypeSpecifier.hpp>
00033 #include <WNS/ldk/HasConnector.hpp>
00034 #include <WNS/ldk/HasReceptor.hpp>
00035 #include <WNS/ldk/HasDeliverer.hpp>
00036 #include <WNS/ldk/FunctionalUnit.hpp>
00037 
00038 #include <WNS/probe/bus/ContextCollector.hpp>
00039 
00040 #include <WNS/events/CanTimeout.hpp>
00041 
00042 #include <WNS/container/Registry.hpp>
00043 
00044 #include <WNS/logger/Logger.hpp>
00045 #include <WNS/pyconfig/View.hpp>
00046 
00047 #include <TCP/CongestionControl.hpp>
00048 
00049 namespace tcp {
00050 
00051     namespace tests {  
00052         class CumulativeACKTest;
00053     } // namespace tests
00054 
00055     class CongestionControl;
00056 
00057     class CumulativeACKCommand : 
00058         public wns::ldk::Command
00059     {
00060     public:
00061         CumulativeACKCommand()
00062         {
00063             peer.type = I;
00064 
00065             peer.advertisedWindowSize = 0;
00066             peer.sequenceNumber = 0;
00067             peer.ACKNumber = 0;
00068         }
00069 
00070         typedef enum {I, ACK} FrameType; //todo: add PiggyBack
00071 
00072         struct {} local;
00073 
00074         struct {
00079             FrameType type;
00080 
00084             unsigned long int advertisedWindowSize;
00085 
00089             unsigned long int sequenceNumber;
00090 
00097             unsigned long int ACKNumber;
00098         } peer;
00099 
00100         struct {} magic;
00101     };
00102 
00103     class CumulativeACK :
00104         public virtual wns::ldk::FunctionalUnit,
00105         public wns::ldk::CommandTypeSpecifier<CumulativeACKCommand>,
00106         public wns::ldk::HasReceptor<>,
00107         public wns::ldk::HasConnector<>,
00108         public wns::ldk::HasDeliverer<>,
00109         public wns::Cloneable<CumulativeACK>
00110     {
00111     private:
00115         class Timeout :
00116             public wns::events::CanTimeout
00117         {
00118         public:
00119             Timeout();
00120             Timeout(CumulativeACK* _parent, unsigned long int seqNr, simTimeType timer):
00121                 CanTimeout(),
00122                 sequenceNumber(seqNr),
00123                 parent(_parent),
00124                 logger("TCP", "CumulativeACK")
00125             {
00126                 assure(_parent, "Invalid CumulativeACK instance.");
00127                 this->setTimeout(timer);
00128             };
00129 
00130             virtual ~Timeout()
00131             {
00132                 parent = NULL;
00133             }
00134 
00135             void onTimeout()
00136             {
00137                 parent->ccStrategy->onSegmentLoss(CongestionControl::TIMEOUT, sequenceNumber);
00138 
00139                 MESSAGE_BEGIN(NORMAL, logger, m, parent->getFUN()->getName());
00140                 m << "\tTimeout of compund SequenceNr: " << sequenceNumber;
00141                 MESSAGE_END();
00142                 parent->ccStrategy->clearDuplicateACKCounter();
00143 
00144                 parent->retransmitData(sequenceNumber);
00145             }
00146 
00147         private:
00148             unsigned long int sequenceNumber;
00149 
00150             CumulativeACK* parent;
00151 
00152             wns::logger::Logger logger;
00153         };
00154 
00158         typedef wns::container::Registry<unsigned long int, Timeout*, wns::container::registry::DeleteOnErase> Timeouts;
00159 
00163         typedef wns::container::Registry<unsigned long int, wns::ldk::CompoundPtr, wns::container::registry::NoneOnErase> Compounds;
00164 
00165 
00166     public:
00167         CumulativeACK(wns::ldk::fun::FUN* _fun, const wns::pyconfig::View& _pyco);
00168 
00172         virtual
00173         ~CumulativeACK();
00174 
00178         virtual bool
00179         doIsAccepting(const wns::ldk::CompoundPtr& _compound) const;
00180 
00181         virtual void
00182         onFUNCreated();
00183 
00184         virtual void
00185         doOnData(const wns::ldk::CompoundPtr& _compound);
00186 
00187         virtual void
00188         doSendData(const wns::ldk::CompoundPtr& _compound);
00189 
00194         unsigned long int
00195         sendCredit() const;
00196 
00197         simTimeType
00198         getRetransmissionTimeout() { return ccStrategy->getRetransmissionTimeout();}
00199 
00200     private:
00201         void
00202         doWakeup();
00203 
00204         void
00205         retransmitData(const unsigned long int seqNr);
00206 
00207         unsigned long int
00208         min(const unsigned long int x, const unsigned long int y) const;
00209 
00210         void
00211         updateTCPHeader(const wns::ldk::CompoundPtr& _compound);
00212         
00213         const wns::pyconfig::View& pyco;
00214 
00215         wns::logger::Logger logger;
00216 
00217         wns::ldk::fun::FUN* fun;
00218 
00224         CongestionControl* ccStrategy;
00225 
00230         unsigned long int advertisedWindowSize;
00231 
00235         unsigned long int sequenceNR;
00236 
00240         unsigned long int ackNR;
00241 
00245         unsigned long int lastACKInOrder;
00246 
00250         simTimeType retransmissionTimeout;
00251 
00255         Compounds receivingCompounds;
00256         
00260         Compounds sendingCompounds;
00261 
00265         Timeouts timeoutSendingCompounds;
00266 
00271         wns::ldk::CompoundPtr ackCompound;
00272         wns::ldk::CompoundPtr copiedACKCompound;
00273 
00277         wns::ldk::CommandReaderInterface* tcpHeaderReader;
00278         
00279         unsigned long int probeNumber;
00280 
00281         unsigned long int instanceID;
00282 
00283         bool probingEnabled;
00284 
00285         wns::probe::bus::ContextCollectorPtr windowSizeContextCollector;
00286         wns::probe::bus::ContextCollectorPtr sendCreditContextCollector;
00287     };
00288 } // namespace tcp
00289 
00290 #endif // NOT defined TCP_CUMULATIVEACK_HPP
00291 

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