opnet之作者设计csma

来源:互联网 发布:vb中elseif什么意思 编辑:程序博客网 时间:2024/06/05 08:11

作者设计的:
自己设计的:

状态机

这里写图片描述

HB

/* Input stream from ideal generator module */#define IN_STRM     0/* Output stream to bus transmitter module */#define OUT_STRM    0/* Conditional macros */#define PKT_ARVL (op_intrpt_type() == OPC_INTRPT_STRM)/* Global Variable */extern int subm_pkts;/* Input statistic indices */#define CH_BUSY_STAT    0/* Conditional macros */#define FREE (op_stat_local_read (CH_BUSY_STAT) == 0.0)#define PKTS_QUEUED (!op_strm_empty (IN_STRM))#define CH_GOES_FREE (op_intrpt_type () == OPC_INTRPT_STAT)

init

/* Get the maximum packet count, *//* set at simulation run-time */op_ima_sim_attr_get_int32 ("max packet count", &max_packet_count);

tx_pkt

Packet * out_pkt;/* A packet has arrived for transmission.  Acquire *//* the packet from the input stream, send the packet *//* and update the global submitted packet counter. */out_pkt = op_pk_get (IN_STRM);op_pk_send (out_pkt, OUT_STRM);++subm_pkts;/* Compare the total number of packets submitted with *//* the maximum set for this simulation run.  If equal *//* end the simulation run. */if (subm_pkts == max_packet_count)    {    op_sim_end ("Simulation ended when max packet count reached.", "", "", "");    }

仿真结果

这里写图片描述

tags:opnet

0 0
原创粉丝点击