op_pk_create()

Abstract

Creates a new unformatted packet with the specified bulk data size; the packet does not have any of its fields set.

Syntax

op_pk_create (bulk_size)
Argument Type Description
bulk_size OpT_Packet_Size bulk data size of the packet (measured in bits)
[An error will occur if this value is negative.]

Return Type

Packet*

Pointer to the new packet created by this KP, or OPC_NIL if a recoverable error has occurred.

Example

/* determine the length of the packet to be generated */
pklen = op_dist_outcome (len_dist_ptr);

/* create an unformatted packet */
pkptr = op_pk_create (pklen);

/* set the source and destination fields */
op_pk_fd_set (pkptr, SOURCE_FIELD, OPC_TYPE_INTEGER, server_id, 16);
op_pk_fd_set (pkptr, DEST_FIELD,  OPC_TYPE_INTEGER, client_id, 16);

/* send the packet to the lower layer protocol */
op_pk_send (pkptr, TRPRT_OUT_STREAM);

Details

The new packet is allocated by the Simulation Kernel and enters circulation at the processor or queue running the process model which invoked this KP. The packet is unformatted, so its fields can only be accessed by numeric index via the op_pk_fd…() KPs. Upon creation, the packet is empty of fields (i.e., it does not contain any default field settings). The bulk data size of the packet is set to the specified value.

The new packet is issued a unique packet ID, which corresponds to the next available Packet ID when this KP is invoked. The packet’s creation and stamp times are set to the simulation time when this KP is invoked, and the creation and stamp modules are set to the module running the process which called this KP.

Purpose

Provides a mechanism to obtain an empty, unformatted packet. Unformatted packets are useful where collections of data must be dynamically modified as they travel through the network, possibly in different ways that are conditionally determined. Such uses are supported since field data types can be changed at any time, and new fields can be added. The disadvantages of unformatted (versus formatted) packets are that fields must be identified by a numeric index (not a mnemonic name), and more information must be specified for the field-setting operation. However, unformatted packets have less computational overhead during field operations, since fields are directly indexed and do not require a series of string comparisons to find a match.

Newly created packets are typically assigned specific field contents and forwarded from the creating module using the op_pk_send…() or op_pk_deliver…() series of KPs. The pointer of a created packet may also be assigned to a process model state variable, and stored until transmission of the packet is required.

Errors

  • Program Abort: Allocation of memory failed.
  • Recoverable Error: Bulk packet size (<bulk_size>) is out-of-range.

Reference

  • Use the KP op_pk_fd_set() to assign values to an unformatted packet’s fields
  • Use the op_pk_send…() and op_pk_deliver…() KPs to send a packet to another module
  • Use the KP op_pk_destroy() to deallocate a packet which is no longer of use

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