![]() |
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 #ifndef APPLICATIONS_SESSION_SESSION_HPP 00029 #define APPLICATIONS_SESSION_SESSION_HPP 00030 00031 #include <APPLICATIONS/session/Binding.hpp> 00032 #include <deque> 00033 #include <map> 00034 #include <APPLICATIONS/session/PDU.hpp> 00035 #include <WNS/simulator/Time.hpp> 00036 #include <WNS/distribution/Distribution.hpp> 00037 #include <WNS/logger/Logger.hpp> 00038 #include <WNS/events/MultipleTimeout.hpp> 00039 #include <WNS/Enum.hpp> 00040 #include <WNS/simulator/Bit.hpp> 00041 #include <WNS/probe/bus/ContextCollector.hpp> 00042 #include <WNS/probe/bus/ContextProvider.hpp> 00043 #include <WNS/probe/bus/ContextProviderCollection.hpp> 00044 #include <WNS/service/tl/Connection.hpp> 00045 #include <WNS/service/tl/DataHandler.hpp> 00046 #include <WNS/IOutputStreamable.hpp> 00047 00048 00049 namespace applications { 00050 namespace node { namespace component { 00051 class Component; 00052 } //namespace component 00053 } //namespace node 00054 namespace session { 00055 class Binding; 00056 00057 /* StationTypes are used to sort the Probes separated by clients and servers */ 00058 enum StationType 00059 { 00060 SERVER = 1, 00061 CLIENT = 2 00062 }; 00063 00064 /* SessionTypes are used to sort the Probes separated by SessionType */ 00065 enum SessionType 00066 { 00067 cbr = 1, 00068 email = 2, 00069 ftp = 3, 00070 voip = 4, 00071 video = 5, 00072 videotelephony = 6, 00073 videotrace = 7, 00074 www = 8, 00075 wimaxvideo = 9, 00076 wimaxvideotelephony = 10 00077 }; 00078 00079 /* States are used to see Sessionphase */ 00080 enum State 00081 { 00082 idle = 1, 00083 running = 2, 00084 sessionended = 3 00085 }; 00086 00087 /* Timeouts are used to set session and state timer and for windwed probes duration */ 00088 enum Timeout 00089 { 00090 statetimeout = 1, 00091 probetimeout = 2, 00092 sendtimeout = 3, 00093 receivetimeout = 4, 00094 frametimeout = 5, 00095 calltimeout = 6, 00096 connectiontimeout = 7, 00097 statetransitiontimeout = 8 00098 }; 00099 00100 class Session : 00101 public wns::service::tl::DataHandler, 00102 public wns::events::MultipleTimeout<Timeout>, 00103 public wns::IOutputStreamable 00104 { 00105 public: 00106 Session(const wns::pyconfig::View& _pyco); 00107 virtual ~Session(); 00108 00109 typedef wns::PyConfigViewCreator<Session, Session> Creator; 00110 typedef wns::StaticFactory<Creator> Factory; 00111 00112 virtual void 00113 onTimeout(const Timeout& _t); 00114 00115 virtual void 00116 onData(const wns::osi::PDUPtr& _pdu) = 0; 00117 00118 virtual void 00119 registerBinding(const applications::session::BindingPtr& _binding); 00120 00121 virtual void 00122 registerListener(applications::session::Binding* _listener); 00123 00124 virtual void 00125 registerComponent(applications::node::component::Component* _component, 00126 int _sessionIndex); 00127 00128 virtual void 00129 onConnectionEstablished(wns::service::tl::Connection* _connection); 00130 00131 virtual void 00132 incomingProbesCalculation(const wns::osi::PDUPtr& _pdu); 00133 00134 virtual void 00135 outgoingProbesCalculation(const wns::osi::PDUPtr& _pdu); 00136 00137 virtual void 00138 sessionProbesCalculation(); 00139 00140 virtual void 00141 iatProbesCalculation(); 00142 00143 virtual void 00144 onShutdown(); 00145 00146 virtual std::string 00147 doToString() const; 00148 00149 virtual void 00150 onPDUReceivedByPeer(const wns::osi::PDUPtr& _pdu); 00151 00152 virtual int 00153 getId(); 00154 00155 virtual int 00156 getCellId(int senderId); 00157 00158 protected: 00159 00160 /* WARNING: sessionStartTime should not be greater than settlingTime */ 00161 wns::simulator::Time sessionStartTime; 00162 wns::simulator::Time now; 00163 00164 /* Inter arrival Time distribution */ 00165 wns::simulator::Time iat;// [sek] 00166 00167 /* Packet Size distribution */ 00168 Bit packetSize;// [bit] 00169 int bitRate;// [bit/sek] 00170 00171 wns::logger::Logger logger; 00172 const wns::pyconfig::View pyco; 00173 applications::session::BindingPtr binding; 00174 applications::session::Binding* listener; 00175 applications::session::State state; 00176 00177 /* used to restart a session if simulationtime left */ 00178 applications::node::component::Component* component; 00179 int sessionIndex; 00180 00181 /* Same as NodeId */ 00182 int applId; 00183 00184 /* Peer Id */ 00185 int senderId; 00186 00187 /* used to tell the server which connection has to be used, 00188 if there are more clients then servers, e.g. there are less 00189 listenerBindings and the connection will be overwriten in 00190 the listenerBinding from each client. */ 00191 wns::service::tl::Connection* connection; 00192 00193 /* used to tell the client when to close the connection */ 00194 bool lastPacket; 00195 00196 /* Variables needed for Probes */ 00197 wns::probe::bus::ContextCollectorPtr incomingPacketSizeProbe; 00198 wns::probe::bus::ContextCollectorPtr outgoingPacketSizeProbe; 00199 wns::probe::bus::ContextCollectorPtr packetDelayProbe; 00200 wns::probe::bus::ContextCollectorPtr windowIncomingBitThroughputProbe; 00201 wns::probe::bus::ContextCollectorPtr windowOutgoingBitThroughputProbe; 00202 wns::probe::bus::ContextCollectorPtr windowIncomingPacketThroughputProbe; 00203 wns::probe::bus::ContextCollectorPtr windowOutgoingPacketThroughputProbe; 00204 wns::probe::bus::ContextCollectorPtr sessionIncomingBitThroughputProbe; 00205 wns::probe::bus::ContextCollectorPtr sessionOutgoingBitThroughputProbe; 00206 wns::probe::bus::ContextCollectorPtr sessionIncomingPacketThroughputProbe; 00207 wns::probe::bus::ContextCollectorPtr sessionOutgoingPacketThroughputProbe; 00208 wns::probe::bus::ContextCollectorPtr measuringDurationProbe; 00209 wns::probe::bus::ContextCollectorPtr iatProbe; 00210 wns::probe::bus::ContextCollectorPtr packetLossProbe; 00211 wns::probe::bus::ContextCollectorPtr userSatisfactionProbe; 00212 wns::probe::bus::ContextCollectorPtr connectionProbe; 00213 SessionType sessionType; 00214 StationType stationType; 00215 00216 /* counter variables for each packet */ 00217 Bit incomingPacketSize; 00218 Bit outgoingPacketSize; 00219 wns::simulator::Time packetDelay; 00220 wns::simulator::Time maxDelay; 00221 wns::simulator::Time iatStart; 00222 wns::simulator::Time iatEnd; 00223 wns::simulator::Time settlingTime; 00224 wns::simulator::Time probeEndTime; 00225 bool firstIatProbe; 00226 00227 /* counter variables for windowed probes*/ 00228 wns::simulator::Time windowSize; 00229 Bit windowedIncomingBitThroughput; 00230 Bit windowedOutgoingBitThroughput; 00231 int windowedIncomingPacketThroughput; 00232 int windowedOutgoingPacketThroughput; 00233 00234 /* counter variables for whole session */ 00235 int incomingPacketCounter; 00236 int outgoingPacketCounter; 00237 long int receivedPackets; 00238 long int receivedOnTimePackets; 00239 wns::simulator::Time measuringDuration; 00240 wns::simulator::Time sessionRunTime; 00241 Bit incomingPacketSizeCounter; 00242 Bit outgoingPacketSizeCounter; 00243 double packetLossRatio; 00244 double maxLossRatio; 00245 00246 long int packetNumber; 00247 long int lastPacketNumber; 00248 long int packetLossCounter; 00249 long int delayLossCounter; 00250 long int receivedPacketNumber; 00251 long int packetsDuringSettlingTime; 00252 00253 //TEST 00254 std::string packetFrom; 00255 int intWert; 00256 std::stringstream strings; 00257 std::string packetFromID; 00258 00259 }; 00260 } // namespace session 00261 } // namespace applications 00262 00263 #endif //APPLICATIONS_SESSION_SESSION_HPP
1.5.5