static int kx_initiator;
static struct GNUNET_TESTBED_UnderlayLinkModel *model;
+static int msg_count;
+static struct GNUNET_SCHEDULER_Task *task;
+
+enum RES {
+ RECEIVED_MESSAGE = 1
+};
+
+enum RES check;
+
+static void
+set_data_loss_rate (int rate)
+{
+ GNUNET_TESTBED_underlaylinkmodel_set_link (model,
+ test_peers[0].testbed_peer,
+ 0, rate, 100);
+ GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s: %i loss.\n", __func__, rate);
+}
static void
send_message ()
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__);
- envelope = GNUNET_MQ_msg_extra (msg, 10000,
+ envelope = GNUNET_MQ_msg_extra (msg, 1000,
GNUNET_MESSAGE_TYPE_DUMMY);
data = (int *) &msg[1];
*data = 1000;
GNUNET_MQ_send (GNUNET_CADET_get_mq (test_peers[0].channel),
envelope);
+
+ msg_count++;
+
+ switch (msg_count)
+ {
+ case 2: set_data_loss_rate (100); break;
+ case 4: set_data_loss_rate (0); break;
+ }
+
+ if (msg_count < 5)
+ task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1),
+ &send_message,
+ NULL);
}
int
const struct GNUNET_MessageHeader *msg)
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__);
+ GNUNET_CADET_receive_done (test_peers[1].channel);
-/*
- model = GNUNET_TESTBED_underlaylinkmodel_create (test_peers[1].testbed_peer,
- GNUNET_TESTBED_UNDERLAYLINKMODELTYPE_BLACKLIST);
- GNUNET_TESTBED_underlaylinkmodel_set_link (model,
- test_peers[0].testbed_peer,
- 0, 100, 0);
- GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s: Modified link model.\n", __func__);
-*/
- send_message();
+ check = RECEIVED_MESSAGE;
}
/**
{
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__);
+ // Init underlay link model to manipulate links
+ model = GNUNET_TESTBED_underlaylinkmodel_create (test_peers[1].testbed_peer,
+ GNUNET_TESTBED_UNDERLAYLINKMODELTYPE_BLACKLIST);
+
kx_initiator = (0 < GNUNET_memcmp (&test_peers[0].id, &test_peers[1].id)) ? 1 : 0;
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
GNUNET_i2s (&test_peers[kx_initiator].id),
kx_initiator);
- for (int i=0; i<10; i++)
- send_message();
+ send_message();
}
*/
static struct GNUNET_HashCode hashed_portname;
+/**
+ * Port handle.
+ */
+struct GNUNET_CADET_Port *port;
+
/**
* Result of the test.
*/
GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__);
+ if (0 == strncmp ("listening_peer", cls, sizeof (cls)))
+ GNUNET_CADET_close_port (port);
+
GNUNET_CADET_disconnect (cadet);
}
struct GNUNET_CADET_Channel *channel,
const struct GNUNET_PeerIdentity *source)
{
+ test_peers[1].channel = channel;
return NULL;
}
const struct GNUNET_CONFIGURATION_Handle *cfg)
{
struct GNUNET_CADET_Handle *cadet;
- struct GNUNET_CADET_Port *port;
struct GNUNET_MQ_MessageHandler msg_handlers[] = {
- GNUNET_MQ_hd_fixed_size (message,
- GNUNET_MESSAGE_TYPE_DUMMY,
- struct GNUNET_MessageHeader,
- NULL),
+ GNUNET_MQ_hd_var_size (message,
+ GNUNET_MESSAGE_TYPE_DUMMY,
+ struct GNUNET_MessageHeader,
+ NULL),
GNUNET_MQ_handler_end ()
};
"cadet",
&check_test_readyness, NULL,
&setup_listening_peer,
- &disconnect_from_peer, NULL);
+ &disconnect_from_peer, "listening_peer");
testbed_to_svc[0] =
GNUNET_TESTBED_service_connect (NULL, test_peers[0].testbed_peer,
"cadet",
&check_test_readyness, NULL,
&setup_initiating_peer,
- &disconnect_from_peer, NULL);
+ &disconnect_from_peer, "initiating_peer");
}
}
int test_result;
-void prepare_test ();
+void
+prepare_test ();
-void run_test ();
+void
+run_test ();
-void handle_message (void *cls,
- const struct GNUNET_MessageHeader *msg);
+void
+handle_message (void *cls,
+ const struct GNUNET_MessageHeader *msg);
+
+int
+check_message (void *cls,
+ const struct GNUNET_MessageHeader *message);
/**
* Structure for storing information of testbed peers.
testbed_api_test.c \
testbed_api_topology.c testbed_api_topology.h \
testbed_api_sd.c testbed_api_sd.h \
- testbed_api_barriers.c
+ testbed_api_barriers.c \
+ testbed_api_underlay.c
libgnunettestbed_la_LIBADD = $(XLIB) \
$(top_builddir)/src/statistics/libgnunetstatistics.la \
$(top_builddir)/src/transport/libgnunettransport.la \
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
*/
+#include "platform.h"
+#include "gnunet_util_lib.h"
+#include "gnunet_testbed_service.h"
#include "testbed_api_peers.h"
-
/**
* An underlay link
*/
* the type of this model
*/
enum GNUNET_TESTBED_UnderlayLinkModelType type;
-}
+};
/**
model->peer->underlay_model_exists = 0;
free_entries (model);
free_link_properties (model);
- gnunet_free (model);
+ GNUNET_free (model);
}