aboutsummaryrefslogtreecommitdiff
path: root/src/cadet/test_cadeT.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/cadet/test_cadeT.c')
-rw-r--r--src/cadet/test_cadeT.c50
1 files changed, 38 insertions, 12 deletions
diff --git a/src/cadet/test_cadeT.c b/src/cadet/test_cadeT.c
index 97f315167..71170aa80 100644
--- a/src/cadet/test_cadeT.c
+++ b/src/cadet/test_cadeT.c
@@ -63,6 +63,23 @@
63 63
64static int kx_initiator; 64static int kx_initiator;
65static struct GNUNET_TESTBED_UnderlayLinkModel *model; 65static struct GNUNET_TESTBED_UnderlayLinkModel *model;
66static int msg_count;
67static struct GNUNET_SCHEDULER_Task *task;
68
69enum RES {
70 RECEIVED_MESSAGE = 1
71};
72
73enum RES check;
74
75static void
76set_data_loss_rate (int rate)
77{
78 GNUNET_TESTBED_underlaylinkmodel_set_link (model,
79 test_peers[0].testbed_peer,
80 0, rate, 100);
81 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s: %i loss.\n", __func__, rate);
82}
66 83
67static void 84static void
68send_message () 85send_message ()
@@ -73,13 +90,26 @@ send_message ()
73 90
74 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); 91 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__);
75 92
76 envelope = GNUNET_MQ_msg_extra (msg, 10000, 93 envelope = GNUNET_MQ_msg_extra (msg, 1000,
77 GNUNET_MESSAGE_TYPE_DUMMY); 94 GNUNET_MESSAGE_TYPE_DUMMY);
78 data = (int *) &msg[1]; 95 data = (int *) &msg[1];
79 *data = 1000; 96 *data = 1000;
80 97
81 GNUNET_MQ_send (GNUNET_CADET_get_mq (test_peers[0].channel), 98 GNUNET_MQ_send (GNUNET_CADET_get_mq (test_peers[0].channel),
82 envelope); 99 envelope);
100
101 msg_count++;
102
103 switch (msg_count)
104 {
105 case 2: set_data_loss_rate (100); break;
106 case 4: set_data_loss_rate (0); break;
107 }
108
109 if (msg_count < 5)
110 task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 1),
111 &send_message,
112 NULL);
83} 113}
84 114
85int 115int
@@ -94,16 +124,9 @@ handle_message (void *cls,
94 const struct GNUNET_MessageHeader *msg) 124 const struct GNUNET_MessageHeader *msg)
95{ 125{
96 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); 126 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__);
127 GNUNET_CADET_receive_done (test_peers[1].channel);
97 128
98/* 129 check = RECEIVED_MESSAGE;
99 model = GNUNET_TESTBED_underlaylinkmodel_create (test_peers[1].testbed_peer,
100 GNUNET_TESTBED_UNDERLAYLINKMODELTYPE_BLACKLIST);
101 GNUNET_TESTBED_underlaylinkmodel_set_link (model,
102 test_peers[0].testbed_peer,
103 0, 100, 0);
104 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s: Modified link model.\n", __func__);
105*/
106 send_message();
107} 130}
108 131
109/** 132/**
@@ -116,6 +139,10 @@ run_test ()
116{ 139{
117 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__); 140 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "%s\n", __func__);
118 141
142 // Init underlay link model to manipulate links
143 model = GNUNET_TESTBED_underlaylinkmodel_create (test_peers[1].testbed_peer,
144 GNUNET_TESTBED_UNDERLAYLINKMODELTYPE_BLACKLIST);
145
119 kx_initiator = (0 < GNUNET_memcmp (&test_peers[0].id, &test_peers[1].id)) ? 1 : 0; 146 kx_initiator = (0 < GNUNET_memcmp (&test_peers[0].id, &test_peers[1].id)) ? 1 : 0;
120 147
121 GNUNET_log (GNUNET_ERROR_TYPE_INFO, 148 GNUNET_log (GNUNET_ERROR_TYPE_INFO,
@@ -123,8 +150,7 @@ run_test ()
123 GNUNET_i2s (&test_peers[kx_initiator].id), 150 GNUNET_i2s (&test_peers[kx_initiator].id),
124 kx_initiator); 151 kx_initiator);
125 152
126 for (int i=0; i<10; i++) 153 send_message();
127 send_message();
128} 154}
129 155
130 156