Beispiel #1
0
        public void Test()
        {
            RandomNumberGenerator rng = new RNGCryptoServiceProvider();
            TargetSelector        ts  = new DefaultTargetSelector();

            //in this case we set the current to an address in our list
            for (int i = 0; i < _addr_list.Length; i++)
            {
                AHAddress tmp_addr = new AHAddress(rng);
                _addr_list[i] = tmp_addr;
            }
            _idx = 0;
            for (int i = 0; i < _addr_list.Length; i++)
            {
                ts.ComputeCandidates(new AHAddress(rng), 10, TargetSelectorCallback, _addr_list[i]);
            }

            //in this case we set the current address to null
            for (int i = 0; i < _addr_list.Length; i++)
            {
                AHAddress tmp_addr = new AHAddress(rng);
                _addr_list[i] = tmp_addr;
            }
            _idx = 0;
            for (int i = 0; i < _addr_list.Length; i++)
            {
                ts.ComputeCandidates(_addr_list[i], 10, TargetSelectorCallback, null);
            }
        }
        public StructuredShortcutConnectionOverlord(Node n)
        {
            _sync = new Object();
            lock ( _sync ) {
                _node = n;
#if BRUNET_SIMULATOR
                _rand = Node.SimulatorRandom;
#else
                _rand = new Random();
#endif
                _last_connection_time = DateTime.UtcNow;

                /**
                 * Every heartbeat we assess the trimming situation.
                 * If we have excess edges and it has been more than
                 * _trim_wait_time heartbeats then we trim.
                 */
                _last_retry_time        = DateTime.UtcNow;
                _current_retry_interval = _DEFAULT_RETRY_INTERVAL;

                /**
                 * Information related to the target selector feature.
                 * Includes statistics such as trim rate and connection lifetimes.
                 */

                _target_selector    = new DefaultTargetSelector();
                _last_optimize_time = DateTime.UtcNow;
                _sum_con_lifetime   = 0.0;
                _start_time         = DateTime.UtcNow;
                _trim_count         = 0;
                _shortcuts          = 0;

                /*
                 * Register event handlers after everything else is set
                 */
                //Listen for connection events:
                _node.ConnectionTable.DisconnectionEvent += DisconnectHandler;
                _node.ConnectionTable.ConnectionEvent    += ConnectHandler;

                _node.HeartBeatEvent += CheckState;
                _node.HeartBeatEvent += CheckConnectionOptimality;
            }
        }
    public StructuredShortcutConnectionOverlord(Node n)
    {
      _sync = new Object();
      lock( _sync ) {
        _node = n;
#if BRUNET_SIMULATOR
        _rand = Node.SimulatorRandom;
#else
        _rand = new Random();
#endif
        _last_connection_time = DateTime.UtcNow;
      /**
       * Every heartbeat we assess the trimming situation.
       * If we have excess edges and it has been more than
       * _trim_wait_time heartbeats then we trim.
       */
        _last_retry_time = DateTime.UtcNow;
        _current_retry_interval = _DEFAULT_RETRY_INTERVAL;

        /**
         * Information related to the target selector feature.
         * Includes statistics such as trim rate and connection lifetimes.
         */
        
        _target_selector = new DefaultTargetSelector();
        _last_optimize_time = DateTime.UtcNow;
        _sum_con_lifetime = 0.0;
        _start_time = DateTime.UtcNow;
        _trim_count = 0;
        _shortcuts = 0;

        /*
         * Register event handlers after everything else is set
         */
        //Listen for connection events:
        _node.ConnectionTable.DisconnectionEvent += DisconnectHandler;
        _node.ConnectionTable.ConnectionEvent += ConnectHandler;
        
        _node.HeartBeatEvent += CheckState;
        _node.HeartBeatEvent += CheckConnectionOptimality;
      }
    }
Beispiel #4
0
    public void Test() {
      RandomNumberGenerator rng = new RNGCryptoServiceProvider();
      TargetSelector ts = new DefaultTargetSelector();
      //in this case we set the current to an address in our list
      for (int i = 0; i < _addr_list.Length; i++ ) {
        AHAddress tmp_addr = new AHAddress(rng);
        _addr_list[i] = tmp_addr;
      }
      _idx = 0;
      for (int i = 0; i < _addr_list.Length; i++ ) {
        ts.ComputeCandidates(new AHAddress(rng), 10, TargetSelectorCallback, _addr_list[i]);
      }

      //in this case we set the current address to null
      for (int i = 0; i < _addr_list.Length; i++ ) {
        AHAddress tmp_addr = new AHAddress(rng);
        _addr_list[i] = tmp_addr;
      }
      _idx = 0;
      for (int i = 0; i < _addr_list.Length; i++ ) {
        ts.ComputeCandidates(_addr_list[i], 10, TargetSelectorCallback, null);
      }
    }