op_sar_srcbuf_seg_remove()

Abstract

Removes a segment of the specified length from the head of the specified source buffer (either a segmentation or resegmentation buffer). A pointer to the removed segment is returned.

Syntax

op_sar_srcbuf_seg_remove (sb_hndl, bit_count)
Argument Type Description
sb_hndl Sbhandle handle identifying the source buffer-of-interest
[This value must identify a Sar source buffer (i.e., either a segmentation or a resegmentation buffer). A Sar buffer handle is obtained when a buffer is created via the KP op_sar_buf_create().]
bit_count OpT_Sar_Size number of bits in segment to be removed from buffer
[This value is an integer, instead of a double as in the case of the bit_count arguments of some Sar KPs, because the maximum size of a Sar segment is below the maximum value of an integer.]

Return Type

Packet*

Pointer to the segment packet removed from the specified source buffer.

Example

/* Obtain an arriving source packet. */
src_pkptr = op_pk_get (HLP_INSTRM);

/* Determine the size of the source packet. */
rem_size = op_pk_total_size_get (src_pkptr);

/* Insert the source packet into segmentation buffer. */
op_sar_segbuf_pk_insert (seg_sbh, src_pkptr, pk_seq_num++);

/* Remove and send the first segment associated with arriving packet. */
seg_pkptr = op_sar_srcbuf_seg_remove (seg_sbh, SEG_SIZE);
op_pk_send (seg_pkptr, LLP_OUTSTRM);

/* Compute new remainder of source packet
rem_size -= SEG_SIZE;

/* If there is a remainder of source packet, schedule next segment transmission. */
if (rem_size > 0)
	op_intrpt_schedule_self (op_sim_time () + SEG_TX_TIME, SEG_TX_CODE);

Details

The bit_count argument requests a segment of a certain length; however, there are several factors that affect whether the actual segment obtained by this KP has the requested length. If the number of bits in the buffer is less than the requested segment length, or if the packet boundary option has been set on the buffer and the bits at the head of the buffer are associated with a source packet that has less remaining bits than the requested segment length, then the segment will be limited to contain only the number of available data bits. However, if the segment padding option has been set on the buffer, then even if the number of data bits available for the removed segment is less than the segment’s requested length, the segment will be padded to the requested length. The padding bits will not factor into the size of source packets reassembled from padded segments.

Purpose

Provides a mechanism for removing a Sar segment from a segmentation or resegmentation buffer. This is one of the two techniques for obtaining new Sar segments (the other is to access the segments from a source buffer via op_sar_srcbuf_seg_access()). Once a Sar segment has been removed from a source buffer, it can be processed as a normal packet (i.e., transmitted over links, stored in queues, copied, destroyed).

Errors

  • Standard Sar errors (see Table 15)
  • Program Abort: Number of bits value (<bit_count>) must be greater than 0.
  • Program Abort: Buffer type (reassembly) is invalid for this KP, should be (segmentation or resegmentation).
  • Program Abort: Virtual memory limits exceeded. Too many allocated objects.
  • Recoverable Error: Allocation of object block failed / Object type (<ob_type>).

Reference

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