13e12c5d1SDavid du Colombier.TL 23e12c5d1SDavid du ColombierThe Organization of Networks in Plan 9 33e12c5d1SDavid du Colombier.AU 43e12c5d1SDavid du ColombierDave Presotto 53e12c5d1SDavid du ColombierPhil Winterbottom 6*219b2ee8SDavid du Colombier.sp 7*219b2ee8SDavid du Colombierpresotto,philw@plan9.att.com 83e12c5d1SDavid du Colombier.AB 9*219b2ee8SDavid du Colombier.FS 10*219b2ee8SDavid du ColombierOriginally appeared in 11*219b2ee8SDavid du Colombier.I 12*219b2ee8SDavid du ColombierProc. of the Winter 1993 USENIX Conf., 13*219b2ee8SDavid du Colombier.R 14*219b2ee8SDavid du Colombierpp. 271-280, 15*219b2ee8SDavid du ColombierSan Diego, CA 16*219b2ee8SDavid du Colombier.FE 173e12c5d1SDavid du ColombierIn a distributed system networks are of paramount importance. This 18*219b2ee8SDavid du Colombierpaper describes the implementation, design philosophy, and organization 193e12c5d1SDavid du Colombierof network support in Plan 9. Topics include network requirements 20*219b2ee8SDavid du Colombierfor distributed systems, our kernel implementation, network naming, user interfaces, 213e12c5d1SDavid du Colombierand performance. We also observe that much of this organization is relevant to 223e12c5d1SDavid du Colombiercurrent systems. 233e12c5d1SDavid du Colombier.AE 243e12c5d1SDavid du Colombier.NH 253e12c5d1SDavid du ColombierIntroduction 263e12c5d1SDavid du Colombier.PP 273e12c5d1SDavid du ColombierPlan 9 [Pike90] is a general-purpose, multi-user, portable distributed system 28bd389b36SDavid du Colombierimplemented on a variety of computers and networks. 29bd389b36SDavid du ColombierWhat distinguishes Plan 9 is its organization. 30bd389b36SDavid du ColombierThe goals of this organization were to 31bd389b36SDavid du Colombierreduce administration 323e12c5d1SDavid du Colombierand to promote resource sharing. One of the keys to its success as a distributed 333e12c5d1SDavid du Colombiersystem is the organization and management of its networks. 343e12c5d1SDavid du Colombier.PP 35bd389b36SDavid du ColombierA Plan 9 system comprises file servers, CPU servers and terminals. 36bd389b36SDavid du ColombierThe file servers and CPU servers are typically centrally 37bd389b36SDavid du Colombierlocated multiprocessor machines with large memories and 38bd389b36SDavid du Colombierhigh speed interconnects. 39bd389b36SDavid du ColombierA variety of workstation-class machines 40bd389b36SDavid du Colombierserve as terminals 41bd389b36SDavid du Colombierconnected to the central servers using several networks and protocols. 423e12c5d1SDavid du ColombierThe architecture of the system demands a hierarchy of network 433e12c5d1SDavid du Colombierspeeds matching the needs of the components. 44bd389b36SDavid du ColombierConnections between file servers and CPU servers are high-bandwidth point-to-point 45bd389b36SDavid du Colombierfiber links. 46bd389b36SDavid du ColombierConnections from the servers fan out to local terminals 47bd389b36SDavid du Colombierusing medium speed networks 48bd389b36SDavid du Colombiersuch as Ethernet [Met80] and Datakit [Fra80]. 493e12c5d1SDavid du ColombierLow speed connections via the Internet and 50bd389b36SDavid du Colombierthe AT&T backbone serve users in Oregon and Illinois. 51bd389b36SDavid du ColombierBasic Rate ISDN data service and 9600 baud serial lines provide slow 523e12c5d1SDavid du Colombierlinks to users at home. 533e12c5d1SDavid du Colombier.PP 54bd389b36SDavid du ColombierSince CPU servers and terminals use the same kernel, 55bd389b36SDavid du Colombierusers may choose to run programs locally on 563e12c5d1SDavid du Colombiertheir terminals or remotely on CPU servers. 57bd389b36SDavid du ColombierThe organization of Plan 9 hides the details of system connectivity 58bd389b36SDavid du Colombierallowing both users and administrators to configure their environment 593e12c5d1SDavid du Colombierto be as distributed or centralized as they wish. 60bd389b36SDavid du ColombierSimple commands support the 61bd389b36SDavid du Colombierconstruction of a locally represented name space 62bd389b36SDavid du Colombierspanning many machines and networks. 63*219b2ee8SDavid du ColombierAt work, users tend to use their terminals like workstations, 64bd389b36SDavid du Colombierrunning interactive programs locally and 653e12c5d1SDavid du Colombierreserving the CPU servers for data or compute intensive jobs 663e12c5d1SDavid du Colombiersuch as compiling and computing chess endgames. 67bd389b36SDavid du ColombierAt home or when connected over 68bd389b36SDavid du Colombiera slow network, users tend to do most work on the CPU server to minimize 69*219b2ee8SDavid du Colombiertraffic on the slow links. 703e12c5d1SDavid du ColombierThe goal of the network organization is to provide the same 713e12c5d1SDavid du Colombierenvironment to the user wherever resources are used. 723e12c5d1SDavid du Colombier.NH 733e12c5d1SDavid du ColombierKernel Network Support 743e12c5d1SDavid du Colombier.PP 75bd389b36SDavid du ColombierNetworks play a central role in any distributed system. This is particularly 763e12c5d1SDavid du Colombiertrue in Plan 9 where most resources are provided by servers external to the kernel. 77bd389b36SDavid du ColombierThe importance of the networking code within the kernel 78bd389b36SDavid du Colombieris reflected by its size; 79bd389b36SDavid du Colombierof 25,000 lines of kernel code, 12,500 are network and protocol related. 80bd389b36SDavid du ColombierNetworks are continually being added and the fraction of code 81bd389b36SDavid du Colombierdevoted to communications 82bd389b36SDavid du Colombieris growing. 83bd389b36SDavid du ColombierMoreover, the network code is complex. 843e12c5d1SDavid du ColombierProtocol implementations consist almost entirely of 85*219b2ee8SDavid du Colombiersynchronization and dynamic memory management, areas demanding 86bd389b36SDavid du Colombiersubtle error recovery 87bd389b36SDavid du Colombierstrategies. 88bd389b36SDavid du ColombierThe kernel currently supports Datakit, point-to-point fiber links, 893e12c5d1SDavid du Colombieran Internet (IP) protocol suite and ISDN data service. 90bd389b36SDavid du ColombierThe variety of networks and machines 91bd389b36SDavid du Colombierhas raised issues not addressed by other systems running on commercial 923e12c5d1SDavid du Colombierhardware supporting only Ethernet or FDDI. 933e12c5d1SDavid du Colombier.NH 2 943e12c5d1SDavid du ColombierThe File System protocol 953e12c5d1SDavid du Colombier.PP 963e12c5d1SDavid du ColombierA central idea in Plan 9 is the representation of a resource as a hierarchical 973e12c5d1SDavid du Colombierfile system. 983e12c5d1SDavid du ColombierEach process assembles a view of the system by building a 99*219b2ee8SDavid du Colombier.I "name space 100bd389b36SDavid du Colombier[Needham] connecting its resources. 101bd389b36SDavid du ColombierFile systems need not represent disc files; in fact, most Plan 9 file systems have no 1023e12c5d1SDavid du Colombierpermanent storage. 103bd389b36SDavid du ColombierA typical file system dynamically represents 104bd389b36SDavid du Colombiersome resource like a set of network connections or the process table. 105*219b2ee8SDavid du ColombierCommunication between the kernel, device drivers, and local or remote file servers uses a 1063e12c5d1SDavid du Colombierprotocol called 9P. The protocol consists of 17 messages 107bd389b36SDavid du Colombierdescribing operations on files and directories. 108bd389b36SDavid du ColombierKernel resident device and protocol drivers use a procedural version 109bd389b36SDavid du Colombierof the protocol while external file servers use an RPC form. 1103e12c5d1SDavid du ColombierNearly all traffic between Plan 9 systems consists 1113e12c5d1SDavid du Colombierof 9P messages. 112bd389b36SDavid du Colombier9P relies on several properties of the underlying transport protocol. 113bd389b36SDavid du ColombierIt assumes messages arrive reliably and in sequence and 114bd389b36SDavid du Colombierthat delimiters between messages 115bd389b36SDavid du Colombierare preserved. 116bd389b36SDavid du ColombierWhen a protocol does not meet these 117*219b2ee8SDavid du Colombierrequirements (for example, TCP does not preserve delimiters) 118bd389b36SDavid du Colombierwe provide mechanisms to marshal messages before handing them 119bd389b36SDavid du Colombierto the system. 1203e12c5d1SDavid du Colombier.PP 1213e12c5d1SDavid du ColombierA kernel data structure, the 1223e12c5d1SDavid du Colombier.I channel , 123bd389b36SDavid du Colombieris a handle to a file server. 124bd389b36SDavid du ColombierOperations on a channel generate the following 9P messages. 1253e12c5d1SDavid du ColombierThe 126*219b2ee8SDavid du Colombier.CW session 1273e12c5d1SDavid du Colombierand 1283e12c5d1SDavid du Colombier.CW attach 129bd389b36SDavid du Colombiermessages authenticate a connection, established by means external to 9P, 1303e12c5d1SDavid du Colombierand validate its user. 1313e12c5d1SDavid du ColombierThe result is an authenticated 132bd389b36SDavid du Colombierchannel 133bd389b36SDavid du Colombierreferencing the root of the 1343e12c5d1SDavid du Colombierserver. 1353e12c5d1SDavid du ColombierThe 1363e12c5d1SDavid du Colombier.CW clone 137bd389b36SDavid du Colombiermessage makes a new channel identical to an existing channel, much like 138bd389b36SDavid du Colombierthe 139bd389b36SDavid du Colombier.CW dup 140bd389b36SDavid du Colombiersystem call. 1413e12c5d1SDavid du ColombierA 142bd389b36SDavid du Colombierchannel 1433e12c5d1SDavid du Colombiermay be moved to a file on the server using a 1443e12c5d1SDavid du Colombier.CW walk 1453e12c5d1SDavid du Colombiermessage to descend each level in the hierarchy. 1463e12c5d1SDavid du ColombierThe 1473e12c5d1SDavid du Colombier.CW stat 1483e12c5d1SDavid du Colombierand 1493e12c5d1SDavid du Colombier.CW wstat 150bd389b36SDavid du Colombiermessages read and write the attributes of the file referenced by a channel. 1513e12c5d1SDavid du ColombierThe 1523e12c5d1SDavid du Colombier.CW open 1533e12c5d1SDavid du Colombiermessage prepares a channel for subsequent 1543e12c5d1SDavid du Colombier.CW read 1553e12c5d1SDavid du Colombierand 1563e12c5d1SDavid du Colombier.CW write 157bd389b36SDavid du Colombiermessages to access the contents of the file. 158bd389b36SDavid du Colombier.CW Create 1593e12c5d1SDavid du Colombierand 1603e12c5d1SDavid du Colombier.CW remove 161bd389b36SDavid du Colombierperform the actions implied by their names on the file 162bd389b36SDavid du Colombierreferenced by the channel. 1633e12c5d1SDavid du ColombierThe 1643e12c5d1SDavid du Colombier.CW clunk 1653e12c5d1SDavid du Colombiermessage discards a channel without affecting the file. 1663e12c5d1SDavid du Colombier.PP 1673e12c5d1SDavid du ColombierA kernel resident file server called the 168bd389b36SDavid du Colombier.I "mount driver" 169*219b2ee8SDavid du Colombierconverts the procedural version of 9P into RPCs. 170bd389b36SDavid du ColombierThe 1713e12c5d1SDavid du Colombier.I mount 172bd389b36SDavid du Colombiersystem call provides a file descriptor, which can be 173bd389b36SDavid du Colombiera pipe to a user process or a network connection to a remote machine, to 174bd389b36SDavid du Colombierbe associated with the mount point. 1753e12c5d1SDavid du ColombierAfter a mount, operations 1763e12c5d1SDavid du Colombieron the file tree below the mount point are sent as messages to the file server. 1773e12c5d1SDavid du ColombierThe 178bd389b36SDavid du Colombiermount 179bd389b36SDavid du Colombierdriver manages buffers, packs and unpacks parameters from 180*219b2ee8SDavid du Colombiermessages, and demultiplexes among processes using the file server. 1813e12c5d1SDavid du Colombier.NH 2 1823e12c5d1SDavid du ColombierKernel Organization 1833e12c5d1SDavid du Colombier.PP 184bd389b36SDavid du ColombierThe network code in the kernel is divided into three layers: hardware interface, 1853e12c5d1SDavid du Colombierprotocol processing, and program interface. 186bd389b36SDavid du ColombierA device driver typically uses streams to connect the two interface layers. 187bd389b36SDavid du ColombierAdditional stream modules may be pushed on 188bd389b36SDavid du Colombiera device to process protocols. 189bd389b36SDavid du ColombierEach device driver is a kernel-resident file system. 1903e12c5d1SDavid du ColombierSimple device drivers serve a single level 191bd389b36SDavid du Colombierdirectory containing just a few files; 192bd389b36SDavid du Colombierfor example, we represent each UART 1933e12c5d1SDavid du Colombierby a data and a control file. 1943e12c5d1SDavid du Colombier.P1 195*219b2ee8SDavid du Colombiercpu% cd /dev 196*219b2ee8SDavid du Colombiercpu% ls -l eia* 1973e12c5d1SDavid du Colombier--rw-rw-rw- t 0 bootes bootes 0 Jul 16 17:28 eia1 1983e12c5d1SDavid du Colombier--rw-rw-rw- t 0 bootes bootes 0 Jul 16 17:28 eia1ctl 1993e12c5d1SDavid du Colombier--rw-rw-rw- t 0 bootes bootes 0 Jul 16 17:28 eia2 2003e12c5d1SDavid du Colombier--rw-rw-rw- t 0 bootes bootes 0 Jul 16 17:28 eia2ctl 201*219b2ee8SDavid du Colombiercpu% 2023e12c5d1SDavid du Colombier.P2 203bd389b36SDavid du ColombierThe control file is used to control the device; 204bd389b36SDavid du Colombierwriting the string 205*219b2ee8SDavid du Colombier.CW b1200 2063e12c5d1SDavid du Colombierto 2073e12c5d1SDavid du Colombier.CW /dev/eia1ctl 208bd389b36SDavid du Colombiersets the line to 1200 baud. 2093e12c5d1SDavid du Colombier.PP 210bd389b36SDavid du ColombierMultiplexed devices present 211bd389b36SDavid du Colombiera more complex interface structure. 212bd389b36SDavid du ColombierFor example, the LANCE Ethernet driver 213bd389b36SDavid du Colombierserves a two level file tree (Figure 1) 214bd389b36SDavid du Colombierproviding 2153e12c5d1SDavid du Colombier.IP \(bu 216bd389b36SDavid du Colombierdevice control and configuration 2173e12c5d1SDavid du Colombier.IP \(bu 218*219b2ee8SDavid du Colombieruser-level protocols like ARP 2193e12c5d1SDavid du Colombier.IP \(bu 220bd389b36SDavid du Colombierdiagnostic interfaces for snooping software. 2213e12c5d1SDavid du Colombier.LP 2223e12c5d1SDavid du ColombierThe top directory contains a 2233e12c5d1SDavid du Colombier.CW clone 224bd389b36SDavid du Colombierfile and a directory for each connection, numbered 2253e12c5d1SDavid du Colombier.CW 1 2263e12c5d1SDavid du Colombierto 2273e12c5d1SDavid du Colombier.CW n . 228bd389b36SDavid du ColombierEach connection directory corresponds to an Ethernet packet type. 229bd389b36SDavid du ColombierOpening the 230bd389b36SDavid du Colombier.CW clone 231bd389b36SDavid du Colombierfile finds an unused connection directory 2323e12c5d1SDavid du Colombierand opens its 2333e12c5d1SDavid du Colombier.CW ctl 2343e12c5d1SDavid du Colombierfile. 235bd389b36SDavid du ColombierReading the control file returns the ASCII connection number; the user 236bd389b36SDavid du Colombierprocess can use this value to construct the name of the proper 237bd389b36SDavid du Colombierconnection directory. 238bd389b36SDavid du ColombierIn each connection directory files named 2393e12c5d1SDavid du Colombier.CW ctl , 2403e12c5d1SDavid du Colombier.CW data , 241*219b2ee8SDavid du Colombier.CW stats , 2423e12c5d1SDavid du Colombierand 243bd389b36SDavid du Colombier.CW type 244bd389b36SDavid du Colombierprovide access to the connection. 2453e12c5d1SDavid du ColombierWriting the string 246*219b2ee8SDavid du Colombier.CW "connect 2048" 2473e12c5d1SDavid du Colombierto the 2483e12c5d1SDavid du Colombier.CW ctl 249bd389b36SDavid du Colombierfile sets the packet type to 2048 250bd389b36SDavid du Colombierand 251bd389b36SDavid du Colombierconfigures the connection to receive 2523e12c5d1SDavid du Colombierall IP packets sent to the machine. 2533e12c5d1SDavid du ColombierSubsequent reads of the file 2543e12c5d1SDavid du Colombier.CW type 255bd389b36SDavid du Colombieryield the string 256*219b2ee8SDavid du Colombier.CW 2048 . 2573e12c5d1SDavid du ColombierThe 2583e12c5d1SDavid du Colombier.CW data 259bd389b36SDavid du Colombierfile accesses the media; 260bd389b36SDavid du Colombierreading it 261bd389b36SDavid du Colombierreturns the 262bd389b36SDavid du Colombiernext packet of the selected type. 263bd389b36SDavid du ColombierWriting the file 264bd389b36SDavid du Colombierqueues a packet for transmission after 265bd389b36SDavid du Colombierappending a packet header containing the source address and packet type. 2663e12c5d1SDavid du ColombierThe 2673e12c5d1SDavid du Colombier.CW stats 268bd389b36SDavid du Colombierfile returns ASCII text containing the interface address, 269*219b2ee8SDavid du Colombierpacket input/output counts, error statistics, and general information 2703e12c5d1SDavid du Colombierabout the state of the interface. 2713e12c5d1SDavid du Colombier.so tree.pout 2723e12c5d1SDavid du Colombier.PP 273bd389b36SDavid du ColombierIf several connections on an interface 274*219b2ee8SDavid du Colombierare configured for a particular packet type, each receives a 2753e12c5d1SDavid du Colombiercopy of the incoming packets. 276*219b2ee8SDavid du ColombierThe special packet type 277*219b2ee8SDavid du Colombier.CW -1 278bd389b36SDavid du Colombierselects all packets. 2793e12c5d1SDavid du ColombierWriting the strings 280*219b2ee8SDavid du Colombier.CW promiscuous 2813e12c5d1SDavid du Colombierand 282*219b2ee8SDavid du Colombier.CW connect 283*219b2ee8SDavid du Colombier.CW -1 284bd389b36SDavid du Colombierto the 2853e12c5d1SDavid du Colombier.CW ctl 286bd389b36SDavid du Colombierfile 287bd389b36SDavid du Colombierconfigures a conversation to receive all packets on the Ethernet. 2883e12c5d1SDavid du Colombier.PP 289bd389b36SDavid du ColombierAlthough the driver interface may seem elaborate, 290bd389b36SDavid du Colombierthe representation of a device as a set of files using ASCII strings for 291bd389b36SDavid du Colombiercommunication has several advantages. 292bd389b36SDavid du ColombierAny mechanism supporting remote access to files immediately 293bd389b36SDavid du Colombierallows a remote machine to use our interfaces as gateways. 294bd389b36SDavid du ColombierUsing ASCII strings to control the interface avoids byte order problems and 295bd389b36SDavid du Colombierensures a uniform representation for 296*219b2ee8SDavid du Colombierdevices on the same machine and even allows devices to be accessed remotely. 297bd389b36SDavid du ColombierRepresenting dissimilar devices by the same set of files allows common tools 298bd389b36SDavid du Colombierto serve 299bd389b36SDavid du Colombierseveral networks or interfaces. 3003e12c5d1SDavid du ColombierPrograms like 3013e12c5d1SDavid du Colombier.CW stty 302bd389b36SDavid du Colombierare replaced by 3033e12c5d1SDavid du Colombier.CW echo 3043e12c5d1SDavid du Colombierand shell redirection. 3053e12c5d1SDavid du Colombier.NH 2 3063e12c5d1SDavid du ColombierProtocol devices 3073e12c5d1SDavid du Colombier.PP 3083e12c5d1SDavid du ColombierNetwork connections are represented as pseudo-devices called protocol devices. 3093e12c5d1SDavid du ColombierProtocol device drivers exist for the Datakit URP protocol and for each of the 3103e12c5d1SDavid du ColombierInternet IP protocols TCP, UDP, and IL. 3113e12c5d1SDavid du ColombierIL, described below, is a new communication protocol used by Plan 9 for 312bd389b36SDavid du Colombiertransmitting file system RPC's. 313bd389b36SDavid du ColombierAll protocol devices look identical so user programs contain no 314bd389b36SDavid du Colombiernetwork-specific code. 3153e12c5d1SDavid du Colombier.PP 316bd389b36SDavid du ColombierEach protocol device driver serves a directory structure 317bd389b36SDavid du Colombiersimilar to that of the Ethernet driver. 3183e12c5d1SDavid du ColombierThe top directory contains a 3193e12c5d1SDavid du Colombier.CW clone 320bd389b36SDavid du Colombierfile and a directory for each connection numbered 321*219b2ee8SDavid du Colombier.CW 0 3223e12c5d1SDavid du Colombierto 3233e12c5d1SDavid du Colombier.CW n . 324bd389b36SDavid du ColombierEach connection directory contains files to control one 325bd389b36SDavid du Colombierconnection and to send and receive information. 326*219b2ee8SDavid du ColombierA TCP connection directory looks like this: 3273e12c5d1SDavid du Colombier.P1 328*219b2ee8SDavid du Colombiercpu% cd /net/tcp/2 329*219b2ee8SDavid du Colombiercpu% ls -l 3303e12c5d1SDavid du Colombier--rw-rw---- I 0 ehg bootes 0 Jul 13 21:14 ctl 3313e12c5d1SDavid du Colombier--rw-rw---- I 0 ehg bootes 0 Jul 13 21:14 data 3323e12c5d1SDavid du Colombier--rw-rw---- I 0 ehg bootes 0 Jul 13 21:14 listen 3333e12c5d1SDavid du Colombier--r--r--r-- I 0 bootes bootes 0 Jul 13 21:14 local 3343e12c5d1SDavid du Colombier--r--r--r-- I 0 bootes bootes 0 Jul 13 21:14 remote 3353e12c5d1SDavid du Colombier--r--r--r-- I 0 bootes bootes 0 Jul 13 21:14 status 336*219b2ee8SDavid du Colombiercpu% cat local remote status 3373e12c5d1SDavid du Colombier135.104.9.31 5012 3383e12c5d1SDavid du Colombier135.104.53.11 564 3393e12c5d1SDavid du Colombiertcp/2 1 Established connect 340*219b2ee8SDavid du Colombiercpu% 3413e12c5d1SDavid du Colombier.P2 3423e12c5d1SDavid du ColombierThe files 3433e12c5d1SDavid du Colombier.CW local , 344*219b2ee8SDavid du Colombier.CW remote , 3453e12c5d1SDavid du Colombierand 3463e12c5d1SDavid du Colombier.CW status 347bd389b36SDavid du Colombiersupply information about the state of the connection. 3483e12c5d1SDavid du ColombierThe 3493e12c5d1SDavid du Colombier.CW data 3503e12c5d1SDavid du Colombierand 3513e12c5d1SDavid du Colombier.CW ctl 352bd389b36SDavid du Colombierfiles 353bd389b36SDavid du Colombierprovide access to the process end of the stream implementing the protocol. 3543e12c5d1SDavid du ColombierThe 3553e12c5d1SDavid du Colombier.CW listen 356bd389b36SDavid du Colombierfile is used to accept incoming calls from the network. 3573e12c5d1SDavid du Colombier.PP 358bd389b36SDavid du ColombierThe following steps establish a connection. 3593e12c5d1SDavid du Colombier.IP 1) 3603e12c5d1SDavid du ColombierThe clone device of the 361bd389b36SDavid du Colombierappropriate protocol directory is opened to reserve an unused connection. 3623e12c5d1SDavid du Colombier.IP 2) 363bd389b36SDavid du ColombierThe file descriptor returned by the open points to the 3643e12c5d1SDavid du Colombier.CW ctl 3653e12c5d1SDavid du Colombierfile of the new connection. 366bd389b36SDavid du ColombierReading that file descriptor returns an ASCII string containing 3673e12c5d1SDavid du Colombierthe connection number. 3683e12c5d1SDavid du Colombier.IP 3) 3693e12c5d1SDavid du ColombierA protocol/network specific ASCII address string is written to the 3703e12c5d1SDavid du Colombier.CW ctl 3713e12c5d1SDavid du Colombierfile. 3723e12c5d1SDavid du Colombier.IP 4) 3733e12c5d1SDavid du ColombierThe path of the 3743e12c5d1SDavid du Colombier.CW data 375bd389b36SDavid du Colombierfile is constructed using the connection number. 376bd389b36SDavid du ColombierWhen the 3773e12c5d1SDavid du Colombier.CW data 378bd389b36SDavid du Colombierfile is opened the connection is established. 379bd389b36SDavid du Colombier.LP 380bd389b36SDavid du ColombierA process can read and write this file descriptor 381bd389b36SDavid du Colombierto send and receive messages from the network. 3823e12c5d1SDavid du ColombierIf the process opens the 3833e12c5d1SDavid du Colombier.CW listen 384bd389b36SDavid du Colombierfile it blocks until an incoming call is received. 385bd389b36SDavid du ColombierAn address string written to the 386bd389b36SDavid du Colombier.CW ctl 387bd389b36SDavid du Colombierfile before the listen selects the 388bd389b36SDavid du Colombierports or services the process is prepared to accept. 389bd389b36SDavid du ColombierWhen an incoming call is received, the open completes 390bd389b36SDavid du Colombierand returns a file descriptor 391bd389b36SDavid du Colombierpointing to the 392bd389b36SDavid du Colombier.CW ctl 393bd389b36SDavid du Colombierfile of the new connection. 394bd389b36SDavid du ColombierReading the 395bd389b36SDavid du Colombier.CW ctl 396bd389b36SDavid du Colombierfile yields a connection number used to construct the path of the 3973e12c5d1SDavid du Colombier.CW data 398bd389b36SDavid du Colombierfile. 3993e12c5d1SDavid du ColombierA connection remains established while any of the files in the connection directory 4003e12c5d1SDavid du Colombierare referenced or until a close is received from the network. 401*219b2ee8SDavid du Colombier.NH 2 402*219b2ee8SDavid du ColombierStreams 403*219b2ee8SDavid du Colombier.PP 404*219b2ee8SDavid du ColombierA 405*219b2ee8SDavid du Colombier.I stream 406*219b2ee8SDavid du Colombier[Rit84a][Presotto] is a bidirectional channel connecting a 407*219b2ee8SDavid du Colombierphysical or pseudo-device to user processes. 408*219b2ee8SDavid du ColombierThe user processes insert and remove data at one end of the stream. 409*219b2ee8SDavid du ColombierKernel processes acting on behalf of a device insert data at 410*219b2ee8SDavid du Colombierthe other end. 411*219b2ee8SDavid du ColombierAsynchronous communications channels such as pipes, 412*219b2ee8SDavid du ColombierTCP conversations, Datakit conversations, and RS232 lines are implemented using 413*219b2ee8SDavid du Colombierstreams. 414*219b2ee8SDavid du Colombier.PP 415*219b2ee8SDavid du ColombierA stream comprises a linear list of 416*219b2ee8SDavid du Colombier.I "processing modules" . 417*219b2ee8SDavid du ColombierEach module has both an upstream (toward the process) and 418*219b2ee8SDavid du Colombierdownstream (toward the device) 419*219b2ee8SDavid du Colombier.I "put routine" . 420*219b2ee8SDavid du ColombierCalling the put routine of the module on either end of the stream 421*219b2ee8SDavid du Colombierinserts data into the stream. 422*219b2ee8SDavid du ColombierEach module calls the succeeding one to send data up or down the stream. 423*219b2ee8SDavid du Colombier.PP 424*219b2ee8SDavid du ColombierAn instance of a processing module is represented by a pair of 425*219b2ee8SDavid du Colombier.I queues , 426*219b2ee8SDavid du Colombierone for each direction. 427*219b2ee8SDavid du ColombierThe queues point to the put procedures and can be used 428*219b2ee8SDavid du Colombierto queue information traveling along the stream. 429*219b2ee8SDavid du ColombierSome put routines queue data locally and send it along the stream at some 430*219b2ee8SDavid du Colombierlater time, either due to a subsequent call or an asynchronous 431*219b2ee8SDavid du Colombierevent such as a retransmission timer or a device interrupt. 432*219b2ee8SDavid du ColombierProcessing modules create helper kernel processes to 433*219b2ee8SDavid du Colombierprovide a context for handling asynchronous events. 434*219b2ee8SDavid du ColombierFor example, a helper kernel process awakens periodically 435*219b2ee8SDavid du Colombierto perform any necessary TCP retransmissions. 436*219b2ee8SDavid du ColombierThe use of kernel processes instead of serialized run-to-completion service routines 437*219b2ee8SDavid du Colombierdiffers from the implementation of Unix streams. 438*219b2ee8SDavid du ColombierUnix service routines cannot 439*219b2ee8SDavid du Colombieruse any blocking kernel resource and they lack a local long-lived state. 440*219b2ee8SDavid du ColombierHelper kernel processes solve these problems and simplify the stream code. 441*219b2ee8SDavid du Colombier.PP 442*219b2ee8SDavid du ColombierThere is no implicit synchronization in our streams. 443*219b2ee8SDavid du ColombierEach processing module must ensure that concurrent processes using the stream 444*219b2ee8SDavid du Colombierare synchronized. 445*219b2ee8SDavid du ColombierThis maximizes concurrency but introduces the 446*219b2ee8SDavid du Colombierpossibility of deadlock. 447*219b2ee8SDavid du ColombierHowever, deadlocks are easily avoided by careful programming; to 448*219b2ee8SDavid du Colombierdate they have not caused us problems. 449*219b2ee8SDavid du Colombier.PP 450*219b2ee8SDavid du ColombierInformation is represented by linked lists of kernel structures called 451*219b2ee8SDavid du Colombier.I blocks . 452*219b2ee8SDavid du ColombierEach block contains a type, some state flags, and pointers to 453*219b2ee8SDavid du Colombieran optional buffer. 454*219b2ee8SDavid du ColombierBlock buffers can hold either data or control information, i.e., directives 455*219b2ee8SDavid du Colombierto the processing modules. 456*219b2ee8SDavid du ColombierBlocks and block buffers are dynamically allocated from kernel memory. 457*219b2ee8SDavid du Colombier.NH 3 458*219b2ee8SDavid du ColombierUser Interface 459*219b2ee8SDavid du Colombier.PP 460*219b2ee8SDavid du ColombierA stream is represented at user level as two files, 461*219b2ee8SDavid du Colombier.CW ctl 462*219b2ee8SDavid du Colombierand 463*219b2ee8SDavid du Colombier.CW data . 464*219b2ee8SDavid du ColombierThe actual names can be changed by the device driver using the stream, 465*219b2ee8SDavid du Colombieras we saw earlier in the example of the UART driver. 466*219b2ee8SDavid du ColombierThe first process to open either file creates the stream automatically. 467*219b2ee8SDavid du ColombierThe last close destroys it. 468*219b2ee8SDavid du ColombierWriting to the 469*219b2ee8SDavid du Colombier.CW data 470*219b2ee8SDavid du Colombierfile copies the data into kernel blocks 471*219b2ee8SDavid du Colombierand passes them to the downstream put routine of the first processing module. 472*219b2ee8SDavid du ColombierA write of less than 32K is guaranteed to be contained by a single block. 473*219b2ee8SDavid du ColombierConcurrent writes to the same stream are not synchronized, although the 474*219b2ee8SDavid du Colombier32K block size assures atomic writes for most protocols. 475*219b2ee8SDavid du ColombierThe last block written is flagged with a delimiter 476*219b2ee8SDavid du Colombierto alert downstream modules that care about write boundaries. 477*219b2ee8SDavid du ColombierIn most cases the first put routine calls the second, the second 478*219b2ee8SDavid du Colombiercalls the third, and so on until the data is output. 479*219b2ee8SDavid du ColombierAs a consequence, most data is output without context switching. 480*219b2ee8SDavid du Colombier.PP 481*219b2ee8SDavid du ColombierReading from the 482*219b2ee8SDavid du Colombier.CW data 483*219b2ee8SDavid du Colombierfile returns data queued at the top of the stream. 484*219b2ee8SDavid du ColombierThe read terminates when the read count is reached 485*219b2ee8SDavid du Colombieror when the end of a delimited block is encountered. 486*219b2ee8SDavid du ColombierA per stream read lock ensures only one process 487*219b2ee8SDavid du Colombiercan read from a stream at a time and guarantees 488*219b2ee8SDavid du Colombierthat the bytes read were contiguous bytes from the 489*219b2ee8SDavid du Colombierstream. 490*219b2ee8SDavid du Colombier.PP 491*219b2ee8SDavid du ColombierLike UNIX streams [Rit84a], 492*219b2ee8SDavid du ColombierPlan 9 streams can be dynamically configured. 493*219b2ee8SDavid du ColombierThe stream system intercepts and interprets 494*219b2ee8SDavid du Colombierthe following control blocks: 495*219b2ee8SDavid du Colombier.IP "\f(CWpush\fP \fIname\fR" 15 496*219b2ee8SDavid du Colombieradds an instance of the processing module 497*219b2ee8SDavid du Colombier.I name 498*219b2ee8SDavid du Colombierto the top of the stream. 499*219b2ee8SDavid du Colombier.IP \f(CWpop\fP 15 500*219b2ee8SDavid du Colombierremoves the top module of the stream. 501*219b2ee8SDavid du Colombier.IP \f(CWhangup\fP 15 502*219b2ee8SDavid du Colombiersends a hangup message 503*219b2ee8SDavid du Colombierup the stream from the device end. 504*219b2ee8SDavid du Colombier.LP 505*219b2ee8SDavid du ColombierOther control blocks are module-specific and are interpreted by each 506*219b2ee8SDavid du Colombierprocessing module 507*219b2ee8SDavid du Colombieras they pass. 508*219b2ee8SDavid du Colombier.PP 509*219b2ee8SDavid du ColombierThe convoluted syntax and semantics of the UNIX 510*219b2ee8SDavid du Colombier.CW ioctl 511*219b2ee8SDavid du Colombiersystem call convinced us to leave it out of Plan 9. 512*219b2ee8SDavid du ColombierInstead, 513*219b2ee8SDavid du Colombier.CW ioctl 514*219b2ee8SDavid du Colombieris replaced by the 515*219b2ee8SDavid du Colombier.CW ctl 516*219b2ee8SDavid du Colombierfile. 517*219b2ee8SDavid du ColombierWriting to the 518*219b2ee8SDavid du Colombier.CW ctl 519*219b2ee8SDavid du Colombierfile 520*219b2ee8SDavid du Colombieris identical to writing to a 521*219b2ee8SDavid du Colombier.CW data 522*219b2ee8SDavid du Colombierfile except the blocks are of type 523*219b2ee8SDavid du Colombier.I control . 524*219b2ee8SDavid du ColombierA processing module parses each control block it sees. 525*219b2ee8SDavid du ColombierCommands in control blocks are ASCII strings, so 526*219b2ee8SDavid du Colombierbyte ordering is not an issue when one system 527*219b2ee8SDavid du Colombiercontrols streams in a name space implemented on another processor. 528*219b2ee8SDavid du ColombierThe time to parse control blocks is not important, since control 529*219b2ee8SDavid du Colombieroperations are rare. 530*219b2ee8SDavid du Colombier.NH 3 531*219b2ee8SDavid du ColombierDevice Interface 532*219b2ee8SDavid du Colombier.PP 533*219b2ee8SDavid du ColombierThe module at the downstream end of the stream is part of a device interface. 534*219b2ee8SDavid du ColombierThe particulars of the interface vary with the device. 535*219b2ee8SDavid du ColombierMost device interfaces consist of an interrupt routine, an output 536*219b2ee8SDavid du Colombierput routine, and a kernel process. 537*219b2ee8SDavid du ColombierThe output put routine stages data for the 538*219b2ee8SDavid du Colombierdevice and starts the device if it is stopped. 539*219b2ee8SDavid du ColombierThe interrupt routine wakes up the kernel process whenever 540*219b2ee8SDavid du Colombierthe device has input to be processed or needs more output staged. 541*219b2ee8SDavid du ColombierThe kernel process puts information up the stream or stages more data for output. 542*219b2ee8SDavid du ColombierThe division of labor among the different pieces varies depending on 543*219b2ee8SDavid du Colombierhow much must be done at interrupt level. 544*219b2ee8SDavid du ColombierHowever, the interrupt routine may not allocate blocks or call 545*219b2ee8SDavid du Colombiera put routine since both actions require a process context. 546*219b2ee8SDavid du Colombier.NH 3 547*219b2ee8SDavid du ColombierMultiplexing 548*219b2ee8SDavid du Colombier.PP 549*219b2ee8SDavid du ColombierThe conversations using a protocol device must be 550*219b2ee8SDavid du Colombiermultiplexed onto a single physical wire. 551*219b2ee8SDavid du ColombierWe push a multiplexer processing module 552*219b2ee8SDavid du Colombieronto the physical device stream to group the conversations. 553*219b2ee8SDavid du ColombierThe device end modules on the conversations add the necessary header 554*219b2ee8SDavid du Colombieronto downstream messages and then put them to the module downstream 555*219b2ee8SDavid du Colombierof the multiplexer. 556*219b2ee8SDavid du ColombierThe multiplexing module looks at each message moving up its stream and 557*219b2ee8SDavid du Colombierputs it to the correct conversation stream after stripping 558*219b2ee8SDavid du Colombierthe header controlling the demultiplexing. 559*219b2ee8SDavid du Colombier.PP 560*219b2ee8SDavid du ColombierThis is similar to the Unix implementation of multiplexer streams. 561*219b2ee8SDavid du ColombierThe major difference is that we have no general structure that 562*219b2ee8SDavid du Colombiercorresponds to a multiplexer. 563*219b2ee8SDavid du ColombierEach attempt to produce a generalized multiplexer created a more complicated 564*219b2ee8SDavid du Colombierstructure and underlined the basic difficulty of generalizing this mechanism. 565*219b2ee8SDavid du ColombierWe now code each multiplexer from scratch and favor simplicity over 566*219b2ee8SDavid du Colombiergenerality. 567*219b2ee8SDavid du Colombier.NH 3 568*219b2ee8SDavid du ColombierReflections 569*219b2ee8SDavid du Colombier.PP 570*219b2ee8SDavid du ColombierDespite five year's experience and the efforts of many programmers, 571*219b2ee8SDavid du Colombierwe remain dissatisfied with the stream mechanism. 572*219b2ee8SDavid du ColombierPerformance is not an issue; 573*219b2ee8SDavid du Colombierthe time to process protocols and drive 574*219b2ee8SDavid du Colombierdevice interfaces continues to dwarf the 575*219b2ee8SDavid du Colombiertime spent allocating, freeing, and moving blocks 576*219b2ee8SDavid du Colombierof data. 577*219b2ee8SDavid du ColombierHowever the mechanism remains inordinately 578*219b2ee8SDavid du Colombiercomplex. 579*219b2ee8SDavid du ColombierMuch of the complexity results from our efforts 580*219b2ee8SDavid du Colombierto make streams dynamically configurable, to 581*219b2ee8SDavid du Colombierreuse processing modules on different devices 582*219b2ee8SDavid du Colombierand to provide kernel synchronization 583*219b2ee8SDavid du Colombierto ensure data structures 584*219b2ee8SDavid du Colombierdon't disappear under foot. 585*219b2ee8SDavid du ColombierThis is particularly irritating since we seldom use these properties. 586*219b2ee8SDavid du Colombier.PP 587*219b2ee8SDavid du ColombierStreams remain in our kernel because we are unable to 588*219b2ee8SDavid du Colombierdevise a better alternative. 589*219b2ee8SDavid du ColombierLarry Peterson's X-kernel [Pet89a] 590*219b2ee8SDavid du Colombieris the closest contender but 591*219b2ee8SDavid du Colombierdoesn't offer enough advantage to switch. 592*219b2ee8SDavid du ColombierIf we were to rewrite the streams code, we would probably statically 593*219b2ee8SDavid du Colombierallocate resources for a large fixed number of conversations and burn 594*219b2ee8SDavid du Colombiermemory in favor of less complexity. 5953e12c5d1SDavid du Colombier.NH 5963e12c5d1SDavid du ColombierThe IL Protocol 5973e12c5d1SDavid du Colombier.PP 598*219b2ee8SDavid du ColombierNone of the standard IP protocols is suitable for transmission of 5993e12c5d1SDavid du Colombier9P messages over an Ethernet or the Internet. 6003e12c5d1SDavid du ColombierTCP has a high overhead and does not preserve delimiters. 601bd389b36SDavid du ColombierUDP, while cheap, does not provide reliable sequenced delivery. 602bd389b36SDavid du ColombierEarly versions of the system used a custom protocol that was 603bd389b36SDavid du Colombierefficient but unsatisfactory for internetwork transmission. 604*219b2ee8SDavid du ColombierWhen we implemented IP, TCP, and UDP we looked around for a suitable 605bd389b36SDavid du Colombierreplacement with the following properties: 6063e12c5d1SDavid du Colombier.IP \(bu 6073e12c5d1SDavid du ColombierReliable datagram service with sequenced delivery 6083e12c5d1SDavid du Colombier.IP \(bu 609bd389b36SDavid du ColombierRuns over IP 6103e12c5d1SDavid du Colombier.IP \(bu 6113e12c5d1SDavid du ColombierLow complexity, high performance 6123e12c5d1SDavid du Colombier.IP \(bu 613bd389b36SDavid du ColombierAdaptive timeouts 6143e12c5d1SDavid du Colombier.LP 615bd389b36SDavid du ColombierNone met our needs so a new protocol was designed. 6163e12c5d1SDavid du ColombierIL is a lightweight protocol designed to be encapsulated by IP. 617bd389b36SDavid du ColombierIt is a connection-based protocol 618bd389b36SDavid du Colombierproviding reliable transmission of sequenced messages between machines. 619bd389b36SDavid du ColombierNo provision is made for flow control since the protocol is designed to transport RPC 6203e12c5d1SDavid du Colombiermessages between client and server. 6213e12c5d1SDavid du ColombierA small outstanding message window prevents too 622bd389b36SDavid du Colombiermany incoming messages from being buffered; 623bd389b36SDavid du Colombiermessages outside the window are discarded 624bd389b36SDavid du Colombierand must be retransmitted. 6253e12c5d1SDavid du ColombierConnection setup uses a two way handshake to generate 626bd389b36SDavid du Colombierinitial sequence numbers at each end of the connection; 627bd389b36SDavid du Colombiersubsequent data messages increment the 628bd389b36SDavid du Colombiersequence numbers allowing 629bd389b36SDavid du Colombierthe receiver to resequence out of order messages. 630bd389b36SDavid du ColombierIn contrast to other protocols, IL does not do blind retransmission. 631bd389b36SDavid du ColombierIf a message is lost and a timeout occurs, a query message is sent. 6323e12c5d1SDavid du ColombierThe query message is a small control message containing the current 6333e12c5d1SDavid du Colombiersequence numbers as seen by the sender. 6343e12c5d1SDavid du ColombierThe receiver responds to a query by retransmitting missing messages. 6353e12c5d1SDavid du ColombierThis allows the protocol to behave well in congested networks, 6363e12c5d1SDavid du Colombierwhere blind retransmission would cause further 6373e12c5d1SDavid du Colombiercongestion. 6383e12c5d1SDavid du ColombierLike TCP, IL has adaptive timeouts. 6393e12c5d1SDavid du ColombierA round-trip timer is used 6403e12c5d1SDavid du Colombierto calculate acknowledge and retransmission times in terms of the network speed. 641bd389b36SDavid du ColombierThis allows the protocol to perform well on both the Internet and on local Ethernets. 6423e12c5d1SDavid du Colombier.PP 6433e12c5d1SDavid du ColombierIn keeping with the minimalist design of the rest of the kernel, IL is small. 6443e12c5d1SDavid du ColombierThe entire protocol is 847 lines of code, compared to 2200 lines for TCP. 645bd389b36SDavid du ColombierIL is our protocol of choice. 6463e12c5d1SDavid du Colombier.NH 6473e12c5d1SDavid du ColombierNetwork Addressing 6483e12c5d1SDavid du Colombier.PP 649bd389b36SDavid du ColombierA uniform interface to protocols and devices is not sufficient to 650bd389b36SDavid du Colombiersupport the transparency we require. 651bd389b36SDavid du ColombierSince each network uses a different 652bd389b36SDavid du Colombieraddressing scheme, 653bd389b36SDavid du Colombierthe ASCII strings written to a control file have no common format. 654bd389b36SDavid du ColombierAs a result, every tool must know the specifics of the networks it 6553e12c5d1SDavid du Colombieris capable of addressing. 656bd389b36SDavid du ColombierMoreover, since each machine supplies a subset 657bd389b36SDavid du Colombierof the available networks, each user must be aware of the networks supported 658bd389b36SDavid du Colombierby every terminal and server machine. 659bd389b36SDavid du ColombierThis is obviously unacceptable. 6603e12c5d1SDavid du Colombier.PP 661bd389b36SDavid du ColombierSeveral possible solutions were considered and rejected; one deserves 6623e12c5d1SDavid du Colombiermore discussion. 663bd389b36SDavid du ColombierWe could have used a user-level file server 6643e12c5d1SDavid du Colombierto represent the network name space as a Plan 9 file tree. 6653e12c5d1SDavid du ColombierThis global naming scheme has been implemented in other distributed systems. 666bd389b36SDavid du ColombierThe file hierarchy provides paths to 667bd389b36SDavid du Colombierdirectories representing network domains. 668bd389b36SDavid du ColombierEach directory contains 669bd389b36SDavid du Colombierfiles representing the names of the machines in that domain; 6703e12c5d1SDavid du Colombieran example might be the path 6713e12c5d1SDavid du Colombier.CW /net/name/usa/edu/mit/ai . 672bd389b36SDavid du ColombierEach machine file contains information like the IP address of the machine. 673bd389b36SDavid du ColombierWe rejected this representation for several reasons. 674bd389b36SDavid du ColombierFirst, it is hard to devise a hierarchy encompassing all representations 6753e12c5d1SDavid du Colombierof the various network addressing schemes in a uniform manner. 6763e12c5d1SDavid du ColombierDatakit and Ethernet address strings have nothing in common. 6773e12c5d1SDavid du ColombierSecond, the address of a machine is 678bd389b36SDavid du Colombieroften only a small part of the information required to connect to a service on 679bd389b36SDavid du Colombierthe machine. 680bd389b36SDavid du ColombierFor example, the IP protocols require symbolic service names to be mapped into 6813e12c5d1SDavid du Colombiernumeric port numbers, some of which are privileged and hence special. 6823e12c5d1SDavid du ColombierInformation of this sort is hard to represent in terms of file operations. 683bd389b36SDavid du ColombierFinally, the size and number of the networks being represented burdens users with 6843e12c5d1SDavid du Colombieran unacceptably large amount of information about the organization of the network 6853e12c5d1SDavid du Colombierand its connectivity. 686bd389b36SDavid du ColombierIn this case the Plan 9 representation of a 687bd389b36SDavid du Colombierresource as a file is not appropriate. 6883e12c5d1SDavid du Colombier.PP 689bd389b36SDavid du ColombierIf tools are to be network independent, a third-party server must resolve 6903e12c5d1SDavid du Colombiernetwork names. 6913e12c5d1SDavid du ColombierA server on each machine, with local knowledge, can select the best network 692bd389b36SDavid du Colombierfor any particular destination machine or service. 693bd389b36SDavid du ColombierSince the network devices present a common interface, 6943e12c5d1SDavid du Colombierthe only operation which differs between networks is name resolution. 695bd389b36SDavid du ColombierA symbolic name must be translated to 696bd389b36SDavid du Colombierthe path of the clone file of a protocol 697bd389b36SDavid du Colombierdevice and an ASCII address string to write to the 6983e12c5d1SDavid du Colombier.CW ctl 6993e12c5d1SDavid du Colombierfile. 7003e12c5d1SDavid du ColombierA connection server (CS) provides this service. 701*219b2ee8SDavid du Colombier.NH 2 702*219b2ee8SDavid du ColombierNetwork Database 703*219b2ee8SDavid du Colombier.PP 704*219b2ee8SDavid du ColombierOn most systems several 705*219b2ee8SDavid du Colombierfiles such as 706*219b2ee8SDavid du Colombier.CW /etc/hosts , 707*219b2ee8SDavid du Colombier.CW /etc/networks , 708*219b2ee8SDavid du Colombier.CW /etc/services , 709*219b2ee8SDavid du Colombier.CW /etc/hosts.equiv , 710*219b2ee8SDavid du Colombier.CW /etc/bootptab , 711*219b2ee8SDavid du Colombierand 712*219b2ee8SDavid du Colombier.CW /etc/named.d 713*219b2ee8SDavid du Colombierhold network information. 714*219b2ee8SDavid du ColombierMuch time and effort is spent 715*219b2ee8SDavid du Colombieradministering these files and keeping 716*219b2ee8SDavid du Colombierthem mutually consistent. 717*219b2ee8SDavid du ColombierTools attempt to 718*219b2ee8SDavid du Colombierautomatically derive one or more of the files from 719*219b2ee8SDavid du Colombierinformation in other files but maintenance continues to be 720*219b2ee8SDavid du Colombierdifficult and error prone. 721*219b2ee8SDavid du Colombier.PP 722*219b2ee8SDavid du ColombierSince we were writing an entirely new system, we were free to 723*219b2ee8SDavid du Colombiertry a simpler approach. 724*219b2ee8SDavid du ColombierOne database on a shared server contains all the information 725*219b2ee8SDavid du Colombierneeded for network administration. 726*219b2ee8SDavid du ColombierTwo ASCII files comprise the main database: 727*219b2ee8SDavid du Colombier.CW /lib/ndb/local 728*219b2ee8SDavid du Colombiercontains locally administered information and 729*219b2ee8SDavid du Colombier.CW /lib/ndb/global 730*219b2ee8SDavid du Colombiercontains information imported from elsewhere. 731*219b2ee8SDavid du ColombierThe files contain sets of attribute/value pairs of the form 732*219b2ee8SDavid du Colombier.I attr\f(CW=\fPvalue , 733*219b2ee8SDavid du Colombierwhere 734*219b2ee8SDavid du Colombier.I attr 735*219b2ee8SDavid du Colombierand 736*219b2ee8SDavid du Colombier.I value 737*219b2ee8SDavid du Colombierare alphanumeric strings. 738*219b2ee8SDavid du ColombierSystems are described by multi-line entries; 739*219b2ee8SDavid du Colombiera header line at the left margin begins each entry followed by zero or more 740*219b2ee8SDavid du Colombierindented attribute/value pairs specifying 741*219b2ee8SDavid du Colombiernames, addresses, properties, etc. 742*219b2ee8SDavid du ColombierFor example, the entry for our CPU server 743*219b2ee8SDavid du Colombierspecifies a domain name, an IP address, an Ethernet address, 744*219b2ee8SDavid du Colombiera Datakit address, a boot file, and supported protocols. 745*219b2ee8SDavid du Colombier.P1 746*219b2ee8SDavid du Colombiersys = helix 747*219b2ee8SDavid du Colombier dom=helix.research.att.com 748*219b2ee8SDavid du Colombier bootf=/mips/9power 749*219b2ee8SDavid du Colombier ip=135.104.9.31 ether=0800690222f0 750*219b2ee8SDavid du Colombier dk=nj/astro/helix 751*219b2ee8SDavid du Colombier proto=il flavor=9cpu 752*219b2ee8SDavid du Colombier.P2 753*219b2ee8SDavid du ColombierIf several systems share entries such as 754*219b2ee8SDavid du Colombiernetwork mask and gateway, we specify that information 755*219b2ee8SDavid du Colombierwith the network or subnetwork instead of the system. 756*219b2ee8SDavid du ColombierThe following entries define a Class B IP network and 757*219b2ee8SDavid du Colombiera few subnets derived from it. 758*219b2ee8SDavid du ColombierThe entry for the network specifies the IP mask, 759*219b2ee8SDavid du Colombierfile system, and authentication server for all systems 760*219b2ee8SDavid du Colombieron the network. 761*219b2ee8SDavid du ColombierEach subnetwork specifies its default IP gateway. 762*219b2ee8SDavid du Colombier.P1 763*219b2ee8SDavid du Colombieripnet=mh-astro-net ip=135.104.0.0 ipmask=255.255.255.0 764*219b2ee8SDavid du Colombier fs=bootes.research.att.com 765*219b2ee8SDavid du Colombier auth=1127auth 766*219b2ee8SDavid du Colombieripnet=unix-room ip=135.104.117.0 767*219b2ee8SDavid du Colombier ipgw=135.104.117.1 768*219b2ee8SDavid du Colombieripnet=third-floor ip=135.104.51.0 769*219b2ee8SDavid du Colombier ipgw=135.104.51.1 770*219b2ee8SDavid du Colombieripnet=fourth-floor ip=135.104.52.0 771*219b2ee8SDavid du Colombier ipgw=135.104.52.1 772*219b2ee8SDavid du Colombier.P2 773*219b2ee8SDavid du ColombierDatabase entries also define the mapping of service names 774*219b2ee8SDavid du Colombierto port numbers for TCP, UDP, and IL. 775*219b2ee8SDavid du Colombier.P1 776*219b2ee8SDavid du Colombiertcp=echo port=7 777*219b2ee8SDavid du Colombiertcp=discard port=9 778*219b2ee8SDavid du Colombiertcp=systat port=11 779*219b2ee8SDavid du Colombiertcp=daytime port=13 780*219b2ee8SDavid du Colombier.P2 781*219b2ee8SDavid du Colombier.PP 782*219b2ee8SDavid du ColombierAll programs read the database directly so 783*219b2ee8SDavid du Colombierconsistency problems are rare. 784*219b2ee8SDavid du ColombierHowever the database files can become large. 785*219b2ee8SDavid du ColombierOur global file, containing all information about 786*219b2ee8SDavid du Colombierboth Datakit and Internet systems in AT&T, has 43,000 787*219b2ee8SDavid du Colombierlines. 788*219b2ee8SDavid du ColombierTo speed searches, we build hash table files for each 789*219b2ee8SDavid du Colombierattribute we expect to search often. 790*219b2ee8SDavid du ColombierThe hash file entries point to entries 791*219b2ee8SDavid du Colombierin the master files. 792*219b2ee8SDavid du ColombierEvery hash file contains the modification time of its master 793*219b2ee8SDavid du Colombierfile so we can avoid using an out-of-date hash table. 794*219b2ee8SDavid du ColombierSearches for attributes that aren't hashed or whose hash table 795*219b2ee8SDavid du Colombieris out-of-date still work, they just take longer. 796*219b2ee8SDavid du Colombier.NH 2 797*219b2ee8SDavid du ColombierConnection Server 798*219b2ee8SDavid du Colombier.PP 799*219b2ee8SDavid du ColombierOn each system a user level connection server process, CS, translates 800*219b2ee8SDavid du Colombiersymbolic names to addresses. 801*219b2ee8SDavid du ColombierCS uses information about available networks, the network database, and 802*219b2ee8SDavid du Colombierother servers (such as DNS) to translate names. 803*219b2ee8SDavid du ColombierCS is a file server serving a single file, 804*219b2ee8SDavid du Colombier.CW /net/cs . 805*219b2ee8SDavid du ColombierA client writes a symbolic name to 806*219b2ee8SDavid du Colombier.CW /net/cs 807*219b2ee8SDavid du Colombierthen reads one line for each matching destination reachable 808*219b2ee8SDavid du Colombierfrom this system. 809*219b2ee8SDavid du ColombierThe lines are of the form 810*219b2ee8SDavid du Colombier.I "filename message", 811*219b2ee8SDavid du Colombierwhere 812*219b2ee8SDavid du Colombier.I filename 813*219b2ee8SDavid du Colombieris the path of the clone file to open for a new connection and 814*219b2ee8SDavid du Colombier.I message 815*219b2ee8SDavid du Colombieris the string to write to it to make the connection. 816*219b2ee8SDavid du ColombierThe following example illustrates this. 817*219b2ee8SDavid du Colombier.CW Ndb/csquery 818*219b2ee8SDavid du Colombieris a program that prompts for strings to write to 819*219b2ee8SDavid du Colombier.CW /net/cs 820*219b2ee8SDavid du Colombierand prints the replies. 821*219b2ee8SDavid du Colombier.P1 822*219b2ee8SDavid du Colombier% ndb/csquery 823*219b2ee8SDavid du Colombier> net!helix!9fs 824*219b2ee8SDavid du Colombier/net/il/clone 135.104.9.31!17008 825*219b2ee8SDavid du Colombier/net/dk/clone nj/astro/helix!9fs 826*219b2ee8SDavid du Colombier.P2 827*219b2ee8SDavid du Colombier.PP 828*219b2ee8SDavid du ColombierCS provides meta-name translation to perform complicated 829*219b2ee8SDavid du Colombiersearches. 830*219b2ee8SDavid du ColombierThe special network name 831*219b2ee8SDavid du Colombier.CW net 832*219b2ee8SDavid du Colombierselects any network in common between source and 833*219b2ee8SDavid du Colombierdestination supporting the specified service. 834*219b2ee8SDavid du ColombierA host name of the form \f(CW$\fIattr\f1 835*219b2ee8SDavid du Colombieris the name of an attribute in the network database. 836*219b2ee8SDavid du ColombierThe database search returns the value 837*219b2ee8SDavid du Colombierof the matching attribute/value pair 838*219b2ee8SDavid du Colombiermost closely associated with the source host. 839*219b2ee8SDavid du ColombierMost closely associated is defined on a per network basis. 840*219b2ee8SDavid du ColombierFor example, the symbolic name 841*219b2ee8SDavid du Colombier.CW tcp!$auth!rexauth 842*219b2ee8SDavid du Colombiercauses CS to search for the 843*219b2ee8SDavid du Colombier.CW auth 844*219b2ee8SDavid du Colombierattribute in the database entry for the source system, then its 845*219b2ee8SDavid du Colombiersubnetwork (if there is one) and then its network. 846*219b2ee8SDavid du Colombier.P1 847*219b2ee8SDavid du Colombier% ndb/csquery 848*219b2ee8SDavid du Colombier> net!$auth!rexauth 849*219b2ee8SDavid du Colombier/net/il/clone 135.104.9.34!17021 850*219b2ee8SDavid du Colombier/net/dk/clone nj/astro/p9auth!rexauth 851*219b2ee8SDavid du Colombier/net/il/clone 135.104.9.6!17021 852*219b2ee8SDavid du Colombier/net/dk/clone nj/astro/musca!rexauth 853*219b2ee8SDavid du Colombier.P2 854*219b2ee8SDavid du Colombier.PP 855*219b2ee8SDavid du ColombierNormally CS derives naming information from its database files. 856*219b2ee8SDavid du ColombierFor domain names however, CS first consults another user level 857*219b2ee8SDavid du Colombierprocess, the domain name server (DNS). 858*219b2ee8SDavid du ColombierIf no DNS is reachable, CS relies on its own tables. 859*219b2ee8SDavid du Colombier.PP 860*219b2ee8SDavid du ColombierLike CS, the domain name server is a user level process providing 861*219b2ee8SDavid du Colombierone file, 862*219b2ee8SDavid du Colombier.CW /net/dns . 863*219b2ee8SDavid du ColombierA client writes a request of the form 864*219b2ee8SDavid du Colombier.I "domain-name type" , 865*219b2ee8SDavid du Colombierwhere 866*219b2ee8SDavid du Colombier.I type 867*219b2ee8SDavid du Colombieris a domain name service resource record type. 868*219b2ee8SDavid du ColombierDNS performs a recursive query through the 869*219b2ee8SDavid du ColombierInternet domain name system producing one line 870*219b2ee8SDavid du Colombierper resource record found. The client reads 871*219b2ee8SDavid du Colombier.CW /net/dns 872*219b2ee8SDavid du Colombierto retrieve the records. 873*219b2ee8SDavid du ColombierLike other domain name servers, DNS caches information 874*219b2ee8SDavid du Colombierlearned from the network. 875*219b2ee8SDavid du ColombierDNS is implemented as a multi-process shared memory application 876*219b2ee8SDavid du Colombierwith separate processes listening for network and local requests. 877*219b2ee8SDavid du Colombier.NH 878*219b2ee8SDavid du ColombierLibrary routines 879*219b2ee8SDavid du Colombier.PP 880*219b2ee8SDavid du ColombierThe section on protocol devices described the details 881*219b2ee8SDavid du Colombierof making and receiving connections across a network. 882*219b2ee8SDavid du ColombierThe dance is straightforward but tedious. 883*219b2ee8SDavid du ColombierLibrary routines are provided to relieve 884*219b2ee8SDavid du Colombierthe programmer of the details. 885*219b2ee8SDavid du Colombier.NH 2 886*219b2ee8SDavid du ColombierConnecting 887*219b2ee8SDavid du Colombier.PP 888*219b2ee8SDavid du ColombierThe 889*219b2ee8SDavid du Colombier.CW dial 890*219b2ee8SDavid du Colombierlibrary call establishes a connection to a remote destination. 891*219b2ee8SDavid du ColombierIt 892*219b2ee8SDavid du Colombierreturns an open file descriptor for the 893*219b2ee8SDavid du Colombier.CW data 894*219b2ee8SDavid du Colombierfile in the connection directory. 895*219b2ee8SDavid du Colombier.P1 896*219b2ee8SDavid du Colombierint dial(char *dest, char *local, char *dir, int *cfdp) 897*219b2ee8SDavid du Colombier.P2 898*219b2ee8SDavid du Colombier.IP \f(CWdest\fP 10 899*219b2ee8SDavid du Colombieris the symbolic name/address of the destination. 900*219b2ee8SDavid du Colombier.IP \f(CWlocal\fP 10 901*219b2ee8SDavid du Colombieris the local address. 902*219b2ee8SDavid du ColombierSince most networks do not support this, it is 903*219b2ee8SDavid du Colombierusually zero. 904*219b2ee8SDavid du Colombier.IP \f(CWdir\fP 10 905*219b2ee8SDavid du Colombieris a pointer to a buffer to hold the path name of the protocol directory 906*219b2ee8SDavid du Colombierrepresenting this connection. 907*219b2ee8SDavid du Colombier.CW Dial 908*219b2ee8SDavid du Colombierfills this buffer if the pointer is non-zero. 909*219b2ee8SDavid du Colombier.IP \f(CWcfdp\fP 10 910*219b2ee8SDavid du Colombieris a pointer to a file descriptor for the 911*219b2ee8SDavid du Colombier.CW ctl 912*219b2ee8SDavid du Colombierfile of the connection. 913*219b2ee8SDavid du ColombierIf the pointer is non-zero, 914*219b2ee8SDavid du Colombier.CW dial 915*219b2ee8SDavid du Colombieropens the control file and tucks the file descriptor here. 916*219b2ee8SDavid du Colombier.LP 917*219b2ee8SDavid du ColombierMost programs call 918*219b2ee8SDavid du Colombier.CW dial 919*219b2ee8SDavid du Colombierwith a destination name and all other arguments zero. 920*219b2ee8SDavid du Colombier.CW Dial 921*219b2ee8SDavid du Colombieruses CS to 922*219b2ee8SDavid du Colombiertranslate the symbolic name to all possible destination addresses 923*219b2ee8SDavid du Colombierand attempts to connect to each in turn until one works. 924*219b2ee8SDavid du ColombierSpecifying the special name 925*219b2ee8SDavid du Colombier.CW net 926*219b2ee8SDavid du Colombierin the network portion of the destination 927*219b2ee8SDavid du Colombierallows CS to pick a network/protocol in common 928*219b2ee8SDavid du Colombierwith the destination for which the requested service is valid. 929*219b2ee8SDavid du ColombierFor example, assume the system 930*219b2ee8SDavid du Colombier.CW research.att.com 931*219b2ee8SDavid du Colombierhas the Datakit address 932*219b2ee8SDavid du Colombier.CW nj/astro/research 933*219b2ee8SDavid du Colombierand IP addresses 934*219b2ee8SDavid du Colombier.CW 135.104.117.5 935*219b2ee8SDavid du Colombierand 936*219b2ee8SDavid du Colombier.CW 129.11.4.1 . 937*219b2ee8SDavid du ColombierThe call 938*219b2ee8SDavid du Colombier.P1 939*219b2ee8SDavid du Colombierfd = dial("net!research.att.com!login", 0, 0, 0, 0); 940*219b2ee8SDavid du Colombier.P2 941*219b2ee8SDavid du Colombiertries in succession to connect to 942*219b2ee8SDavid du Colombier.CW nj/astro/research!login 943*219b2ee8SDavid du Colombieron the Datakit and both 944*219b2ee8SDavid du Colombier.CW 135.104.117.5!513 945*219b2ee8SDavid du Colombierand 946*219b2ee8SDavid du Colombier.CW 129.11.4.1!513 947*219b2ee8SDavid du Colombieracross the Internet. 948*219b2ee8SDavid du Colombier.PP 949*219b2ee8SDavid du Colombier.CW Dial 950*219b2ee8SDavid du Colombieraccepts addresses instead of symbolic names. 951*219b2ee8SDavid du ColombierFor example, the destinations 952*219b2ee8SDavid du Colombier.CW tcp!135.104.117.5!513 953*219b2ee8SDavid du Colombierand 954*219b2ee8SDavid du Colombier.CW tcp!research.att.com!login 955*219b2ee8SDavid du Colombierare equivalent 956*219b2ee8SDavid du Colombierreferences to the same machine. 957*219b2ee8SDavid du Colombier.NH 2 958*219b2ee8SDavid du ColombierListening 959*219b2ee8SDavid du Colombier.PP 960*219b2ee8SDavid du ColombierA program uses 961*219b2ee8SDavid du Colombierfour routines to listen for incoming connections. 962*219b2ee8SDavid du ColombierIt first 963*219b2ee8SDavid du Colombier.CW announce() s 964*219b2ee8SDavid du Colombierits intention to receive connections, 965*219b2ee8SDavid du Colombierthen 966*219b2ee8SDavid du Colombier.CW listen() s 967*219b2ee8SDavid du Colombierfor calls and finally 968*219b2ee8SDavid du Colombier.CW accept() s 969*219b2ee8SDavid du Colombieror 970*219b2ee8SDavid du Colombier.CW reject() s 971*219b2ee8SDavid du Colombierthem. 972*219b2ee8SDavid du Colombier.CW Announce 973*219b2ee8SDavid du Colombierreturns an open file descriptor for the 974*219b2ee8SDavid du Colombier.CW ctl 975*219b2ee8SDavid du Colombierfile of a connection and fills 976*219b2ee8SDavid du Colombier.CW dir 977*219b2ee8SDavid du Colombierwith the 978*219b2ee8SDavid du Colombierpath of the protocol directory 979*219b2ee8SDavid du Colombierfor the announcement. 980*219b2ee8SDavid du Colombier.P1 981*219b2ee8SDavid du Colombierint announce(char *addr, char *dir) 982*219b2ee8SDavid du Colombier.P2 983*219b2ee8SDavid du Colombier.CW Addr 984*219b2ee8SDavid du Colombieris the symbolic name/address announced; 985*219b2ee8SDavid du Colombierif it does not contain a service, the announcement is for 986*219b2ee8SDavid du Colombierall services not explicitly announced. 987*219b2ee8SDavid du ColombierThus, one can easily write the equivalent of the 988*219b2ee8SDavid du Colombier.CW inetd 989*219b2ee8SDavid du Colombierprogram without 990*219b2ee8SDavid du Colombierhaving to announce each separate service. 991*219b2ee8SDavid du ColombierAn announcement remains in force until the control file is 992*219b2ee8SDavid du Colombierclosed. 993*219b2ee8SDavid du Colombier.LP 994*219b2ee8SDavid du Colombier.CW Listen 995*219b2ee8SDavid du Colombierreturns an open file descriptor for the 996*219b2ee8SDavid du Colombier.CW ctl 997*219b2ee8SDavid du Colombierfile and fills 998*219b2ee8SDavid du Colombier.CW ldir 999*219b2ee8SDavid du Colombierwith the path 1000*219b2ee8SDavid du Colombierof the protocol directory 1001*219b2ee8SDavid du Colombierfor the received connection. 1002*219b2ee8SDavid du ColombierIt is passed 1003*219b2ee8SDavid du Colombier.CW dir 1004*219b2ee8SDavid du Colombierfrom the announcement. 1005*219b2ee8SDavid du Colombier.P1 1006*219b2ee8SDavid du Colombierint listen(char *dir, char *ldir) 1007*219b2ee8SDavid du Colombier.P2 1008*219b2ee8SDavid du Colombier.LP 1009*219b2ee8SDavid du Colombier.CW Accept 1010*219b2ee8SDavid du Colombierand 1011*219b2ee8SDavid du Colombier.CW reject 1012*219b2ee8SDavid du Colombierare called with the control file descriptor and 1013*219b2ee8SDavid du Colombier.CW ldir 1014*219b2ee8SDavid du Colombierreturned by 1015*219b2ee8SDavid du Colombier.CW listen. 1016*219b2ee8SDavid du ColombierSome networks such as Datakit accept a reason for a rejection; 1017*219b2ee8SDavid du Colombiernetworks such as IP ignore the third argument. 1018*219b2ee8SDavid du Colombier.P1 1019*219b2ee8SDavid du Colombierint accept(int ctl, char *ldir) 1020*219b2ee8SDavid du Colombierint reject(int ctl, char *ldir, char *reason) 1021*219b2ee8SDavid du Colombier.P2 1022*219b2ee8SDavid du Colombier.PP 1023*219b2ee8SDavid du ColombierThe following code implements a typical TCP listener. 1024*219b2ee8SDavid du ColombierIt announces itself, listens for connections, and forks a new 1025*219b2ee8SDavid du Colombierprocess for each. 1026*219b2ee8SDavid du ColombierThe new process echoes data on the connection until the 1027*219b2ee8SDavid du Colombierremote end closes it. 1028*219b2ee8SDavid du ColombierThe "*" in the symbolic name means the announcement is valid for 1029*219b2ee8SDavid du Colombierany addresses bound to the machine the program is run on. 1030*219b2ee8SDavid du Colombier.P1 1031*219b2ee8SDavid du Colombier.ta 8n 16n 24n 32n 40n 48n 56n 64n 1032*219b2ee8SDavid du Colombierint 1033*219b2ee8SDavid du Colombierecho_server(void) 1034*219b2ee8SDavid du Colombier{ 1035*219b2ee8SDavid du Colombier int dfd, lcfd; 1036*219b2ee8SDavid du Colombier char adir[40], ldir[40]; 1037*219b2ee8SDavid du Colombier int n; 1038*219b2ee8SDavid du Colombier char buf[256]; 1039*219b2ee8SDavid du Colombier 1040*219b2ee8SDavid du Colombier afd = announce("tcp!*!echo", adir); 1041*219b2ee8SDavid du Colombier if(afd < 0) 1042*219b2ee8SDavid du Colombier return -1; 1043*219b2ee8SDavid du Colombier 1044*219b2ee8SDavid du Colombier for(;;){ 1045*219b2ee8SDavid du Colombier /* listen for a call */ 1046*219b2ee8SDavid du Colombier lcfd = listen(adir, ldir); 1047*219b2ee8SDavid du Colombier if(lcfd < 0) 1048*219b2ee8SDavid du Colombier return -1; 1049*219b2ee8SDavid du Colombier 1050*219b2ee8SDavid du Colombier /* fork a process to echo */ 1051*219b2ee8SDavid du Colombier switch(fork()){ 1052*219b2ee8SDavid du Colombier case 0: 1053*219b2ee8SDavid du Colombier /* accept the call and open the data file */ 1054*219b2ee8SDavid du Colombier dfd = accept(lcfd, ldir); 1055*219b2ee8SDavid du Colombier if(dfd < 0) 1056*219b2ee8SDavid du Colombier return -1; 1057*219b2ee8SDavid du Colombier 1058*219b2ee8SDavid du Colombier /* echo until EOF */ 1059*219b2ee8SDavid du Colombier while((n = read(dfd, buf, sizeof(buf))) > 0) 1060*219b2ee8SDavid du Colombier write(dfd, buf, n); 1061*219b2ee8SDavid du Colombier exits(0); 1062*219b2ee8SDavid du Colombier case -1: 1063*219b2ee8SDavid du Colombier perror("forking"); 1064*219b2ee8SDavid du Colombier default: 1065*219b2ee8SDavid du Colombier close(lcfd); 1066*219b2ee8SDavid du Colombier break; 1067*219b2ee8SDavid du Colombier } 1068*219b2ee8SDavid du Colombier 1069*219b2ee8SDavid du Colombier } 1070*219b2ee8SDavid du Colombier} 1071*219b2ee8SDavid du Colombier.P2 10723e12c5d1SDavid du Colombier.NH 10733e12c5d1SDavid du ColombierUser Level 10743e12c5d1SDavid du Colombier.PP 10753e12c5d1SDavid du ColombierCommunication between Plan 9 machines is done almost exclusively in 1076*219b2ee8SDavid du Colombierterms of 9P messages. Only the two services 1077*219b2ee8SDavid du Colombier.CW cpu 10783e12c5d1SDavid du Colombierand 1079*219b2ee8SDavid du Colombier.CW exportfs 10803e12c5d1SDavid du Colombierare used. 10813e12c5d1SDavid du ColombierThe 1082*219b2ee8SDavid du Colombier.CW cpu 1083bd389b36SDavid du Colombierservice is analogous to 1084bd389b36SDavid du Colombier.CW rlogin . 10853e12c5d1SDavid du ColombierHowever, rather than emulating a terminal session 10863e12c5d1SDavid du Colombieracross the network, 1087*219b2ee8SDavid du Colombier.CW cpu 10883e12c5d1SDavid du Colombiercreates a process on the remote machine whose name space is an analogue of the window 10893e12c5d1SDavid du Colombierin which it was invoked. 1090*219b2ee8SDavid du Colombier.CW Exportfs 10913e12c5d1SDavid du Colombieris a user level file server which allows a piece of name space to be 10923e12c5d1SDavid du Colombierexported from machine to machine across a network. It is used by the 1093*219b2ee8SDavid du Colombier.CW cpu 1094bd389b36SDavid du Colombiercommand to serve the files in the terminal's name space when they are 1095bd389b36SDavid du Colombieraccessed from the 10963e12c5d1SDavid du Colombiercpu server. 10973e12c5d1SDavid du Colombier.PP 1098*219b2ee8SDavid du ColombierBy convention, the protocol and device driver file systems are mounted in a 10993e12c5d1SDavid du Colombierdirectory called 1100bd389b36SDavid du Colombier.CW /net . 1101bd389b36SDavid du ColombierAlthough the per-process name space allows users to configure an 1102*219b2ee8SDavid du Colombierarbitrary view of the system, in practice their profiles build 1103bd389b36SDavid du Colombiera conventional name space. 11043e12c5d1SDavid du Colombier.NH 2 11053e12c5d1SDavid du ColombierExportfs 11063e12c5d1SDavid du Colombier.PP 1107*219b2ee8SDavid du Colombier.CW Exportfs 1108bd389b36SDavid du Colombieris invoked by an incoming network call. 1109bd389b36SDavid du ColombierThe 1110*219b2ee8SDavid du Colombier.I listener 1111bd389b36SDavid du Colombier(the Plan 9 equivalent of 1112bd389b36SDavid du Colombier.CW inetd ) 1113bd389b36SDavid du Colombierruns the profile of the user 1114bd389b36SDavid du Colombierrequesting the service to construct a name space before starting 1115*219b2ee8SDavid du Colombier.CW exportfs . 1116bd389b36SDavid du ColombierAfter an initial protocol 1117bd389b36SDavid du Colombierestablishes the root of the file tree being 1118bd389b36SDavid du Colombierexported, 1119*219b2ee8SDavid du Colombierthe remote process mounts the connection, 1120bd389b36SDavid du Colombierallowing 1121*219b2ee8SDavid du Colombier.CW exportfs 1122bd389b36SDavid du Colombierto act as a relay file server. Operations in the imported file tree 11233e12c5d1SDavid du Colombierare executed on the remote server and the results returned. 1124bd389b36SDavid du ColombierAs a result 1125bd389b36SDavid du Colombierthe name space of the remote machine appears to be exported into a 11263e12c5d1SDavid du Colombierlocal file tree. 11273e12c5d1SDavid du Colombier.PP 11283e12c5d1SDavid du ColombierThe 1129*219b2ee8SDavid du Colombier.CW import 11303e12c5d1SDavid du Colombiercommand calls 1131*219b2ee8SDavid du Colombier.CW exportfs 1132*219b2ee8SDavid du Colombieron a remote machine, mounts the result in the local name space, 1133*219b2ee8SDavid du Colombierand 1134bd389b36SDavid du Colombierexits. 1135*219b2ee8SDavid du ColombierNo local process is required to serve mounts; 1136*219b2ee8SDavid du Colombier9P messages are generated by the kernel's mount driver and sent 11373e12c5d1SDavid du Colombierdirectly over the network. 11383e12c5d1SDavid du Colombier.PP 1139*219b2ee8SDavid du Colombier.CW Exportfs 11403e12c5d1SDavid du Colombiermust be multithreaded since the system calls 1141*219b2ee8SDavid du Colombier.CW open, 1142*219b2ee8SDavid du Colombier.CW read 11433e12c5d1SDavid du Colombierand 1144*219b2ee8SDavid du Colombier.CW write 11453e12c5d1SDavid du Colombiermay block. 11463e12c5d1SDavid du ColombierPlan 9 does not implement the 1147*219b2ee8SDavid du Colombier.CW select 1148bd389b36SDavid du Colombiersystem call but does allow processes to share file descriptors, 1149bd389b36SDavid du Colombiermemory and other resources. 1150*219b2ee8SDavid du Colombier.CW Exportfs 1151bd389b36SDavid du Colombierand the configurable name space 1152*219b2ee8SDavid du Colombierprovide a means of sharing resources between machines. 1153bd389b36SDavid du ColombierIt is a building block for constructing complex name spaces 1154bd389b36SDavid du Colombierserved from many machines. 11553e12c5d1SDavid du Colombier.PP 1156bd389b36SDavid du ColombierThe simplicity of the interfaces encourages naive users to exploit the potential 1157bd389b36SDavid du Colombierof a richly connected environment. 1158bd389b36SDavid du ColombierUsing these tools it is easy to gateway between networks. 1159*219b2ee8SDavid du ColombierFor example a terminal with only a Datakit connection can import from the server 1160*219b2ee8SDavid du Colombier.CW helix : 11613e12c5d1SDavid du Colombier.P1 11623e12c5d1SDavid du Colombierimport -a helix /net 11633e12c5d1SDavid du Colombiertelnet ai.mit.edu 11643e12c5d1SDavid du Colombier.P2 11653e12c5d1SDavid du ColombierThe 1166*219b2ee8SDavid du Colombier.CW import 1167*219b2ee8SDavid du Colombiercommand makes a Datakit connection to the machine 1168*219b2ee8SDavid du Colombier.CW helix 1169*219b2ee8SDavid du Colombierwhere 1170bd389b36SDavid du Colombierit starts an instance 1171*219b2ee8SDavid du Colombier.CW exportfs 1172bd389b36SDavid du Colombierto serve 1173bd389b36SDavid du Colombier.CW /net . 1174bd389b36SDavid du ColombierThe 1175*219b2ee8SDavid du Colombier.CW import 1176bd389b36SDavid du Colombiercommand mounts the remote 1177bd389b36SDavid du Colombier.CW /net 1178bd389b36SDavid du Colombierdirectory after (the 1179*219b2ee8SDavid du Colombier.CW -a 1180bd389b36SDavid du Colombieroption to 1181*219b2ee8SDavid du Colombier.CW import ) 1182bd389b36SDavid du Colombierthe existing contents 1183bd389b36SDavid du Colombierof the local 1184bd389b36SDavid du Colombier.CW /net 1185bd389b36SDavid du Colombierdirectory. 1186bd389b36SDavid du ColombierThe directory contains the union of the local and remote contents of 1187bd389b36SDavid du Colombier.CW /net . 1188bd389b36SDavid du ColombierLocal entries supersede remote ones of the same name so 1189bd389b36SDavid du Colombiernetworks on the local machine are chosen in preference 11903e12c5d1SDavid du Colombierto those supplied remotely. 1191bd389b36SDavid du ColombierHowever, unique entries in the remote directory are now visible in the local 1192bd389b36SDavid du Colombier.CW /net 1193bd389b36SDavid du Colombierdirectory. 1194*219b2ee8SDavid du ColombierAll the networks connected to 1195*219b2ee8SDavid du Colombier.CW helix , 1196*219b2ee8SDavid du Colombiernot just Datakit, 1197*219b2ee8SDavid du Colombierare now available in the terminal. The effect on the name space is shown by the following 1198bd389b36SDavid du Colombierexample: 1199bd389b36SDavid du Colombier.P1 1200bd389b36SDavid du Colombierphilw-gnot% ls /net 1201bd389b36SDavid du Colombier/net/cs 1202bd389b36SDavid du Colombier/net/dk 1203bd389b36SDavid du Colombierphilw-gnot% import -a musca /net 1204bd389b36SDavid du Colombierphilw-gnot% ls /net 1205bd389b36SDavid du Colombier/net/cs 1206bd389b36SDavid du Colombier/net/cs 1207bd389b36SDavid du Colombier/net/dk 1208bd389b36SDavid du Colombier/net/dk 1209bd389b36SDavid du Colombier/net/dns 1210bd389b36SDavid du Colombier/net/ether 1211bd389b36SDavid du Colombier/net/il 1212bd389b36SDavid du Colombier/net/tcp 1213bd389b36SDavid du Colombier/net/udp 1214bd389b36SDavid du Colombier.P2 1215bd389b36SDavid du Colombier.NH 2 1216bd389b36SDavid du ColombierFtpfs 1217bd389b36SDavid du Colombier.PP 1218*219b2ee8SDavid du ColombierWe decided to make our interface to FTP 1219*219b2ee8SDavid du Colombiera file system rather than the traditional command. 1220bd389b36SDavid du ColombierOur command, 1221bd389b36SDavid du Colombier.I ftpfs, 1222*219b2ee8SDavid du Colombierdials the FTP port of a remote system, prompts for login and password, sets image mode, 1223bd389b36SDavid du Colombierand mounts the remote file system onto 1224bd389b36SDavid du Colombier.CW /n/ftp . 1225bd389b36SDavid du ColombierFiles and directories are cached to reduce traffic. 1226bd389b36SDavid du ColombierThe cache is updated whenever a file is created. 1227bd389b36SDavid du ColombierFtpfs works with TOPS-20, VMS, and various Unix flavors 1228bd389b36SDavid du Colombieras the remote system. 1229bd389b36SDavid du Colombier.NH 1230bd389b36SDavid du ColombierCyclone Fiber Links 1231bd389b36SDavid du Colombier.PP 1232bd389b36SDavid du ColombierThe file servers and CPU servers are connected by 1233bd389b36SDavid du Colombierhigh-bandwidth 1234bd389b36SDavid du Colombierpoint-to-point links. 1235bd389b36SDavid du ColombierA link consists of two VME cards connected by a pair of optical 1236bd389b36SDavid du Colombierfibers. 1237*219b2ee8SDavid du ColombierThe VME cards use 33MHz Intel 960 processors and AMD's TAXI 1238bd389b36SDavid du Colombierfiber transmitter/receivers to drive the lines at 125 Mbit/sec. 1239bd389b36SDavid du ColombierSoftware in the VME card reduces latency by copying messages from system memory 1240bd389b36SDavid du Colombierto fiber without intermediate buffering. 12413e12c5d1SDavid du Colombier.NH 12423e12c5d1SDavid du ColombierPerformance 12433e12c5d1SDavid du Colombier.PP 1244*219b2ee8SDavid du ColombierWe measured both latency and throughput 12453e12c5d1SDavid du Colombierof reading and writing bytes between two processes 12463e12c5d1SDavid du Colombierfor a number of different paths. 1247*219b2ee8SDavid du ColombierMeasurements were made on two- and four-CPU SGI Power Series processors. 1248*219b2ee8SDavid du ColombierThe CPUs are 25 MHz MIPS 3000s. 12493e12c5d1SDavid du ColombierThe latency is measured as the round trip time 12503e12c5d1SDavid du Colombierfor a byte sent from one process to another and 12513e12c5d1SDavid du Colombierback again. 12523e12c5d1SDavid du ColombierThroughput is measured using 16k writes from 12533e12c5d1SDavid du Colombierone process to another. 12543e12c5d1SDavid du Colombier.DS C 12553e12c5d1SDavid du Colombier.TS 12563e12c5d1SDavid du Colombierbox, tab(:); 12573e12c5d1SDavid du Colombierc s s 12583e12c5d1SDavid du Colombierc | c | c 12593e12c5d1SDavid du Colombierl | n | n. 12603e12c5d1SDavid du ColombierTable 1 - Performance 12613e12c5d1SDavid du Colombier_ 12623e12c5d1SDavid du Colombiertest:throughput:latency 12633e12c5d1SDavid du Colombier:MBytes/sec:millisec 12643e12c5d1SDavid du Colombier_ 12653e12c5d1SDavid du Colombierpipes:8.15:.255 12663e12c5d1SDavid du Colombier_ 12673e12c5d1SDavid du ColombierIL/ether:1.02:1.42 12683e12c5d1SDavid du Colombier_ 1269*219b2ee8SDavid du ColombierURP/Datakit:0.22:1.75 12703e12c5d1SDavid du Colombier_ 12713e12c5d1SDavid du ColombierCyclone:3.2:0.375 12723e12c5d1SDavid du Colombier.TE 12733e12c5d1SDavid du Colombier.DE 12743e12c5d1SDavid du Colombier.NH 12753e12c5d1SDavid du ColombierConclusion 12763e12c5d1SDavid du Colombier.PP 12773e12c5d1SDavid du ColombierThe representation of all resources as file systems 12783e12c5d1SDavid du Colombiercoupled with an ASCII interface has proved more powerful 12793e12c5d1SDavid du Colombierthan we had originally imagined. 12803e12c5d1SDavid du ColombierResources can be used by any computer in our networks 12813e12c5d1SDavid du Colombierindependent of byte ordering or CPU type. 12823e12c5d1SDavid du ColombierThe connection server provides an elegant means 12833e12c5d1SDavid du Colombierof decoupling tools from the networks they use. 12843e12c5d1SDavid du ColombierUsers successfully use Plan 9 without knowing the 12853e12c5d1SDavid du Colombiertopology of the system or the networks they use. 1286*219b2ee8SDavid du ColombierMore information about 9P can be found in the Section 5 of the Plan 9 Programmer's 1287*219b2ee8SDavid du ColombierManual, Volume I. 12883e12c5d1SDavid du Colombier.NH 12893e12c5d1SDavid du ColombierReferences 12903e12c5d1SDavid du Colombier.LP 12913e12c5d1SDavid du Colombier[Pike90] R. Pike, D. Presotto, K. Thompson, H. Trickey, 12923e12c5d1SDavid du Colombier``Plan 9 from Bell Labs'', 12933e12c5d1SDavid du Colombier.I 12943e12c5d1SDavid du ColombierUKUUG Proc. of the Summer 1990 Conf. , 12953e12c5d1SDavid du ColombierLondon, England, 1296*219b2ee8SDavid du Colombier1990. 12973e12c5d1SDavid du Colombier.LP 12983e12c5d1SDavid du Colombier[Needham] R. Needham, ``Names'', in 12993e12c5d1SDavid du Colombier.I 13003e12c5d1SDavid du ColombierDistributed systems, 13013e12c5d1SDavid du Colombier.R 13023e12c5d1SDavid du ColombierS. Mullender, ed., 1303*219b2ee8SDavid du ColombierAddison Wesley, 1989. 13043e12c5d1SDavid du Colombier.LP 13053e12c5d1SDavid du Colombier[Presotto] D. Presotto, ``Multiprocessor Streams for Plan 9'', 13063e12c5d1SDavid du Colombier.I 13073e12c5d1SDavid du ColombierUKUUG Proc. of the Summer 1990 Conf. , 13083e12c5d1SDavid du Colombier.R 1309*219b2ee8SDavid du ColombierLondon, England, 1990. 13103e12c5d1SDavid du Colombier.LP 13113e12c5d1SDavid du Colombier[Met80] R. Metcalfe, D. Boggs, C. Crane, E. Taf and J. Hupp, ``The 13123e12c5d1SDavid du ColombierEthernet Local Network: Three reports'', 13133e12c5d1SDavid du Colombier.I 13143e12c5d1SDavid du ColombierCSL-80-2, 13153e12c5d1SDavid du Colombier.R 1316bd389b36SDavid du ColombierXEROX Palo Alto Research Center, February 1980. 13173e12c5d1SDavid du Colombier.LP 13183e12c5d1SDavid du Colombier[Fra80] A. G. Fraser, ``Datakit - A Modular Network for Synchronous 13193e12c5d1SDavid du Colombierand Asynchronous Traffic'', 13203e12c5d1SDavid du Colombier.I 1321*219b2ee8SDavid du ColombierProc. Int'l Conf. on Communication, 1322*219b2ee8SDavid du Colombier.R 1323*219b2ee8SDavid du ColombierBoston, June 1980. 13243e12c5d1SDavid du Colombier.LP 13253e12c5d1SDavid du Colombier[Pet89a] L. Peterson, ``RPC in the X-Kernel: Evaluating new Design Techniques'', 13263e12c5d1SDavid du Colombier.I 1327*219b2ee8SDavid du ColombierProc. Twelfth Symp. on Op. Sys. Princ., 13283e12c5d1SDavid du Colombier.R 1329*219b2ee8SDavid du ColombierLitchfield Park, AZ, December 1990. 13303e12c5d1SDavid du Colombier.LP 13313e12c5d1SDavid du Colombier[Rit84a] D. M. Ritchie, ``A Stream Input-Output System'', 13323e12c5d1SDavid du Colombier.I 13333e12c5d1SDavid du ColombierAT&T Bell Laboratories Technical Journal, 68(8), 13343e12c5d1SDavid du Colombier.R 13353e12c5d1SDavid du ColombierOctober 1984. 1336