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