User Manual, Developers Guide and API Documentation

VirtualPathSelection.hpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  * WiFiMac                                                                    *
00003  * This file is part of openWNS (open Wireless Network Simulator)
00004  * _____________________________________________________________________________
00005  *
00006  * Copyright (C) 2004-2007
00007  * Chair of Communication Networks (ComNets)
00008  * Kopernikusstr. 16, D-52074 Aachen, Germany
00009  * phone: ++49-241-80-27910,
00010  * fax: ++49-241-80-22242
00011  * email: info@openwns.org
00012  * www: http://www.openwns.org
00013  * _____________________________________________________________________________
00014  *
00015  * openWNS is free software; you can redistribute it and/or modify it under the
00016  * terms of the GNU Lesser General Public License version 2 as published by the
00017  * Free Software Foundation;
00018  *
00019  * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
00020  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00021  * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00022  * details.
00023  *
00024  * You should have received a copy of the GNU Lesser General Public License
00025  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00026  *
00027  ******************************************************************************/
00028 
00029 #ifndef WIFIMAC_PATHSELECTION_VIRTUALPATHSELECTION_HPP
00030 #define WIFIMAC_PATHSELECTION_VIRTUALPATHSELECTION_HPP
00031 
00032 #include <WIFIMAC/pathselection/IPathSelection.hpp>
00033 #include <WIFIMAC/pathselection/Metric.hpp>
00034 
00035 #include <DLL/UpperConvergence.hpp>
00036 
00037 #include <WNS/node/component/Component.hpp>
00038 #include <WNS/container/Registry.hpp>
00039 #include <WNS/ldk/fun/Main.hpp>
00040 #include <WNS/ldk/Layer.hpp>
00041 #include <WNS/logger/Logger.hpp>
00042 #include <WNS/Singleton.hpp>
00043 #include <WNS/container/Matrix.hpp>
00044 
00045 #include <map>
00046 #include <list>
00047 
00048 namespace wifimac { namespace pathselection {
00049 
00066     class VirtualPathSelection:
00067         virtual public wns::ldk::Layer,
00068         public wns::node::component::Component,
00069         public IPathSelection
00070     {
00081         class AddressStorage
00082         {
00083             typedef wns::container::Registry<wns::service::dll::UnicastAddress, int> IdLookup;
00084             typedef wns::container::Registry<int, wns::service::dll::UnicastAddress> AdrLookup;
00085 
00086         public:
00087             AddressStorage();
00088 
00092             int
00093             map(const wns::service::dll::UnicastAddress adr);
00094 
00098             int
00099             get(const wns::service::dll::UnicastAddress adr) const;
00100 
00104             wns::service::dll::UnicastAddress
00105             get(const int id) const;
00106 
00110             bool
00111             knows(const wns::service::dll::UnicastAddress adr) const;
00112 
00116             bool
00117             knows(const int id) const;
00118 
00122             int
00123             getMaxId() const;
00124 
00125         private:
00129             int nextId;
00130 
00134             IdLookup adr2id;
00138             AdrLookup id2adr;
00139         };
00140 
00141     public:
00145         VirtualPathSelection(
00146             wns::node::Interface* _node,
00147             const wns::pyconfig::View& _config);
00148 
00152         virtual void
00153         doStartup()
00154             {};
00155 
00159         virtual ~VirtualPathSelection()
00160             {};
00161 
00166         virtual void
00167         onNodeCreated()
00168             {};
00169 
00173         virtual void
00174         onWorldCreated()
00175             {};
00176 
00180         virtual void
00181         onShutdown()
00182             {};
00183 
00191         void
00192         registerMP(const wns::service::dll::UnicastAddress mpAddress);
00193 
00205         void
00206         registerPortal(const wns::service::dll::UnicastAddress portalAddress,
00207                        dll::APUpperConvergence* apUC);
00208 
00219         virtual wns::service::dll::UnicastAddress
00220         getNextHop(const wns::service::dll::UnicastAddress current,
00221                    const wns::service::dll::UnicastAddress finalDestination);
00222 
00226         virtual bool
00227         isMeshPoint(const wns::service::dll::UnicastAddress address) const;
00228 
00232         virtual bool
00233         isPortal(const wns::service::dll::UnicastAddress address) const;
00234 
00241         virtual wns::service::dll::UnicastAddress
00242         getPortalFor(const wns::service::dll::UnicastAddress clientAddress);
00243 
00252         virtual wns::service::dll::UnicastAddress
00253         getProxyFor(const wns::service::dll::UnicastAddress clientAddress);
00254 
00265         virtual void
00266         registerProxy(const wns::service::dll::UnicastAddress proxy,
00267                       const wns::service::dll::UnicastAddress client);
00271         virtual void
00272         deRegisterProxy(const wns::service::dll::UnicastAddress proxy,
00273                         const wns::service::dll::UnicastAddress client);
00274 
00278         virtual void
00279         createPeerLink(const wns::service::dll::UnicastAddress myself,
00280                        const wns::service::dll::UnicastAddress peer,
00281                        const Metric linkMetric = Metric(1));
00285         virtual void
00286         updatePeerLink(const wns::service::dll::UnicastAddress myself,
00287                        const wns::service::dll::UnicastAddress peer,
00288                        const Metric linkMetric = Metric(1));
00289 
00293         virtual void
00294         closePeerLink(const wns::service::dll::UnicastAddress myself,
00295                       const wns::service::dll::UnicastAddress peer);
00296     private:
00300         void
00301         printPathSelectionTable() const;
00305         void
00306         printPathSelectionLine(const wns::service::dll::UnicastAddress source) const;
00310         void
00311         printProxyInformation(const wns::service::dll::UnicastAddress proxy) const;
00315         void
00316         printPortalInformation(const wns::service::dll::UnicastAddress portal) const;
00317 
00321         void onNewPathSelectionEntry();
00322 
00326         wns::logger::Logger logger;
00327 
00331         typedef wns::container::Matrix<int, 2> addressMatrix;
00335         typedef wns::container::Matrix<Metric, 2> metricMatrix;
00339         typedef std::map<int, int> addressMap;
00343         typedef std::map<int, dll::APUpperConvergence*> adr2ucMap;
00347         typedef std::list<int> addressList;
00348 
00352         addressList mps;
00353 
00357     bool useStaticPS;
00361     wns::simulator::Time staticPSsnapshotTimeout;
00365         adr2ucMap portals;
00369         metricMatrix linkCosts;
00373         metricMatrix pathCosts;
00377         addressMatrix paths;
00381         addressMap clients2proxies;
00385         addressMap clients2portals;
00386 
00390         AddressStorage mapper;
00391 
00396         const int numNodes;
00397 
00401         bool pathMatrixIsConsistent;
00402 
00406         double preKnowledgeAlpha;
00411         metricMatrix preKnowledgeCosts;
00412     };
00413 
00414     class VirtualPathSelectionService {
00415     public:
00416         VirtualPathSelectionService();
00417 
00418         VirtualPathSelection*
00419         getVPS();
00420 
00421         void
00422         setVPS(VirtualPathSelection* _vps);
00423 
00424     private:
00425         wns::logger::Logger logger;
00426         VirtualPathSelection* vps;
00427     };
00428 
00429     typedef wns::SingletonHolder<VirtualPathSelectionService> TheVPSService;
00430 
00431 } // mac
00432 } // wifimac
00433 
00434 #endif // WIFIMAC_SCHEDULER_HPP

Generated on Sat May 26 03:32:10 2012 for openWNS by  doxygen 1.5.5