Main Page   Class Hierarchy   Compound List   File List   Compound Members  

C_CallControl.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_CALL_CONTROL_H
00021 #define _C_CALL_CONTROL_H
00022 
00023 #include "C_TaskControl.hpp"
00024 #include "C_MessageFrame.hpp"
00025 #include "C_CallContext.hpp"
00026 #include "C_ScenarioControl.hpp"
00027 #include "C_GeneratorConfig.hpp"
00028 
00029 #include "TrafficType.h"
00030 #include "C_TrafficModel.hpp"
00031 
00032 #include "C_MultiList.hpp"
00033 
00034 #include "C_GeneratorStats.hpp"
00035 
00036 #include "C_ChannelControl.hpp"
00037 
00038 #include "list_t.hpp"
00039 #include "map_t.hpp"
00040 
00041 
00042 #include "gen_operation_t.hpp"
00043 
00044 #include "ProtocolData.hpp"
00045 #include "ReceiveMsgContext.h"
00046 
00047 
00048 #include "C_TrafficDistribUniform.hpp"
00049 #include "C_TrafficDistribBestEffort.hpp"
00050 #include "C_TrafficDistribPoisson.hpp"
00051 
00052 
00053 typedef struct _event_recv {
00054   C_TransportEvent::T_TransportEvent_type m_type ;
00055   int                                     m_id   ;
00056 } T_EventRecv, *T_pEventRecv ;
00057 
00058 class C_ScenarioControl ;
00059 
00060 class C_CallControl : public C_TaskControl {
00061 
00062 public:
00063 
00064 
00065   typedef C_MultiList<C_CallContext> T_CallContextList, 
00066     *T_pCallContextList ;
00067   
00068   typedef map_t<T_ValueData,
00069                    T_pCallContext> T_CallMap, *T_pCallMap ;
00070 
00071   typedef map_t<int, T_pCallContext> T_SuspendMap, *T_pSuspendMap ;
00072 
00073    C_CallControl(C_GeneratorConfig    *P_config, 
00074                  C_ScenarioControl    *P_scenControl,
00075                  C_ChannelControl     *P_channel_ctrl);
00076   ~C_CallControl();
00077   
00078   //  void set_call_rate (unsigned long P_rate) ;
00079   void messageReceived      (T_pReceiveMsgContext P_ctxt) ;
00080   void eventReceived        (T_pEventRecv P_event) ;
00081 
00082   virtual void pause_traffic () ;
00083   virtual void restart_traffic () ;
00084           void force_init() ;
00085   virtual unsigned long get_call_rate();
00086   virtual void change_call_rate(T_GenChangeOperation P_op,
00087                                 unsigned long        P_rate);
00088   virtual void change_rate_scale(unsigned long P_scale);
00089   virtual void change_burst (unsigned long P_burst);
00090 
00091   virtual void clean_traffic () ;
00092 
00093 
00094   T_GeneratorError close() ;
00095 
00096   T_pCallMap* get_call_map () ;
00097 
00098   virtual void start_traffic () ;
00099 
00100   
00101 protected:
00102 
00103   typedef list_t<T_EventRecv> T_EventRecvList, *T_pEventRecvList ;
00104 
00105 
00106   // message management
00107   T_pRcvMsgCtxtList    m_msg_rcv_ctxt_list ;
00108 
00109   // statistics
00110   C_GeneratorStats    *m_stat ;
00111 
00112   unsigned long        m_call_created ;
00113   unsigned long        m_call_to_simulate ;
00114   bool                 m_pause ;
00115   T_TrafficType        m_type ;
00116 
00117 
00118   // call context management
00119   T_pCallContext      *m_call_ctxt_table ;
00120   size_t               m_call_ctxt_table_size ;
00121   T_pCallContextList   m_call_ctxt_mlist ;
00122 
00123   T_pSuspendMap        m_call_suspended ;
00124 
00125   T_pCallMap          *m_call_map_table ;
00126   int                  m_nb_channel ;
00127   
00128   // traffic parameters
00129   bool                 m_accept_new_call ;
00130 
00131   // open event management
00132   T_EventRecvList     *m_event_list ;
00133 
00134   // scenario informations
00135   C_ScenarioControl   *m_scenario_control ;
00136 
00137   // channel management
00138   C_ChannelControl    *m_channel_control ;
00139 
00140   // configuration
00141   C_GeneratorConfig   *m_config ;
00142   int                  m_max_send_loop ;
00143   int                  m_max_receive_loop ;
00144   unsigned long        m_call_timeout_ms ;
00145 
00146   unsigned long       *m_wait_values ;
00147   size_t               m_nb_wait_values ;
00148 
00149   bool                 m_call_timeout_abort ;
00150 
00151   unsigned long        m_open_timeout_ms ;
00152 
00153   unsigned long          m_max_retrans                    ;
00154   unsigned long          m_retrans_enabled                ;
00155   C_CallContext::T_pRetransContextList  *m_retrans_context_list           ;
00156 
00157   unsigned long         *m_retrans_delay_values           ;
00158   size_t                 m_nb_retrans_delay_values        ;
00159 
00160   int                    m_nb_send_per_scene              ;
00161   int                    m_nb_recv_per_scene              ;
00162 
00163   
00164   // TaskController related methods
00165   T_GeneratorError TaskProcedure();
00166   virtual T_GeneratorError InitProcedure();
00167   T_GeneratorError EndProcedure();
00168   T_GeneratorError StoppingProcedure();
00169   T_GeneratorError ForcedStoppingProcedure();
00170 
00171   // internal methods
00172   void messageReceivedControl () ;
00173   void messageTimeoutControl () ;
00174   void waitControl () ;
00175   void messageSendControl () ;
00176   void endTrafficControl () ;
00177   void eventControl () ;
00178 
00179   void messageOpenTimeoutControl () ;
00180   
00181   void stopServer () ;
00182 
00183   T_exeCode execute_scenario_cmd (T_pCallContext P_callContext, bool P_resume=false) ;
00184 
00185   void messageRetransControl () ;
00186   T_exeCode execute_scenario_cmd_retrans (int P_index, T_pCallContext  P_callContext);
00187   void insert_retrans_list(T_pCallContext  P_callContext) ;
00188 
00189   void stopRetrans (T_pCallContext P_callContext) ;
00190 
00191   void makeCallContextAvailable (T_pCallContext *P_pCallCxt) ;
00192   T_pCallContext  makeCallContextUnavailable (C_Scenario *P_scen);
00193   T_pCallContext   retrieve_call_context (int P_channel_id, T_pValueData P_id);
00194 
00195   void makeCallContextSuspended (T_pCallContext P_callContext);
00196 
00197   virtual void init_done() ;  // to be called when init scenario is executed
00198                               // => function also defined for the client
00199 
00200   void clean_mlist (long P_id) ;
00201 
00202 
00203 } ;
00204 
00205 typedef C_CallControl * T_pC_CallControl ;
00206 
00207 class C_CallControlClient : public C_CallControl {
00208 public:
00209   C_CallControlClient(C_GeneratorConfig *P_config, 
00210                       C_ScenarioControl *P_scenControl,
00211                       C_ChannelControl     *P_channel_ctrl) ;
00212   ~C_CallControlClient() ;
00213   virtual void start_traffic () ;
00214 
00215 protected:
00216   virtual T_GeneratorError InitProcedure();
00217   T_GeneratorError TaskProcedure();
00218   T_GeneratorError StoppingProcedure();
00219 
00220   void             newCallControl() ;
00221   void             init_done () ;
00222   void             pause_traffic() ;
00223   void             restart_traffic() ;
00224 
00225   virtual void clean_traffic () ;
00226 
00227   unsigned long    get_call_rate();
00228   void             change_call_rate(T_GenChangeOperation P_op,
00229                                     unsigned long        P_rate);
00230   void             change_rate_scale(unsigned long P_scale);
00231   void             change_burst (unsigned long P_burst);
00232 
00233   C_TrafficModel*  m_traffic_model ;
00234 
00235 
00236   unsigned int            m_model_traffic_select        ;
00237   typedef void           (C_CallControlClient::*T_Update_Param_Traffic)()    ;
00238   T_Update_Param_Traffic  m_update_param_traffic        ;
00239   void                    calculNilParamTraffic()       ;  
00240   void                    calculUpdateParamTraffic()    ;  
00241 
00242 
00243   bool             m_outgoing_traffic ;
00244 
00245   long             m_call_rate, m_burst_limit ;
00246   long             m_call_rate_scale ;
00247   C_Scenario      *m_traffic_scen ;
00248 
00249   T_pCallContext  makeCallContextUnavailable ();
00250 
00251 } ;
00252 
00253 class C_CallControlServer : public C_CallControl {
00254 public:
00255   C_CallControlServer(C_GeneratorConfig *P_config, 
00256                       C_ScenarioControl *P_scenControl,
00257                       C_ChannelControl     *P_channel_ctrl) ;
00258   ~C_CallControlServer() ;
00259 protected:
00260   virtual T_GeneratorError InitProcedure();
00261   virtual void clean_traffic () ;
00262 } ;
00263 
00264 
00265 #endif  // _C_CALL_CONTROL_H

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