excoax_net学习笔记之eth_mac_v2 -----INIT 出口代码

本文是关于excoax_net中eth_mac_v2模块INIT出口代码的学习笔记,主要涉及地址获取、自动寻址、帧等待变量初始化、节点与进程信息注册、发射机对象标识获取及比特率确定等关键步骤。通过这段代码,可以了解到OPNET模型中MAC层初始化过程的关键操作。
摘要由CSDN通过智能技术生成

 初学opnet  如理解有误,欢迎指正

INIT 出口代码   出口代码有点长,不要被吓到了奋斗

/* Obtain the address assigned to this node.   */
if (op_ima_obj_attr_get (mac_attr_objid, "Address", &my_32bit_address) //op_ima_obj_attr_get(objid,attr_name,value_ptr)  从指定的对象objid中获取属性attr_name放到value_ptr中    value_ptr是void*型   返回值为compcode

 == OPC_COMPCODE_FAILURE)
 {
 eth_mac_error ("Unable to read station address attribute.", OPC_NIL, OPC_NIL);
 }

/* Perform auto-addressing for the MAC address dynamically addresses·, if auto-assigned, the address resolution function also detects duplicate */
/* static assignments. By default each address is  */
/* considered as being a valid destination unless it is */
/* explicitly set.     */
oms_aa_address_resolve (oms_aa_handle, mac_attr_objid, &my_32bit_address);//

Creates a new, unique  address (if theaddress is auto-assigned), or verifies that theaddress is unique (if the address is explicitly assigned). 所以有检测重复分配的功能

 

/* Initialize and export the frame-waiting variable used */  初始化并导出帧等待变量
/* by deference process in computing deference intervals. */
frame_waiting = 0.0;
op_stat_write (frame_handle, frame_waiting);

/* Obtain the node's object id. */
own_node_objid = op_topo_parent (my_objid); 获得节点id

/* Obtain the process's process handle. */
own_prohandle = op_pro_self ();  //获得进程句柄

/* Obtain the name of the process. */
op_ima_obj_attr_get (my_objid, "process model", proc_model_name);

/* Register this Ethernet MAC process in the model-wide registry. */  

own_process_record_handle = (OmsT_Pr_Handle) oms_pr_process_register (own_node_objid, my_objid,  获得记录进程注册信息的句柄
 own_prohandle, proc_model_name);

/* Register the protocol attribute and mac type info of this  */

/* process into the model-wide registry.        */
oms_pr_attr_set (own_process_record_handle, "protocol", OMSC_PR_STRING, "mac", OPC_NIL); 在句柄中注册协议信息  name type value ...OPNIL
oms_pr_attr_set (own_process_record_handle, "mac_type", OMSC_PR_STRING, "eth", OPC_NIL); /*两句可以合并为一句   oms_pr_attr_set    (own_process_record_handle, "protocol", OMSC_PR_STRING, "mac", "mac_type", OMSC_PR_STRING, "eth",OPC_NIL);*/

/* Determine object identifier of transmitter connecting */
/* the MAC layer to the bus.  This Objid is needed to abort */

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值