摘要 |
The present invention discloses a method and a device for storing a routing table entry. The method includes: splitting a routing table entry into two points according to a range matching policy, wherein the length of each point is equal to the length of the routing table entry; dividing each point into multiple segments, where the multiple segments at least include a first segment and a second segment, the first segment is a common part of the two points, and the second segment is a different part of the two points; obtaining a storage location of the routing table entry in a hierarchical binary tree, where the hierarchical binary tree includes a binary tree of each segment, and the binary tree of each segment at least includes a binary tree of the first segment and a binary tree of the second segment; and adding each segment related to the routing table entry to the binary tree of each segment according to the storage location, where the binary tree of the first segment points to the binary tree of the second segment by a pointer. According to the present invention, the routing table entry is stored in the hierarchical binary tree in segments, which significantly reduces the total amount of memory required to be occupied by storage of the routing table entry.
|