OPNET学习笔记OPNET学习笔记.doc
文本预览下载声明
OPNET学习笔记
simple_source模块的功能是按照配置产生包,包括不同的包格式和产生速率,也是比较简单的进程模型。
参考了《opnet process model:simple_source分析》/ebinghaus/blog/item/c7cade9228876c83a877a405.html
该模块有4个local statistic,注意有5个model attribute,分别是Packet Interarrival Time,Packet Size,Packet Format,Start Time,Stop Time,这些是在使用该模块时需要配置的,当然也可以使用默认配置。
状态机也很简单:
在header block中定义了
/* Include files. */#include oms_dist_support.h //注意该模块使用了外部文件《oms_dist_support》和《oms_string_support》
/* Special attribute values. */#define SSC_INFINITE_TIME -1.0 //定义无穷大时间为-1
/* Interrupt code values. */ //注意这里的中断代码是自定义的,为了在产生自中断是使用#define SSC_START 0#define SSC_GENERATE 1#define SSC_STOP 2
/* Node configuration constants. */#define SSC_STRM_TO_LOW 0 //发送的stream index,默认的,该模块只有一个stream连接,所以不需要动态获取stream index
/* Macro definitions for state transitions.*/ //转换条件为中断代码是自定义的常量:
#define START (intrpt_code == SSC_START)#define DISABLED (intrpt_code == SSC_STOP)#define STOP (intrpt_code == SSC_STOP)#define PACKET_GENERATE (intrpt_code == SSC_GENERATE)
/* Function prototypes. */static void ss_packet_generate (void); //产生包的函数,在function block中定义
一,INIT的入口代码:
/* At this initial state, we read the values of source attributes *//* and schedule a selt interrupt that will indicate our start time *//* for packet generation. */
/* Obtain the object id of the surrounding module. */own_id = op_id_self (); //首先得到surrounding objid,应该是自己的objid,后面根据objid获取对象的属性
/* Read the values of the packet generation parameters, i.e. the *//* attribute values of the surrounding module. */
//用op_ima_obj_attr_get()得到对象的属性的值,是产生包的参数。注意interarrival_str和size_str是临时变量,还是char数组类型。op_ima_obj_attr_get (own_id, Packet Interarrival Time, interarrival_str);op_ima_obj_attr_get (own_id, Packet Size, size_str);op_ima_obj_attr_get (own_id, Packet Format, format_str);op_ima_obj_attr_get (own_id, Start Time, start_time);op_ima_obj_attr_get (own_id, Stop Tim
显示全部