op_pk_stamp_mod_get()
Abstract
Obtains the object ID of the module where the specified packet was last stamped.
Syntax
op_pk_stamp_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 last stamped.
Example
/* obtain a pointer to the arriving packet */
pkptr = op_pk_get (INPUT_STRM);
/* determine the object ID of packet's source module */
src_mod_objid = op_pk_stamp_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
Packets that have never been stamped via the KP op_pk_stamp() will have their stamp module defined to be the module where they were created.
Most operations performed on packets will not affect their stamp information. Transmission over bus and radio links may create multiple copies of a packet, but each copy retains the original stamp information. Explicitly copying a packet via the KP op_pk_copy() will produce a duplicate packet with the same stamp information as the original packet.
Both unformatted and formatted packets can be operated on via this KP.
Purpose
Provides a mechanism for determining at which location a packet was last stamped. Typically this KP is used in conjunction with the KP op_pk_stamp_time_get() to compare delays in transmission from different source locations. It is also useful in logging the different modules which have performed some user-defined operation on incoming packets.
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_stamp() to set a packet's stamp
- Use the KP op_pk_stamp_time_get() to obtain the simulation time when a packet was last stamped
- Use the KP op_topo_parent() to convert a module object ID to the surrounding node's object ID
- Use the KPs op_pk_creation_mod_get() and op_pk_creation_time_get() to obtain the module object ID and simulation time associated with a packet's creation
- Use the KP op_pk_id() to obtain the unique ID of a packet