C# Class Ipop.IpopNode

IpopRouter allows Ipop to provide L3 connectivity between multiple domains with only a single instance per site.
Specifically, a user can have 2 remote clusters set up and using only a single instance of Ipop per-site connect the two clusters. Unlike previous versions of Ipop, the advantage are that this does not require any configuration changes to the individual cluster machines, still provides dynamic IP addresses for all nodes in the combined cluster, and allows machines in the same cluster to talk directly with each other.
Inheritance: Brunet.Applications.BasicNode, IDataHandler, IRpcHandler
ファイルを表示 Open project: pstjuste/brunet Class Usage Examples

Public Properties

Property Type Description
AppNode Brunet.Applications.ApplicationNode
Ethernet Ethernet
Info Brunet.Applications.Information
PublicInfo Brunet.Applications.Information
PublicNode Brunet.Applications.ApplicationNode

Protected Properties

Property Type Description
_address_resolver IAddressResolver
_broadcast bool
_checked_out System.Collections.Hashtable
_conn_handler ConnectionHandler
_dhcp_client_port int
_dhcp_config DHCPConfig
_dhcp_server Ipop.DhcpServer
_dhcp_server_port int
_dns Dns
_ether_to_dhcp_server DhcpServer>.Dictionary
_ether_to_ip MemBlock>.Dictionary
_ip_to_ether MemBlock>.Dictionary
_ipop_config IpopConfig
_last_check_node System.DateTime
_lock int
_multicast bool
_static_dhcp_server Ipop.DhcpServer
_static_mapping SimpleTimer>.Dictionary
_sync object
_translator ITranslator

Public Methods

Method Description
CalculateNetmaskCidr ( string netmask ) : int

Converts from a.b.c.d to the number of 1s in a.b.c.d (CIDR notation).

HandleData ( MemBlock b, ISender ret, object state ) : void

This method handles all incoming packets into the IpopNode, both abroad and local. This is done to reduce unnecessary extra classes and circular dependencies. This method probably shouldn't be called directly.

HandleIPIn ( MemBlock packet, ISender ret ) : void

This method handles IPPackets that come from Brunet, i.e., abroad.

HandleRpc ( ISender caller, string method, IList args, object rs ) : void
IpopNode ( NodeConfig node_config, IpopConfig ipop_config, DHCPConfig dhcp_config ) : Brunet

Creates an IpopNode given a NodeConfig and an IpopConfig. Also sets up the Information, Ethernet device, and subscribes to Brunet for IP Packets

Run ( ) : void

Starts the execution of the IpopNode, this passes the caller to execute the Brunet.Connect to eventually become Brunet.AnnounceThread.

Protected Methods

Method Description
CheckInDhcpServer ( Ipop.DhcpServer dhcp_server ) : void

The request on the IP allocation space (DHT) has returned. So we're done with the server.

CheckNode ( object o, EventArgs ea ) : void
CheckOutDhcpServer ( MemBlock ether_addr ) : Ipop.DhcpServer

Static addresses are handled nearly identically to dynamic, so we use one shared method to pull a dhcp server from the list of dhcp servers. We only want one request per Ethernet / IP at a time.

GetDhcpConfig ( ) : void

We need to get the DHCPConfig as soon as possible so that we can allocate static addresses, this method helps us do that.

GetDhcpServer ( ) : Ipop.DhcpServer

Used to retrieve an instance of the DhcpServer associated with this type of node.

HandleArp ( MemBlock packet ) : void

Parses Arp Packets and writes to the Ethernet the translation.

IpopRouter makes nodes think they are in the same Layer 2 network so that two nodes in the same network can communicate directly with each other. IpopRouter masquerades for those that are not local.

HandleBroadcast ( IPPacket ipp ) : bool

This method is called by HandleIPOut if the destination address is the broadcast address. If you want Broadcast, implement this method, output will most likely be sent via the SendIP() method in the IpopNode base class.

HandleDhcp ( IPPacket ipp ) : bool

This is used to process a dhcp packet on the node side, that includes placing data such as the local Brunet Address, Ipop Namespace, and other optional parameters in our request to the dhcp server. When receiving the results, if it is successful, the results are written to the TAP device.

HandleDns ( IPPacket ipp ) : bool

If a request is sent to address a.b.c.255 with the dns port (53), this method will be called by HandleIPOut. If you want Dns, implement this method, responses should be written directly to the tap interface using Ethernet.Send()

HandleIPOut ( EthernetPacket packet, ISender ret ) : void

This method handles IPPackets that come from the TAP Device, i.e., local system.

Currently this supports HandleMulticast (ip[0] >= 244 && ip[0]<=239), HandleDns (dport = 53 and ip[3] == 1), dhcp (sport 68 and dport 67.

HandleMulticast ( IPPacket ipp ) : bool

This method is called by HandleIPOut if the destination address is within the multicast address range. If you want Multicast, implement this method, output will most likely be sent via the SendIP() method in the IpopNode base class.

HandleNewStaticIP ( MemBlock ether_addr, MemBlock ip ) : void

Let's see if we can route for an IP. Default is do nothing!

IsLocalIP ( MemBlock ip ) : bool

Is this our IP? Are we routing for it?

MappingMissing ( MemBlock ip ) : bool
MissedMapping ( string ip, Brunet.Address addr ) : void
SendIP ( Brunet.Address target, MemBlock packet ) : void

Sends the IP Packet to the specified target address.

SendIcmpRequest ( MemBlock dest_ip ) : void

This sends an Icmp Request to the specified address, we want him to respond to us, so we can guarantee that by pretending to be the Server (i.e. x.y.z.1). We'll get a response in our main thread.

SetDns ( ) : void
SetTAAuth ( ) : void
SupportedDns ( string dns ) : bool
UpdateMapping ( MemBlock ether_addr, MemBlock ip_addr ) : void

Called when an ethernet address has had its IP address changed or set for the first time.

WriteIP ( ICopyable packet ) : void

Writes an IPPacket as is to the TAP device.

Method Details

CalculateNetmaskCidr() public static method

Converts from a.b.c.d to the number of 1s in a.b.c.d (CIDR notation).
public static CalculateNetmaskCidr ( string netmask ) : int
netmask string
return int

CheckInDhcpServer() protected method

The request on the IP allocation space (DHT) has returned. So we're done with the server.
protected CheckInDhcpServer ( Ipop.DhcpServer dhcp_server ) : void
dhcp_server Ipop.DhcpServer
return void

CheckNode() protected method

protected CheckNode ( object o, EventArgs ea ) : void
o object
ea System.EventArgs
return void

CheckOutDhcpServer() protected method

Static addresses are handled nearly identically to dynamic, so we use one shared method to pull a dhcp server from the list of dhcp servers. We only want one request per Ethernet / IP at a time.
protected CheckOutDhcpServer ( MemBlock ether_addr ) : Ipop.DhcpServer
ether_addr MemBlock
return Ipop.DhcpServer

GetDhcpConfig() protected method

We need to get the DHCPConfig as soon as possible so that we can allocate static addresses, this method helps us do that.
protected GetDhcpConfig ( ) : void
return void

GetDhcpServer() protected abstract method

Used to retrieve an instance of the DhcpServer associated with this type of node.
protected abstract GetDhcpServer ( ) : Ipop.DhcpServer
return Ipop.DhcpServer

HandleArp() protected method

Parses Arp Packets and writes to the Ethernet the translation.
IpopRouter makes nodes think they are in the same Layer 2 network so that two nodes in the same network can communicate directly with each other. IpopRouter masquerades for those that are not local.
protected HandleArp ( MemBlock packet ) : void
packet MemBlock
return void

HandleBroadcast() protected method

This method is called by HandleIPOut if the destination address is the broadcast address. If you want Broadcast, implement this method, output will most likely be sent via the SendIP() method in the IpopNode base class.
protected HandleBroadcast ( IPPacket ipp ) : bool
ipp NetworkPackets.IPPacket The IPPacket the contains the broadcast message
return bool

HandleData() public method

This method handles all incoming packets into the IpopNode, both abroad and local. This is done to reduce unnecessary extra classes and circular dependencies. This method probably shouldn't be called directly.
public HandleData ( MemBlock b, ISender ret, object state ) : void
b MemBlock The incoming packet
ret ISender An ISender to return data from the original sender.
state object always will be null
return void

HandleDhcp() protected method

This is used to process a dhcp packet on the node side, that includes placing data such as the local Brunet Address, Ipop Namespace, and other optional parameters in our request to the dhcp server. When receiving the results, if it is successful, the results are written to the TAP device.
protected HandleDhcp ( IPPacket ipp ) : bool
ipp NetworkPackets.IPPacket The IPPacket that contains the Dhcp Request
return bool

HandleDns() protected method

If a request is sent to address a.b.c.255 with the dns port (53), this method will be called by HandleIPOut. If you want Dns, implement this method, responses should be written directly to the tap interface using Ethernet.Send()
protected HandleDns ( IPPacket ipp ) : bool
ipp NetworkPackets.IPPacket The IPPacket contain the Dns packet
return bool

HandleIPIn() public method

This method handles IPPackets that come from Brunet, i.e., abroad.
public HandleIPIn ( MemBlock packet, ISender ret ) : void
packet MemBlock The packet from Brunet.
ret ISender An ISender to send data to the Brunet node that sent /// the packet.
return void

HandleIPOut() protected method

This method handles IPPackets that come from the TAP Device, i.e., local system.
Currently this supports HandleMulticast (ip[0] >= 244 && ip[0]<=239), HandleDns (dport = 53 and ip[3] == 1), dhcp (sport 68 and dport 67.
protected HandleIPOut ( EthernetPacket packet, ISender ret ) : void
packet NetworkPackets.EthernetPacket The packet from the TAP device
ret ISender
return void

HandleMulticast() protected method

This method is called by HandleIPOut if the destination address is within the multicast address range. If you want Multicast, implement this method, output will most likely be sent via the SendIP() method in the IpopNode base class.
protected HandleMulticast ( IPPacket ipp ) : bool
ipp NetworkPackets.IPPacket The IPPacket the contains the multicast message
return bool

HandleNewStaticIP() protected method

Let's see if we can route for an IP. Default is do nothing!
protected HandleNewStaticIP ( MemBlock ether_addr, MemBlock ip ) : void
ether_addr MemBlock
ip MemBlock The IP in question.
return void

HandleRpc() public method

public HandleRpc ( ISender caller, string method, IList args, object rs ) : void
caller ISender
method string
args IList
rs object
return void

IpopNode() public method

Creates an IpopNode given a NodeConfig and an IpopConfig. Also sets up the Information, Ethernet device, and subscribes to Brunet for IP Packets
public IpopNode ( NodeConfig node_config, IpopConfig ipop_config, DHCPConfig dhcp_config ) : Brunet
node_config Brunet.Applications.NodeConfig The path to a NodeConfig xml file
ipop_config IpopConfig The path to a IpopConfig xml file
dhcp_config DHCPConfig
return Brunet

IsLocalIP() protected method

Is this our IP? Are we routing for it?
protected IsLocalIP ( MemBlock ip ) : bool
ip MemBlock The IP in question.
return bool

MappingMissing() protected method

protected MappingMissing ( MemBlock ip ) : bool
ip MemBlock
return bool

MissedMapping() protected method

protected MissedMapping ( string ip, Brunet.Address addr ) : void
ip string
addr Brunet.Address
return void

Run() public method

Starts the execution of the IpopNode, this passes the caller to execute the Brunet.Connect to eventually become Brunet.AnnounceThread.
public Run ( ) : void
return void

SendIP() protected method

Sends the IP Packet to the specified target address.
protected SendIP ( Brunet.Address target, MemBlock packet ) : void
target Brunet.Address the Brunet Address of the target
packet MemBlock the data to send to the recepient
return void

SendIcmpRequest() protected method

This sends an Icmp Request to the specified address, we want him to respond to us, so we can guarantee that by pretending to be the Server (i.e. x.y.z.1). We'll get a response in our main thread.
protected SendIcmpRequest ( MemBlock dest_ip ) : void
dest_ip MemBlock
return void

SetDns() protected method

protected SetDns ( ) : void
return void

SetTAAuth() protected method

protected SetTAAuth ( ) : void
return void

SupportedDns() protected method

protected SupportedDns ( string dns ) : bool
dns string
return bool

UpdateMapping() protected method

Called when an ethernet address has had its IP address changed or set for the first time.
protected UpdateMapping ( MemBlock ether_addr, MemBlock ip_addr ) : void
ether_addr MemBlock
ip_addr MemBlock
return void

WriteIP() protected method

Writes an IPPacket as is to the TAP device.
protected WriteIP ( ICopyable packet ) : void
packet ICopyable The IPPacket!
return void

Property Details

AppNode public_oe property

Stores the underlying ApplicationNode
public ApplicationNode,Brunet.Applications AppNode
return Brunet.Applications.ApplicationNode

Ethernet public_oe property

The Virtual Network handler
public Ethernet,Ipop Ethernet
return Ethernet

Info public_oe property

The Rpc handler for Information
public Information,Brunet.Applications Info
return Brunet.Applications.Information

PublicInfo public_oe property

The Rpc handler for the Public overlays Information. It will be the same as AppNode's, if there is no private overlay.
public Information,Brunet.Applications PublicInfo
return Brunet.Applications.Information

PublicNode public_oe property

Stores the public overlays ApplicationNode. It will be the same as AppNode, if there is no private overlay.
public ApplicationNode,Brunet.Applications PublicNode
return Brunet.Applications.ApplicationNode

_address_resolver protected_oe property

Resolves IP Addresses to Brunet.Addresses
protected IAddressResolver _address_resolver
return IAddressResolver

_broadcast protected_oe property

Enables broadcast.
protected bool _broadcast
return bool

_checked_out protected_oe property

A hashtable used to lock Dhcp Servers.
protected Hashtable,System.Collections _checked_out
return System.Collections.Hashtable

_conn_handler protected_oe property

Address to ISender (connection or secure connection).
protected ConnectionHandler _conn_handler
return ConnectionHandler

_dhcp_client_port protected_oe property

Port number to use for the Dhcp Client, typically 68.
protected int _dhcp_client_port
return int

_dhcp_config protected_oe property

We use this to set our L3 network
protected DHCPConfig,Ipop _dhcp_config
return DHCPConfig

_dhcp_server protected_oe property

protected DhcpServer,Ipop _dhcp_server
return Ipop.DhcpServer

_dhcp_server_port protected_oe property

Port number to use for the Dhcp Server, typically 67.
protected int _dhcp_server_port
return int

_dns protected_oe property

Resolves hostnames and IP Addresses
protected Dns _dns
return Dns

_ether_to_dhcp_server protected_oe property

Mapping of Ethernet to the its Dhcp server.
protected Dictionary _ether_to_dhcp_server
return DhcpServer>.Dictionary

_ether_to_ip protected_oe property

Mapping of Ethernet address to IP Address.
protected Dictionary _ether_to_ip
return MemBlock>.Dictionary

_ip_to_ether protected_oe property

Mapping of IP Address to Ethernet Address
protected Dictionary _ip_to_ether
return MemBlock>.Dictionary

_ipop_config protected_oe property

The IpopConfig for this IpopNode
protected IpopConfig,Ipop _ipop_config
return IpopConfig

_last_check_node protected_oe property

We must check the node every so often to see if there are any static addresses that have gone away or new ones that have shown up.
protected DateTime,System _last_check_node
return System.DateTime

_lock protected_oe property

Because locks are reentrant, this is a non-reentrant lock.
protected int _lock
return int

_multicast protected_oe property

Enables multicast.
protected bool _multicast
return bool

_static_dhcp_server protected_oe property

Used to hold configuration information.
protected DhcpServer,Ipop _static_dhcp_server
return Ipop.DhcpServer

_static_mapping protected_oe property

protected Dictionary _static_mapping
return SimpleTimer>.Dictionary

_sync protected_oe property

Global lock
protected object _sync
return object

_translator protected_oe property

If necessary, acts as a DNAT / SNAT
protected ITranslator _translator
return ITranslator