![]() |
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/Video.hpp> 00029 00030 using namespace applications::session::client; 00031 00032 STATIC_FACTORY_REGISTER_WITH_CREATOR(applications::session::client::Video, 00033 applications::session::Session, 00034 "client.Video", wns::PyConfigViewCreator); 00035 00036 Video::Video(const wns::pyconfig::View& _pyco) : 00037 Session(_pyco) 00038 { 00039 settlingTime = _pyco.get<wns::simulator::Time>("settlingTime"); 00040 00041 /* only for probing */ 00042 sessionType = video; 00043 00044 state = running; 00045 00046 sessionDelay = (*sessionDelayDistribution)(); 00047 MESSAGE_SINGLE(NORMAL, logger, "APPL: Delay before session starts: " << sessionDelay << ".\n"); 00048 00049 setTimeout(connectiontimeout, sessionDelay); 00050 setTimeout(probetimeout, windowSize); 00051 } 00052 00053 Video::~Video() 00054 { 00055 } 00056 00057 void 00058 Video::onData(const wns::osi::PDUPtr& _pdu) 00059 { 00060 state = running; 00061 00062 assureType(_pdu.getPtr(), applications::session::PDU*); 00063 00064 receivedPacketNumber = static_cast<applications::session::PDU*>(_pdu.getPtr())->getPacketNumber(); 00065 00066 MESSAGE_SINGLE(NORMAL, logger, "APPL: receivedPacketNumber = " << receivedPacketNumber << "."); 00067 00068 applications::session::Session::incomingProbesCalculation(_pdu); 00069 } 00070 00071 void 00072 Video::onTimeout(const Timeout& _t) 00073 { 00074 if(_t == statetimeout) 00075 { 00076 /* Sending request for Video. */ 00077 /* 1600 bit is the size of an URL */ 00078 packetSize = 1600; 00079 applications::session::PDU* applicationPDU = new applications::session::PDU(Bit(packetSize), pyco); 00080 00081 applicationPDU->setCreationTime(wns::simulator::getEventScheduler()->getTime()); 00082 00083 packetNumber = 1; 00084 applicationPDU->setPacketNumber(packetNumber, packetFrom); 00085 MESSAGE_SINGLE(NORMAL, logger, "APPL: PacketNumber = " << packetNumber << "."); 00086 00087 wns::osi::PDUPtr pdu(applicationPDU); 00088 00089 applications::session::Session::outgoingProbesCalculation(pdu); 00090 connection->sendData(pdu); 00091 00092 state = idle; 00093 } 00094 else if(_t == connectiontimeout) 00095 { 00096 packetFrom = "client.Video"; 00097 00098 /* Open connection */ 00099 binding->initBinding(); 00100 } 00101 else if(_t == probetimeout) 00102 { 00103 applications::session::Session::onTimeout(_t); 00104 } 00105 else 00106 { 00107 assure(false, "APPL: Unknown timout type =" << _t); 00108 } 00109 } 00110
1.5.5