[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Communications Programming Concepts

Internet Datagram Protocol

Internet Datagram Protocol (IDP) is a simple, unreliable datagram protocol, which is used to support the SOCK_DGRAM abstraction for the Internet Protocol (IP) family. IDP sockets are connectionless and normally used with the sendto and recvfrom subroutines. The connect subroutine can also be used to fix the destination for future packets, in which case the recv or read subroutine and the send or write subroutine can be used.

Xerox protocols are built vertically on top of IDP. Thus, IDP address formats are identical to those used by the Sequenced Packet Protocol (SPP). The IDP port space is the same as the SPP port space; that is, an IDP port may be "connected" to an SPP port, with certain options enabled. In addition, broadcast packets may be sent (assuming the underlying network supports this) by using a reserved broadcast address. This address is network interface-dependent.

Usage Conventions

The following example illustrates how IDP uses the SOCK_DGRAM mechanism:

#include <sys/socket.h>
#include <netns/ns.h>
#include <netns/idp.h>

s = socket(AF_NS, SOCK_DGRAM, 0);

Socket Options for IDP

SO_HEADERS_ON_INPUT When set, the first 30 bytes of any data returned from a read or recvfrom subroutine are the initial 30 bytes of the IDP packet, described as follows:

struct idp {
             u_short        idp_sum;
             u_short        idp_len;
             u_char         idp_tc;
             u_char         idp_pt;
             struct ns_addr idp_dna;
             struct ns_addr idp_sna;
           };

This allows the user to determine both the packet type and whether the packet was a multicast packet or directed specifically at the local host. When requested by the getsockopt subroutine, the SO_HEADERS_ON_INPUT option gives the current state of the option: NSP_RAWIN or 0.

SO_HEADERS_ON_OUTPUT When set, the first 30 bytes of any data sent are the initial 30 bytes of the IDP packet. This allows the user to determine both the packet type and whether the packet should be a multicast packet or directed specifically at the local host. You can also misrepresent the sender of the packet. When requested by the getsockopt subroutine, the SO_HEADERS_ON_OUTPUT option gives the current state of the option: NSP_RAWOUT or 0.
SO_DEFAULT_HEADERS The user provides the kernel an IDP header, from which the kernel determines the packet type. When the SO_DEFAULT_HEADERS option is requested by the getsockopt subroutine, the kernel provides an IDP header, showing the default packet type and the local and foreign addresses, if connected.
SO_ALL_PACKETS When set, this option disables automatic processing of both Error Protocol packets, and SPP packets.
SO_SEQNO When requested by the getsockopt subroutine, the S0_SEQNO option returns a sequence number that is not likely to be repeated. It is useful in constructing Packet Exchange Protocol (PEP) packets.

Error Codes

The IDP protocol 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.
ENOTCONN The socket has not been connected or no destination address was specified when the datagram was sent.
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.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]