欢迎来到天天文库
浏览记录
ID:28099410
大小:41.00 KB
页数:9页
时间:2018-12-08
《OPNET学习笔记.doc》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、OPNET学习笔记simple_source模块的功能是按照配置产生包,包括不同的包格式和产生速率,也是比较简单的进程模型。参考了《opnetprocessmodel:simple_source分析》http://hi.baidu.com/ebinghaus/blog/item/c7cade9228876c83a877a405.html 该模块有4个localstatistic,注意有5个modelattribute,分别是PacketInterarrivalTime,PacketSize,PacketFormat,StartTime,StopTime,这些是在使用该模块时需
2、要配置的,当然也可以使用默认配置。状态机也很简单:在headerblock中定义了/*Includefiles.*/#include //注意该模块使用了外部文件《oms_dist_support》和《oms_string_support》/*Specialattributevalues.*/#defineSSC_INFINITE_TIME-1.0 //定义无穷大时间为-1/*Interruptcodevalues.*/ //注意这里的中断代码是自定义的,为了在产生自中断是使用#defineSSC_START0#defineSS
3、C_GENERATE1#defineSSC_STOP2/*Nodeconfigurationconstants.*/#defineSSC_STRM_TO_LOW0 //发送的streamindex,默认的,该模块只有一个stream连接,所以不需要动态获取streamindex/*Macrodefinitionsforstatetransitions.*/ //转换条件为中断代码是自定义的常量:#defineSTART(intrpt_code==SSC_START)#defineDISABLED(intrpt_code==SSC_STOP)#defineSTOP(in
4、trpt_code==SSC_STOP)#definePACKET_GENERATE(intrpt_code==SSC_GENERATE)/*Functionprototypes.*/staticvoidss_packet_generate(void); //产生包的函数,在functionblock中定义一,INIT的入口代码:/*Atthisinitialstate,wereadthevaluesofsourceattributes*//*andscheduleaseltinterruptthatwillindicateourstarttime*//*forpacketg
5、eneration.*//*Obtaintheobjectidofthesurroundingmodule.*/own_id=op_id_self(); //首先得到surroundingobjid,应该是自己的objid,后面根据objid获取对象的属性/*Readthevaluesofthepacketgenerationparameters,i.e.the*//*attributevaluesofthesurroundingmodule.*///用op_ima_obj_attr_get()得到对象的属性的值,是产生包的参数。注意interarrival_st
6、r和size_str是临时变量,还是char数组类型。op_ima_obj_attr_get(own_id,"PacketInterarrivalTime",interarrival_str);op_ima_obj_attr_get(own_id,"PacketSize",size_str);op_ima_obj_attr_get(own_id,"PacketFormat",format_str);op_ima_obj_attr_get(own_id,"StartTime",&start_time);op_ima_obj_attr_get(own_id,"StopTime",&
7、stop_time);/*LoadthePDFsthatwillbeusedincomputingthepacket*//*interarrivaltimesandpacketsizes.*///装入PDF,用于前两个参数,得到包产生和包大小的分布,函数是oms_dist_load_from_string(),这样很方便的使用string类型的参数。//获得的是分布函数的句柄,注意两个句柄都是statevariable,类型为Omst_dist_handle。interarrival_dis
此文档下载收益归作者所有