当前位置: 首页>>代码示例>>C#>>正文


C# Brunet.Address类代码示例

本文整理汇总了C#中Brunet.Address的典型用法代码示例。如果您正苦于以下问题:C# Address类的具体用法?C# Address怎么用?C# Address使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Address类属于Brunet命名空间,在下文中一共展示了Address类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TargetSelectorCallback

 protected void TargetSelectorCallback(Address start, SortedList score_table, Address current) {
   Assert.IsTrue(score_table.Count > 0);
   if (current == null) {
     Address min_target = (Address) score_table.GetByIndex(0);
     Assert.AreEqual(_addr_list[_idx++], min_target);
   }
 }
开发者ID:xujyan,项目名称:brunet,代码行数:7,代码来源:TargetSelector.cs

示例2: RequestState

 public RequestState(Address start, int range, TargetSelectorDelegate cb, Address current) {
   Start = start;
   Range = range;
   Callback = cb;
   Current = current;
   ResultTable = new Hashtable();
 }
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:7,代码来源:VivaldiTargetSelector.cs

示例3: AHHeader

  public AHHeader(short hops, short ttl, Address source, Address dest, ushort options) {
    //Make the header part:
    byte[] header = new byte[ LENGTH ];
    int offset = 0;
    //Write hops:
    NumberSerializer.WriteShort(hops, header, offset);
    Hops = hops;
    offset += 2;

    NumberSerializer.WriteShort(ttl, header, offset);
    Ttl = ttl;
    offset += 2;
    
    _src = source;
    offset += source.CopyTo(header, offset);

    _dest = dest;
    offset += dest.CopyTo(header, offset);

    Opts = options;
    NumberSerializer.WriteShort((short)options, header, offset);
    offset += 2;

    _data = MemBlock.Reference(header, 0, offset);
  }
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:25,代码来源:AHSender.cs

示例4: SendMessage

 /// <summary>This methods send some ICopyable data to the remote address.
 /// </summary>
 /// <param name="remote_addr">Remote Nodes are referenced by their P2P
 /// Address, typically of type AHAddress.</param>
 /// <param name="data">This is an ICopyable object which contains the data
 /// to send.</param>
 public void SendMessage(Address remote_addr, ICopyable data) {
   // This instantiates a multi-use method to sending to the remote node,
   // though we will only use it once.  It is VERY similar to UDP.
   AHExactSender sender = new AHExactSender(_app_node.Node, remote_addr);
   // This is the process of actually sending the data.
   sender.Send(new CopyList(HW, data));
 }
开发者ID:pstjuste,项目名称:brunet,代码行数:13,代码来源:HelloWorldNodeDataHandler.cs

示例5: AddressInSubjectAltName

    ///<summary>Verify the edge by comparing the address in the certificate to
    ///the one provided in the overlay.</summary>
    public static bool AddressInSubjectAltName(Node node, Edge e, Address addr) {
      SecureEdge se = e as SecureEdge;
      if(se == null) {
        throw new Exception("Invalid edge type!");
      }

      return se.SA.VerifyCertificateBySubjectAltName(addr.ToString());
    }
开发者ID:kyungyonglee,项目名称:BrunetTutorial,代码行数:10,代码来源:EdgeVerification.cs

示例6: ComputeCandidates

 /**
  * Selects an optimal target given a start address, the range starting at that address, and the current address (could be null).
  * If the current address is not null, it is returned as optimal, or else start address is returned.
  * @param start start address of the range.
  * @param range number of candidates
  * @param callback callback function into the caller
  * @param current currently selected optimal
  */
   public override void ComputeCandidates(Address start, int range, TargetSelectorDelegate callback, Address current) {
     SortedList sorted = new SortedList();
     if (current != null) {
       sorted[1.0] = (Address) current;
     } else {
       sorted[1.0] = start;
     }
     callback(start, sorted, current);
   }
开发者ID:xujyan,项目名称:brunet,代码行数:17,代码来源:TargetSelector.cs

示例7: SimulatorCache

 /// Simulator != thread-safe!
 protected static Address SimulatorCache(Address a) {
   int idx = NumberSerializer.ReadInt(a.ToMemBlock(), 0);
   Address tmp = _cache.GetValue(idx);
   if(a.Equals(tmp)) {
     return tmp;
   }
   _cache.Replace(idx, a);
   return a;
 }
开发者ID:pstjuste,项目名称:brunet,代码行数:10,代码来源:AddressParser.cs

示例8: Connection

    /**
     * Prefered constructor for a Connection
     */
    public Connection(Edge e, Address a,
		      string connectiontype,
		      StatusMessage sm, LinkMessage peerlm)
    {
      _e = e;
      _a = a;
      _ct = String.Intern(connectiontype);
      _stat = sm;
      _lm = peerlm;
      _creation_time = DateTime.UtcNow;
      MainType = StringToMainType(_ct);
    }
开发者ID:xujyan,项目名称:brunet,代码行数:15,代码来源:Connection.cs

示例9: Connection

    /**
     * Prefered constructor for a Connection
     */
    public Connection(Edge e, Address a,
		      string connectiontype,
		      StatusMessage sm, LinkMessage peerlm)
    {
      _e = e;
      _a = a;
      _ct = String.Intern(connectiontype);
      _stat = sm;
      _lm = peerlm;
      _creation_time = DateTime.UtcNow;
      MainType = StringToMainType(_ct);
      _as_dict = new WriteOnce<ListDictionary>();
      _sub_type = new WriteOnce<string>();
    }
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:17,代码来源:Connection.cs

示例10: AHHeader

 public AHHeader(short hops, short ttl, Address source, Address dest, ushort options) {
   //Make the header part:
   byte[] header = new byte[ AHPacket.HeaderLength ];
   int offset = 0;
   //Write hops:
   NumberSerializer.WriteShort(hops, header, offset);
   offset += 2;
   NumberSerializer.WriteShort(ttl, header, offset);
   offset += 2;
   offset += source.CopyTo(header, offset);
   offset += dest.CopyTo(header, offset);
   NumberSerializer.WriteShort((short)options, header, offset);
   offset += 2;
   _data = MemBlock.Reference(header, 0, offset);
 }
开发者ID:kyungyonglee,项目名称:BrunetTutorial,代码行数:15,代码来源:AHSender.cs

示例11: CreateInstance

 /**
  * Factory method to reduce memory allocations by caching
  * commonly used NodeInfo objects
  */
 public static NodeInfo CreateInstance(Address a) {
   //Read some of the least significant bytes out,
   //AHAddress all have last bit 0, so we skip the last byte which
   //will have less entropy
   MemBlock mb = a.ToMemBlock();
   ushort idx = (ushort)NumberSerializer.ReadShort(mb, Address.MemSize - 3);
   NodeInfo ni = _mb_cache[idx];
   if( ni != null ) {
     if (a.Equals(ni._address)) {
       return ni;
     }
   }
   ni = new NodeInfo(a);
   _mb_cache[idx] = ni;
   return ni;
 }
开发者ID:xujyan,项目名称:brunet,代码行数:20,代码来源:NodeInfo.cs

示例12: GetString

 private static string GetString(Address target, IEnumerable forwarders) {
   var sb = new System.Text.StringBuilder();
   sb.Append("brunet.tunnel://");
   sb.Append(target.ToString().Substring(12));
   sb.Append("/");
   foreach(object forwarder in forwarders) {
     Address addr = forwarder as Address;
     if(addr == null) {
       addr = (forwarder as Brunet.Connections.Connection).Address;
     }
     sb.Append(addr.ToString().Substring(12,8));
     sb.Append("+");
   }
   if(sb[sb.Length - 1] == '+') {
     sb.Remove(sb.Length - 1, 1);
   }
   return sb.ToString();
 }
开发者ID:hseom,项目名称:hseom_brunet,代码行数:18,代码来源:TunnelTransportAddress.cs

示例13: TunnelTransportAddress

 public TunnelTransportAddress(string s) : base(s) {
   /** String representing the tunnel TA is as follows: brunet.tunnel://A/X1+X2+X3
    *  A: target address
    *  X1, X2, X3: forwarders, each X1, X2 and X3 is actually a slice of the initial few bytes of the address.
    */
   int k = s.IndexOf(":") + 3;
   int k1 = s.IndexOf("/", k);
   byte []addr_t  = Base32.Decode(s.Substring(k, k1 - k)); 
   _target = AddressParser.Parse( MemBlock.Reference(addr_t) );
   k = k1 + 1;
   _forwarders = new List<MemBlock>();
   while (k < s.Length) {
     byte [] addr_prefix = Base32.Decode(s.Substring(k, 8));
     _forwarders.Add(MemBlock.Reference(addr_prefix));
     //jump over the 8 characters and the + sign
     k = k + 9;
   }
   _forwarders.Sort();
 }
开发者ID:hseom,项目名称:hseom_brunet,代码行数:19,代码来源:TunnelTransportAddress.cs

示例14: PacketForwarder

 public PacketForwarder(Node local)
 {
   _n = local;
   _local = _n.Address;
 }
开发者ID:twchoi,项目名称:tmp-brunet-deetoo,代码行数:5,代码来源:PacketForwarder.cs

示例15: ComputeCandidates

    /**
     * Compute candidate scores for a shortcut connection.
     * @param start address computed by the SCO.
     * @param range nunber of candidate nodes.
     * @param cb callback function when candidate scores are available. 
     * @param current current selection of the optimal in the provided range.
     */
    public override void ComputeCandidates(Address start, int range, TargetSelectorDelegate cb, Address current) {
      Channel q = null;
      RequestState rs = null;
      lock(_sync) {
#if VTS_DEBUG
        Console.Error.WriteLine("VTS local: {0}, start: {1}, range: {2}, count: {3}", _node.Address, start, range, _num_requests);
#endif
        if (_num_requests == MAX_REQUESTS) {
          return; //do nothing and return;
        }
        _num_requests++;
        q = new Channel();
        rs = new RequestState(start, range, cb, current);
        _channel_to_state[q] = rs;        
      }
      
      //create a new request state
      ISender s = new ForwardingSender(_node, 
                                       start, 
                                       AHHeader.Options.Greedy, 
                                       new DirectionalAddress(DirectionalAddress.Direction.Left),
                                       (short) range,
                                       AHHeader.Options.Path
                                       );

      q.EnqueueEvent += new EventHandler(EnqueueHandler);
      q.CloseEvent += new EventHandler(CloseHandler);
      RpcManager rpc = _node.Rpc;
      rpc.Invoke(s, q, "ncserver.EchoVivaldiState", new object[]{});
    }
开发者ID:hseom,项目名称:brunet,代码行数:37,代码来源:VivaldiTargetSelector.cs


注:本文中的Brunet.Address类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。