aboutsummaryrefslogtreecommitdiff
path: root/src/transport/gnunet-service-transport_manipulation.c
diff options
context:
space:
mode:
authorMatthias Wachs <wachs@net.in.tum.de>2013-03-20 08:14:01 +0000
committerMatthias Wachs <wachs@net.in.tum.de>2013-03-20 08:14:01 +0000
commit0f8b8d96afa2e2bf69bb0da67c83661524997af2 (patch)
treec39e0ddddb11423e959ab119ea81998831694371 /src/transport/gnunet-service-transport_manipulation.c
parentcc3c044d1d00227473409f3125fc6a1bb90ebf8c (diff)
downloadgnunet-0f8b8d96afa2e2bf69bb0da67c83661524997af2.tar.gz
gnunet-0f8b8d96afa2e2bf69bb0da67c83661524997af2.zip
fixed delay manipulation
Diffstat (limited to 'src/transport/gnunet-service-transport_manipulation.c')
-rw-r--r--src/transport/gnunet-service-transport_manipulation.c72
1 files changed, 35 insertions, 37 deletions
diff --git a/src/transport/gnunet-service-transport_manipulation.c b/src/transport/gnunet-service-transport_manipulation.c
index dbfa89e12..c03456903 100644
--- a/src/transport/gnunet-service-transport_manipulation.c
+++ b/src/transport/gnunet-service-transport_manipulation.c
@@ -55,22 +55,22 @@ struct GST_ManipulationHandle
55 /** 55 /**
56 * General inbound delay 56 * General inbound delay
57 */ 57 */
58 struct GNUNET_TIME_Relative delay_in; 58 struct GNUNET_TIME_Relative delay_recv;
59 59
60 /** 60 /**
61 * General outbound delay 61 * General outbound delay
62 */ 62 */
63 struct GNUNET_TIME_Relative delay_out; 63 struct GNUNET_TIME_Relative delay_send;
64 64
65 /** 65 /**
66 * General inbound distance 66 * General inbound distance
67 */ 67 */
68 unsigned long long distance_in; 68 unsigned long long distance_recv;
69 69
70 /** 70 /**
71 * General outbound distance 71 * General outbound distance
72 */ 72 */
73 unsigned long long distance_out; 73 unsigned long long distance_send;
74 74
75}; 75};
76 76
@@ -210,14 +210,16 @@ GST_manipulation_set_metric (void *cls, struct GNUNET_SERVER_Client *client,
210 210
211 switch (type) { 211 switch (type) {
212 case GNUNET_ATS_QUALITY_NET_DELAY: 212 case GNUNET_ATS_QUALITY_NET_DELAY:
213
214 if ((TM_RECEIVE == direction) || (TM_BOTH == direction)) 213 if ((TM_RECEIVE == direction) || (TM_BOTH == direction))
215 man_handle.delay_in.rel_value = value; 214 man_handle.delay_recv.rel_value = value;
216 if ((TM_SEND == direction) || (TM_BOTH == direction)) 215 if ((TM_SEND == direction) || (TM_BOTH == direction))
217 man_handle.delay_out.rel_value = value; 216 man_handle.delay_send.rel_value = value;
218 break; 217 break;
219 case GNUNET_ATS_QUALITY_NET_DISTANCE: 218 case GNUNET_ATS_QUALITY_NET_DISTANCE:
220 219 if ((TM_RECEIVE == direction) || (TM_BOTH == direction))
220 man_handle.distance_recv = value;
221 if ((TM_SEND == direction) || (TM_BOTH == direction))
222 man_handle.distance_send = value;
221 break; 223 break;
222 default: 224 default:
223 break; 225 break;
@@ -318,10 +320,10 @@ GST_manipulation_send (const struct GNUNET_PeerIdentity *target, const void *msg
318 return; 320 return;
319 } 321 }
320 } 322 }
321 else if (man_handle.delay_out.rel_value != 0) 323 else if (man_handle.delay_send.rel_value != 0)
322 { 324 {
323 /* We have a delay */ 325 /* We have a delay */
324 delay = man_handle.delay_out; 326 delay = man_handle.delay_send;
325 dqe = GNUNET_malloc (sizeof (struct DelayQueueEntry) + msg_size); 327 dqe = GNUNET_malloc (sizeof (struct DelayQueueEntry) + msg_size);
326 dqe->tmp = tmp; 328 dqe->tmp = tmp;
327 dqe->sent_at = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), delay); 329 dqe->sent_at = GNUNET_TIME_absolute_add (GNUNET_TIME_absolute_get(), delay);
@@ -349,35 +351,30 @@ GST_manipulation_recv (void *cls,
349 const char *sender_address, 351 const char *sender_address,
350 uint16_t sender_address_len) 352 uint16_t sender_address_len)
351{ 353{
352 return GST_receive_callback (cls, peer, message,
353 session, sender_address, sender_address_len);
354
355/* FIXME */
356#if 0
357 struct TM_Peer *tmp; 354 struct TM_Peer *tmp;
358 int d; 355 //int d;
359 struct GNUNET_ATS_Information ats_new[ats_count]; 356 //struct GNUNET_ATS_Information ats_new[ats_count];
360 struct GNUNET_TIME_Relative quota_delay; 357 struct GNUNET_TIME_Relative quota_delay;
361 struct GNUNET_TIME_Relative m_delay; 358 struct GNUNET_TIME_Relative m_delay;
362 359
363 360 if (man_handle.delay_recv.rel_value > GNUNET_TIME_UNIT_ZERO.rel_value)
364 361 m_delay = man_handle.delay_recv; /* Global delay */
365 if (man_handle.delay_in.rel_value > GNUNET_TIME_UNIT_ZERO.rel_value)
366 m_delay = man_handle.delay_in; /* Global delay */
367 else 362 else
368 m_delay = GNUNET_TIME_UNIT_ZERO; 363 m_delay = GNUNET_TIME_UNIT_ZERO;
369 364
370 365#if 0
371 for (d = 0; d < ats_count; d++) 366 for (d = 0; d < ats_count; d++)
372 { 367 {
373 ats_new[d] = ats[d]; 368 ats_new[d] = ats[d];
374 if ((ntohl(ats[d].type) == GNUNET_ATS_QUALITY_NET_DISTANCE) && 369 if ((ntohl(ats[d].type) == GNUNET_ATS_QUALITY_NET_DISTANCE) &&
375 (man_handle.distance_in > 0)) 370 (man_handle.distance_recv > 0))
376 ats_new[d].value = htonl(man_handle.distance_in); /* Global inbound distance */ 371 ats_new[d].value = htonl(man_handle.distance_recv); /* Global inbound distance */
377 } 372 }
373#endif
378 374
379 if (NULL != (tmp = GNUNET_CONTAINER_multihashmap_get (man_handle.peers, &peer->hashPubKey))) 375 if (NULL != (tmp = GNUNET_CONTAINER_multihashmap_get (man_handle.peers, &peer->hashPubKey)))
380 { 376 {
377#if 0
381 /* Manipulate distance */ 378 /* Manipulate distance */
382 for (d = 0; d < ats_count; d++) 379 for (d = 0; d < ats_count; d++)
383 { 380 {
@@ -387,6 +384,7 @@ GST_manipulation_recv (void *cls,
387 (UINT32_MAX != tmp->metrics[TM_RECEIVE][DISTANCE])) 384 (UINT32_MAX != tmp->metrics[TM_RECEIVE][DISTANCE]))
388 ats_new[d].value = htonl(tmp->metrics[TM_RECEIVE][DISTANCE]); 385 ats_new[d].value = htonl(tmp->metrics[TM_RECEIVE][DISTANCE]);
389 } 386 }
387#endif
390 /* Manipulate receive delay */ 388 /* Manipulate receive delay */
391 if (UINT32_MAX != tmp->metrics[TM_RECEIVE][DELAY]) 389 if (UINT32_MAX != tmp->metrics[TM_RECEIVE][DELAY])
392 m_delay.rel_value = tmp->metrics[TM_RECEIVE][DELAY]; /* Peer specific delay */ 390 m_delay.rel_value = tmp->metrics[TM_RECEIVE][DELAY]; /* Peer specific delay */
@@ -398,7 +396,7 @@ GST_manipulation_recv (void *cls,
398 return quota_delay; 396 return quota_delay;
399 else 397 else
400 return m_delay; 398 return m_delay;
401#endif 399
402} 400}
403 401
404void 402void
@@ -406,32 +404,32 @@ GST_manipulation_init (const struct GNUNET_CONFIGURATION_Handle *GST_cfg)
406{ 404{
407 405
408 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg, 406 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg,
409 "transport", "MANIPULATE_DISTANCE_IN", &man_handle.distance_in)) 407 "transport", "MANIPULATE_DISTANCE_IN", &man_handle.distance_recv))
410 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Setting inbound distance_in to %u\n", 408 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Setting inbound distance_in to %u\n",
411 (unsigned long long) man_handle.distance_in); 409 (unsigned long long) man_handle.distance_recv);
412 else 410 else
413 man_handle.distance_in = 0; 411 man_handle.distance_recv = 0;
414 412
415 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg, 413 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_number (GST_cfg,
416 "transport", "MANIPULATE_DISTANCE_OUT", &man_handle.distance_out)) 414 "transport", "MANIPULATE_DISTANCE_OUT", &man_handle.distance_send))
417 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Setting outbound distance_in to %u\n", 415 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Setting outbound distance_in to %u\n",
418 (unsigned long long) man_handle.distance_out); 416 (unsigned long long) man_handle.distance_send);
419 else 417 else
420 man_handle.distance_out = 0; 418 man_handle.distance_send = 0;
421 419
422 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (GST_cfg, 420 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (GST_cfg,
423 "transport", "MANIPULATE_DELAY_IN", &man_handle.delay_in)) 421 "transport", "MANIPULATE_DELAY_IN", &man_handle.delay_recv))
424 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Delaying inbound traffic for %llu ms\n", 422 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Delaying inbound traffic for %llu ms\n",
425 (unsigned long long) man_handle.delay_in.rel_value); 423 (unsigned long long) man_handle.delay_recv.rel_value);
426 else 424 else
427 man_handle.delay_in.rel_value = 0; 425 man_handle.delay_recv.rel_value = 0;
428 426
429 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (GST_cfg, 427 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_time (GST_cfg,
430 "transport", "MANIPULATE_DELAY_OUT", &man_handle.delay_out)) 428 "transport", "MANIPULATE_DELAY_OUT", &man_handle.delay_send))
431 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Delaying outbound traffic for %llu ms\n", 429 GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Delaying outbound traffic for %llu ms\n",
432 (unsigned long long) man_handle.delay_out.rel_value); 430 (unsigned long long) man_handle.delay_send.rel_value);
433 else 431 else
434 man_handle.delay_out.rel_value = 0; 432 man_handle.delay_send.rel_value = 0;
435 433
436 man_handle.peers = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO); 434 man_handle.peers = GNUNET_CONTAINER_multihashmap_create (10, GNUNET_NO);
437} 435}