stéphane frenot - département télécommunication - sid - stephane.frenot@insa- lyon.fr ii - rpc...
TRANSCRIPT
Stéphane Frenot - Département Télécommunication - SID - [email protected]
II - RPC 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 - [email protected]
II - RPC 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 - [email protected]
II - RPC 4
Démarrage
Programmeclient
SE Client
PortMapper
Programme Serveur
1
2
SE Serveur
port c
port b
port a3
Stéphane Frenot - Département Télécommunication - SID - [email protected]
II - RPC 5
Utilisation
Programmeclient
SE Client SE ServeurDémon de service
à l’écoute
RéseauClient en attente
Invocation du service
Lancement de la procédure de service
Exécution de la procédure
Réponse
Requête complète,Assemblage de la réponse
Invocation RPCRequête
Renvoie réponse
Stéphane Frenot - Département Télécommunication - SID - [email protected]
II - RPC 6
RPC et OSI
Réseau
Interface Physique
1,2 Liaison de données / Physique
3 Réseau
4 Transport
5 Session
6 Présentation
7 ApplicationApplication Utilisateur
XDR
RPC
TCP UDP
IP
Stéphane Frenot - Département Télécommunication - SID - [email protected]
II - RPC 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 - [email protected]
II - RPC 8
Client / Serveur et appel de procédure
Program m e principal
Procédure addition
Procédure m ultip lication
Stéphane Frenot - Département Télécommunication - SID - [email protected]
II - RPC 9
Program m e principal
P rocédure addition
Procédure m ultip lication
Stéphane Frenot - Département Télécommunication - SID - [email protected]
II - RPC 10
ClientInterface procedure addition (x, y, total) procedure multiplication(x, y, total)
Serveur
Stéphane Frenot - Département Télécommunication - SID - [email protected]
II - RPC 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 - [email protected]
II - RPC 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 - [email protected]
II - RPC 13
Flux client / serveur
ProcessusEmetteur
Flot XDR d'encodage
Flot XDRde décodage
ProcessusRécepteur
Encodage(sérialisation)
Décodage(desérialisation)
Transfert
Stéphane Frenot - Département Télécommunication - SID - [email protected]
II - RPC 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 - [email protected]
II - RPC 15
Services de la couche haute
• NFS
• rwall
• ruserd
Stéphane Frenot - Département Télécommunication - SID - [email protected]
II - RPC 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 - [email protected]
II - RPC 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 - [email protected]
II - RPC 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 - [email protected]
II - RPC 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 - [email protected]
II - RPC 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 - [email protected]
II - RPC 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);
}
}