![]() |
User Manual, Developers Guide and API Documentation |
![]() |
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/macr/Scorer.hpp> 00029 #include <LTE/rlc/RLCCommand.hpp> 00030 00031 #include <WNS/ldk/CommandReaderInterface.hpp> 00032 00033 using namespace lte::macr; 00034 00035 Scorer::Scorer(const std::string& _modeName, const wns::pyconfig::View& config) : 00036 seen(), 00037 associationService(NULL), 00038 modeName(_modeName), 00039 logger(config.get("logger")), 00040 rlcReader(NULL) 00041 {} 00042 00043 Scorer::~Scorer() 00044 {} 00045 00046 lte::helper::Route 00047 Scorer::score(const wns::ldk::CompoundPtr& compound) 00048 { 00049 assure(associationService,"AssociationService has not been set in Scorer!"); 00050 assure(rlcReader,"RLC command Reader has not been set in Scorer!"); 00051 00052 lte::rlc::RLCCommand* rlcCommand = rlcReader->readCommand<lte::rlc::RLCCommand>(compound->getCommandPool()); 00053 lte::helper::Route route; 00054 route.modeName = this->modeName; 00055 00056 MESSAGE_BEGIN(VERBOSE, logger, m, "score "); 00057 m << lte::rlc::PacketDirection::toString(rlcCommand->local.direction) 00058 << " destination " 00059 << rlcCommand->peer.destination; 00060 MESSAGE_END(); 00061 00062 if(rlcCommand->local.direction == lte::rlc::PacketDirection::UPLINK()) { 00063 if (associationService->hasAssociation()){ 00064 route.score = 1.0; 00065 route.target = associationService->getAssociation(); 00066 00067 00068 MESSAGE_SINGLE(NORMAL, logger, "uplink Route.target is: "<< route.target); 00069 00070 00071 } else { 00072 route.score = -1.0; 00073 } 00074 } else if(lte::rlc::PacketDirection::DOWNLINK()) { 00075 if (hasRoute(rlcCommand->peer.destination)){ 00076 route.score = 1.0; 00077 route.target = seen[rlcCommand->peer.destination]; 00078 00079 00080 MESSAGE_SINGLE(NORMAL, logger, "downlink Route.target is: "<< route.target); 00081 00082 00083 00084 } else { 00085 route.score = -1.0; 00086 } 00087 } else { 00088 assure(false, "compound is neither in UPLINK, nor in DOWNLINK"); 00089 } 00090 00091 if (route.valid()) { 00092 MESSAGE_BEGIN(VERBOSE, logger, m, "score "); 00093 m << " direction " << lte::rlc::PacketDirection::toString(rlcCommand->local.direction) 00094 << " -> score " << route.score 00095 << " mode " << route.modeName 00096 << " target DLL Address " << route.target; 00097 MESSAGE_END(); 00098 } 00099 00100 return route; 00101 } 00102 00103 void 00104 Scorer::setRoute(const wns::service::dll::UnicastAddress& source, 00105 const wns::service::dll::UnicastAddress& receivedFrom) 00106 { 00107 seen[source] = receivedFrom; 00108 } 00109 00110 void 00111 Scorer::deleteRoute(const wns::service::dll::UnicastAddress& source) 00112 { 00113 assure(hasRoute(source), "Could not delete route"); 00114 seen.erase(source); 00115 } 00116 00117 bool 00118 Scorer::hasRoute(const wns::service::dll::UnicastAddress& source) 00119 { 00120 if (seen.find(source) != seen.end()) 00121 return true; 00122 else 00123 return false; 00124 } 00125 00126 wns::service::dll::UnicastAddress 00127 Scorer::getRoute(const wns::service::dll::UnicastAddress& source) 00128 { 00129 assure(hasRoute(source),"route could not found!"); 00130 return seen[source]; 00131 } 00132 00133 void 00134 Scorer::setAssociationService(dll::services::control::Association* service) 00135 { 00136 associationService = service; 00137 } 00138 00139 void 00140 Scorer::setRLC(wns::ldk::CommandReaderInterface* _rlcReader) 00141 { 00142 rlcReader = _rlcReader; 00143 }
1.5.5