rece_2

来源:互联网 发布:齐汇火腿肠 知乎 编辑:程序博客网 时间:2024/06/05 12:00

节点模型 lmz_cct_rx

这里写图片描述

进程模型 bbbccc_csma_rx

这里写图片描述

SV

这里写图片描述

TV

char node_name[128];char module_name[128];

HB

#define IN_STRM 0#define OUT_STRM 0#define PKT_RCVD (op_intrpt_type () == OPC_INTRPT_STRM)int subm_pkts;int sending;int sended;//int beacon;

INIT

rcvd_pkts = 0;sh_pack_rece_time = op_stat_reg ("Pack Rece Time",         OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);sh_pack_rece_num = op_stat_reg ("Pack Rece Num",         OPC_STAT_INDEX_NONE, OPC_STAT_LOCAL);sh_pack_delay = op_stat_reg ("Pack Delay",         OPC_STAT_INDEX_NONE, OPC_STAT_GLOBAL);my_id = op_id_self ();p_id = op_topo_parent(my_id);op_ima_obj_attr_get (p_id, "name", node_name); op_ima_obj_attr_get (my_id, "name", module_name); printf("%s ",node_name);printf("%s ",module_name);printf("initing...\n");

PACK_ARVL

Packet* in_pkt;     Packet* ack_pkt;    double ete_delay;   int node_flag;int node_src;double cre_time;in_pkt = op_pk_get (IN_STRM);       op_pk_nfd_get_int32 (in_pkt, "flag", &node_flag);//csma data packetif (node_flag == 0)    {    op_pk_nfd_get_int32 (in_pkt, "src", &node_src);    op_pk_nfd_get (in_pkt, "time", &cre_time);    ete_delay = op_sim_time () - cre_time;    op_pk_print (in_pkt);    printf("current time is %f\n",op_sim_time ());//    printf("creation time is %f\n",cre_time);//    printf("delay time is %f\n",ete_delay);//    op_pk_destroy (in_pkt);    ++rcvd_pkts;    ack_pkt = op_pk_create_fmt ("aaa_csma_ca_ack");    op_pk_nfd_set (ack_pkt, "dest", node_src);    op_pk_print (ack_pkt);    op_pk_send(ack_pkt,OUT_STRM);    printf("sending ack packet...");    op_stat_write (sh_pack_rece_time, 1);    op_stat_write (sh_pack_rece_num, rcvd_pkts);    op_stat_write (sh_pack_delay, ete_delay);    }//ack packet        if (node_flag == 1)    {    printf("ack packet received!");    op_pk_destroy (in_pkt);    }//beacon packetif (node_flag == 3)    {    printf("beacon packet received!");    op_pk_destroy (in_pkt);    }       //////////////////////////////////////////////////      if (node_flag == 4)    {    op_pk_destroy (in_pkt);    }//////////////////////////////////////////////////if (node_flag == 5)    {    ++rcvd_pkts;    ete_delay = op_sim_time () - op_pk_creation_time_get(in_pkt);    op_pk_print(in_pkt);    printf("received packet number is %d\n",rcvd_pkts);    printf("packet delay is %f\n",ete_delay);    printf("current time is %f\n",op_sim_time ());    op_stat_write (sh_pack_rece_time, 1);    op_stat_write (sh_pack_rece_num, rcvd_pkts);    op_stat_write (sh_pack_delay, ete_delay);    op_pk_destroy (in_pkt);    }
0 0