public void Increment(Address dest) {
      // Sample every 1 / SAMPLE_SIZE
      if( _rand.Next(SAMPLE_SIZE) != 0 ) {
        return;
      }


      lock(_sync) {
        NodeRankInformation node_rank =
          (NodeRankInformation) _dest_to_node_rank[dest];
        if( node_rank == null ) {
          node_rank = new NodeRankInformation(dest);
          _node_rank_list.Add( node_rank );
          _dest_to_node_rank[dest] = node_rank;
        }
        // Increment by SAMPLE_SIZE
        node_rank.Count += SAMPLE_SIZE;
      }
    }
Esempio n. 2
0
    /**
     * We count incoming IP packets here
     */
    public void HandleData(MemBlock p, ISender from, object state) {
      AHSender ahs = from as AHSender;
      if( ahs == null ) {
        return;
      }

      // Sample every 1 / SAMPLE_SIZE
      if( _rand.Next(SAMPLE_SIZE) != 0 ) {
        return;
      }

      Address dest = ahs.Destination;

      lock(_sync) {
        NodeRankInformation node_rank =
          (NodeRankInformation) _dest_to_node_rank[dest];
        if( node_rank == null ) {
          node_rank = new NodeRankInformation(dest);
          _node_rank_list.Add( node_rank );
          _dest_to_node_rank[dest] = node_rank;
        }
        // Increment by SAMPLE_SIZE
        node_rank.Count += SAMPLE_SIZE;
      }
    }