![]() |
User Manual, Developers Guide and API Documentation |
![]() |
00001 /****************************************************************************** 00002 * WiFiMAC (IEEE 802.11 and its alphabet soup) * 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/Layer2.hpp> 00030 00031 #include <WIFIMAC/pathselection/IPathSelection.hpp> 00032 #include <WIFIMAC/pathselection/Metric.hpp> 00033 #include <WIFIMAC/helper/contextprovider/CommandInformation.hpp> 00034 #include <WIFIMAC/helper/contextprovider/CompoundSize.hpp> 00035 #include <WNS/service/dll/StationTypes.hpp> 00036 #include <WNS/Assure.hpp> 00037 #include <DLL/StationManager.hpp> 00038 00039 using namespace wifimac; 00040 00041 STATIC_FACTORY_REGISTER_WITH_CREATOR(wifimac::Layer2, 00042 wns::node::component::Interface, 00043 "wifimac.Layer2", 00044 wns::node::component::ConfigCreator); 00045 00046 Layer2::Layer2(wns::node::Interface* _node, const wns::pyconfig::View& _config) : 00047 dll::Layer2(_node, _config, NULL), 00048 logger_(config.get("logger")), 00049 managers_() 00050 { 00051 MESSAGE_SINGLE(NORMAL, logger_, "creating station" << _node->getName() << " with ID " << this->stationID << " and type " << type); 00052 } 00053 00054 void Layer2::doStartup() 00055 { 00056 dll::Layer2::doStartup(); 00057 00058 } 00059 00060 void Layer2::onNodeCreated() 00061 { 00062 // Initialize management and control services 00063 getMSR()->onMSRCreated(); 00064 getCSR()->onCSRCreated(); 00065 00066 fun->onFUNCreated(); 00067 00068 // Create node-wide context providers and set them to zero 00069 this->setContext("MAC.STAAssociatedToAP", 0); 00070 this->setContext("MAC.WindowProbeHopCount", 0); 00071 this->setContext("MAC.WindowProbeAddress", 0); 00072 00073 // Add compound-based context providers 00074 // TODO: Readin names from configuration 00075 getNode()->getContextProviderCollection().addProvider( 00076 wifimac::helper::contextprovider::HopCount(fun, "ForwardingCommand")); 00077 getNode()->getContextProviderCollection().addProvider( 00078 wifimac::helper::contextprovider::SourceAddress(fun, "upperConvergence")); 00079 getNode()->getContextProviderCollection().addProvider( 00080 wifimac::helper::contextprovider::TargetAddress(fun, "upperConvergence")); 00081 getNode()->getContextProviderCollection().addProvider( 00082 wifimac::helper::contextprovider::IsUnicast(fun, "upperConvergence")); 00083 getNode()->getContextProviderCollection().addProvider( 00084 wifimac::helper::contextprovider::DataBitsPerSymbol(fun, "ManagerCommand")); 00085 getNode()->getContextProviderCollection().addProvider( 00086 wifimac::helper::contextprovider::SpatialStreams(fun, "ManagerCommand")); 00087 getNode()->getContextProviderCollection().addProvider( 00088 wifimac::helper::contextprovider::IsForMe(fun, "upperConvergence")); 00089 00090 // Add compound-size context providers 00091 getNode()->getContextProviderCollection().addProvider( 00092 wifimac::helper::contextprovider::CompleteLengthInBits()); 00093 getNode()->getContextProviderCollection().addProvider( 00094 wifimac::helper::contextprovider::CommandPoolLengthInBits()); 00095 getNode()->getContextProviderCollection().addProvider( 00096 wifimac::helper::contextprovider::DataLengthInBits()); 00097 00098 } 00099 00100 void 00101 Layer2::registerManager(wifimac::lowerMAC::Manager* manager, 00102 wns::service::dll::UnicastAddress address) 00103 { 00104 MESSAGE_SINGLE(NORMAL, logger_, "Register manager for transceiver with address " << address); 00105 00106 managers_.insert(address, manager); 00107 00108 // Register transceiver as an own station, if it has a different address 00109 if(address != this->getDLLAddress()) 00110 { 00111 assure(getStationType() != wns::service::dll::StationTypes::UT(), "UT do not support multiple addresses, because they have no support pathselection"); 00112 00113 this->getStationManager()->registerStation(this->stationID, address, this); 00114 00115 // Register transceiver at pathselection as an MP (it has no direct 00116 // connection to RANG) 00117 std::string psName = config.get<std::string>("pathSelectionServiceName"); 00118 wifimac::pathselection::IPathSelection* ps = this->getManagementService<wifimac::pathselection::IPathSelection>(psName); 00119 assure(ps, "PathSelection not found"); 00120 00121 ps->registerMP(address); 00122 // Hop-cost from this transceiver to the DLL is always for free and 00123 // works in both directions 00124 ps->createPeerLink(address, this->dll::Layer2::getDLLAddress(), 00125 wifimac::pathselection::Metric::Metric(0)); 00126 ps->createPeerLink(this->dll::Layer2::getDLLAddress(), address, 00127 wifimac::pathselection::Metric(0)); 00128 } 00129 } 00130 00131 bool 00132 Layer2::isTransceiverMAC(wns::service::dll::UnicastAddress address) 00133 { 00134 // So far only single transceiver 00135 return (managers_.knows(address)); 00136 } 00137 00138 void 00139 Layer2::onWorldCreated() 00140 { 00141 } 00142 00143 void 00144 Layer2::onShutdown() 00145 { 00146 }
1.5.5