User Manual, Developers Guide and API Documentation

PeerId.cpp

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 #include <LTE/helper/idprovider/PeerId.hpp>
00029 
00030 #include <LTE/rlc/RLCCommand.hpp>
00031 #include <LTE/macg/MACgCommand.hpp>
00032 
00033 #include <WNS/service/Service.hpp>
00034 #include <WNS/ldk/CommandReaderInterface.hpp>
00035 #include <WNS/ldk/Compound.hpp>
00036 #include <WNS/isClass.hpp>
00037 
00038 using namespace lte::helper::idprovider;
00039 
00040 PeerId::PeerId(wns::ldk::fun::FUN* fun) :
00041   layer2(fun->getLayer<dll::ILayer2*>()),
00042   rlcCommandReader(fun->getCommandReader("rlc")),
00043   macgCommandReader(fun->getCommandReader("macg")),
00044   key("MAC.PeerId"),
00045   stationType(layer2->getStationType())
00046 {
00047 }
00048 
00049 PeerId::~PeerId()
00050 {
00051 }
00052 
00053 void
00054 PeerId::doVisit(wns::probe::bus::IContext& c, const wns::ldk::CompoundPtr& compound) const
00055 {
00056   assure(compound, "Received NULL CompoundPtr");
00057 
00058   int peerIdInt = 0;
00059   wns::service::dll::UnicastAddress myAddress = layer2->getDLLAddress();
00060   wns::service::dll::UnicastAddress sourceAddress;
00061   wns::service::dll::UnicastAddress destinationAddress;
00062   wns::service::dll::UnicastAddress peerAddress;
00063 
00064   if ( rlcCommandReader->commandIsActivated(compound->getCommandPool()) ) {
00065 
00066     rlc::RLCCommand* rlcCommand =
00067       rlcCommandReader->readCommand<rlc::RLCCommand>(compound->getCommandPool());
00068 
00069     sourceAddress = rlcCommand->peer.source;
00070     destinationAddress = rlcCommand->peer.destination;
00071 
00072     if (myAddress == destinationAddress)
00073       {
00074     // it is the incoming path, i.e. the source is the peer
00075     peerAddress = sourceAddress;
00076       }
00077     else if (myAddress == sourceAddress)
00078       {
00079     // it is the outgoing path, i.e. the destination is the peer
00080     peerAddress = destinationAddress;
00081       }
00082   }
00083   // no RLC E2E peer address available, then ask the MACg next-hop address
00084   if ( peerAddress == wns::service::dll::UnicastAddress() && macgCommandReader->commandIsActivated(compound->getCommandPool())) {
00085 
00086     macg::MACgCommand* macgCommand =
00087       macgCommandReader->readCommand<macg::MACgCommand>(compound->getCommandPool());
00088 
00089 
00090     sourceAddress = macgCommand->peer.source;
00091     destinationAddress = macgCommand->peer.dest;
00092 
00093     if (myAddress == destinationAddress)
00094       {
00095     // it is the incoming path, i.e. the source is the peer
00096     peerAddress = sourceAddress;
00097       }
00098     else if (myAddress == sourceAddress)
00099       {
00100     // it is the outgoing path, i.e. the destination is the peer
00101     peerAddress = destinationAddress;
00102       }
00103   }
00104   // only if finally a peerAddress could be determined, write the probe context
00105   // e.g. for BCH there is no peer address, since it is broadcast
00106   if (peerAddress != wns::service::dll::UnicastAddress()) {
00107     peerIdInt = peerAddress.getInteger();
00108     c.insertInt( this->key, peerIdInt);
00109   }
00110 }

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