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 #include "C_TrafficDistribUniform.hpp" 00021 #include "GeneratorTrace.hpp" 00022 #include "Utils.hpp" 00023 00024 #include <cmath> 00025 00026 00027 C_TrafficDistribUniform::C_TrafficDistribUniform () : C_TrafficModel() { 00028 } 00029 00030 00031 C_TrafficDistribUniform::~C_TrafficDistribUniform() { 00032 } 00033 00034 int C_TrafficDistribUniform::authorize_new_call() 00035 { 00036 int L_callLimit; 00037 float L_NB1; 00038 00039 long L_desiredAverageRate ; 00040 long L_createdCallNb ; 00041 long L_nbCallCreatedInPeriod ; 00042 long L_currentPeriodDuration ; 00043 00044 00045 update (); 00046 00047 m_sem_desired->P(); 00048 L_desiredAverageRate = m_desiredAverageRate ; 00049 m_sem_desired->V(); 00050 00051 m_sem_created_call->P(); 00052 L_createdCallNb = m_createdCallNb ; 00053 L_currentPeriodDuration = m_currentPeriodDuration ; 00054 00055 m_sem_created_call->V(); 00056 00057 m_sem_created_call_period->P(); 00058 L_nbCallCreatedInPeriod = m_nbCallCreatedInPeriod ; 00059 m_sem_created_call_period->V(); 00060 00061 if (m_currentTrafficDuration <= ms_setup_time) { 00062 return (0); 00063 } 00064 00065 L_NB1 = ( (L_currentPeriodDuration * L_desiredAverageRate) / 00066 (float) 1000.0) ; 00067 00068 00069 L_callLimit = (int) (floor (L_NB1)) - L_nbCallCreatedInPeriod ; 00070 00071 reset () ; 00072 00073 return ((L_callLimit < 0) ? 0 : L_callLimit ); 00074 00075 } /* end of authorize_new_call */ 00076 00077 00078 00079