op_pk_creation_mod_get()
Abstract
Obtains the object ID of the module in which the specified packet was created.
Syntax
op_pk_creation_mod_get (pkptr)
| Argument | Type | Description |
|---|---|---|
pkptr |
Packet* |
pointer to the packet-of-interest [A pointer to a packet can be obtained from many KPs, including op_pk_create(), op_pk_create_fmt(), op_pk_copy(), op_pk_get(), op_subq_pk_access(), and op_subq_pk_remove().] |
Return Type
Objid
Object ID of the module in which the specified packet was created.
Packets that have been created outside a process context will have their creation module set to the constant OPC_OBJID_INVALID.
Example
/* obtain a pointer to the arriving packet */
pkptr = op_pk_get (INPUT_STRM);
/* determine the object ID of packet’s creation module */
src_mod_objid = op_pk_creation_mod_get (pkptr);
/* determine the object ID of source node */
src_node_objid = op_topo_parent (src_mod_objid);
/* extract the LAN address of source node */
op_ima_obj_attr_get (src_node_objid, "LAN_Address", lan_address);
/* print out the extracted LAN address */
printf ("Packet just received from node [%s]", lan_address);
Details
New packets enter circulation via one of the following methods:
- creation explicitly by the KPs op_pk_create() or op_pk_create_fmt()
- duplication of existing packets via the KP op_pk_copy()
- automatic duplication by the Simulation Kernel of packets engaged in transmission over bus or radio links to multiple destinations
Packets created via methods (1) and (2) above are assigned fresh creation module object ID and creation time values (except in the case where method (2) is invoked from outside a process context, in which case the creation module object ID is set to the constant OPC_OBJID_INVALID). Packets copied via method (3) above are assigned the creation information of the originally transmitted packet.
Most operations performed on packets will not affect their creation information. As mentioned above, transmission over bus and radio links may create multiple copies of a packet, but each copy retains the original creation information. However, explicitly copying a packet via the KP op_pk_copy() will produce a duplicate packet with fresh creation information.
Both unformatted and formatted packets can be operated on via this KP.
Purpose
Provides a mechanism to determine the original site of a packet’s creation. This is typically useful when trying to determine which object should be sent a response or acknowledgement packet. Another possible use is in associating end-to-end delay (computed using the KP op_pk_creation_time_get()) with the corresponding origin module (or node).
Errors
- Program Abort: Segmentation violation. (due to an invalid packet pointer or malformed packet)
- Program Abort: Packet pointer is NIL.
- Program Abort: Packet pointer references destroyed packet.
Reference
- Use the KP op_pk_creation_time_get() to obtain the simulation time when a packet was created
- Use the KP op_topo_parent() to convert a module object ID to the surrounding node’s object ID
- Use the KP op_pk_stamp() to stamp a packet with the current module and simulation time
- Use the KPs op_pk_stamp_mod_get() and op_pk_stamp_time_get() to obtain the module object ID and simulation time from a packet’s stamp
- Use the KP op_pk_id() to obtain the unique ID of a packet