manet_olsr_protocol_olsr_process.pr.c
来自「protocole sur opnet simulation」· C语言 代码 · 共 1,499 行 · 第 1/3 页
C
1,499 行
/* Process model C form file: MANET_OLSR_PROTOCOL_OLSR_PROCESS.pr.c */
/* Portions of this file copyright 1992-2007 by OPNET Technologies, Inc. */
/* This variable carries the header into the object file */
const char MANET_OLSR_PROTOCOL_OLSR_PROCESS_pr_c [] = "MIL_3_Tfile_Hdr_ 140A 30A op_runsim 7 49EAEE52 49EAEE52 1 server1 cyber 0 0 none none 0 0 none 0 0 0 0 0 0 0 0 18a9 3 ";
#include <string.h>
/* OPNET system definitions */
#include <opnet.h>
/* Header Block */
# include "stdlib.h"
/************************************************************ intrpt pour l'arrive d'un paquet *********************************************************/
#define Packet_Arrival ( op_intrpt_type() == OPC_INTRPT_STRM)
/****************************************************** intrpt pour la generation d'un paquet du control ************************************************/
#define Generate_Control_Messages (op_intrpt_type () == OPC_INTRPT_SELF)
/******************************************************************** intrpt END SIMULATION **************************************************************/
#define END_SIMULATION (op_intrpt_type () == OPC_INTRPT_ENDSIM)
/******************************************************************** declaration des constants ***********************************************************/
// 20 octets pour l'IP header
#define IP_HEADER 160
// 8 octets pour l'UDP header
#define UDP_HEADER 64
/******* status link ********/
#define ASYM_LINK 1
#define SYM_LINK 2
#define MPR_LINK 3
/******* temps de la mise a jours ******/
#define NEIGHB_HOLD_TIME 9
#define TOP_HOLD_TIME 15
#define D_HOLD_TIME 30
#define MIN_TC_INTERVAL 2
#define TIMER_RATE 2
/******** types des messages ************/
#define HELLO_MESSAGE 1
#define TC_MESSAGE 2
#define DATA_MESSAGE 3
// 2 octets
#define MAXCTRLPKT 65536
#define MAXData 65524
// 2 octets
#define MAXPACKETSIZE 65536
#define HOPCNT_MAX 16
/*****************************************/
#define FROM_PHY_LAYER 0
#define FROM_AP_LAYER 1
/************* la taille du message **************/
// 2^16 - 12
#define MAXSIZE_OLSR_PKT 65524
/************* max float *****************/
#define FT_MAX 6000
/************************* structure de donnees *********************************/
/*************************** table des voisins ************************/
struct Neighbor_table
{
int N_addr ; // address of the neighbor
int N_status; // status of the link with that neighbor
double N_time; // le temps de la mise a jours
int degree ; // degree of one hop neighbor excluding the node performing the computation and all its direct neigbors
int nb_2hop_nocov ; // number of 2-hop nodes which are not yet covered by mpr
struct Neighbor_2hop_table *N_2hop ; // liste des voisins a deux sauts
struct Neighbor_table *suiv; // pointe le voisin suivant
} ;
struct Neighbor_2hop_table
{
int N_2hop_addr ; // address of 2-hop neighbor
double N_2hop_time ; // le temps de mise a jours
struct Neighbor_2hop_table *suiv; // pointe le 2-hop neighbor suivant
} ;
/**************************** table MPR_Selector ************************/
struct MPR_selector_table
{
int MSSN ; // numero de sequence le plus recent
struct MPR_selector_S * MPR_selector ; // pointe la liste des mpr selecteur
};
struct MPR_selector_S
{
int MS_addr ; // adresse du noeud
double MS_time ;// le temps de la mise a jours
struct MPR_selector_S * suiv ; // pointe l'element suivant
};
/****************************** duplicata table ***************************/
struct duplicata_table
{
int D_addr ; // originator address
int D_seq_num ; // message sequence number
double D_time; // le temps de la mise a jours
struct duplicata_table * suiv ; //pointe l'element suivant
} ;
/****************************** la table topologique *********************/
struct topology_infos
{
int T_dest ;
int T_last ;
int T_seq ;
double T_time ;
struct topology_infos* suiv;
} ;
/****************************** la table du routage ***********************/
struct routing_infos
{
int R_dest ; // noeud distinataire
int R_next ; // noeud suivant a un saut
int R_dist ; // le nombre de sauts
struct routing_infos* suiv ;
} ;
/*****************************************************************************/
/****************************** la table generale des infos ******************/
/*****************************************************************************/
struct noeud_infos_table
{
struct Neighbor_table * noeud_voisin;
struct MPR_selector_table * table_mpr_selector ;
struct duplicata_table * table_duplicate ;
struct topology_infos * topology_table ;
struct routing_infos * routing_table ;
int change_in_mpr_selector_table ; // indique la presence d'un changement au niveau de la table MPR SELECTOR
int change_in_neigbor_table ; // indique la presence d'un changement au niveau de la table des voisins
int change_in_toplogy_table ; // indique la presence d'un changement au niveau de la table topologique
int time_since_last_tc ; // indique le temps depuis la derniere generation d'un message TC
int packet_seq_number_data ; // un unique identificateur pour chaque message data
int default_nexthop; // le default reoute est un voisin a un MPR qui couvre le max des voisins a deyx sauts
};
struct noeud_infos_table * noeud_infos ;
/******************************************************************************/
/******************** structure pour implemante l'algorithme de djikstra ******/
/******************************************************************************/
struct sommet
{
int fils;
float poids;
struct sommet *suivant;
} ;
/*******************************************************************************************/
/************************ structure a attacher dans le message hello et TC *****************/
/*******************************************************************************************/
struct Neighbor_table_attached
{
int N_addr ; // address of the neighbor
int N_status; // status of the link with that neighbor
struct Neighbor_table_attached *suiv; // pointe le voisin suivant
} ;
struct MPR_selector_table_attached
{
int MSSN ;
struct MPR_selector_S_attached * MPR_selector ;
} ;
struct MPR_selector_S_attached
{
int MS_addr ; // adresse du noeud
struct MPR_selector_S_attached * suiv ; // pointe l'element suivant
};
struct noeud_message_ctl
{
struct Neighbor_table_attached *noeud_voisin ;
struct MPR_selector_table_attached *table_mpr_selector ;
} ;
struct noeud_message_ctl table_ctl[MAXCTRLPKT];
extern double max_vitesse ;
int nb_total_tc_sent ;
int nb_total_paquets_data;
int packet_seq_number_ctl;
/* 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 */
Objid own_id ;
int nombre_max_mobiles ;
double HELLO_INTERVAL ;
double TC_INTERVAL ;
int nb_total_data_bien_recu ;
Stathandle nb_total_data_bien_recu_stat ;
int nb_total_data_lost_chemin_non_trouve ;
Stathandle nb_total_data_lost_chemin_non_trouve_stat ;
int nb_total_hello_sent ;
Stathandle nb_total_hello_sent_stat ;
Stathandle nb_total_tc_sent_stat ;
int nb_total_tc_retransmited ;
double max_jitter ;
Distribution * ptr_jitter ;
Stathandle nb_total_paquets_data_stat ;
} MANET_OLSR_PROTOCOL_OLSR_PROCESS_state;
#define own_id op_sv_ptr->own_id
#define nombre_max_mobiles op_sv_ptr->nombre_max_mobiles
#define HELLO_INTERVAL op_sv_ptr->HELLO_INTERVAL
#define TC_INTERVAL op_sv_ptr->TC_INTERVAL
#define nb_total_data_bien_recu op_sv_ptr->nb_total_data_bien_recu
#define nb_total_data_bien_recu_stat op_sv_ptr->nb_total_data_bien_recu_stat
#define nb_total_data_lost_chemin_non_trouve op_sv_ptr->nb_total_data_lost_chemin_non_trouve
#define nb_total_data_lost_chemin_non_trouve_stat op_sv_ptr->nb_total_data_lost_chemin_non_trouve_stat
#define nb_total_hello_sent op_sv_ptr->nb_total_hello_sent
#define nb_total_hello_sent_stat op_sv_ptr->nb_total_hello_sent_stat
#define nb_total_tc_sent_stat op_sv_ptr->nb_total_tc_sent_stat
#define nb_total_tc_retransmited op_sv_ptr->nb_total_tc_retransmited
#define max_jitter op_sv_ptr->max_jitter
#define ptr_jitter op_sv_ptr->ptr_jitter
#define nb_total_paquets_data_stat op_sv_ptr->nb_total_paquets_data_stat
/* 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
#define FIN_PREAMBLE_DEC MANET_OLSR_PROTOCOL_OLSR_PROCESS_state *op_sv_ptr;
#define FIN_PREAMBLE_CODE \
op_sv_ptr = ((MANET_OLSR_PROTOCOL_OLSR_PROCESS_state *)(OP_SIM_CONTEXT_PTR->_op_mod_state_ptr));
/* Function Block */
#if !defined (VOSD_NO_FIN)
enum { _op_block_origin = __LINE__ + 2};
#endif
/*******************************************************************************************************/
/** fonction : time_out_duplicate_table **/
/** objectif : supprimer les entrees qui ont depasse leur time out **/
/*******************************************************************************************************/
void time_out_duplicate_table (int f_code)
{
struct duplicata_table * p_cour;
struct duplicata_table * p_prec;
/************** pour debuger il faire une fonction d'affichage avant et apres la suppression ***********/
p_cour = noeud_infos[f_code].table_duplicate ;
p_prec = NULL ;
while ( p_cour != NULL)
{
if (p_cour->D_time < op_sim_time())
{
if(p_prec == NULL )
{
noeud_infos[f_code].table_duplicate = (noeud_infos[f_code].table_duplicate)->suiv ;
free ( p_cour ) ;
p_cour = noeud_infos[f_code].table_duplicate ;
}
else
{
p_prec->suiv = p_cour->suiv ;
free( p_cour );
p_cour = p_prec->suiv ;
}
}
else
{
p_prec = p_cour ;
p_cour = p_cour->suiv;
}
}
}
/*******************************************************************************************************/
/** fonction : time_out_selector_table **/
/** objectif : supprimer les entrees qui ont depasse leur time out **/
/*******************************************************************************************************/
void time_out_selector_table (int f_code)
{
struct MPR_selector_S * p_cour,*p_prec ;
p_cour = (noeud_infos[f_code].table_mpr_selector)->MPR_selector ;
p_prec = NULL ;
while ( p_cour != NULL )
{
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?