Distributed Program Generation(rpcgen Concept) Chuan-Ming liu CSIE NTUT Spring 04, TAIWAN
1 Distributed Program Generation (rpcgen Concept) Chuan-Ming Liu CSIE, NTUT Spring ’04, TAIWAN
Introduction )Focuses on the structure of programs that use RPC, and shows how program can be divided along procedure boundaries INtroduces the stub procedure concept and a program generator tool that automates much of the code generation associated with ONC RPC DIt also discusses a library of procedures that makes it easy to build servers that offer remote procedures and clients that call them
2 Introduction Focuses on the structure of programs that use RPC, and shows how program can be divided along procedure boundaries Introduces the stub procedure concept and a program generator tool that automates much of the code generation associated with ONC RPC It also discusses a library of procedures that makes it easy to build servers that offer remote procedures and clients that call them
Using rPcs D The RPC model is general )A programmer can choose to use the remote procedure paradigm in any of the tollowing ways DAS a program specification techniques only D For both program specifications and as an abstraction during program design
3 Using RPCs The RPC model is general A programmer can choose to use the remote procedure paradigm in any of the following ways: As a program specification techniques only For both program specifications and as an abstraction during program design
Using rPcs(cont) O For the conceptual design and explicitly in the implementation D For design and implementation, constructing all software from scratch D For design and implementation, using standard libraries D For an automated implementation
4 Using RPCs (cont.) For the conceptual design and explicitly in the implementation For design and implementation, constructing all software from scratch For design and implementation, using standard libraries For an automated implementation
Programming mechanisms to Support RPC IMplementations of ONC RPC provide significant help for those who wish to avoid unnecessary programming ASsistance comes in four forms D XDR library routines that convert individual data items from internal form to the Xdr standard external representation
5 Programming Mechanisms to Support RPC Implementations of ONC RPC provide significant help for those who wish to avoid unnecessary programming Assistance comes in four forms: XDR library routines that convert individual data items from internal form to the XDR standard external representation
Programming Mechanisms to Support rPC(cont) D XDR library routines that format the complex data aggregates(e.g, arrays and structures) used to define rPc messages ORPC run-time library routines that allow a program to call a remote procedure, register a service with the port mapper or dispatch an incoming call to the correct remote procedure inside a remote program a program generator tool that produces many of the c source files needed to build a distributed program that uses rPc
6 Programming Mechanisms to Support RPC (cont.) XDR library routines that format the complex data aggregates (e.g., arrays and structures) used to define RPC messages RPC run-time library routines that allow a program to call a remote procedure, register a service with the port mapper, or dispatch an incoming call to the correct remote procedure inside a remote program A program generator tool that produces many of the C source files needed to build a distributed program that uses RPC
Programming Mechanisms to Support rPC(cont) )The RPC run-time library has procedures that supply most of the functionality needed for rpc ) For example, procedure callrpc sends an RPC message to a server Dcallrpc(host, prog, prover procnum, inproc, in, outproc, out
7 Programming Mechanisms to Support RPC (cont.) The RPC run-time library has procedures that supply most of the functionality needed for RPC For example, procedure callrpc sends an RPC message to a server callrpc(host, prog, progver, procnum, inproc, in , outproc, out);
Programming Mechanisms to Support rPC(cont) Da client calls function cInt create to create an integer identifier(called a handle that can be used to send rPC message Handle=cInt create(host, prog, vers, proto) ) Several RPC library pi rocedures take a handle as one of their argument
8 Programming Mechanisms to Support RPC (cont.) A client calls function clnt_create to create an integer identifier (called a handle) that can be used to send RPC message: handle = clnt_create(host, prog, vers, proto) Several RPC library procedures take a handle as one of their argument
Programming Mechanisms to Support rPC(cont) D The library library also contains routines that create store, and manipulate authentication information PFor example, procedure authunix creates an authentication handle for a given use on a given host computer Dauthunix create(host, uid gid, len, aup gids D Most programmers rely on the program generator tool to generate a code that contains calls to the library procedures
9 Programming Mechanisms to Support RPC (cont.) The library library also contains routines that create, store, and manipulate authentication information For example, procedure authunix creates an authentication handle for a given use on a given host computer authunix_create(host, uid, gid, len, aup_gids) Most programmers rely on the program generator tool to generate a code that contains calls to the library procedures
Dividing a program into local and remote procedures DFig. 22. 1 illustrates an example procedure call that shows the procedural interface used by a calling procedure and a called procedure D The dashed lines denote a match(the total number and types )between arguments in the procedure call and formal parameters in the called procedure
10 Dividing a Program into Local and Remote Procedures Fig. 22.1 illustrates an example procedure call that shows the procedural interface used by a calling procedure and a called procedure The dashed lines denote a match (the total number and types) between arguments in the procedure call and formal parameters in the called procedure