ruby replacement for net::patricia needed

J

jm

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.
 
C

Charles Comstock

jm said:
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
 
H

Hugh Sasse Staff Elec Eng

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.

[...]

Hugh
 
Y

YANAGAWA Kazuhisa

In Message-Id: <[email protected]>
jm said:
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
 
J

jm

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.
 
J

jm

This combined with the suggestion made by (e-mail address removed) 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/tildeAlgDS/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/Routers Altas Prestaciones/
ip_report.pdf

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


Jeff.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top