User Manual, Developers Guide and API Documentation

UE.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. 16, 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/upperconvergence/UE.hpp>
00029 
00030 #include <LTE/controlplane/flowmanagement/IFlowManager.hpp>
00031 #include <LTE/rlc/RLCCommand.hpp>
00032 #include <LTE/helper/Keys.hpp>
00033 
00034 #include <DLL/StationManager.hpp>
00035 #define A2N(a) layer2->getStationManager()->getStationByMAC(a)->getName()
00036 
00037 using namespace lte::upperconvergence;
00038 
00039 STATIC_FACTORY_REGISTER_WITH_CREATOR(UEUpperConvergence,
00040                      wns::ldk::FunctionalUnit,
00041                                      "lte.UEUpperConvergence",
00042                      wns::ldk::FUNConfigCreator);
00043 
00044 
00045 UEUpperConvergence::UEUpperConvergence(wns::ldk::fun::FUN* _fun,
00046                        const wns::pyconfig::View& config) :
00047   dll::UTUpperConvergence(_fun, config),
00048   fun(_fun),
00049   rlcReader(NULL),
00050   layer2(NULL),
00051   flowManager(NULL),
00052   tlFlowHandler(NULL)
00053 {
00054     assure(fun, "FUN not set");
00055 }
00056 
00057 void
00058 UEUpperConvergence::onFUNCreated()
00059 {
00060     layer2 = fun->getLayer<dll::Layer2*>();
00061     assure(layer2, "Layer2 not set");
00062 
00063     flowManager = layer2->getControlService<lte::controlplane::flowmanagement::IFlowManagerUE>("FlowManagerUT");
00064 
00065     rlcReader   = fun->getCommandReader("rlc");
00066     assure(rlcReader, "rlcReader not set");
00067     MESSAGE_SINGLE(NORMAL, logger,"onFUNCreated(): FlowManager set to: "<< flowManager);
00068 }
00069 
00070 void
00071 UEUpperConvergence::sendData(const wns::service::dll::UnicastAddress& _peer,
00072                  const wns::osi::PDUPtr& pdu,
00073                  wns::service::dll::protocolNumber protocol,
00074                  wns::service::dll::FlowID _dllFlowID)
00075 {
00076   wns::ldk::ConstKeyPtr key(new lte::helper::key::FlowID(_dllFlowID));
00077   if(flowManager->isValidFlow(key))
00078     {
00079       wns::ldk::CompoundPtr compound(new wns::ldk::Compound(getFUN()->createCommandPool(), pdu));
00080       if (_peer.getInteger()==-1) {
00081     MESSAGE_SINGLE(NORMAL, logger,"Sending Compound with FlowID: "<< _dllFlowID<<" to: ?");
00082       } else {
00083     MESSAGE_SINGLE(NORMAL, logger,"Sending Compound with FlowID: "<< _dllFlowID<<" to: "<<A2N(_peer));
00084       }
00085       dll::UpperConvergence::sendData(_peer, pdu, protocol, _dllFlowID);
00086     } else {
00087     if (_peer.getInteger()==-1) {
00088       MESSAGE_SINGLE(NORMAL, logger,"Dropped Compound with FlowID: "<< _dllFlowID<<" to: ?, because unknown FlowID.");
00089     } else {
00090       MESSAGE_SINGLE(NORMAL, logger,"Dropped Compound with FlowID: "<< _dllFlowID<<" to: "<<A2N(_peer)<<" , because unknown FlowID.");
00091     }
00092   }
00093 }
00094 
00095 
00096 void
00097 UEUpperConvergence::processIncoming(const wns::ldk::CompoundPtr& compound)
00098 {
00099   //the FlowID is read out of the RLC command to be forwarded to the datahandler
00100   lte::rlc::RLCCommand* rlcCommand = rlcReader->readCommand<lte::rlc::RLCCommand>(compound->getCommandPool());
00101   assure(rlcCommand, "RlcCommand not set");
00102   int protocol = wns::service::dll::protocolNumberOf(compound->getData());
00103   
00104   MESSAGE_BEGIN(NORMAL, logger, m, getFUN()->getName());
00105   m << "UEUpperConv::processIncoming(), forwarding packet from "<<A2N(rlcCommand->peer.source)<<" to upper Component (IP), protocol "<<protocol;
00106   MESSAGE_END();
00107 
00108   if(protocol == 1)
00109     {
00110       dataHandlerRegistry.find(wns::service::dll::protocolNumberOf(compound->getData()))->onData(compound->getData(), rlcCommand->peer.flowID);
00111     }
00112   else
00113     {
00114       dataHandlerRegistry.find(wns::service::dll::protocolNumberOf(compound->getData()))->onData(compound->getData());
00115     }
00116   
00117   MESSAGE_BEGIN(VERBOSE, logger, m, getFUN()->getName());
00118   m << ": Compound backtrace"
00119     << compound->dumpJourney(); // JOURNEY
00120   MESSAGE_END();
00121 }
00122 
00123 void
00124 UEUpperConvergence::registerHandler(wns::service::dll::protocolNumber protocol,
00125                                     wns::service::dll::Handler* dh)
00126 {
00127   assureNotNull(dh);
00128   dataHandlerRegistry.insert(protocol, dh);
00129   
00130   MESSAGE_BEGIN(NORMAL, logger, m, getFUN()->getName());
00131   m << ": UEUpperConv registered dataHandler for protocol number " << protocol;
00132   MESSAGE_END();
00133 }
00134 
00135 void
00136 UEUpperConvergence::registerFlowHandler(wns::service::dll::FlowHandler* flowHandler)
00137 {
00138   tlFlowHandler = flowHandler;
00139   MESSAGE_SINGLE(NORMAL, logger, "TL-FlowHandler Registered: "<<flowHandler);
00140 }
00141 
00142 void
00143 UEUpperConvergence::establishFlow(wns::service::tl::FlowID flowID, wns::service::qos::QoSClass qosClass)
00144 {
00145   MESSAGE_SINGLE(NORMAL, logger, "FlowEstablishment called from TL for: " <<flowID);
00146   assure(flowManager, "FlowManager not set!");
00147   // if the default QoS class UNDEFINED is set in the traffic generator then change it to BACKGROUND
00148   if (qosClass == lte::helper::QoSClasses::UNDEFINED())
00149     qosClass = lte::helper::QoSClasses::BACKGROUND();
00150 
00151   flowManager->buildFlow(flowID,qosClass);
00152 } // establishFlow
00153 
00154 
00155 //after succesfully build of layer2-flow notify the TL
00156 void
00157 UEUpperConvergence::onFlowBuilt(wns::service::tl::FlowID _flowID,
00158                                 wns::service::dll::FlowID _dllFlowID,
00159                                 bool newFlow)
00160 {
00161   assure(tlFlowHandler, "TransportLayerFlowHandler not set!");
00162   if(newFlow)
00163     {
00164       MESSAGE_SINGLE(NORMAL, logger, "New Flow built: "<<_dllFlowID);
00165       tlFlowHandler->onFlowEstablished(_flowID, _dllFlowID);
00166     }
00167   else
00168     {
00169       MESSAGE_SINGLE(NORMAL, logger, "Flow changed for TLFlowID: "<<_flowID);
00170       tlFlowHandler->onFlowChanged(_flowID, _dllFlowID);
00171     }
00172 }
00173 
00174 
00175 void
00176 UEUpperConvergence::releaseFlow(wns::service::tl::FlowID flowID)
00177 {
00178   MESSAGE_SINGLE(NORMAL, logger, "Deleting Flow for TlFlowID: " <<flowID);
00179   assure(flowManager, "FlowManager not set!");
00180   flowManager->releaseFlow(flowID);
00181 } // releaseFlow

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