for the same service.

Usually, you don't have to change the services file that comes along with the network software on your Linux system. Nevertheless, we give a small excerpt from that file in Example 12.2.

Example 12.2: A Sample /etc/services File

# The services file:

#

# well-known services

echo           7/tcp                 # Echo

echo           7/udp                 #

discard        9/tcp  sink null      # Discard

discard        9/udp  sink null      #

daytime       13/tcp                 # Daytime

daytime       13/udp                 #

chargen       19/tcp  ttytst source  # Character Generator

chargen       19/udp  ttytst source  #

ftp-data      20/tcp                 # File Transfer Protocol (Data)

ftp           21/tcp                 # File Transfer Protocol (Control)

telnet        23/tcp                 # Virtual Terminal Protocol

smtp          25/tcp                 # Simple Mail Transfer Protocol

nntp         119/tcp  readnews       # Network News Transfer Protocol

#

# UNIX services

exec         512/tcp                 # BSD rexecd

biff         512/udp  comsat         # mail notification

login        513/tcp                 # remote login

who          513/udp  whod           # remote who and uptime

shell        514/tcp  cmd            # remote command, no passwd used

syslog       514/udp                 # remote system logging

printer      515/tcp  spooler        # remote print spooling

route        520/udp  router routed  # routing information protocol

Note that the echo service is offered on port 7 for both TCP and UDP, and that port 512 is used for two different services: remote execution (rexec) using TCP, and the COMSAT daemon, which notifies users of new mail, over UDP (see xbiff(1x)).

Like the services file, the networking library needs a way to translate protocol names - for example, those used in the services file - to protocol numbers understood by the IP layer on other hosts. This is done by looking up the name in the /etc/protocols file. It contains one entry per line, each containing a protocol name, and the associated number. Having to touch this file is even more unlikely than having to meddle with /etc/services. A sample file is given in Example 12.3.

Example 12.3: A Sample /etc/protocols File

#

# Internet (IP) protocols

#

ip      0       IP              # internet protocol, pseudo protocol number

icmp    1       ICMP            # internet control message protocol

igmp    2       IGMP            # internet group multicast protocol

tcp     6       TCP             # transmission control protocol

udp     17      UDP             # user datagram protocol

raw     255     RAW             # RAW IP interface

Remote Procedure Call

The general mechanism for client-server applications is provided by the Remote Procedure Call (RPC) package. RPC was developed by Sun Microsystems and is a collection of tools and library functions. Important applications built on top of RPC are NIS, the Network Information System (described in Chapter 13, The Network Information System), and NFS, the Network File System (described in Chapter 14, The Network File System), which are both described in this book.

An RPC server consists of a collection of procedures that a client can call by sending an RPC request to the server along with the procedure parameters. The server will invoke the indicated procedure on behalf of the client, handing back the return value, if there is any. In order to be machine-independent, all data exchanged between client and server is converted to the External Data Representation format (XDR) by the sender, and converted back to the machine-local representation by the receiver. RPC relies on standard UDP and TCP sockets to transport the XDR formatted data to the remote host. Sun has graciously placed RPC in the public domain; it is described in a series of RFCs.

Sometimes improvements to an RPC application introduce incompatible changes in the procedure call interface. Of course, simply changing the server would crash all applications that still expect the original behavior. Therefore, RPC programs have version numbers assigned to them, usually starting with 1, and with each new version of the RPC interface, this counter will be bumped up. Often, a server may offer several versions simultaneously; clients then indicate by the version number in their requests which implementation of the service they want to use.

The communication between RPC servers and clients is somewhat peculiar. An RPC server offers one or more collections of procedures; each set is called a program and is uniquely identified by a program number. A list that maps service names to program numbers is usually kept in /etc/rpc, an excerpt of which is shown in Example 12.4.

Example 12.4: A Sample /etc/rpc File

#

# /etc/rpc - miscellaneous RPC-based services

#

portmapper      100000  portmap sunrpc

rstatd          100001  rstat rstat_svc rup perfmeter

rusersd         100002  rusers

nfs             100003  nfsprog

ypserv          100004  ypprog

mountd          100005  mount showmount

ypbind          100007

walld           100008  rwall shutdown

yppasswdd       100009  yppasswd

bootparam       100026

ypupdated       100028  ypupdate

In TCP/IP networks, the authors of RPC faced the problem of mapping program numbers to generic network services. They designed each server to provide both a TCP and a UDP port for each program and each version. Generally, RPC applications use UDP when sending data, and fall back to TCP only when the data to be transferred doesn't fit into a single UDP datagram.

Of course, client programs need to find out to which port a program number maps. Using a configuration file for this would be too unflexible; since RPC applications don't use reserved ports, there's no guarantee that a port originally meant to be used by our database application hasn't been taken by some other process. Therefore, RPC applications pick any port they can get and register it with a special program called the portmapper daemon. The portmapper acts as a service broker for all RPC servers

Добавить отзыв
ВСЕ ОТЗЫВЫ О КНИГЕ В ИЗБРАННОЕ

0

Вы можете отметить интересные вам фрагменты текста, которые будут доступны по уникальной ссылке в адресной строке браузера.

Отметить Добавить цитату