P2PNSTestApp.cc

Go to the documentation of this file.
00001 //
00002 // Copyright (C) 2007 Institut fuer Telematik, Universitaet Karlsruhe (TH)
00003 //
00004 // This program is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU General Public License
00006 // as published by the Free Software Foundation; either version 2
00007 // of the License, or (at your option) any later version.
00008 //
00009 // This program is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 // GNU General Public License for more details.
00013 //
00014 // You should have received a copy of the GNU General Public License
00015 // along with this program; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 //
00018 
00024 #include "UnderlayConfiguratorAccess.h"
00025 #include "GlobalStatisticsAccess.h"
00026 #include "CommonMessages_m.h"
00027 
00028 #include "P2PNSTestApp.h"
00029 
00030 Define_Module(P2PNSTestApp);
00031 
00032 void P2PNSTestApp::initializeApp(int stage)
00033 {
00034     if (stage != MIN_STAGE_APP)
00035         return;
00036 
00037     // fetch parameters
00038     debugOutput = par("debugOutput");
00039     activeNetwInitPhase = par("activeNetwInitPhase");
00040 
00041     mean = par("messageDelay");
00042     deviation = mean / 10;
00043 
00044     underlayConfigurator = UnderlayConfiguratorAccess().get();
00045     globalStatistics = GlobalStatisticsAccess().get();
00046 
00047     // statistics
00048     numSent = 0;
00049 
00050     initRpcs();
00051     WATCH(numSent);
00052 
00053     // initiate test message emision
00054     //cMessage* p2pnstest_timer = new cMessage("p2pnstest_timer");
00055 
00056     //if (mean > 0) {
00057         //scheduleAt(simTime() + truncnormal(mean, deviation),
00058           //         p2pnstest_timer);
00059     //}
00060 }
00061 
00062 void P2PNSTestApp::handleRpcResponse(BaseResponseMessage* msg,
00063                                      cPolymorphic* context,
00064                                      int rpcId,
00065                                      simtime_t rtt)
00066 {
00067     RPC_SWITCH_START(msg)
00068     RPC_ON_RESPONSE( DHTputCAPI ) {
00069         handlePutResponse(_DHTputCAPIResponse);
00070         EV << "[P2PNSTestApp::handleRpcResponse()]\n"
00071            << "   DHT Put RPC Response received: id=" << rpcId
00072            << " msg=" << *_DHTputCAPIResponse << " rtt=" << rtt
00073            << endl;
00074         break;
00075     }
00076     RPC_SWITCH_END( )
00077 }
00078 
00079 void P2PNSTestApp::handlePutResponse(DHTputCAPIResponse* msg)
00080 {
00081     EV << "[P2PNSTestApp::handlePutResponse()]\n"
00082        << "   Received Put response!"
00083        << endl;
00084 }
00085 
00086 
00087 void P2PNSTestApp::handleTraceMessage(cMessage* msg)
00088 {
00089         throw cRuntimeError("P2PNSTestApp::handleTraceMessage(): Not implemented!");
00090 
00091         delete msg;
00092 }
00093 
00094 void P2PNSTestApp::handleTimerEvent(cMessage* msg)
00095 {
00096     if (msg->isName("p2pnstest_timer")) {
00097 
00098     } else {
00099         throw cRuntimeError("P2PNSTestApp::handleTimerEvent(): "
00100                              "Unknown event!");
00101     }
00102 
00103 }
00104 
00105 
00106 
00107 void P2PNSTestApp::finishApp()
00108 {
00109     globalStatistics->addStdDev("P2PNSTestApp: Sent Messages", numSent);
00110 }
00111 
Generated on Wed May 26 16:21:14 2010 for OverSim by  doxygen 1.6.3