Main Page   Class Hierarchy   Compound List   File List   Compound Members  

C_TrafficModel.hpp

00001 /*
00002  *  This program is free software; you can redistribute it and/or modify
00003  *  it under the terms of the GNU General Public License as published by
00004  *  the Free Software Foundation; either version 2 of the License, or
00005  *  (at your option) any later version.
00006  *
00007  *  This program is distributed in the hope that it will be useful,
00008  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00009  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010  *  GNU General Public License for more details.
00011  *
00012  *  You should have received a copy of the GNU General Public License
00013  *  along with this program; if not, write to the Free Software
00014  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00015  *
00016  * (c)Copyright 2006 Hewlett-Packard Development Company, LP.
00017  *
00018  */
00019 
00020 #ifndef _C_TRAFFIC_MODEL_H
00021 #define _C_TRAFFIC_MODEL_H
00022 
00023 #include "C_Semaphore.hpp"
00024 
00025 #include <sys/time.h>
00026 
00027 class C_TrafficModel {
00028 public:
00029 
00030   C_TrafficModel ();
00031   virtual ~C_TrafficModel ();
00032 
00048   int init (long P_averageRate, 
00049             long P_maxCreationPerPeriod, 
00050             long P_setupTime,
00051             long P_rateScale);
00052   
00059   void start ();
00060   
00064   void call_created (); 
00065   
00073   virtual int  authorize_new_call () = 0 ;
00074   
00075   //  int  authorize_new_call_lis ();
00076   long get_current_period_duration();
00077 
00078   unsigned long get_desired_rate ();
00079   void change_desired_rate (unsigned long P_rate);
00080   void increase_desired_rate () ;
00081   void decrease_desired_rate () ;
00082   void change_max_created_calls (unsigned long P_max);
00083 
00084   void change_rate_scale (long P_rateScale) ;
00085   
00086   //private:
00087 protected:
00088   void update() ;
00089   void reset() ;
00090   
00091   void re_init() ;
00092 
00093   C_Semaphore   *m_sem_desired ;
00094   C_Semaphore   *m_sem_max ;
00095   C_Semaphore   *m_sem_created_call ;
00096   C_Semaphore   *m_sem_created_call_period ;
00097 
00098   long           m_currentTrafficDuration;
00099   long           m_desiredAverageRate;
00100   long           m_createdCallNb;
00101   long           m_currentPeriodDuration;
00102   long           m_maxNbCreationPerPeriod;
00103   long           m_periodDuration;
00104   long           m_nbCallCreatedInPeriod;
00105   struct timeval m_startTrafficDate;
00106   struct timeval m_startPeriodDate;
00107   struct timeval m_currentTimeval;
00108   long           ms_setup_time;
00109 
00110   long           m_rateScale;
00111 
00112 };
00113 
00114 typedef C_TrafficModel *T_pTrafficModel ;
00115 
00116 #endif // __TRAFFIC_MODEL_H__
00117 
00118 
00119 

Generated on Wed Mar 7 14:44:58 2007 for Seagull by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002