本文主要是介绍opnet之作者设计csma,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
作者设计的:
自己设计的:
状态机
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
这篇关于opnet之作者设计csma的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!