op_strm_pksize()

Abstract

Obtains the number of packets contained within the specified input stream.

Syntax

op_strm_pksize (instrm_index)
Argument Type Description
instrm_index int numeric index of the input stream-of-interest [Input stream indices start at 0 and increment by one.]

Return Type

int

number of packets contained in the specified input stream. The constant OPC_INT_INVALID will be returned if a recoverable error occurs.

Example

/** loop through all input streams, flushing those that have more **/
/** than one packet queued up within them                         **/

/* determine the number of allocated input streams */
alloc_instrms = op_strm_max_index_in ();

/* loop through each allocated stream */
for (i = 0; i <= alloc_intstrms; i++)
	{
	/* if an input stream contains more than one packet, flush it */
	if (op_strm_pksize (i) > 1)
		op_strm_flush (i);
	}

Details

Input streams are initially empty. Packets are placed into input streams via two techniques:

  • Connected input streams receive packets that have been transferred using the op_pk_send…() series of KPs, from source modules which are connected through physical packet streams.
  • Unconnected input streams can only receive packets that have been transferred using the op_pk_deliver…() series of KPs, from source processors or queues which are not necessarily even in the same node as the destination module.

There are also two techniques for removing packets from input streams:

  • Packets can be removed one-by-one using the KP op_pk_get(), and then manipulated by the process algorithms.
  • Packets can be destructively removed en masse using the KP op_strm_flush(), when they are no longer useful.

Purpose

Provides a mechanism to determine the number of packets queued within an input stream. This KP is usually used to establish the bounds of a loop that will remove and process all the packets in turn. The packets are removed via the KP op_pk_get(). Packets that have been queued in a module's input stream, but that are not read in and processed during the next invocation of the associated process, will continue to be queued until they are removed during a successive process invocation.

Errors

  • Program Abort: KP requires process context.
  • Program Abort: Allocation of (<n>) input streams failed.
  • Recoverable Error: Input stream index (<strm_index>) is out-of-range.

Reference

  • Use the KP op_strm_empty() to determine if an input stream is empty or not
  • Use the KP op_strm_flush() to remove all packets from an input stream
  • Use the KP op_pk_get() to remove the first packet from an input stream, and obtain a pointer to it

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · 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