op_pk_id()
Abstract
Obtains the unique Simulation Kernel-assigned ID of the specified packet.
Syntax
op_pk_id (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
OpT_Packet_Id
Unique ID of the specified packet.
Example
Excerpt from: example model (models/std/base); process model (acb_fifo_ms); state (svc_start); enter execs.
/* schedule an interrupt for this server */
/* at the time where service ends. */
op_intrpt_schedule_self (op_sim_time () + pk_svc_time, i);
/* the server is now busy. */
server_status_table [i] = STATUS_BUSY;
/* reduce the number of free servers */
num_free_servers--;
/* decrease the number of waiting packets */
num_waiting_pks--;
/* establish a correspondence between the server */
/* and the packet which it is serving */
server_pkid_table [i] = op_pk_id (pkptr);
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
The format of the packet ID varies depending on whether the ID is serialized globally (typical in sequential simulations) or by module (typical in parallel simulations). The serialization scheme is set by the op_runsim preference “fully_serialized_packet_ids“.
The IDs of destroyed packets are not reused within the same simulation; thus there is an upper limit of 2^32 unique packet IDs.
Both unformatted and formatted packets can be identified via this KP.
Purpose
Provides a mechanism to identify or track a specific packet through its lifetime. Although packet IDs are not used as arguments to any KPs, they are very useful in the context of the simulation debugger, which supports commands which take packet IDs as arguments. The debugger command pkmap prints the location of an identified packet, the command pkprint prints the contents of an identified packet, and the command pktrace enables trace statements for every operation performed on an identified packet. Packet IDs may also be used by process models to distinguish among otherwise identical packets. For example, a packet ID may be used as a key to find the appropriate packet within a collection of packets, such as within a queue.
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 KPs op_pk_creation_time_get() and op_pk_creation_mod_get() to obtain information on the creation of a packet
- Use the KPs op_pk_stamp_time_get() and op_pk_stamp_mod_get() to obtain information about the last stamp applied to a packet
- Use the KP op_subq_pk_access() to obtain a pointer to a packet within a subqueue (to check its ID)
- Use the KP op_pk_id_str_get() to obtain a string representation of a packet ID