Package Overview

The Sar (Segmentation and Reassembly) package is a collection of Kernel Procedures concerned with performing the common networking operations of splitting data packets into smaller segments (or merging them into larger segments), and reassembling the segments back into the original packets. Segmentation is often used when a stream of variable-sized packets needs to be converted into a stream of fixed-sized packets (frames, cells, etc.).

The Sar package has been defined to abstract most of the low-level data handling and accounting required to split, merge, and reassemble packets. The package is self-contained, in that it does not require the use of specific KPs in any other package to be fully functional, and no other packages in the Simulation Kernel reference Sar concepts or data structures. However, Sar does use the standard Packet data structure for representing data packets and segments, and packets will need to be created in a simulation if they are to be processed by the Sar package.

Terminology

The following terms represent key concepts and are used throughout this overview and the descriptions of Sar package KPs. These definitions build upon each other and are best read in sequence.

splitting

Splitting a packet entails creating two new packets that replace the original packet and together represent its data payload. The bits in the original packet are divided between the two new packets according to a split point. For instance, splitting a 100-bit packet after its 40th bit generates a 40-bit packet and a 60-bit packet.

merging

Merging two or more packets entails creating a new packet that replaces the original packets and represents their combined data payload. The length of a “merge result” packet is the sum of the lengths of the packets that were merged.

segmentation

The operation that combines splitting and merging a sequence of packets into a new packet is termed segmentation. Segmentation operates on a sequence of one or more packets, and generates a single packet consisting of bits split or merged from the original packets. For instance, three 100-bit packets can be segmented twice to generate two packets: a 50-bit packet and a 250-bit packet. The 50-bit packet would simply be split from the first 100-bit packet at its halfway point; the 250-bit packet would be merged from the remaining 50-bit packet and the other two 100-bit packets.

source packet

Packets that undergo the segmentation operation are termed source packets. A sequence of one or more source packets forms the input data to every segmentation operation.

segment

The packets generated by segmentation are called segments. In some ways, segments are just normal simulation packets: for all non-Sar KPs in the Simulation Kernel, segments are treated the same as packets that have not undergone segmentation. However, to the Sar package, segments are detectable as a special class of packet that was generated by a segmentation operation. Segments do not actually contain portions of the data from their corresponding source packets; instead, they transparently reference the source packets, which are held and managed by the Sar package as soon as they are segmented. Segments do contain data fields that can be assigned or obtained, but this data is local to the segment, and not derived from the source packet. Segments are created by the segmentation operation as unformatted packets with a specific length, but no defined data fields.

reassembly

The operation of reconstructing source packets from their corresponding segments is termed reassembly. Reassembly consumes segments, and recreates the source packets they reference. Any data assigned to the local fields of segments is lost during reassembly.

resegmentation

The operation of splitting or merging a sequence of segments into a new segment is termed resegmentation. Resegmentation is different from multiple recursions of segmentation in that the input segments are not retained and referenced as “source” segments; instead, the input segments are destroyed and replaced by the new segments. Thus, applying the reassembly operation to segments resulting from resegmentation generates a source packet from the original segmentation operation, not an input segment from the resegmentation operation.

buffer

The segmentation, reassembly, and resegmentation operations depend on access to a sequence of input packets, since they may merge two or more input packets to form an output packet. The mechanism for managing sequences, or “lists”, of packets is the buffer, which stores source packets or segments awaiting processing. Buffers are persistent data objects, and are created and destroyed by Sar package KPs. Most Sar KPs have an argument that specifies a single buffer which is to be used for the operation. Buffers are specialized according to the operations they support, as described in the definitions of later terms.

bit-range

The ordered list of packets contained within a buffer can be considered as a linear array of bits that flows across packet boundaries. The full range of the array starts at the first bit of the first packet in the list and ends at the last bit of the last packet in the list. Any contiguous portion of this linear array can be considered a bit-range. Bit-ranges are described by two numbers: a starting bit index, and a length in bits. The local bit index scheme for a buffer list is defined so that the first bit in the first packet of the list has an index of 0, and the last bit of the last packet in the list has an index equal to the number of bits in the list, minus one.

A segment may contain bits from several packets or non-contiguous bits from the same packet. When the segment is not in a buffer, each contiguous group of bits from the same original packet can be referenced by a data structure called a bit-range. A list of bit ranges may be created for a segment, thereby creating a “table of contents” for the segment. Thus, when in the context of a Sar buffer, a bit-range refers to a group of contiguous bits. When a segment is not in a buffer, a bit-range refers to an uninterrupted series of bits from one packet.

insertion

Packets can be inserted into a buffer by several Sar KPs. Insertion adds a packet to a buffer’s internal packet list. The insertion operation may perform immediate merging of the inserted packet and the packets already in the buffer.

removal

Packets can be removed from a buffer by several Sar KPs. Removal extracts a packet from a buffer’s internal packet list and provides a pointer to the packet for external processing. The logic of the buffer may perform splitting or merging of the packets in the buffer as needed to form the output packet.

flushing

Bit-ranges can be flushed from a buffer by several Sar KPs. Flushing extracts a range of bits from packets in the buffer, without creating a new packet to contain them. Flushing is useful when a bit-range within a buffer is no longer needed.

segmentation buffer

Segmentation buffers support the segmentation operation, and contain a single list of source packets. Source packets are inserted into the segmentation buffer, and segments are removed from the buffer.

reassembly buffer

Reassembly buffers support the reassembly operation, and contain two lists of source packets: an incomplete list for source packets under construction, and a complete list for source packets that have been reassembled. Segments are inserted into the reassembly buffer, and added to the list of incomplete source packets. When a source packet has completed reassembly due to insertion of a new segment, it is transferred to the list of complete source packets. Non-segmented source packets can also be inserted into reassembly buffers; they are directly added to the complete list. Complete source packets are removed from the buffer.

resegmentation buffer

Resegmentation buffers support the resegmentation operation and contain a single list of segments. Segments are inserted into the resegmentation buffer, and segments are removed from the buffer.

source buffer

Source buffers are a class of buffers including segmentation buffers and resegmentation buffers. Both of these buffer types serve as sources of segments.

KP Summaries

Most of the Sar package KPs can be categorized by the type of buffer on which they operate. The buffer abbreviations and associated KPs are listed in the following table.

Table 14: Sar Buffer Types

Abbreviation Buffer Type Associated KPs
buf any buffer op_sar_buf_create()
op_sar_buf_destroy()
op_sar_buf_options_set()
op_sar_buf_print()
op_sar_buf_size()
segbuf segmentation buffer op_sar_segbuf_pk_insert()
rsmbuf reassembly buffer op_sar_rsmbuf_pk_count()
op_sar_rsmbuf_pk_flush()
op_sar_rsmbuf_pk_remove()
op_sar_rsmbuf_seg_insert()
rsgbuf resegmentation buffer op_sar_rsgbuf_bits_flush_abs()
op_sar_rsgbuf_lbl_pk_range_get()
op_sar_rsgbuf_lbl_seg_range_get()
op_sar_rsgbuf_seg_insert()
srcbuf source buffers op_sar_srcbuf_bits_flush()
op_sar_srcbuf_seg_access()
op_sar_srcbuf_seg_remove()

The KP op_sar_pk_is_segment() does not fit into the above categories, because it operates only on a packet and does not directly interface with Sar buffers. Also, because the KP op_sar_seg_parent_packets_access() and the bit-range KPs deal with segments that are outside buffers, they do not appear in the categories above.

The Sar KPs can also be categorized according to the type of operation they perform. The following sections describe the KPs by operational category.

General Buffer Operation KPs

General buffer operations are concerned with the Sar buffer as a whole, and thus do not manipulate specific source packets, segments, or bit-ranges. In addition, all the general buffer operations can be applied to any type of Sar buffer. New Sar buffers are allocated and initialized via the KP op_sar_buf_create(). The type of the buffer to be created is specified to this KP, and is fixed for the buffer’s lifetime. Although a buffer’s type is fixed, some buffer options can be changed after it has been created; such option changes are performed via the KP op_sar_buf_options_set(). The current state of a buffer can be determined via the KPs op_sar_buf_size() and op_sar_buf_print(): the former obtains the number of bits contained in the buffer, and the later prints out comprehensive information about the buffer contents to the standard output device for diagnostic purposes. Finally, when a Sar buffer is no longer needed in a simulation, it’s memory can be deallocated via the KP op_sar_buf_destroy().

Insertion Operation KPs

The main purpose of Sar buffers is to hold packets during the procedures of segmentation or reassembly, so several KPs are defined for inserting packets into Sar buffers. A source packet is inserted into a segmentation buffer via the KP op_sar_segbuf_pk_insert(), a segment is inserted into a reassembly buffer via the KP op_sar_rsmbuf_seg_insert(), and a segment is inserted into a resegmentation buffer via the KP op_sar_rsgbuf_seg_insert(). Insertion operation KPs are specific to each buffer type, since the kinds of identification information supplied with the packet to be inserted vary according to the buffer type. Once source packets or segments have been inserted into a Sar buffer, ownership of the packets reverts to the Simulation Kernel, and pointers to the packets are no longer valid (in a manner similar to sending a packet out of a processor or queue via op_pk_send()). Source packets that have been segmented may later be reassembled, but any packets resulting from reassembly are replicas of the originally segmented packet, and not necessarily the same unique packet (as determined by a unique packet ID).

Removal & Access Operation KPs

Segmented or reassembled packets need to leave their Sar buffers in order to interact with the non-Sar portions of a simulation. Thus, several KPs are defined for removing (or copying) packets from Sar buffers. A reassembled source packet is removed from a reassembly buffer via the KP op_sar_rsmbuf_pk_remove(). A new segment is removed from a source buffer via the KP op_sar_srcbuf_seg_remove(), or copied from such a buffer via the KP op_sar_srcbuf_seg_access() (accessing a segment from a source buffer does not remove the segment’s bits from the buffer, allowing the segment to be re-accessed multiple times).

Flush Operation KPs

After being inserted into Sar buffers, packets can stay in the buffers indefinitely if they are not removed. However, there are some conditions in which the packets are no longer needed, either inside or outside of the buffer. In such cases, packets can be removed and discarded from a buffer via “flushing” them. Several KPs are defined for flushing packets from Sar buffers. All incompletely reassembled source packets can be flushed from a reassembly buffer via a single invocation of the KP op_sar_rsmbuf_pk_flush(). A bit-range identified by a user-defined absolute bit index can be flushed from a resegmentation buffer via the KP op_sar_rsgbuf_bits_flush_abs(). A bit-range identified by a buffer-local bit index can be flushed from a source buffer via the KP op_sar_srcbuf_bits_flush().

Query Operation KPs

To interface correctly with Sar buffers using the previously described KPs, it is sometimes necessary to get information about the buffers (or their future packets). Several KPs have been defined to query Sar buffers and packets for useful information. The number of completely reassembled source packets in a reassembly buffer can be obtained via the KP op_sar_rsmbuf_pk_count().

The location and length of a bit-range associated with a specifically identified source packet can be obtained from a resegmentation buffer via the KP op_sar_rsgbuf_lbl_pk_range_get(). A similar operation can be performed for specifically identified segments via the KP op_sar_rsgbuf_lbl_seg_range_get(). An unknown packet can be identified as a Sar segment, or a “normal” packet, using the KP op_sar_pk_is_segment(). You can identify the parent packets of a segment using op_sar_seg_parent_packets_access().

Bit-Range Operation KPs

When working outside a buffer, it is sometimes useful to know the contents of a segment. The bit-range KPs provide a mechanism to track the bits that make up a segment. The KP op_sar_bitrange_create() produces a bit-range that contains four components:

  • The starting bit’s position in its original packet
  • The number of bits in the bit-range
  • The size of the original packet
  • The numeric label of the original packet

Because bit-ranges use system resources, their memory should be deallocated when they are no longer needed by using op_sar_bitrange_destroy(). The KP op_sar_bitrange_info_get() queries a bit-range and places the value of one of its four components into a variable. For diagnostic purposes, op_sar_bitrange_print() displays the components of a bit-range on the standard output device. The KP op_sar_seg_bitrange_list_get() can be used to obtain a list in which each element is a bit-range. The list contains all of the bit-ranges present in a specified packet. Finally, op_sar_seg_create_vvec() takes a value vector and a bit-range as arguments and returns a segment that can later be inserted into Sar buffers.

Standard Sar Errors

A common set of errors is trapped by almost all Sar package KPs. These errors are known collectively as the Standard Sar Errors, and are listed in Table 15. In the Errors sections of the KP descriptions in this section, the Standard Sar Errors are referenced as a set, in order to provide additional room within the sections for the specialized errors of each KP.

Table 15: Standard Sar Errors

Error Cause
Program Abort: KP requires process context due to the KP being called outside of the context of an invoked process
Program Abort: Buffer pointer is NIL due to a NIL Sar buffer handle
Program Abort: Segmentation violation due to an invalid or malformed Sar buffer handle

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