[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r8129 - GNUnet/src/applications/testing
From: |
gnunet |
Subject: |
[GNUnet-SVN] r8129 - GNUnet/src/applications/testing |
Date: |
Tue, 20 Jan 2009 12:20:28 -0700 (MST) |
Author: nevans
Date: 2009-01-20 12:20:27 -0700 (Tue, 20 Jan 2009)
New Revision: 8129
Modified:
GNUnet/src/applications/testing/remote.c
GNUnet/src/applications/testing/remote.h
GNUnet/src/applications/testing/remotetest.c
GNUnet/src/applications/testing/remotetopologies.c
Log:
dot graphics for testing, erdos-renyi random graph topology, ring topology
Modified: GNUnet/src/applications/testing/remote.c
===================================================================
--- GNUnet/src/applications/testing/remote.c 2009-01-19 19:40:54 UTC (rev
8128)
+++ GNUnet/src/applications/testing/remote.c 2009-01-20 19:20:27 UTC (rev
8129)
@@ -69,7 +69,7 @@
system (cmd);
GNUNET_free (cmd);
-
+
length =
snprintf (NULL, 0, "ssh address@hidden %sgnunet-update -c %s%s", username,
hostname,
gnunetd_home, remote_config_path, configFileName);
@@ -78,7 +78,7 @@
hostname, gnunetd_home, remote_config_path, configFileName);
fprintf (stderr, _("ssh command is : %s \n"), cmd);
-
+
system (cmd);
GNUNET_free (cmd);
@@ -108,10 +108,11 @@
struct GNUNET_REMOTE_host_list *temp_pos;
GNUNET_REMOTE_TOPOLOGIES type_of_topology;
list_as_array = &array_of_pointers[0];
+ FILE *dotOutFile;
-
char *ssh_username;
char *control_host;
+ char *percentage_string;
char *remote_config_path;
char *remote_gnunetd_path;
char *remote_pid_path;
@@ -123,6 +124,7 @@
char *temp_pid_file;
char *curr_host;
char *temp_remote_config_path;
+ char *dotOutFileName;
unsigned long long starting_port;
unsigned long long port_increment;
@@ -145,6 +147,7 @@
int friend_location_length;
int ret;
char *ipk_dir;
+ double percentage;
length = 0;
ipk_dir = GNUNET_get_installation_path (GNUNET_IPK_DATADIR);
@@ -157,34 +160,65 @@
GNUNET_GC_get_configuration_value_string (newcfg, "MULTIPLE_SERVER_TESTING",
"SSH_USERNAME", "",
&ssh_username);
+
GNUNET_GC_get_configuration_value_number (newcfg, "MULTIPLE_SERVER_TESTING",
"TOPOLOGY", 0, -1, 0, &topology);
+
type_of_topology = (unsigned int) topology;
+
GNUNET_GC_get_configuration_value_string (newcfg, "MULTIPLE_SERVER_TESTING",
+ "PERCENTAGE", "1.0",
+ &percentage_string);
+ percentage = atof(percentage_string);
+
+ GNUNET_GC_get_configuration_value_string (newcfg, "MULTIPLE_SERVER_TESTING",
"CONTROL_HOST", "localhost",
&control_host);
+
GNUNET_GC_get_configuration_value_string (newcfg, "MULTIPLE_SERVER_TESTING",
"HOSTNAMES", "localhost",
&hostnames);
+
+ GNUNET_GC_get_configuration_value_string (newcfg, "MULTIPLE_SERVER_TESTING",
+ "DOT_OUTPUT", "",
+ &dotOutFileName);
+
+ dotOutFile = NULL;
+ if (strcmp(dotOutFileName,"") != 0)
+ {
+ dotOutFile = FOPEN (dotOutFileName,"w");
+ if (dotOutFile != NULL)
+ {
+ fprintf(dotOutFile, "strict graph G {\n");
+ }
+ }
+
GNUNET_GC_get_configuration_value_number (newcfg, "MULTIPLE_SERVER_TESTING",
"STARTING_PORT",
1, -1, 1, &starting_port);
+
GNUNET_GC_get_configuration_value_number (newcfg, "MULTIPLE_SERVER_TESTING",
"PORT_INCREMENT",
1, -1, 2, &port_increment);
+
GNUNET_GC_get_configuration_value_string (newcfg, "MULTIPLE_SERVER_TESTING",
"REMOTE_CONFIG_PATH", "/tmp/",
&remote_config_path);
+
ipk_dir = GNUNET_get_installation_path (GNUNET_IPK_BINDIR);
+
GNUNET_GC_get_configuration_value_string (newcfg, "MULTIPLE_SERVER_TESTING",
"REMOTE_GNUNETD_PATH", ipk_dir,
&remote_gnunetd_path);
+
if (ipk_dir != NULL)
GNUNET_free (ipk_dir);
+
GNUNET_GC_get_configuration_value_string (newcfg, "MULTIPLE_SERVER_TESTING",
"BASE_CONFIG",
"gnunetd.conf.skel",
&base_config);
+
GNUNET_GC_get_configuration_value_string (newcfg, "MULTIPLE_SERVER_TESTING",
"PID_PATH", "/tmp/",
&remote_pid_path);
@@ -445,8 +479,15 @@
GNUNET_GC_free (basecfg);
++i;
}
- ret = GNUNET_REMOTE_create_topology (type_of_topology, number_of_daemons);
+ ret = GNUNET_REMOTE_create_topology (type_of_topology, number_of_daemons,
dotOutFile, percentage);
+ if (dotOutFile != NULL)
+ {
+ fprintf(dotOutFile,"}\n");
+ fclose(dotOutFile);
+ }
+ GNUNET_free (dotOutFileName);
+ GNUNET_free (percentage_string);
GNUNET_free (base_config);
GNUNET_free (remote_pid_path);
GNUNET_free (data_dir);
@@ -460,8 +501,8 @@
}
int
-GNUNET_REMOTE_create_topology (GNUNET_REMOTE_TOPOLOGIES t,
- int number_of_daemons)
+GNUNET_REMOTE_create_topology (GNUNET_REMOTE_TOPOLOGIES type,
+ int number_of_daemons, FILE *dotOutFile, double
percentage)
{
FILE *temp_friend_handle;
int ret;
@@ -472,11 +513,11 @@
int length;
ret = GNUNET_OK;
- switch (t)
+ switch (type)
{
case GNUNET_REMOTE_CLIQUE:
fprintf (stderr, "Creating clique topology\n");
- ret = GNUNET_REMOTE_connect_clique (head);
+ ret = GNUNET_REMOTE_connect_clique (head, dotOutFile);
break;
case GNUNET_REMOTE_SMALL_WORLD:
fprintf (stderr, "Creating small world topology\n");
@@ -484,12 +525,16 @@
break;
case GNUNET_REMOTE_RING:
fprintf (stderr, "Creating ring topology\n");
- ret = GNUNET_SYSERR;
+ ret = GNUNET_REMOTE_connect_ring (head, dotOutFile);
break;
case GNUNET_REMOTE_2D_TORUS:
fprintf (stderr, "Creating 2d torus topology\n");
- ret = GNUNET_REMOTE_connect_2d_torus (number_of_daemons, list_as_array);
+ ret = GNUNET_REMOTE_connect_2d_torus (number_of_daemons, list_as_array,
dotOutFile);
break;
+ case GNUNET_REMOTE_ERDOS_RENYI:
+ fprintf (stderr, "Creating Erdos-Renyi topology\n");
+ ret = GNUNET_REMOTE_connect_erdos_renyi (percentage, head, dotOutFile);
+ break;
default:
ret = GNUNET_SYSERR;
break;
@@ -551,7 +596,7 @@
friend_pos->hostentry->port);
GNUNET_REMOTE_connect_daemons (pos->hostname, pos->port,
friend_pos->hostentry->hostname,
- friend_pos->hostentry->port);
+ friend_pos->hostentry->port,
dotOutFile);
friend_pos = friend_pos->next;
}
pos = pos->next;
Modified: GNUnet/src/applications/testing/remote.h
===================================================================
--- GNUnet/src/applications/testing/remote.h 2009-01-19 19:40:54 UTC (rev
8128)
+++ GNUnet/src/applications/testing/remote.h 2009-01-20 19:20:27 UTC (rev
8129)
@@ -68,7 +68,7 @@
*/
int
GNUNET_REMOTE_connect_daemons (char *hostname1, unsigned short port1,
- char *hostname2, unsigned short port2);
+ char *hostname2, unsigned short port2, FILE
*dotOutFile);
/**
* Because we need to copy over the friends file before actually connecting,
@@ -90,11 +90,11 @@
/**
* Create a topology (connect the running gnunetd's) that corresponds
- * to the type specified in t.
+ * to the type specified in type.
*/
int
-GNUNET_REMOTE_create_topology (GNUNET_REMOTE_TOPOLOGIES t,
- int number_of_daemons);
+GNUNET_REMOTE_create_topology (GNUNET_REMOTE_TOPOLOGIES type,
+ int number_of_daemons, FILE *dotOufFile, double
percentage);
#endif /*REMOTE_H_ */
Modified: GNUnet/src/applications/testing/remotetest.c
===================================================================
--- GNUnet/src/applications/testing/remotetest.c 2009-01-19 19:40:54 UTC
(rev 8128)
+++ GNUnet/src/applications/testing/remotetest.c 2009-01-20 19:20:27 UTC
(rev 8129)
@@ -20,7 +20,7 @@
/**
* @file applications/testing/remotetest.c
- * @brief Testcase for remote library
+ * @brief Start gnunet daemons, connect them together to create some topology
* @author Nathan Evans
*/
@@ -31,6 +31,7 @@
#include "remote.h"
static char *configFile = GNUNET_DEFAULT_DAEMON_CONFIG_FILE;
+static char *dotOutFileName = NULL;
static unsigned long long number_of_daemons;
static struct GNUNET_CommandLineOption gnunetRemoteOptions[] = {
@@ -42,14 +43,14 @@
{'n', "number_of_daemons", "NUMBER_OF_DAEMONS",
gettext_noop ("set number of daemons to start"),
1, &GNUNET_getopt_configure_set_ulong, &number_of_daemons}, /* -n */
+ GNUNET_COMMAND_LINE_OPTION_VERSION (PACKAGE_VERSION), /* -v */
+ {'O', "output", "DOT_OUTPUT",
+ gettext_noop ("set output file for a dot input file which represents
the graph of the connected nodes"),
+ 1, &GNUNET_getopt_configure_set_string, &dotOutFileName},
GNUNET_COMMAND_LINE_OPTION_VERBOSE,
GNUNET_COMMAND_LINE_OPTION_END,
};
-/**
- * Testcase
- * @return 0: ok, -1: error
- */
int
main (int argc, char *const *argv)
{
@@ -77,6 +78,14 @@
return -1;
}
+ if (dotOutFileName != NULL)
+ {
+ GNUNET_GC_set_configuration_value_string (hostConfig, NULL,
+
"MULTIPLE_SERVER_TESTING",
+ "DOT_OUTPUT",
+ dotOutFileName);
+ }
+
GNUNET_REMOTE_start_daemons (hostConfig, number_of_daemons);
GNUNET_GC_free (hostConfig);
Modified: GNUnet/src/applications/testing/remotetopologies.c
===================================================================
--- GNUnet/src/applications/testing/remotetopologies.c 2009-01-19 19:40:54 UTC
(rev 8128)
+++ GNUnet/src/applications/testing/remotetopologies.c 2009-01-20 19:20:27 UTC
(rev 8129)
@@ -43,10 +43,69 @@
return GNUNET_OK;
}
-/*int GNUNET_REMOTE_connect_erdos_renyi*/
+int
+GNUNET_REMOTE_connect_erdos_renyi (double probability, struct
GNUNET_REMOTE_host_list *main_list, FILE *dotOutFile)
+{
+ double temp_rand;
+ struct GNUNET_REMOTE_host_list *pos = main_list;
+ struct GNUNET_REMOTE_host_list *iter_pos = main_list;
+ GNUNET_EncName *node1;
+ GNUNET_EncName *node2;
+ struct GNUNET_REMOTE_friends_list *node1temp;
+ struct GNUNET_REMOTE_friends_list *node2temp;
+ node1 = GNUNET_malloc (sizeof (GNUNET_EncName));
+ node2 = GNUNET_malloc (sizeof (GNUNET_EncName));
+
+
+ while ((pos != NULL) && (pos->next != NULL))
+ {
+ iter_pos = pos->next;
+ while (iter_pos != NULL)
+ {
+ if (GNUNET_OK ==
+ GNUNET_REMOTE_get_daemons_information (pos->hostname, pos->port,
+ iter_pos->hostname,
+ iter_pos->port, &node1,
+ &node2))
+ {
+ temp_rand = RANDOM ();
+ if (temp_rand <
probability)
+ {
+
node1temp =
+
GNUNET_malloc (sizeof (struct GNUNET_REMOTE_friends_list));
+
node2temp =
+
GNUNET_malloc (sizeof (struct GNUNET_REMOTE_friends_list));
+
+
node2temp->hostentry = pos;
+
node1temp->hostentry = iter_pos;
+
+
node1temp->nodeid = GNUNET_malloc (sizeof (GNUNET_EncName));
+
node2temp->nodeid = GNUNET_malloc (sizeof (GNUNET_EncName));
+
+ memcpy
(node1temp->nodeid, node2, sizeof (GNUNET_EncName));
+ memcpy
(node2temp->nodeid, node1, sizeof (GNUNET_EncName));
+
+
node1temp->next = pos->friend_entries;
+
node2temp->next = iter_pos->friend_entries;
+
+
pos->friend_entries = node1temp;
+
iter_pos->friend_entries = node2temp;
+ }
+ }
+ iter_pos = iter_pos->next;
+ }
+ pos = pos->next;
+ }
+
+ GNUNET_free (node1);
+ GNUNET_free (node2);
+
+ return GNUNET_OK;
+}
+
int
-GNUNET_REMOTE_connect_clique (struct GNUNET_REMOTE_host_list *main_list)
+GNUNET_REMOTE_connect_clique (struct GNUNET_REMOTE_host_list *main_list, FILE
*dotOutFile)
{
struct GNUNET_REMOTE_host_list *pos = main_list;
struct GNUNET_REMOTE_host_list *iter_pos = main_list;
@@ -101,7 +160,7 @@
}
int
-GNUNET_REMOTE_connect_ring (struct GNUNET_REMOTE_host_list *main_list)
+GNUNET_REMOTE_connect_ring (struct GNUNET_REMOTE_host_list *main_list, FILE
*dotOutFile)
{
struct GNUNET_REMOTE_host_list *pos = main_list;
struct GNUNET_REMOTE_host_list *iter_pos = main_list;
@@ -178,7 +237,7 @@
int
GNUNET_REMOTE_connect_2d_torus (unsigned int number_of_daemons,
struct GNUNET_REMOTE_host_list
- **list_as_array)
+ **list_as_array, FILE *dotOutFile)
{
unsigned int i;
unsigned int square;
@@ -305,7 +364,7 @@
int
GNUNET_REMOTE_connect_small_world (int number_of_daemons,
struct GNUNET_REMOTE_host_list
- **list_as_array)
+ **list_as_array, FILE *dotOutFile)
{
return GNUNET_SYSERR;
@@ -323,9 +382,10 @@
int
GNUNET_REMOTE_connect_daemons (char *hostname1, unsigned short port1,
- char *hostname2, unsigned short port2)
+ char *hostname2, unsigned short port2, FILE
*dotOutFile)
{
char host[128];
+ char *buf;
struct GNUNET_GC_Configuration *cfg1 = GNUNET_GC_create ();
struct GNUNET_GC_Configuration *cfg2 = GNUNET_GC_create ();
struct GNUNET_ClientServerConnection *sock1;
@@ -419,6 +479,15 @@
GNUNET_IDENTITY_request_peer_infos (sock2, &printInfo, NULL);
}
+ if (dotOutFile != NULL)
+ {
+ buf = GNUNET_malloc(18);
+ snprintf(buf, 7, "\tn%s", (char *)host1entry);
+ snprintf(&buf[6], 5," -- ");
+ snprintf(&buf[10], 6, "n%s", (char *)host2entry);
+ fprintf(dotOutFile, "%s;\n", buf);
+ GNUNET_free(buf);
+ }
fprintf (stderr, "%s\n", ret == GNUNET_OK ? "Connected nodes." : "?");
GNUNET_client_connection_destroy (sock1);
GNUNET_client_connection_destroy (sock2);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r8129 - GNUnet/src/applications/testing,
gnunet <=