op_pk_bulk_size_get()

摘要

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

语法

op_pk_bulk_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

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

示例

/* obtain the arriving packet */
pkptr = op_pk_get (INPUT_STRM);

/* determine the bulk size of the packet */
bulk_size = op_pk_bulk_size_get (pkptr);

/* Compute the total time required to service the packet based on its size. */
/* Keep track of the service time as a global statistic. */
svc_time = bulk_size / svc_rate;
op_stat_global_write (svc_time_glob_stat, svc_time);

/* Enqueue the packet in subqueue zero */
op_subq_pk_insert (0, pkptr, OPC_QPOS_TAIL);

/* Compute the time at which the packet shall be extracted from the queue; */
/* this is the last time where the server is active, plus the service time. */
last_busy_time = (extract_time = (last_busy_time > op_sim_time() ? 
	last_busy_time: op_sim_time ()) + svc_time);

/* Schedule the interrupt that will cause the packet to be extracted. */
op_intrpt_schedule_self (last_busy_time, 0);

详情

bulk 数据大小是数据包的一个属性,用于建模那些未显式归属于各个字段的数据量。修改数据包的 bulk 数据大小会按比例修改数据包的总大小,而总大小是 bulk 数据大小与数据包各字段大小之和。数据包的 bulk 数据大小可以在任何时候修改或访问。未格式化和已格式化的数据包都可以通过该内核过程获取其 bulk 数据大小。创建时,未格式化数据包的 bulk 数据大小被设置为作为 op_pk_create() 参数指定的值;新创建的已格式化数据包的 bulk 数据大小被设置为零。

用途

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

错误

  • 程序中止:Segmentation violation.(由于无效的数据包指针或格式错误的数据包)
  • 程序中止:数据包指针为 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