[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Communications Programming Concepts

Sequence Packet Protocol

Sequence Packet Protocol (SPP) is the primary transport-layer protocol in the Xerox Network Systems (XNS). It provides reliable, flow-controlled, two-way transmission of data for an application program. It is a byte-stream protocol used to support the SOCK_STREAM abstraction. The SPP protocol uses the standard Network Systems (NS) address formats.

The SPP layer presents a byte-stream interface to an application or user process. As a byte-stream protocol, SPP is used to support the SOCK_STREAM mechanism for interprocess communication.

Usage Conventions

The following example illustrates how SPP uses the SOCK_STREAM mechanism:

#include <sys/socket.h>
#include <netns/ns.h>
s = socket (AF_NS, SOCK_STREAM, 0);

The next example illustrates how SPP uses the SOCK_SEQPACKET mechanism:

#include <sys/socket.h>
#include <netns.sp.h>
s = socket (AF_NS, SOCK_SEQPACKET, 0);

Sockets using the SPP protocol are either active or passive. By default, SPP sockets are created active. The following conventions apply to using active and passive sockets.

Using Socket Types with SPP

If the socket is defined using the SOCK_SEQPACKET socket type, each SPP packet received has the actual 12-byte sequenced packet header left for the user to inspect. The following example data structure illustrates the format of a packet header.

       u_char        sp_cc;        /*connection control*/
#define SP_EM 0x10                 /*end of message*/
       u_char        sp_dt;        /*datastream type*/
       u_short       sp_sid;
       u_short       sp_did;
       u_short       sp_seq;
       u_short       sp_ack;
       u_short       sp_alo;

Providing the sequenced packet header facilitates the implementation of higher level Xerox protocols, which make use of the data-stream type field and the end-of-message bit. The user is required to supply a 12-byte header, of which the data-stream type and the end-of-message fields are inspected.

For either the SOCK_STREAM or SOCK_SEQPACKET socket type, packets received with the attention bit set are interpreted as out-of-band data. Data sent with send (..., ..., ..., MSG_OOB) causes the attention bit to be set.

Socket Options for SPP

SO_DEFAULT_HEADERS Determines the data-stream type and whether the end-of-message bit is to be set on every ensuing packet.
SO_MTU Specifies the maximum amount of user data in a single packet. The default is 576 bytes minus the size of the packet header. This quantity affects windowing. Increasing the mtu parameter without increasing the amount of buffering in the socket, lowers the number of accepted unread packets. Anything larger than the default is not forwarded by a genuine XEROX-product internetwork router. The data argument for the setsockopt subroutine must be an unsigned short.

Error Codes

SPP fails if one or more of the following are true:

EISCONN The socket already has a connection established on it.
ENOBUFS The system ran out of memory for an internal data structure.
ETIMEDOUT A connection was dropped due to excessive retransmissions.
ECONNRESET The remote peer forced the connection to be closed.
ECONNREFUSED The remote peer actively refused connection establishment (usually because no process is listening to the port).
EADDRINUSE An attempt was made to create a socket with a port that has already been allocated.
EADDRNOTAVAIL An attempt was made to create a socket with a network address for which no network interface exists.

[ Previous | Next | Contents | Glossary | Home | Search ]