1 / 21

RPC

RPC. RPC. Remote Procedure Call : Possibilité d'invocation de procédures situées en dehors de l'espace d'adressage de l'application courante Système RPC Collection de logiciels nécessaire pour supporter la programmation RPC ainsi que le support à l’exécution (run-time services). RPC qui ?.

lysa
Download Presentation

RPC

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. RPC Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

  2. RPC • Remote Procedure Call : • Possibilité d'invocation de procédures situées en dehors de l'espace d'adressage de l'application courante • Système RPC • Collection de logiciels nécessaire pour supporter la programmation RPC ainsi que le support à l’exécution (run-time services) Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

  3. RPC qui ? • Sun • Microsystems'Open Network Computing group (ONC) aka ONC rpc aka Sun RPC 4.0 • Gratuit disponible • OSF (Open Software Fondation) • DCE : Distributed Computed Environnement • Standardisation sur grand systèmes Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

  4. Démarrage SE Client SE Serveur 2 PortMapper port c 1 port b 3 Programme Serveur port a Programme client Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

  5. Utilisation SE Client SE Serveur Réseau Démon de service à l’écoute Programme client Invocation RPC Requête Invocation du service Lancement de la procédure de service Client en attente Exécution de la procédure Réponse Renvoie réponse Requête complète, Assemblage de la réponse Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

  6. RPC et OSI Application Utilisateur 7 Application XDR 6 Présentation 5 Session RPC 4 Transport TCP UDP 3 Réseau IP 1,2 Liaison de données / Physique Interface Physique Réseau Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

  7. Identification des procédures • Regroupement de différentes procédures dans un "programme RPC" • Exemple NFS : ensemble de procédures permettant de manipuler un programme à distance • Identification d'un programme par un entier • Identification des procédures par un autre entier • Exemple NFS : 100003 • Lecture 6 • Ecriture 8 • Chaque programme possède également un numéro de version Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

  8. Client / Serveur et appel de procédure Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

  9. Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

  10. Client Interface procedure addition (x, y, total) procedure multiplication(x, y, total) Serveur Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

  11. Xdr • Problème de la standardisation du flux • Non unicité de la représentation interne des objets • Types de base / structures complexes… • Taille des objets • (2, 4 octets) • Ordre des octets • LittleEndian / BidEndian • Représentation interne • Complément a2, Ca1… • Problèmes d'alignement • Bits de bourrage Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

  12. Exemple expediteur.c #include <unistd.h> main(){ float x=12.45; int n= -1234; write(STDOUT_FILENO,&n,sizeof(int)); write(STDOUT_FILENO,&x,sizeof(float)); } recepteur.c #include <unistd.c> main(){ read(STDIN_FILENO,&n,sizeof(int)); read(STDIN_FILENO,&n,sizeof(float)); printf("Entier recu : %d\n",n); printf("Flottant recu : %f\n",x); } Appel expediteur | remsh vax recepteur Entier recu : 788267007 Flottant recu : 0.000000 Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

  13. Flux client / serveur Processus Emetteur Processus Récepteur Encodage (sérialisation) Décodage (desérialisation) Flot XDR d'encodage Flot XDR de décodage Transfert Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

  14. Services du middleware • portmapper : service de nommage • /etc/rpc : fichier de description des services • rpcinfo • rpcinfo -p => liste les services • rpcinfo -u tc-frenot-1 nfs ==> interroge un service Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

  15. Services de la couche haute • NFS • rwall • ruserd Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

  16. Exemple #include <rpc/types.h> #include <rpc/xdr.h> #define ARITH_PROG 0x33333333 #define ARITH_VERS1 1 #define ADD_PROC 1 #define MULT_PROC 2 #define SQRT_PROC 3 struct couple {float e1, e2;}; int xdr_couple(); Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

  17. Exemple Flux #include "exemple.h" int xdr_couple(XDR * xdrp, struct couple * p) { return (xdr_float(xdrp, &p->e1)&&xdr_float(xdrp, &p->e2)); } Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

  18. Exemple serveur #include <stdio.h> #include "exemple.h" char *add(); char * mult(); char * rac(); main(){ int rep; rep=registerrpc(ARITH_PROG, ARITH_VERS1, ADD_PROC, add, xdr_couple, xdr_float); if (rep==-1){ fprintf(stderr, "errreur registerrpc (add)\n"); exit(2); } Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

  19. Exemple serveur rep=registerrpc(ARITH_PROG, ARITH_VERS1, MULT_PROC, mult, xdr_couple, xdr_float); if (rep==-1){ fprintf(stderr, "errreur registerrpc (mult)\n"); exit(2); } rep=registerrpc(ARITH_PROG, ARITH_VERS1, SQRT_PROC, rac, xdr_couple, xdr_float); if (rep==-1){ fprintf(stderr, "errreur registerrpc (rac)\n"); exit(2); } svc_run(); fprintf(stderr, "erreur sur svc_run\n"); exit(3); } Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

  20. Fonctions #include "exemple.h" char * add (struct couple *p){ static float res; res=p->e1+p->e2; return ((char *)&res); } Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

  21. Client #include <stdio.h> #include "exemple.h" main (int n, char * v []){ float x; struct couple don, res; int op, m; don.e1=13.4; don.e2=17.1; m=callrpc(v[1], ARITH_PROG, ARITH_VERS1, ADD_PROC, xdr_couple, &don, xdr_float, &x); if (m==0){ printf("%f + %f = %f\n", don.e1, don.e2, x); }else{ fprintf(stderr, "erreur : %d\n", m); } } Stéphane Frenot - Département Télécommunication - SID - stephane.frenot@insa-lyon.fr

More Related