⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mobile_process_mobilite_inter_reseau.pr.c

📁 simulation ip mobile sur opnet
💻 C
字号:
/* Process model C form file: Mobile_Process_Mobilite_Inter_Reseau.pr.c */
/* Portions of this file copyright 1992-2003 by OPNET Technologies, Inc. */



/* This variable carries the header into the object file */
const char Mobile_Process_Mobilite_Inter_Reseau_pr_c [] = "MIL_3_Tfile_Hdr_ 100A 30A op_runsim 7 401A6F86 401A6F86 1 blatte jaquemet 0 0 none none 0 0 none 0 0 0 0 0 0 0 0 8f3 1                                                                                                                                                                                                                                                                                                                                                                                                         ";
#include <string.h>



/* OPNET system definitions */
#include <opnet.h>



/* Header Block */


#include <stdio.h>
#include <malloc.h>
#include <prg_graph.h>
#include <prg_vector.h>
#include <prg_djk.h>

#define SEND		(op_intrpt_type () == OPC_INTRPT_SELF)
//#define NOUVEAU_CLIENT	(op_intrpt_type () == OPC_INTRPT_STRM)
#define ENDSIM			(op_sim_at_end () == OPC_TRUE)

// a mettre en attribut
#define MOYENNE 20


#define GRAPH_STATE_ID 0

#define LIEN_TRAFFIC_IP 0
#define PK_FORMAT_NAME	"Projet_IP_Mobile_packet_client"


struct ha {
	int id_reseau;
//	PrgT_Vector * clients;
};

/* End of Header Block */


#if !defined (VOSD_NO_FIN)
#undef	BIN
#undef	BOUT
#define	BIN		FIN_LOCAL_FIELD(_op_last_line_passed) = __LINE__ - _op_block_origin;
#define	BOUT	BIN
#define	BINIT	FIN_LOCAL_FIELD(_op_last_line_passed) = 0; _op_block_origin = __LINE__;
#else
#define	BINIT
#endif /* #if !defined (VOSD_NO_FIN) */



/* State variable definitions */
typedef struct
	{
	/* Internal state tracking for FSM */
	FSM_SYS_STATE
	/* State Variables */
	int	                    		nbReseau;
	int	                    		nbVoisinInterNiveau;
	int	                    		nbNiveau;
	int	                    		nbMouvement;
	PrgT_Graph *	           		monGraph;
	int	                    		nbMobile;
	PrgT_Vector *	          		clients;
	PrgT_Vector **	         		mesNiveaux;
	int	                    		nbHopHAFA;
	PrgT_Graph_State_ID	    		graphEnv;
	int	                    		nbHopDirect;
	int	                    		tailleData;
	double	                 		debit;
	} Mobile_Process_Mobilite_Inter_Reseau_state;

#define pr_state_ptr            		((Mobile_Process_Mobilite_Inter_Reseau_state*) (OP_SIM_CONTEXT_PTR->mod_state_ptr))
#define nbReseau                		pr_state_ptr->nbReseau
#define nbVoisinInterNiveau     		pr_state_ptr->nbVoisinInterNiveau
#define nbNiveau                		pr_state_ptr->nbNiveau
#define nbMouvement             		pr_state_ptr->nbMouvement
#define monGraph                		pr_state_ptr->monGraph
#define nbMobile                		pr_state_ptr->nbMobile
#define clients                 		pr_state_ptr->clients
#define mesNiveaux              		pr_state_ptr->mesNiveaux
#define nbHopHAFA               		pr_state_ptr->nbHopHAFA
#define graphEnv                		pr_state_ptr->graphEnv
#define nbHopDirect             		pr_state_ptr->nbHopDirect
#define tailleData              		pr_state_ptr->tailleData
#define debit                   		pr_state_ptr->debit

/* These macro definitions will define a local variable called	*/
/* "op_sv_ptr" in each function containing a FIN statement.	*/
/* This variable points to the state variable data structure,	*/
/* and can be used from a C debugger to display their values.	*/
#undef FIN_PREAMBLE_DEC
#undef FIN_PREAMBLE_CODE
#if defined (OPD_PARALLEL)
#  define FIN_PREAMBLE_DEC	Mobile_Process_Mobilite_Inter_Reseau_state *op_sv_ptr; OpT_Sim_Context * tcontext_ptr;
#  define FIN_PREAMBLE_CODE	\
		if (VosS_Mt_Perform_Lock) \
			VOS_THREAD_SPECIFIC_DATA_GET (VosI_Globals.simi_mt_context_data_key, tcontext_ptr, SimT_Context *); \
		else \
			tcontext_ptr = VosI_Globals.simi_sequential_context_ptr; \
		op_sv_ptr = ((Mobile_Process_Mobilite_Inter_Reseau_state *)(tcontext_ptr->mod_state_ptr));
#else
#  define FIN_PREAMBLE_DEC	Mobile_Process_Mobilite_Inter_Reseau_state *op_sv_ptr;
#  define FIN_PREAMBLE_CODE	op_sv_ptr = pr_state_ptr;
#endif


/* Function Block */


#if !defined (VOSD_NO_FIN)
enum { _op_block_origin = __LINE__ };
#endif
short ajouterClientMobile(Packet *client,int reseau);
short retirerClientMobile(Packet *client,int reseau);
short deplacer(Packet * clientMobile, int futur);
short progDeplacement(Packet * client);
void faireDeplacement(void * client, int futur );
PrgT_Compcode destructeur (void* ptr);
void* par_copie (void* ptr);
int calculNbLienMini(PrgT_Graph * reseau, PrgT_Graph_Vertex * reseauDepart, PrgT_Graph_Vertex * reseauArrivee);
PrgT_Graph_Vertex * getSource(int reseau);

void printClient(Packet * client); 
void printClient2(int idClient);


void *
par_copie2 (void *elem_ptr, PrgT_Graph_Element_Type elem_type);
PrgT_Compcode destructeur2
		(void *elem_ptr, PrgT_Graph_Element_Type elem_type);

short ajouterClientMobile(Packet *client,int reseau) {
	int ret = 0;
	
	// on insere le client dans le reseau destination ( en queue )
	ret = op_subq_pk_insert(reseau,client, op_subq_stat(reseau,OPC_QSTAT_PKSIZE));
	
	if ( ret != OPC_QINS_OK ) {
		printf("insertion non reussie \n");
		return -1;
	} else 
		return 0;
	
}

short retirerClientMobile(Packet *client,int reseau) {
	int ret = 0;
	double size = op_subq_stat(reseau,OPC_QSTAT_PKSIZE);
	int i = 0, id = 0, fini = 0;
	Packet * tmp;

	//ret = op_pk_fd_get (client, 0, &id);
	//printf("on retire le client %d du reseau %d\n",id,reseau);

	// on cherche le client
	for ( i = 0; i < size && !fini ; ++i) {
		int idTmp;
		tmp = op_subq_pk_access(reseau, i);
		
		if ( tmp == client ) {
			// on l'as trouv

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -