From 7a938066a0284d1dc3252ebffb76e5189a7ab387 Mon Sep 17 00:00:00 2001 From: Matteo Cypriani Date: Tue, 17 Jun 2008 13:23:03 +0000 Subject: [PATCH] =?UTF-8?q?client=20:=20nombre=20de=20paquets=20=C3=A9mis?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit code/loc-bts/client : * Affinement de la gestion du nombre de paquets envoyés et du délai entre envois de paquets, dans le cas de la demande de localisation et dans le cas de la requête de calibration. * Makefile : Ajout d'une cible de compilation statique, afin d'obtenir un binaire autonome à copier sur les clients. code/librtaputil/Makefile : * Ajout d'un lien symbolique vers la version numérotée de la bibliothèque, dans la cible "install-dynamic". code/GuiNuMo-server/test.bash : * Suppression de ce fichier obsolète. git-svn-id: https://pif.pu-pm.univ-fcomte.fr/svn/loc@44 785a6c6c-259e-4ff1-8b91-dc31627914f0 --- GuiNuMo-server/test.bash | 3 --- librtaputil/Makefile | 5 +++- loc-bts/client/Makefile | 15 ++++++++--- loc-bts/client/locclient.c | 53 +++++++++++++++++++++----------------- 4 files changed, 46 insertions(+), 30 deletions(-) delete mode 100644 GuiNuMo-server/test.bash diff --git a/GuiNuMo-server/test.bash b/GuiNuMo-server/test.bash deleted file mode 100644 index b86003c..0000000 --- a/GuiNuMo-server/test.bash +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash - -./test 1060-scan.csv 1080-scan.csv 1100-scan.csv 1070-scan.csv 1090-scan.csv couloir-scan.csv diff --git a/librtaputil/Makefile b/librtaputil/Makefile index 284199e..07616c9 100644 --- a/librtaputil/Makefile +++ b/librtaputil/Makefile @@ -14,6 +14,7 @@ RANLIB = ranlib # Commandes d'installation et de désinstallation RM=rm -fv CP=cp -v +SYMLINK=ln -svf # Variables générales LIB_CIBLE=librtaputil @@ -36,6 +37,7 @@ XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) PICFLAG=-fPIC LIBS=-liw #STRIPFLAGS= -Wl,-s +#LDFLAGS= ## Cibles de compilation standard ## @@ -72,6 +74,7 @@ install-dynamic : install-header $(DYNAMIC) @$(CP) $(DYNAMIC) $(INSTALL_LIB) &&\ chmod 644 $(INSTALL_LIB)/$(DYNAMIC) &&\ chown root:root $(INSTALL_LIB)/$(DYNAMIC) &&\ + cd $(INSTALL_LIB) && $(SYMLINK) $(DYNAMIC) $(LIB_CIBLE).so &&\ echo -e "\n!!! Installation de la bibliothèque dynamique effectuée avec succès.\n!!! Ajoutez une ligne « $(INSTALL_LIB) » dans le fichier /etc/ld.so.conf\n ou dans un nouveau fichier de /etc/ld.so.conf.d/, si ce n'est déjà fait.\n!!! Exécutez ldconfig ensuite.\n" install-static : install-header $(STATIC) @@ -90,7 +93,7 @@ install-header : $(HEADER) uninstall : uninstall-dynamic uninstall-static uninstall-dynamic : uninstall-header - @$(RM) $(INSTALL_LIB)/$(DYNAMIC) + @$(RM) $(INSTALL_LIB)/$(DYNAMIC) $(INSTALL_LIB)/$(LIB_CIBLE).so ldconfig uninstall-static : uninstall-header diff --git a/loc-bts/client/Makefile b/loc-bts/client/Makefile index 7775883..8a1ab35 100644 --- a/loc-bts/client/Makefile +++ b/loc-bts/client/Makefile @@ -21,7 +21,8 @@ CFLAGS=-O2 -W -Wall -Wstrict-prototypes -O -I. DEPFLAGS=-MMD XCFLAGS=$(CFLAGS) $(DEPFLAGS) $(WARN) $(HEADERS) PICFLAG=-fPIC -LIBS=../../librtaputil/librtaputil.so.1.0 +LIBS=-lrtaputil +STATIC_LIBS=-liw -lm ## Cibles de compilation standard ## @@ -29,6 +30,7 @@ LIBS=../../librtaputil/librtaputil.so.1.0 .PHONY : all install uninstall clean purge help all : $(TARGET) +static : $(TARGET).static % : %.o $(CC) $(LDFLAGS) $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS) @@ -38,6 +40,9 @@ all : $(TARGET) # Compilation du programme $(TARGET) : $(TARGET).o $(HEADER) +$(TARGET).static : $(TARGET).c $(HEADER) + $(CC) $(LDFLAGS) -static $(STRIPFLAGS) $(XCFLAGS) -o $@ $^ $(LIBS) $(STATIC_LIBS) + ## Installation / désinstallation ## @@ -45,8 +50,12 @@ install : $(TARGET) @$(CP) $(TARGET) $(INSTALL_DIR) @cd $(INSTALL_DIR) ; chown root:root $(TARGET) ; chmod 755 $(TARGET) +install-static : $(TARGET).static + @$(CP) $(TARGET).static $(INSTALL_DIR) + @cd $(INSTALL_DIR) ; chown root:root $(TARGET).static ; chmod 755 $(TARGET).static + uninstall : - @$(RM) $(INSTALL_DIR)/$(TARGET) + @$(RM) $(INSTALL_DIR)/{$(TARGET),$(TARGET).static} ## Nettoyage ## @@ -55,7 +64,7 @@ clean : @$(RM) -fv *~ *.o *.d purge : clean - @$(RM) -fv $(TARGET) + @$(RM) -fv $(TARGET) $(TARGET).static ## Aide ## diff --git a/loc-bts/client/locclient.c b/loc-bts/client/locclient.c index 1a3f203..6991484 100644 --- a/loc-bts/client/locclient.c +++ b/loc-bts/client/locclient.c @@ -18,6 +18,11 @@ /* Nombre de paquets envoyés */ #define NBPKT_CALIB 20 // Rafale de 20 paquets lors de la calibration +#define NBPKT_NORMAL 10 // Nombre de paquets envoyés dans le cas d'une demande de localisation + +/* Délai entre chaque paquet envoyé */ +#define DELAY_CALIB 50000 // Délai entre chaque émission de paquet lors de la calibration (en ms) +#define DELAY_NORMAL 25000 // Délai entre chaque émission de paquet dans le cas d'une demande de localisation (en ms) @@ -45,6 +50,9 @@ int main(int argc, char *argv[]) ssize_t nsent ; // Retour de sendto char iface[IFNAMSIZ + 1] = "" ; // Interface réseau depuis laquelle on envoit le paquet + int i ; // Compteur + int delay = (argc == ARGC_NORMAL ? DELAY_NORMAL : DELAY_CALIB) ; // Temps d'attente entre chaque émission de paquet + /* Test du nombre d'arguments */ if (argc == ARGC_NORMAL + 1 || argc == ARGC_CALIB + 1) // Si on a spécifié un nom d'interface @@ -84,7 +92,7 @@ int main(int argc, char *argv[]) /* Création du paquet à envoyer */ gettimeofday(&request_time, NULL) ; - if(argc == ARGC_NORMAL) // Paquet normal + if (argc == ARGC_NORMAL) // Paquet normal { printf("Envoi normal effectué à : %llu\n", timeval_to_ms(request_time)) ; buf_size = sizeof(char) + sizeof(struct timeval) ; @@ -93,7 +101,7 @@ int main(int argc, char *argv[]) memcpy(&buf[1], &request_time, sizeof(request_time)) ; } - else if(argc == ARGC_CALIB) // Paquet calibration + else // Paquet calibration { printf("Envoi Calibration effectué à : %llu\n", timeval_to_ms(request_time)) ; @@ -120,35 +128,34 @@ int main(int argc, char *argv[]) /* Envoi des infos au serveur d'aggrégation */ - nsent = sendto(sockfd, (void *) buf, buf_size, 0, (struct sockaddr *) &server, (socklen_t) sizeof(server)) ; -#ifdef DEBUG - printf("Paquets envoyés : .") ; -#endif + nsent = sendto(sockfd, (void *) buf, buf_size, 0, (struct sockaddr *) &server, (socklen_t) sizeof(server)) ; // Envoi d'un paquet. if (nsent != (ssize_t) buf_size) { - perror("Erreur lors de l'envoi des infos au serveur ") ; + perror("Erreur lors de l'envoi des informations au serveur ") ; return ERR_SENDING_INFO ; } - - if (argc == ARGC_CALIB) // Dans le cas d'un paquet de calibration, on envoit une rafale de NBPKT_CALIB paquets? - { - int i ; - for (i = 0 ; i < NBPKT_CALIB - 1 ; i++) - { - usleep(50000) ; // On attend 50 ms entre chaque paquet. - - nsent = sendto(sockfd, (void *) buf, buf_size, 0, (struct sockaddr *) &server, (socklen_t) sizeof(server)) ; #ifdef DEBUG - putchar('.') ; - fflush(stdout) ; + printf("Paquets envoyés : .") ; + fflush(stdout) ; #endif - if (nsent != (ssize_t) buf_size) - { - perror("Erreur lors de l'envoi des infos au serveur ") ; - return ERR_SENDING_INFO ; - } + + for (i = 0 ; i < (argc == ARGC_NORMAL ? NBPKT_NORMAL : NBPKT_CALIB) - 1 ; i++) // Si tels sont les paramètres, on envoit éventuellement la suite de la rafale de paquets : + { + usleep(delay) ; // On attend le temps voulu entre chaque paquet. + + nsent = sendto(sockfd, (void *) buf, buf_size, 0, (struct sockaddr *) &server, (socklen_t) sizeof(server)) ; + if (nsent != (ssize_t) buf_size) + { + perror("Erreur lors de l'envoi des infos au serveur ") ; + return ERR_SENDING_INFO ; } + +#ifdef DEBUG + putchar('.') ; + fflush(stdout) ; +#endif } + #ifdef DEBUG putchar('\n') ; #endif