- - --- - ~- -------- - \Fn\()Hh PH()(.I{ \\1\11\(, - - --- -- - - -
By Carl Malamud
ow•emcetreams
As Part ofAT&T's Unix System V, Streams Delivers aStandardSetofCommunications Interfaces and ProgrammingTools that Gives Network
Programmers aModular Approach to Complex, Layered Protocols
..II1II1 n the Dark Age of data communication , net orks were ju tanother program, adjunct to ageneral-purpose operating sytern, like a word proce sor or a
.... graphic routine. But in today'network-inten ive environment, that' nolonger the ca. twork-based applications are on the way to becoming thenorm, and the network itself ha becomeanother operating sy tern support tool,like file y terns, lock managers, and CPUscheduling mechanism .
With the advent of layered communication protocol, howe er, the ituationha grown decidedly more difficult. Thevery complexity of the protocols d mands a framework that allows them tobe implemented in a modular fashion,thu making it pos ible to build up sophisticated communication services fromimpler building blocks. E sentially, a
framework of this sort need to furnish at of standard interfaces between the
modul 0 that one module need notknow the details of its neighbor. Oncewritten, these module can be used overand over again ift different combinations,giving network programmers a highlyportable, ea ily reusable t of r ources.For instance, it' po ible tE> arrange theprotocol tack so that X.25 (implementedas one or more modules) can be locatedimultaneously under the network layer
of both TCP/IP and OSI.In the Unix world, upport for net
work operations comes through Stream ,which is included as a standard part ofAT&T' Unix System V. Streams itself isnot a net ork component, but a framework that makes it ea . r to implement
communications-based services.Streams i not the only uch mecha
ni m, of course. But it presence in Unixmakes it a factor in many key products:Sun Micro ystem Inc.' and AT&T'Unix, Digital Equipment Corp.' Ultrix,and IBM' AIX, for example. Other vendors, such as ovell, also are adopting
treams for their operating systems.In its broadest n e, Stream is a
tandard set of communication interfaces and programming tool that residein the operating tem kernel. It provides a way of pa ing me sages first between an application program and a network protocol stack and finally to anetwork interface card.
One of the prime advantages to amechanism like Stream is that it ensuresportability by establishing a standard program interface to operating sy tem reSources. ving a Streams-based application to another em can be as implea recompiling it (and for binary compatibility, it' not even necessary to recompile). True, this ideal i not al ay realized, but it is the goal.
The other advantage i interoperability, easily seen in the interaction between an application and the network.Many application directly invo e the services fumi bed at the net ork transportlayer, providing reliable, end-to-end comrnunicatio . Streams upplies a way foran application to bmit I to atransport module. If network designerswrite their modules so that all accept thesame types of g, the applicationprogram' able to choose the appropriatetransport tack for the job. The samemessage (for example, " E CONNECTION") can establi h a connection onTCP/IP, OSI's TP, and Novell's SPXtransport modules.
Coupled with Streams are ts oftandard message definitions. In the ca
of the transport layer, the Transport Provider Interface (TPI), also a part of UnixSy tern V, de the m Ie that atransport module can accept and actupon. Thus, any TPI-compliant transport
DATA COMMUNICATIONS 0 MAY 19900 ..
--- - - - u -- -- - \1'T\\()I<h PH()(,I<\\l\ll\t. - ~- ---- - -
Stream
head, modules, and driver. The head con- for a particular et of modules andlain a set of routine that communicate drivers.between the operating system and the apo Streams' message-handling capabiliplication and the re t of the tream. The ties also provide a more advanced ap-tream head and driver are connected proach to 110 proc . . Aprogram can
automatically hen the device i opened. is ue a PUT function call, which alerts theIn other ords, a tream is opened just as stream head that data from some locationa file would be. When the node represent- in memory i to be sent downstream. Theing the device on the file y tem is head gets the message from user (appliopened, th device driver i connected to cation) memory, which consists of twothe tream head. Module can then be parts, control and data.added to the tream. tandard operating The control part of the message indi-y tern calls can be u ed to open and cates what kind of message is being sent.
clo the tream. The data part i hat the interpreter ofIn addition to standard 1/0 opera- the me sage will u . ormally, the pro
tion such as READ and WRITE, the gram generates protocol messages thattream head supports additional com- are interpreted by module on the
mands. T 0 important ones are PUSH stream, modified, then sent along to theand POP, hich add and remove modules next module or driver.from a tream. When the stream is For example, the top level of theopened for the first time, it actually con- stream might be a transport layer thatsists of a head and driver. The user pro- upplies service primitives to send andgram can then PUSH modules onto the receive data. When the transport layerstack, in between the stream head and receive a message, it ould add thethe driver. Additional modules are transport header, the sequence numberPUSHed between the stream head and of the message, and any flo -control inthe highest-level module. formation for the remote node on the
To add a module onto the tack, the network.programmer issues an IOCTL call, giving The transport module ould thenthe PUSH argument and giving the ad- send the e to the net ork mod ,dress of a module that will be added to hich ould add the De ork-level beadthe stream. POP would be used to delete er containing routing information. Then,a module. PUSH and POP are exam or the message ould be handed off to theargument that the fream head deals device driver, in this case a network inwith directly. But if IOCTL ha an un- terface card. The data link informationknown argument, the tream head will ould be added to the message, and thegenerate a mes- message ould besage and send it nt onto the LAN.do tream. At the remote
When the end, the rever eu send a com- ould occur. Anmand to the Ethernet driver,tream head, it for . , woukl
tat the data and receive the mepackage it as a da am aDdm e. The first package it into amodule down- Streams message,tream from the head examines the mel- hich ouId it to the net ork
sage and decid if it will take action. If it layer. The ork-layer module oulddoesn't recognize the message, it will strip the routing header and hand thepass it to the next module. The ability to me age to the tran port layer. The
unknown paramete m traDsport module ouId determiDe thedo tream instead of generatiDI an er- traDsport layer addr check theror me ge to the calling program queoce of the m , aDd then hand itmU Streams easily extensible. . back up to the tream bead, which ouIdStreams are de6Ded in the deliver· to the user proJraID....
Str interface. Others be defiDed Each Streams componentneeded. The TPI· an example of a of mes:saae queues, ODe for •.::oIDIIDi
upp tal of defiDecl , the other for ou .
module can service such me ages,thereby establi bing a protocol-independent interface to the application.
Stream provides the framewor forinteroperability; standard interfacesmake that frame or 1 reality. e orkprogrammers-the people ho developdataba s and scheduling and conferencing systems-an thu concentrate ontheir work and not worry about the m chanics of the lower layers of thenetwork.
The Streams specification comprise a collection of system call , function calls, kernel resources, and kernelutility routines. The primary facilitie thatit offers are buffer management, flowcontrol, scheduling, multiplexing, a ynchronous operation, and error and tracelogging.
Every individual stream consists ofa tream head and a driver, bet een
hich module can be placed. The driveri the end of the stream (see Figure 1).The tream head i a set of routine thate tablishe the interface to the re t ofthe y tern. WRITE and IOCTL (1/0 control) requ ts are turned into messagesand sent to the tream. Read reques incomparison, take data from the streamand pa it to the user. The modules proce s messages transmitted between atream head and driver.
The be t way to understand Streamsi to tart with the ay 110 proces ing isdone on a local computer. Any device(say, a network interface card) that· accessed by an application has a device driver. Each device driver has a set of c0m
mand that ignal the type of operation tobe performed. Stream comes into thepicture by providing the common interface to the network card or to any otherdevice.
.Traditional device drivers are basedon a character 110 mechanism that letsusers read or write one character t atime. Stream operates in the same manner, but it also allo users to dispatch anentire message to the device driver forprocessing. The message· placed in aqueue until the driver is ready to procesit This m e 110 feature· ODe of thefacets of Streams that makes it particularly ell suited for the ne ork enviroomen!, here a shared medium makes
es more efficient than seodin& .gle cbaracten.
As DOted. a stream consists of a
OOATA :TlONSOMAY 1990
-- - --- ---- ---- \1'''\()I~h PH()(.\{\\1\II\(, - - -- -- - - --
Stream
treams baring the multipl xing moduleor verallo er tream under the control of the multiplexing module.
ultiple lower tream are createdby first opening two parate tream,one con . ling of the stream head and
multiplexing module, and the other, atream head and driver. xt, the 10 ertream i connected to the multip xing
driver u . I-U K command, hich. tructs the 10 er module to send allupstream data to the multiplexing module. An data from the multiplexing mod-
JlONS 0 MAY 1990UlODATACOM
g (see Figure 2). The qu ueslish Bow control to prevent roes gfrom overloading a module or driver.Th y also expedite data rvices.
Of th 0 me g qu u ,on ifor upstream roes g ; the other i fortho e headed down tream. The qu uesare imply area of memory managed by amodule larg enough to hold several me -
ge . When a modul nd am ssagedown tream, it invoke the PUT proc dure of it down tream modul . Thi al10 a modul to pa m sag to thenext module b placing it in a queue forproces ing. The PUT procedure examinthe me sage and decides if it needs immediate servicing. Ifnot, it will PUT th message onto the queue.
The queue itself con i ts of a riesof linked mes es. The head of thequ ue point to the first message, hichin tum contains the addr of the nextm sage. The la t me sage, or tail of thqueue, has a pointer back to th head.
Normally, amessage i PUT in th tailof the queue and the pointer is adju ted topoint to the qu ue head. But certain ciae of m sag (those 'th high-prioritytatu ) are not ubject to flow control and
are added not to the tail but to the head,behind any exi ting high-priorityme sages.
Besides the PUT procedure, aStreams modul also has a service procedure a sociated with it. It is scheduled toexecute whenever there is ork to bedone, and it periodically emptie thequ u of all m ges. At time ,a modulewill be unable to send a message becauthe downstream module is unable to proc it. When this occurs, the stream isblocked. If the do nstream queue iblocked, the local module may not be ableto empty its own queue, bringing thestream to a halt until the downstreamqu ue' unblocked.
In most computing envirOlllDeDts, it. necessary to hare drivers among mUltiple u r, hich can be accomplishedthrough the Streams multiplexer. Atransport-layer protocol uch Tep . u~
port multiple and' a good candidate for multip ed Stream .
Amultiplexed tream' actually t 0
or more streams stac ed atop one another ( F'tgUre 3). The multiplexing moduIe' used to route data to the appropriate tream. Multiplexing can take place ineither direction, ith everal upper
treams
,. ;~ ~. ..', "' .
"'. . • ~ •)~." '~.: . .-, .'" .. : ~ . loy.: "~
; ... # • - ••
- .•. "'. ~.... ". ~.... ~ .
that are recognized by differ nt tran portlayer modules. The Tran port Level Interface (TLI) provide a functional interface to the TPI, WID h is th actual mesag format under tood by the transport
protocol . Thus, the TLI library tran late a function call request for a transport ervice into a TPI me sage to use
the service provided by th underlyingprotocol.
A TPI-compliant transport levelmodule will rvi e any application layerprogram that uses the TLI interface. Intead of programming directly to oven'
SP , for example, the programmerwrites an application that use the TLIlibrary call. t run time, the program canbe run u ing PX,O I, or TCPIIP protocol tack. It's thus po sible to changethe underlying tran port mechani mwithout rewriting program . And inceTLI ha been adopted by so may vendor ,the net ork components of a programhay become very portable.
ill consi ts of t 0 components: aill library and a ill module ( rlgure "). The hbrary is linked into the ap
. . program and becomes a upportmuch in the same y remote
procedure caD (RPC) hbraries are linkedto application. The ill library aceenl in the main body of the pr0gram and performs the required opera
to deli er a message to the stream
The TU module· PUSHed OIl 0 theit· It then p
requleStI from and trof into standard TPI
mes!iiqeS,. The TU library aDo a pr0grammer to develop network-based programs without orrying about the type oftransport tack being used. For example,a programmer can issue a T-CO CTfunction caD to open a connection on anysupported transport tack.
The T-CO ECT can is translatedinto a T-CO -REQ (tran port cODDeCtionr t) bich i passed downto the transport provider, a module thataccepts TPI .the rvices OIl a particular network. TheTU module . until it receiv aT-CO -CO (transport CODDection confirmed) &om the transport provider.At that point, i~ returns the information tothe stream bead, which fills in the addressof the remote connection.
A . variety of iPI me es(and corresponding function calls) havebeen defined for Streams, including errorhandling and expedited data. hich further extend the usefulnes of theStreams programming interface. The hi-. fuoctiooaIity is the as if a~
grammer ere writing directly to thetnDsport layer. The advantage of tbi
....-'. a contributing editor toDATA CO CATIO s. TIn article·an excerpt &om . fortbcominl boo A..•4lpi1v Nt1MJ NIIrItwts (Van traDdReinbold, 1990).
111.".". 10 I"g Arl s.~sniIz tI/AT~T &U~ ftw lIis"." tiM COJIIMftIs.
\ I 1\\ ( 11\" P1\ ( )( 11\ \ '1\ II \ (,
approach is implicity and uniformity: Aprogrammer u one approach to net·work programming, regardles of thtype of net or .
In e, Streams alIo a~grammer to a toolbox of capabiliti :TU tools, for example, make it pos ibleto t up connection easily. The fact thatthe connection i over TCP/IP, OSI,DECnel, or veil SPX i irrelevant tothe application programmer.
TU hield the programmer fromthe intricacies of transport providers. Upper-layer providers, uch as RPC , can beput into thi frame ork with ease.Net . , for example, u Streams andnl to tie i RPC technology into~veil' et are and other net orkarchitectur
AT
Astrocom Corporation
As "23 DSUI U ead to LPDA-2' smooth and traight
The trocom 2300 DSU/CSU Plus, it's attracti ely priced andwith the LPDA-2 option offers backed by~ rt mce.everything you need for complete For the mooth and straight roadNetView'" compatibility. to LPDA-2, call: (612) 227-8651
All the diagnostic optio .The easy DDS access.
The variable speed 2300 DSUIC>U supports speeds of2.4, 4.8, 9.6,19.2 and S6K bps. RS232 and V.3Sinterfaces are co-resident Thiscombination provides the flexibilityto reconfigure your network without
. changing the DSU/CSU.
Top Related