Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Ruby (http://www.velocityreviews.com/forums/f66-ruby.html)
-   -   ruby replacement for net::patricia needed (http://www.velocityreviews.com/forums/t814489-ruby-replacement-for-net-patricia-needed.html)

jm 05-07-2004 05:44 AM

ruby replacement for net::patricia needed
 
I'm looking for the ruby equivalent of the perl Net::Patricia module
which uses the Patricia Trie algorithm for storing objects in
association with a ip address/mask combinations. For example,

p = Patricia.new()
p.add_address('127.0.0.0/8', obj) # stores object obj
o = p.match('127.0.0.1') # returns object obj

Is there anything similar already in existence for ruby? Is it possible
to adapt the acl modules?

I'm trying to avoid re-inventing the wheel.

Jeff.




Charles Comstock 05-07-2004 06:03 AM

Re: ruby replacement for net::patricia needed
 
jm wrote:

> I'm looking for the ruby equivalent of the perl Net::Patricia module
> which uses the Patricia Trie algorithm for storing objects in
> association with a ip address/mask combinations. For example,
>
> p = Patricia.new()
> p.add_address('127.0.0.0/8', obj) # stores object obj
> o = p.match('127.0.0.1') # returns object obj
>
> Is there anything similar already in existence for ruby? Is it possible
> to adapt the acl modules?
>
> I'm trying to avoid re-inventing the wheel.
>
> Jeff.
>
>
>


Is there an overall Trie object in Ruby at all? I would be interested
in one if it exists. If it doesn't maybe that's something important we
are missing. I'm done with finals in a week or so, maybe i'll throw
something together after that.
Charles Comstock

Hugh Sasse Staff Elec Eng 05-07-2004 11:01 AM

Re: ruby replacement for net::patricia needed
 
On Fri, 7 May 2004, jm wrote:

> I'm looking for the ruby equivalent of the perl Net::Patricia module
> which uses the Patricia Trie algorithm for storing objects in
> association with a ip address/mask combinations. For example,


I'm not familiar with this package but....
>
> p = Patricia.new()
> p.add_address('127.0.0.0/8', obj) # stores object obj
> o = p.match('127.0.0.1') # returns object obj
>

Tuplespaces may help, though you'll need to create some Netmask
class with an === operator so it will compare the addresses against
the mask (to do the matching) the way you want. This is part of Rinda
which is part of ruby out of the box.

[...]
> Jeff.
>


Hugh



YANAGAWA Kazuhisa 05-07-2004 11:45 AM

Re: ruby replacement for net::patricia needed
 
In Message-Id: <AF51BBF4-9FE9-11D8-9DC6-000A95D0C980@transact.com.au>
jm <jm@transact.com.au> writes:

> p = Patricia.new()
> p.add_address('127.0.0.0/8', obj) # stores object obj
> o = p.match('127.0.0.1') # returns object obj
>
> Is there anything similar already in existence for ruby? Is it
> possible to adapt the acl modules?


I don't know whether patricia trie itself is essential or not, but
ipaddr.rb, bundled with the current Ruby distribution, may help you.

require "ipaddr"

net = IPAddr.new("127.0.0.0/8")
net.include?(IPAddr.new("127.0.0.1")) #=> true


--
kjana@dm4lab.to May 7, 2004
A man is known by the company he keeps.




jm 05-10-2004 12:08 AM

Re: ruby replacement for net::patricia needed
 

On 07/05/2004, at 4:03 PM, Charles Comstock wrote:

> Is there an overall Trie object in Ruby at all? I would be interested
> in one if it exists. If it doesn't maybe that's something important
> we are missing. I'm done with finals in a week or so, maybe i'll
> throw something together after that.
> Charles Comstock


It would be much appreciated. I shouldn't be playing with ruby at the
moment either I've couple of assignments and exams to look forward to
in the next month (along with full time work).

Jeff.




jm 05-10-2004 01:04 AM

Re: ruby replacement for net::patricia needed
 
This combined with the suggestion made by hgs@dmu.ac.uk to use
truplespaces may provide a short term solution. The only problem I
have with truplespaces is the number of match operations that may be
needed. I checked the authors web pages (which is in japanese) from
reading between the lines I don't think he mentions what algorithm he
uses.
Looks like I'll have to read the source.

Take a look at some of the following for info on patricia tries if your
curious,

http://en.wikipedia.org/wiki/Patricia_trie

http://www.csse.monash.edu.au/~lloyd...Tree/PATRICIA/

"Optimized IP to ISO3166 Country Code Mapping in C#" which uses tries
http://www.codeproject.com/csharp/iptocountry.asp

This paper discusses various algorithms (it contains some typos)
http://herodes.redes.upv.es/rap/Rout...0Prestaciones/
ip_report.pdf

Citation info for original paper,
http://theory.lcs.mit.edu/~jacm/Auth...ondonaldr.html


Jeff.

On 07/05/2004, at 9:45 PM, YANAGAWA Kazuhisa wrote:

> In Message-Id: <AF51BBF4-9FE9-11D8-9DC6-000A95D0C980@transact.com.au>
> jm <jm@transact.com.au> writes:
>
>> p = Patricia.new()
>> p.add_address('127.0.0.0/8', obj) # stores object obj
>> o = p.match('127.0.0.1') # returns object obj
>>
>> Is there anything similar already in existence for ruby? Is it
>> possible to adapt the acl modules?

>
> I don't know whether patricia trie itself is essential or not, but
> ipaddr.rb, bundled with the current Ruby distribution, may help you.
>
> require "ipaddr"
>
> net = IPAddr.new("127.0.0.0/8")
> net.include?(IPAddr.new("127.0.0.1")) #=> true
>
>
> --
> kjana@dm4lab.to May 7, 2004
> A man is known by the company he keeps.
>
>






All times are GMT. The time now is 12:51 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.