op_pk_deliver()
Abstract
Forwards the specified packet to a remote module, schedules the packet’s arrival at the module for the current simulation time, and releases ownership of the packet by the invoking process.
Syntax
op_pk_deliver (pkptr, mod_objid, instrm_index)
| 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().] |
mod_objid |
Objid |
object ID of the remote module [A module object ID can be obtained from several KPs in the Topo and Id packages including: op_id_self(), op_topo_child(), and op_id_from_name().] |
instrm_index |
int |
index of an input packet stream of the remote module |
Return Type
void
No return value.
Example
/* obtain the object ID of remote telemetry processor */
node_objid = op_id_from_name (0, OPC_OBJTYPE_NODE_FIXED, "tlm_node");
proc_objid = op_id_from_name (node_objid, OPC_OBJTYPE_PROC, "tlm_proc");
/* create a packet */
pkptr = op_pk_create (128);
/* stuff packet with operation code */
op_pk_fd_set (pkptr, 0, OPC_FIELD_TYPE_INTEGER, OPCODE_ACTIVATE, 0);
/* deliver the packet to remote processor */
op_pk_deliver (pkptr, proc_objid, 0);
Details
This KP schedules the specified packet’s arrival at the specified remote module. The arrival is scheduled for the current simulation time, and the corresponding event is added to the simulation event list. The event will take place before any simulation time elapses, but not before the execution of other events already scheduled for the current simulation time. Upon execution of the event, the remote module will be invoked with a stream interrupt. If the remote module is a processor or a queue, its associated process may determine that the interrupt is due to an input stream via the KP op_intrpt_type(). Packets which arrive on input packet streams may be obtained by the destination process via the KP op_pk_get().
Once a packet is passed to this KP, the invoking process loses ownership of the packet, since the ownership is transferred to the remote module. Any KPs invoked by the delivering process that are passed the “stale” packet pointer will result in packet ownership errors.
Both unformatted and formatted packets can be transferred via this KP.
Purpose
Provides a mechanism to transfer packets between modules without relying on packet streams. Delivering packets using this KP is an alternative to the packet stream-oriented op_pk_send…() series of KPs. This alternative is useful when the physical interconnection between modules and nodes does not need to impact a transmission between peer processes, or when the lower layers of a network architecture (i.e., physical, data link, and network) are not being explicitly modeled. Variants of this KP provide delayed, forced, or quiet arrivals at the remote module. Packets may be delivered to other processes running in processors or queues, or to transmitter modules.
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: Packet pointer references static packet (
<pk_id>). - Program Abort: Packet delivery failed at object (
<mod_objid>), stream (<instrm_index>). - Recoverable Error: Object ID (
<mod_objid>) is out-of-range.
Reference
- Use the KP op_pk_deliver_delayed() to deliver a packet with a delayed arrival
- Use the KP op_pk_deliver_forced() to deliver a packet for immediate processing at a remote module
- Use the KP op_pk_deliver_quiet() to deliver a packet without causing an interrupt at the remote module
- Use the
op_pk_send…()KPs to forward packets to adjacent modules using packet streams - Use the KP op_pk_get() to obtain a pointer to an arriving packet