Layered Protocols and Protocol Chains

Winsock supports layered protocols. A layered protocol implements only higher-level communications functions while relying on an underlying transport stack for the actual exchange of data with a remote endpoint. An example of this type of layered protocol is a security layer that adds a protocol to the socket connection process in order to perform authentication and establish an encryption scheme. Such a security protocol generally requires the services of an underlying and reliable transport protocol such as Transmission Control Protocol (TCP) or Sequenced Packed Exchange (SPX).

The term base protocol refers to a protocol, such as TCP or SPX, that is fully capable of performing data communications with a remote endpoint. A layered protocol is a protocol that cannot stand alone, and a protocol chain is one or more layered protocols strung together and anchored by a base protocol.

You can create a protocol chain if you design the layered protocols to support the Winsock SPI at both their upper and lower layers. The WSAPROTOCOL_INFO structure refers to the protocol chain as a whole and describes the explicit order in which the layered protocols are joined. Because only base protocols and protocol chains are directly usable by applications, they are the only ones listed when the installed protocols are enumerated with the WSAEnumProtocols function.

An application uses the WSAEnumProtocols function to determine which transport protocols and protocol chains are present, and to obtain information about each one as that information is contained in the associated WSAPROTOCOL_INFO structure.

In most instances, there is a single WSAPROTOCOL_INFO structure for each protocol or protocol chain. However, some protocols exhibit multiple behaviors. For example, the SPX protocol is message-oriented. That is, the network preserves the sender's message boundaries, but the receiving socket can ignore these message boundaries and treat them as a byte stream. Consequently, two different WSAPROTOCOL_INFO structure entries could exist for SPX, one for each behavior.

Winsock allows protocol stack vendors to obtain unique identifiers for new address families, socket types, and protocols. FTP and Web servers supply current identifier/value mappings and use e-mail to request allocation of new ones.

Applications that need to be protocol-independent are encouraged to select a protocol on the basis of its suitability rather than on the basis of the values assigned to their socket_type or protocol parameters. Protocol suitability is indicated by the communications attributes, such as message-versus-byte stream, and reliable-versus-unreliable, that are contained in the WSAPROTOCOL_INFO structure. Selecting protocols on the basis of suitability as opposed to on the basis of well-known protocol names and socket types lets protocol-independent applications take advantage of new transport protocols and their associated media types, as these become available.

The server half of a client/server application benefits by establishing listening sockets on all suitable transport protocols. Then, the client can establish its connection using any suitable protocol. For example, this lets a client application be unmodified whether it is running on a desktop system, connected through a Local Area Network (LAN), or on a laptop using a wireless network.

See Also

Multiple Transport Protocols

 Last updated on Saturday, April 10, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.