User Manual, Developers Guide and API Documentation

FrameSynchronization.cpp

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 #include <WIFIMAC/convergence/FrameSynchronization.hpp>
00030 #include <WIFIMAC/convergence/PhyUser.hpp>
00031 #include <WIFIMAC/convergence/PreambleGenerator.hpp>
00032 #include <WIFIMAC/convergence/ErrorModelling.hpp>
00033 #include <WIFIMAC/convergence/TxDurationSetter.hpp>
00034 
00035 #include <WNS/ldk/Layer.hpp>
00036 #include <WNS/ldk/crc/CRC.hpp>
00037 #include <WNS/probe/bus/utils.hpp>
00038 #include <WNS/probe/bus/json/probebus.hpp>
00039 
00040 #include <WNS/service/dll/StationTypes.hpp>
00041 
00042 #include <DLL/Layer2.hpp>
00043 #include <DLL/StationManager.hpp>
00044 
00045 #include <sstream>
00046 
00047 using namespace wifimac::convergence;
00048 
00049 STATIC_FACTORY_REGISTER_WITH_CREATOR(
00050     FrameSynchronization,
00051     wns::ldk::probe::Probe,
00052     "wifimac.convergence.FrameSynchronization",
00053     wns::ldk::FUNConfigCreator);
00054 
00055 STATIC_FACTORY_REGISTER_WITH_CREATOR(
00056     FrameSynchronization,
00057     wns::ldk::FunctionalUnit,
00058     "wifimac.convergence.FrameSynchronization",
00059     wns::ldk::FUNConfigCreator);
00060 
00061 FrameSynchronization::FrameSynchronization(wns::ldk::fun::FUN* fun, const wns::pyconfig::View& config):
00062     wns::ldk::fu::Plain<FrameSynchronization, FrameSynchronizationCommand>(fun),
00063     wns::ldk::probe::Probe(),
00064 
00065     logger(config.get("logger")),
00066     curState(Idle),
00067     synchronizedToAddress(),
00068     slcCapture(config.get<wns::Ratio>("myConfig.slcCapture")),
00069     slgCapture(config.get<wns::Ratio>("myConfig.slgCapture")),
00070     idleCapture(config.get<wns::Ratio>("myConfig.idleCapture")),
00071     detectionThreshold(config.get<wns::Ratio>("myConfig.detectionThreshold")),
00072     signalRxErrorAlthoughNotSynchronized(config.get<bool>("myConfig.signalRxErrorAlthoughNotSynchronized")),
00073     lastFrameEnd(0),
00074     managerName(config.get<std::string>("managerName")),
00075     crcCommandName(config.get<std::string>("crcCommandName")),
00076     phyUserCommandName(config.get<std::string>("phyUserCommandName")),
00077     errorModellingCommandName(config.get<std::string>("errorModellingCommandName")),
00078     txDurationProviderCommandName(config.get<std::string>("txDurationProviderCommandName")),
00079     sinrMIBServiceName(config.get<std::string>("sinrMIBServiceName")),
00080     numSpatialStreamsLastPreambleFragment(0)
00081 {
00082     // read the localIDs from the config
00083     wns::probe::bus::ContextProviderCollection localContext(&fun->getLayer()->getContextProviderCollection());
00084     for (int ii = 0; ii<config.len("localIDs.keys()"); ++ii)
00085     {
00086         std::string key = config.get<std::string>("localIDs.keys()",ii);
00087         unsigned long int value  = config.get<unsigned long int>("localIDs.values()",ii);
00088         localContext.addProvider(wns::probe::bus::contextprovider::Constant(key, value));
00089         MESSAGE_SINGLE(VERBOSE, logger, "Using Local IDName '"<<key<<"' with value: "<<value);
00090     }
00091     successRateProbe = wns::probe::bus::collector(localContext, config, "successRateProbeName");
00092     sinrProbe = wns::probe::bus::collector(localContext, config, "sinrProbeName");
00093     perProbe = wns::probe::bus::collector(localContext, config, "perProbeName");
00094     jsonTracing = wns::probe::bus::collector(localContext, config, "phyTraceProbeName");
00095 }
00096 
00097 FrameSynchronization::~FrameSynchronization()
00098 {
00099 
00100 }
00101 
00102 void FrameSynchronization::doSendData(const wns::ldk::CompoundPtr& compound)
00103 {
00104     // Stop any synchronization
00105     switch(curState)
00106     {
00107     case Idle:
00108         break;
00109     case Synchronized:
00110         // signal end of frame to each observer
00111         MESSAGE_SINGLE(NORMAL, logger, "Send data during decoding -> signal rx error");
00112         this->wns::Subject<IRxStartEnd>::forEachObserver(OnRxStartEnd(0, false, true));
00113         // Fall through to set state to Idle
00114     case waitForFinalDelivery:
00115     case Garbled:
00116         MESSAGE_SINGLE(NORMAL, logger, "Send data during reception -> reset curState to idle");
00117         lastFrameEnd = wns::simulator::getEventScheduler()->getTime();
00118         cancelTimeout();
00119         curState = Idle;
00120         synchronizedToAddress = wns::service::dll::UnicastAddress();
00121         numSpatialStreamsLastPreambleFragment = 0;
00122         break;
00123     default:
00124         assure(false, "Unknown state");
00125     }
00126 
00127     // pass through
00128     getConnector()->getAcceptor(compound)->sendData(compound);
00129 }
00130 
00131 void FrameSynchronization::doOnData(const wns::ldk::CompoundPtr& compound)
00132 {
00133 #ifndef NDEBUG
00134     if(jsonTracing->hasObservers())
00135         traceIncoming(compound);
00136 #endif
00137 
00138     if(friends.manager->getFrameType(compound->getCommandPool()) == PREAMBLE)
00139     {
00140         this->processPreamble(compound);
00141     }
00142     else
00143     {
00144         this->processPSDU(compound);
00145     }
00146 }
00147 
00148 void FrameSynchronization::processPreamble(const wns::ldk::CompoundPtr& compound)
00149 {
00150     assure(friends.manager->getFrameType(compound->getCommandPool()) == PREAMBLE,
00151            "called processPreamble for non-preamble");
00152 
00153     bool crcOk = getFUN()->getCommandReader(crcCommandName)->readCommand<wns::ldk::crc::CRCCommand>(compound->getCommandPool())->local.checkOK;
00154 
00155     wns::simulator::Time fDur = friends.manager->getFrameExchangeDuration(compound->getCommandPool());
00156 
00157     wns::Ratio sinr = getFUN()->getCommandReader(phyUserCommandName)->
00158         readCommand<wifimac::convergence::PhyUserCommand>(compound->getCommandPool())->getCIR();
00159 
00160     if(sinr < detectionThreshold)
00161     {
00162         MESSAGE_SINGLE(NORMAL, logger, "ProcessPreamble(idle), SINR= " << sinr << " below detection threshold -> DROP");
00163         return;
00164     }
00165 
00166     if(curState == Synchronized and
00167        friends.manager->getTransmitterAddress(compound->getCommandPool()) == this->synchronizedToAddress)
00168     {
00169          MESSAGE_BEGIN(NORMAL, logger, m, "Received LTF from ");
00170          m << friends.manager->getTransmitterAddress(compound->getCommandPool());
00171          m << " with ";
00172          m << friends.manager->getPhyMode(compound->getCommandPool()).getNumberOfSpatialStreams();
00173          m << " spatial streams";
00174          MESSAGE_END();
00175 
00176         if(friends.manager->getPhyMode(compound->getCommandPool()).getNumberOfSpatialStreams() != (numSpatialStreamsLastPreambleFragment+1))
00177         {
00178             MESSAGE_BEGIN(NORMAL, logger, m, "Received LTF with ");
00179             m << friends.manager->getPhyMode(compound->getCommandPool()).getNumberOfSpatialStreams();
00180             m << " spatial streams, but waiting for ";
00181             m << numSpatialStreamsLastPreambleFragment+1;
00182             m << " -> DROP";
00183             MESSAGE_END();
00184             return;
00185         }
00186         ++numSpatialStreamsLastPreambleFragment;
00187 
00188         // the preamble comes from the same transmitter as the current
00189         // synchronization
00190         assure(wns::simulator::getEventScheduler()->getTime() + fDur <= lastFrameEnd + 1e-9,
00191                "Received LTF tries to extend the synchronization time: Now" << wns::simulator::getEventScheduler()->getTime() << ", fDur " << fDur << ", lfe " << lastFrameEnd);
00192         //this->syncToNewPreamble(fDur, synchronizedToAddress);
00193         // deliver LTF
00194         getDeliverer()->getAcceptor(compound)->onData(compound);
00195         return;
00196     }
00197 
00198     // preamble from difference receiver
00199     if(friends.manager->getPhyMode(compound->getCommandPool()).getNumberOfSpatialStreams() > 1)
00200     {
00201         MESSAGE_SINGLE(NORMAL, logger, "Received LTF, but no preamble with one stream -> DROP");
00202         return;
00203     }
00204 
00205 
00206     wns::Ratio captureThreshold;
00207     switch(curState)
00208     {
00209     case Idle:
00210         MESSAGE_SINGLE(NORMAL, logger, "ProcessPreamble(idle), SINR= " << sinr << " CRC " << crcOk);
00211         assure(lastFrameEnd <= wns::simulator::getEventScheduler()->getTime(), "State is idle, but last frame has not finished");
00212         assure(!this->hasTimeoutSet(), "State is idle, but timeout is set");
00213         captureThreshold = idleCapture;
00214         break;
00215 
00216     case Synchronized:
00217         MESSAGE_SINGLE(NORMAL, logger, "processPreamble(synchronized), SINR= " << sinr << " CRC " << crcOk);
00218         assure(lastFrameEnd >= wns::simulator::getEventScheduler()->getTime(), "State is synchronized, but lastFrameEnd is over");
00219         assure(this->hasTimeoutSet(), "State is decoding, but no timeout set");
00220         captureThreshold = slcCapture;
00221         break;
00222 
00223     case waitForFinalDelivery:
00224         MESSAGE_SINGLE(NORMAL, logger, "processPreamble(waitForFinalDelivery), SINR= " << sinr << " CRC " << crcOk);
00225         assure(this->hasTimeoutSet(), "State is waitForFinalDelivery, but no timeout set");
00226         assure(lastFrameEnd+10e-9 >= wns::simulator::getEventScheduler()->getTime(), "State is waitForFinalDelivery, but lastFrameEnd is over");
00227         captureThreshold = slcCapture;
00228         break;
00229 
00230     case Garbled:
00231         MESSAGE_SINGLE(NORMAL, logger, "processPreamble(garbled), SINR= " << sinr << " CRC " << crcOk);
00232         assure(this->hasTimeoutSet(), "State is garbled, but no timeout set");
00233         assure(lastFrameEnd >= wns::simulator::getEventScheduler()->getTime(), "State is garbled, but lastFrameEnd is over");
00234         captureThreshold = slgCapture;
00235         break;
00236 
00237     default:
00238         assure(false, "Unknown state");
00239     }
00240 
00241     if (sinr > captureThreshold)
00242     {
00243         // capture has taken place
00244         if(curState == Synchronized)
00245         {
00246             // signal end of frame to each observer
00247             MESSAGE_SINGLE(NORMAL, logger, "ProcessPreamble -> Capture current decoding, signal rx end");
00248             this->wns::Subject<IRxStartEnd>::forEachObserver(OnRxStartEnd(0, false, true));
00249         }
00250 
00251         if(crcOk)
00252         {
00253             this->syncToNewPreamble(fDur, friends.manager->getTransmitterAddress(compound->getCommandPool()));
00254             // deliver preamble
00255             getDeliverer()->getAcceptor(compound)->onData(compound);
00256         }
00257         else
00258         {
00259             this->failedSyncToNewPreamble(fDur);
00260         }
00261     }
00262     else
00263     {
00264         if ((curState == Synchronized) or (curState == waitForFinalDelivery))
00265         {
00266             // special handling if the state is synchronized:
00267             // Wait for the end of the current frame, and then change into the garbled state if neccessary
00268             if(wns::simulator::getEventScheduler()->getTime() + fDur > lastFrameEnd)
00269             {
00270                 lastFrameEnd = wns::simulator::getEventScheduler()->getTime() + fDur;
00271                 MESSAGE_SINGLE(NORMAL, logger, "Rx preamble while synchronized, but no capture, decode frame and then garbled until " << lastFrameEnd);
00272             }
00273             else
00274             {
00275                 MESSAGE_SINGLE(NORMAL, logger, "Rx preamble while synchronized, no capture, frame is shorter than current one");
00276             }
00277         }
00278         else
00279         {
00280             this->failedSyncToNewPreamble(fDur);
00281         }
00282     }
00283 }
00284 
00285 void FrameSynchronization::failedSyncToNewPreamble(wns::simulator::Time fDur)
00286 {
00287     if((wns::simulator::getEventScheduler()->getTime() + fDur) > lastFrameEnd)
00288     {
00289         lastFrameEnd = wns::simulator::getEventScheduler()->getTime() + fDur;
00290         this->setNewTimeout(fDur);
00291         MESSAGE_SINGLE(NORMAL, logger, "Rx preamble, but no sync possible -> garbled until " << lastFrameEnd);
00292     }
00293     else
00294     {
00295         assure(this->hasTimeoutSet(), "lastFrameEnd is not over, but no timeout set");
00296         MESSAGE_SINGLE(NORMAL, logger, "Rx another preamble, but no sync possible -> garbled for " << fDur << " and afterwards until " << lastFrameEnd);
00297     }
00298     this->synchronizedToAddress = wns::service::dll::UnicastAddress();
00299     numSpatialStreamsLastPreambleFragment = 0;
00300     curState = Garbled;
00301 }
00302 
00303 void FrameSynchronization::syncToNewPreamble(const wns::simulator::Time fDur, const wns::service::dll::UnicastAddress transmitter)
00304 {
00305     MESSAGE_SINGLE(NORMAL, logger, "Rx preamble from " << transmitter << ", signal rxStart");
00306     assure(fDur > 0, "Preamble must have duration larger than zero");
00307     this->wns::Subject<IRxStartEnd>::forEachObserver(OnRxStartEnd(fDur, true, false));
00308 
00309     this->setNewTimeout(fDur);
00310 
00311     if(((wns::simulator::getEventScheduler()->getTime() + fDur) >= lastFrameEnd)
00312        or
00313        (lastFrameEnd - (wns::simulator::getEventScheduler()->getTime() + fDur) < 0.000001))
00314     {
00315         // only change lastFrameEnd if the new frame is longer than the current one
00316         lastFrameEnd = wns::simulator::getEventScheduler()->getTime() + fDur;
00317         MESSAGE_SINGLE(NORMAL, logger, "Rx preamble, synced until " << lastFrameEnd);
00318     }
00319     else
00320     {
00321         MESSAGE_SINGLE(NORMAL, logger, "Rx preamble, synced for " << fDur << ", afterwards garbled until " << lastFrameEnd);
00322     }
00323     this->synchronizedToAddress = transmitter;
00324     curState = Synchronized;
00325     numSpatialStreamsLastPreambleFragment = 1;
00326 }
00327 
00328 void FrameSynchronization::onTimeout()
00329 {
00330     if(curState == Synchronized)
00331     {
00332         // finished reception
00333         MESSAGE_SINGLE(NORMAL, logger, "End of decoding, signal rxEnd");
00334         this->wns::Subject<IRxStartEnd>::forEachObserver(OnRxStartEnd(0, false, false));
00335         curState = waitForFinalDelivery;
00336         setTimeout(10e-9);
00337         return;
00338     }
00339 
00340     // Frame reception as indicated by the preamble is over, stop synchronization
00341     if(lastFrameEnd > wns::simulator::getEventScheduler()->getTime())
00342     {
00343         // there are still active transmissions, but the preamble was missed
00344         curState = Garbled;
00345         this->setTimeout(lastFrameEnd-wns::simulator::getEventScheduler()->getTime());
00346         MESSAGE_SINGLE(NORMAL, logger, "End of frame, change state to garbled until " << lastFrameEnd);
00347     }
00348     else
00349     {
00350         MESSAGE_SINGLE(NORMAL, logger, "End of frame, change state to idle");
00351         curState = Idle;
00352     }
00353     this->synchronizedToAddress = wns::service::dll::UnicastAddress();
00354     numSpatialStreamsLastPreambleFragment = 0;
00355 }
00356 
00357 void FrameSynchronization::processPSDU(const wns::ldk::CompoundPtr& compound)
00358 {
00359     assure(friends.manager->getFrameType(compound->getCommandPool()) != PREAMBLE,
00360            "called processPSDU for non-psdu");
00361 
00362     MESSAGE_BEGIN(NORMAL, logger, m, "");
00363     m << "Received psdu. Synchronized: " << (curState == Synchronized or curState == waitForFinalDelivery);
00364     m << "; Transmitter ok: " << (friends.manager->getTransmitterAddress(compound->getCommandPool()) == this->synchronizedToAddress);
00365     m << "; CRC ok: " << (getFUN()->getCommandReader(crcCommandName)->
00366                           readCommand<wns::ldk::crc::CRCCommand>(compound->getCommandPool())->
00367                           local.checkOK);
00368     MESSAGE_END();
00369 
00370     wns::Ratio sinr = getFUN()->getCommandReader(phyUserCommandName)->
00371         readCommand<wifimac::convergence::PhyUserCommand>(compound->getCommandPool())->getCIRwithoutMIMO();
00372     sinrProbe->put(compound, sinr.get_dB());
00373 
00374     double per = getFUN()->getCommandReader(errorModellingCommandName)->
00375         readCommand<wifimac::convergence::ErrorModellingCommand>(compound->getCommandPool())->getErrorRate();
00376     perProbe->put(compound, per);
00377 
00378     if((curState == Synchronized or curState == waitForFinalDelivery) and
00379        (friends.manager->getTransmitterAddress(compound->getCommandPool()) == this->synchronizedToAddress))
00380     {
00381         if(getFUN()->getCommandReader(crcCommandName)->readCommand<wns::ldk::crc::CRCCommand>(compound->getCommandPool())->local.checkOK)
00382         {
00383             MESSAGE_SINGLE(NORMAL, logger, "Received matching psdu for current synchronization");
00384             sinrMIB->putMeasurement(friends.manager->getTransmitterAddress(compound->getCommandPool()), sinr);
00385             successRateProbe->put(compound, 1);
00386 
00387             MESSAGE_SINGLE(NORMAL,logger,"lastFrameEnd: " << lastFrameEnd << " current time: " << wns::simulator::getEventScheduler()->getTime() << " -> till frame end: " << lastFrameEnd-wns::simulator::getEventScheduler()->getTime());
00388             if ((lastFrameEnd-wns::simulator::getEventScheduler()->getTime() < 10e-9) 
00389                 and
00390                 (curState == Synchronized))
00391             {
00392                 MESSAGE_SINGLE(NORMAL,logger," frame end reached, cancel timeout on last PSDU");
00393                 cancelTimeout();
00394                 onTimeout();
00395             }
00396 
00397             getDeliverer()->getAcceptor(compound)->onData(compound);
00398         }
00399         else
00400         {
00401             MESSAGE_SINGLE(NORMAL, logger, "Received (synchronized) psdu, but CRC error -> DROP");
00402             successRateProbe->put(compound, 0);
00403             // Signal rxError event
00404             this->wns::Subject<IRxStartEnd>::forEachObserver(OnRxStartEnd(0, false, true));
00405         }
00406     }
00407     else
00408     {
00409         MESSAGE_SINGLE(NORMAL, logger, "Received psdu, but not synchronized -> DROP");
00410         successRateProbe->put(compound, 0);
00411         // signal rxError only in case the user specifically asked for this kind
00412         // of strange behavior (i.e. not synchronized --> CRC cannot be checked
00413         // at all!
00414         if(this->signalRxErrorAlthoughNotSynchronized)
00415         {
00416             this->wns::Subject<IRxStartEnd>::forEachObserver(OnRxStartEnd(0, false, true));
00417         }
00418     }
00419 
00420     // delivery occured
00421     if((curState == waitForFinalDelivery) and (friends.manager->getTransmitterAddress(compound->getCommandPool()) == this->synchronizedToAddress))
00422     {
00423         assure(hasTimeoutSet(), "State is waitForFinalDelivery, but no timeout set");
00424         cancelTimeout();
00425         onTimeout();
00426     }
00427 }
00428 
00429 void FrameSynchronization::onFUNCreated()
00430 {
00431     sinrMIB = getFUN()->getLayer<dll::ILayer2*>()->getManagementService<wifimac::management::SINRInformationBase>(sinrMIBServiceName);
00432     friends.manager = getFUN()->findFriend<wifimac::lowerMAC::Manager*>(managerName);
00433 
00434 }
00435 
00436 bool FrameSynchronization::doIsAccepting(const wns::ldk::CompoundPtr& compound) const
00437 {
00438     return getConnector()->hasAcceptor(compound);
00439 }
00440 
00441 void FrameSynchronization::doWakeup()
00442 {
00443     getReceptor()->wakeup();
00444 }
00445 
00446 void
00447 FrameSynchronization::traceIncoming(wns::ldk::CompoundPtr compound)
00448 {
00449     wns::probe::bus::json::Object objdoc;
00450 
00451     // Can be invalid => Broadcast
00452     wns::service::dll::UnicastAddress dstAdr = 
00453         friends.manager->getReceiverAddress(compound->getCommandPool());
00454 
00455     wns::service::dll::UnicastAddress srcAdr = 
00456         friends.manager->getTransmitterAddress(compound->getCommandPool());
00457     assure(srcAdr.isValid(), "Source address not set");
00458 
00459     wns::service::dll::UnicastAddress myAdr = friends.manager->getMACAddress();
00460     assure(srcAdr.isValid(), "MAC address not set");
00461 
00462     // Can be used to distiguish hop and e2e
00463     wns::service::dll::UnicastAddress senderAdr = 
00464         friends.manager->getTransmitterAddress(compound->getCommandPool());
00465     assure(senderAdr.isValid(), "Sender address not set");
00466 
00467     dll::ILayer2* srcLayer;
00468     dll::ILayer2* dstLayer;
00469     dll::ILayer2* senderLayer;
00470     dll::ILayer2* myLayer;
00471 
00472     myLayer = getFUN()->getLayer<dll::ILayer2*>();
00473     srcLayer = myLayer->getStationManager()->getStationByMAC(srcAdr);
00474     if(dstAdr.isValid())
00475         dstLayer = myLayer->getStationManager()->getStationByMAC(dstAdr);
00476     senderLayer = myLayer->getStationManager()->getStationByMAC(senderAdr);
00477 
00478     std::string src;
00479     std::string dst("Broadcast");
00480     std::string me;
00481     std::string sender;
00482 
00483     if(myLayer->getStationType() == wns::service::dll::StationTypes::UT())
00484     {
00485         std::stringstream s;
00486         s << "UT" << myAdr;
00487         me = s.str();
00488     }
00489     else
00490     {
00491         std::stringstream s;
00492         s << "BS" << myAdr;
00493         me = s.str();
00494     }
00495     if(srcLayer->getStationType() == wns::service::dll::StationTypes::UT())
00496     {
00497         std::stringstream s;
00498         s << "UT" << srcAdr;
00499         src = s.str();
00500     }
00501     else
00502     {
00503         std::stringstream s;
00504         s << "BS" << srcAdr;
00505         src = s.str();
00506     }
00507     if(dstAdr.isValid())
00508     {
00509         std::stringstream s;
00510         if(dstLayer->getStationType() == wns::service::dll::StationTypes::UT())
00511         {
00512             s << "UT" << dstAdr;
00513             dst = s.str();
00514         }
00515         else
00516         {
00517             s << "BS" << srcAdr;
00518             dst = s.str();
00519         }
00520     }
00521     if(senderLayer->getStationType() == wns::service::dll::StationTypes::UT())
00522     {
00523         std::stringstream s;
00524         s << "UT" << senderAdr;
00525         sender = s.str();
00526     }
00527     else
00528     {
00529         std::stringstream s;
00530         s << "BS" << senderAdr;
00531         sender = s.str();
00532     }
00533 
00534     objdoc["Transmission"]["ReceiverID"] = wns::probe::bus::json::String(me);
00535     objdoc["Transmission"]["SenderID"] = wns::probe::bus::json::String(sender);
00536     objdoc["Transmission"]["SourceID"] = wns::probe::bus::json::String(src);
00537     objdoc["Transmission"]["DestinationID"] = wns::probe::bus::json::String(dst);
00538 
00539     wns::simulator::Time now = wns::simulator::getEventScheduler()->getTime();
00540     wns::simulator::Time frameTxDuration = 
00541         getFUN()->getCommandReader(txDurationProviderCommandName)->
00542             readCommand<wifimac::convergence::TxDurationProviderCommand>(
00543                 compound->getCommandPool())->getDuration();
00544 
00545     objdoc["Transmission"]["Start"] =
00546          wns::probe::bus::json::Number(now - frameTxDuration);
00547         
00548     objdoc["Transmission"]["Stop"] = wns::probe::bus::json::Number(now);
00549 
00550     // We abuse this to watch per station results
00551     objdoc["Transmission"]["Subchannel"] = wns::probe::bus::json::Number(srcAdr.getInteger());
00552     
00553 
00554     wns::Power rxPower = getFUN()->getCommandReader(phyUserCommandName)->
00555         readCommand<wifimac::convergence::PhyUserCommand>(
00556             compound->getCommandPool())->local.rxPower;
00557     wns::Power interference = getFUN()->getCommandReader(phyUserCommandName)->
00558         readCommand<wifimac::convergence::PhyUserCommand>(
00559             compound->getCommandPool())->local.interference;
00560 
00561     objdoc["Transmission"]["TxPower"] = 
00562         wns::probe::bus::json::Number(0.0); // Unknown
00563     objdoc["Transmission"]["RxPower"] = 
00564         wns::probe::bus::json::Number(rxPower.get_dBm());
00565     objdoc["Transmission"]["InterferencePower"] = 
00566         wns::probe::bus::json::Number(interference.get_dBm());
00567 
00568     wns::probe::bus::json::probeJSON(jsonTracing, objdoc);
00569 }
00570 

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