op_pk_total_size_get()

摘要

获取指定数据包的总大小。

语法

op_pk_total_size_get (pkptr)
参数 类型 说明
pkptr Packet* 指向目标数据包的指针
[许多内核过程都可以获得数据包指针,包括 op_pk_create()、op_pk_create_fmt()、op_pk_copy()、op_pk_get()、op_subq_pk_access() 和 op_subq_pk_remove()。]

返回类型

OpT_Packet_Size

指定数据包的总大小(以比特计)。

示例

摘自:示例模型(models/std/eth_net);进程模型(eth_mac);函数块(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
	}

详情

数据包的总大小是 bulk 数据大小与各已设置字段大小之和。总大小可以直接修改:修改 bulk 数据大小、设置或取消设置数据包的字段,或修改数据包各字段的大小。未格式化数据包与格式化数据包均可通过此内核过程进行操作。

用途

提供了一种确定数据包总大小的机制,可用于统计量收集、资源分配或按大小对数据包分类。

错误

  • 程序中止:段违例。(由于无效的数据包指针或格式错误的数据包)
  • 程序中止:数据包指针为 NIL。
  • 程序中止:数据包指针指向已被销毁的数据包。

参考

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