1*426d2b71SDavid du Colombier.HTML "The Organization of Networks in Plan 9 23e12c5d1SDavid du Colombier.TL 33e12c5d1SDavid du ColombierThe Organization of Networks in Plan 9 43e12c5d1SDavid du Colombier.AU 53e12c5d1SDavid du ColombierDave Presotto 63e12c5d1SDavid du ColombierPhil Winterbottom 7219b2ee8SDavid du Colombier.sp 87dd7cddfSDavid du Colombierpresotto,philw@plan9.bell-labs.com 93e12c5d1SDavid du Colombier.AB 10219b2ee8SDavid du Colombier.FS 11219b2ee8SDavid du ColombierOriginally appeared in 12219b2ee8SDavid du Colombier.I 13219b2ee8SDavid du ColombierProc. of the Winter 1993 USENIX Conf., 14219b2ee8SDavid du Colombier.R 15219b2ee8SDavid du Colombierpp. 271-280, 16219b2ee8SDavid du ColombierSan Diego, CA 17219b2ee8SDavid du Colombier.FE 183e12c5d1SDavid du ColombierIn a distributed system networks are of paramount importance. This 19219b2ee8SDavid du Colombierpaper describes the implementation, design philosophy, and organization 203e12c5d1SDavid du Colombierof network support in Plan 9. Topics include network requirements 21219b2ee8SDavid du Colombierfor distributed systems, our kernel implementation, network naming, user interfaces, 223e12c5d1SDavid du Colombierand performance. We also observe that much of this organization is relevant to 233e12c5d1SDavid du Colombiercurrent systems. 243e12c5d1SDavid du Colombier.AE 253e12c5d1SDavid du Colombier.NH 263e12c5d1SDavid du ColombierIntroduction 273e12c5d1SDavid du Colombier.PP 283e12c5d1SDavid du ColombierPlan 9 [Pike90] is a general-purpose, multi-user, portable distributed system 29bd389b36SDavid du Colombierimplemented on a variety of computers and networks. 30bd389b36SDavid du ColombierWhat distinguishes Plan 9 is its organization. 31bd389b36SDavid du ColombierThe goals of this organization were to 32bd389b36SDavid du Colombierreduce administration 333e12c5d1SDavid du Colombierand to promote resource sharing. One of the keys to its success as a distributed 343e12c5d1SDavid du Colombiersystem is the organization and management of its networks. 353e12c5d1SDavid du Colombier.PP 36bd389b36SDavid du ColombierA Plan 9 system comprises file servers, CPU servers and terminals. 37bd389b36SDavid du ColombierThe file servers and CPU servers are typically centrally 38bd389b36SDavid du Colombierlocated multiprocessor machines with large memories and 39bd389b36SDavid du Colombierhigh speed interconnects. 40bd389b36SDavid du ColombierA variety of workstation-class machines 41bd389b36SDavid du Colombierserve as terminals 42bd389b36SDavid du Colombierconnected to the central servers using several networks and protocols. 433e12c5d1SDavid du ColombierThe architecture of the system demands a hierarchy of network 443e12c5d1SDavid du Colombierspeeds matching the needs of the components. 45bd389b36SDavid du ColombierConnections between file servers and CPU servers are high-bandwidth point-to-point 46bd389b36SDavid du Colombierfiber links. 47bd389b36SDavid du ColombierConnections from the servers fan out to local terminals 48bd389b36SDavid du Colombierusing medium speed networks 49bd389b36SDavid du Colombiersuch as Ethernet [Met80] and Datakit [Fra80]. 503e12c5d1SDavid du ColombierLow speed connections via the Internet and 51bd389b36SDavid du Colombierthe AT&T backbone serve users in Oregon and Illinois. 52bd389b36SDavid du ColombierBasic Rate ISDN data service and 9600 baud serial lines provide slow 533e12c5d1SDavid du Colombierlinks to users at home. 543e12c5d1SDavid du Colombier.PP 55bd389b36SDavid du ColombierSince CPU servers and terminals use the same kernel, 56bd389b36SDavid du Colombierusers may choose to run programs locally on 573e12c5d1SDavid du Colombiertheir terminals or remotely on CPU servers. 58bd389b36SDavid du ColombierThe organization of Plan 9 hides the details of system connectivity 59bd389b36SDavid du Colombierallowing both users and administrators to configure their environment 603e12c5d1SDavid du Colombierto be as distributed or centralized as they wish. 61bd389b36SDavid du ColombierSimple commands support the 62bd389b36SDavid du Colombierconstruction of a locally represented name space 63bd389b36SDavid du Colombierspanning many machines and networks. 64219b2ee8SDavid du ColombierAt work, users tend to use their terminals like workstations, 65bd389b36SDavid du Colombierrunning interactive programs locally and 663e12c5d1SDavid du Colombierreserving the CPU servers for data or compute intensive jobs 673e12c5d1SDavid du Colombiersuch as compiling and computing chess endgames. 68bd389b36SDavid du ColombierAt home or when connected over 69bd389b36SDavid du Colombiera slow network, users tend to do most work on the CPU server to minimize 70219b2ee8SDavid du Colombiertraffic on the slow links. 713e12c5d1SDavid du ColombierThe goal of the network organization is to provide the same 723e12c5d1SDavid du Colombierenvironment to the user wherever resources are used. 733e12c5d1SDavid du Colombier.NH 743e12c5d1SDavid du ColombierKernel Network Support 753e12c5d1SDavid du Colombier.PP 76bd389b36SDavid du ColombierNetworks play a central role in any distributed system. This is particularly 773e12c5d1SDavid du Colombiertrue in Plan 9 where most resources are provided by servers external to the kernel. 78bd389b36SDavid du ColombierThe importance of the networking code within the kernel 79bd389b36SDavid du Colombieris reflected by its size; 80bd389b36SDavid du Colombierof 25,000 lines of kernel code, 12,500 are network and protocol related. 81bd389b36SDavid du ColombierNetworks are continually being added and the fraction of code 82bd389b36SDavid du Colombierdevoted to communications 83bd389b36SDavid du Colombieris growing. 84bd389b36SDavid du ColombierMoreover, the network code is complex. 853e12c5d1SDavid du ColombierProtocol implementations consist almost entirely of 86219b2ee8SDavid du Colombiersynchronization and dynamic memory management, areas demanding 87bd389b36SDavid du Colombiersubtle error recovery 88bd389b36SDavid du Colombierstrategies. 89bd389b36SDavid du ColombierThe kernel currently supports Datakit, point-to-point fiber links, 903e12c5d1SDavid du Colombieran Internet (IP) protocol suite and ISDN data service. 91bd389b36SDavid du ColombierThe variety of networks and machines 92bd389b36SDavid du Colombierhas raised issues not addressed by other systems running on commercial 933e12c5d1SDavid du Colombierhardware supporting only Ethernet or FDDI. 943e12c5d1SDavid du Colombier.NH 2 953e12c5d1SDavid du ColombierThe File System protocol 963e12c5d1SDavid du Colombier.PP 973e12c5d1SDavid du ColombierA central idea in Plan 9 is the representation of a resource as a hierarchical 983e12c5d1SDavid du Colombierfile system. 993e12c5d1SDavid du ColombierEach process assembles a view of the system by building a 100219b2ee8SDavid du Colombier.I "name space 101bd389b36SDavid du Colombier[Needham] connecting its resources. 102bd389b36SDavid du ColombierFile systems need not represent disc files; in fact, most Plan 9 file systems have no 1033e12c5d1SDavid du Colombierpermanent storage. 104bd389b36SDavid du ColombierA typical file system dynamically represents 105bd389b36SDavid du Colombiersome resource like a set of network connections or the process table. 106219b2ee8SDavid du ColombierCommunication between the kernel, device drivers, and local or remote file servers uses a 1073e12c5d1SDavid du Colombierprotocol called 9P. The protocol consists of 17 messages 108bd389b36SDavid du Colombierdescribing operations on files and directories. 109bd389b36SDavid du ColombierKernel resident device and protocol drivers use a procedural version 110bd389b36SDavid du Colombierof the protocol while external file servers use an RPC form. 1113e12c5d1SDavid du ColombierNearly all traffic between Plan 9 systems consists 1123e12c5d1SDavid du Colombierof 9P messages. 113bd389b36SDavid du Colombier9P relies on several properties of the underlying transport protocol. 114bd389b36SDavid du ColombierIt assumes messages arrive reliably and in sequence and 115bd389b36SDavid du Colombierthat delimiters between messages 116bd389b36SDavid du Colombierare preserved. 117bd389b36SDavid du ColombierWhen a protocol does not meet these 118219b2ee8SDavid du Colombierrequirements (for example, TCP does not preserve delimiters) 119bd389b36SDavid du Colombierwe provide mechanisms to marshal messages before handing them 120bd389b36SDavid du Colombierto the system. 1213e12c5d1SDavid du Colombier.PP 1223e12c5d1SDavid du ColombierA kernel data structure, the 1233e12c5d1SDavid du Colombier.I channel , 124bd389b36SDavid du Colombieris a handle to a file server. 125bd389b36SDavid du ColombierOperations on a channel generate the following 9P messages. 1263e12c5d1SDavid du ColombierThe 127219b2ee8SDavid du Colombier.CW session 1283e12c5d1SDavid du Colombierand 1293e12c5d1SDavid du Colombier.CW attach 130bd389b36SDavid du Colombiermessages authenticate a connection, established by means external to 9P, 1313e12c5d1SDavid du Colombierand validate its user. 1323e12c5d1SDavid du ColombierThe result is an authenticated 133bd389b36SDavid du Colombierchannel 134bd389b36SDavid du Colombierreferencing the root of the 1353e12c5d1SDavid du Colombierserver. 1363e12c5d1SDavid du ColombierThe 1373e12c5d1SDavid du Colombier.CW clone 138bd389b36SDavid du Colombiermessage makes a new channel identical to an existing channel, much like 139bd389b36SDavid du Colombierthe 140bd389b36SDavid du Colombier.CW dup 141bd389b36SDavid du Colombiersystem call. 1423e12c5d1SDavid du ColombierA 143bd389b36SDavid du Colombierchannel 1443e12c5d1SDavid du Colombiermay be moved to a file on the server using a 1453e12c5d1SDavid du Colombier.CW walk 1463e12c5d1SDavid du Colombiermessage to descend each level in the hierarchy. 1473e12c5d1SDavid du ColombierThe 1483e12c5d1SDavid du Colombier.CW stat 1493e12c5d1SDavid du Colombierand 1503e12c5d1SDavid du Colombier.CW wstat 151bd389b36SDavid du Colombiermessages read and write the attributes of the file referenced by a channel. 1523e12c5d1SDavid du ColombierThe 1533e12c5d1SDavid du Colombier.CW open 1543e12c5d1SDavid du Colombiermessage prepares a channel for subsequent 1553e12c5d1SDavid du Colombier.CW read 1563e12c5d1SDavid du Colombierand 1573e12c5d1SDavid du Colombier.CW write 158bd389b36SDavid du Colombiermessages to access the contents of the file. 159bd389b36SDavid du Colombier.CW Create 1603e12c5d1SDavid du Colombierand 1613e12c5d1SDavid du Colombier.CW remove 162bd389b36SDavid du Colombierperform the actions implied by their names on the file 163bd389b36SDavid du Colombierreferenced by the channel. 1643e12c5d1SDavid du ColombierThe 1653e12c5d1SDavid du Colombier.CW clunk 1663e12c5d1SDavid du Colombiermessage discards a channel without affecting the file. 1673e12c5d1SDavid du Colombier.PP 1683e12c5d1SDavid du ColombierA kernel resident file server called the 169bd389b36SDavid du Colombier.I "mount driver" 170219b2ee8SDavid du Colombierconverts the procedural version of 9P into RPCs. 171bd389b36SDavid du ColombierThe 1723e12c5d1SDavid du Colombier.I mount 173bd389b36SDavid du Colombiersystem call provides a file descriptor, which can be 174bd389b36SDavid du Colombiera pipe to a user process or a network connection to a remote machine, to 175bd389b36SDavid du Colombierbe associated with the mount point. 1763e12c5d1SDavid du ColombierAfter a mount, operations 1773e12c5d1SDavid du Colombieron the file tree below the mount point are sent as messages to the file server. 1783e12c5d1SDavid du ColombierThe 179bd389b36SDavid du Colombiermount 180bd389b36SDavid du Colombierdriver manages buffers, packs and unpacks parameters from 181219b2ee8SDavid du Colombiermessages, and demultiplexes among processes using the file server. 1823e12c5d1SDavid du Colombier.NH 2 1833e12c5d1SDavid du ColombierKernel Organization 1843e12c5d1SDavid du Colombier.PP 185bd389b36SDavid du ColombierThe network code in the kernel is divided into three layers: hardware interface, 1863e12c5d1SDavid du Colombierprotocol processing, and program interface. 187bd389b36SDavid du ColombierA device driver typically uses streams to connect the two interface layers. 188bd389b36SDavid du ColombierAdditional stream modules may be pushed on 189bd389b36SDavid du Colombiera device to process protocols. 190bd389b36SDavid du ColombierEach device driver is a kernel-resident file system. 1913e12c5d1SDavid du ColombierSimple device drivers serve a single level 192bd389b36SDavid du Colombierdirectory containing just a few files; 193bd389b36SDavid du Colombierfor example, we represent each UART 1943e12c5d1SDavid du Colombierby a data and a control file. 1953e12c5d1SDavid du Colombier.P1 196219b2ee8SDavid du Colombiercpu% cd /dev 197219b2ee8SDavid du Colombiercpu% ls -l eia* 1983e12c5d1SDavid du Colombier--rw-rw-rw- t 0 bootes bootes 0 Jul 16 17:28 eia1 1993e12c5d1SDavid du Colombier--rw-rw-rw- t 0 bootes bootes 0 Jul 16 17:28 eia1ctl 2003e12c5d1SDavid du Colombier--rw-rw-rw- t 0 bootes bootes 0 Jul 16 17:28 eia2 2013e12c5d1SDavid du Colombier--rw-rw-rw- t 0 bootes bootes 0 Jul 16 17:28 eia2ctl 202219b2ee8SDavid du Colombiercpu% 2033e12c5d1SDavid du Colombier.P2 204bd389b36SDavid du ColombierThe control file is used to control the device; 205bd389b36SDavid du Colombierwriting the string 206219b2ee8SDavid du Colombier.CW b1200 2073e12c5d1SDavid du Colombierto 2083e12c5d1SDavid du Colombier.CW /dev/eia1ctl 209bd389b36SDavid du Colombiersets the line to 1200 baud. 2103e12c5d1SDavid du Colombier.PP 211bd389b36SDavid du ColombierMultiplexed devices present 212bd389b36SDavid du Colombiera more complex interface structure. 213bd389b36SDavid du ColombierFor example, the LANCE Ethernet driver 214bd389b36SDavid du Colombierserves a two level file tree (Figure 1) 215bd389b36SDavid du Colombierproviding 2163e12c5d1SDavid du Colombier.IP \(bu 217bd389b36SDavid du Colombierdevice control and configuration 2183e12c5d1SDavid du Colombier.IP \(bu 219219b2ee8SDavid du Colombieruser-level protocols like ARP 2203e12c5d1SDavid du Colombier.IP \(bu 221bd389b36SDavid du Colombierdiagnostic interfaces for snooping software. 2223e12c5d1SDavid du Colombier.LP 2233e12c5d1SDavid du ColombierThe top directory contains a 2243e12c5d1SDavid du Colombier.CW clone 225bd389b36SDavid du Colombierfile and a directory for each connection, numbered 2263e12c5d1SDavid du Colombier.CW 1 2273e12c5d1SDavid du Colombierto 2283e12c5d1SDavid du Colombier.CW n . 229bd389b36SDavid du ColombierEach connection directory corresponds to an Ethernet packet type. 230bd389b36SDavid du ColombierOpening the 231bd389b36SDavid du Colombier.CW clone 232bd389b36SDavid du Colombierfile finds an unused connection directory 2333e12c5d1SDavid du Colombierand opens its 2343e12c5d1SDavid du Colombier.CW ctl 2353e12c5d1SDavid du Colombierfile. 236bd389b36SDavid du ColombierReading the control file returns the ASCII connection number; the user 237bd389b36SDavid du Colombierprocess can use this value to construct the name of the proper 238bd389b36SDavid du Colombierconnection directory. 239bd389b36SDavid du ColombierIn each connection directory files named 2403e12c5d1SDavid du Colombier.CW ctl , 2413e12c5d1SDavid du Colombier.CW data , 242219b2ee8SDavid du Colombier.CW stats , 2433e12c5d1SDavid du Colombierand 244bd389b36SDavid du Colombier.CW type 245bd389b36SDavid du Colombierprovide access to the connection. 2463e12c5d1SDavid du ColombierWriting the string 247219b2ee8SDavid du Colombier.CW "connect 2048" 2483e12c5d1SDavid du Colombierto the 2493e12c5d1SDavid du Colombier.CW ctl 250bd389b36SDavid du Colombierfile sets the packet type to 2048 251bd389b36SDavid du Colombierand 252bd389b36SDavid du Colombierconfigures the connection to receive 2533e12c5d1SDavid du Colombierall IP packets sent to the machine. 2543e12c5d1SDavid du ColombierSubsequent reads of the file 2553e12c5d1SDavid du Colombier.CW type 256bd389b36SDavid du Colombieryield the string 257219b2ee8SDavid du Colombier.CW 2048 . 2583e12c5d1SDavid du ColombierThe 2593e12c5d1SDavid du Colombier.CW data 260bd389b36SDavid du Colombierfile accesses the media; 261bd389b36SDavid du Colombierreading it 262bd389b36SDavid du Colombierreturns the 263bd389b36SDavid du Colombiernext packet of the selected type. 264bd389b36SDavid du ColombierWriting the file 265bd389b36SDavid du Colombierqueues a packet for transmission after 266bd389b36SDavid du Colombierappending a packet header containing the source address and packet type. 2673e12c5d1SDavid du ColombierThe 2683e12c5d1SDavid du Colombier.CW stats 269bd389b36SDavid du Colombierfile returns ASCII text containing the interface address, 270219b2ee8SDavid du Colombierpacket input/output counts, error statistics, and general information 2713e12c5d1SDavid du Colombierabout the state of the interface. 2723e12c5d1SDavid du Colombier.so tree.pout 2733e12c5d1SDavid du Colombier.PP 274bd389b36SDavid du ColombierIf several connections on an interface 275219b2ee8SDavid du Colombierare configured for a particular packet type, each receives a 2763e12c5d1SDavid du Colombiercopy of the incoming packets. 277219b2ee8SDavid du ColombierThe special packet type 278219b2ee8SDavid du Colombier.CW -1 279bd389b36SDavid du Colombierselects all packets. 2803e12c5d1SDavid du ColombierWriting the strings 281219b2ee8SDavid du Colombier.CW promiscuous 2823e12c5d1SDavid du Colombierand 283219b2ee8SDavid du Colombier.CW connect 284219b2ee8SDavid du Colombier.CW -1 285bd389b36SDavid du Colombierto the 2863e12c5d1SDavid du Colombier.CW ctl 287bd389b36SDavid du Colombierfile 288bd389b36SDavid du Colombierconfigures a conversation to receive all packets on the Ethernet. 2893e12c5d1SDavid du Colombier.PP 290bd389b36SDavid du ColombierAlthough the driver interface may seem elaborate, 291bd389b36SDavid du Colombierthe representation of a device as a set of files using ASCII strings for 292bd389b36SDavid du Colombiercommunication has several advantages. 293bd389b36SDavid du ColombierAny mechanism supporting remote access to files immediately 294bd389b36SDavid du Colombierallows a remote machine to use our interfaces as gateways. 295bd389b36SDavid du ColombierUsing ASCII strings to control the interface avoids byte order problems and 296bd389b36SDavid du Colombierensures a uniform representation for 297219b2ee8SDavid du Colombierdevices on the same machine and even allows devices to be accessed remotely. 298bd389b36SDavid du ColombierRepresenting dissimilar devices by the same set of files allows common tools 299bd389b36SDavid du Colombierto serve 300bd389b36SDavid du Colombierseveral networks or interfaces. 3013e12c5d1SDavid du ColombierPrograms like 3023e12c5d1SDavid du Colombier.CW stty 303bd389b36SDavid du Colombierare replaced by 3043e12c5d1SDavid du Colombier.CW echo 3053e12c5d1SDavid du Colombierand shell redirection. 3063e12c5d1SDavid du Colombier.NH 2 3073e12c5d1SDavid du ColombierProtocol devices 3083e12c5d1SDavid du Colombier.PP 3093e12c5d1SDavid du ColombierNetwork connections are represented as pseudo-devices called protocol devices. 3103e12c5d1SDavid du ColombierProtocol device drivers exist for the Datakit URP protocol and for each of the 3113e12c5d1SDavid du ColombierInternet IP protocols TCP, UDP, and IL. 3123e12c5d1SDavid du ColombierIL, described below, is a new communication protocol used by Plan 9 for 313bd389b36SDavid du Colombiertransmitting file system RPC's. 314bd389b36SDavid du ColombierAll protocol devices look identical so user programs contain no 315bd389b36SDavid du Colombiernetwork-specific code. 3163e12c5d1SDavid du Colombier.PP 317bd389b36SDavid du ColombierEach protocol device driver serves a directory structure 318bd389b36SDavid du Colombiersimilar to that of the Ethernet driver. 3193e12c5d1SDavid du ColombierThe top directory contains a 3203e12c5d1SDavid du Colombier.CW clone 321bd389b36SDavid du Colombierfile and a directory for each connection numbered 322219b2ee8SDavid du Colombier.CW 0 3233e12c5d1SDavid du Colombierto 3243e12c5d1SDavid du Colombier.CW n . 325bd389b36SDavid du ColombierEach connection directory contains files to control one 326bd389b36SDavid du Colombierconnection and to send and receive information. 327219b2ee8SDavid du ColombierA TCP connection directory looks like this: 3283e12c5d1SDavid du Colombier.P1 329219b2ee8SDavid du Colombiercpu% cd /net/tcp/2 330219b2ee8SDavid du Colombiercpu% ls -l 3313e12c5d1SDavid du Colombier--rw-rw---- I 0 ehg bootes 0 Jul 13 21:14 ctl 3323e12c5d1SDavid du Colombier--rw-rw---- I 0 ehg bootes 0 Jul 13 21:14 data 3333e12c5d1SDavid du Colombier--rw-rw---- I 0 ehg bootes 0 Jul 13 21:14 listen 3343e12c5d1SDavid du Colombier--r--r--r-- I 0 bootes bootes 0 Jul 13 21:14 local 3353e12c5d1SDavid du Colombier--r--r--r-- I 0 bootes bootes 0 Jul 13 21:14 remote 3363e12c5d1SDavid du Colombier--r--r--r-- I 0 bootes bootes 0 Jul 13 21:14 status 337219b2ee8SDavid du Colombiercpu% cat local remote status 3383e12c5d1SDavid du Colombier135.104.9.31 5012 3393e12c5d1SDavid du Colombier135.104.53.11 564 3403e12c5d1SDavid du Colombiertcp/2 1 Established connect 341219b2ee8SDavid du Colombiercpu% 3423e12c5d1SDavid du Colombier.P2 3433e12c5d1SDavid du ColombierThe files 3443e12c5d1SDavid du Colombier.CW local , 345219b2ee8SDavid du Colombier.CW remote , 3463e12c5d1SDavid du Colombierand 3473e12c5d1SDavid du Colombier.CW status 348bd389b36SDavid du Colombiersupply information about the state of the connection. 3493e12c5d1SDavid du ColombierThe 3503e12c5d1SDavid du Colombier.CW data 3513e12c5d1SDavid du Colombierand 3523e12c5d1SDavid du Colombier.CW ctl 353bd389b36SDavid du Colombierfiles 354bd389b36SDavid du Colombierprovide access to the process end of the stream implementing the protocol. 3553e12c5d1SDavid du ColombierThe 3563e12c5d1SDavid du Colombier.CW listen 357bd389b36SDavid du Colombierfile is used to accept incoming calls from the network. 3583e12c5d1SDavid du Colombier.PP 359bd389b36SDavid du ColombierThe following steps establish a connection. 3603e12c5d1SDavid du Colombier.IP 1) 3613e12c5d1SDavid du ColombierThe clone device of the 362bd389b36SDavid du Colombierappropriate protocol directory is opened to reserve an unused connection. 3633e12c5d1SDavid du Colombier.IP 2) 364bd389b36SDavid du ColombierThe file descriptor returned by the open points to the 3653e12c5d1SDavid du Colombier.CW ctl 3663e12c5d1SDavid du Colombierfile of the new connection. 367bd389b36SDavid du ColombierReading that file descriptor returns an ASCII string containing 3683e12c5d1SDavid du Colombierthe connection number. 3693e12c5d1SDavid du Colombier.IP 3) 3703e12c5d1SDavid du ColombierA protocol/network specific ASCII address string is written to the 3713e12c5d1SDavid du Colombier.CW ctl 3723e12c5d1SDavid du Colombierfile. 3733e12c5d1SDavid du Colombier.IP 4) 3743e12c5d1SDavid du ColombierThe path of the 3753e12c5d1SDavid du Colombier.CW data 376bd389b36SDavid du Colombierfile is constructed using the connection number. 377bd389b36SDavid du ColombierWhen the 3783e12c5d1SDavid du Colombier.CW data 379bd389b36SDavid du Colombierfile is opened the connection is established. 380bd389b36SDavid du Colombier.LP 381bd389b36SDavid du ColombierA process can read and write this file descriptor 382bd389b36SDavid du Colombierto send and receive messages from the network. 3833e12c5d1SDavid du ColombierIf the process opens the 3843e12c5d1SDavid du Colombier.CW listen 385bd389b36SDavid du Colombierfile it blocks until an incoming call is received. 386bd389b36SDavid du ColombierAn address string written to the 387bd389b36SDavid du Colombier.CW ctl 388bd389b36SDavid du Colombierfile before the listen selects the 389bd389b36SDavid du Colombierports or services the process is prepared to accept. 390bd389b36SDavid du ColombierWhen an incoming call is received, the open completes 391bd389b36SDavid du Colombierand returns a file descriptor 392bd389b36SDavid du Colombierpointing to the 393bd389b36SDavid du Colombier.CW ctl 394bd389b36SDavid du Colombierfile of the new connection. 395bd389b36SDavid du ColombierReading the 396bd389b36SDavid du Colombier.CW ctl 397bd389b36SDavid du Colombierfile yields a connection number used to construct the path of the 3983e12c5d1SDavid du Colombier.CW data 399bd389b36SDavid du Colombierfile. 4003e12c5d1SDavid du ColombierA connection remains established while any of the files in the connection directory 4013e12c5d1SDavid du Colombierare referenced or until a close is received from the network. 402219b2ee8SDavid du Colombier.NH 2 403219b2ee8SDavid du ColombierStreams 404219b2ee8SDavid du Colombier.PP 405219b2ee8SDavid du ColombierA 406219b2ee8SDavid du Colombier.I stream 407219b2ee8SDavid du Colombier[Rit84a][Presotto] is a bidirectional channel connecting a 408219b2ee8SDavid du Colombierphysical or pseudo-device to user processes. 409219b2ee8SDavid du ColombierThe user processes insert and remove data at one end of the stream. 410219b2ee8SDavid du ColombierKernel processes acting on behalf of a device insert data at 411219b2ee8SDavid du Colombierthe other end. 412219b2ee8SDavid du ColombierAsynchronous communications channels such as pipes, 413219b2ee8SDavid du ColombierTCP conversations, Datakit conversations, and RS232 lines are implemented using 414219b2ee8SDavid du Colombierstreams. 415219b2ee8SDavid du Colombier.PP 416219b2ee8SDavid du ColombierA stream comprises a linear list of 417219b2ee8SDavid du Colombier.I "processing modules" . 418219b2ee8SDavid du ColombierEach module has both an upstream (toward the process) and 419219b2ee8SDavid du Colombierdownstream (toward the device) 420219b2ee8SDavid du Colombier.I "put routine" . 421219b2ee8SDavid du ColombierCalling the put routine of the module on either end of the stream 422219b2ee8SDavid du Colombierinserts data into the stream. 423219b2ee8SDavid du ColombierEach module calls the succeeding one to send data up or down the stream. 424219b2ee8SDavid du Colombier.PP 425219b2ee8SDavid du ColombierAn instance of a processing module is represented by a pair of 426219b2ee8SDavid du Colombier.I queues , 427219b2ee8SDavid du Colombierone for each direction. 428219b2ee8SDavid du ColombierThe queues point to the put procedures and can be used 429219b2ee8SDavid du Colombierto queue information traveling along the stream. 430219b2ee8SDavid du ColombierSome put routines queue data locally and send it along the stream at some 431219b2ee8SDavid du Colombierlater time, either due to a subsequent call or an asynchronous 432219b2ee8SDavid du Colombierevent such as a retransmission timer or a device interrupt. 433219b2ee8SDavid du ColombierProcessing modules create helper kernel processes to 434219b2ee8SDavid du Colombierprovide a context for handling asynchronous events. 435219b2ee8SDavid du ColombierFor example, a helper kernel process awakens periodically 436219b2ee8SDavid du Colombierto perform any necessary TCP retransmissions. 437219b2ee8SDavid du ColombierThe use of kernel processes instead of serialized run-to-completion service routines 438219b2ee8SDavid du Colombierdiffers from the implementation of Unix streams. 439219b2ee8SDavid du ColombierUnix service routines cannot 440219b2ee8SDavid du Colombieruse any blocking kernel resource and they lack a local long-lived state. 441219b2ee8SDavid du ColombierHelper kernel processes solve these problems and simplify the stream code. 442219b2ee8SDavid du Colombier.PP 443219b2ee8SDavid du ColombierThere is no implicit synchronization in our streams. 444219b2ee8SDavid du ColombierEach processing module must ensure that concurrent processes using the stream 445219b2ee8SDavid du Colombierare synchronized. 446219b2ee8SDavid du ColombierThis maximizes concurrency but introduces the 447219b2ee8SDavid du Colombierpossibility of deadlock. 448219b2ee8SDavid du ColombierHowever, deadlocks are easily avoided by careful programming; to 449219b2ee8SDavid du Colombierdate they have not caused us problems. 450219b2ee8SDavid du Colombier.PP 451219b2ee8SDavid du ColombierInformation is represented by linked lists of kernel structures called 452219b2ee8SDavid du Colombier.I blocks . 453219b2ee8SDavid du ColombierEach block contains a type, some state flags, and pointers to 454219b2ee8SDavid du Colombieran optional buffer. 455219b2ee8SDavid du ColombierBlock buffers can hold either data or control information, i.e., directives 456219b2ee8SDavid du Colombierto the processing modules. 457219b2ee8SDavid du ColombierBlocks and block buffers are dynamically allocated from kernel memory. 458219b2ee8SDavid du Colombier.NH 3 459219b2ee8SDavid du ColombierUser Interface 460219b2ee8SDavid du Colombier.PP 461219b2ee8SDavid du ColombierA stream is represented at user level as two files, 462219b2ee8SDavid du Colombier.CW ctl 463219b2ee8SDavid du Colombierand 464219b2ee8SDavid du Colombier.CW data . 465219b2ee8SDavid du ColombierThe actual names can be changed by the device driver using the stream, 466219b2ee8SDavid du Colombieras we saw earlier in the example of the UART driver. 467219b2ee8SDavid du ColombierThe first process to open either file creates the stream automatically. 468219b2ee8SDavid du ColombierThe last close destroys it. 469219b2ee8SDavid du ColombierWriting to the 470219b2ee8SDavid du Colombier.CW data 471219b2ee8SDavid du Colombierfile copies the data into kernel blocks 472219b2ee8SDavid du Colombierand passes them to the downstream put routine of the first processing module. 473219b2ee8SDavid du ColombierA write of less than 32K is guaranteed to be contained by a single block. 474219b2ee8SDavid du ColombierConcurrent writes to the same stream are not synchronized, although the 475219b2ee8SDavid du Colombier32K block size assures atomic writes for most protocols. 476219b2ee8SDavid du ColombierThe last block written is flagged with a delimiter 477219b2ee8SDavid du Colombierto alert downstream modules that care about write boundaries. 478219b2ee8SDavid du ColombierIn most cases the first put routine calls the second, the second 479219b2ee8SDavid du Colombiercalls the third, and so on until the data is output. 480219b2ee8SDavid du ColombierAs a consequence, most data is output without context switching. 481219b2ee8SDavid du Colombier.PP 482219b2ee8SDavid du ColombierReading from the 483219b2ee8SDavid du Colombier.CW data 484219b2ee8SDavid du Colombierfile returns data queued at the top of the stream. 485219b2ee8SDavid du ColombierThe read terminates when the read count is reached 486219b2ee8SDavid du Colombieror when the end of a delimited block is encountered. 487219b2ee8SDavid du ColombierA per stream read lock ensures only one process 488219b2ee8SDavid du Colombiercan read from a stream at a time and guarantees 489219b2ee8SDavid du Colombierthat the bytes read were contiguous bytes from the 490219b2ee8SDavid du Colombierstream. 491219b2ee8SDavid du Colombier.PP 492219b2ee8SDavid du ColombierLike UNIX streams [Rit84a], 493219b2ee8SDavid du ColombierPlan 9 streams can be dynamically configured. 494219b2ee8SDavid du ColombierThe stream system intercepts and interprets 495219b2ee8SDavid du Colombierthe following control blocks: 496219b2ee8SDavid du Colombier.IP "\f(CWpush\fP \fIname\fR" 15 497219b2ee8SDavid du Colombieradds an instance of the processing module 498219b2ee8SDavid du Colombier.I name 499219b2ee8SDavid du Colombierto the top of the stream. 500219b2ee8SDavid du Colombier.IP \f(CWpop\fP 15 501219b2ee8SDavid du Colombierremoves the top module of the stream. 502219b2ee8SDavid du Colombier.IP \f(CWhangup\fP 15 503219b2ee8SDavid du Colombiersends a hangup message 504219b2ee8SDavid du Colombierup the stream from the device end. 505219b2ee8SDavid du Colombier.LP 506219b2ee8SDavid du ColombierOther control blocks are module-specific and are interpreted by each 507219b2ee8SDavid du Colombierprocessing module 508219b2ee8SDavid du Colombieras they pass. 509219b2ee8SDavid du Colombier.PP 510219b2ee8SDavid du ColombierThe convoluted syntax and semantics of the UNIX 511219b2ee8SDavid du Colombier.CW ioctl 512219b2ee8SDavid du Colombiersystem call convinced us to leave it out of Plan 9. 513219b2ee8SDavid du ColombierInstead, 514219b2ee8SDavid du Colombier.CW ioctl 515219b2ee8SDavid du Colombieris replaced by the 516219b2ee8SDavid du Colombier.CW ctl 517219b2ee8SDavid du Colombierfile. 518219b2ee8SDavid du ColombierWriting to the 519219b2ee8SDavid du Colombier.CW ctl 520219b2ee8SDavid du Colombierfile 521219b2ee8SDavid du Colombieris identical to writing to a 522219b2ee8SDavid du Colombier.CW data 523219b2ee8SDavid du Colombierfile except the blocks are of type 524219b2ee8SDavid du Colombier.I control . 525219b2ee8SDavid du ColombierA processing module parses each control block it sees. 526219b2ee8SDavid du ColombierCommands in control blocks are ASCII strings, so 527219b2ee8SDavid du Colombierbyte ordering is not an issue when one system 528219b2ee8SDavid du Colombiercontrols streams in a name space implemented on another processor. 529219b2ee8SDavid du ColombierThe time to parse control blocks is not important, since control 530219b2ee8SDavid du Colombieroperations are rare. 531219b2ee8SDavid du Colombier.NH 3 532219b2ee8SDavid du ColombierDevice Interface 533219b2ee8SDavid du Colombier.PP 534219b2ee8SDavid du ColombierThe module at the downstream end of the stream is part of a device interface. 535219b2ee8SDavid du ColombierThe particulars of the interface vary with the device. 536219b2ee8SDavid du ColombierMost device interfaces consist of an interrupt routine, an output 537219b2ee8SDavid du Colombierput routine, and a kernel process. 538219b2ee8SDavid du ColombierThe output put routine stages data for the 539219b2ee8SDavid du Colombierdevice and starts the device if it is stopped. 540219b2ee8SDavid du ColombierThe interrupt routine wakes up the kernel process whenever 541219b2ee8SDavid du Colombierthe device has input to be processed or needs more output staged. 542219b2ee8SDavid du ColombierThe kernel process puts information up the stream or stages more data for output. 543219b2ee8SDavid du ColombierThe division of labor among the different pieces varies depending on 544219b2ee8SDavid du Colombierhow much must be done at interrupt level. 545219b2ee8SDavid du ColombierHowever, the interrupt routine may not allocate blocks or call 546219b2ee8SDavid du Colombiera put routine since both actions require a process context. 547219b2ee8SDavid du Colombier.NH 3 548219b2ee8SDavid du ColombierMultiplexing 549219b2ee8SDavid du Colombier.PP 550219b2ee8SDavid du ColombierThe conversations using a protocol device must be 551219b2ee8SDavid du Colombiermultiplexed onto a single physical wire. 552219b2ee8SDavid du ColombierWe push a multiplexer processing module 553219b2ee8SDavid du Colombieronto the physical device stream to group the conversations. 554219b2ee8SDavid du ColombierThe device end modules on the conversations add the necessary header 555219b2ee8SDavid du Colombieronto downstream messages and then put them to the module downstream 556219b2ee8SDavid du Colombierof the multiplexer. 557219b2ee8SDavid du ColombierThe multiplexing module looks at each message moving up its stream and 558219b2ee8SDavid du Colombierputs it to the correct conversation stream after stripping 559219b2ee8SDavid du Colombierthe header controlling the demultiplexing. 560219b2ee8SDavid du Colombier.PP 561219b2ee8SDavid du ColombierThis is similar to the Unix implementation of multiplexer streams. 562219b2ee8SDavid du ColombierThe major difference is that we have no general structure that 563219b2ee8SDavid du Colombiercorresponds to a multiplexer. 564219b2ee8SDavid du ColombierEach attempt to produce a generalized multiplexer created a more complicated 565219b2ee8SDavid du Colombierstructure and underlined the basic difficulty of generalizing this mechanism. 566219b2ee8SDavid du ColombierWe now code each multiplexer from scratch and favor simplicity over 567219b2ee8SDavid du Colombiergenerality. 568219b2ee8SDavid du Colombier.NH 3 569219b2ee8SDavid du ColombierReflections 570219b2ee8SDavid du Colombier.PP 571219b2ee8SDavid du ColombierDespite five year's experience and the efforts of many programmers, 572219b2ee8SDavid du Colombierwe remain dissatisfied with the stream mechanism. 573219b2ee8SDavid du ColombierPerformance is not an issue; 574219b2ee8SDavid du Colombierthe time to process protocols and drive 575219b2ee8SDavid du Colombierdevice interfaces continues to dwarf the 576219b2ee8SDavid du Colombiertime spent allocating, freeing, and moving blocks 577219b2ee8SDavid du Colombierof data. 578219b2ee8SDavid du ColombierHowever the mechanism remains inordinately 579219b2ee8SDavid du Colombiercomplex. 580219b2ee8SDavid du ColombierMuch of the complexity results from our efforts 581219b2ee8SDavid du Colombierto make streams dynamically configurable, to 582219b2ee8SDavid du Colombierreuse processing modules on different devices 583219b2ee8SDavid du Colombierand to provide kernel synchronization 584219b2ee8SDavid du Colombierto ensure data structures 585219b2ee8SDavid du Colombierdon't disappear under foot. 586219b2ee8SDavid du ColombierThis is particularly irritating since we seldom use these properties. 587219b2ee8SDavid du Colombier.PP 588219b2ee8SDavid du ColombierStreams remain in our kernel because we are unable to 589219b2ee8SDavid du Colombierdevise a better alternative. 590219b2ee8SDavid du ColombierLarry Peterson's X-kernel [Pet89a] 591219b2ee8SDavid du Colombieris the closest contender but 592219b2ee8SDavid du Colombierdoesn't offer enough advantage to switch. 593219b2ee8SDavid du ColombierIf we were to rewrite the streams code, we would probably statically 594219b2ee8SDavid du Colombierallocate resources for a large fixed number of conversations and burn 595219b2ee8SDavid du Colombiermemory in favor of less complexity. 5963e12c5d1SDavid du Colombier.NH 5973e12c5d1SDavid du ColombierThe IL Protocol 5983e12c5d1SDavid du Colombier.PP 599219b2ee8SDavid du ColombierNone of the standard IP protocols is suitable for transmission of 6003e12c5d1SDavid du Colombier9P messages over an Ethernet or the Internet. 6013e12c5d1SDavid du ColombierTCP has a high overhead and does not preserve delimiters. 602bd389b36SDavid du ColombierUDP, while cheap, does not provide reliable sequenced delivery. 603bd389b36SDavid du ColombierEarly versions of the system used a custom protocol that was 604bd389b36SDavid du Colombierefficient but unsatisfactory for internetwork transmission. 605219b2ee8SDavid du ColombierWhen we implemented IP, TCP, and UDP we looked around for a suitable 606bd389b36SDavid du Colombierreplacement with the following properties: 6073e12c5d1SDavid du Colombier.IP \(bu 6083e12c5d1SDavid du ColombierReliable datagram service with sequenced delivery 6093e12c5d1SDavid du Colombier.IP \(bu 610bd389b36SDavid du ColombierRuns over IP 6113e12c5d1SDavid du Colombier.IP \(bu 6123e12c5d1SDavid du ColombierLow complexity, high performance 6133e12c5d1SDavid du Colombier.IP \(bu 614bd389b36SDavid du ColombierAdaptive timeouts 6153e12c5d1SDavid du Colombier.LP 616bd389b36SDavid du ColombierNone met our needs so a new protocol was designed. 6173e12c5d1SDavid du ColombierIL is a lightweight protocol designed to be encapsulated by IP. 618bd389b36SDavid du ColombierIt is a connection-based protocol 619bd389b36SDavid du Colombierproviding reliable transmission of sequenced messages between machines. 620bd389b36SDavid du ColombierNo provision is made for flow control since the protocol is designed to transport RPC 6213e12c5d1SDavid du Colombiermessages between client and server. 6223e12c5d1SDavid du ColombierA small outstanding message window prevents too 623bd389b36SDavid du Colombiermany incoming messages from being buffered; 624bd389b36SDavid du Colombiermessages outside the window are discarded 625bd389b36SDavid du Colombierand must be retransmitted. 6263e12c5d1SDavid du ColombierConnection setup uses a two way handshake to generate 627bd389b36SDavid du Colombierinitial sequence numbers at each end of the connection; 628bd389b36SDavid du Colombiersubsequent data messages increment the 629bd389b36SDavid du Colombiersequence numbers allowing 630bd389b36SDavid du Colombierthe receiver to resequence out of order messages. 631bd389b36SDavid du ColombierIn contrast to other protocols, IL does not do blind retransmission. 632bd389b36SDavid du ColombierIf a message is lost and a timeout occurs, a query message is sent. 6333e12c5d1SDavid du ColombierThe query message is a small control message containing the current 6343e12c5d1SDavid du Colombiersequence numbers as seen by the sender. 6353e12c5d1SDavid du ColombierThe receiver responds to a query by retransmitting missing messages. 6363e12c5d1SDavid du ColombierThis allows the protocol to behave well in congested networks, 6373e12c5d1SDavid du Colombierwhere blind retransmission would cause further 6383e12c5d1SDavid du Colombiercongestion. 6393e12c5d1SDavid du ColombierLike TCP, IL has adaptive timeouts. 6403e12c5d1SDavid du ColombierA round-trip timer is used 6413e12c5d1SDavid du Colombierto calculate acknowledge and retransmission times in terms of the network speed. 642bd389b36SDavid du ColombierThis allows the protocol to perform well on both the Internet and on local Ethernets. 6433e12c5d1SDavid du Colombier.PP 6443e12c5d1SDavid du ColombierIn keeping with the minimalist design of the rest of the kernel, IL is small. 6453e12c5d1SDavid du ColombierThe entire protocol is 847 lines of code, compared to 2200 lines for TCP. 646bd389b36SDavid du ColombierIL is our protocol of choice. 6473e12c5d1SDavid du Colombier.NH 6483e12c5d1SDavid du ColombierNetwork Addressing 6493e12c5d1SDavid du Colombier.PP 650bd389b36SDavid du ColombierA uniform interface to protocols and devices is not sufficient to 651bd389b36SDavid du Colombiersupport the transparency we require. 652bd389b36SDavid du ColombierSince each network uses a different 653bd389b36SDavid du Colombieraddressing scheme, 654bd389b36SDavid du Colombierthe ASCII strings written to a control file have no common format. 655bd389b36SDavid du ColombierAs a result, every tool must know the specifics of the networks it 6563e12c5d1SDavid du Colombieris capable of addressing. 657bd389b36SDavid du ColombierMoreover, since each machine supplies a subset 658bd389b36SDavid du Colombierof the available networks, each user must be aware of the networks supported 659bd389b36SDavid du Colombierby every terminal and server machine. 660bd389b36SDavid du ColombierThis is obviously unacceptable. 6613e12c5d1SDavid du Colombier.PP 662bd389b36SDavid du ColombierSeveral possible solutions were considered and rejected; one deserves 6633e12c5d1SDavid du Colombiermore discussion. 664bd389b36SDavid du ColombierWe could have used a user-level file server 6653e12c5d1SDavid du Colombierto represent the network name space as a Plan 9 file tree. 6663e12c5d1SDavid du ColombierThis global naming scheme has been implemented in other distributed systems. 667bd389b36SDavid du ColombierThe file hierarchy provides paths to 668bd389b36SDavid du Colombierdirectories representing network domains. 669bd389b36SDavid du ColombierEach directory contains 670bd389b36SDavid du Colombierfiles representing the names of the machines in that domain; 6713e12c5d1SDavid du Colombieran example might be the path 6723e12c5d1SDavid du Colombier.CW /net/name/usa/edu/mit/ai . 673bd389b36SDavid du ColombierEach machine file contains information like the IP address of the machine. 674bd389b36SDavid du ColombierWe rejected this representation for several reasons. 675bd389b36SDavid du ColombierFirst, it is hard to devise a hierarchy encompassing all representations 6763e12c5d1SDavid du Colombierof the various network addressing schemes in a uniform manner. 6773e12c5d1SDavid du ColombierDatakit and Ethernet address strings have nothing in common. 6783e12c5d1SDavid du ColombierSecond, the address of a machine is 679bd389b36SDavid du Colombieroften only a small part of the information required to connect to a service on 680bd389b36SDavid du Colombierthe machine. 681bd389b36SDavid du ColombierFor example, the IP protocols require symbolic service names to be mapped into 6823e12c5d1SDavid du Colombiernumeric port numbers, some of which are privileged and hence special. 6833e12c5d1SDavid du ColombierInformation of this sort is hard to represent in terms of file operations. 684bd389b36SDavid du ColombierFinally, the size and number of the networks being represented burdens users with 6853e12c5d1SDavid du Colombieran unacceptably large amount of information about the organization of the network 6863e12c5d1SDavid du Colombierand its connectivity. 687bd389b36SDavid du ColombierIn this case the Plan 9 representation of a 688bd389b36SDavid du Colombierresource as a file is not appropriate. 6893e12c5d1SDavid du Colombier.PP 690bd389b36SDavid du ColombierIf tools are to be network independent, a third-party server must resolve 6913e12c5d1SDavid du Colombiernetwork names. 6923e12c5d1SDavid du ColombierA server on each machine, with local knowledge, can select the best network 693bd389b36SDavid du Colombierfor any particular destination machine or service. 694bd389b36SDavid du ColombierSince the network devices present a common interface, 6953e12c5d1SDavid du Colombierthe only operation which differs between networks is name resolution. 696bd389b36SDavid du ColombierA symbolic name must be translated to 697bd389b36SDavid du Colombierthe path of the clone file of a protocol 698bd389b36SDavid du Colombierdevice and an ASCII address string to write to the 6993e12c5d1SDavid du Colombier.CW ctl 7003e12c5d1SDavid du Colombierfile. 7013e12c5d1SDavid du ColombierA connection server (CS) provides this service. 702219b2ee8SDavid du Colombier.NH 2 703219b2ee8SDavid du ColombierNetwork Database 704219b2ee8SDavid du Colombier.PP 705219b2ee8SDavid du ColombierOn most systems several 706219b2ee8SDavid du Colombierfiles such as 707219b2ee8SDavid du Colombier.CW /etc/hosts , 708219b2ee8SDavid du Colombier.CW /etc/networks , 709219b2ee8SDavid du Colombier.CW /etc/services , 710219b2ee8SDavid du Colombier.CW /etc/hosts.equiv , 711219b2ee8SDavid du Colombier.CW /etc/bootptab , 712219b2ee8SDavid du Colombierand 713219b2ee8SDavid du Colombier.CW /etc/named.d 714219b2ee8SDavid du Colombierhold network information. 715219b2ee8SDavid du ColombierMuch time and effort is spent 716219b2ee8SDavid du Colombieradministering these files and keeping 717219b2ee8SDavid du Colombierthem mutually consistent. 718219b2ee8SDavid du ColombierTools attempt to 719219b2ee8SDavid du Colombierautomatically derive one or more of the files from 720219b2ee8SDavid du Colombierinformation in other files but maintenance continues to be 721219b2ee8SDavid du Colombierdifficult and error prone. 722219b2ee8SDavid du Colombier.PP 723219b2ee8SDavid du ColombierSince we were writing an entirely new system, we were free to 724219b2ee8SDavid du Colombiertry a simpler approach. 725219b2ee8SDavid du ColombierOne database on a shared server contains all the information 726219b2ee8SDavid du Colombierneeded for network administration. 727219b2ee8SDavid du ColombierTwo ASCII files comprise the main database: 728219b2ee8SDavid du Colombier.CW /lib/ndb/local 729219b2ee8SDavid du Colombiercontains locally administered information and 730219b2ee8SDavid du Colombier.CW /lib/ndb/global 731219b2ee8SDavid du Colombiercontains information imported from elsewhere. 732219b2ee8SDavid du ColombierThe files contain sets of attribute/value pairs of the form 733219b2ee8SDavid du Colombier.I attr\f(CW=\fPvalue , 734219b2ee8SDavid du Colombierwhere 735219b2ee8SDavid du Colombier.I attr 736219b2ee8SDavid du Colombierand 737219b2ee8SDavid du Colombier.I value 738219b2ee8SDavid du Colombierare alphanumeric strings. 739219b2ee8SDavid du ColombierSystems are described by multi-line entries; 740219b2ee8SDavid du Colombiera header line at the left margin begins each entry followed by zero or more 741219b2ee8SDavid du Colombierindented attribute/value pairs specifying 742219b2ee8SDavid du Colombiernames, addresses, properties, etc. 743219b2ee8SDavid du ColombierFor example, the entry for our CPU server 744219b2ee8SDavid du Colombierspecifies a domain name, an IP address, an Ethernet address, 745219b2ee8SDavid du Colombiera Datakit address, a boot file, and supported protocols. 746219b2ee8SDavid du Colombier.P1 747219b2ee8SDavid du Colombiersys=helix 7487dd7cddfSDavid du Colombier dom=helix.research.bell-labs.com 749219b2ee8SDavid du Colombier bootf=/mips/9power 750219b2ee8SDavid du Colombier ip=135.104.9.31 ether=0800690222f0 751219b2ee8SDavid du Colombier dk=nj/astro/helix 752219b2ee8SDavid du Colombier proto=il flavor=9cpu 753219b2ee8SDavid du Colombier.P2 754219b2ee8SDavid du ColombierIf several systems share entries such as 755219b2ee8SDavid du Colombiernetwork mask and gateway, we specify that information 756219b2ee8SDavid du Colombierwith the network or subnetwork instead of the system. 757219b2ee8SDavid du ColombierThe following entries define a Class B IP network and 758219b2ee8SDavid du Colombiera few subnets derived from it. 759219b2ee8SDavid du ColombierThe entry for the network specifies the IP mask, 760219b2ee8SDavid du Colombierfile system, and authentication server for all systems 761219b2ee8SDavid du Colombieron the network. 762219b2ee8SDavid du ColombierEach subnetwork specifies its default IP gateway. 763219b2ee8SDavid du Colombier.P1 764219b2ee8SDavid du Colombieripnet=mh-astro-net ip=135.104.0.0 ipmask=255.255.255.0 7657dd7cddfSDavid du Colombier fs=bootes.research.bell-labs.com 766219b2ee8SDavid du Colombier auth=1127auth 767219b2ee8SDavid du Colombieripnet=unix-room ip=135.104.117.0 768219b2ee8SDavid du Colombier ipgw=135.104.117.1 769219b2ee8SDavid du Colombieripnet=third-floor ip=135.104.51.0 770219b2ee8SDavid du Colombier ipgw=135.104.51.1 771219b2ee8SDavid du Colombieripnet=fourth-floor ip=135.104.52.0 772219b2ee8SDavid du Colombier ipgw=135.104.52.1 773219b2ee8SDavid du Colombier.P2 774219b2ee8SDavid du ColombierDatabase entries also define the mapping of service names 775219b2ee8SDavid du Colombierto port numbers for TCP, UDP, and IL. 776219b2ee8SDavid du Colombier.P1 777219b2ee8SDavid du Colombiertcp=echo port=7 778219b2ee8SDavid du Colombiertcp=discard port=9 779219b2ee8SDavid du Colombiertcp=systat port=11 780219b2ee8SDavid du Colombiertcp=daytime port=13 781219b2ee8SDavid du Colombier.P2 782219b2ee8SDavid du Colombier.PP 783219b2ee8SDavid du ColombierAll programs read the database directly so 784219b2ee8SDavid du Colombierconsistency problems are rare. 785219b2ee8SDavid du ColombierHowever the database files can become large. 786219b2ee8SDavid du ColombierOur global file, containing all information about 787219b2ee8SDavid du Colombierboth Datakit and Internet systems in AT&T, has 43,000 788219b2ee8SDavid du Colombierlines. 789219b2ee8SDavid du ColombierTo speed searches, we build hash table files for each 790219b2ee8SDavid du Colombierattribute we expect to search often. 791219b2ee8SDavid du ColombierThe hash file entries point to entries 792219b2ee8SDavid du Colombierin the master files. 793219b2ee8SDavid du ColombierEvery hash file contains the modification time of its master 794219b2ee8SDavid du Colombierfile so we can avoid using an out-of-date hash table. 795219b2ee8SDavid du ColombierSearches for attributes that aren't hashed or whose hash table 796219b2ee8SDavid du Colombieris out-of-date still work, they just take longer. 797219b2ee8SDavid du Colombier.NH 2 798219b2ee8SDavid du ColombierConnection Server 799219b2ee8SDavid du Colombier.PP 800219b2ee8SDavid du ColombierOn each system a user level connection server process, CS, translates 801219b2ee8SDavid du Colombiersymbolic names to addresses. 802219b2ee8SDavid du ColombierCS uses information about available networks, the network database, and 803219b2ee8SDavid du Colombierother servers (such as DNS) to translate names. 804219b2ee8SDavid du ColombierCS is a file server serving a single file, 805219b2ee8SDavid du Colombier.CW /net/cs . 806219b2ee8SDavid du ColombierA client writes a symbolic name to 807219b2ee8SDavid du Colombier.CW /net/cs 808219b2ee8SDavid du Colombierthen reads one line for each matching destination reachable 809219b2ee8SDavid du Colombierfrom this system. 810219b2ee8SDavid du ColombierThe lines are of the form 811219b2ee8SDavid du Colombier.I "filename message", 812219b2ee8SDavid du Colombierwhere 813219b2ee8SDavid du Colombier.I filename 814219b2ee8SDavid du Colombieris the path of the clone file to open for a new connection and 815219b2ee8SDavid du Colombier.I message 816219b2ee8SDavid du Colombieris the string to write to it to make the connection. 817219b2ee8SDavid du ColombierThe following example illustrates this. 818219b2ee8SDavid du Colombier.CW Ndb/csquery 819219b2ee8SDavid du Colombieris a program that prompts for strings to write to 820219b2ee8SDavid du Colombier.CW /net/cs 821219b2ee8SDavid du Colombierand prints the replies. 822219b2ee8SDavid du Colombier.P1 823219b2ee8SDavid du Colombier% ndb/csquery 824219b2ee8SDavid du Colombier> net!helix!9fs 825219b2ee8SDavid du Colombier/net/il/clone 135.104.9.31!17008 826219b2ee8SDavid du Colombier/net/dk/clone nj/astro/helix!9fs 827219b2ee8SDavid du Colombier.P2 828219b2ee8SDavid du Colombier.PP 829219b2ee8SDavid du ColombierCS provides meta-name translation to perform complicated 830219b2ee8SDavid du Colombiersearches. 831219b2ee8SDavid du ColombierThe special network name 832219b2ee8SDavid du Colombier.CW net 833219b2ee8SDavid du Colombierselects any network in common between source and 834219b2ee8SDavid du Colombierdestination supporting the specified service. 835219b2ee8SDavid du ColombierA host name of the form \f(CW$\fIattr\f1 836219b2ee8SDavid du Colombieris the name of an attribute in the network database. 837219b2ee8SDavid du ColombierThe database search returns the value 838219b2ee8SDavid du Colombierof the matching attribute/value pair 839219b2ee8SDavid du Colombiermost closely associated with the source host. 840219b2ee8SDavid du ColombierMost closely associated is defined on a per network basis. 841219b2ee8SDavid du ColombierFor example, the symbolic name 842219b2ee8SDavid du Colombier.CW tcp!$auth!rexauth 843219b2ee8SDavid du Colombiercauses CS to search for the 844219b2ee8SDavid du Colombier.CW auth 845219b2ee8SDavid du Colombierattribute in the database entry for the source system, then its 846219b2ee8SDavid du Colombiersubnetwork (if there is one) and then its network. 847219b2ee8SDavid du Colombier.P1 848219b2ee8SDavid du Colombier% ndb/csquery 849219b2ee8SDavid du Colombier> net!$auth!rexauth 850219b2ee8SDavid du Colombier/net/il/clone 135.104.9.34!17021 851219b2ee8SDavid du Colombier/net/dk/clone nj/astro/p9auth!rexauth 852219b2ee8SDavid du Colombier/net/il/clone 135.104.9.6!17021 853219b2ee8SDavid du Colombier/net/dk/clone nj/astro/musca!rexauth 854219b2ee8SDavid du Colombier.P2 855219b2ee8SDavid du Colombier.PP 856219b2ee8SDavid du ColombierNormally CS derives naming information from its database files. 857219b2ee8SDavid du ColombierFor domain names however, CS first consults another user level 858219b2ee8SDavid du Colombierprocess, the domain name server (DNS). 859219b2ee8SDavid du ColombierIf no DNS is reachable, CS relies on its own tables. 860219b2ee8SDavid du Colombier.PP 861219b2ee8SDavid du ColombierLike CS, the domain name server is a user level process providing 862219b2ee8SDavid du Colombierone file, 863219b2ee8SDavid du Colombier.CW /net/dns . 864219b2ee8SDavid du ColombierA client writes a request of the form 865219b2ee8SDavid du Colombier.I "domain-name type" , 866219b2ee8SDavid du Colombierwhere 867219b2ee8SDavid du Colombier.I type 868219b2ee8SDavid du Colombieris a domain name service resource record type. 869219b2ee8SDavid du ColombierDNS performs a recursive query through the 870219b2ee8SDavid du ColombierInternet domain name system producing one line 871219b2ee8SDavid du Colombierper resource record found. The client reads 872219b2ee8SDavid du Colombier.CW /net/dns 873219b2ee8SDavid du Colombierto retrieve the records. 874219b2ee8SDavid du ColombierLike other domain name servers, DNS caches information 875219b2ee8SDavid du Colombierlearned from the network. 876219b2ee8SDavid du ColombierDNS is implemented as a multi-process shared memory application 877219b2ee8SDavid du Colombierwith separate processes listening for network and local requests. 878219b2ee8SDavid du Colombier.NH 879219b2ee8SDavid du ColombierLibrary routines 880219b2ee8SDavid du Colombier.PP 881219b2ee8SDavid du ColombierThe section on protocol devices described the details 882219b2ee8SDavid du Colombierof making and receiving connections across a network. 883219b2ee8SDavid du ColombierThe dance is straightforward but tedious. 884219b2ee8SDavid du ColombierLibrary routines are provided to relieve 885219b2ee8SDavid du Colombierthe programmer of the details. 886219b2ee8SDavid du Colombier.NH 2 887219b2ee8SDavid du ColombierConnecting 888219b2ee8SDavid du Colombier.PP 889219b2ee8SDavid du ColombierThe 890219b2ee8SDavid du Colombier.CW dial 891219b2ee8SDavid du Colombierlibrary call establishes a connection to a remote destination. 892219b2ee8SDavid du ColombierIt 893219b2ee8SDavid du Colombierreturns an open file descriptor for the 894219b2ee8SDavid du Colombier.CW data 895219b2ee8SDavid du Colombierfile in the connection directory. 896219b2ee8SDavid du Colombier.P1 897219b2ee8SDavid du Colombierint dial(char *dest, char *local, char *dir, int *cfdp) 898219b2ee8SDavid du Colombier.P2 899219b2ee8SDavid du Colombier.IP \f(CWdest\fP 10 900219b2ee8SDavid du Colombieris the symbolic name/address of the destination. 901219b2ee8SDavid du Colombier.IP \f(CWlocal\fP 10 902219b2ee8SDavid du Colombieris the local address. 903219b2ee8SDavid du ColombierSince most networks do not support this, it is 904219b2ee8SDavid du Colombierusually zero. 905219b2ee8SDavid du Colombier.IP \f(CWdir\fP 10 906219b2ee8SDavid du Colombieris a pointer to a buffer to hold the path name of the protocol directory 907219b2ee8SDavid du Colombierrepresenting this connection. 908219b2ee8SDavid du Colombier.CW Dial 909219b2ee8SDavid du Colombierfills this buffer if the pointer is non-zero. 910219b2ee8SDavid du Colombier.IP \f(CWcfdp\fP 10 911219b2ee8SDavid du Colombieris a pointer to a file descriptor for the 912219b2ee8SDavid du Colombier.CW ctl 913219b2ee8SDavid du Colombierfile of the connection. 914219b2ee8SDavid du ColombierIf the pointer is non-zero, 915219b2ee8SDavid du Colombier.CW dial 916219b2ee8SDavid du Colombieropens the control file and tucks the file descriptor here. 917219b2ee8SDavid du Colombier.LP 918219b2ee8SDavid du ColombierMost programs call 919219b2ee8SDavid du Colombier.CW dial 920219b2ee8SDavid du Colombierwith a destination name and all other arguments zero. 921219b2ee8SDavid du Colombier.CW Dial 922219b2ee8SDavid du Colombieruses CS to 923219b2ee8SDavid du Colombiertranslate the symbolic name to all possible destination addresses 924219b2ee8SDavid du Colombierand attempts to connect to each in turn until one works. 925219b2ee8SDavid du ColombierSpecifying the special name 926219b2ee8SDavid du Colombier.CW net 927219b2ee8SDavid du Colombierin the network portion of the destination 928219b2ee8SDavid du Colombierallows CS to pick a network/protocol in common 929219b2ee8SDavid du Colombierwith the destination for which the requested service is valid. 930219b2ee8SDavid du ColombierFor example, assume the system 9317dd7cddfSDavid du Colombier.CW research.bell-labs.com 932219b2ee8SDavid du Colombierhas the Datakit address 933219b2ee8SDavid du Colombier.CW nj/astro/research 934219b2ee8SDavid du Colombierand IP addresses 935219b2ee8SDavid du Colombier.CW 135.104.117.5 936219b2ee8SDavid du Colombierand 937219b2ee8SDavid du Colombier.CW 129.11.4.1 . 938219b2ee8SDavid du ColombierThe call 939219b2ee8SDavid du Colombier.P1 9407dd7cddfSDavid du Colombierfd = dial("net!research.bell-labs.com!login", 0, 0, 0, 0); 941219b2ee8SDavid du Colombier.P2 942219b2ee8SDavid du Colombiertries in succession to connect to 943219b2ee8SDavid du Colombier.CW nj/astro/research!login 944219b2ee8SDavid du Colombieron the Datakit and both 945219b2ee8SDavid du Colombier.CW 135.104.117.5!513 946219b2ee8SDavid du Colombierand 947219b2ee8SDavid du Colombier.CW 129.11.4.1!513 948219b2ee8SDavid du Colombieracross the Internet. 949219b2ee8SDavid du Colombier.PP 950219b2ee8SDavid du Colombier.CW Dial 951219b2ee8SDavid du Colombieraccepts addresses instead of symbolic names. 952219b2ee8SDavid du ColombierFor example, the destinations 953219b2ee8SDavid du Colombier.CW tcp!135.104.117.5!513 954219b2ee8SDavid du Colombierand 9557dd7cddfSDavid du Colombier.CW tcp!research.bell-labs.com!login 956219b2ee8SDavid du Colombierare equivalent 957219b2ee8SDavid du Colombierreferences to the same machine. 958219b2ee8SDavid du Colombier.NH 2 959219b2ee8SDavid du ColombierListening 960219b2ee8SDavid du Colombier.PP 961219b2ee8SDavid du ColombierA program uses 962219b2ee8SDavid du Colombierfour routines to listen for incoming connections. 963219b2ee8SDavid du ColombierIt first 964219b2ee8SDavid du Colombier.CW announce() s 965219b2ee8SDavid du Colombierits intention to receive connections, 966219b2ee8SDavid du Colombierthen 967219b2ee8SDavid du Colombier.CW listen() s 968219b2ee8SDavid du Colombierfor calls and finally 969219b2ee8SDavid du Colombier.CW accept() s 970219b2ee8SDavid du Colombieror 971219b2ee8SDavid du Colombier.CW reject() s 972219b2ee8SDavid du Colombierthem. 973219b2ee8SDavid du Colombier.CW Announce 974219b2ee8SDavid du Colombierreturns an open file descriptor for the 975219b2ee8SDavid du Colombier.CW ctl 976219b2ee8SDavid du Colombierfile of a connection and fills 977219b2ee8SDavid du Colombier.CW dir 978219b2ee8SDavid du Colombierwith the 979219b2ee8SDavid du Colombierpath of the protocol directory 980219b2ee8SDavid du Colombierfor the announcement. 981219b2ee8SDavid du Colombier.P1 982219b2ee8SDavid du Colombierint announce(char *addr, char *dir) 983219b2ee8SDavid du Colombier.P2 984219b2ee8SDavid du Colombier.CW Addr 985219b2ee8SDavid du Colombieris the symbolic name/address announced; 986219b2ee8SDavid du Colombierif it does not contain a service, the announcement is for 987219b2ee8SDavid du Colombierall services not explicitly announced. 988219b2ee8SDavid du ColombierThus, one can easily write the equivalent of the 989219b2ee8SDavid du Colombier.CW inetd 990219b2ee8SDavid du Colombierprogram without 991219b2ee8SDavid du Colombierhaving to announce each separate service. 992219b2ee8SDavid du ColombierAn announcement remains in force until the control file is 993219b2ee8SDavid du Colombierclosed. 994219b2ee8SDavid du Colombier.LP 995219b2ee8SDavid du Colombier.CW Listen 996219b2ee8SDavid du Colombierreturns an open file descriptor for the 997219b2ee8SDavid du Colombier.CW ctl 998219b2ee8SDavid du Colombierfile and fills 999219b2ee8SDavid du Colombier.CW ldir 1000219b2ee8SDavid du Colombierwith the path 1001219b2ee8SDavid du Colombierof the protocol directory 1002219b2ee8SDavid du Colombierfor the received connection. 1003219b2ee8SDavid du ColombierIt is passed 1004219b2ee8SDavid du Colombier.CW dir 1005219b2ee8SDavid du Colombierfrom the announcement. 1006219b2ee8SDavid du Colombier.P1 1007219b2ee8SDavid du Colombierint listen(char *dir, char *ldir) 1008219b2ee8SDavid du Colombier.P2 1009219b2ee8SDavid du Colombier.LP 1010219b2ee8SDavid du Colombier.CW Accept 1011219b2ee8SDavid du Colombierand 1012219b2ee8SDavid du Colombier.CW reject 1013219b2ee8SDavid du Colombierare called with the control file descriptor and 1014219b2ee8SDavid du Colombier.CW ldir 1015219b2ee8SDavid du Colombierreturned by 1016219b2ee8SDavid du Colombier.CW listen. 1017219b2ee8SDavid du ColombierSome networks such as Datakit accept a reason for a rejection; 1018219b2ee8SDavid du Colombiernetworks such as IP ignore the third argument. 1019219b2ee8SDavid du Colombier.P1 1020219b2ee8SDavid du Colombierint accept(int ctl, char *ldir) 1021219b2ee8SDavid du Colombierint reject(int ctl, char *ldir, char *reason) 1022219b2ee8SDavid du Colombier.P2 1023219b2ee8SDavid du Colombier.PP 1024219b2ee8SDavid du ColombierThe following code implements a typical TCP listener. 1025219b2ee8SDavid du ColombierIt announces itself, listens for connections, and forks a new 1026219b2ee8SDavid du Colombierprocess for each. 1027219b2ee8SDavid du ColombierThe new process echoes data on the connection until the 1028219b2ee8SDavid du Colombierremote end closes it. 1029219b2ee8SDavid du ColombierThe "*" in the symbolic name means the announcement is valid for 1030219b2ee8SDavid du Colombierany addresses bound to the machine the program is run on. 1031219b2ee8SDavid du Colombier.P1 1032219b2ee8SDavid du Colombier.ta 8n 16n 24n 32n 40n 48n 56n 64n 1033219b2ee8SDavid du Colombierint 1034219b2ee8SDavid du Colombierecho_server(void) 1035219b2ee8SDavid du Colombier{ 1036219b2ee8SDavid du Colombier int dfd, lcfd; 1037219b2ee8SDavid du Colombier char adir[40], ldir[40]; 1038219b2ee8SDavid du Colombier int n; 1039219b2ee8SDavid du Colombier char buf[256]; 1040219b2ee8SDavid du Colombier 1041219b2ee8SDavid du Colombier afd = announce("tcp!*!echo", adir); 1042219b2ee8SDavid du Colombier if(afd < 0) 1043219b2ee8SDavid du Colombier return -1; 1044219b2ee8SDavid du Colombier 1045219b2ee8SDavid du Colombier for(;;){ 1046219b2ee8SDavid du Colombier /* listen for a call */ 1047219b2ee8SDavid du Colombier lcfd = listen(adir, ldir); 1048219b2ee8SDavid du Colombier if(lcfd < 0) 1049219b2ee8SDavid du Colombier return -1; 1050219b2ee8SDavid du Colombier 1051219b2ee8SDavid du Colombier /* fork a process to echo */ 1052219b2ee8SDavid du Colombier switch(fork()){ 1053219b2ee8SDavid du Colombier case 0: 1054219b2ee8SDavid du Colombier /* accept the call and open the data file */ 1055219b2ee8SDavid du Colombier dfd = accept(lcfd, ldir); 1056219b2ee8SDavid du Colombier if(dfd < 0) 1057219b2ee8SDavid du Colombier return -1; 1058219b2ee8SDavid du Colombier 1059219b2ee8SDavid du Colombier /* echo until EOF */ 1060219b2ee8SDavid du Colombier while((n = read(dfd, buf, sizeof(buf))) > 0) 1061219b2ee8SDavid du Colombier write(dfd, buf, n); 1062219b2ee8SDavid du Colombier exits(0); 1063219b2ee8SDavid du Colombier case -1: 1064219b2ee8SDavid du Colombier perror("forking"); 1065219b2ee8SDavid du Colombier default: 1066219b2ee8SDavid du Colombier close(lcfd); 1067219b2ee8SDavid du Colombier break; 1068219b2ee8SDavid du Colombier } 1069219b2ee8SDavid du Colombier 1070219b2ee8SDavid du Colombier } 1071219b2ee8SDavid du Colombier} 1072219b2ee8SDavid du Colombier.P2 10733e12c5d1SDavid du Colombier.NH 10743e12c5d1SDavid du ColombierUser Level 10753e12c5d1SDavid du Colombier.PP 10763e12c5d1SDavid du ColombierCommunication between Plan 9 machines is done almost exclusively in 1077219b2ee8SDavid du Colombierterms of 9P messages. Only the two services 1078219b2ee8SDavid du Colombier.CW cpu 10793e12c5d1SDavid du Colombierand 1080219b2ee8SDavid du Colombier.CW exportfs 10813e12c5d1SDavid du Colombierare used. 10823e12c5d1SDavid du ColombierThe 1083219b2ee8SDavid du Colombier.CW cpu 1084bd389b36SDavid du Colombierservice is analogous to 1085bd389b36SDavid du Colombier.CW rlogin . 10863e12c5d1SDavid du ColombierHowever, rather than emulating a terminal session 10873e12c5d1SDavid du Colombieracross the network, 1088219b2ee8SDavid du Colombier.CW cpu 10893e12c5d1SDavid du Colombiercreates a process on the remote machine whose name space is an analogue of the window 10903e12c5d1SDavid du Colombierin which it was invoked. 1091219b2ee8SDavid du Colombier.CW Exportfs 10923e12c5d1SDavid du Colombieris a user level file server which allows a piece of name space to be 10933e12c5d1SDavid du Colombierexported from machine to machine across a network. It is used by the 1094219b2ee8SDavid du Colombier.CW cpu 1095bd389b36SDavid du Colombiercommand to serve the files in the terminal's name space when they are 1096bd389b36SDavid du Colombieraccessed from the 10973e12c5d1SDavid du Colombiercpu server. 10983e12c5d1SDavid du Colombier.PP 1099219b2ee8SDavid du ColombierBy convention, the protocol and device driver file systems are mounted in a 11003e12c5d1SDavid du Colombierdirectory called 1101bd389b36SDavid du Colombier.CW /net . 1102bd389b36SDavid du ColombierAlthough the per-process name space allows users to configure an 1103219b2ee8SDavid du Colombierarbitrary view of the system, in practice their profiles build 1104bd389b36SDavid du Colombiera conventional name space. 11053e12c5d1SDavid du Colombier.NH 2 11063e12c5d1SDavid du ColombierExportfs 11073e12c5d1SDavid du Colombier.PP 1108219b2ee8SDavid du Colombier.CW Exportfs 1109bd389b36SDavid du Colombieris invoked by an incoming network call. 1110bd389b36SDavid du ColombierThe 1111219b2ee8SDavid du Colombier.I listener 1112bd389b36SDavid du Colombier(the Plan 9 equivalent of 1113bd389b36SDavid du Colombier.CW inetd ) 1114bd389b36SDavid du Colombierruns the profile of the user 1115bd389b36SDavid du Colombierrequesting the service to construct a name space before starting 1116219b2ee8SDavid du Colombier.CW exportfs . 1117bd389b36SDavid du ColombierAfter an initial protocol 1118bd389b36SDavid du Colombierestablishes the root of the file tree being 1119bd389b36SDavid du Colombierexported, 1120219b2ee8SDavid du Colombierthe remote process mounts the connection, 1121bd389b36SDavid du Colombierallowing 1122219b2ee8SDavid du Colombier.CW exportfs 1123bd389b36SDavid du Colombierto act as a relay file server. Operations in the imported file tree 11243e12c5d1SDavid du Colombierare executed on the remote server and the results returned. 1125bd389b36SDavid du ColombierAs a result 1126bd389b36SDavid du Colombierthe name space of the remote machine appears to be exported into a 11273e12c5d1SDavid du Colombierlocal file tree. 11283e12c5d1SDavid du Colombier.PP 11293e12c5d1SDavid du ColombierThe 1130219b2ee8SDavid du Colombier.CW import 11313e12c5d1SDavid du Colombiercommand calls 1132219b2ee8SDavid du Colombier.CW exportfs 1133219b2ee8SDavid du Colombieron a remote machine, mounts the result in the local name space, 1134219b2ee8SDavid du Colombierand 1135bd389b36SDavid du Colombierexits. 1136219b2ee8SDavid du ColombierNo local process is required to serve mounts; 1137219b2ee8SDavid du Colombier9P messages are generated by the kernel's mount driver and sent 11383e12c5d1SDavid du Colombierdirectly over the network. 11393e12c5d1SDavid du Colombier.PP 1140219b2ee8SDavid du Colombier.CW Exportfs 11413e12c5d1SDavid du Colombiermust be multithreaded since the system calls 1142219b2ee8SDavid du Colombier.CW open, 1143219b2ee8SDavid du Colombier.CW read 11443e12c5d1SDavid du Colombierand 1145219b2ee8SDavid du Colombier.CW write 11463e12c5d1SDavid du Colombiermay block. 11473e12c5d1SDavid du ColombierPlan 9 does not implement the 1148219b2ee8SDavid du Colombier.CW select 1149bd389b36SDavid du Colombiersystem call but does allow processes to share file descriptors, 1150bd389b36SDavid du Colombiermemory and other resources. 1151219b2ee8SDavid du Colombier.CW Exportfs 1152bd389b36SDavid du Colombierand the configurable name space 1153219b2ee8SDavid du Colombierprovide a means of sharing resources between machines. 1154bd389b36SDavid du ColombierIt is a building block for constructing complex name spaces 1155bd389b36SDavid du Colombierserved from many machines. 11563e12c5d1SDavid du Colombier.PP 1157bd389b36SDavid du ColombierThe simplicity of the interfaces encourages naive users to exploit the potential 1158bd389b36SDavid du Colombierof a richly connected environment. 1159bd389b36SDavid du ColombierUsing these tools it is easy to gateway between networks. 1160219b2ee8SDavid du ColombierFor example a terminal with only a Datakit connection can import from the server 1161219b2ee8SDavid du Colombier.CW helix : 11623e12c5d1SDavid du Colombier.P1 11633e12c5d1SDavid du Colombierimport -a helix /net 11643e12c5d1SDavid du Colombiertelnet ai.mit.edu 11653e12c5d1SDavid du Colombier.P2 11663e12c5d1SDavid du ColombierThe 1167219b2ee8SDavid du Colombier.CW import 1168219b2ee8SDavid du Colombiercommand makes a Datakit connection to the machine 1169219b2ee8SDavid du Colombier.CW helix 1170219b2ee8SDavid du Colombierwhere 1171bd389b36SDavid du Colombierit starts an instance 1172219b2ee8SDavid du Colombier.CW exportfs 1173bd389b36SDavid du Colombierto serve 1174bd389b36SDavid du Colombier.CW /net . 1175bd389b36SDavid du ColombierThe 1176219b2ee8SDavid du Colombier.CW import 1177bd389b36SDavid du Colombiercommand mounts the remote 1178bd389b36SDavid du Colombier.CW /net 1179bd389b36SDavid du Colombierdirectory after (the 1180219b2ee8SDavid du Colombier.CW -a 1181bd389b36SDavid du Colombieroption to 1182219b2ee8SDavid du Colombier.CW import ) 1183bd389b36SDavid du Colombierthe existing contents 1184bd389b36SDavid du Colombierof the local 1185bd389b36SDavid du Colombier.CW /net 1186bd389b36SDavid du Colombierdirectory. 1187bd389b36SDavid du ColombierThe directory contains the union of the local and remote contents of 1188bd389b36SDavid du Colombier.CW /net . 1189bd389b36SDavid du ColombierLocal entries supersede remote ones of the same name so 1190bd389b36SDavid du Colombiernetworks on the local machine are chosen in preference 11913e12c5d1SDavid du Colombierto those supplied remotely. 1192bd389b36SDavid du ColombierHowever, unique entries in the remote directory are now visible in the local 1193bd389b36SDavid du Colombier.CW /net 1194bd389b36SDavid du Colombierdirectory. 1195219b2ee8SDavid du ColombierAll the networks connected to 1196219b2ee8SDavid du Colombier.CW helix , 1197219b2ee8SDavid du Colombiernot just Datakit, 1198219b2ee8SDavid du Colombierare now available in the terminal. The effect on the name space is shown by the following 1199bd389b36SDavid du Colombierexample: 1200bd389b36SDavid du Colombier.P1 1201bd389b36SDavid du Colombierphilw-gnot% ls /net 1202bd389b36SDavid du Colombier/net/cs 1203bd389b36SDavid du Colombier/net/dk 1204bd389b36SDavid du Colombierphilw-gnot% import -a musca /net 1205bd389b36SDavid du Colombierphilw-gnot% ls /net 1206bd389b36SDavid du Colombier/net/cs 1207bd389b36SDavid du Colombier/net/cs 1208bd389b36SDavid du Colombier/net/dk 1209bd389b36SDavid du Colombier/net/dk 1210bd389b36SDavid du Colombier/net/dns 1211bd389b36SDavid du Colombier/net/ether 1212bd389b36SDavid du Colombier/net/il 1213bd389b36SDavid du Colombier/net/tcp 1214bd389b36SDavid du Colombier/net/udp 1215bd389b36SDavid du Colombier.P2 1216bd389b36SDavid du Colombier.NH 2 1217bd389b36SDavid du ColombierFtpfs 1218bd389b36SDavid du Colombier.PP 1219219b2ee8SDavid du ColombierWe decided to make our interface to FTP 1220219b2ee8SDavid du Colombiera file system rather than the traditional command. 1221bd389b36SDavid du ColombierOur command, 1222bd389b36SDavid du Colombier.I ftpfs, 1223219b2ee8SDavid du Colombierdials the FTP port of a remote system, prompts for login and password, sets image mode, 1224bd389b36SDavid du Colombierand mounts the remote file system onto 1225bd389b36SDavid du Colombier.CW /n/ftp . 1226bd389b36SDavid du ColombierFiles and directories are cached to reduce traffic. 1227bd389b36SDavid du ColombierThe cache is updated whenever a file is created. 1228bd389b36SDavid du ColombierFtpfs works with TOPS-20, VMS, and various Unix flavors 1229bd389b36SDavid du Colombieras the remote system. 1230bd389b36SDavid du Colombier.NH 1231bd389b36SDavid du ColombierCyclone Fiber Links 1232bd389b36SDavid du Colombier.PP 1233bd389b36SDavid du ColombierThe file servers and CPU servers are connected by 1234bd389b36SDavid du Colombierhigh-bandwidth 1235bd389b36SDavid du Colombierpoint-to-point links. 1236bd389b36SDavid du ColombierA link consists of two VME cards connected by a pair of optical 1237bd389b36SDavid du Colombierfibers. 1238219b2ee8SDavid du ColombierThe VME cards use 33MHz Intel 960 processors and AMD's TAXI 1239bd389b36SDavid du Colombierfiber transmitter/receivers to drive the lines at 125 Mbit/sec. 1240bd389b36SDavid du ColombierSoftware in the VME card reduces latency by copying messages from system memory 1241bd389b36SDavid du Colombierto fiber without intermediate buffering. 12423e12c5d1SDavid du Colombier.NH 12433e12c5d1SDavid du ColombierPerformance 12443e12c5d1SDavid du Colombier.PP 1245219b2ee8SDavid du ColombierWe measured both latency and throughput 12463e12c5d1SDavid du Colombierof reading and writing bytes between two processes 12473e12c5d1SDavid du Colombierfor a number of different paths. 1248219b2ee8SDavid du ColombierMeasurements were made on two- and four-CPU SGI Power Series processors. 1249219b2ee8SDavid du ColombierThe CPUs are 25 MHz MIPS 3000s. 12503e12c5d1SDavid du ColombierThe latency is measured as the round trip time 12513e12c5d1SDavid du Colombierfor a byte sent from one process to another and 12523e12c5d1SDavid du Colombierback again. 12533e12c5d1SDavid du ColombierThroughput is measured using 16k writes from 12543e12c5d1SDavid du Colombierone process to another. 12553e12c5d1SDavid du Colombier.DS C 12563e12c5d1SDavid du Colombier.TS 12573e12c5d1SDavid du Colombierbox, tab(:); 12583e12c5d1SDavid du Colombierc s s 12593e12c5d1SDavid du Colombierc | c | c 12603e12c5d1SDavid du Colombierl | n | n. 12613e12c5d1SDavid du ColombierTable 1 - Performance 12623e12c5d1SDavid du Colombier_ 12633e12c5d1SDavid du Colombiertest:throughput:latency 12643e12c5d1SDavid du Colombier:MBytes/sec:millisec 12653e12c5d1SDavid du Colombier_ 12663e12c5d1SDavid du Colombierpipes:8.15:.255 12673e12c5d1SDavid du Colombier_ 12683e12c5d1SDavid du ColombierIL/ether:1.02:1.42 12693e12c5d1SDavid du Colombier_ 1270219b2ee8SDavid du ColombierURP/Datakit:0.22:1.75 12713e12c5d1SDavid du Colombier_ 12723e12c5d1SDavid du ColombierCyclone:3.2:0.375 12733e12c5d1SDavid du Colombier.TE 12743e12c5d1SDavid du Colombier.DE 12753e12c5d1SDavid du Colombier.NH 12763e12c5d1SDavid du ColombierConclusion 12773e12c5d1SDavid du Colombier.PP 12783e12c5d1SDavid du ColombierThe representation of all resources as file systems 12793e12c5d1SDavid du Colombiercoupled with an ASCII interface has proved more powerful 12803e12c5d1SDavid du Colombierthan we had originally imagined. 12813e12c5d1SDavid du ColombierResources can be used by any computer in our networks 12823e12c5d1SDavid du Colombierindependent of byte ordering or CPU type. 12833e12c5d1SDavid du ColombierThe connection server provides an elegant means 12843e12c5d1SDavid du Colombierof decoupling tools from the networks they use. 12853e12c5d1SDavid du ColombierUsers successfully use Plan 9 without knowing the 12863e12c5d1SDavid du Colombiertopology of the system or the networks they use. 1287219b2ee8SDavid du ColombierMore information about 9P can be found in the Section 5 of the Plan 9 Programmer's 1288219b2ee8SDavid du ColombierManual, Volume I. 12893e12c5d1SDavid du Colombier.NH 12903e12c5d1SDavid du ColombierReferences 12913e12c5d1SDavid du Colombier.LP 12923e12c5d1SDavid du Colombier[Pike90] R. Pike, D. Presotto, K. Thompson, H. Trickey, 12933e12c5d1SDavid du Colombier``Plan 9 from Bell Labs'', 12943e12c5d1SDavid du Colombier.I 12953e12c5d1SDavid du ColombierUKUUG Proc. of the Summer 1990 Conf. , 12963e12c5d1SDavid du ColombierLondon, England, 1297219b2ee8SDavid du Colombier1990. 12983e12c5d1SDavid du Colombier.LP 12993e12c5d1SDavid du Colombier[Needham] R. Needham, ``Names'', in 13003e12c5d1SDavid du Colombier.I 13013e12c5d1SDavid du ColombierDistributed systems, 13023e12c5d1SDavid du Colombier.R 13033e12c5d1SDavid du ColombierS. Mullender, ed., 1304219b2ee8SDavid du ColombierAddison Wesley, 1989. 13053e12c5d1SDavid du Colombier.LP 13063e12c5d1SDavid du Colombier[Presotto] D. Presotto, ``Multiprocessor Streams for Plan 9'', 13073e12c5d1SDavid du Colombier.I 13083e12c5d1SDavid du ColombierUKUUG Proc. of the Summer 1990 Conf. , 13093e12c5d1SDavid du Colombier.R 1310219b2ee8SDavid du ColombierLondon, England, 1990. 13113e12c5d1SDavid du Colombier.LP 13123e12c5d1SDavid du Colombier[Met80] R. Metcalfe, D. Boggs, C. Crane, E. Taf and J. Hupp, ``The 13133e12c5d1SDavid du ColombierEthernet Local Network: Three reports'', 13143e12c5d1SDavid du Colombier.I 13153e12c5d1SDavid du ColombierCSL-80-2, 13163e12c5d1SDavid du Colombier.R 1317bd389b36SDavid du ColombierXEROX Palo Alto Research Center, February 1980. 13183e12c5d1SDavid du Colombier.LP 13193e12c5d1SDavid du Colombier[Fra80] A. G. Fraser, ``Datakit - A Modular Network for Synchronous 13203e12c5d1SDavid du Colombierand Asynchronous Traffic'', 13213e12c5d1SDavid du Colombier.I 1322219b2ee8SDavid du ColombierProc. Int'l Conf. on Communication, 1323219b2ee8SDavid du Colombier.R 1324219b2ee8SDavid du ColombierBoston, June 1980. 13253e12c5d1SDavid du Colombier.LP 13263e12c5d1SDavid du Colombier[Pet89a] L. Peterson, ``RPC in the X-Kernel: Evaluating new Design Techniques'', 13273e12c5d1SDavid du Colombier.I 1328219b2ee8SDavid du ColombierProc. Twelfth Symp. on Op. Sys. Princ., 13293e12c5d1SDavid du Colombier.R 1330219b2ee8SDavid du ColombierLitchfield Park, AZ, December 1990. 13313e12c5d1SDavid du Colombier.LP 13323e12c5d1SDavid du Colombier[Rit84a] D. M. Ritchie, ``A Stream Input-Output System'', 13333e12c5d1SDavid du Colombier.I 13343e12c5d1SDavid du ColombierAT&T Bell Laboratories Technical Journal, 68(8), 13353e12c5d1SDavid du Colombier.R 13363e12c5d1SDavid du ColombierOctober 1984. 1337