Revision d27d49f4 topology.c

View differences:

topology.c
123 123

  
124 124
static void update_metadata(void) {
125 125
	my_metadata.cb_size = am_i_source() ? 0 : get_cb_size();
126
	my_metadata.cps =  am_i_source() ? 20 : (uint16_t) get_running_offer_threads();
126
	my_metadata.cps =  am_i_source() ? 15 : (uint16_t) get_running_offer_threads();
127 127
	my_metadata.subnet =  subnet;
128 128
	my_metadata.recv_delay = (double) get_receive_delay();
129 129
	my_metadata.capacity = (double) get_capacity();
......
588 588
  return ra;
589 589
}
590 590

  
591
static double get_keep_subnet_root3(const struct nodeID** a){
592
  int his_subnet = get_subnet_of(*a) ;
593
  double ra = NAN;
594
  if (his_subnet == subnet) {
595
          ra = add_noise( 1/cbrt(0.020), alpha_target);
596
  } else if ( ( subnet == 41 && his_subnet == 43 ) || ( subnet == 43 && his_subnet == 41 ) ) {
597
          ra = add_noise( 1/cbrt(0.080), alpha_target);
598
  } else if ( ( subnet == 41 && his_subnet == 44 ) || ( subnet == 44 && his_subnet == 41 ) ) {
599
          ra = add_noise( 1/cbrt(0.120), alpha_target);
600
  } else if ( ( subnet == 41 && his_subnet == 45 ) || ( subnet == 45 && his_subnet == 41 ) ) {
601
          ra = add_noise( 1/cbrt(0.160), alpha_target);
602
  } else if ( ( subnet == 43 && his_subnet == 44 ) || ( subnet == 44 && his_subnet == 43 ) ) {
603
          ra = add_noise( 1/cbrt(0.140), alpha_target);
604
  } else if ( ( subnet == 43 && his_subnet == 45 ) || ( subnet == 45 && his_subnet == 43 ) ) {
605
          ra = add_noise( 1/cbrt(0.240), alpha_target);
606
  } else if ( ( subnet == 44 && his_subnet == 45 ) || ( subnet == 45 && his_subnet == 44 ) ) {
607
          ra = add_noise( 1/cbrt(0.300), alpha_target);
608
  } else if (his_subnet == 40) {
609
           ra = add_noise( 1/cbrt(0.020), alpha_target);
610
  }
611
  dprintf( "subnet rtt: %s %f\n", node_addr(*a), ra);
612
  return ra;
613
}
614

  
615
static double get_keep_subnet_rx_chunks(const struct nodeID** a){
616
  int his_subnet = get_subnet_of(*a) ;
617
  double rx_chunks = get_rx_chunks_of(*a);
618
  double ra = NAN;
619
  if (his_subnet == subnet) {
620
          ra = add_noise( 1/0.020, alpha_target);
621
  } else if ( ( subnet == 41 && his_subnet == 43 ) || ( subnet == 43 && his_subnet == 41 ) ) {
622
          ra = add_noise( 1/0.080, alpha_target);
623
  } else if ( ( subnet == 41 && his_subnet == 44 ) || ( subnet == 44 && his_subnet == 41 ) ) {
624
          ra = add_noise( 1/0.120, alpha_target);
625
  } else if ( ( subnet == 41 && his_subnet == 45 ) || ( subnet == 45 && his_subnet == 41 ) ) {
626
          ra = add_noise( 1/0.160, alpha_target);
627
  } else if ( ( subnet == 43 && his_subnet == 44 ) || ( subnet == 44 && his_subnet == 43 ) ) {
628
          ra = add_noise( 1/0.140, alpha_target);
629
  } else if ( ( subnet == 43 && his_subnet == 45 ) || ( subnet == 45 && his_subnet == 43 ) ) {
630
          ra = add_noise( 1/0.240, alpha_target);
631
  } else if ( ( subnet == 44 && his_subnet == 45 ) || ( subnet == 45 && his_subnet == 44 ) ) {
632
          ra = add_noise( 1/0.300, alpha_target);
633
  } else if (his_subnet == 40) {
634
           ra = add_noise( 1/0.020, alpha_target);
635
  }
636
  dprintf( "subnet rtt: %s %f\n", node_addr(*a), isnan(rx_chunks)? NAN:(rx_chunks/ra));
637
  if isnan(rx_chunks)
638
	return ra;
639
  else 
640
	return (double) (rx_chunks/ra);
641
}
642

  
643

  
591 644
static double get_bw_local2(const struct nodeID** a){
592 645
  double ra = add_noise(get_capacity_of(*a), alpha_target);
593 646
  dprintf( "bw: %s %f\n", node_addr(*a), ra);
......
595 648
}
596 649

  
597 650
static double get_rtt2(const struct nodeID** a){
598
  double ra = (isnan(get_rtt_of(*a)) ? NAN : add_noise((1/get_rtt_of(*a)), alpha_target) );
651
  double rtt = get_rtt_of(*a);
652
  double ra = (isnan(rtt) ? rtt : add_noise(rtt, alpha_target) );
599 653
  dprintf( "rtt2: %s %f\n", node_addr(*a), ra);
600 654
  return ra;
601 655
}
602 656

  
603 657
static double get_rtt_root2(const struct nodeID** a){
604
  double ra = (isnan(get_rtt_of(*a)) ? NAN : add_noise((1/sqrt(get_rtt_of(*a))), alpha_target) );
658
  double rtt = get_rtt_of(*a);
659
  double ra = (isnan(rtt) ? rtt : add_noise((1/sqrt(rtt)), alpha_target) );
605 660
  dprintf( "rtt_root2: %s %f\n", node_addr(*a), ra);
606 661
  return ra;
607 662
}
608 663

  
609 664
static double get_rtt_root3(const struct nodeID** a){
610
  double ra = (isnan(get_rtt_of(*a)) ? NAN : add_noise((1/cbrt(get_rtt_of(*a))), alpha_target) );
665
  double rtt = get_rtt_of(*a);
666
  double ra = (isnan(rtt) ? rtt : add_noise((1/cbrt(rtt)), alpha_target) );
611 667
  dprintf( "rtt_root3: %s %f\n", node_addr(*a), ra);
612 668
  return ra;
613 669
}
614 670

  
615 671
static double get_rx_chunks_rtt(const struct nodeID** a){
616
  double ra = (isnan(get_rtt_of(*a)) || isnan(get_rx_chunks_of(*a)) ? NAN : add_noise(( get_rx_chunks_of(*a) / get_rtt_of(*a) ), alpha_target) );
672
  double rtt = get_rtt_of(*a);
673
  double rx_chunks = get_rx_chunks_of(*a);
674
  double ra = ((isnan(rtt) || isnan(rx_chunks)) ? rx_chunks : add_noise(( rx_chunks / rtt ), alpha_target) );
617 675
  dprintf( "rx_chunks_rtt: %s %f\n", node_addr(*a), ra);
618 676
  return ra;
619 677
}
......
943 1001
    int tmps_size;
944 1002

  
945 1003
    
946
    if ((topo_keep_best) && ((strcmp(topo_keep_best_policy, "W_BW") == 0) || (strcmp(topo_keep_best_policy, "W_RTT") == 0) || (strcmp(topo_keep_best_policy, "W_RTT2") == 0) || (strcmp(topo_keep_best_policy, "W_RTT3") == 0) || (strcmp(topo_keep_best_policy, "W_RX_CHUNKS_RTT") == 0) || (strcmp(topo_keep_best_policy, "W_RTT_TRICK") == 0) || (strcmp(topo_keep_best_policy, "W_RTT_TRICK2") == 0) )) {
1004
    if ((topo_keep_best) && ((strcmp(topo_keep_best_policy, "W_BW") == 0) || (strcmp(topo_keep_best_policy, "W_RTT") == 0) || (strcmp(topo_keep_best_policy, "W_RTT2") == 0) || (strcmp(topo_keep_best_policy, "W_RTT3") == 0) || (strcmp(topo_keep_best_policy, "W_RX_CHUNKS_RTT") == 0) || (strcmp(topo_keep_best_policy, "W_RTT_TRICK") == 0) || (strcmp(topo_keep_best_policy, "W_RTT_TRICK2") == 0) || (strcmp(topo_keep_best_policy, "W_RTT_TRICK3") == 0) || (strcmp(topo_keep_best_policy, "W_RTT_TRICK_RX_CHUNKS") == 0) )) {
947 1005
      peerEvaluateFunction peerevaluate = NULL;
948 1006
      SchedOrdering ordering = SCHED_WEIGHTED;
949 1007
      if (strcmp(topo_keep_best_policy, "W_BW") == 0) {
......
960 1018
	peerevaluate = get_keep_subnet2;
961 1019
      } else if (strcmp(topo_keep_best_policy, "W_RTT_TRICK2") == 0) {
962 1020
	peerevaluate = get_keep_subnet_root2;
1021
      } else if (strcmp(topo_keep_best_policy, "W_RTT_TRICK3") == 0) {
1022
        peerevaluate = get_keep_subnet_root3;
1023
      } else if (strcmp(topo_keep_best_policy, "W_RTT_TRICK_RX_CHUNKS") == 0) {
1024
        peerevaluate = get_keep_subnet_rx_chunks;
963 1025
      }
1026

  
964 1027
      tmps_size = oldids_size;
965 1028
      nidset_select(ordering, oldids, oldids_size, peerevaluate, tmps, &tmps_size);
966 1029
    // select the topo_mem portion of peers to be kept (uniform random)

Also available in: Unified diff