op_pk_total_size_get()

Abstract

Obtains the total size of the specified packet.

Syntax

op_pk_total_size_get (pkptr)
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().]

Return Type

OpT_Packet_Size

Total size (in bits) of the specified packet.

Example

Excerpt from: example model (models/std/eth_net); process model (eth_mac); function block (eth_mac_llc_pk_accept()).

/* acquire the packet */
llc_pkptr = op_pk_get (HIGH_LAYER_INPUT_STREAM);

/* llc data larger than the maximum acceptable size will */
/* cause an error and the data will be discarded. */
if (op_pk_total_size_get (llc_pkptr) > MAX_DATA_SIZE)
	{
	/* compose and display the error message */
	sprintf (err_str, "large packet with (%g) bits",
		op_pk_total_size_get (llc_pkptr));
	op_sim_message ("ethernet mac layer discarding excessively", err_str);
	
	/* throw away the packet and return from invocation. */
	op_pk_destroy (llc_pkptr);

	FOUT
	}

Details

A packet's total size is the sum of the bulk data size and the sizes of each of the set fields. The total size can be modified directly, by modifiying the bulk data size, by setting or unsetting the packet's fields, or by modifying the sizes of the packet's fields. Both unformatted and formatted packets can be operated on via this KP.

Purpose

Provides a mechanism to determine a packet's total size, which is useful for statistics gathering, resource allocation, or categorization of packets by size.

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.

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