#include "gras.h"
#include "amok/bandwidth.h"
-#include "amok/hostmanagement.h"
+#include "amok/peermanagement.h"
XBT_LOG_NEW_DEFAULT_CATEGORY(Bandwidth,"Messages specific to this example");
gras_socket_t peer;
gras_socket_t mysock;
- xbt_host_t h1,h2;
+ xbt_peer_t h1,h2;
xbt_dynar_t group;
gras_init(&argc, argv);
xbt_dynar_length(group));
xbt_die(msg);
}
- h1 = *(xbt_host_t*) xbt_dynar_get_ptr(group, 0);
- h2 = *(xbt_host_t*)xbt_dynar_get_ptr(group, 1);
+ h1 = *(xbt_peer_t*) xbt_dynar_get_ptr(group, 0);
+ h2 = *(xbt_peer_t*)xbt_dynar_get_ptr(group, 1);
INFO2("Contact %s:%d",h1->name, h1->port);
peer = gras_socket_client(h1->name, h1->port);
#include "gras.h"
#include "amok/bandwidth.h"
-#include "amok/hostmanagement.h"
+#include "amok/peermanagement.h"
XBT_LOG_NEW_DEFAULT_CATEGORY(saturate,"Messages specific to this example");
gras_socket_close(sock);
}
static void kill_buddy_dynar(void *b) {
- xbt_host_t buddy=*(xbt_host_t*)b;
+ xbt_peer_t buddy=*(xbt_peer_t*)b;
kill_buddy(buddy->name,buddy->port);
}
-static void free_host(void *d){
- xbt_host_t h=*(xbt_host_t*)d;
+static void free_peer(void *d){
+ xbt_peer_t h=*(xbt_peer_t*)d;
free(h->name);
free(h);
}
int begin;
/* where are the sensors */
- xbt_dynar_t hosts;
- int nb_hosts;
+ xbt_dynar_t peers;
+ int nb_peers;
/* results */
double *bw;
/* iterators */
int i,j,k,l;
- xbt_host_t h1,h2,h3,h4;
+ xbt_peer_t h1,h2,h3,h4;
/* Init the group */
- hosts=amok_hm_group_new("saturate");
+ peers=amok_hm_group_new("saturate");
/* wait 4 dudes */
gras_msg_handle(60);
gras_msg_handle(60);
gras_msg_handle(60);
gras_msg_handle(60);
- nb_hosts = xbt_dynar_length(hosts);
+ nb_peers = xbt_dynar_length(peers);
INFO0("Let's go for the bw_matrix");
begin=time(NULL);
begin_simulated=gras_os_time();
- bw=amok_bw_matrix(hosts,buf_size,exp_size,msg_size,min_duration);
+ bw=amok_bw_matrix(peers,buf_size,exp_size,msg_size,min_duration);
INFO2("Did all BW tests in %ld sec (%.2f simulated(?) sec)",
time(NULL)-begin,gras_os_time()-begin_simulated);
/* Do the test with saturation */
- bw_sat=xbt_new(double,nb_hosts*nb_hosts);
- xbt_dynar_foreach(hosts,i,h1) {
- xbt_dynar_foreach(hosts,j,h2) {
+ bw_sat=xbt_new(double,nb_peers*nb_peers);
+ xbt_dynar_foreach(peers,i,h1) {
+ xbt_dynar_foreach(peers,j,h2) {
if (i==j) continue;
TRY {
0, /* Be nice, compute msg_size yourself */
0 /* no timeout */);
} CATCH(e) {
- RETHROW0("Cannot ask hosts to saturate the link: %s");
+ RETHROW0("Cannot ask peers to saturate the link: %s");
}
gras_os_sleep(5);
begin=time(NULL);
begin_simulated=gras_os_time();
- xbt_dynar_foreach(hosts,k,h3) {
+ xbt_dynar_foreach(peers,k,h3) {
if (i==k || j==k) continue;
- xbt_dynar_foreach(hosts,l,h4) {
+ xbt_dynar_foreach(peers,l,h4) {
double ratio;
if (i==l || j==l || k==l) continue;
h1->name,h2->name,h3->name,h4->name);
amok_bw_request(h3->name,h3->port, h4->name,h4->port,
buf_size,exp_size,msg_size,min_duration,
- NULL,&(bw_sat[k*nb_hosts + l]));
+ NULL,&(bw_sat[k*nb_peers + l]));
- ratio=bw_sat[k*nb_hosts + l] / bw[k*nb_hosts + l];
+ ratio=bw_sat[k*nb_peers + l] / bw[k*nb_peers + l];
INFO8("SATURATED BW XP(%s %s // %s %s) => %f (%f vs %f)%s",
h1->name,h2->name,h3->name,h4->name,
ratio,
- bw[k*nb_hosts + l] , bw_sat[k*nb_hosts + l],
+ bw[k*nb_peers + l] , bw_sat[k*nb_peers + l],
ratio < 0.7 ? " THERE IS SOME INTERFERENCE !!!": "");
}
}
int i; /* iterator */
char *data; /* data exchanged */
int datasize; /* size of message */
- xbt_host_t h; /* iterator */
+ xbt_peer_t h; /* iterator */
gras_socket_t peer; /* socket to node */
- /* xbt_dynar for hosts */
- xbt_dynar_t hosts = xbt_dynar_new(sizeof(xbt_host_t),&xbt_host_free_voidp);
+ /* xbt_dynar for peers */
+ xbt_dynar_t peers = xbt_dynar_new(sizeof(xbt_peer_t),&xbt_peer_free_voidp);
/* Init the GRAS infrastructure and declare my globals */
gras_init(&argc,argv);
/* Get the node location from argc/argv */
for (i=1; i<argc-1; i++){
- xbt_host_t host = xbt_host_from_string(argv[i]);
- xbt_dynar_push(hosts,&host);
+ xbt_peer_t peer = xbt_peer_from_string(argv[i]);
+ xbt_dynar_push(peers,&peer);
}
datasize=atoi(argv[argc-1]);
gras_os_sleep(1);
/* write 'em */
- xbt_dynar_foreach(hosts,i,h) {
+ xbt_dynar_foreach(peers,i,h) {
peer = gras_socket_client(h->name,h->port);
gras_msg_send(peer,gras_msgtype_by_name("data"),&data);
}
/* Free the allocated resources, and shut GRAS down */
- xbt_dynar_free(&hosts);
+ xbt_dynar_free(&peers);
gras_exit();
return 0;
#include "gras.h"
#include "xbt/matrix.h"
-#include "amok/hostmanagement.h"
+#include "amok/peermanagement.h"
#define PROC_MATRIX_SIZE 3
#define NEIGHBOR_COUNT PROC_MATRIX_SIZE - 1
GRAS_DEFINE_TYPE(s_pmm_assignment,struct s_pmm_assignment {
int linepos;
int rowpos;
- xbt_host_t line[NEIGHBOR_COUNT];
- xbt_host_t row[NEIGHBOR_COUNT];
+ xbt_peer_t line[NEIGHBOR_COUNT];
+ xbt_peer_t row[NEIGHBOR_COUNT];
xbt_matrix_t A GRAS_ANNOTE(subtype,double);
xbt_matrix_t B GRAS_ANNOTE(subtype,double);
});
gras_socket_t from;
- xbt_dynar_t hosts; /* group of slaves */
- xbt_host_t grid[SLAVE_COUNT]; /* The slaves as an array */
+ xbt_dynar_t peers; /* group of slaves */
+ xbt_peer_t grid[SLAVE_COUNT]; /* The slaves as an array */
gras_socket_t socket[SLAVE_COUNT]; /* sockets for brodcast to slaves */
/* Init the GRAS's infrastructure */
/* Create the connexions */
gras_socket_server(atoi(argv[1]));
- hosts=amok_hm_group_new("pmm");
+ peers=amok_hm_group_new("pmm");
INFO0("Wait for peers for 10 sec");
gras_msg_handleall(10); /* friends, we're ready. Come and play */
- INFO1("Got %ld pals",xbt_dynar_length(hosts));
+ INFO1("Got %ld pals",xbt_dynar_length(peers));
for (i=0;
- i<xbt_dynar_length(hosts) && i<SLAVE_COUNT;
+ i<xbt_dynar_length(peers) && i<SLAVE_COUNT;
i++) {
- xbt_dynar_get_cpy(hosts,i,&grid[i]);
+ xbt_dynar_get_cpy(peers,i,&grid[i]);
socket[i]=gras_socket_client(grid[i]->name,grid[i]->port);
INFO2("Connected to %s:%d.",grid[i]->name,grid[i]->port);
}
i,SLAVE_COUNT);
/* Kill surnumerous slaves */
- for (i=SLAVE_COUNT; i<xbt_dynar_length(hosts); ) {
- xbt_host_t h;
+ for (i=SLAVE_COUNT; i<xbt_dynar_length(peers); ) {
+ xbt_peer_t h;
- xbt_dynar_get_cpy(hosts,i,&h);
+ xbt_dynar_get_cpy(peers,i,&h);
amok_hm_kill_hp(h->name,h->port);
free(h);
}
for (i=0 ; i<PROC_MATRIX_SIZE-1 ; i++){
socket_line[i]=gras_socket_client(assignment.line[i]->name,
assignment.line[i]->port);
- xbt_host_free(assignment.line[i]);
+ xbt_peer_free(assignment.line[i]);
}
for (i=0 ; i<PROC_MATRIX_SIZE-1 ; i++){
socket_row[i]=gras_socket_client(assignment.row[i]->name,
assignment.row[i]->port);
- xbt_host_free(assignment.row[i]);
+ xbt_peer_free(assignment.row[i]);
}
for (step=0; step<PROC_MATRIX_SIZE;step++) {
xbt/fifo.h \
xbt/swag.h \
xbt/matrix.h \
- xbt/host.h \
+ xbt/peer.h \
xbt/config.h \
xbt/cunit.h \
xbt/graphxml_parse.h \
gras/messages.h gras/timer.h \
\
amok/base.h \
- amok/hostmanagement.h \
+ amok/peermanagement.h \
amok/bandwidth.h
surf/surfxml.h:
/* $Id$ */
-/* amok host management - servers main loop and remote host stopping */
+/* amok peer management - servers main loop and remote peer stopping */
/* Copyright (c) 2006 Martin Quinson. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#ifndef AMOK_HOST_MANAGEMENT_H
-#define AMOK_HOST_MANAGEMENT_H
+#ifndef AMOK_PEER_MANAGEMENT_H
+#define AMOK_PEER_MANAGEMENT_H
#include <gras.h>
#include <amok/base.h>
/** @} */
-#endif /* AMOK_HOST_MANAGEMENT_H */
+#endif /* AMOK_peer_MANAGEMENT_H */
#include <xbt/swag.h>
#include <xbt/heap.h>
-#include <xbt/host.h>
+#include <xbt/peer.h>
#include <xbt/config.h>
#include <xbt/cunit.h>
double val);
void xbt_cfg_set_string(xbt_cfg_t cfg, const char *name,
const char *val);
-void xbt_cfg_set_host (xbt_cfg_t cfg, const char *name,
- const char *host,int port);
+void xbt_cfg_set_peer (xbt_cfg_t cfg, const char *name,
+ const char *peer,int port);
/*
Remove the provided value from the cell @name in @cfg.
double val);
void xbt_cfg_rm_string(xbt_cfg_t cfg, const char *name,
const char *val);
-void xbt_cfg_rm_host (xbt_cfg_t cfg, const char *name,
- const char *host,int port);
+void xbt_cfg_rm_peer (xbt_cfg_t cfg, const char *name,
+ const char *peer,int port);
/*
Remove the value at position \e pos from the config \e cfg
xbt_cfgelm_int=0, /**< int */
xbt_cfgelm_double, /**< double */
xbt_cfgelm_string, /**< char* */
- xbt_cfgelm_host, /**< both a char* (representing the hostname) and an integer (representing the port) */
+ xbt_cfgelm_peer, /**< both a char* (representing the peername) and an integer (representing the port) */
xbt_cfgelm_any, /* not shown to users to prevent errors */
xbt_cfgelm_type_count
int xbt_cfg_get_int (xbt_cfg_t cfg, const char *name);
double xbt_cfg_get_double(xbt_cfg_t cfg, const char *name);
char* xbt_cfg_get_string(xbt_cfg_t cfg, const char *name);
- void xbt_cfg_get_host (xbt_cfg_t cfg, const char *name, char **host, int *port);
+ void xbt_cfg_get_peer (xbt_cfg_t cfg, const char *name, char **peer, int *port);
xbt_dynar_t xbt_cfg_get_dynar (xbt_cfg_t cfg, const char *name);
int xbt_cfg_get_int_at (xbt_cfg_t cfg, const char *name, int pos);
double xbt_cfg_get_double_at(xbt_cfg_t cfg, const char *name, int pos);
char* xbt_cfg_get_string_at(xbt_cfg_t cfg, const char *name, int pos);
- void xbt_cfg_get_host_at (xbt_cfg_t cfg, const char *name, int pos, char **host, int *port);
+ void xbt_cfg_get_peer_at (xbt_cfg_t cfg, const char *name, int pos, char **peer, int *port);
/** @} */
+++ /dev/null
-/* $Id$ */
-
-/* host.h - host management functions */
-
-/* Copyright (c) 2006 Arnaud Legrand. */
-/* All rights reserved. */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#ifndef XBT_HOST_H
-#define XBT_HOST_H
-
-#include "xbt/misc.h"
-
-SG_BEGIN_DECL()
-
-typedef struct {
- char *name;
- int port;
-} s_xbt_host_t, *xbt_host_t;
-
-xbt_host_t xbt_host_new(const char *name, int port);
-xbt_host_t xbt_host_from_string(const char *hostport);
-xbt_host_t xbt_host_copy(xbt_host_t h);
-void xbt_host_free(xbt_host_t host);
-void xbt_host_free_voidp(void *d);
-
-SG_END_DECL()
-
-
-#endif /* XBT_MISC_H */
--- /dev/null
+/* $Id$ */
+
+/* peer.h - peer (remote processes) management functions */
+
+/* Copyright (c) 2006 Arnaud Legrand. */
+/* Copyright (c) 2006 Martin Quinson. */
+/* All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#ifndef XBT_PEER_H
+#define XBT_PEER_H
+
+#include "xbt/misc.h"
+
+SG_BEGIN_DECL()
+
+typedef struct {
+ char *name;
+ int port;
+} s_xbt_peer_t, *xbt_peer_t;
+
+xbt_peer_t xbt_peer_new(const char *name, int port);
+xbt_peer_t xbt_peer_from_string(const char *peerport);
+xbt_peer_t xbt_peer_copy(xbt_peer_t h);
+void xbt_peer_free(xbt_peer_t peer);
+void xbt_peer_free_voidp(void *d);
+
+SG_END_DECL()
+
+
+#endif /* XBT_PEER_H */
+++ /dev/null
-/* $Id$ */
-
-/* xbt_host_t management functions */
-
-/* Copyright (c) 2006 Martin Quinson. All rights reserved. */
-
-/* This program is free software; you can redistribute it and/or modify it
- * under the terms of the license (GNU LGPL) which comes with this package. */
-
-#include "xbt/sysdep.h"
-#include "xbt/log.h"
-#include "xbt/host.h"
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(host,xbt,"Host management");
-
-/** \brief constructor */
-xbt_host_t xbt_host_new(const char *name, int port) {
- xbt_host_t res=xbt_new(s_xbt_host_t, 1);
- res->name = xbt_strdup(name);
- res->port = port;
- return res;
-}
-
-xbt_host_t xbt_host_copy(xbt_host_t h) {
- return xbt_host_new(h->name,h->port);
-}
-
-/** \brief constructor. Argument should be of form '<hostname>:<port>'. */
-xbt_host_t xbt_host_from_string(const char *hostport) {
- xbt_host_t res=xbt_new(s_xbt_host_t, 1);
- char *name=xbt_strdup(hostport);
- char *port_str=strchr(name,':');
- xbt_assert1(port_str,"argument of xbt_host_from_string should be of form <hostname>:<port>, it's '%s'", hostport);
- *port_str='\0';
- port_str++;
-
- res->name = xbt_strdup(name); /* it will be shorter now that we cut the port */
- res->port = atoi(port_str);
- free(name);
- return res;
-}
-
-/** \brief destructor */
-void xbt_host_free(xbt_host_t host) {
- if (host) {
- if (host->name) free(host->name);
- free(host);
- }
-}
-
-/** \brief Freeing function for dynars of xbt_host_t */
-void xbt_host_free_voidp(void *d) {
- xbt_host_free( (xbt_host_t) *(void**)d );
-}
--- /dev/null
+/* $Id$ */
+
+/* xbt_peer_t management functions */
+
+/* Copyright (c) 2006 Martin Quinson. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "xbt/sysdep.h"
+#include "xbt/log.h"
+#include "xbt/peer.h"
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(peer,xbt,"peer management");
+
+/** \brief constructor */
+xbt_peer_t xbt_peer_new(const char *name, int port) {
+ xbt_peer_t res=xbt_new(s_xbt_peer_t, 1);
+ res->name = xbt_strdup(name);
+ res->port = port;
+ return res;
+}
+
+xbt_peer_t xbt_peer_copy(xbt_peer_t h) {
+ return xbt_peer_new(h->name,h->port);
+}
+
+/** \brief constructor. Argument should be of form '<peername>:<port>'. */
+xbt_peer_t xbt_peer_from_string(const char *peerport) {
+ xbt_peer_t res=xbt_new(s_xbt_peer_t, 1);
+ char *name=xbt_strdup(peerport);
+ char *port_str=strchr(name,':');
+ xbt_assert1(port_str,"argument of xbt_peer_from_string should be of form <peername>:<port>, it's '%s'", peerport);
+ *port_str='\0';
+ port_str++;
+
+ res->name = xbt_strdup(name); /* it will be shorter now that we cut the port */
+ res->port = atoi(port_str);
+ free(name);
+ return res;
+}
+
+/** \brief destructor */
+void xbt_peer_free(xbt_peer_t peer) {
+ if (peer) {
+ if (peer->name) free(peer->name);
+ free(peer);
+ }
+}
+
+/** \brief Freeing function for dynars of xbt_peer_t */
+void xbt_peer_free_voidp(void *d) {
+ xbt_peer_free( (xbt_peer_t) *(void**)d );
+}