General Properties of Packets
Packets are data structures defined by the Modeler environment to support message-oriented communications. Each packet exists as an individual structure that can be used to transfer information from one entity to another. Packets are treated as objects, which can be created, modified, examined, copied, sent, received, and destroyed.
Packet Structure
Each packet contains several information storage areas. The first and most frequently used area consists of a list of fields that provide storage for user-defined information. Packets can be formatted, unformatted, or value vector. A formatted packet allows its fields to be accessed (both for setting and getting) by named reference, whereas an unformatted packet requires that its fields be specified by index. A value vector packet does not have user-defined fields, instead containing a value vector of type bit. If a packet is formatted or unformatted, its fields can be used to store information of various types: integer and double fields store numerical data; packet fields allow the encapsulation of a packet within another; structure fields allow the inclusion of a user-defined data-structure within a packet.
In addition to fields, all packets contain predefined information such as priority assignments, and time and place of creation. A third storage area is dedicated to storing information that supports the modeling of packet transmission over communication links. For a description of packet structure, see "Modeling Overview" on page 1.
Packet Size
In addition to their information content, fields have an assigned size in terms of bits. The size of all the assigned fields in a packet plus a base value known as the packet's bulk data size determine the packet's overall size. This is not the size of the packet as stored in the host computer's memory, but rather the modeled size, used in calculations of such values as transmission time, or error probability.
Packet Ownership
Packets are treated essentially as physical objects, which implies that each one can exist in only one location at a given time. Therefore, when a packet is sent, the entity that sends it loses access to the packet. The entity that has control of a packet is referred to as the packet's owner. Generally, modules or packet streams are the owners of packets.
A module can obtain ownership of a packet in four ways:
- The packet can be created with the KPs
op_pk_create(),op_pk_create_fmt(), orop_pk_create_vvec() - The packet can be created as a copy of an existing packet with the KP
op_pk_copy() - The packet can be decapsulated from within another packet with the KPs
op_pk_nfd_get()orop_pk_fd_get() - The packet can be received via an input stream and acquired with the KP
op_pk_get()
A packet stream simply obtains ownership of a packet when its source module uses it to send a packet to its destination module using the KPs op_pk_send(), op_pk_send_delayed(), op_pk_send_quiet(), or op_pk_send_forced(). Ownership is retained until the destination module acquires the packet or the stream is flushed.