Docstoc

Trie-based lookup

Document Sample
Trie-based lookup Powered By Docstoc
					                  Advanced topics
                                in
  Computer Networks
              Lecture 8: Trie-based lookup

                   University of Tehran
          Dept. of EE and Computer Engineering
                              By:
                    Dr. Nasser Yazdani
Univ. of Tehran       Adv. topics in Computer Network   1
                  Trie Based Methods
n    Trie or radix tree is a data structure in
    which each data element is represented
    by the path to the leaf and no. of internal
    nodes are the no. of alphabet.

         Two branching.
         Black node in
         the
         leaves represent
         next hops

Univ. of Tehran        Adv. topics in Computer Network   2
     Trie Based Methods (cont)
Trie has been the base of many methods.
There are two main problems with trie:
n The blank nodes do not correspond to
   any data element in the lookup table.
n The number of branching is small, 2.

Both of these add to the height of trie,
   waste memory and prolong the search
   time.
The Max search time is proportional to
   string length or O(32) for IPv4 and
   O(128) for IPv6. in Computer Network
Univ. of Tehran Adv. topics              3
                  Trie Based Methods (cont)
Trie based schemes try to reduce the memory
  usage and shorten the trie height and expedite
  the search time.
In the worst case, the memory usage can be
  O(NL) where N is number of prefixes and L is
  their length.
q   Compressed Trie:
    The idea is to eliminate blank node as much as
    possible.
    Patricia trie compress the path from root to the
    leaf.

Univ. of Tehran        Adv. topics in Computer Network   4
                  Trie Based Methods (cont)
An Example:




       The information of skipped
       bits can be kept in links
       Max memory usages is O(2N)
       The worst case search is again O(NL).
Univ. of Tehran        Adv. topics in Computer Network   5
                  Trie Based Methods (cont)
q    Dynamic Prefix Trie (DP-Trie)
  Introduced by IBM research center in Zurich.
  the idea is to
      I) Eliminate the blank nodes completely
      II) Push common prefixes upper.
      III) To Make the height proportional to the
  # of prefixes than prefix lengths.
      IV) Compare more bits as much as possible.
They introduce a specific data structure each
  node having the following fields.

Univ. of Tehran        Adv. topics in Computer Network   6
                  Trie Based Methods (cont)
q     Index: differentiating bit
      position.
2.    LeftKey and RightKey:
     Prefixes with leftKey[Index]=0
     RightKey[Index]=1.
The trie is build dynamically.
Example: {1000100, 1001, 10, 1111, 11}
   First the trie is empty. Then, 1000100 is
   inserted. A node is allocated.

Univ. of Tehran        Adv. topics in Computer Network   7
                  Trie Based Methods (cont)




      6 in the first implies the differentiating bit is 6th.
      In the second node, 1001 is inserted. The differentiating bit is
      3th.
      10 inserted. Index is 1. New node is allocated.


Univ. of Tehran        Adv. topics in Computer Network           8
                  Trie Based Methods (cont)




            And the final trie with those elements is:

Univ. of Tehran        Adv. topics in Computer Network   9
                  Trie Based Methods (cont)


       Problems:
       Ø Two way branching.
       Ø Too much overhead for
          each node.
         What is next?



Univ. of Tehran        Adv. topics in Computer Network   10
                  Trie Based Methods (cont)
q    Controlled Prefix Expansion
    the idea is to compare more bits at the same
    time. (reduce the height of trie)
    Reduce prefixes with N distinct lengths to
    equivalent prefixes of M (M<N) lengths.
§   Expansion: Expand Prefix P of length L into two
    Prefixes P0 and P1 of lengths L+1.
§   Reduction: delete any repeated prefix.
     Indeed, this method compress few level
       together and use extra memory to reduce
       trie height.

Univ. of Tehran        Adv. topics in Computer Network   11
                  Trie Based Methods (cont)
Example: The same data set
Expand length 1 -> 2. Then,
00, 01, 10, 11
P5, P5, P1, P4
       Final lengths are 2,
       5 and 7.

       Reduce the search time
       from 7 to 3.


Univ. of Tehran        Adv. topics in Computer Network   12
                  Trie Based Methods (cont)
v   Problem: Extra memory usage.
v    Solution: Optimize the memory usage.
    Pick stride s for root and recursively solve
    the covering problem for the subtrees
    rooted at Trie level s+1 using k-1 level
        The dynamic programming
        method can be used to build
        the data structure bottom
        up with all values of K.

        Insertion?
Univ. of Tehran        Adv. topics in Computer Network   13
                  Trie Based Methods (cont)
q    Level Compress Trie LC-trie
    the idea is the same as the previous one,
    to compare more bits at the same time.
    Few levels are compress together.




Univ. of Tehran        Adv. topics in Computer Network   14
                  Trie Based Methods (cont)
 LC-trie reduces the height of trie in the
  expense of memory usage.
In order to have better memory utilization,
  it uses Greedy algorithm and compress
  the part which is more populated.

    In each level, we have to
    keep all possible
    combination
    like 000, 001, 010, etc.
Univ. of Tehran        Adv. topics in Computer Network   15
                  Trie Based Methods (cont)
Problems With expansion methods.
    q       Insertion may need to reconstruct the trie.
    q       Not scaleable to IPv6.
Problems with LC-trie:
    q       It uses greedy algorithm and optimize memory
           locally, the final memory utilization may not be
           good.
    q       Higher trie height and skip count compression
           leads to slower search times.
The Controlled Prefix Expansion method uses
  the same technique but, try to globally
  optimize memory usage.

Univ. of Tehran        Adv. topics in Computer Network        16

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:1
posted:4/21/2014
language:English
pages:16