op_pk_fd_size()

Abstract

Obtains the modeled size of a field in the specified packet; the field-of-interest is specified by a numeric index.

Syntax

op_pk_fd_size (pkptr, fd_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().]
fd_index int numeric index of the field-of-interest
[This value should be non-negative; however, no error will occur if it is not. Instead, the value OPC_FIELD_SIZE_INVALID will be returned indicating the specified field is not defined in the packet.]

Return Type

OpT_Packet_Size

Modeled size of the specified field (in bits).

This value is set to OPC_FIELD_SIZE_INVALID if the specified field is not defined in the packet or if a recoverable error occurs.

Example

/* obtain an arriving packet */
pkptr = op_pk_get (0);

/* determine the size of the information field */
data_size = op_pk_fd_size (pkptr, 2);

/* write the data size out as a statistic */
op_stat_write (0, (double) data_size);

/* deallocate the packet */
op_pk_destroy (pkptr);

Details

Returns the size of the specified field, as it was last set via the size argument of the KPs op_pk_fd_set() or op_pk_nfd_set(), or as it was created by the KP op_pk_create_fmt().

Purpose

Provides a mechanism to determine the modeled size of a packet field. This is typically useful when an information field has a variable size, and its size is of interest in computing traffic statistics (as in the example on the previous page). This KP is usually applied to unformatted packets, but it can be applied to formatted packets as well (formatted packet field names may be converted into numeric indices using the KP op_pk_nfd_name_to_index()).

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.
  • Recoverable Error: No field with index (<fd_index>) in packet (<pk_id>).
  • Recoverable Error: Field index (<fd_index>) is out-of-range for packet (<pk_id>).

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