User Manual, Developers Guide and API Documentation

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

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