User Manual, Developers Guide and API Documentation

CommandInformation.hpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  * WiFiMAC (IEEE 802.11)                                                      *
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_HELPER_CONTEXTPROVIDER_COMMANDINFORMATION_HPP
00030 #define WIFIMAC_HELPER_CONTEXTPROVIDER_COMMANDINFORMATION_HPP
00031 
00032 // declaration of the commands which are read by the specific command readers
00033 #include <WIFIMAC/pathselection/BeaconLinkQualityMeasurement.hpp>
00034 #include <WIFIMAC/pathselection/ForwardingCommand.hpp>
00035 #include <DLL/UpperConvergence.hpp>
00036 #include <WIFIMAC/convergence/PhyMode.hpp>
00037 #include <WNS/service/dll/Address.hpp>
00038 #include <WIFIMAC/Layer2.hpp>
00039 
00040 #include <WNS/probe/bus/CommandContextProvider.hpp>
00041 
00042 //#include <WNS/isClass.hpp>
00043 
00044 namespace wifimac { namespace helper { namespace contextprovider {
00045 
00046 
00054     class IsUnicast:
00055         virtual public wns::probe::bus::CommandContextProvider<dll::UpperCommand>
00056     {
00057     public:
00058         IsUnicast(wns::ldk::fun::FUN* fun, std::string ucCommandName):
00059             wns::probe::bus::CommandContextProvider<dll::UpperCommand>(fun, ucCommandName, "MAC.CompoundIsUnicast")
00060             {};
00061     private:
00062         virtual void
00063         doVisitCommand(wns::probe::bus::IContext& c, const dll::UpperCommand* command) const
00064             {
00065                 if(command->peer.targetMACAddress.isValid())
00066                 {
00067                     c.insertInt(getKey(), 1);
00068                 }
00069                 else
00070                 {
00071                     c.insertInt(getKey(), 0);
00072                 }
00073             };
00074     };
00075 
00084     class IsForMe:
00085         virtual public wns::probe::bus::CommandContextProvider<dll::UpperCommand>
00086     {
00087     public:
00088         IsForMe(wns::ldk::fun::FUN* fun_, std::string ucCommandName):
00089             wns::probe::bus::CommandContextProvider<dll::UpperCommand>(fun_, ucCommandName, "MAC.CompoundIsForMe"),
00090             fun(fun_)
00091             {};
00092 
00093     private:
00094         virtual void
00095         doVisitCommand(wns::probe::bus::IContext& c, const dll::UpperCommand* command) const
00096             {
00097                 wns::service::dll::UnicastAddress targetAddress = command->peer.targetMACAddress;
00098                 if(targetAddress.isValid())
00099                 {
00100                     if(fun->getLayer<wifimac::Layer2*>()->isTransceiverMAC(targetAddress))
00101                     {
00102                         c.insertInt(this->key, 1);
00103                     }
00104                     else
00105                     {
00106                         c.insertInt(this->key, 0);
00107                     }
00108                 }
00109                 else
00110                 {
00111                     // broadcast -> is for me
00112                     c.insertInt(this->key, 1);
00113                 }
00114             };
00115         wns::ldk::fun::FUN* fun;
00116     };
00117 
00125     class IsFromMe:
00126         virtual public wns::probe::bus::CommandContextProvider<dll::UpperCommand>
00127     {
00128     public:
00129         IsFromMe(wns::ldk::fun::FUN* fun_, std::string ucCommandName):
00130             wns::probe::bus::CommandContextProvider<dll::UpperCommand>(fun_, ucCommandName, "MAC.CompoundIsFromMe"),
00131             fun(fun_)
00132             {};
00133 
00134     private:
00135         virtual void
00136         doVisitCommand(wns::probe::bus::IContext& c, const dll::UpperCommand* command) const
00137             {
00138                 wns::service::dll::UnicastAddress sourceAddress = command->peer.sourceMACAddress;
00139                 if(sourceAddress.isValid())
00140                 {
00141                     if(fun->getLayer<wifimac::Layer2*>()->isTransceiverMAC(sourceAddress))
00142                     {
00143                         c.insertInt(this->key, 1);
00144                     }
00145                     else
00146                     {
00147                         c.insertInt(this->key, 0);
00148                     }
00149                 }
00150                 else
00151                 {
00152                     // broadcast -> is not from me
00153                     c.insertInt(this->key, 0);
00154                 }
00155             };
00156         wns::ldk::fun::FUN* fun;
00157     };
00158 
00163     class SourceAddress:
00164         virtual public wns::probe::bus::CommandContextProvider<dll::UpperCommand>
00165     {
00166     public:
00167         SourceAddress(wns::ldk::fun::FUN* fun, std::string ucCommandName):
00168             wns::probe::bus::CommandContextProvider<dll::UpperCommand>(fun, ucCommandName, "MAC.CompoundSourceAddress")
00169             {};
00170 
00171     private:
00172         virtual void
00173         doVisitCommand(wns::probe::bus::IContext& c, const dll::UpperCommand* command) const
00174             {
00175                 if(command->peer.sourceMACAddress.isValid())
00176                 {
00177                     // if the command is activated, we add the tx address to the
00178                     // context
00179                     c.insertInt(this->key,
00180                                 command->peer.sourceMACAddress.getInteger());
00181                 }
00182             }
00183     };
00184 
00189     class TargetAddress:
00190         virtual public wns::probe::bus::CommandContextProvider<dll::UpperCommand>
00191     {
00192     public:
00193         TargetAddress(wns::ldk::fun::FUN* fun, std::string ucCommandName):
00194             wns::probe::bus::CommandContextProvider<dll::UpperCommand>(fun, ucCommandName, "MAC.CompoundTargetAddress")
00195             {};
00196 
00197     private:
00198         virtual void
00199         doVisitCommand(wns::probe::bus::IContext& c, const dll::UpperCommand* command) const
00200             {
00201                 if(command->peer.targetMACAddress.isValid())
00202                 {
00203                     // if the command is activated, we add the tx address to the
00204                     // context
00205                     c.insertInt(this->key,
00206                                 command->peer.targetMACAddress.getInteger());
00207                 }
00208             }
00209     };
00210 
00217     class HopCount :
00218         virtual public wns::probe::bus::CommandContextProvider<wifimac::pathselection::ForwardingCommand>
00219     {
00220     public:
00221         HopCount(wns::ldk::fun::FUN* fun, std::string forwardingCommandName):
00222             wns::probe::bus::CommandContextProvider<wifimac::pathselection::ForwardingCommand>(fun, forwardingCommandName, "MAC.CompoundHopCount")
00223             {};
00224     private:
00225         virtual void
00226         doVisitCommand(wns::probe::bus::IContext& c, const wifimac::pathselection::ForwardingCommand* command) const
00227             {
00228                 if(command->magic.hopCount > 0)
00229                 {
00230                     // if the command is activated, we add the tx address to the
00231                     // context
00232                     c.insertInt(this->key,
00233                                 command->magic.hopCount);
00234                 }
00235             }
00236     };
00237 
00244     class DataBitsPerSymbol:
00245         virtual public wns::probe::bus::CommandContextProvider<wifimac::lowerMAC::ManagerCommand>
00246     {
00247     public:
00248         DataBitsPerSymbol(wns::ldk::fun::FUN* fun, std::string managerCommandName):
00249             wns::probe::bus::CommandContextProvider<wifimac::lowerMAC::ManagerCommand>(fun, managerCommandName, "MAC.CompoundDBPS")
00250             {};
00251 
00252     private:
00253         virtual void
00254         doVisitCommand(wns::probe::bus::IContext& c, const wifimac::lowerMAC::ManagerCommand* command) const
00255             {
00256                 wifimac::convergence::PhyMode phymode = command->getPhyMode();
00257                 c.insertInt(this->key, phymode.getDataBitsPerSymbol());
00258             }
00259     };
00260 
00267     class SpatialStreams :
00268         virtual public wns::probe::bus::CommandContextProvider<wifimac::lowerMAC::ManagerCommand>
00269     {
00270     public:
00271         SpatialStreams(wns::ldk::fun::FUN* fun, std::string managerCommandName):
00272             wns::probe::bus::CommandContextProvider<wifimac::lowerMAC::ManagerCommand>(fun, managerCommandName, "MAC.CompoundSpatialStreams")
00273             {};
00274 
00275     private:
00276         virtual void
00277         doVisitCommand(wns::probe::bus::IContext& c, const wifimac::lowerMAC::ManagerCommand* command) const
00278             {
00279                 wifimac::convergence::PhyMode mcs = command->getPhyMode();
00280                 c.insertInt(this->key, mcs.getNumberOfSpatialStreams());
00281             }
00282     };
00283 }}}
00284 
00285 #endif //WIFIMAC_HELPER_CONTEXTPROVIDER_COMMANDINFORMATION_HPP

Generated on Sun May 27 03:32:08 2012 for openWNS by  doxygen 1.5.5