op_pk_bulk_size_get()
Abstract
Obtains the bulk data size of the specified packet.
Syntax
op_pk_bulk_size_get (pkptr)
| Argument | Type | Description |
|---|---|---|
pkptr |
Packet* |
pointer to the packet-of-interest [A pointer to a packet can be obtained from many KPs, including op_pk_create(), op_pk_create_fmt(), op_pk_copy(), op_pk_get(), op_subq_pk_access(), and op_subq_pk_remove().] |
Return Type
OpT_Packet_Size
Bulk data size (in bits) of the specified packet.
Example
/* 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);
Details
Bulk data size is a property of a packet that is used to model the amount of data that is not explicitly attributed to individual fields. Modifying the bulk data size of a packet proportionally modifies the total size of the packet, which is the sum of the bulk data size and the sizes of the packet’s fields. The bulk data size of a packet can be modified or accessed at any time. Both unformatted and formatted packets can have their bulk data sizes obtained via this KP. Upon creation, unformatted packets have their bulk data size set to the value specified as an argument to op_pk_create(); newly created formatted packets have their bulk data size set to zero.
Purpose
Provides a mechanism to determine a packet’s bulk data size, which is useful for statistics gathering, resource allocation, or categorization of packets by size.
Errors
- Program Abort: Segmentation violation. (due to an invalid packet pointer or malformed packet)
- Program Abort: Packet pointer is NIL.
- Program Abort: Packet pointer references destroyed packet.
Reference
- Use the KP op_pk_bulk_size_set() to assign a packet’s bulk data size
- Use the KP op_pk_total_size_set() to directly assign the total size of a packet
- Use the KP op_pk_total_size_get() to obtain the total size of a packet
- Use the KP op_pk_fd_set() to modify the size of a field in an unformatted packet (and set its value)
- Use the KPs op_pk_fd_strip() or op_pk_nfd_strip() to strip off a field in a packet, thus eliminating its contribution to the total size of a packet