op_pk_nfd_size()

Abstract

Obtains the modeled size (in bits) of a field in the specified packet; the field-of-interest is specified by name.

Syntax

op_pk_nfd_size (pkptr, fd_name)
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_fmt(), op_pk_copy(), op_pk_get(), op_subq_pk_access(), and op_subq_pk_remove().]
fd_name const char* name of the field-of-interest
[This name should be a defined field within the packet's format; 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).

The constant value OPC_FIELD_SIZE_INVALID will be returned 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_nfd_size (pkptr, "info_fd");

/* 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 originally defined in the format of the packet, as it was last set using the KP op_pk_fd_set(), or in the case of packet fields, as it was taken from an encapsulated packet assigned via op_pk_nfd_set() or op_pk_fd_set().

Purpose

Provides a mechanism to determine the modeled size of a packet's 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 should only be applied to formatted packets; otherwise the returned size for any field name passed to this KP will be zero.

Errors

  • Program Abort: Segmentation violation. (due to an invalid packet pointer or fd_name argument)
  • Program Abort: Packet pointer is NIL.
  • Program Abort: Packet pointer references destroyed packet.
  • Recoverable Error: No field named (<fd_name>) in 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