00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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
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
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