/* Process model C form file: wy_wsn_route_test.pr.c */
/* Portions of this file copyright 1992-2003 by OPNET Technologies, Inc. */
/* This variable carries the header into the object file */
const char wy_wsn_route_test_pr_c [] = "MIL_3_Tfile_Hdr_ 100A 30A modeler 7 46C3B17E 46C3B17E 1 wy-0fda98abb0ce wy 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 <math.h>
#include "wsn.h"
/* Define streams */
#define OUTSTRM_TO_MAC 0
#define INSTRM_FROM_MAC 0
/* Define interrupt codes */
#define RESET_TIME_CODE 0
#define NEW_ROUND_TIME_CODE 1
#define SCHEDULE_TIME_CODE 2
#define JOIN_REQ_TIME_CODE 3
#define PACKET_TO_SEND_CODE 4
/* Define time constants */
double RESET_TIME_LENGTH;
#define ROUND_TIME_LENGTH 60 /* 一轮的时间长度 */
#define SET_UP_TIME_LENGTH 1 /* set_up状态时间长度 */
#define STEADY_TIME_LENGTH 59 /* 稳定状态时间长度 */
#define JOIN_REQ_WAIT_TIME_LENGTH 0.7
#define ADV_WAIT_TIME_LENGTH 0.5
#define SLOT_LENGTH 0.01 /* member node packet send time's length once */
#define TOTAL_ROUND_N 20
double current_round_start_time;
double current_state_start_time;
/* Define process model transitions. */
#define TIME_TO_RESET (op_intrpt_type() == OPC_INTRPT_SELF && op_intrpt_code() == RESET_TIME_CODE)
#define TIME_TO_NEW_ROUND (op_intrpt_type() == OPC_INTRPT_SELF && op_intrpt_code() == NEW_ROUND_TIME_CODE)
#define TIME_TO_SCHEDULE (op_intrpt_type() == OPC_INTRPT_SELF && op_intrpt_code() == SCHEDULE_TIME_CODE)
#define TIME_TO_JOIN_REQ (op_intrpt_type() == OPC_INTRPT_SELF && op_intrpt_code() == JOIN_REQ_TIME_CODE)
#define JOIN_REQ_ARR (op_intrpt_type() == OPC_INTRPT_STRM && op_intrpt_strm() == INSTRM_FROM_MAC)
#define ADV_ARR (op_intrpt_type() == OPC_INTRPT_STRM && op_intrpt_strm() == INSTRM_FROM_MAC)
#define SCHEDULE_ARR (op_intrpt_type() == OPC_INTRPT_STRM && op_intrpt_strm() == INSTRM_FROM_MAC)
#define PACKET_ARR (op_intrpt_type() == OPC_INTRPT_STRM && op_intrpt_strm() == INSTRM_FROM_MAC)
#define PACKET_TO_SEND (op_intrpt_type() == OPC_INTRPT_SELF && op_intrpt_code() == PACKET_TO_SEND_CODE)
/* 定义成员节点ID数组 */
#define MAX_NODE 200
int members_id [MAX_NODE];
/* 定义簇头所占比例P */
double cluster_p = 0.05;
/* 发送数据的距离 */
double node_distance;
/* 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 my_objid;
Objid my_node_objid;
Objid cluster_objid;
Objid sink_objid;
Objid min_objid;
double min_distance;
double frame_length;
int member_i;
int member_n;
int current_round_r;
int round_n;
int cluster_id;
int my_node_id;
int intrpt_strm;
int sink_id;
double x_self;
double y_self;
double z_self;
double x_sink;
double y_sink;
double z_sink;
} wy_wsn_route_test_state;
#define pr_state_ptr ((wy_wsn_route_test_state*) (OP_SIM_CONTEXT_PTR->mod_state_ptr))
#define my_objid pr_state_ptr->my_objid
#define my_node_objid pr_state_ptr->my_node_objid
#define cluster_objid pr_state_ptr->cluster_objid
#define sink_objid pr_state_ptr->sink_objid
#define min_objid pr_state_ptr->min_objid
#define min_distance pr_state_ptr->min_distance
#define frame_length pr_state_ptr->frame_length
#define member_i pr_state_ptr->member_i
#define member_n pr_state_ptr->member_n
#define current_round_r pr_state_ptr->current_round_r
#define round_n pr_state_ptr->round_n
#define cluster_id pr_state_ptr->cluster_id
#define my_node_id pr_state_ptr->my_node_id
#define intrpt_strm pr_state_ptr->intrpt_strm
#define sink_id pr_state_ptr->sink_id
#define x_self pr_state_ptr->x_self
#define y_self pr_state_ptr->y_self
#define z_self pr_state_ptr->z_self
#define x_sink pr_state_ptr->x_sink
#define y_sink pr_state_ptr->y_sink
#define z_sink pr_state_ptr->z_sink
/* 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 wy_wsn_route_test_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 = ((wy_wsn_route_test_state *)(tcontext_ptr->mod_state_ptr));
#else
# define FIN_PREAMBLE_DEC wy_wsn_route_test_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
/* End of Function Block */
/* Undefine optional tracing in FIN/FOUT/FRET */
/* The FSM has its own tracing code and the other */
/* functions should not have any tracing. */
#undef FIN_TRACING
#define FIN_TRACING
#undef FOUTRET_TRACING
#define FOUTRET_TRACING
#if defined (__cplusplus)
extern "C" {
#endif
void wy_wsn_route_test (OP_SIM_CONTEXT_ARG_OPT);
VosT_Obtype wy_wsn_route_test_init (int * init_block_ptr);
VosT_Address wy_wsn_route_test_alloc (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype, int);
void wy_wsn_route_test_diag (OP_SIM_CONTEXT_ARG_OPT);
void wy_wsn_route_test_terminate (OP_SIM_CONTEXT_ARG_OPT);
void wy_wsn_route_test_svar (void *, const char *, void **);
VosT_Fun_Status Vos_Define_Object (VosT_Obtype * obst_ptr, const char * name, unsigned int size, unsigned int init_obs, unsigned int inc_obs);
VosT_Address Vos_Alloc_Object_MT (VOS_THREAD_INDEX_ARG_COMMA VosT_Obtype ob_hndl);
VosT_Fun_Status Vos_Poolmem_Dealloc_MT (VOS_THREAD_INDEX_ARG_COMMA VosT_Address ob_ptr);
#if defined (__cplusplus)
} /* end of 'extern "C"' */
#endif
/* Process model interrupt handling procedure */
void
wy_wsn_route_test (OP_SIM_CONTEXT_ARG_OPT)
{
#if !defined (VOSD_NO_FIN)
int _op_block_origin = 0;
#endif
FIN_MT (wy_wsn_route_test ());
if (1)
{
Packet* pkptr;
/* 一下为计算成员到簇头最近距离所需的变量 */
/* 记录两个节点的坐标信息 */
double x_src; /* 源节点 */
double
没有合适的资源?快使用搜索试试~ 我知道了~
LEACH-in-OPNET.zip_LEACH-in-OPNET_csma_csma/ca opnet_opnet csma_
共272个文件
m:73个
obj:35个
c:21个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 5 下载量 94 浏览量
2022-07-13
19:31:32
上传
评论 1
收藏 1.68MB ZIP 举报
温馨提示
LEACH算法在OPNET平台的仿真。包括CSMA/CA协议仿真、若干节点的网络仿真
资源详情
资源评论
资源推荐
收起资源包目录
LEACH-in-OPNET.zip_LEACH-in-OPNET_csma_csma/ca opnet_opnet csma_ (272个子文件)
wy_csma.ac 3KB
wy_wsn_route_test.pr.c 44KB
wy1_wsn_route_test.pr.c 43KB
wy4_wsn_leach_proc.pr.c 37KB
wy_lee_leach1.pr.c 33KB
wy1_wsn_energy_modify_pro.pr.c 18KB
wy_wsn_energy_modify_pro.pr.c 18KB
wy_wsn_energy_modify_direct_pro.pr.c 17KB
wy_CSMA_tx.pr.c 14KB
wy_wsn_node_direct_proc.pr.c 14KB
wy1_wsn_mac_interface_test.pr.c 14KB
wy_wsn_mac_interface_test.pr.c 13KB
wy_wsn_mac_interface_direct_proc.pr.c 13KB
wy1_wsn_mac_csma_proc.pr.c 13KB
wy_wsn_mac_csma_proc.pr.c 13KB
wy_CSMA_cct_rx.pr.c 10KB
wy_cct_rx.pr.c 9KB
wy1_wsn_sink_proc.pr.c 9KB
wy_wsn_sink_proc.pr.c 9KB
wy_cct_tx.pr.c 9KB
wy_wsn_lee_leach_bs.pr.c 9KB
wy_cct_network1-CSMA.em.c 6KB
wy_wsn_direct_proj-direct.cml 136B
wy_cct_network-CSMA.cml 130B
wy_cct_network1-CSMA.cml 126B
wy4_wsn_leach_proj1-route.cml 121B
wy1_wsn_leach_proj-route.cml 120B
wy1_wsn_leach_proj-#route.cml 120B
wy4_wsn_leach_proj-route.cml 120B
wy4_wsn_leach_proj-#route.cml 120B
wy_wsn_leach_1proj-leach.cml 118B
wy_wsn_leach_3proj-leach1.cml 118B
wy_wsn_leach_proj-TT.cml 118B
wy_wsn_leach_proj-#TT.cml 118B
wy_wsn_leach_proj1-route.cml 118B
wy_cct_network-aloha.cml 110B
wy_cct_network1-aloha.cml 110B
wy_wsn_direct_proj-direct.dev32.i0.nt.dll 211KB
wy4_wsn_leach_proj-route.dev32.i0.nt.dll 210KB
wy4_wsn_leach_proj1-route.dev32.i0.nt.dll 210KB
wy_wsn_leach_proj1-route.dev32.i0.nt.dll 197KB
wy_wsn_leach_proj-TT.dev32.i0.nt.dll 197KB
wy_wsn_leach_3proj-leach1.dev32.i0.nt.dll 196KB
wy_wsn_leach_1proj-leach.dev32.i0.nt.dll 196KB
wy1_wsn_leach_proj-route.dev32.i0.nt.dll 193KB
wy4_wsn_leach_proj-route.opt32.i0.nt.dll 72KB
wy_wsn_leach_proj1-route.opt32.i0.nt.dll 68KB
wy1_wsn_leach_proj-route.opt32.i0.nt.dll 68KB
wy_wsn_leach_3proj-leach1.opt32.i0.nt.dll 68KB
wy_cct_network1-CSMA.opt32.i0.nt.dll 60KB
wy_cct_network-CSMA.opt32.i0.nt.dll 60KB
wy_cct_network-aloha.opt32.i0.nt.dll 28KB
wy1_wsn_leach_proj-route.ef 795B
wy_wsn_direct_proj-direct.ef 770B
wy_cct_network1-CSMA.ef 407B
wy_cct_network-aloha.ef 373B
wy_cct_network-CSMA.ef 373B
wy_cct_network1-aloha.ef 373B
wy1_wsn_leach_proj-#route.ef 331B
wy_wsn_leach_proj1-route.ef 331B
wy_wsn_leach_3proj-leach1.ef 307B
wy4_wsn_leach_proj1-route.ef 307B
wy4_wsn_leach_proj-route.ef 304B
wy4_wsn_leach_proj-#route.ef 304B
wy_wsn_leach_1proj-leach.ef 304B
wy_wsn_leach_proj-TT.ef 292B
wy_wsn_leach_proj-#TT.ef 292B
wy_wsn_direct_proj-direct.dev32.i0.nt.exp 12KB
wy4_wsn_leach_proj1-route.dev32.i0.nt.exp 10KB
wy4_wsn_leach_proj-route.dev32.i0.nt.exp 10KB
wy4_wsn_leach_proj-route.opt32.i0.nt.exp 10KB
wy_wsn_leach_3proj-leach1.opt32.i0.nt.exp 9KB
wy_wsn_leach_1proj-leach.dev32.i0.nt.exp 9KB
wy1_wsn_leach_proj-route.dev32.i0.nt.exp 9KB
wy1_wsn_leach_proj-route.opt32.i0.nt.exp 9KB
wy_wsn_leach_3proj-leach1.dev32.i0.nt.exp 9KB
wy_wsn_leach_proj1-route.opt32.i0.nt.exp 9KB
wy_wsn_leach_proj1-route.dev32.i0.nt.exp 9KB
wy_wsn_leach_proj-TT.dev32.i0.nt.exp 9KB
wy_cct_network-CSMA.dev32.i0.nt.exp 8KB
wy_cct_network1-CSMA.dev32.i0.nt.exp 8KB
wy_cct_network-CSMA.opt32.i0.nt.exp 7KB
wy_cct_network1-CSMA.opt32.i0.nt.exp 7KB
wy_cct_network-#CSMA.opt32.i0.nt.exp 7KB
wy_cct_network-aloha.opt32.i0.nt.exp 4KB
wy_wsn_direct_proj-direct.dev32.i0.nt.lib 22KB
wy4_wsn_leach_proj1-route.dev32.i0.nt.lib 19KB
wy4_wsn_leach_proj-route.dev32.i0.nt.lib 18KB
wy4_wsn_leach_proj-route.opt32.i0.nt.lib 18KB
wy_wsn_leach_3proj-leach1.opt32.i0.nt.lib 16KB
wy_wsn_leach_1proj-leach.dev32.i0.nt.lib 16KB
wy1_wsn_leach_proj-route.dev32.i0.nt.lib 15KB
wy1_wsn_leach_proj-route.opt32.i0.nt.lib 15KB
wy_wsn_leach_3proj-leach1.dev32.i0.nt.lib 15KB
wy_wsn_leach_proj1-route.dev32.i0.nt.lib 15KB
wy_wsn_leach_proj1-route.opt32.i0.nt.lib 15KB
wy_wsn_leach_proj-TT.dev32.i0.nt.lib 15KB
wy_cct_network-CSMA.dev32.i0.nt.lib 15KB
wy_cct_network1-CSMA.dev32.i0.nt.lib 15KB
wy_cct_network-CSMA.opt32.i0.nt.lib 14KB
共 272 条
- 1
- 2
- 3
weixin_42653672
- 粉丝: 93
- 资源: 1万+
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论5