• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/adc/estimator.h

00001 /* -*-  Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
00002 /*
00003  * Copyright (c) Xerox Corporation 1997. All rights reserved.
00004  *
00005  * This program is free software; you can redistribute it and/or modify it
00006  * under the terms of the GNU General Public License as published by the
00007  * Free Software Foundation; either version 2 of the License, or (at your
00008  * option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful, but
00011  * WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License along
00016  * with this program; if not, write to the Free Software Foundation, Inc.,
00017  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  *
00019  * Linking this file statically or dynamically with other modules is making
00020  * a combined work based on this file.  Thus, the terms and conditions of
00021  * the GNU General Public License cover the whole combination.
00022  *
00023  * In addition, as a special exception, the copyright holders of this file
00024  * give you permission to combine this file with free software programs or
00025  * libraries that are released under the GNU LGPL and with code included in
00026  * the standard release of ns-2 under the Apache 2.0 license or under
00027  * otherwise-compatible licenses with advertising requirements (or modified
00028  * versions of such code, with unchanged license).  You may copy and
00029  * distribute such a system following the terms of the GNU GPL for this
00030  * file and the licenses of the other code concerned, provided that you
00031  * include the source code of that other code when and as the GNU GPL
00032  * requires distribution of source code.
00033  *
00034  * Note that people who make modified versions of this file are not
00035  * obligated to grant this special exception for their modified versions;
00036  * it is their choice whether to do so.  The GNU General Public License
00037  * gives permission to release a modified version without this exception;
00038  * this exception also makes it possible to release a modified version
00039  * which carries forward this exception.
00040  *
00041  * @(#) $Header: /cvsroot/nsnam/ns-2/adc/estimator.h,v 1.8 2005/08/26 05:05:27 tomh Exp $
00042  */
00043 
00044 //Estimator unit estimates average load every period interval of time
00045 
00046 #ifndef ns_estimator_h
00047 #define ns_estimator_h
00048 
00049 #include "connector.h"
00050 #include "measuremod.h"
00051 #include "timer-handler.h"
00052 
00053 class Estimator;
00054 
00055 class Estimator_Timer : public TimerHandler {
00056 public:
00057         Estimator_Timer(Estimator *est) : TimerHandler() { est_ = est;}
00058         
00059 protected:
00060         virtual void expire(Event *e);
00061         Estimator *est_;
00062 };
00063 
00064 class Estimator : public NsObject {
00065 public:
00066         Estimator();
00067         inline double avload() { return double(avload_);};
00068 
00069         inline virtual void change_avload(double incr) { avload_ += incr;}
00070         inline virtual void newflow(double) {};
00071         int command(int argc, const char*const* argv); 
00072         virtual void timeout(int);
00073         inline void recv(Packet *,Handler *){}
00074         virtual void start();
00075         void stop();
00076         void setmeasmod(MeasureMod *);
00077         void setactype(const char*);
00078         inline double &period(){ return period_;}
00079         void trace(TracedVar* v);
00080 protected:
00081         MeasureMod *meas_mod_;
00082         TracedDouble avload_;
00083         double period_; 
00084         virtual void estimate()=0;
00085         Estimator_Timer est_timer_;
00086         TracedDouble measload_;
00087         Tcl_Channel tchan_;
00088         int src_;
00089         int dst_;
00090         double omeasload_;
00091         double oavload_;
00092         char *actype_;
00093 };
00094 
00095 #endif

Generated on Tue Aug 10 2010 16:16:06 for ns-2.33 by  doxygen 1.7.1