op_sar_rsmbuf_pk_count()
Abstract
Obtains the number of complete source packets within the specified reassembly buffer.
Syntax
op_sar_rsmbuf_pk_count (sb_hndl)
| Argument | Type | Description |
|---|---|---|
sb_hndl |
Sbhandle |
handle identifying the reassembly buffer-of-interest [This value must identify a Sar reassembly buffer. A Sar buffer handle is obtained when a buffer is created via the KP op_sar_buf_create().] |
Return Type
int
Number of completely reassembled packets within the specified reassembly buffer.
Example
/* Obtain an arriving segment. */
seg_pkptr = op_pk_get (SEG_INSTRM);
/* Insert the segment into reassembly buffer. */
op_sar_rsmbuf_seg_insert (rsm_sbh, seg_pkptr);
/* Determine the number of complete source packets in reassembly buffer. */
comp_pk_count = op_sar_rsmbuf_pk_count (rsm_sbh);
/* Loop through all complete source packets in reassembly buffer. */
for (pk_index = 0; pk_index < comp_pk_count; pk_index++)
{
/* Remove a complete source packet. */
src_pkptr = op_sar_rsmbuf_pk_remove (rsm_sbh);
/* Add source packet to internal sub-queue. */
op_subq_pk_insert (0, src_pkptr, OPC_QPOS_TAIL);
}
Details
Only completely reassembled source packets are counted in the quantity returned by this KP; incomplete source packets that are missing one or more bits are ignored.
Note that the KP op_sar_buf_size() determines the total number of bits in a reassembly buffer, including both complete and incomplete source packets. Thus, the results of op_sar_rsmbuf_pk_count() and op_sar_buf_size() should generally not be used together in a mathematical expression (e.g., determining the average size of packets in a reassembly buffer by computing the ratio of the two values).
Purpose
Provides a mechanism to determine how many reassembled source packets are available for removal from a reassembly buffer. This quantity is mainly useful as the limit value of a loop that will remove and process each complete source packet from a reassembly buffer, as illustrated in the Example section (alternatively, this type of loop can be terminated by a failed attempt to remove a complete source packet, signified by op_sar_rsmbuf_pk_remove() returning OPC_NIL). The number of complete source packets in a reassembly buffer may also be useful in reserving resources that these packets would require after removal from the buffer, or for computing reassembly throughput statistics.
Errors
- Standard Sar errors (see Table 15)
- Program Abort: Buffer handle references destroyed buffer.
- Program Abort: Buffer type (
<type>) is invalid for this KP, should be (reassembly).
Reference
- Use the KP op_sar_buf_size() to determine the number of bits stored in a Sar buffer
- Use the KP op_sar_rsmbuf_pk_remove() to remove and obtain a complete source packet from the head of a reassembly buffer
- Use the KP op_sar_rsmbuf_seg_insert() to insert a Sar segment into a reassembly buffer
- Use the KP op_sar_rsmbuf_pk_flush() to flush old, incomplete source packets from a reassembly buffer