![]() |
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 <APPLICATIONS/session/client/Session.hpp> 00029 00030 using namespace applications::session::client; 00031 00032 STATIC_FACTORY_REGISTER_WITH_CREATOR(applications::session::client::Session, 00033 applications::session::Session, 00034 "client.Session", wns::PyConfigViewCreator); 00035 00036 Session::Session(const wns::pyconfig::View& _pyco): 00037 session::Session(_pyco), 00038 sessionDelayDistribution(NULL), 00039 sessionDelay(0.0), 00040 establishedAt(0.0) 00041 { 00042 wns::pyconfig::View sDDConfig(_pyco, "sessionDelay"); 00043 std::string sDDName = sDDConfig.get<std::string>("__plugin__"); 00044 sessionDelayDistribution = wns::distribution::DistributionFactory::creator(sDDName)->create(sDDConfig); 00045 00046 stationType = CLIENT; 00047 } 00048 00049 Session::~Session() 00050 { 00051 if(sessionDelayDistribution != NULL) 00052 delete sessionDelayDistribution; 00053 sessionDelayDistribution = NULL; 00054 } 00055 00056 void 00057 Session::onData(const wns::osi::PDUPtr& _pdu) 00058 { 00059 } 00060 00061 void 00062 Session::onShutdown() 00063 { 00064 /* Session ended, because simulationtime is over. */ 00065 00066 state = sessionended; 00067 00068 cancelAllTimeouts(); 00069 00070 /* 00071 First condition checks if L2 connection was established. 00072 Second one checks if at least one PDU got through to create 00073 the server session. 00074 */ 00075 if(connection != NULL && receivedPacketNumber > 0) 00076 { 00077 binding->releaseBinding(connection); 00078 if(establishedAt > settlingTime) 00079 { 00080 MESSAGE_SINGLE(NORMAL, logger, "APPL: Connection established but after probing started!"); 00081 connectionProbe->put(0, 00082 boost::make_tuple("Appl.CellId", getCellId(senderId))); 00083 } 00084 else 00085 { 00086 MESSAGE_SINGLE(NORMAL, logger, "APPL: Connection was succesfully established!"); 00087 connectionProbe->put(1, 00088 boost::make_tuple("Appl.CellId", getCellId(senderId))); 00089 } 00090 } 00091 else 00092 { 00093 MESSAGE_SINGLE(NORMAL, logger, "APPL: No connection was established at the end of the session!"); 00094 connectionProbe->put(0); 00095 } 00096 00097 applications::session::Session::sessionProbesCalculation(); 00098 } 00099 00100 void 00101 Session::onConnectionEstablished(wns::service::tl::Connection* _connection) 00102 { 00103 /* Connection is ready, so start sending after session start delay. */ 00104 connection = _connection; 00105 establishedAt = wns::simulator::getEventScheduler()->getTime(); 00106 00107 MESSAGE_SINGLE(NORMAL, logger, "APPL: Connection established!"); 00108 00109 onTimeout(statetimeout); 00110 }
1.5.5