C# Class Ipop.Dht.DhtAddressResolver

This class provides a method to do address resolution over the Brunet Dht, where entries are listed in the dht by means of the DhtDHCPServer.
Inheritance: IAddressResolver
Mostrar archivo Open project: pstjuste/brunet Class Usage Examples

Protected Properties

Property Type Description
_attempts int>.Dictionary
_dht IDht
_incoming_cache Address>.TimeBasedCache
_ipop_namespace string
_mapping MemBlock>.Dictionary
_queued bool>.Dictionary
_sync Object
_verified_cache Address>.TimeBasedCache

Public Methods

Method Description
Check ( MemBlock ip, Brunet.Address addr ) : bool

Is the right person sending me this packet?

DhtAddressResolver ( IDht dht, string ipop_namespace ) : Brunet

Creates a DhtAddressResolver Object.

Resolve ( MemBlock ip ) : Brunet.Address

Translates an IP Address to a Brunet Address. If it is in the cache it returns a result, otherwise it returns null and begins a Miss lookup.

Stop ( ) : void

Stops the timer at which point a new DhtAddressResolver will need to be constructed, if used in the same process.

Protected Methods

Method Description
Miss ( MemBlock ip ) : bool

This is called if the cache's don't have an Address mapping. It prepares an asynchronous Dht query if one doesn't already exist, that is only one query at a time per IP regardless of how many misses occur. The ansychonorous call back is call MissCallback.

MissCallback ( Object o, EventArgs args ) : void

This is the asynchronous callback for Miss. This contains the lookup results from the Dht. If there is a valid mapping it is added to the cache. Either way, new queries can now be run for the IP address after the completion of this method.

Method Details

Check() public method

Is the right person sending me this packet?
public Check ( MemBlock ip, Brunet.Address addr ) : bool
ip MemBlock The IP source.
addr Brunet.Address
return bool

DhtAddressResolver() public method

Creates a DhtAddressResolver Object.
public DhtAddressResolver ( IDht dht, string ipop_namespace ) : Brunet
dht IDht The dht object to use for dht interactions.
ipop_namespace string The ipop namespace where the dhcp server /// is storing names.
return Brunet

Miss() protected method

This is called if the cache's don't have an Address mapping. It prepares an asynchronous Dht query if one doesn't already exist, that is only one query at a time per IP regardless of how many misses occur. The ansychonorous call back is call MissCallback.
protected Miss ( MemBlock ip ) : bool
ip MemBlock The IP Address to look up in the Dht.
return bool

MissCallback() protected method

This is the asynchronous callback for Miss. This contains the lookup results from the Dht. If there is a valid mapping it is added to the cache. Either way, new queries can now be run for the IP address after the completion of this method.
protected MissCallback ( Object o, EventArgs args ) : void
o Object Contains the Channel where the results are stored.
args System.EventArgs Null.
return void

Resolve() public method

Translates an IP Address to a Brunet Address. If it is in the cache it returns a result, otherwise it returns null and begins a Miss lookup.
public Resolve ( MemBlock ip ) : Brunet.Address
ip MemBlock The IP Address to translate.
return Brunet.Address

Stop() public method

Stops the timer at which point a new DhtAddressResolver will need to be constructed, if used in the same process.
public Stop ( ) : void
return void

Property Details

_attempts protected_oe property

Failed query attempts.
protected Dictionary _attempts
return int>.Dictionary

_dht protected_oe property

The dht object to use for dht interactions.
protected IDht _dht
return IDht

_incoming_cache protected_oe property

Cache based upon check calls
protected TimeBasedCache _incoming_cache
return Address>.TimeBasedCache

_ipop_namespace protected_oe property

The ipop namespace where the dhcp server is storing names
protected string _ipop_namespace
return string

_mapping protected_oe property

Maps the Channel in MissCallback to an IP.
protected Dictionary _mapping
return MemBlock>.Dictionary

_queued protected_oe property

Contains which IP Address Misses are pending.
protected Dictionary _queued
return bool>.Dictionary

_sync protected_oe property

A lock synchronizer for the hashtables and cache.
protected Object _sync
return Object

_verified_cache protected_oe property

Cache based upon Dht and thus verified
protected TimeBasedCache _verified_cache
return Address>.TimeBasedCache