diff options
-rw-r--r-- | src/transport/Makefile.am | 20 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_manipulation.c | 335 | ||||
-rw-r--r-- | src/transport/gnunet-service-transport_manipulation.h | 63 | ||||
-rw-r--r-- | src/transport/test_transport_api_manipulation_recv_tcp_peer1.conf (renamed from src/transport/test_transport_api_manipulation_tcp_peer1.conf) | 0 | ||||
-rw-r--r-- | src/transport/test_transport_api_manipulation_recv_tcp_peer2.conf (renamed from src/transport/test_transport_api_manipulation_tcp_peer2.conf) | 0 | ||||
-rw-r--r-- | src/transport/test_transport_api_manipulation_send_tcp.c (renamed from src/transport/test_transport_api_manipulation.c) | 37 | ||||
-rw-r--r-- | src/transport/test_transport_api_manipulation_send_tcp_peer1.conf | 30 | ||||
-rw-r--r-- | src/transport/test_transport_api_manipulation_send_tcp_peer2.conf | 30 |
8 files changed, 489 insertions, 26 deletions
diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index d02117437..3586d29f1 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am | |||
@@ -343,7 +343,8 @@ check_PROGRAMS = \ | |||
343 | $(HTTPS_API_TIMEOUT_TEST) \ | 343 | $(HTTPS_API_TIMEOUT_TEST) \ |
344 | $(WLAN_API_TEST) \ | 344 | $(WLAN_API_TEST) \ |
345 | test_transport_api_multi \ | 345 | test_transport_api_multi \ |
346 | test_transport_api_manipulation_tcp \ | 346 | test_transport_api_manipulation_send_tcp \ |
347 | test_transport_api_manipulation_recv_tcp \ | ||
347 | test_transport_api_reliability_tcp \ | 348 | test_transport_api_reliability_tcp \ |
348 | test_transport_api_reliability_tcp_nat \ | 349 | test_transport_api_reliability_tcp_nat \ |
349 | test_transport_api_unreliability_udp \ | 350 | test_transport_api_unreliability_udp \ |
@@ -391,7 +392,8 @@ TESTS = \ | |||
391 | $(HTTPS_API_TIMEOUT_TEST) \ | 392 | $(HTTPS_API_TIMEOUT_TEST) \ |
392 | $(WLAN_API_TEST) \ | 393 | $(WLAN_API_TEST) \ |
393 | test_transport_api_multi \ | 394 | test_transport_api_multi \ |
394 | test_transport_api_manipulation_tcp \ | 395 | test_transport_api_manipulation_send_tcp \ |
396 | test_transport_api_manipulation_recv_tcp \ | ||
395 | test_transport_api_reliability_tcp \ | 397 | test_transport_api_reliability_tcp \ |
396 | test_transport_api_reliability_tcp_nat \ | 398 | test_transport_api_reliability_tcp_nat \ |
397 | test_transport_api_unreliability_udp \ | 399 | test_transport_api_unreliability_udp \ |
@@ -592,9 +594,17 @@ test_transport_api_tcp_nat_LDADD = \ | |||
592 | $(top_builddir)/src/util/libgnunetutil.la \ | 594 | $(top_builddir)/src/util/libgnunetutil.la \ |
593 | $(top_builddir)/src/transport/libgnunettransporttesting.la | 595 | $(top_builddir)/src/transport/libgnunettransporttesting.la |
594 | 596 | ||
595 | test_transport_api_manipulation_tcp_SOURCES = \ | 597 | test_transport_api_manipulation_send_tcp_SOURCES = \ |
596 | test_transport_api_manipulation.c | 598 | test_transport_api_manipulation_send_tcp.c |
597 | test_transport_api_manipulation_tcp_LDADD = \ | 599 | test_transport_api_manipulation_send_tcp_LDADD = \ |
600 | $(top_builddir)/src/transport/libgnunettransport.la \ | ||
601 | $(top_builddir)/src/hello/libgnunethello.la \ | ||
602 | $(top_builddir)/src/util/libgnunetutil.la \ | ||
603 | $(top_builddir)/src/transport/libgnunettransporttesting.la | ||
604 | |||
605 | test_transport_api_manipulation_recv_tcp_SOURCES = \ | ||
606 | test_transport_api_manipulation_recv_tcp.c | ||
607 | test_transport_api_manipulation_recv_tcp_LDADD = \ | ||
598 | $(top_builddir)/src/transport/libgnunettransport.la \ | 608 | $(top_builddir)/src/transport/libgnunettransport.la \ |
599 | $(top_builddir)/src/hello/libgnunethello.la \ | 609 | $(top_builddir)/src/hello/libgnunethello.la \ |
600 | $(top_builddir)/src/util/libgnunetutil.la \ | 610 | $(top_builddir)/src/util/libgnunetutil.la \ |
diff --git a/src/transport/gnunet-service-transport_manipulation.c b/src/transport/gnunet-service-transport_manipulation.c new file mode 100644 index 000000000..74f903c98 --- /dev/null +++ b/src/transport/gnunet-service-transport_manipulation.c | |||
@@ -0,0 +1,335 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2010,2011 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file transport/gnunet-service-transport_manipulation.c | ||
23 | * @brief transport component manipulation traffic for simulation | ||
24 | * @author Christian Grothoff | ||
25 | * @author | ||
26 | */ | ||
27 | #include "platform.h" | ||
28 | #include "gnunet-service-transport_blacklist.h" | ||
29 | #include "gnunet-service-transport_clients.h" | ||
30 | #include "gnunet-service-transport_hello.h" | ||
31 | #include "gnunet-service-transport_neighbours.h" | ||
32 | #include "gnunet-service-transport_plugins.h" | ||
33 | #include "gnunet-service-transport_validation.h" | ||
34 | #include "gnunet-service-transport.h" | ||
35 | #include "transport.h" | ||
36 | |||
37 | static struct GNUNET_CONTAINER_MultiHashMap *peers; | ||
38 | |||
39 | #define DELAY 0 | ||
40 | #define DISTANCE 1 | ||
41 | |||
42 | struct TM_Peer; | ||
43 | |||
44 | struct DelayQueueEntry | ||
45 | { | ||
46 | struct DelayQueueEntry *prev; | ||
47 | struct DelayQueueEntry *next; | ||
48 | struct TM_Peer *tmp; | ||
49 | struct GNUNET_TIME_Absolute sent_at; | ||
50 | void *msg; | ||
51 | size_t msg_size; | ||
52 | struct GNUNET_TIME_Relative timeout; | ||
53 | GST_NeighbourSendContinuation cont; | ||
54 | void *cont_cls; | ||
55 | }; | ||
56 | |||
57 | struct TM_Peer | ||
58 | { | ||
59 | struct GNUNET_PeerIdentity peer; | ||
60 | uint32_t metrics [TM_BOTH][GNUNET_ATS_QualityPropertiesCount]; | ||
61 | GNUNET_SCHEDULER_TaskIdentifier send_delay_task; | ||
62 | struct DelayQueueEntry *send_head; | ||
63 | struct DelayQueueEntry *send_tail; | ||
64 | }; | ||
65 | |||
66 | |||
67 | |||
68 | static void | ||
69 | set_delay(struct TM_Peer *tmp, struct GNUNET_PeerIdentity *peer, int direction, uint32_t value) | ||
70 | { | ||
71 | uint32_t val; | ||
72 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Set traffic metrics %s for peer `%s' in direction %s to %u\n", | ||
73 | "DELAY", GNUNET_i2s(peer), | ||
74 | (TM_BOTH == direction) ? "BOTH" : (TM_SEND == direction) ? "SEND": "RECEIVE", value); | ||
75 | |||
76 | if (UINT32_MAX == value) | ||
77 | val = UINT32_MAX - 1; /* prevent overflow */ | ||
78 | else if (0 == value) | ||
79 | val = UINT32_MAX; /* disable */ | ||
80 | else | ||
81 | val = value; | ||
82 | |||
83 | switch (direction) { | ||
84 | case TM_BOTH: | ||
85 | tmp->metrics[TM_SEND][DELAY] = val; | ||
86 | tmp->metrics[TM_RECEIVE][DELAY] = val; | ||
87 | break; | ||
88 | case TM_SEND: | ||
89 | tmp->metrics[TM_SEND][DELAY] = val; | ||
90 | break; | ||
91 | case TM_RECEIVE: | ||
92 | tmp->metrics[TM_RECEIVE][DELAY] = val; | ||
93 | break; | ||
94 | default: | ||
95 | break; | ||
96 | } | ||
97 | |||
98 | } | ||
99 | |||
100 | static void | ||
101 | set_distance (struct TM_Peer *tmp, struct GNUNET_PeerIdentity *peer, int direction, uint32_t value) | ||
102 | { | ||
103 | uint32_t val; | ||
104 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Set traffic metrics %s for peer `%s' in direction %s to %u\n", | ||
105 | "DISTANCE", GNUNET_i2s(peer), | ||
106 | (TM_BOTH == direction) ? "BOTH" : (TM_SEND == direction) ? "SEND": "RECEIVE", value); | ||
107 | |||
108 | if (UINT32_MAX == value) | ||
109 | val = UINT32_MAX - 1; /* prevent overflow */ | ||
110 | else if (0 == value) | ||
111 | val = UINT32_MAX; /* disable */ | ||
112 | else | ||
113 | val = value; | ||
114 | |||
115 | switch (direction) { | ||
116 | case TM_BOTH: | ||
117 | tmp->metrics[TM_SEND][DISTANCE] = val; | ||
118 | tmp->metrics[TM_RECEIVE][DISTANCE] = val; | ||
119 | break; | ||
120 | case TM_SEND: | ||
121 | tmp->metrics[TM_SEND][DISTANCE] = val; | ||
122 | break; | ||
123 | case TM_RECEIVE: | ||
124 | tmp->metrics[TM_RECEIVE][DISTANCE] = val; | ||
125 | break; | ||
126 | default: | ||
127 | break; | ||
128 | } | ||
129 | } | ||
130 | |||
131 | void | ||
132 | GST_manipulation_set_metric (void *cls, struct GNUNET_SERVER_Client *client, | ||
133 | const struct GNUNET_MessageHeader *message) | ||
134 | { | ||
135 | struct TrafficMetricMessage *tm = (struct TrafficMetricMessage *) message; | ||
136 | struct GNUNET_ATS_Information *ats; | ||
137 | struct TM_Peer *tmp; | ||
138 | uint32_t type; | ||
139 | uint32_t value; | ||
140 | int c; | ||
141 | int c2; | ||
142 | |||
143 | if (0 == ntohs (tm->ats_count)) | ||
144 | GNUNET_SERVER_receive_done (client, GNUNET_SYSERR); | ||
145 | |||
146 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received traffic metrics for peer `%s'\n", | ||
147 | GNUNET_i2s(&tm->peer)); | ||
148 | |||
149 | if (NULL == (tmp = GNUNET_CONTAINER_multihashmap_get (peers, &tm->peer.hashPubKey))) | ||
150 | { | ||
151 | tmp = GNUNET_malloc (sizeof (struct TM_Peer)); | ||
152 | tmp->peer = (tm->peer); | ||
153 | for (c = 0; c < TM_BOTH; c++) | ||
154 | { | ||
155 | for (c2 = 0; c2 < GNUNET_ATS_QualityPropertiesCount; c2++) | ||
156 | { | ||
157 | tmp->metrics[c][c2] = UINT32_MAX; | ||
158 | } | ||
159 | } | ||
160 | GNUNET_CONTAINER_multihashmap_put (peers, &tm->peer.hashPubKey, tmp, GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST); | ||
161 | } | ||
162 | |||
163 | ats = (struct GNUNET_ATS_Information *) &tm[1]; | ||
164 | for (c = 0; c < ntohs (tm->ats_count); c++) | ||
165 | { | ||
166 | type = htonl (ats[c].type); | ||
167 | value = htonl (ats[c].value); | ||
168 | switch (type) { | ||
169 | case GNUNET_ATS_QUALITY_NET_DELAY: | ||
170 | set_delay (tmp, &tm->peer, ntohs (tm->direction), value); | ||
171 | break; | ||
172 | case GNUNET_ATS_QUALITY_NET_DISTANCE: | ||
173 | set_distance (tmp, &tm->peer, ntohs (tm->direction), value); | ||
174 | break; | ||
175 | default: | ||
176 | break; | ||
177 | } | ||
178 | } | ||
179 | |||
180 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | ||
181 | } | ||
182 | |||
183 | static void | ||
184 | send_delayed (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
185 | { | ||
186 | struct DelayQueueEntry *dqe = cls; | ||
187 | struct DelayQueueEntry *next; | ||
188 | struct TM_Peer *tmp = dqe->tmp; | ||
189 | struct GNUNET_TIME_Relative delay; | ||
190 | tmp->send_delay_task = GNUNET_SCHEDULER_NO_TASK; | ||
191 | GNUNET_CONTAINER_DLL_remove (tmp->send_head, tmp->send_tail, dqe); | ||
192 | GST_neighbours_send (&tmp->peer, dqe->msg, dqe->msg_size, dqe->timeout, dqe->cont, dqe->cont_cls); | ||
193 | |||
194 | next = tmp->send_head; | ||
195 | if (NULL != next) | ||
196 | { | ||
197 | /* More delayed messages */ | ||
198 | delay = GNUNET_TIME_absolute_get_remaining (next->sent_at); | ||
199 | tmp->send_delay_task = GNUNET_SCHEDULER_add_delayed (delay, &send_delayed, dqe); | ||
200 | } | ||
201 | |||
202 | GNUNET_free (dqe); | ||
203 | } | ||
204 | |||
205 | void | ||
206 | GST_manipulation_send (const struct GNUNET_PeerIdentity *target, const void *msg, | ||
207 | size_t msg_size, struct GNUNET_TIME_Relative timeout, | ||
208 | GST_NeighbourSendContinuation cont, void *cont_cls) | ||
209 | { | ||
210 | struct TM_Peer *tmp; | ||
211 | struct DelayQueueEntry *dqe; | ||
212 | struct GNUNET_TIME_Relative delay; | ||
213 | |||
214 | if (NULL != (tmp = GNUNET_CONTAINER_multihashmap_get (peers, &target->hashPubKey))) | ||
215 | { | ||
216 | /* Manipulate here */ | ||
217 | /* Delay */ | ||
218 | if (UINT32_MAX != tmp->metrics[TM_SEND][DELAY]) | ||
219 | { | ||
220 | /* We have a delay */ | ||
221 | delay.rel_value = tmp->metrics[TM_SEND][DELAY]; | ||
222 | dqe = GNUNET_malloc (sizeof (struct DelayQueueEntry) + msg_size); | ||
223 | dqe->tmp = tmp; | ||
224 | dqe->sent_at = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), delay); | ||
225 | dqe->cont = cont; | ||
226 | dqe->cont_cls = cont_cls; | ||
227 | dqe->msg = &dqe[1]; | ||
228 | dqe->msg_size = msg_size; | ||
229 | dqe->timeout = timeout; | ||
230 | memcpy (dqe->msg, msg, msg_size); | ||
231 | GNUNET_CONTAINER_DLL_insert_tail (tmp->send_head, tmp->send_tail, dqe); | ||
232 | if (GNUNET_SCHEDULER_NO_TASK == tmp->send_delay_task) | ||
233 | tmp->send_delay_task =GNUNET_SCHEDULER_add_delayed (delay, &send_delayed, dqe); | ||
234 | return; | ||
235 | } | ||
236 | } | ||
237 | /* Normal sending */ | ||
238 | GST_neighbours_send (target, msg, msg_size, timeout, cont, cont_cls); | ||
239 | } | ||
240 | |||
241 | struct GNUNET_TIME_Relative | ||
242 | GST_manipulation_recv (void *cls, const struct GNUNET_PeerIdentity *peer, | ||
243 | const struct GNUNET_MessageHeader *message, | ||
244 | const struct GNUNET_ATS_Information *ats, | ||
245 | uint32_t ats_count, struct Session *session, | ||
246 | const char *sender_address, | ||
247 | uint16_t sender_address_len) | ||
248 | { | ||
249 | struct TM_Peer *tmp; | ||
250 | int d; | ||
251 | struct GNUNET_ATS_Information ats_new[ats_count]; | ||
252 | struct GNUNET_TIME_Relative q_delay; | ||
253 | struct GNUNET_TIME_Relative m_delay; | ||
254 | |||
255 | for (d = 0; d < ats_count; d++) | ||
256 | |||
257 | if (NULL != (tmp = GNUNET_CONTAINER_multihashmap_get (peers, &peer->hashPubKey))) | ||
258 | { | ||
259 | /* Manipulate distance */ | ||
260 | for (d = 0; d < ats_count; d++) | ||
261 | { | ||
262 | ats_new[d] = ats[d]; | ||
263 | /* Set distance */ | ||
264 | if ((ntohl(ats[d].type) == GNUNET_ATS_QUALITY_NET_DISTANCE) && | ||
265 | (UINT32_MAX != tmp->metrics[TM_RECEIVE][DISTANCE])) | ||
266 | { | ||
267 | ats_new[d].value = htonl(tmp->metrics[TM_RECEIVE][DISTANCE]); | ||
268 | } | ||
269 | } | ||
270 | /* Manipulate receive delay */ | ||
271 | if (UINT32_MAX != tmp->metrics[TM_RECEIVE][DELAY]) | ||
272 | { | ||
273 | m_delay.rel_value = tmp->metrics[TM_RECEIVE][DELAY]; | ||
274 | q_delay = GST_receive_callback (cls, peer, message, &ats_new[0], ats_count, | ||
275 | session, sender_address, sender_address_len); | ||
276 | |||
277 | if (q_delay.rel_value >= m_delay.rel_value) | ||
278 | { | ||
279 | return q_delay; | ||
280 | } | ||
281 | else | ||
282 | { | ||
283 | return m_delay; | ||
284 | } | ||
285 | } | ||
286 | } | ||
287 | |||
288 | return GST_receive_callback (cls, peer, message, ats, ats_count, | ||
289 | session, sender_address, sender_address_len); | ||
290 | } | ||
291 | |||
292 | void | ||
293 | GST_manipulation_init () | ||
294 | { | ||
295 | peers = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); | ||
296 | } | ||
297 | |||
298 | int free_tmps (void *cls, | ||
299 | const struct GNUNET_HashCode * key, | ||
300 | void *value) | ||
301 | { | ||
302 | struct DelayQueueEntry *dqe; | ||
303 | struct DelayQueueEntry *next; | ||
304 | if (NULL != value) | ||
305 | { | ||
306 | struct TM_Peer *tmp = (struct TM_Peer *) value; | ||
307 | GNUNET_CONTAINER_multihashmap_remove (peers, key, value); | ||
308 | next = tmp->send_head; | ||
309 | while (NULL != (dqe = next)) | ||
310 | { | ||
311 | next = dqe->next; | ||
312 | GNUNET_CONTAINER_DLL_remove (tmp->send_head, tmp->send_tail, dqe); | ||
313 | GNUNET_free (dqe); | ||
314 | } | ||
315 | if (GNUNET_SCHEDULER_NO_TASK != tmp->send_delay_task) | ||
316 | { | ||
317 | GNUNET_SCHEDULER_cancel (tmp->send_delay_task); | ||
318 | tmp->send_delay_task = GNUNET_SCHEDULER_NO_TASK; | ||
319 | } | ||
320 | GNUNET_free (tmp); | ||
321 | } | ||
322 | return GNUNET_OK; | ||
323 | } | ||
324 | |||
325 | void | ||
326 | GST_manipulation_stop () | ||
327 | { | ||
328 | GNUNET_CONTAINER_multihashmap_iterate (peers, &free_tmps,NULL); | ||
329 | |||
330 | GNUNET_CONTAINER_multihashmap_destroy (peers); | ||
331 | peers = NULL; | ||
332 | } | ||
333 | |||
334 | |||
335 | /* end of file gnunet-service-transport_manipulation.c */ | ||
diff --git a/src/transport/gnunet-service-transport_manipulation.h b/src/transport/gnunet-service-transport_manipulation.h new file mode 100644 index 000000000..f8faa85dd --- /dev/null +++ b/src/transport/gnunet-service-transport_manipulation.h | |||
@@ -0,0 +1,63 @@ | |||
1 | /* | ||
2 | This file is part of GNUnet. | ||
3 | (C) 2010,2011 Christian Grothoff (and other contributing authors) | ||
4 | |||
5 | GNUnet is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published | ||
7 | by the Free Software Foundation; either version 3, or (at your | ||
8 | option) any later version. | ||
9 | |||
10 | GNUnet is distributed in the hope that it will be useful, but | ||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with GNUnet; see the file COPYING. If not, write to the | ||
17 | Free Software Foundation, Inc., 59 Temple Place - Suite 330, | ||
18 | Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /** | ||
22 | * @file transport/gnunet-service-transport_neighbours.h | ||
23 | * @brief neighbour management API | ||
24 | * @author Christian Grothoff | ||
25 | */ | ||
26 | #ifndef GNUNET_SERVICE_TRANSPORT_MANIPULATION_H | ||
27 | #define GNUNET_SERVICE_TRANSPORT_MANIPULATION_H | ||
28 | |||
29 | #include "platform.h" | ||
30 | #include "gnunet-service-transport_blacklist.h" | ||
31 | #include "gnunet-service-transport_clients.h" | ||
32 | #include "gnunet-service-transport_hello.h" | ||
33 | #include "gnunet-service-transport_neighbours.h" | ||
34 | #include "gnunet-service-transport_plugins.h" | ||
35 | #include "gnunet-service-transport_validation.h" | ||
36 | #include "gnunet-service-transport.h" | ||
37 | #include "transport.h" | ||
38 | |||
39 | void | ||
40 | GST_manipulation_set_metric (void *cls, struct GNUNET_SERVER_Client *client, | ||
41 | const struct GNUNET_MessageHeader *message); | ||
42 | |||
43 | void | ||
44 | GST_manipulation_send (const struct GNUNET_PeerIdentity *target, const void *msg, | ||
45 | size_t msg_size, struct GNUNET_TIME_Relative timeout, | ||
46 | GST_NeighbourSendContinuation cont, void *cont_cls); | ||
47 | |||
48 | struct GNUNET_TIME_Relative | ||
49 | GST_manipulation_recv (void *cls, const struct GNUNET_PeerIdentity *peer, | ||
50 | const struct GNUNET_MessageHeader *message, | ||
51 | const struct GNUNET_ATS_Information *ats, | ||
52 | uint32_t ats_count, struct Session *session, | ||
53 | const char *sender_address, | ||
54 | uint16_t sender_address_len); | ||
55 | |||
56 | void | ||
57 | GST_manipulation_init (); | ||
58 | |||
59 | void | ||
60 | GST_manipulation_stop (); | ||
61 | |||
62 | #endif | ||
63 | /* end of file gnunet-service-transport_neighbours.h */ | ||
diff --git a/src/transport/test_transport_api_manipulation_tcp_peer1.conf b/src/transport/test_transport_api_manipulation_recv_tcp_peer1.conf index db662826b..db662826b 100644 --- a/src/transport/test_transport_api_manipulation_tcp_peer1.conf +++ b/src/transport/test_transport_api_manipulation_recv_tcp_peer1.conf | |||
diff --git a/src/transport/test_transport_api_manipulation_tcp_peer2.conf b/src/transport/test_transport_api_manipulation_recv_tcp_peer2.conf index 67f171ec9..67f171ec9 100644 --- a/src/transport/test_transport_api_manipulation_tcp_peer2.conf +++ b/src/transport/test_transport_api_manipulation_recv_tcp_peer2.conf | |||
diff --git a/src/transport/test_transport_api_manipulation.c b/src/transport/test_transport_api_manipulation_send_tcp.c index 21bed3a65..cdef9921b 100644 --- a/src/transport/test_transport_api_manipulation.c +++ b/src/transport/test_transport_api_manipulation_send_tcp.c | |||
@@ -176,7 +176,7 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
176 | 176 | ||
177 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); | 177 | char *ps = GNUNET_strdup (GNUNET_i2s (&p->id)); |
178 | 178 | ||
179 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 179 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
180 | "Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n", | 180 | "Peer %u (`%4s') received message of type %d and size %u size from peer %u (`%4s')!\n", |
181 | p->no, ps, ntohs (message->type), ntohs (message->size), t->no, | 181 | p->no, ps, ntohs (message->type), ntohs (message->size), t->no, |
182 | GNUNET_i2s (&t->id)); | 182 | GNUNET_i2s (&t->id)); |
@@ -196,13 +196,13 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
196 | return; | 196 | return; |
197 | } | 197 | } |
198 | 198 | ||
199 | |||
200 | if (0 == messages_recv) | 199 | if (0 == messages_recv) |
201 | { | 200 | { |
202 | /* Received non-delayed message */ | 201 | /* Received non-delayed message */ |
203 | dur_normal = GNUNET_TIME_absolute_get_duration(start_normal); | 202 | dur_normal = GNUNET_TIME_absolute_get_duration(start_normal); |
204 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 203 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
205 | "Received non-delayed message after %llu\n", | 204 | "Received non-delayed message %u after %llu\n", |
205 | messages_recv, | ||
206 | (long long unsigned int) dur_normal.rel_value); | 206 | (long long unsigned int) dur_normal.rel_value); |
207 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); | 207 | send_task = GNUNET_SCHEDULER_add_now (&sendtask, NULL); |
208 | } | 208 | } |
@@ -210,8 +210,9 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
210 | { | 210 | { |
211 | /* Received manipulated message */ | 211 | /* Received manipulated message */ |
212 | dur_delayed = GNUNET_TIME_absolute_get_duration(start_delayed); | 212 | dur_delayed = GNUNET_TIME_absolute_get_duration(start_delayed); |
213 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 213 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
214 | "Received delayed message after %llu\n", | 214 | "Received delayed message %u after %llu\n", |
215 | messages_recv, | ||
215 | (long long unsigned int) dur_delayed.rel_value); | 216 | (long long unsigned int) dur_delayed.rel_value); |
216 | if (dur_delayed.rel_value < 1000) | 217 | if (dur_delayed.rel_value < 1000) |
217 | { | 218 | { |
@@ -221,15 +222,12 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
221 | "Delayed message was not delayed correctly: took only %llu\n", | 222 | "Delayed message was not delayed correctly: took only %llu\n", |
222 | (long long unsigned int) dur_delayed.rel_value); | 223 | (long long unsigned int) dur_delayed.rel_value); |
223 | } | 224 | } |
224 | |||
225 | for (c = 0; c < ats_count; c++) | 225 | for (c = 0; c < ats_count; c++) |
226 | { | 226 | { |
227 | if (ntohl (ats[c].type) == GNUNET_ATS_QUALITY_NET_DISTANCE) | 227 | if (ntohl (ats[c].type) == GNUNET_ATS_QUALITY_NET_DISTANCE) |
228 | { | 228 | { |
229 | if (ntohl (ats[c].value) == 10) | 229 | if (ntohl (ats[c].value) == 10) |
230 | { | ||
231 | ok += 0; | 230 | ok += 0; |
232 | } | ||
233 | else | 231 | else |
234 | { | 232 | { |
235 | GNUNET_break (0); | 233 | GNUNET_break (0); |
@@ -237,20 +235,10 @@ notify_receive (void *cls, const struct GNUNET_PeerIdentity *peer, | |||
237 | } | 235 | } |
238 | } | 236 | } |
239 | } | 237 | } |
240 | |||
241 | /* shutdown */ | 238 | /* shutdown */ |
242 | end (); | 239 | end (); |
243 | } | 240 | } |
244 | messages_recv ++; | 241 | messages_recv ++; |
245 | |||
246 | |||
247 | |||
248 | /* | ||
249 | |||
250 | |||
251 | // | ||
252 | * | ||
253 | */ | ||
254 | } | 242 | } |
255 | 243 | ||
256 | 244 | ||
@@ -320,8 +308,7 @@ sendtask (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
320 | ats[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); | 308 | ats[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); |
321 | ats[1].value = htonl (10); | 309 | ats[1].value = htonl (10); |
322 | 310 | ||
323 | GNUNET_TRANSPORT_set_traffic_metric (p1->th, &p2->id, TM_BOTH, ats, 2); | 311 | GNUNET_TRANSPORT_set_traffic_metric (p2->th, &p1->id, TM_SEND, ats, 2); |
324 | GNUNET_TRANSPORT_set_traffic_metric (p2->th, &p1->id, TM_BOTH, ats, 2); | ||
325 | 312 | ||
326 | start_delayed = GNUNET_TIME_absolute_get(); | 313 | start_delayed = GNUNET_TIME_absolute_get(); |
327 | } | 314 | } |
@@ -410,7 +397,15 @@ start_cb (struct PeerContext *p, void *cls) | |||
410 | "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", | 397 | "Test tries to connect peer %u (`%s') -> peer %u (`%s')\n", |
411 | p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); | 398 | p1->no, sender_c, p2->no, GNUNET_i2s (&p2->id)); |
412 | GNUNET_free (sender_c); | 399 | GNUNET_free (sender_c); |
400 | /* | ||
401 | struct GNUNET_ATS_Information ats[2]; | ||
402 | ats[0].type = htonl (GNUNET_ATS_QUALITY_NET_DELAY); | ||
403 | ats[0].value = htonl (1000); | ||
404 | ats[1].type = htonl (GNUNET_ATS_QUALITY_NET_DISTANCE); | ||
405 | ats[1].value = htonl (10); | ||
413 | 406 | ||
407 | GNUNET_TRANSPORT_set_traffic_metric (p1->th, &p2->id, TM_RECEIVE, ats, 2); | ||
408 | */ | ||
414 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, | 409 | cc = GNUNET_TRANSPORT_TESTING_connect_peers (tth, p1, p2, &testing_connect_cb, |
415 | NULL); | 410 | NULL); |
416 | 411 | ||
@@ -451,7 +446,7 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
451 | static int | 446 | static int |
452 | check () | 447 | check () |
453 | { | 448 | { |
454 | static char *const argv[] = { "test-transport-api", | 449 | static char *const argv[] = { "test-transport-api-manipulation", |
455 | "-c", | 450 | "-c", |
456 | "test_transport_api_data.conf", | 451 | "test_transport_api_data.conf", |
457 | NULL | 452 | NULL |
diff --git a/src/transport/test_transport_api_manipulation_send_tcp_peer1.conf b/src/transport/test_transport_api_manipulation_send_tcp_peer1.conf new file mode 100644 index 000000000..db662826b --- /dev/null +++ b/src/transport/test_transport_api_manipulation_send_tcp_peer1.conf | |||
@@ -0,0 +1,30 @@ | |||
1 | @INLINE@ template_cfg_peer1.conf | ||
2 | [PATHS] | ||
3 | SERVICEHOME = /tmp/test-transport/api-tcp-p1/ | ||
4 | |||
5 | [transport-tcp] | ||
6 | PORT = 12000 | ||
7 | TIMEOUT = 5 s | ||
8 | |||
9 | [arm] | ||
10 | PORT = 12005 | ||
11 | DEFAULTSERVICES = transport | ||
12 | UNIXPATH = /tmp/gnunet-p1-service-arm.sock | ||
13 | |||
14 | [statistics] | ||
15 | PORT = 12004 | ||
16 | UNIXPATH = /tmp/gnunet-p1-service-statistics.sock | ||
17 | |||
18 | [resolver] | ||
19 | PORT = 12003 | ||
20 | UNIXPATH = /tmp/gnunet-p1-service-resolver.sock | ||
21 | |||
22 | [peerinfo] | ||
23 | PORT = 12002 | ||
24 | UNIXPATH = /tmp/gnunet-p1-service-peerinfo.sock | ||
25 | |||
26 | [transport] | ||
27 | PORT = 12001 | ||
28 | UNIXPATH = /tmp/gnunet-p1-service-transport.sock | ||
29 | PLUGINS = tcp | ||
30 | |||
diff --git a/src/transport/test_transport_api_manipulation_send_tcp_peer2.conf b/src/transport/test_transport_api_manipulation_send_tcp_peer2.conf new file mode 100644 index 000000000..67f171ec9 --- /dev/null +++ b/src/transport/test_transport_api_manipulation_send_tcp_peer2.conf | |||
@@ -0,0 +1,30 @@ | |||
1 | @INLINE@ template_cfg_peer2.conf | ||
2 | [PATHS] | ||
3 | SERVICEHOME = /tmp/test-transport/api-tcp-p2/ | ||
4 | |||
5 | [transport-tcp] | ||
6 | PORT = 12015 | ||
7 | TIMEOUT = 5 s | ||
8 | |||
9 | [arm] | ||
10 | PORT = 12014 | ||
11 | DEFAULTSERVICES = transport | ||
12 | UNIXPATH = /tmp/gnunet-p2-service-arm.sock | ||
13 | |||
14 | [statistics] | ||
15 | PORT = 12013 | ||
16 | UNIXPATH = /tmp/gnunet-p2-service-statistics.sock | ||
17 | |||
18 | [resolver] | ||
19 | PORT = 12012 | ||
20 | UNIXPATH = /tmp/gnunet-p2-service-resolver.sock | ||
21 | |||
22 | [peerinfo] | ||
23 | PORT = 12011 | ||
24 | UNIXPATH = /tmp/gnunet-p2-service-peerinfo.sock | ||
25 | |||
26 | [transport] | ||
27 | PORT = 12010 | ||
28 | PLUGINS = tcp | ||
29 | UNIXPATH = /tmp/gnunet-p2-service-transport.sock | ||
30 | |||