op_pk_type()

Abstract

Determines the type of a specified packet.

Syntax

op_pk_type (pk_ptr)
Argument Type Description
pk_ptr Packet* pointer to the packet of interest

Return Type

int

Constant indicating whether the packet is formatted (OPC_PACKET_TYPE_FORMATTED), unformatted (OPC_PACKET_TYPE_UNFORMATTED), or value vector (OPC_PACKET_TYPE_VVEC).

Example

/* Access a value vector representation from a packet that */
/* might be an SAR segment, an opnet field packet, or an */
/* opnet value vector packet. */
if (op_sar_pk_is_segment (pkptr))
	{
	/* Access the value vector in this SAR segment. */
	/* This value vector will be a duplicate of the */
	/* contents of the SAR segment. */
	op_pk_vvec_get (pkptr, &sar_vvec);
	}
else
	{
	/* This packet is not a SAR segment, and therefore */
	/* either contains fields, or contains a value vector. */
	if (op_pk_type (pkptr) == OPC_PACKET_TYPE_VVEC)
		{
		/* Access the value vector in this packet */
		...
		}
	else
		{
		/* This packet contains fields. */
		/* Convert the packet to its value vector form */
		...
		}
	}

Details

A formatted packet contains fields defined prior to a simulation using the Packet Editor. An unformatted packet’s fields are specified dynamically during a simulation. A value vector packet does not contain specified fields, but rather a value vector.

Note: If the packet passed to op_pk_type() is a Sar segment, the KP identifies it as an unformatted packet unless the segment has been converted to a value vector packet, in which case the KP identifies it as such.

Purpose

Provides a mechanism to identify a packet’s type.

Errors

  • Program Abort: Segmentation violation. (due to an invalid or malformed packet)
  • Program Abort: Packet pointer is NIL.
  • Program Abort: Packet pointer references destroyed packet.

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