aboutsummaryrefslogtreecommitdiff
path: root/src/setu/gnunet-service-setu.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/setu/gnunet-service-setu.c')
-rw-r--r--src/setu/gnunet-service-setu.c110
1 files changed, 105 insertions, 5 deletions
diff --git a/src/setu/gnunet-service-setu.c b/src/setu/gnunet-service-setu.c
index fb4c9c258..5799908ba 100644
--- a/src/setu/gnunet-service-setu.c
+++ b/src/setu/gnunet-service-setu.c
@@ -407,14 +407,14 @@ struct Operation
407 double rtt_bandwidth_tradeoff; 407 double rtt_bandwidth_tradeoff;
408 408
409 /** 409 /**
410 * Number of Element per bucket 410 * Number of Element per bucket in IBF
411 */ 411 */
412 unsigned int number_buckets_per_element; 412 unsigned int ibf_number_buckets_per_element;
413 413
414 /** 414 /**
415 * Number of buckets 415 * Number of buckets in IBF
416 */ 416 */
417 unsigned bucket_number; 417 unsigned ibf_bucket_number;
418 418
419}; 419};
420 420
@@ -637,6 +637,68 @@ static uint32_t suggest_id;
637 637
638 638
639/** 639/**
640 * Added Roundtripscounter
641 */
642
643
644struct perf_num_send_resived_msg {
645 int sent;
646 int received;
647};
648
649
650struct perf_rtt_struct
651{
652 struct perf_num_send_resived_msg operation_request;
653 struct perf_num_send_resived_msg se;
654 struct perf_num_send_resived_msg request_full;
655 struct perf_num_send_resived_msg element_full;
656 struct perf_num_send_resived_msg full_done;
657 struct perf_num_send_resived_msg ibf;
658 struct perf_num_send_resived_msg inquery;
659 struct perf_num_send_resived_msg element;
660 struct perf_num_send_resived_msg demand;
661 struct perf_num_send_resived_msg offer;
662 struct perf_num_send_resived_msg done;
663 struct perf_num_send_resived_msg over;
664};
665
666struct perf_rtt_struct perf_rtt;
667
668
669static float
670calculate_perf_rtt() {
671 /**
672 * Calculate RTT of init phase normally always 1
673 */
674 float rtt = 1;
675
676 /**
677 * Calculate RRT of Fullsync normaly 1 or 1.5 depending
678 */
679 if (( perf_rtt.element_full.received != 0 ) ||
680 ( perf_rtt.element_full.sent != 0)
681 ) rtt += 1;
682
683 if (( perf_rtt.request_full.received != 0 ) ||
684 ( perf_rtt.request_full.sent != 0)
685 ) rtt += 0.5;
686
687 /**
688 * In case of a differential sync 3 rtt's are needed.
689 * for every active/passive switch additional 3.5 rtt's are used
690 */
691
692 float iterations = perf_rtt.ibf.received;
693 if(iterations > 1)
694 rtt += (iterations - 1 ) * 0.5;
695 rtt += 3 * iterations;
696
697 return rtt;
698}
699
700
701/**
640 * Iterator over hash map entries, called to 702 * Iterator over hash map entries, called to
641 * destroy the linked list of colliding ibf key entries. 703 * destroy the linked list of colliding ibf key entries.
642 * 704 *
@@ -1226,6 +1288,7 @@ send_ibf (struct Operation *op,
1226 if (buckets_in_message > MAX_BUCKETS_PER_MESSAGE) 1288 if (buckets_in_message > MAX_BUCKETS_PER_MESSAGE)
1227 buckets_in_message = MAX_BUCKETS_PER_MESSAGE; 1289 buckets_in_message = MAX_BUCKETS_PER_MESSAGE;
1228 1290
1291 perf_rtt.ibf.sent += 1;
1229 ev = GNUNET_MQ_msg_extra (msg, 1292 ev = GNUNET_MQ_msg_extra (msg,
1230 buckets_in_message * IBF_BUCKET_SIZE, 1293 buckets_in_message * IBF_BUCKET_SIZE,
1231 GNUNET_MESSAGE_TYPE_SETU_P2P_IBF); 1294 GNUNET_MESSAGE_TYPE_SETU_P2P_IBF);
@@ -1297,6 +1360,7 @@ send_full_element_iterator (void *cls,
1297 LOG (GNUNET_ERROR_TYPE_DEBUG, 1360 LOG (GNUNET_ERROR_TYPE_DEBUG,
1298 "Sending element %s\n", 1361 "Sending element %s\n",
1299 GNUNET_h2s (key)); 1362 GNUNET_h2s (key));
1363 perf_rtt.element_full.received += 1;
1300 ev = GNUNET_MQ_msg_extra (emsg, 1364 ev = GNUNET_MQ_msg_extra (emsg,
1301 el->size, 1365 el->size,
1302 GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_ELEMENT); 1366 GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_ELEMENT);
@@ -1328,6 +1392,7 @@ send_full_set (struct Operation *op)
1328 (void) GNUNET_CONTAINER_multihashmap_iterate (op->set->content->elements, 1392 (void) GNUNET_CONTAINER_multihashmap_iterate (op->set->content->elements,
1329 &send_full_element_iterator, 1393 &send_full_element_iterator,
1330 op); 1394 op);
1395 perf_rtt.full_done.sent += 1;
1331 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_DONE); 1396 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_DONE);
1332 GNUNET_MQ_send (op->mq, 1397 GNUNET_MQ_send (op->mq,
1333 ev); 1398 ev);
@@ -1376,6 +1441,7 @@ static void
1376handle_union_p2p_strata_estimator (void *cls, 1441handle_union_p2p_strata_estimator (void *cls,
1377 const struct StrataEstimatorMessage *msg) 1442 const struct StrataEstimatorMessage *msg)
1378{ 1443{
1444 perf_rtt.se.received += 1;
1379 struct Operation *op = cls; 1445 struct Operation *op = cls;
1380 struct StrataEstimator *remote_se; 1446 struct StrataEstimator *remote_se;
1381 unsigned int diff; 1447 unsigned int diff;
@@ -1447,6 +1513,9 @@ handle_union_p2p_strata_estimator (void *cls,
1447 return; 1513 return;
1448 } 1514 }
1449 1515
1516 /**
1517 * Added rtt_bandwidth_tradeoff directly need future improvements
1518 */
1450 if ((GNUNET_YES == op->force_full) || 1519 if ((GNUNET_YES == op->force_full) ||
1451 (diff > op->initial_size / 4) || 1520 (diff > op->initial_size / 4) ||
1452 (0 == other_size)) 1521 (0 == other_size))
@@ -1471,6 +1540,7 @@ handle_union_p2p_strata_estimator (void *cls,
1471 LOG (GNUNET_ERROR_TYPE_DEBUG, 1540 LOG (GNUNET_ERROR_TYPE_DEBUG,
1472 "Telling other peer that we expect its full set\n"); 1541 "Telling other peer that we expect its full set\n");
1473 op->phase = PHASE_FULL_RECEIVING; 1542 op->phase = PHASE_FULL_RECEIVING;
1543 perf_rtt.request_full.sent += 1;
1474 ev = GNUNET_MQ_msg_header ( 1544 ev = GNUNET_MQ_msg_header (
1475 GNUNET_MESSAGE_TYPE_SETU_P2P_REQUEST_FULL); 1545 GNUNET_MESSAGE_TYPE_SETU_P2P_REQUEST_FULL);
1476 GNUNET_MQ_send (op->mq, 1546 GNUNET_MQ_send (op->mq,
@@ -1520,6 +1590,7 @@ send_offers_iterator (void *cls,
1520 if (ke->ibf_key.key_val != sec->ibf_key.key_val) 1590 if (ke->ibf_key.key_val != sec->ibf_key.key_val)
1521 return GNUNET_YES; 1591 return GNUNET_YES;
1522 1592
1593 perf_rtt.offer.sent += 1;
1523 ev = GNUNET_MQ_msg_header_extra (mh, 1594 ev = GNUNET_MQ_msg_header_extra (mh,
1524 sizeof(struct GNUNET_HashCode), 1595 sizeof(struct GNUNET_HashCode),
1525 GNUNET_MESSAGE_TYPE_SETU_P2P_OFFER); 1596 GNUNET_MESSAGE_TYPE_SETU_P2P_OFFER);
@@ -1675,6 +1746,8 @@ decode_and_send (struct Operation *op)
1675 1746
1676 LOG (GNUNET_ERROR_TYPE_DEBUG, 1747 LOG (GNUNET_ERROR_TYPE_DEBUG,
1677 "transmitted all values, sending DONE\n"); 1748 "transmitted all values, sending DONE\n");
1749
1750 perf_rtt.done.sent += 1;
1678 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SETU_P2P_DONE); 1751 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SETU_P2P_DONE);
1679 GNUNET_MQ_send (op->mq, ev); 1752 GNUNET_MQ_send (op->mq, ev);
1680 /* We now wait until we get a DONE message back 1753 /* We now wait until we get a DONE message back
@@ -1697,6 +1770,7 @@ decode_and_send (struct Operation *op)
1697 struct GNUNET_MQ_Envelope *ev; 1770 struct GNUNET_MQ_Envelope *ev;
1698 struct InquiryMessage *msg; 1771 struct InquiryMessage *msg;
1699 1772
1773 perf_rtt.inquery.sent += 1;
1700 /* It may be nice to merge multiple requests, but with CADET's corking it is not worth 1774 /* It may be nice to merge multiple requests, but with CADET's corking it is not worth
1701 * the effort additional complexity. */ 1775 * the effort additional complexity. */
1702 ev = GNUNET_MQ_msg_extra (msg, 1776 ev = GNUNET_MQ_msg_extra (msg,
@@ -1796,6 +1870,7 @@ handle_union_p2p_ibf (void *cls,
1796 struct Operation *op = cls; 1870 struct Operation *op = cls;
1797 unsigned int buckets_in_message; 1871 unsigned int buckets_in_message;
1798 1872
1873 perf_rtt.ibf.received += 1;
1799 buckets_in_message = (ntohs (msg->header.size) - sizeof *msg) 1874 buckets_in_message = (ntohs (msg->header.size) - sizeof *msg)
1800 / IBF_BUCKET_SIZE; 1875 / IBF_BUCKET_SIZE;
1801 if ((op->phase == PHASE_PASSIVE_DECODING) || 1876 if ((op->phase == PHASE_PASSIVE_DECODING) ||
@@ -1924,6 +1999,7 @@ maybe_finish (struct Operation *op)
1924 struct GNUNET_MQ_Envelope *ev; 1999 struct GNUNET_MQ_Envelope *ev;
1925 2000
1926 op->phase = PHASE_FINISHED; 2001 op->phase = PHASE_FINISHED;
2002 perf_rtt.done.sent += 1;
1927 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SETU_P2P_DONE); 2003 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SETU_P2P_DONE);
1928 GNUNET_MQ_send (op->mq, 2004 GNUNET_MQ_send (op->mq,
1929 ev); 2005 ev);
@@ -1984,6 +2060,7 @@ handle_union_p2p_elements (void *cls,
1984 struct KeyEntry *ke; 2060 struct KeyEntry *ke;
1985 uint16_t element_size; 2061 uint16_t element_size;
1986 2062
2063 perf_rtt.element.received += 1;
1987 element_size = ntohs (emsg->header.size) - sizeof(struct 2064 element_size = ntohs (emsg->header.size) - sizeof(struct
1988 GNUNET_SETU_ElementMessage); 2065 GNUNET_SETU_ElementMessage);
1989 ee = GNUNET_malloc (sizeof(struct ElementEntry) + element_size); 2066 ee = GNUNET_malloc (sizeof(struct ElementEntry) + element_size);
@@ -2095,6 +2172,8 @@ handle_union_p2p_full_element (void *cls,
2095 struct KeyEntry *ke; 2172 struct KeyEntry *ke;
2096 uint16_t element_size; 2173 uint16_t element_size;
2097 2174
2175 perf_rtt.element_full.received += 1;
2176
2098 2177
2099 if(PHASE_EXPECT_IBF == op->phase) { 2178 if(PHASE_EXPECT_IBF == op->phase) {
2100 op->phase = PHASE_FULL_RECEIVING; 2179 op->phase = PHASE_FULL_RECEIVING;
@@ -2229,6 +2308,8 @@ handle_union_p2p_inquiry (void *cls,
2229 const struct IBF_Key *ibf_key; 2308 const struct IBF_Key *ibf_key;
2230 unsigned int num_keys; 2309 unsigned int num_keys;
2231 2310
2311 perf_rtt.inquery.received += 1;
2312
2232 LOG (GNUNET_ERROR_TYPE_DEBUG, 2313 LOG (GNUNET_ERROR_TYPE_DEBUG,
2233 "Received union inquiry\n"); 2314 "Received union inquiry\n");
2234 num_keys = (ntohs (msg->header.size) - sizeof(struct InquiryMessage)) 2315 num_keys = (ntohs (msg->header.size) - sizeof(struct InquiryMessage))
@@ -2272,6 +2353,7 @@ send_missing_full_elements_iter (void *cls,
2272 2353
2273 if (GNUNET_YES == ke->received) 2354 if (GNUNET_YES == ke->received)
2274 return GNUNET_YES; 2355 return GNUNET_YES;
2356 perf_rtt.element_full.received += 1;
2275 ev = GNUNET_MQ_msg_extra (emsg, 2357 ev = GNUNET_MQ_msg_extra (emsg,
2276 ee->element.size, 2358 ee->element.size,
2277 GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_ELEMENT); 2359 GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_ELEMENT);
@@ -2297,7 +2379,9 @@ handle_union_p2p_request_full (void *cls,
2297{ 2379{
2298 struct Operation *op = cls; 2380 struct Operation *op = cls;
2299 2381
2300 LOG (GNUNET_ERROR_TYPE_DEBUG, 2382 perf_rtt.request_full.received += 1;
2383
2384 LOG (GNUNET_ERROR_TYPE_DEBUG,
2301 "Received request for full set transmission\n"); 2385 "Received request for full set transmission\n");
2302 if (PHASE_EXPECT_IBF != op->phase) 2386 if (PHASE_EXPECT_IBF != op->phase)
2303 { 2387 {
@@ -2325,6 +2409,8 @@ handle_union_p2p_full_done (void *cls,
2325{ 2409{
2326 struct Operation *op = cls; 2410 struct Operation *op = cls;
2327 2411
2412 perf_rtt.full_done.received += 1;
2413
2328 switch (op->phase) 2414 switch (op->phase)
2329 { 2415 {
2330 case PHASE_FULL_RECEIVING: 2416 case PHASE_FULL_RECEIVING:
@@ -2338,6 +2424,7 @@ handle_union_p2p_full_done (void *cls,
2338 GNUNET_CONTAINER_multihashmap32_iterate (op->key_to_element, 2424 GNUNET_CONTAINER_multihashmap32_iterate (op->key_to_element,
2339 &send_missing_full_elements_iter, 2425 &send_missing_full_elements_iter,
2340 op); 2426 op);
2427 perf_rtt.full_done.sent += 1;
2341 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_DONE); 2428 ev = GNUNET_MQ_msg_header (GNUNET_MESSAGE_TYPE_SETU_P2P_FULL_DONE);
2342 GNUNET_MQ_send (op->mq, 2429 GNUNET_MQ_send (op->mq,
2343 ev); 2430 ev);
@@ -2416,6 +2503,8 @@ handle_union_p2p_demand (void *cls,
2416 unsigned int num_hashes; 2503 unsigned int num_hashes;
2417 struct GNUNET_MQ_Envelope *ev; 2504 struct GNUNET_MQ_Envelope *ev;
2418 2505
2506 perf_rtt.demand.received += 1;
2507
2419 num_hashes = (ntohs (mh->size) - sizeof(struct GNUNET_MessageHeader)) 2508 num_hashes = (ntohs (mh->size) - sizeof(struct GNUNET_MessageHeader))
2420 / sizeof(struct GNUNET_HashCode); 2509 / sizeof(struct GNUNET_HashCode);
2421 for (hash = (const struct GNUNET_HashCode *) &mh[1]; 2510 for (hash = (const struct GNUNET_HashCode *) &mh[1];
@@ -2438,6 +2527,7 @@ handle_union_p2p_demand (void *cls,
2438 fail_union_operation (op); 2527 fail_union_operation (op);
2439 return; 2528 return;
2440 } 2529 }
2530 perf_rtt.element.sent += 1;
2441 ev = GNUNET_MQ_msg_extra (emsg, 2531 ev = GNUNET_MQ_msg_extra (emsg,
2442 ee->element.size, 2532 ee->element.size,
2443 GNUNET_MESSAGE_TYPE_SETU_P2P_ELEMENTS); 2533 GNUNET_MESSAGE_TYPE_SETU_P2P_ELEMENTS);
@@ -2513,6 +2603,8 @@ handle_union_p2p_offer (void *cls,
2513 const struct GNUNET_HashCode *hash; 2603 const struct GNUNET_HashCode *hash;
2514 unsigned int num_hashes; 2604 unsigned int num_hashes;
2515 2605
2606 perf_rtt.offer.received += 1;
2607
2516 num_hashes = (ntohs (mh->size) - sizeof(struct GNUNET_MessageHeader)) 2608 num_hashes = (ntohs (mh->size) - sizeof(struct GNUNET_MessageHeader))
2517 / sizeof(struct GNUNET_HashCode); 2609 / sizeof(struct GNUNET_HashCode);
2518 for (hash = (const struct GNUNET_HashCode *) &mh[1]; 2610 for (hash = (const struct GNUNET_HashCode *) &mh[1];
@@ -2548,6 +2640,8 @@ handle_union_p2p_offer (void *cls,
2548 LOG (GNUNET_ERROR_TYPE_DEBUG, 2640 LOG (GNUNET_ERROR_TYPE_DEBUG,
2549 "[OP %p] Requesting element (hash %s)\n", 2641 "[OP %p] Requesting element (hash %s)\n",
2550 op, GNUNET_h2s (hash)); 2642 op, GNUNET_h2s (hash));
2643
2644 perf_rtt.demand.sent += 1;
2551 ev = GNUNET_MQ_msg_header_extra (demands, 2645 ev = GNUNET_MQ_msg_header_extra (demands,
2552 sizeof(struct GNUNET_HashCode), 2646 sizeof(struct GNUNET_HashCode),
2553 GNUNET_MESSAGE_TYPE_SETU_P2P_DEMAND); 2647 GNUNET_MESSAGE_TYPE_SETU_P2P_DEMAND);
@@ -2572,6 +2666,7 @@ handle_union_p2p_done (void *cls,
2572{ 2666{
2573 struct Operation *op = cls; 2667 struct Operation *op = cls;
2574 2668
2669 perf_rtt.done.received += 1;
2575 switch (op->phase) 2670 switch (op->phase)
2576 { 2671 {
2577 case PHASE_PASSIVE_DECODING: 2672 case PHASE_PASSIVE_DECODING:
@@ -2621,6 +2716,7 @@ static void
2621handle_union_p2p_over (void *cls, 2716handle_union_p2p_over (void *cls,
2622 const struct GNUNET_MessageHeader *mh) 2717 const struct GNUNET_MessageHeader *mh)
2623{ 2718{
2719 perf_rtt.over.received += 1;
2624 send_client_done (cls); 2720 send_client_done (cls);
2625} 2721}
2626 2722
@@ -3401,6 +3497,7 @@ handle_client_evaluate (void *cls,
3401 struct GNUNET_MQ_Envelope *ev; 3497 struct GNUNET_MQ_Envelope *ev;
3402 struct OperationRequestMessage *msg; 3498 struct OperationRequestMessage *msg;
3403 3499
3500 perf_rtt.operation_request.sent += 1;
3404 ev = GNUNET_MQ_msg_nested_mh (msg, 3501 ev = GNUNET_MQ_msg_nested_mh (msg,
3405 GNUNET_MESSAGE_TYPE_SETU_P2P_OPERATION_REQUEST, 3502 GNUNET_MESSAGE_TYPE_SETU_P2P_OPERATION_REQUEST,
3406 context); 3503 context);
@@ -3599,6 +3696,7 @@ handle_client_accept (void *cls,
3599 buf = GNUNET_malloc (se->strata_count * IBF_BUCKET_SIZE * se->ibf_size); 3696 buf = GNUNET_malloc (se->strata_count * IBF_BUCKET_SIZE * se->ibf_size);
3600 len = strata_estimator_write (se, 3697 len = strata_estimator_write (se,
3601 buf); 3698 buf);
3699 perf_rtt.se.sent += 1;
3602 if (len < se->strata_count * IBF_BUCKET_SIZE * se->ibf_size) 3700 if (len < se->strata_count * IBF_BUCKET_SIZE * se->ibf_size)
3603 type = GNUNET_MESSAGE_TYPE_SETU_P2P_SEC; 3701 type = GNUNET_MESSAGE_TYPE_SETU_P2P_SEC;
3604 else 3702 else
@@ -3647,6 +3745,8 @@ shutdown_task (void *cls)
3647 GNUNET_YES); 3745 GNUNET_YES);
3648 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3746 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3649 "handled shutdown request\n"); 3747 "handled shutdown request\n");
3748 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
3749 "RTT:%f\n", calculate_perf_rtt());
3650} 3750}
3651 3751
3652 3752