Technical data
bufmod(7M) STREAMS Modules SunOS 5.5
NAME bufmod − STREAMS Buffer Module
SYNOPSIS ioctl(fd, I_PUSH, "bufmod");
DESCRIPTION bufmod is a STREAMS module that buffers incoming messages, reducing the number of
system calls and the associated overhead required to read and process them. Although
bufmod was originally designedto be used in conjunction withSTREAMS-based net-
working device drivers, the version described here is general purpose so that it can be
used anywhereSTREAMS input buffering is required.
Read-side Behavior bufmod’s behavior depends on various parameters and flags that can be set and queried
as described below under IOCTLS. bufmod collects incoming M_DATA messages into
chunks, passing each chunk upstream when the chunk becomes full or the current read
timeout expires. It optionally converts M_PROTO messages to M_DATA and adds them
to chunks as well. It also optionally adds to each message a header containinga times-
tamp, and a cumulative count of messages dropped on the stream read side due to
resource exhaustion or flow control. bufmod’s default settingsallow it to drop messages
when flow control sets in or resources are exhausted; disabling headers and explicitly
requesting no drops makes bufmod pass all messages through. Finally,bufmod is capa-
ble of truncating upstream messages to a fixed, programmable length.
When a message arrives, bufmod processes it in several steps. The following paragraphs
discuss each step in turn.
Upon receiving a message from below, if the SB_NO_HEADER flag is not set, bufmod
immediately timestamps it and saves the current time value for later insertion in the
header described below.
Next, ifSB_NO_PROTO_CVT is not set, bufmod converts all leadingM_PROTO blocks in
the message toM_DATA blocks, alteringonly the message type field and leaving the con-
tents alone.
It then truncates the message to the current snapshot length, which is set with the
SBIOCSSNAP ioctl described below.
Afterwards, if SB_NO_HEADER is not set, bufmod prepends a header to the converted
message. This header is defined as follows.
struct sb_hdr {
u_int sbh_origlen;
u_int sbh_msglen;
u_int sbh_totlen;
u_int sbh_drops;
struct timevalsbh_timestamp;
};
The sbh_origlen field gives the message’s original lengthbefore truncation in bytes. The
sbh_msglen field gives the length in bytes of the message after the truncation has been
done. sbh_totlen gives the distance in bytes from the start of the truncated message in
the current chunk (described below) to the start of the next message in the chunk; the
7M-48 modified 27 Jul 1992










