op_pk_encap_flag_set()

摘要

在数据包上置一个标志,该标志在任何封装了原始数据包的数据包上都会可见。

语法

op_pk_encap_flag_set (pkptr, index)
参数 类型 说明
pkptr Packet* 指向目标数据包的指针
[指向数据包的指针可以从许多内核过程获得,包括 op_pk_create()、op_pk_create_fmt()、op_pk_copy()、op_pk_get()、op_subq_pk_access() 和 op_subq_pk_remove()。]
index int 要在数据包上置的标志
[标志可以是 0 到 31 之间的整数。]

返回类型

void

无返回值。

示例

以下节选自 models/std/ip 目录中的 ip_basetraf_src.pr.c

/* We need to set the "hold_time" for the traffic which is used */
/* in other models to set the expiration time of this traffic. */
/* We want traffic to be valid for slightly longer than the duration */
/* specified by the basetraf event to give a margin of safety in case */
/* the bgutil_tracer packet is delayed when traveling the network. */
saftey_margin = HOLD_TIME_SAFETY_FRACTION * traf_event_duration;
op_pk_nfd_set (tracer_pk, "hold_time", saftey_margin + duration);

/* Assign amount of traffic this tracer packet reprsents. */
op_pk_nfd_set (tracer_pk, "bandwidth",
	traf_event_ptr->num_bits / traf_event_duration);
op_pk_nfd_set (tracer_pk, "packets_per_sec",
	traf_event_ptr->num_packets / traf_event_duration);

/* Tag the tracer packet as special so that we can find it efficiently */
/* in models that need to make use of this traffic information. */
op_pk_encap_flag_set (tracer_pk, OMSC_BGUTIL_ENCAP_FLAG_INDEX);

详情

index 参数所置的标志编号没有特定含义;其含义完全由模型开发者决定。如果另一个数据包随后封装了带标志的数据包,封装它的数据包也会继承该标志。一个数据包上可以置多个标志。

如果带标志的数据包被 SAR 包中的任何内核过程分段,则每个包含原始数据包某一分段的数据包都会继承该标志。

用途

提供一种为数据包加标志的机制,使该标志在任何封装了原始数据包的数据包上都可见。

错误

  • 程序中止:Segmentation violation.(由于无效的数据包指针或格式错误的数据包)
  • 可恢复错误:封装标志索引 (<index>) 超出数据包 (<pk_id>) 的范围。合法范围为 0 到 31。

参考

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