User Manual, Developers Guide and API Documentation

SegAndConcat.hpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  * WinProSt Protocol Stack)                                                   *
00003  * __________________________________________________________________________ *
00004  *                                                                            *
00005  * Copyright (C) 2004                                                         *
00006  * Lehrstuhl f?r Kommunikationsnetze (ComNets)                                *
00007  * Kopernikusstr. 16, D-52074 Aachen, Germany                                 *
00008  * phone: ++49-241-80-27910 (phone), fax: ++49-241-80-22242                   *
00009  * email: msg@comnets.de, www: http://winner.comnets.rwth-aachen.de/~msg      *
00010  ******************************************************************************/
00011 
00012 #ifndef WNS_LDK_SAR_SEGANDCONCAT_HPP
00013 #define WNS_LDK_SAR_SEGANDCONCAT_HPP
00014 
00015 #include <WNS/ldk/sar/reassembly/ReorderingWindow.hpp>
00016 #include <WNS/ldk/sar/reassembly/ReassemblyBuffer.hpp>
00017 
00018 #include <WNS/scheduler/queue/ISegmentationCommand.hpp>
00019 #include <WNS/ldk/Delayed.hpp>
00020 #include <WNS/ldk/CommandTypeSpecifier.hpp>
00021 #include <WNS/ldk/HasReceptor.hpp>
00022 #include <WNS/ldk/HasConnector.hpp>
00023 #include <WNS/ldk/HasDeliverer.hpp>
00024 #include <WNS/logger/Logger.hpp>
00025 #include <WNS/probe/bus/ContextCollector.hpp>
00026 
00027 namespace wns { namespace ldk { namespace sar { 
00028 
00029     class SegAndConcatCommand:
00030         public wns::scheduler::queue::ISegmentationCommand
00031     {
00032     public:
00033         SegAndConcatCommand()
00034         {
00035             peer.isBegin_ = false;
00036             peer.isEnd_ = false;
00037             peer.sn_ = 0;
00038             peer.headerSize_ = 0;
00039             peer.dataSize_ = 0;
00040             peer.paddingSize_ = 0;
00041             peer.sdus_ = 0;
00042         }
00043 
00048         virtual void
00049         setBeginFlag() { peer.isBegin_ = true; }
00050 
00051         virtual bool
00052         getBeginFlag() { return peer.isBegin_; }
00053 
00054         virtual void
00055         clearBeginFlag() { peer.isBegin_ = false; }
00056 
00061         virtual void
00062         setEndFlag() { peer.isEnd_ = true; }
00063 
00064         virtual bool
00065         getEndFlag() { return peer.isEnd_; }
00066 
00067         virtual void
00068         clearEndFlag() { peer.isEnd_ = false; }
00069 
00073         virtual void
00074         setSequenceNumber(long sn) { peer.sn_ = sn;}
00075 
00079         virtual long
00080         getSequenceNumber() { return peer.sn_; }
00081 
00082         virtual void
00083         increaseHeaderSize(Bit size) { peer.headerSize_ += size; }
00084 
00085         virtual void
00086         increaseDataSize(Bit size) { peer.dataSize_ += size; }
00087 
00088         virtual void
00089         increasePaddingSize(Bit size) { peer.paddingSize_ += size; }
00090 
00091         virtual Bit
00092         headerSize() { return peer.headerSize_; }
00093 
00094         virtual Bit
00095         dataSize() { return peer.dataSize_; }
00096 
00097         virtual Bit
00098         paddingSize() { return peer.paddingSize_; }
00099 
00100         virtual Bit
00101         totalSize() { return peer.headerSize_ + peer.dataSize_ + peer.paddingSize_; }
00102 
00106         virtual void
00107         addSDU(wns::ldk::CompoundPtr c) { peer.pdus_.push_back(c); peer.sdus_++;}
00108 
00109         virtual unsigned int
00110         getNumSDUs() {return peer.sdus_;}
00111 
00112         struct {
00113         } magic;
00114 
00115         struct {} local;
00116 
00117         struct peer
00118         {
00119             bool isBegin_;
00120             bool isEnd_;
00121             long sn_;
00122             Bit headerSize_;
00123             Bit dataSize_;
00124             Bit paddingSize_;
00125             unsigned int sdus_;
00126             std::list<wns::ldk::CompoundPtr> pdus_;
00127         } peer;
00128     };
00129 
00130     class SegAndConcat:
00131         virtual public wns::ldk::FunctionalUnit,
00132         virtual public wns::ldk::Delayed<SegAndConcat>,
00133         public wns::ldk::HasReceptor<>,
00134         public wns::ldk::HasConnector<>,
00135         public wns::ldk::HasDeliverer<>,
00136         public wns::Cloneable<SegAndConcat>,
00137         public wns::ldk::CommandTypeSpecifier<SegAndConcatCommand>
00138     {
00139     public:
00140         SegAndConcat(wns::ldk::fun::FUN* fuNet, const wns::pyconfig::View& config);
00141 
00142         SegAndConcat(const SegAndConcat&);
00143 
00144         virtual
00145         ~SegAndConcat();
00146 
00147         virtual void
00148         onFUNCreated();
00149 
00150         virtual void
00151         processIncoming(const wns::ldk::CompoundPtr& compound);
00152 
00153         virtual void
00154         processOutgoing(const wns::ldk::CompoundPtr&);
00155 
00156         virtual bool
00157         hasCapacity() const;
00158 
00159         virtual const wns::ldk::CompoundPtr
00160         hasSomethingToSend() const;
00161 
00162         virtual wns::ldk::CompoundPtr
00163         getSomethingToSend();
00164 
00165         virtual void
00166         calculateSizes(const wns::ldk::CommandPool* commandPool, Bit& commandPoolSize, Bit& dataSize) const;
00167 
00168     protected:
00169 
00170     wns::ldk::CommandReaderInterface*
00171     getCommandReader() const;
00172 
00173         wns::logger::Logger logger_;
00174         bool isSegmenting_;
00175 
00176     private:
00177 
00178         void
00179         onReorderedPDU(long, wns::ldk::CompoundPtr);
00180 
00181         void
00182         onDiscardedPDU(long, wns::ldk::CompoundPtr);
00183 
00184         std::list<wns::ldk::CompoundPtr> senderPendingSegments_;
00185 
00186         std::string commandName_;
00187 
00188         Bit headerSize_;
00189 
00190         Bit segmentSize_;
00191 
00192         Bit sduLengthAddition_;
00193 
00194         long nextOutgoingSN_;
00195 
00196         reassembly::ReassemblyBuffer reassemblyBuffer_;
00197 
00198         reassembly::ReorderingWindow reorderingWindow_;
00199 
00200         wns::probe::bus::ContextCollectorPtr minDelayCC_;
00201         wns::probe::bus::ContextCollectorPtr maxDelayCC_;
00202         wns::probe::bus::ContextCollectorPtr sizeCC_;
00203         wns::ldk::CommandReaderInterface* probeHeaderReader_;
00204 
00205         wns::probe::bus::ContextCollectorPtr segmentDropRatioCC_;
00206         std::string segmentDropRatioProbeName_;
00207     };
00208 }
00209 }
00210 }
00211 
00212 #endif // WNS_LDK_SAR_SEGANDCONCAT_HPP

Generated on Fri May 25 03:31:46 2012 for openWNS by  doxygen 1.5.5