User Manual, Developers Guide and API Documentation

RRHandler.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. 5, 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 LTE_CONTROLPLANE_RRHANDLER
00029 #define LTE_CONTROLPLANE_RRHANDLER
00030 
00031 #include <LTE/timing/TimingScheduler.hpp>
00032 #include <LTE/helper/HasModeName.hpp>
00033 #include <LTE/helper/SwitchConnector.hpp>
00034 #include <LTE/controlplane/MapHandlerInterface.hpp>
00035 
00036 #include <DLL/services/control/Association.hpp>
00037 
00038 #include <WNS/ldk/CommandTypeSpecifier.hpp>
00039 #include <WNS/ldk/HasReceptor.hpp>
00040 #include <WNS/ldk/HasConnector.hpp>
00041 #include <WNS/ldk/HasDeliverer.hpp>
00042 #include <WNS/ldk/Compound.hpp>
00043 #include <WNS/ldk/Command.hpp>
00044 #include <WNS/ldk/IConnectorReceptacle.hpp>
00045 #include <WNS/Cloneable.hpp>
00046 #include <WNS/logger/Logger.hpp>
00047 #include <WNS/service/dll/Address.hpp>
00048 #include <WNS/Observer.hpp>
00049 #include <WNS/scheduler/SchedulerTypes.hpp>
00050 #include <WNS/scheduler/RegistryProxyInterface.hpp>
00051 #include <WNS/service/dll/FlowID.hpp>
00052 
00053 namespace lte {
00054     namespace timing {
00055         class ResourceSchedulerInterface;
00056         class ResourceSchedulerUT;
00057         class ResourceSchedulerBS;
00058         class RegistryProxy;
00059     }
00060     namespace macg {
00061         class MACg;
00062     }
00063     namespace rlc {
00064         class RLC;
00065     }
00066 
00067     namespace controlplane {
00068         namespace flowmanagement {
00069             class FlowManager;
00070         }
00071         namespace tests {
00072             class RRHandlerTests;
00073         }
00074         class RRHandlerUT;
00075 
00076         typedef std::map<wns::scheduler::UserID, double> ResourceShares;
00077 
00078         struct ResourceRequest {
00079             ResourceRequest() :
00080                 user(NULL),
00081                 allRequestedResources()
00082             {}
00083             wns::scheduler::UserID user;
00084             // QueueStatusContainer is a Registry, the key is the ConnectionID=FlowID
00085             wns::scheduler::QueueStatusContainer allRequestedResources;
00086         };
00087 
00088         class RequestStorageInterface
00089         {
00090             friend class lte::controlplane::tests::RRHandlerTests;
00091         public:
00092             virtual
00093             ~RequestStorageInterface(){};
00094 
00095             virtual void
00096             storeRequest(const wns::scheduler::UserID user, wns::scheduler::QueueStatusContainer& partialQueueStatusContainer) = 0;
00097             //virtual void
00098             //storeRequest(ResourceRequest&) = 0;
00099 
00100             virtual ResourceShares
00101             getResourceShares(const wns::scheduler::UserSet&) const = 0;
00102 
00103             virtual wns::scheduler::UserSet
00104             getActiveUsers() const = 0;
00105 
00106             virtual wns::scheduler::ConnectionSet
00107             getActiveConnections() const = 0;
00108 
00109             virtual wns::scheduler::ConnectionSet
00110             filterActiveConnections(wns::scheduler::ConnectionSet& inputConnectionSet) const = 0;
00111 
00112             virtual bool
00113             knowsFlow(wns::scheduler::ConnectionID flowId) const = 0;
00114 
00115             virtual void
00116             resetFlow(const wns::scheduler::ConnectionID flowId) = 0;
00117 
00118             virtual void
00119             resetUser(const wns::scheduler::UserID) = 0;
00120 
00121             virtual void
00122             reset(const wns::scheduler::UserSet&) = 0;
00123 
00124             virtual bool
00125             isEmpty() const = 0;
00126 
00127             virtual uint32_t
00128             numBitsForCid(wns::scheduler::ConnectionID cid) const = 0;
00129             virtual uint32_t
00130             numCompoundsForCid(wns::scheduler::ConnectionID cid) const = 0;
00131             virtual wns::scheduler::Bits
00132             decrementRequest(wns::scheduler::ConnectionID cid, wns::scheduler::Bits bits) = 0;
00133 
00134             virtual wns::scheduler::QueueStatusContainer
00135             getQueueStatus() const = 0;
00136             virtual std::string
00137             printQueueStatus() const = 0;
00138         }; // class RequestStorageInterface
00139 
00140         class RequestStorage :
00141                 public virtual RequestStorageInterface
00142         {
00143             friend class lte::controlplane::tests::RRHandlerTests;
00144             //typedef std::list<ResourceRequest> RequestList;
00146             //RequestList receivedRequests;
00148             typedef wns::container::Registry<wns::scheduler::ConnectionID, wns::scheduler::UserID> ConnectionUserMapping;
00149             ConnectionUserMapping connectionUserMapping;
00151             wns::scheduler::QueueStatusContainer queueStatusContainer;
00153             wns::scheduler::UserSet activeULUsers;
00155             wns::logger::Logger logger;
00156 
00157         public:
00158             RequestStorage(wns::logger::Logger& _logger);
00159 
00160             virtual
00161             ~RequestStorage();
00162 
00163             virtual void
00164             storeRequest(const wns::scheduler::UserID user, wns::scheduler::QueueStatusContainer& partialQueueStatusContainer);
00165 
00166             //virtual void
00167             //storeRequest(ResourceRequest&);
00168 
00169             virtual ResourceShares
00170             getResourceShares(const wns::scheduler::UserSet&) const;
00171 
00172             virtual wns::scheduler::UserSet
00173             getActiveUsers() const;
00174 
00175             virtual wns::scheduler::ConnectionSet
00176             getActiveConnections() const;
00177 
00178             virtual wns::scheduler::ConnectionSet
00179             filterActiveConnections(wns::scheduler::ConnectionSet& inputConnectionSet) const;
00180 
00181             virtual bool
00182             knowsFlow(wns::scheduler::ConnectionID flowId) const;
00183 
00184             virtual void
00185             resetFlow(const wns::scheduler::ConnectionID flowId);
00186 
00187             virtual void
00188             resetUser(const wns::scheduler::UserID);
00189 
00190             virtual void
00191             deleteUser(const wns::scheduler::UserID);
00192 
00193             virtual void
00194             reset(const wns::scheduler::UserSet&);
00195 
00196             virtual bool
00197             isEmpty() const;
00198 
00199             virtual uint32_t
00200             numBitsForCid(wns::scheduler::ConnectionID cid) const;
00201             virtual uint32_t
00202             numCompoundsForCid(wns::scheduler::ConnectionID cid) const;
00203             virtual wns::scheduler::Bits
00204             decrementRequest(wns::scheduler::ConnectionID cid, wns::scheduler::Bits bits);
00205 
00206             virtual wns::scheduler::QueueStatusContainer
00207             getQueueStatus() const;
00208             virtual std::string
00209             printQueueStatus() const;
00210         }; // class RequestStorage
00211 
00213         class RRCommand :
00214                 public wns::ldk::Command
00215         {
00216         public:
00217             RRCommand()
00218             {
00219                 peer.request = ResourceRequest();
00220             };
00221             struct {
00222             } local;
00223             struct {
00224                 ResourceRequest request;
00225             } peer;
00226             struct {
00227                 wns::service::dll::UnicastAddress source;
00228             } magic;
00229         };
00230 
00232         class RRHandler :
00233                 public virtual wns::ldk::FunctionalUnit,
00234                 //public lte::controlplane::associationHandler::AssociationObserver,
00235                 public wns::ldk::CommandTypeSpecifier<RRCommand>,
00236                 public wns::ldk::HasReceptor<>,
00237                 public wns::ldk::HasConnector<lte::helper::SwitchConnector>,
00238                 public wns::ldk::HasDeliverer<>,
00239                 public lte::helper::HasModeName
00240         {
00241             friend class lte::controlplane::tests::RRHandlerTests;
00242         public:
00244             RRHandler(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config);
00246             virtual ~RRHandler();
00247 
00250             virtual void
00251             doSendData(const wns::ldk::CompoundPtr&);
00253 
00254             //** @name AssociationObserverInterface */
00256             //virtual void
00257             //onDisassociation(wns::service::dll::UnicastAddress userAdr, wns::service::dll::UnicastAddress dstAdr);
00258             //virtual void
00259             //onAssociationChanged(wns::service::dll::UnicastAddress userAdr, wns::service::dll::UnicastAddress dstAdr);
00261 
00264             virtual void
00265             onFUNCreated();
00266 
00267             virtual void
00268             setColleagues(wns::scheduler::RegistryProxyInterface* registry);
00269 
00271             virtual void
00272             calculateSizes(const wns::ldk::CommandPool* commandPool,
00273                            Bit& commandPoolSize,
00274                            Bit& dataSize) const;
00275 
00277             virtual int
00278             getTotalNumberOfUsers(const wns::scheduler::UserID user) const;
00279 
00280         protected:
00281             virtual void
00282             doWakeup();
00283 
00284             virtual bool
00285             doIsAccepting(const wns::ldk::CompoundPtr& /* compound */) const;
00286 
00290             struct Friends {
00291                 Friends() {macg=NULL;rachDispatcher=NULL;cpDispatcher=NULL;flowManager=NULL;registry=NULL;};
00292                 lte::macg::MACg* macg;
00293                 wns::ldk::IConnectorReceptacle* rachDispatcher;
00294                 wns::ldk::IConnectorReceptacle* cpDispatcher;
00295                 lte::controlplane::flowmanagement::FlowManager* flowManager;
00296                 wns::scheduler::RegistryProxyInterface* registry; // RegistryProxy of RS-RX (uplink master)
00297             } friends;
00298 
00299         wns::ldk::CommandReaderInterface* rlcReader;
00302             lte::helper::SwitchConnector* connector;
00303 
00306             dll::services::control::Association* associationService;
00307 
00309             Bit commandSize;
00310 
00312             Bit pcchSize;
00313 
00315             wns::logger::Logger logger;
00316 
00318             dll::ILayer2* layer2;
00319 
00320             wns::pyconfig::View pyco;
00321 
00322             bool usesShortcut;
00323         };
00324 
00325         class RRHandlerBS :
00326                 public RRHandler,
00327                 public wns::Cloneable<RRHandlerBS>,
00328                 public dll::services::control::AssociationObserver,
00329                 public wns::Observer<lte::timing::SuperFrameStartNotificationInterface>
00330         {
00332             bool firstWakeup;
00333 
00338             RequestStorageInterface* rrStorage;
00339             RRHandlerUT* rnUplinkRRHandler;
00340             lte::timing::ResourceSchedulerBS* rsrx;
00343             uint32_t ulSegmentSize;
00344         public:
00345             RRHandlerBS(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config);
00346 
00347             virtual
00348             ~RRHandlerBS();
00349 
00350             virtual void
00351             onFUNCreated();
00352 
00353             virtual int
00354             getDefaultBitsPerPDU();
00355 
00356             virtual wns::ldk::CompoundPtr
00357             createFakePDU(wns::service::dll::UnicastAddress destinationAddress, wns::scheduler::Bits bits, wns::service::dll::FlowID flowID);
00358 
00361             void
00362             fakeRelayRRs() const;
00363 
00364             virtual void
00365             doWakeup();
00366 
00368             virtual void
00369             onSuperFrameStart();
00370 
00371             virtual void
00372             doOnData(const wns::ldk::CompoundPtr&);
00373 
00374             virtual ResourceShares
00375             getResourceShares(const wns::scheduler::UserSet&) const;
00376 
00377             virtual wns::scheduler::UserSet
00378             getActiveUsers() const;
00379 
00380             virtual RequestStorageInterface*
00381             getRRStorage();
00382 
00383             virtual void
00384             onAssociated(wns::service::dll::UnicastAddress userAdr,
00385                          wns::service::dll::UnicastAddress dstAdr);
00386 
00387             virtual void
00388             onDisassociated(wns::service::dll::UnicastAddress userAdr,
00389                             wns::service::dll::UnicastAddress dstAdr);
00390 
00391         protected: // only used by unitTest:
00392             virtual void
00393             reset(const wns::scheduler::UserSet& users);
00394 
00395         };
00396 
00397         class RRHandlerUT :
00398                 public RRHandler,
00399                 public wns::Cloneable<RRHandlerUT>,
00400                 public wns::Observer<lte::controlplane::ResourceGrantNotificationInterface>
00401         {
00405             bool resourceGrantState;
00406 
00409             lte::timing::ResourceSchedulerUT* rstx;
00410 
00412             wns::scheduler::QueueStatusContainer allRelayedRequestedResources;
00413 
00415             wns::service::dll::FlowID pcchFlowID;
00416 
00417         public:
00418             RRHandlerUT(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config) :
00419                 RRHandler(fun, config),
00420                 wns::Cloneable<RRHandlerUT>(),
00421                 resourceGrantState(false),
00422                 rstx(NULL),
00423                 allRelayedRequestedResources(),
00424                 pcchFlowID(0)
00425             {}
00426 
00427             virtual
00428             ~RRHandlerUT();
00429 
00430             virtual void
00431             onFUNCreated();
00432 
00434             void
00435             createRRCompound();
00436 
00439             virtual void
00440             resourcesGranted(bool state);
00441 
00442             bool
00443             hasResourcesGranted() const { return resourceGrantState; }
00444 
00445             virtual void
00446             doOnData(const wns::ldk::CompoundPtr&);
00447         };
00448     }}
00449 
00450 #endif

Generated on Fri May 25 03:32:05 2012 for openWNS by  doxygen 1.5.5