User Manual, Developers Guide and API Documentation

PhyUser.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-2009
00006  * Chair of Communication Networks (ComNets)
00007  * Kopernikusstr. 5, D-52074 Aachen, Germany
00008  * email: info@openwns.org
00009  * www: http://www.openwns.org
00010  * _____________________________________________________________________________
00011  *
00012  * openWNS is free software; you can redistribute it and/or modify it under the
00013  * terms of the GNU Lesser General Public License version 2 as published by the
00014  * Free Software Foundation;
00015  *
00016  * openWNS is distributed in the hope that it will be useful, but WITHOUT ANY
00017  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
00018  * A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00019  * details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public License
00022  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00023  *
00024  ******************************************************************************/
00025 
00026 
00027 #include <WIMAC/PhyUser.hpp>
00028 #include <cmath>
00029 
00030 #include <WNS/service/phy/ofdma/DataTransmission.hpp>
00031 #include <WNS/service/dll/StationTypes.hpp>
00032 #include <WNS/rng/RNGen.hpp>
00033 #include <WNS/ldk/fun/FUN.hpp>
00034 #include <WNS/ldk/fcf/FrameBuilder.hpp>
00035 #include <WNS/pyconfig/View.hpp>
00036 #include <WNS/probe/bus/ContextProviderCollection.hpp>
00037 #include <WNS/probe/bus/utils.hpp>
00038 
00039 
00040 #include <WIMAC/Classifier.hpp>
00041 #include <WIMAC/ConnectionIdentifier.hpp>
00042 #include <WIMAC/Component.hpp>
00043 #include <WIMAC/Logger.hpp>
00044 #include <WIMAC/services/InterferenceCache.hpp>
00045 #include <WIMAC/StationManager.hpp>
00046 #include <WIMAC/services/ConnectionManager.hpp>
00047 #include <WIMAC/frame/DataCollector.hpp>
00048 #include <WIMAC/scheduler/Scheduler.hpp>
00049 
00050 using namespace wimac;
00051 
00052 STATIC_FACTORY_REGISTER_WITH_CREATOR(PhyUser, wns::ldk::FunctionalUnit, "wimac.PhyUser", wns::ldk::FUNConfigCreator);
00053 
00054 PhyUser::PhyUser(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config) :
00055     wns::ldk::CommandTypeSpecifier<PhyUserCommand>(fun),
00056     wns::ldk::HasReceptor<>(),
00057     wns::ldk::HasConnector<>(),
00058     wns::ldk::HasDeliverer<>(),
00059     wns::Cloneable<PhyUser>(),
00060     cacheEntryTimeStamp(-1),
00061     maxAgeCacheEntry(1.0),
00062     lastInterferenceSlot(-1),
00063     friends_()
00064 {
00065     friends_.interferenceCacheName = "interferenceCache";
00066     friends_.connectionManagerName = "connectionManager";
00067     friends_.connectionClassifierName = "classifier";
00068     friends_.dataCollectorName = "ulscheduler";
00069 
00070     friends_.layer = NULL;
00071     friends_.interferenceCache = NULL;
00072     friends_.connectionManager = NULL;
00073     friends_.connectionClassifier = NULL;
00074 
00075     // Probes configure
00076     wns::probe::bus::ContextProviderCollection* cpcParent = &fun->getLayer()->getContextProviderCollection();
00077 
00078     wns::probe::bus::ContextProviderCollection cpc(cpcParent);
00079 
00080     probes_.interferenceSDMA = 
00081         wns::probe::bus::collector(cpc, config, "iProbeName");
00082 
00083     probes_.cirSDMA = 
00084         wns::probe::bus::collector(cpc, config, "cirProbeName");
00085 
00086     probes_.carrierSDMA = 
00087         wns::probe::bus::collector(cpc, config, "cProbeName");
00088 
00089     probes_.deltaInterferenceSDMA =
00090         wns::probe::bus::collector(cpc, config, "deltaIProbeName");
00091 
00092     probes_.deltaCarrierSDMA = 
00093         wns::probe::bus::collector(cpc, config, "deltaCProbeName");
00094 
00095     probes_.PHYModeSDMA = 
00096         wns::probe::bus::collector(cpc, config, "phyModeProbeName");
00097 
00098     probes_.deltaPHYModeSDMA = 
00099         wns::probe::bus::collector(cpc, config, "deltaPhyProbeName");
00100 
00101     probes_.interferenceFrameHead = 
00102         wns::probe::bus::collector(cpc, config, "iFCHProbeName");
00103 
00104     probes_.cirFrameHead = 
00105         wns::probe::bus::collector(cpc, config, "cirFCHProbeName");
00106 
00107     probes_.interferenceContention = 
00108         wns::probe::bus::collector(cpc, config, "iContentionProbeName");
00109 
00110     probes_.cirContention = 
00111         wns::probe::bus::collector(cpc, config, "cirContentionProbeName");
00112 
00113     probes_.pathloss = 
00114         wns::probe::bus::collector(cpc, config, "pathlossProbeName");
00115 
00116     probes_.jsonTracing = 
00117         wns::probe::bus::collector(cpc, config, "phyTraceProbeName");
00118 
00119 }
00120 
00121 
00122 PhyUser::PhyUser( const PhyUser& rhs ):
00123     wns::ldk::CompoundHandlerInterface<FunctionalUnit>( rhs ),
00124     wns::ldk::CommandTypeSpecifierInterface( rhs ),
00125     wns::ldk::HasReceptorInterface( rhs ),
00126     wns::ldk::HasConnectorInterface( rhs ),
00127     wns::ldk::HasDelivererInterface( rhs ),
00128     wns::CloneableInterface( rhs ),
00129     wns::IOutputStreamable( rhs ),
00130     wns::PythonicOutput( rhs ),
00131     wns::ldk::FunctionalUnit( rhs ),
00132     wns::service::phy::ofdma::Handler( rhs ),
00133     wns::ldk::CommandTypeSpecifier<PhyUserCommand>( rhs ),
00134     wns::ldk::HasReceptor<>( rhs ),
00135     wns::ldk::HasConnector<>( rhs ),
00136     wns::ldk::HasDeliverer<>( rhs ),
00137     wns::Cloneable<PhyUser>( rhs ),
00138     cacheEntryTimeStamp(-1),
00139     maxAgeCacheEntry(1.0),
00140     lastInterferenceSlot(-1),
00141     friends_()
00142 {
00143     friends_.interferenceCacheName = rhs.friends_.interferenceCacheName;
00144     friends_.connectionManagerName = rhs.friends_.connectionManagerName;
00145     friends_.connectionClassifierName = rhs.friends_.connectionClassifierName;
00146     friends_.dataCollectorName = rhs.friends_.dataCollectorName;
00147 
00148     friends_.layer = NULL;
00149     friends_.interferenceCache = NULL;
00150     friends_.connectionManager = NULL;
00151 
00152 
00153     probes_.interferenceSDMA = wns::probe::bus::ContextCollectorPtr(
00154         new wns::probe::bus::ContextCollector(
00155             *rhs.probes_.interferenceSDMA ));
00156     probes_.carrierSDMA = wns::probe::bus::ContextCollectorPtr(
00157         new wns::probe::bus::ContextCollector(
00158             *rhs.probes_.carrierSDMA ));
00159     probes_.cirSDMA = wns::probe::bus::ContextCollectorPtr(
00160         new wns::probe::bus::ContextCollector(
00161             *rhs.probes_.cirSDMA ));
00162     probes_.deltaPHYModeSDMA = wns::probe::bus::ContextCollectorPtr(
00163         new wns::probe::bus::ContextCollector(
00164             *rhs.probes_.deltaPHYModeSDMA));
00165     probes_.PHYModeSDMA = wns::probe::bus::ContextCollectorPtr(
00166         new wns::probe::bus::ContextCollector(
00167         *rhs.probes_.PHYModeSDMA));
00168     probes_.deltaInterferenceSDMA = wns::probe::bus::ContextCollectorPtr(
00169         new wns::probe::bus::ContextCollector(
00170             *rhs.probes_.deltaInterferenceSDMA ));
00171     probes_.deltaCarrierSDMA = wns::probe::bus::ContextCollectorPtr(
00172         new wns::probe::bus::ContextCollector(
00173             *rhs.probes_.deltaCarrierSDMA ));
00174     probes_.interferenceFrameHead = wns::probe::bus::ContextCollectorPtr(
00175         new wns::probe::bus::ContextCollector(
00176             *rhs.probes_.interferenceFrameHead ));
00177     probes_.cirFrameHead = wns::probe::bus::ContextCollectorPtr(
00178         new wns::probe::bus::ContextCollector(
00179             *rhs.probes_.cirFrameHead ));
00180     probes_.interferenceContention = wns::probe::bus::ContextCollectorPtr(
00181         new wns::probe::bus::ContextCollector(
00182             *rhs.probes_.interferenceContention ));
00183     probes_.cirContention = wns::probe::bus::ContextCollectorPtr(
00184         new wns::probe::bus::ContextCollector(
00185             *rhs.probes_.cirContention ));
00186     probes_.pathloss = wns::probe::bus::ContextCollectorPtr(
00187         new wns::probe::bus::ContextCollector(
00188             *rhs.probes_.pathloss ));
00189     probes_.jsonTracing = wns::probe::bus::ContextCollectorPtr(
00190         new wns::probe::bus::ContextCollector(
00191             *rhs.probes_.jsonTracing ));
00192 }
00193 
00194 PhyUser::PhyUser::~PhyUser()
00195 {
00196 }
00197 
00198 
00199 bool
00200 PhyUser::doIsAccepting(const wns::ldk::CompoundPtr& /*compound*/) const
00201 {
00202     return true;
00203 }
00204 
00205 
00206 void
00207 PhyUser::doSendData(const wns::ldk::CompoundPtr& compound)
00208 {
00209     COMMANDTYPE* command = getCommand( compound->getCommandPool() );
00210     LOG_INFO( getFUN()->getName(), ": doSendData" );
00211     (*command->local.pAFunc_.get())( this, compound );
00212 
00213     int macaddr = address.getInteger();
00214 }
00215 
00216 
00217 void PhyUser::onFUNCreated()
00218 {
00219     friends_.layer = dynamic_cast<wimac::Component*>( getFUN()->getLayer() );
00220     assure(friends_.layer, "must be part of wimac::Component");
00221     friends_.interferenceCache = getFUN()->getLayer()
00222         ->getManagementService<service::InterferenceCache>(friends_.interferenceCacheName);
00223 
00224     friends_.connectionManager = getFUN()->getLayer()
00225         ->getManagementService<service::ConnectionManager>(friends_.connectionManagerName);
00226     friends_.connectionClassifier = getFUN()
00227         ->findFriend<ConnectionClassifier*>(friends_.connectionClassifierName);
00228 
00229     // Get the Registry Proxy either from the TX (UT) or RX (BS) scheduler 
00230     if(getFUN()->findFriend<frame::DataCollector*>(friends_.dataCollectorName)
00231             ->getTxScheduler() != NULL)
00232     {
00233         friends_.registry = getFUN()
00234             ->findFriend<frame::DataCollector*>(friends_.dataCollectorName)
00235                 ->getTxScheduler()->getRegistryProxy();
00236     }
00237     else
00238     {
00239         friends_.registry = getFUN()
00240             ->findFriend<frame::DataCollector*>(friends_.dataCollectorName)
00241                 ->getRxScheduler()->getRegistryProxy();
00242     }
00243     assure(friends_.registry != NULL, "Unable to get RegistryProxy");
00244 
00245     cacheEntryTimeStamp = -maxAgeCacheEntry;
00246 }
00247 
00248 
00249 
00250 void
00251 PhyUser::doOnData(const wns::ldk::CompoundPtr& compound)
00252 {
00253     assure(compound, "doOnData called with an invalid compound.");
00254 
00255     PhyUserCommand* puCommand = getCommand( compound->getCommandPool() );
00256     LOG_INFO( getFUN()->getName(), ": doOnData source: ", puCommand->peer.source_->getName(),
00257               "  C/I = ", puCommand->local.rxPower_, " / ", puCommand->local.interference_,
00258               " = ", getCommand( compound->getCommandPool() )->magic.rxMeasurement->getSINR()
00259               );
00260     if(puCommand->peer.estimatedCQI.interference.get_mW() > 0)
00261     {
00262         LOG_INFO( "estimated C/I = ",
00263                   puCommand->peer.estimatedCQI.carrier, " / ", puCommand->peer.estimatedCQI.interference,
00264                   " = " , puCommand->peer.estimatedCQI.carrier / puCommand->peer.estimatedCQI.interference,
00265                   "\n estimated intra-cell interference: ", puCommand->getEstimatedIintra()
00266             );
00267                        double delta_SINR = (getCommand( compound->getCommandPool() )->magic.rxMeasurement->getSINR().get_factor()) - (puCommand->peer.estimatedCQI.carrier / puCommand->peer.estimatedCQI.interference).get_factor();
00268                 if(abs(delta_SINR) > 0.001)
00269                 {
00270                     LOG_INFO( "Delta C / I: ", delta_SINR);
00271                 }else{ LOG_INFO("abs(Delta C / I) < 0.001 "); }
00272         }
00273     else{
00274         LOG_INFO( "estimated C/I = ",
00275                   puCommand->peer.estimatedCQI.carrier, " / ", puCommand->peer.estimatedCQI.interference,
00276                   "\n estimated intra-cell interference: ", puCommand->getEstimatedIintra()
00277             );
00278     }
00279     getDeliverer()->getAcceptor(compound)->onData(compound);
00280 }
00281 
00282 void
00283 PhyUser::onData(wns::osi::PDUPtr pdu,
00284         wns::service::phy::power::PowerMeasurementPtr rxPowerMeasurement)
00285 {
00286     wns::ldk::CompoundPtr compound = wns::staticCast<wns::ldk::Compound>(pdu)->copy();
00287     if(!getFUN()->getProxy()->commandIsActivated(
00288         compound->getCommandPool(), this))      
00289             return;
00290 
00291     PhyUserCommand* puCommand = getCommand( compound->getCommandPool() );
00292 
00293     // store measured signal into PhyUserCommand
00294     wns::Power rxPower          = rxPowerMeasurement->getRxPower();
00295     wns::Power txPower          = rxPowerMeasurement->getTxPower();
00296     wns::Power interference     = rxPowerMeasurement->getInterferencePower();
00297     wns::Power omniInterference = rxPowerMeasurement->getOmniInterferencePower();
00298     puCommand->local.rxPower_   = rxPower;
00299     //puCommand->local.txPower_   = txPower;
00300     puCommand->local.interference_ = interference;
00301 
00302     puCommand->magic.rxMeasurement = rxPowerMeasurement;
00303 
00304     // Only proceed on filtered compounds
00305     if ( !filter( compound ) )
00306         return;
00307 
00308     if ( puCommand->peer.measureInterference_ )
00309     {   // only for flaged transmissions
00310         // store C and I in sender's cache
00311         // The remote interferenceCache stores the averaged noise plus inter-cell
00312         // interference and the carrier signal strength separated by usedID.
00313         puCommand->magic.sourceComponent_
00314             ->getManagementService<service::InterferenceCache>
00315             ("interferenceCache")
00316             ->storeCarrier( friends_.layer->getNode(),
00317                             rxPower,
00318                             service::InterferenceCache::Remote );
00319 
00320         puCommand->magic.sourceComponent_
00321             ->getManagementService<service::InterferenceCache>
00322             ("interferenceCache")
00323             ->storePathloss( friends_.layer->getNode(),
00324                             rxPowerMeasurement->getPathLoss(),
00325                             service::InterferenceCache::Remote );
00326 
00327         wns::Power iInterPlusNoise;
00328         if(interference > wns::Power::from_mW(0.0)) { /*puCommand->getEstimatedIintra()){*/
00329             iInterPlusNoise = interference - puCommand->getEstimatedIintra();
00330         }else{
00331             iInterPlusNoise = wns::Power::from_mW(0.0);
00332             LOG_INFO(getFUN()->getName(), " PhyUser: write iInterPlusNoise = null to interferenceCache");
00333         }
00334 
00335         puCommand->magic.sourceComponent_
00336             ->getManagementService<service::InterferenceCache>
00337             ("interferenceCache")
00338             ->storeInterference( friends_.layer->getNode(),
00339                                     iInterPlusNoise,
00340                                     service::InterferenceCache::Remote );
00341 
00342         cacheEntryTimeStamp = wns::simulator::getEventScheduler()->getTime();
00343 
00344         LOG_INFO(getFUN()->getName(), " wrote interference cache entry to sender ( ",
00345                     puCommand->magic.sourceComponent_->getFUN()->getName(), " )");
00346     }
00347 
00348 
00349     // Probes put
00350     if (!puCommand->peer.destination_ && !puCommand->magic.contentionAccess_ && puCommand->magic.frameHead_)
00351     { // Probe frameHead
00352         probes_.interferenceFrameHead->put(compound, interference.get_dBm() );
00353         probes_.cirFrameHead->put(compound, rxPower.get_dBm() - interference.get_dBm() );
00354 
00355         if(cacheEntryTimeStamp + maxAgeCacheEntry < wns::simulator::getEventScheduler()->getTime()){
00356             // write frame head C/I into interference cache
00357             puCommand->magic.sourceComponent_
00358                 ->getManagementService<service::InterferenceCache>
00359                 ("interferenceCache")
00360                 ->storeCarrier( friends_.layer->getNode(),
00361                                 rxPower,
00362                                 service::InterferenceCache::Remote );
00363 
00364             puCommand->magic.sourceComponent_
00365                 ->getManagementService<service::InterferenceCache>
00366                 ("interferenceCache")
00367                 ->storePathloss( friends_.layer->getNode(),
00368                                 rxPowerMeasurement->getPathLoss(),
00369                                 service::InterferenceCache::Remote );
00370 
00371 
00372             puCommand->magic.sourceComponent_
00373                 ->getManagementService<service::InterferenceCache>
00374                 ("interferenceCache")
00375                 ->storeInterference( friends_.layer->getNode(),
00376                                         ( interference ),
00377                                         service::InterferenceCache::Remote );
00378 
00379             cacheEntryTimeStamp = wns::simulator::getEventScheduler()->getTime();
00380 
00381             LOG_INFO(getFUN()->getName(), " wrote FCH interference cache entry to sender ( ",
00382                         puCommand->magic.sourceComponent_->getFUN()->getName(), " )");
00383 
00384         }
00385     }
00386     else if(!puCommand->peer.destination_ && !puCommand->magic.contentionAccess_ && !puCommand->magic.frameHead_)
00387     { // Probe Broadcast transmissions without frameHead
00388         // Probe nothing
00389     }
00390     else if(puCommand->peer.destination_ && puCommand->magic.contentionAccess_ && !puCommand->magic.frameHead_)
00391     { // Probe contention based access
00392         probes_.interferenceContention->put(compound, interference.get_dBm() );
00393         probes_.cirContention->put(compound, rxPower.get_dBm() - interference.get_dBm() );
00394     }
00395     else if(puCommand->peer.destination_ && !puCommand->magic.contentionAccess_ && !puCommand->magic.frameHead_)
00396     { // Probe SDMA transmitted
00397         probes_.interferenceSDMA->put(compound, interference.get_dBm() );
00398         probes_.carrierSDMA->put(compound, rxPower.get_dBm() );
00399         probes_.cirSDMA->put(compound, rxPower.get_dBm() - interference.get_dBm() );
00400         probes_.pathloss->put(compound, txPower.get_dBm() - rxPower.get_dBm());
00401         LOG_INFO( "pathloss from PhyUser:",txPower.get_dBm() - rxPower.get_dBm());
00402     
00403         /* Probe deviation between possible and chosen PHY mode*/
00404         int phyModeIndex =
00405             friends_.registry->getPhyModeMapper()->
00406                 getIndexForPhyMode(*puCommand->peer.phyModePtr);
00407         int possiblePhyModeIndex = 
00408             friends_.registry->getPhyModeMapper()->getIndexForPhyMode(
00409                 *friends_.registry->getPhyModeMapper()->getBestPhyMode(rxPower / interference));
00410 
00411         probes_.deltaPHYModeSDMA->put(compound, possiblePhyModeIndex - phyModeIndex);
00412 
00413         // probe the ratio of actual-to-estimated signal strength in dB
00414         probes_.deltaCarrierSDMA->put(compound, 
00415             rxPower.get_dBm() - puCommand->peer.estimatedCQI.carrier.get_dBm());
00416         probes_.deltaInterferenceSDMA->put(compound, 
00417             interference.get_dBm() - puCommand->peer.estimatedCQI.interference.get_dBm());
00418     }else{
00419         assure(0, "PhyUser::onData: Received PDU can't be releated to a probe!");
00420     }
00421 
00422 #ifndef NDEBUG
00423     traceIncoming(compound, rxPowerMeasurement);
00424 #endif
00425     //Deliver compound
00426     doOnData(compound);
00427 }
00428 
00429 void
00430 PhyUser::doWakeup()
00431 {
00432     // calls wakeup method of upper functional unit(s)
00433     getReceptor()->wakeup();
00434 }
00435 
00436 
00437 
00438 void
00439 PhyUser::setDataTransmissionService(wns::service::Service* phy)
00440 {
00441     assure(phy, "must be non-NULL");
00442     assureType(phy, wns::service::phy::ofdma::DataTransmission*);
00443     dataTransmission = dynamic_cast<wns::service::phy::ofdma::DataTransmission*>(phy);
00444 }
00445 
00446 
00447 
00448 wns::service::phy::ofdma::DataTransmission*
00449 PhyUser::getDataTransmissionService() const
00450 {
00451     assure(dataTransmission, "no ofdma::DataTransmission set. Did you call setDataTransmission()?");
00452     return dataTransmission;
00453 }
00454 
00455 
00456 
00457 void
00458 PhyUser::setNotificationService(wns::service::Service* phy)
00459 {
00460     assure(phy, "must be non-NULL");
00461     assureType(phy, wns::service::phy::ofdma::Notification*);
00462     notificationService = dynamic_cast<wns::service::phy::ofdma::Notification*>(phy);
00463     notificationService->registerHandler(this);
00464 }
00465 
00466 
00467 
00468 wns::service::phy::ofdma::Notification*
00469 PhyUser::getNotificationService() const
00470 {
00471     assure(notificationService, "no ofdma::Notification set. Did you call setNotificationService()?");
00472     return notificationService;
00473 }
00474 
00475 
00476 
00477 void
00478 PhyUser::setMACAddress(const wns::service::dll::UnicastAddress& _address)
00479 {
00480     address = _address;
00481     LOG_INFO( "setting MAC address of PhyUser to: ", address );
00482 }
00483 
00484 bool PhyUser::filter( const wns::ldk::CompoundPtr& compound)
00485 {
00486     PhyUserCommand* phyCommand = getCommand( compound->getCommandPool() );
00487 
00488 
00489     // reject own compounds
00490     if ( phyCommand->peer.source_ == friends_.layer->getNode() )
00491         return false;
00492 
00493 
00494     // SS should receive all broadcasts
00495     if( friends_.layer->getStationType() != wns::service::dll::StationTypes::AP() )
00496     {
00497         ConnectionIdentifier::Ptr rngCI;
00498         rngCI = friends_.connectionManager->getConnectionWithID(0);
00499 
00500         if(rngCI == NULL)
00501         {
00502             if(phyCommand->magic.frameHead_)
00503             {
00504                 // Receive frame head from other BSs while not associated
00505                 return true;
00506             }
00507             else
00508             {
00509                 // Do not receive other broadcasts like MAPs
00510                 return false;
00511             }
00512 
00513         }
00514         if ( !phyCommand->peer.destination_       //broadcast
00515                 && ( phyCommand->magic.sourceComponent_->getID()
00516                     == rngCI->baseStation_ )                // from our BaseStation
00517             )
00518         {
00519             return true;
00520         }
00521     }
00522 
00523     // Receive all compounds for us
00524     if ( phyCommand->peer.destination_ )  //no broadcast
00525     {
00526         if ( phyCommand->peer.destination_ == friends_.layer->getNode() ) //for us
00527         {
00528             // return true;
00529 
00530             wns::ldk::ClassifierCommand* cCommand;
00531             cCommand = friends_.connectionClassifier->getCommand(compound->getCommandPool());
00532 
00533             if(   (friends_.connectionManager->getConnectionWithID(cCommand->peer.id))
00534                 || (cCommand->peer.id == 0) )
00535             {   //Only receive compounds for a registered CID
00543                 return true;
00544             }
00545         }
00546         else // probe interference in BS
00547         {
00548             // Currently only OFDM is supported so only subChannel 0 is used
00549             if(friends_.layer->getStationType() == wns::service::dll::StationTypes::AP()
00550                 && phyCommand->local.pAFunc_->timeSlot_ >= 0
00551                 && phyCommand->local.pAFunc_->subBand_ == 0)
00552             {
00553                 int slot = phyCommand->local.pAFunc_->timeSlot_;
00554                 wns::Power rxPower = phyCommand->magic.rxMeasurement->getRxPower(); 
00555                 if(slot != lastInterferenceSlot)
00556                 {
00557                     if(lastInterferenceSlot >= 0)
00558                     {
00559                         LOG_INFO( "Storing interference for slot: ", lastInterferenceSlot, " ",  
00560                             interferenceForSlot);
00561         
00562                         friends_.layer->getManagementService<service::InterferenceCache>(
00563                             "interferenceCache")->storeInterference(friends_.layer->getNode(),
00564                                                     interferenceForSlot,
00565                                                     service::InterferenceCache::Local, 
00566                                                     lastInterferenceSlot);
00567                     }
00568                     lastInterferenceSlot = slot;
00569                     interferenceForSlot = wns::Power::from_dBm(-200.0);
00570                 }
00571 
00572                 interferenceForSlot += rxPower;
00573                 LOG_INFO( "Added interference from: ", 
00574                     phyCommand->peer.source_->getName(), " ",
00575                     rxPower, " total in slot ", slot, " is ",  interferenceForSlot);
00576             }
00577         }
00578     }
00579 
00580     return false;
00581 }
00582 
00583 void
00584 PhyUser::traceIncoming(wns::ldk::CompoundPtr compound, wns::service::phy::power::PowerMeasurementPtr rxPowerMeasurement)
00585 {
00586     wns::probe::bus::json::Object objdoc;
00587 
00588     PhyUserCommand* myCommand = getCommand(compound->getCommandPool());
00589 
00590     objdoc["Transmission"]["ReceiverID"] = 
00591         wns::probe::bus::json::String(getFUN()->getLayer()->getNodeName());
00592     objdoc["Transmission"]["SenderID"] = 
00593         wns::probe::bus::json::String(myCommand->peer.source_->getName());
00594     objdoc["Transmission"]["SourceID"] = 
00595         wns::probe::bus::json::String(myCommand->peer.source_->getName());
00596     if(myCommand->peer.destination_ == NULL)
00597     {
00598         objdoc["Transmission"]["DestinationID"] = 
00599             wns::probe::bus::json::String("Broadcast");
00600     }
00601     else
00602     {
00603         objdoc["Transmission"]["DestinationID"] = 
00604             wns::probe::bus::json::String(myCommand->peer.destination_->getName());
00605     }
00606 
00607     objdoc["Transmission"]["Start"] = 
00608         wns::probe::bus::json::Number(myCommand->local.pAFunc_->transmissionStart_);
00609     objdoc["Transmission"]["Stop"] = 
00610         wns::probe::bus::json::Number(myCommand->local.pAFunc_->transmissionStop_);
00611     objdoc["Transmission"]["Subchannel"] = 
00612         wns::probe::bus::json::Number(myCommand->local.pAFunc_->subBand_);
00613     objdoc["Transmission"]["TxPower"] = 
00614         wns::probe::bus::json::Number(rxPowerMeasurement->getTxPower().get_dBm());
00615     objdoc["Transmission"]["RxPower"] = 
00616         wns::probe::bus::json::Number(rxPowerMeasurement->getRxPower().get_dBm());
00617     objdoc["Transmission"]["InterferencePower"] = 
00618         wns::probe::bus::json::Number(rxPowerMeasurement->getInterferencePower().get_dBm());
00619 
00620     if (myCommand->peer.estimatedCQI.carrier != wns::Power() &&
00621         myCommand->peer.estimatedCQI.interference != wns::Power())
00622     {
00623         objdoc["SINREst"]["C"] = 
00624             wns::probe::bus::json::Number(myCommand->peer.estimatedCQI.carrier.get_dBm());
00625         objdoc["SINREst"]["I"] = 
00626             wns::probe::bus::json::Number(myCommand->peer.estimatedCQI.interference.get_dBm());
00627     }
00628     wns::probe::bus::json::probeJSON(probes_.jsonTracing, objdoc);
00629 }
00630 
00631 

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