op_pk_get()

Abstract

Obtains a pointer to a packet that has arrived on an input packet stream, and removes the packet from the stream.

Syntax

op_pk_get (instrm_index)
Argument Type Description
instrm_index int index of an input packet stream of the surrounding module

Return Type

Packet*

Pointer to the packet taken from the input stream.

If the specified input stream does not contain any packets, the value OPC_NIL will be returned by this KP; this situation can be avoided by first calling the KP op_strm_empty() to determine if a stream contains any packets.

Example

Excerpt from: example model (models/std/base); process model (prq_fifo); state (REQUEUE); enter execs.

/* a packet is being ’pushed’ onto the head of the queue */
pkptr = op_pk_get (op_intrpt_strm ());

/* insert the new packet at head of subqueue 0 */
if (op_subq_pk_insert (0, pkptr, OPC_QPOS_HEAD) != OPC_QINS_OK)
	{
	/* if the insertion failed, discard the packet */
	op_pk_destroy (pkptr);
	}

Details

This KP can obtain packets that have been sent through a packet stream and packets that have been delivered by remote modules. There is no difference in the way packets transferred using these two techniques are handled in terms of entry into the module.

Packets that are sent or delivered to an input stream quietly (i.e., using the KPs op_send_quiet() or op_deliver_quiet()) will not cause interrupts at the associated module. If multiple quiet packets arrive at an input stream, they will queue up in order of arrival. In such situations, op_pk_get() obtains only the first of several packets queued within the input stream; successive calls to this KP can be used to obtain the remaining packets from the stream (the number of packets queued in an input stream can be obtained using the KP op_strm_pksize()).

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 obtained via this KP.

When this KP is called with an input stream index that exceeds the index of the highest existing input stream, the Simulation Kernel will attempt to allocate new input streams. This capability provides support for receipt of packets on an unlimited number of input streams via the packet delivery mechanism.

Purpose

Provides a mechanism to obtain a packet that has arrived at the surrounding module. This KP is the only way that a process can initially get hold of a packet that it has not created or declared; therefore the vast majority of process models will utilize this KP.

Errors

  • Program Abort: KP requires process context.
  • Program Abort: Allocation of memory failed.
  • Recoverable Error: Input stream index (<instrm_index>) is out-of-range. (due to a negative stream index)

Reference

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com