Transport Interfaces Programming Guide
  Cerca solo questo libro
Scarica il manuale in formato PDF

Introduction to Network Programming Interfaces

1

This chapter is a high-level introduction to this book. It is most helpful to those who are new to network programming and for those who would like a brief overview of network programming in the Solaris environment.
The Client-Server Modelpage 2
Network Services in the Solaris Environmentpage 3
Layered Protocolspage 4
Open Systems Interconnection Reference Modelpage 5
Internet Protocol Suite (TCP/IP)page 7
Connection-Oriented Protocolspage 9
Connectionless Protocolspage 9
Choosing Between COTS and CLTSpage 10

Note - Because this chapter briefly introduces these topics, you may find the reference books listed in "Related Books" on page xvi to be helpful.

The Client-Server Model

The client-server model is a common method of implementing distributed applications. Figure 1-1 shows a typical networked environment where different services are provided and used by client and server processes.

Grafica

A server is a process that provides a service that can be used by other processes. Examples are a file service such as the NFS filesystem, which provides access to files and directories to other processes or systems, and a display service, such as the X Window System(TM) environment, which provides access to a high resolution display device. A server process normally listens at a known address for service requests. When a request is received, the server is unblocked and serves the client requests.
A client is a process that makes use of a service, or services, provided by other processes. An individual system may be both client and server for different services, or even for the same service. For example, a print server receives print requests, but may need to issue a client request to a file server to access a file.

Network Services in the Solaris Environment

The Solaris environment provides a large number of networking services based upon the Internet protocol suite (also loosely referred to as the TCP/IP protocol suite, described on page 7). These services are listed in Table 1-1.
Table 1-1
ServiceService Description
ARPAddress Resolution Protocol. Used to obtain the hardware network address corresponding to an IP address.
RARPReverse Address Resolution Protocol. Used primarily in diskless clients systems that have a hardware address but need to find out their IP address.
IPInternet Protocol. The core protocol of the TCP/IP protocol suite.
ICMPInternet Control Message Protocol. Used to relay error and control
information. Used by TCP for flow control.
TCPTransmission Control Protocol. Reliable connection-oriented byte stream transport.
UDPUser Datagram Protocol. Unreliable connectionless datagram transport.
SMTPSimple Mail Transfer Protocol. Electronic mail delivery protocol.
TELNETTerminal emulation. Enables login and interactive session on a remote system.
FTPFile Transfer Protocol. Reliable file transfer. Allows ASCII and binary files to be transferred interactively.
TFTPTrivial File Transfer Protocol. Simpler but less secure version of FTP.
DNSDomain Name System. Name service used by the Internet. Uses both TCP and UDP protocols.
BOOTPBoot Protocol. Allows diskless systems to boot from a remote server.
SNMPSimple Network Management Protocol. Basis of many network management packages. Allows activity throughout network to be monitored.
In addition to the base protocols and services it also provides some commonly used utility applications (such as rcp, rsh, and rlogin) built on top of the Internet protocol suite.
The Solaris computing environment also provides heterogeneous distributed computing facilities in its ONC+ architecture. The ONC+ architecture is a set of services built on top of Sun's remote procedure call (RPC) protocol. The programming interfaces available in the ONC+ platform are described fully in the ONC+ Developer's Guide.

Layered Protocols

A protocol is a set of rules and conventions that describes how information is to be exchanged between two entities. Networking tasks often require more than one protocol in order to perform a task, such as file transfer.

Grafica

These protocols can be conceptualized in a model comprising of a series of layers, each of which deals with one functional aspect of the communication. Each layer has a well-defined interface to the layer immediately above and below it. Figure 1-2 on page 4 shows that data is passed through the interface to the layer below. Each layer adds on the necessary information in order for the receiving system to understand and be able to route the data. At the bottom layer, the data is physically transmitted across some medium to the receiving system. It is passed up through the layers, with each layer removing the control information added by the layers on the sending system. A set of protocols layered in this way is called a protocol stack. A layer can have more than one protocol defined for it.
Two well-known reference models are discussed in the following sections: OSI reference model and Internet (TCP/IP) protocol suite.

Open Systems Interconnection Reference Model

The open systems interconnection (OSI) reference model is used to conceptualize network service architectures and as a convenient framework for explaining networking concepts. It is not the basis for the Internet protocol suite, but the Internet protocol's four-layer model can be mapped to the more general OSI reference model. The OSI protocol suite follows the OSI reference model closely.
The OSI reference model divides networking functions into seven layers, as shown in Figure 1-3 on page 6. Each protocol layer performs services for the layer above it. The ISO definition of the protocol layers gives designers considerable freedom in implementation. For example, some applications skip the presentation and session layers to interface directly with the transport layer. In this case, the application performs any needed presentation and session services.
Industry standards have been or are being defined for each layer of the reference model.

Grafica

Layer 1: Physical Layer The hardware layer of the model. It specifies the physical media connecting hosts and networks, and the procedures used to transfer data between machines using a specified media.
Layer 2: Data-Link Layer Manages the reliable delivery of data across the physical network. For example, it provides the abstraction of a reliable wire over the potentially unreliable physical layer.
Layer 3: Network Layer This layer is responsible for routing machine-to machine communications. It determines the path a transmission must take, based upon the destination machine's address.
Layer 4: Transport Layer This layer provides end-to-end sequenced delivery of data. It is the lowest layer that provides applications and higher layers with end-to-end service. This layer hides the topology and characteristics of the underlying network from users. It provides reliable end-to-end data delivery if the service characteristics require it.
Layer 5: Session Layer The session layer manages sessions between cooperating applications.
Layer 6: Presentation Layer Performs the translation between the data representation local to the computer and the processor-independent format that is sent across the network. It can also negotiate the transfer formats in some protocol suites.
Layer 7: Application Layer At this top layer are the user-level programs and network services. Some examples are telnet, ftp, and tftp.

Internet Protocol Suite (TCP/IP)

TCP/IP is a widely used protocol suite for internetworking, a term that refers to the connection of various physical networks to form one large virtual network. Any system connected to a TCP/IP internetwork should be able to communicate with any other system within the internetwork, regardless of which physical network the systems actually reside. Networks are linked together by a system that functions as a gateway between systems.
TCP/IP has a closely associated history with UNIX systems, but the protocols themselves are independent of the operating system, the network topology, and the connection medium. TCP/IP operates on Ethernet and Token Ring local area networks (LANs), across wide area links such as X.25, and serial connections. Support for TCP/IP networking has been an integral part of SunOS in all versions of the operating system.

TCP/IP Protocol Stack

The TCP/IP protocol suite can be described using a reference model similar to the OSI seven layer reference model. Figure 1-4 shows the corresponding OSI layers and some example services at each layer. TCP/IP does not delineate the presentation and session layers as the OSI model does; application code provides the necessary presentation or session functionality.

Grafica

The core protocol is IP, which corresponds to the network layer in the OSI reference model. IP provides a connectionless, "unreliable" packet-forwarding service which routes packets from one system to another.
Built on top of IP are the two transport protocols, TCP, a connection-oriented transport service (COTS), and the user datagram protocol (UDP), a connectionless transport service (CLTS).
The TCP/IP protocols are defined in documents called Requests for Comments (RFCs). RFCs are maintained by the Network Information Center (NIC), the organization that handles address registration for the Internet.
RFCs define a number of applications, the most widely used being telnet, a terminal emulation service on remote hosts, and ftp, which allows files to be transferred between systems.

Connection Oriented and Connectionless Protocols

A number of characteristics can be used to describe communications protocols. The most important is the distinction between connection-oriented transport (COTS) and connectionless transport (CLTS).

Connection-Oriented Protocols

TCP is an example of a connection-oriented protocol. It requires a logical connection to be made between two processes before data can be exchanged. The connection must be maintained during the time communication is taking place and then released afterwards. The process is much like a telephone call, where a virtual circuit is established--the caller must know the person's telephone number and the person must answer the phone before the message can be delivered.
TCP/IP is also a connection-oriented transport with orderly release. With orderly release, any data remaining in the buffer will be sent before the connection is terminated. The release is accomplished in a four-way handshake between client and server processes. The connection-oriented protocols in the OSI protocol suite do not support orderly release. Applications perform any handshake necessary for ensuring orderly release.

Connectionless Protocols

In contrast, connectionless protocols allow data to be exchanged without setting up a link between processes. Each unit of data is transferred independently with all the necessary information to route it to the intended destination. UDP is a connectionless protocol. It is known as a datagram protocol because it is analogous to sending a letter where you don't acknowledge receipt.

Choosing Between COTS and CLTS

The application developer must decide which type of protocol works best for the particular application. Some questions to ask are:
  • How reliable must the connection be?
  • Must the data arrive in the same order as it was sent?
  • Must it be able to handle duplicate data packets?
  • Must it have flow control?
  • Must it acknowledge the messages it receives?
  • What kind of service can the application live with?
  • What level of performance is required?
Broadcasting and tftp are other examples of applications that use CLTS. NFS is one example of an application that uses a connectionless protocol such as UDP. However, recent versions of NFS also operate over TCP.
On the other hand, if reliability is paramount, then COTS is better. telnet, rlogin, and ftp are examples of services that use COTS.