op_pk_stamp()
Abstract
Stores information in the specified packet which records the current location (i.e., module) and simulation time, for later reference.
Syntax
op_pk_stamp (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
void
No return value.
Example
Excerpt from: example model (models/std/marsat); process model (inm_mac); state (ARRIVAL); enter execs.
/* acquire the arriving packet */
/* (multiple arriving streams are supported.) */
pkptr = op_pk_get (op_intrpt_strm());
/* stamp the packet so that later other */
/* processes will know which process was the source */
op_pk_stamp (pkptr);
/* determine the ship index for the arriving packet */
op_pk_nfd_get (pkptr, "ship_index", &ship_index);
/* enqueue the packet at tail of the subqueue */
/* for the corresponding ship. */
op_subq_pk_insert (ship_index, pkptr, OPC_QPOS_TAIL)
Details
This KP modifies the specified packet's internal stamp information to reflect the current module and simulation time. The module and time values of a stamp may later be accessed by calling the KPs op_pk_stamp_mod_get() and op_pk_stamp_time_get(). Packet stamps are persistent across copy operations (the KP op_pk_copy() copies the original packet's stamp into the duplicate packet).
This KP requires a process context, so it must only be invoked from a process model, or a function that has been directly or indirectly invoked by a process model. Both unformatted and formatted packets can be stamped via this KP.
Purpose
Provides a mechanism for labeling a packet with the current time and location of processing. This may be useful for providing information to a destination node to compute path-specific delays (either end-to-end, or with reference to the last hop). Another common application is dynamic determination of a node's neighbors; this can be performed by mapping an arriving packet's stamp module object ID into the parent node object ID using the KP op_topo_parent().
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.
- Program Abort: Packet pointer references unowned packet (
<pk_id>). - Program Abort: KP requires process context.
Reference
- Use the KP op_pk_stamp_mod_get() to obtain the module object ID of a packet's stamp
- Use the KP op_pk_stamp_time_get() to obtain the simulation time of a packet's stamp
- 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