CN100375463C - A Method of Realizing Longest Prefix Address Routing Lookup Using Segment Compression Table - Google Patents
A Method of Realizing Longest Prefix Address Routing Lookup Using Segment Compression Table Download PDFInfo
- Publication number
- CN100375463C CN100375463C CNB2004100500691A CN200410050069A CN100375463C CN 100375463 C CN100375463 C CN 100375463C CN B2004100500691 A CNB2004100500691 A CN B2004100500691A CN 200410050069 A CN200410050069 A CN 200410050069A CN 100375463 C CN100375463 C CN 100375463C
- Authority
- CN
- China
- Prior art keywords
- index
- value
- routing
- compression deviation
- route
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Lifetime
Links
Images
Landscapes
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
本发明涉及数据通信技术领域,一种实现最长前缀地址路由查找的方法。该方法建立两级路由信息表格:64K段表和压缩偏移表,将偏移表中路由索引值压缩成该索引值与本段基准路由索引差值,通过此方法来存储路由查找信息。查找时,先使用欲查找的目标IPv4地址的高16位作为索引值,在64K段表中定位表项:判断该表项中压缩偏移表指针是否无效?若是,则此表项中路由索引即为该目标IPv4地址所对应下一跳路由索引值;若否,则根据此表项得到该IPv4地址对应压缩偏移表的指针值、基准值和压缩表表项宽度,以目标IPv4地址的低16位为偏移量访问对应压缩偏移表表项,通过计算得到该IPv4地址的下一跳路由索引值。
The invention relates to the technical field of data communication, and relates to a method for realizing longest prefix address routing search. This method establishes a two-level routing information table: a 64K section table and a compressed offset table, and compresses the routing index value in the offset table into the difference between the index value and the reference routing index of this section, and stores the routing lookup information through this method. When searching, first use the upper 16 bits of the target IPv4 address to be searched as the index value, and locate the entry in the 64K segment table: determine whether the compression offset table pointer in the entry is invalid? If so, the routing index in this entry is the next-hop routing index value corresponding to the target IPv4 address; if not, then the pointer value, reference value and compression table corresponding to the IPv4 address are obtained according to this entry The width of the table entry, access the corresponding compressed offset table entry with the lower 16 bits of the target IPv4 address as the offset, and obtain the next-hop routing index value of the IPv4 address through calculation.
Description
技术领域 technical field
本发明涉及数据通信技术领域。特别是一种使用分段、压缩技术实现IPv4最长前缀地址路由查找的方法。该方法可以使用于IPv4因特网中路由器、三层交换机、接入服务器等需要进行IPv4地址路由查找的设备。The invention relates to the technical field of data communication. In particular, a method for realizing routing lookup of IPv4 longest prefix address by using segmentation and compression technology. The method can be used in routers, layer-3 switches, access servers and other devices in the IPv4 Internet that need to search for IPv4 address routing.
背景技术 Background technique
路由查找是路由器、三层交换机等设备的基本功能之一。IP地址由<网络标识,主机标识>组成,IP分组的转发按照网络标识进行。早期,IP地址根据网络标识长度固定在8、16、24位,分别对应于A、B、C类地址。无类域间路由技术(CIDR)允许任意长度地址聚合,使得IP地址的网络标识长度不再仅限于8位、16位和24位三种,而是可以为8~32的任何值。路由表中路由信息由<地址前缀/前缀长度,下一跳地址(索引)>给出。进行IPv4地址查找时,原有的完全匹配被最长前缀匹配(LPM)所替代,即需要在路由前缀数据库中查找与给定IP分组目的地址有着最长匹配前缀的表项。Route lookup is one of the basic functions of routers,
由于最长前缀匹配查找较为复杂,使得处理器负担大大加重;加上网络对路由器转发速度要求的不断提高,路由查找成为影响路由器性能的主要瓶颈之一。Due to the complexity of the longest prefix match search, the burden on the processor is greatly increased; coupled with the continuous improvement of the network's requirements on the forwarding speed of the router, the route search has become one of the main bottlenecks affecting the performance of the router.
评价一种IP地址查找方法的性能时,必须综合考虑该本方法所能达到的查找速度(一般以每秒所能进行的分组查找数目(pps)衡量)、存储一定路由表项需要的存储器容量、查找表的更新开销、复杂度、以及实现方法的难易程度、功耗、面积等各方面,其中,查找方法的查找速度、更新开销和存储器容量更为重要。When evaluating the performance of an IP address lookup method, it is necessary to comprehensively consider the search speed that this method can achieve (generally measured by the number of packet searches per second (pps)), and the memory capacity required to store a certain routing table item. , the update overhead and complexity of the lookup table, and the ease of implementation, power consumption, area, etc., among which the lookup speed, update overhead, and memory capacity of the lookup method are more important.
如何提高IP地址查找方法的查找速度、降低更新开销和存储器容量,达到各方面性能的均衡成为了一些业内人士的研究方向,他们提出了众多不同查找方法。How to improve the search speed of the IP address search method, reduce the update overhead and memory capacity, and achieve a balance of performance in all aspects has become the research direction of some people in the industry, and they have proposed many different search methods.
发明内容 Contents of the invention
(一)要解决的技术问题(1) Technical problems to be solved
本发明的目的是提供一种实现IPv4最长前缀地址路由查找的方法。该方法拥有高速的IPv4最长前缀地址路由查找能力与转发表更新能力,同时需要较少的存储空间。The purpose of the present invention is to provide a method for realizing routing lookup of IPv4 longest prefix address. The method has high-speed IPv4 longest prefix address routing lookup capability and forwarding table update capability, and requires less storage space.
(二)技术方案(2) Technical solutions
为达到上述目的,本发明的技术方案是这样实现的:In order to achieve the above object, technical solution of the present invention is achieved in that way:
一种使用分段压缩表实现最长前缀地址路由查找的方法,选定压缩偏移表路由基准索引字段位宽和压缩偏移表指针字段位宽,在存储器中通过建立两级表格:64K段表(Segment Table)和压缩偏移表(Compressed OffsetTable),通过将压缩偏移表中原偏移表路由索引值压缩成该索引值与本段基准路由索引差值的方法来存储路由索引信息。查找时,先使用欲查找的目标IPv4地址的高16位(IPH16)作为索引值,在64K段表中定位表项:判断该表项中压缩偏移表指针值(pOffetTable)是否无效(全1值)。若指针值无效,表示此表项中段路由索引(NHseg)为该目标IPv4地址所对应下一跳路由索引值(NHI);若否,则根据此表项中压缩偏移表指针值得到该IPv4地址对应压缩偏移表的入口地址,由段路由索引字段(NHseg)值得到当前下一跳路由索引值(NHIcurrent)。使用公式1计算出该压缩偏移表表项宽度EntryWidth,使用该IPv4地址的低16位(IPL16)和压缩偏移表表项宽度通过公式2计算出此IPv4地址在压缩偏移表中的字偏移量(Offsetword)、通过公式3计算出此IPv4地址在该字中的比特偏移量(Offsetbit),计算出压缩偏移表路由基准值(BaseIndex),访问此IPv4地址对应压缩偏移表中的字偏移量字,得到比特宽度为EntryWidth的下一跳路由索引偏移量(OffsetNH)。判断下一跳路由索引偏移量值是否为全1值(2EntryWidth-1)?若是,表示此IPv4地址对应下一跳路由索引(NHI)即等于当前一跳索引值(NHIcurrent);若否,通过公式4计算得到该IPv4地址的下一跳路由索引值(NHI)。A method for realizing the longest prefix address routing lookup by using segmented compression tables, selecting the bit width of the routing reference index field of the compressed offset table and the bit width of the pointer field of the compressed offset table, and establishing two-level tables in the memory: 64K segments The table (Segment Table) and the compressed offset table (Compressed OffsetTable) store the routing index information by compressing the routing index value of the original offset table in the compressed offset table into the difference between the index value and the reference routing index of this segment. When searching, first use the upper 16 bits (IP H16 ) of the target IPv4 address to be searched as the index value, and locate the entry in the 64K segment table: judge whether the compressed offset table pointer value (pOffetTable) in the entry is invalid (all 1 value). If the pointer value is invalid, it means that the segment route index (NH seg ) in this table entry is the next-hop route index value (NHI) corresponding to the target IPv4 address; The IPv4 address corresponds to the entry address of the compressed offset table, and the current next-hop routing index value (NHI current ) is obtained from the value of the segment routing index field (NH seg ). Use formula 1 to calculate the entry width EntryWidth of the compressed offset table, and use the lower 16 bits (IP L16 ) of the IPv4 address and the width of the compressed offset table entry to calculate the entry width of the IPv4 address in the compressed offset table through
公式1:EntryWidth=2WidthIndex Formula 1: EntryWidth=2 WidthIndex
公式2:Offsetword=Int((EntryWidth×IPL16)/Widthword)Formula 2: Offset word = Int((EntryWidth×IP L16 )/Width word )
公式3:Offsetbit=((EntryWidth×IPL16))-(Offsetword×Widthword)Formula 3: Offset bit =((EntryWidth×IP L16 ))-(Offset word ×Width word )
公式4:NHI=BaseValue+OffsetNH Formula 4: NHI=BaseValue+Offset NH
其中:Widthword为压缩偏移表所在存储器的位宽Among them: Width word is the bit width of the memory where the compressed offset table is located
Int表示取整Int means rounding
BaseValue为根据路由基准索引值(BaseIndex)得到的路由索引基准值。BaseValue is the route index base value obtained according to the route base index value (BaseIndex).
上文所述的64K段表中,每条表项由段路由索引(NHseg)、压缩偏移表指针(pOffetTable)、路由基准索引(BaseIndex)和压缩表表项宽度索引(WidthIndex)四个字段组成。见图1说明。In the 64K segment table mentioned above, each entry consists of four segment routing index (NH seg ), compression offset table pointer (pOffetTable), routing reference index (BaseIndex) and compression table entry width index (WidthIndex) field composition. See Figure 1 for illustration.
段路由索引字段位宽为8比特,存储在表项的最高有效位置,初始化为0xFF,表示无有效下一跳路由。The segment routing index field has a bit width of 8 bits and is stored in the most effective position of the entry. It is initialized to 0xFF, indicating that there is no valid next-hop route.
压缩偏移表表项位宽索引字段为2比特,存储于表项中与压缩偏移表指针相邻的高有效位,初始化为全1,即0x3。根据压缩偏移表表项位宽索引,可以由公式1计算出压缩偏移表中每条表项所占比特位数。The bit width index field of the compressed offset table entry is 2 bits, stored in the most significant bits adjacent to the compressed offset table pointer in the entry, and initialized to all 1s, that is, 0x3. According to the bit width index of the entry in the compression offset table, the number of bits occupied by each entry in the compression offset table can be calculated by formula 1.
压缩偏移表指针字段存储在表项的最低有效位。压缩偏移表指针字段位宽可以由具体实施方案确定,取值16比特或14比特,初始化为全1值,即分别初始化为0xFFFF(字段位宽为16比特)、0x3FFF(字段位宽为14比特),表示无效,不需要进行进一步查找;查找时,若指针值不等于初始全1值(字段位宽为14比特时为0x3FFF,字段位宽为16比特时为0xFFFF),表示需进行进一步查找,且此指针值为目标IPv4地址对应的压缩偏移表起始地址。The compressed offset table pointer field is stored in the least significant bits of the table entry. The bit width of the compressed offset table pointer field can be determined by the specific implementation plan, and the value is 16 bits or 14 bits, and is initialized to a value of all 1s, that is, initialized to 0xFFFF (the field bit width is 16 bits), 0x3FFF (the field bit width is 14 bits) and 0xFFFF (the field bit width is 14 bits). bit), indicating that it is invalid and no further search is required; when searching, if the pointer value is not equal to the initial value of all 1s (0x3FFF when the field bit width is 14 bits, and 0xFFFF when the field bit width is 16 bits), it means that further Search, and this pointer value is the starting address of the compressed offset table corresponding to the target IPv4 address.
路由基准索引字段的位宽根据压缩偏移表指针字段位宽的不同取相应的长度,存储在表项中与段路由索引相邻的低高有效位置。当压缩偏移表指针字段位宽分别为14、16比特时,路由索引基准字段位宽分别为6比特、8比特。The bit width of the routing reference index field is a corresponding length according to the bit width of the pointer field of the compression offset table, and is stored in the low-high effective position adjacent to the segment routing index in the entry. When the bit widths of the compression offset table pointer field are 14 and 16 bits respectively, the bit widths of the routing index reference field are 6 bits and 8 bits respectively.
上文所述的压缩偏移表中,每条表项由一个位宽为EntryWidth个比特的路由索引差值字段构成,表示路由索引值和段路由索引的差值,见图2说明。In the above-mentioned compressed offset table, each entry is composed of a routing index difference field with a bit width of EntryWidth bits, indicating the difference between the routing index value and the segment routing index, as shown in Figure 2.
当路由基准索引(BaseIndex)字段位宽为8比特时,路由基准值(BaseValue)等于路由基准索引字段值:当路由基准索引字段位宽为6比特时,路由基准值由以下公式5给出:When the routing base index (BaseIndex) field bit width is 8 bits, the routing base value (BaseValue) is equal to the routing base index field value: when the routing base index field bit width is 6 bits, the routing base value is given by the following formula 5:
公式5:BaseValue=4×BaseIndexFormula 5: BaseValue=4×BaseIndex
所述的64K段表每一条表项都是一个32比特的长字,由段路由索引字段(31:24比特)、压缩偏移表路由索引基准值字段(23:18比特或23:16比特)、压缩偏移表表项宽度索引字段(17:16比特或15:14比特)和压缩偏移表指针字段(15:0比特或13:0比特)共四个字段构成。Each entry of the 64K segment table is a 32-bit long word, composed of a segment routing index field (31:24 bits), a compression offset table routing index reference value field (23:18 bits or 23:16 bits ), a compressed offset table entry width index field (17:16 bits or 15:14 bits) and a compressed offset table pointer field (15:0 bits or 13:0 bits) consisting of four fields.
所述的64K段表,表项的最高8比特(31:24)段路由索引是指向路由表的索引,初始化为0xFF表示默认无有效下一跳路由;若段路由索引等于路由索引初始值时,表示无有效下一跳路由;若段路由索引不等于路由索引初始值,其数值为IPv4地址对应下一跳路由的索引值。In the 64K section table, the highest 8-bit (31:24) section routing index of the entry is an index pointing to the routing table, and it is initialized to 0xFF to indicate that there is no valid next-hop route by default; if the section routing index is equal to the initial value of the routing index , indicating that there is no valid next-hop route; if the segment route index is not equal to the initial value of the route index, its value is the index value of the next-hop route corresponding to the IPv4 address.
所述的64K段表,表项的压缩偏移表路由基准索引值(23:18比特或23:16比特)是压缩偏移表路由索引值的基准索引值,初始化为0x3F(字段位宽为6比特时)或0xFF(字段位宽为8比特时),仅当同表项中压缩偏移表指针不为压缩偏移表指针初始值时有意义;字段位宽为6比特时,压缩偏移表路由索引基准值等于4倍的压缩偏移表路由基准索引值;字段位宽为8比特时,压缩偏移表路由索引基准值等于压缩偏移表路由基准索引值。The 64K section table, the compressed offset table routing reference index value (23:18 bits or 23:16 bits) of the entry is the reference index value of the compressed offset table routing index value, initialized to 0x3F (the field bit width is 6 bits) or 0xFF (when the field bit width is 8 bits), it is meaningful only when the compression offset table pointer in the same entry is not the initial value of the compression offset table pointer; when the field bit width is 6 bits, the compression offset table pointer The routing index reference value of the shift table is equal to 4 times the routing reference index value of the compressed offset table; when the field bit width is 8 bits, the routing index reference value of the compressed offset table is equal to the routing reference index value of the compressed offset table.
所述的64K段表,表项的压缩偏移表表项宽度索引(17:16比特或15:14比特)是指明压缩偏移表表项宽度的索引值,初始化为压缩偏移表表项宽度索引初始值0x3,仅当同表项中压缩偏移表指针不为压缩偏移表指针初始值时有意义。In the 64K segment table, the compressed offset table entry width index (17:16 bits or 15:14 bits) of the entry is an index value indicating the width of the compressed offset table entry, and is initialized to the compressed offset table entry The initial value of the width index is 0x3, which is meaningful only when the compression offset table pointer in the same entry is not the initial value of the compression offset table pointer.
所述的64K段表,表项的压缩偏移表指针(15:0比特或13:0比特)是指向本表项所对应压缩偏移表起始地址的指针,初始化为0xFFFF(字段位宽为16比特时)或0x3FFF(字段宽度为14比特时),若压缩偏移表指针值等于压缩偏移表指针初始值,表示本表项不存在对应压缩偏移表,不需要进行进一步查找;若压缩偏移表指针值不等于压缩偏移表指针初始值,表示本表项存在对应压缩偏移表,需要进行进一步路由查找,且压缩偏移表指针的值为本表项对应的压缩偏移表的起始地址。The 64K segment table, the compression offset table pointer (15:0 bit or 13:0 bit) of the entry is a pointer pointing to the start address of the compression offset table corresponding to this entry, initialized to 0xFFFF (
压缩偏移表路由基准值表示压缩偏移表的下一跳路由基准值,压缩偏移表路由基准值等于4倍的压缩偏移表路由基准索引值(64K段表中压缩偏移表路由基准索引字段位宽为6比特时),或压缩偏移表路由基准值等于压缩偏移表路由基准索引值(64K段表中压缩偏移表路由基准索引值字段位宽为8比特时)。The compressed offset table routing reference value represents the next hop routing reference value of the compressed offset table, and the compressed offset table routing reference value is equal to 4 times the compressed offset table routing reference index value (the compression offset table routing reference value in the 64K segment table When the bit width of the index field is 6 bits), or the routing reference value of the compression offset table is equal to the routing reference index value of the compression offset table (when the bit width of the routing reference index value field of the compression offset table in the 64K segment table is 8 bits).
所述的压缩偏移表每一条表项由路由索引偏移字段构成,表项位宽等于2的压缩偏移表表项宽度索引值次幂,表示表项对应的下一跳路由索引值与压缩偏移表路由基准值的差值,初始化为全1值,若压缩偏移表表项值等于压缩偏移表表项初始值,表示下一跳路由索引值等于此压缩偏移表所属64K段表表项中的段路由索引值;若压缩偏移表表项的值不等于压缩偏移表表项初始值,表示下一跳路由索引值等于表项值与压缩偏移表路由基准值之和。Each entry in the compressed offset table is composed of a routing index offset field, and the bit width of the entry is equal to the power of the index value of the compressed offset table entry width of 2, indicating that the next hop routing index value corresponding to the entry is equal to The difference between the routing reference value of the compressed offset table, initialized to all 1 values, if the value of the compressed offset table entry is equal to the initial value of the compressed offset table entry, it means that the next-hop routing index value is equal to the 64K to which the compressed offset table belongs The segment routing index value in the segment table entry; if the value of the compression offset table entry is not equal to the initial value of the compression offset table entry, it means that the next hop routing index value is equal to the entry value and the compression offset table routing reference value Sum.
如图4所示,图4是本发明提供的的最长前缀地址路由查找方法,该方法有下列实施步骤:As shown in Figure 4, Figure 4 is the longest prefix address routing search method provided by the present invention, and the method has the following implementation steps:
(1)、选定具体实施方案64K段表表项中压缩偏移表指针和路由基准索引字段位宽和压缩偏移表指针字段位宽。(1), select the compression offset table pointer and the routing reference index field bit width and the compression offset table pointer field bit width in the selected specific embodiment 64K segment table entry.
(2)、首先对原始路由信息表进行扩展、排序和分组:将原始路由记录中前缀长度小于16比特的路由信息均扩展成前缀长度为16的记录;将前缀长度大于16比特且小于32比特的路由条目均扩展成长度为32比特的路由前缀,按照前缀的高16比特分组,组内按照路由前缀的长度从小到大排放;(2), first expand, sort and group the original routing information table: expand the routing information with a prefix length of less than 16 bits in the original routing record into a record with a prefix length of 16; make the prefix length greater than 16 bits and less than 32 bits The route entries of the route are all expanded into a route prefix with a length of 32 bits, grouped according to the high 16 bits of the prefix, and arranged in groups according to the length of the route prefix from small to large;
路由信息扩展指将原始路由信息中的IP地址前缀从原前缀扩展成指定长度的一组为原地址前缀所包含的一组地址前缀,但扩展后的路由信息中前缀长度的有效值和下一跳索引值不变。例如,将路由项<8.0.0.0/8,25>(前缀/前缀长度,下一跳地址)扩展到16比特后可得到的路由项组为<8.0.0.0/8,25>、<8.1.0.0/8,25>、<8.2.0.0/8,25>...<8.254.0.0/8,25>、<8.255.0.0/8,25>。Routing information extension refers to extending the IP address prefix in the original routing information from the original prefix to a group of address prefixes of the specified length, which is a group of address prefixes contained in the original address prefix, but the effective value of the prefix length in the expanded routing information is different from the next The jump index value does not change. For example, after expanding the routing item <8.0.0.0/8, 25> (prefix/prefix length, next hop address) to 16 bits, the routing item group that can be obtained is <8.0.0.0/8, 25>, <8.1. 0.0/8, 25>, <8.2.0.0/8, 25>...<8.254.0.0/8, 25>, <8.255.0.0/8, 25>.
按照目标IPv4地址的高16比特分组,组内按照路由前缀的长度从小到大排放。According to the upper 16 bits of the target IPv4 address, the group is arranged according to the length of the route prefix from small to large.
决定实现方案中压缩偏移表指针(pOffetTable)和路由基准索引(BaseIndex)两个字段的比特宽度。Determine the bit width of the two fields of the compression offset table pointer (pOffetTable) and the routing reference index (BaseIndex) in the implementation scheme.
(3)、64K段表的初始化操化,构建64K段表:将每组路由信息中前缀长度小于等于16比特的信息项按照前缀长度由小到大的顺序依次填入64K段表相应表项,构造64K段表。表中每条表项由段路由索引(NHseg)、压缩偏移表指针(pOffetTable)、路由基准索引(BaseIndex)和压缩表表项宽度索引(WidthIndex)四个字段组成,其中路由基准索引字段、压缩偏移表指针字段和压缩表表项宽度索引字段和段路由索引字段填入初始值(全1)。(3) Initialize the 64K segment table and construct the 64K segment table: Fill the information items with prefix length less than or equal to 16 bits in each group of routing information into the corresponding entries of the 64K segment table in order of prefix length from small to large , Construct a 64K segment table. Each entry in the table consists of four fields: segment routing index (NHseg), compression offset table pointer (pOffetTable), routing base index (BaseIndex) and compression table entry width index (WidthIndex), among which the routing base index field, The compression offset table pointer field, the compression table entry width index field, and the segment routing index field are filled with initial values (all 1s).
64K段表拥有64K条表项,占用的存储空间为The 64K segment table has 64K entries and occupies a storage space of
64K×Widthword 比特64K×Width word bits
(4)、压缩偏移表的初始化操作,构建64K段表中各表项对应的压缩偏移表:统计出每组路由信息中前缀长度大于16比特的信息所对应下一跳路由索引值中最小值NHmin和最大值NHmax,取其最小值为下一跳路由索引值(BaseValue)。若1中选定的路由基准索引字段为6,则根据公式6计算出路由准索引值;若1中选定的路由基准索引字段位宽等比8比特,则选取路由基准索引值等于路由基准值。(4), the initialization operation of the compression offset table, construct the compression offset table corresponding to each entry in the 64K section table: count the next-hop routing index value corresponding to the information whose prefix length is greater than 16 bits in each group of routing information Take the minimum value NH min and the maximum value NH max as the next hop routing index value (BaseValue). If the routing reference index field selected in 1 is 6, then calculate the routing reference index value according to
公式6:BaseIndex=Int(BaseValue/4)Formula 6: BaseIndex=Int(BaseValue/4)
选取压缩偏移表表项宽度索引值WidthIndex使其同时满足以下条件:Select the width index value WidthIndex of the compression offset table entry so that it satisfies the following conditions at the same time:
WidthIndex=log EntryWidth ①WidthIndex=log EntryWidth ①
EntryWidth={min(i)|BaseValue+2i-1>NHmax,i∈N}②EntryWidth={min(i)|BaseValue+2 i -1>NH max ,i∈N}②
申请尺寸为EntryWidth×64K比特的存储器空间,将其首地址填入64K段表中压缩偏移表指针字段。将路由基值索引BaseIndex和压缩偏移表表项宽度索引值WidthIndex填入64K段表中各自对应字段。Apply for a memory space whose size is EntryWidth×64K bits, and fill its head address into the compressed offset table pointer field in the 64K segment table. Fill the routing base value index BaseIndex and compression offset table entry width index value WidthIndex into the corresponding fields in the 64K segment table.
使用全1初始化压缩偏移表。分别对每组路由中前缀长度大于16的路由信息条目计算路由信息中下一跳路由索引值与路由基准值间的差值,依前缀长度从小到大的顺序以位宽EntryWidth填入压缩偏移表中对应比特范围。Initialize the compressed offset table with all 1s. Calculate the difference between the next hop route index value and the route reference value in each group of route information entries with a prefix length greater than 16, and fill in the compressed offset with the bit width EntryWidth in the order of prefix length from small to large Corresponding bit ranges in the table.
(5)、取目标IPv4地址的高16位作为索引值,在64K段表中定位表项:判断该表项中压缩偏移表指针值(pOffetTable)是否无效(全1值)。若压缩偏移表指针无效,转入6;若压缩偏移表指针值有效,转入7。(5), get the upper 16 bits of the target IPv4 address as the index value, and locate the entry in the 64K section table: judge whether the compression offset table pointer value (pOffetTable) in the entry is invalid (all 1 values). If the compression offset table pointer is invalid, transfer to 6; if the compression offset table pointer value is valid, transfer to 7.
(6)、判断表项中段路由索引字段值是否无效(0xFF)?若段路由索引(NHseg)值为0xFF(全1),则该目标IPv4地址无对应有效下一跳路由;若否,则表项中路由索引值即为该目标IPv4地址所对应下一跳路由索引值(NHI)。查找结束(6) Determine whether the route index field value in the entry is invalid (0xFF)? If the segment routing index (NH seg ) value is 0xFF (all 1s), then the target IPv4 address does not have a corresponding valid next-hop route; if not, the routing index value in the entry is the next hop corresponding to the target IPv4 address Routing index value (NHI). end of search
(7)、根据此表项中压缩偏移表指针值得到该IPv4地址对应压缩偏移表的入口地址、路由基准索引值BaseIndex)和压缩表表项宽度索引值(WidthIndex),令当前下一跳路由索引值(NHIcurrent)等于段路由索引(NHseg)。使用公式1计算出该压缩偏移表表项宽度EntryWidth,使用该IPv4地址的低16位(IPL16)和压缩偏移表表项宽度通过公式2计算出此IPv4地址在压缩偏移表中的字偏移量(Offsetword)、通过公式3计算出此IPv4地址在该字中的比特偏移量(Offsetbit),并计算出压缩偏移表路由基准值。(7), obtain the entry address of this IPv4 address corresponding compression offset table, route benchmark index value (BaseIndex) and compression table entry width index value (WidthIndex) according to the compression offset table pointer value in this entry, make current next The hop routing index value (NHI current ) is equal to the segment routing index (NH seg ). Use formula 1 to calculate the entry width EntryWidth of the compressed offset table, and use the lower 16 bits (IP L16 ) of the IPv4 address and the width of the compressed offset table entry to calculate the entry width of the IPv4 address in the compressed offset table through
(8)、以偏移量Offsetword访问此IPv4地址对应压缩偏移表中的偏移量字,得到比特宽度为EntryWidth的下一跳路由索引值偏移量(OffsetNH)。判断下一跳路由索引偏移量值是否为2EntryWidth-1。若是,则此IPv4地址对应下一跳路由索引(NHI)即等于当前一跳索引值(NHIcurrent);若否,通过公式4计算出下一跳路由索引值(NHI)。若NHI为全1值,则此IPv4地址无对应下一跳路由;若否,则此IPv4地址对应下一跳路由即为NHI,查找结束。(8), visit the offset word in this IPv4 address corresponding compression offset table with offset offset word, obtain the next hop routing index value offset (Offset NH ) that bit width is EntryWidth. Determine whether the next-hop routing index offset value is 2 EntryWidth -1. If yes, the next-hop routing index (NHI) corresponding to this IPv4 address is equal to the current one-hop index value (NHI current ); if not, the next-hop routing index value (NHI) is calculated by
(三)有益效果(3) Beneficial effects
从上述技术方案可以看出,本发明具有以下有益效果:As can be seen from the foregoing technical solutions, the present invention has the following beneficial effects:
本发明方法可以拥有高速的查找能力和更新能力,同时需要较少的存储空间。本发明实现IPv4路由查找方法的特点是只需建立两个结构简单的转发表一段表和压缩偏移表。表的构造过程操作步骤简单、且快速、有效。该方法相对于现有的各种分段、压缩进行IPv4路由查询方法,具有以下优点:查找速度相快,仅需要2次存储器访问;实施方法所需要的存储空间较小;更新开销小。The method of the present invention can have high-speed searching ability and updating ability, and needs less storage space at the same time. The feature of the method for realizing the IPv4 routing search in the present invention is that only two forwarding tables with simple structures and a compressed offset table need to be established. The operation steps of the table construction process are simple, fast and effective. Compared with the existing IPv4 route query methods of various segments and compressions, the method has the following advantages: the search speed is relatively fast, and only two memory accesses are required; the storage space required by the implementation method is small; and the update cost is small.
相对于现有的各种分段、压缩实现IPv4地址快速查找算法,本方法具有更高的综合性能,较好的解决了查找速度与更新速度、查找速度与存储器容量之间的矛盾。一次IPv4地址查找最多需要2次存储器访问;二级表的压缩减少了大量存储器空间;同时,由于压缩算法简单,二级表的压缩并未增加传统分段表的更新开销。64K段表表项结构简单但信息量丰富,解决了分段算法可能发生的路由查找回溯现象。Compared with the existing IPv4 address fast lookup algorithms realized by various segmentation and compression, the method has higher comprehensive performance, and better solves the contradiction between search speed and update speed, search speed and memory capacity. An IPv4 address lookup requires at most 2 memory accesses; the compression of the second-level table reduces a large amount of memory space; meanwhile, due to the simplicity of the compression algorithm, the compression of the second-level table does not increase the update overhead of the traditional segment table. The 64K segment table entry structure is simple but the amount of information is rich, which solves the phenomenon of routing lookup backtracking that may occur in the segmentation algorithm.
本发明内容实现起来简单、容易。需要的存储容量小,算法简单、易实现,可以由FPGA采用硬件方式实现,也可以使用普通PC或接入服务器采用软件方式实现。本发明可以应用于三层交换机、路由器和其它需要完成IP网络路由查找的设备。The content of the present invention is simple and easy to realize. The required storage capacity is small, and the algorithm is simple and easy to implement. It can be implemented by FPGA in hardware, or can be implemented in software by using an ordinary PC or access server. The invention can be applied to three-layer switches, routers and other devices that need to complete IP network route search.
附图说明 Description of drawings
图1是本发明的64K段表表项构成方式一示意图。FIG. 1 is a schematic diagram of a configuration method of a 64K segment table entry in the present invention.
图2是本发明的64K段表表项构成方式二示意图。Fig. 2 is a schematic diagram of the second configuration mode of the 64K segment table entry in the present invention.
图3是本发明的压缩偏移表表项结构示意图。Fig. 3 is a schematic diagram of the structure of the compression offset table entry in the present invention.
图4是本发明的实施本方法的操作步骤流程图。Fig. 4 is a flow chart of the operation steps of implementing the method of the present invention.
图5是本发明的硬件实施系统结构图。Fig. 5 is a structural diagram of the hardware implementation system of the present invention.
具体实施方式 Detailed ways
为使本发明的目的、技术方案和优点更加清楚明白,以下结合具体实施例,并参照附图,对本发明进一步详细说明。In order to make the object, technical solution and advantages of the present invention clearer, the present invention will be described in further detail below in conjunction with specific embodiments and with reference to the accompanying drawings.
在64K段表和压缩偏移表中,各字段初始化为全1值,表示无效(压缩偏移表表项宽度字段除处)。查找时,若64K段表中段路由索引字段值为全1,则表示无效路由;64K段表中压缩偏移表指针字段值为全1,则表示本段不存在压缩偏移表;压缩偏移表中若某表项值为全1,表示对应下一跳路由索引值为段路由索引,而不使用公式4计算。In the 64K segment table and the compression offset table, each field is initialized to all 1 values, which means invalid (except for the entry width field of the compression offset table). When searching, if the segment routing index field value in the 64K segment table is all 1, it indicates an invalid route; the compression offset table pointer field value in the 64K segment table is all 1, indicating that there is no compression offset table in this segment; If the value of an entry in the table is all 1s, it means that the corresponding next-hop route index value is a segment route index, and
具体实施时,首先根据实际应用环境选定压缩偏移表路由基准索引字段的位宽和压缩偏移表指针字段的位宽。During specific implementation, firstly, the bit width of the routing reference index field of the compression offset table and the bit width of the pointer field of the compression offset table are selected according to the actual application environment.
查找时,先使用欲查找的目标IPv4地址的高16位(IPH16)作为索引值,在64K段表中定位表项:判断该表项中压缩偏移表指针值(pOffetTable)是否无效(全1值)。若指针值无效,则此表项中段路由索引(NHseg)即为该目标IPv4地址所对应下一跳路由索引值(NHI);若否,则根据此表项中压缩偏移表指针值得到该IPv4地址对应压缩偏移表的入口地址、路由基准索引值(BaseIndex)和压缩表表项宽度索引值(WidthIndex),令当前下一跳路由索引值(NHIcurrent)等于段路由索引(NHseg)。计算出该压缩偏移表表项宽度EntryWidth,使用该IPv4地址的低16位(IPL16)和压缩偏移表表项宽度计算出此IPv4地址在压缩偏移表中的字偏移量(Offsetword)、比特偏移量(Offsetbit),访问此IPv4地址对应压缩偏移表中的字偏移量字,得到比特宽度为EntryWidth的下一跳路由索引值偏移量(OffsetNH)。判断下一跳路由索引偏移量值是否为全1值(2EntryWidth-1)。若是,则此IPv4地址对应下一跳路由索引(NHI)即等于当前一跳索引值(NHIcurrent);若否,通过公式4计算得到该IPv4地址的下一跳路由索引值(NHI)。When searching, first use the upper 16 bits (IP H16 ) of the target IPv4 address to be searched as the index value, and locate the entry in the 64K segment table: judge whether the compressed offset table pointer value (pOffetTable) in the entry is invalid (all 1 value). If the pointer value is invalid, then the segment route index (NH seg ) in this entry is the next-hop route index value (NHI) corresponding to the target IPv4 address; if not, it is obtained according to the compressed offset table pointer value in this entry The IPv4 address corresponds to the entry address of the compression offset table, the routing base index value (BaseIndex) and the compression table entry width index value (WidthIndex), so that the current next-hop routing index value (NHI current ) is equal to the segment routing index (NH seg ). Calculate the entry width EntryWidth of the compressed offset table, use the lower 16 bits (IP L16 ) of the IPv4 address and the entry width of the compressed offset table to calculate the word offset (Offset word ), bit offset (Offset bit ), access the word offset word in the compressed offset table corresponding to this IPv4 address, and obtain the next-hop routing index value offset (Offset NH ) whose bit width is EntryWidth. Determine whether the next-hop routing index offset value is all 1s (2 EntryWidth -1). If yes, the next-hop routing index (NHI) corresponding to this IPv4 address is equal to the current one-hop index value (NHI current ); if not, the next-hop routing index value (NHI) of the IPv4 address is calculated by
根据方法具体实施时所选取64K段表中下一跳路由基准索引字段和压缩偏移表指针字段位宽的不同,本方法的实施方式可具体分为二种情况:下一跳路由基准索引字段宽度为6比特,压缩偏移表字段位宽为16比特;下一跳路由基准索引字段宽度为8比特,压缩偏移表指针字段位宽为14比特。According to the difference in the bit width of the next hop routing reference index field and the compression offset table pointer field in the selected 64K segment table during the specific implementation of the method, the implementation of the method can be specifically divided into two situations: the next hop routing reference index field The width is 6 bits, and the bit width of the compressed offset table field is 16 bits; the width of the next hop routing reference index field is 8 bits, and the bit width of the compressed offset table pointer field is 14 bits.
64K段表中下一跳路由基准索引字段宽度为6比特The width of the next hop routing reference index field in the 64K segment table is 6 bits
64K段表中段路由索引字段位宽为8比特、下一跳路由基准索引字段位宽为6比特、压缩偏移表表项宽度索引字段位宽为2比特、压缩偏移表指针字段为16比特。各字段定义是:The segment routing index field in the 64K segment table has a bit width of 8 bits, the next hop routing reference index field has a bit width of 6 bits, the compressed offset table entry width index field has a bit width of 2 bits, and the compressed offset table pointer field has a 16-bit bit width . The field definitions are:
64K段表中下一跳路由索引基准字段宽度为8比特The width of the next hop routing index reference field in the 64K segment table is 8 bits
64K段表中段路由索引字段位宽为8比特、下一跳路由基准索引字段位宽为8比特、压缩偏移表项宽度索引字段位宽为2比特、压缩偏移表指针字段为14比特。压缩偏移表下一跳路由基准值等于段表中下一跳路由基准索引值。The segment routing index field in the 64K segment table has a bit width of 8 bits, the next hop routing reference index field has a bit width of 8 bits, the compression offset entry width index field has a bit width of 2 bits, and the compression offset table pointer field has a bit width of 14 bits. The next-hop routing reference value in the compression offset table is equal to the next-hop routing reference index value in the segment table.
若具体实施方案选取压缩偏移表指针字段位宽为16比特,压缩偏移表基准索引字段为6比特:压缩偏移表指针字段取值范围为0-65535,去掉一个表示无效指针的数值65535(0xFFFF)后,此字段仍可以区分65535个不同压缩偏移表;同时,压缩偏移表基准索引字段受位宽限制,取值范围为0-63,无法完全表示路由索引可能的取值,本方法采用了4倍取值的算法将路由基准索引值扩展成路由基准值。在某些情况下,偏移表的压缩效率受到一定限制。If the specific implementation plan selects the bit width of the pointer field of the compression offset table as 16 bits, and the reference index field of the compression offset table is 6 bits: the value range of the pointer field of the compression offset table is 0-65535, and a value 65535 representing an invalid pointer is removed (0xFFFF), this field can still distinguish 65535 different compression offset tables; at the same time, the compression offset table reference index field is limited by the bit width, and the value range is 0-63, which cannot fully represent the possible values of the routing index. This method adopts a 4 times value algorithm to expand the routing reference index value into the routing reference value. In some cases, the compression efficiency of offset tables is limited.
若具体实施方案选取压缩偏移表指针字段位宽为14比特,压缩偏移表基准索引字段为8比特:压缩偏移表基准索引字段可以表示0-255中任意数值,偏移表压缩效率得到提高;压缩偏移表指针字段取值范转为0-16383,去掉一个表示无效指针的数值16383(0x3FFF)后,此字段可区分的不同压缩偏移表数目为16383。If the specific implementation plan selects the bit width of the pointer field of the compression offset table as 14 bits, and the reference index field of the compression offset table is 8 bits: the reference index field of the compression offset table can represent any value in 0-255, and the compression efficiency of the offset table is obtained Improve; the value range of the compression offset table pointer field is changed to 0-16383. After removing a value 16383 (0x3FFF) indicating an invalid pointer, the number of different compression offset tables that can be distinguished by this field is 16383.
由上文分析可以看出,两种字段位宽定义组合具有各自的优、缺点。在实际实施本方法时,应根据方法所应用的实际网络路由情况加以选择。It can be seen from the above analysis that the combination of the two field bit width definitions has its own advantages and disadvantages. When this method is actually implemented, it should be selected according to the actual network routing conditions to which the method is applied.
64K段表各表项所对应的压缩偏移表由路由索引偏移字段顺序构成,每一表项表示一个路由索引偏移字段。The compression offset table corresponding to each entry of the 64K segment table is composed of routing index offset fields sequentially, and each entry represents a routing index offset field.
本发明可以在普通PC机或服务器上以软件方式编程实现,表构建及最长前缀查找过程由软件完成,64K段表及压缩偏移表存储在计算机内存中。The present invention can be realized by software programming on an ordinary PC or server, the process of table construction and longest prefix search is completed by software, and the 64K segment table and compressed offset table are stored in the computer memory.
本发明也可采用FPGA以硬件方式实现,具体实施系统结构图如图5所示。表构建和最长前缀查找过程由硬件逻辑单元完成,64K段表和压缩偏移表存储在静态随机存取存储器(SRAM)或动动态存取存储器(DRAM)。The present invention can also be realized in hardware by using FPGA, and the specific implementation system structure diagram is shown in FIG. 5 . The table construction and the longest prefix lookup process are completed by the hardware logic unit, and the 64K segment table and compressed offset table are stored in static random access memory (SRAM) or dynamic dynamic access memory (DRAM).
Claims (9)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2004100500691A CN100375463C (en) | 2004-07-02 | 2004-07-02 | A Method of Realizing Longest Prefix Address Routing Lookup Using Segment Compression Table |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB2004100500691A CN100375463C (en) | 2004-07-02 | 2004-07-02 | A Method of Realizing Longest Prefix Address Routing Lookup Using Segment Compression Table |
Publications (2)
Publication Number | Publication Date |
---|---|
CN1588907A CN1588907A (en) | 2005-03-02 |
CN100375463C true CN100375463C (en) | 2008-03-12 |
Family
ID=34602165
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CNB2004100500691A Expired - Lifetime CN100375463C (en) | 2004-07-02 | 2004-07-02 | A Method of Realizing Longest Prefix Address Routing Lookup Using Segment Compression Table |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN100375463C (en) |
Families Citing this family (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN100566359C (en) * | 2006-02-14 | 2009-12-02 | 北京直真节点技术开发有限公司 | Telecommunication field-oriented intelligent query and confirmation system for end-to-end service circuit resources |
CN100450100C (en) * | 2006-08-29 | 2009-01-07 | 华为技术有限公司 | A routing method and routing device |
CN101729417B (en) * | 2007-02-09 | 2011-12-21 | 北京直真节点技术开发有限公司 | Telecommunication-orientated intelligent inquiry and verification system for end-to-end service circuit resource |
CN102447604B (en) * | 2010-09-30 | 2016-01-27 | 迈普通信技术股份有限公司 | Routing table information storage means and routing device |
CN108156077B (en) * | 2016-12-02 | 2021-11-12 | 中兴通讯股份有限公司 | Segment routing forwarding method and device based on IPv6 data plane |
CN107896193B (en) * | 2017-12-29 | 2020-10-16 | 湖南恒茂高科股份有限公司 | Switch, and creation method and search method of lookup table of switch |
CN114827030B (en) * | 2022-03-26 | 2023-04-07 | 西安电子科技大学 | Flow classification device based on folded SRAM and table entry compression method |
CN119254695B (en) * | 2024-12-06 | 2025-04-22 | 天翼云科技有限公司 | Routing table compression method, device, computer equipment and storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
TW410292B (en) * | 1999-01-05 | 2000-11-01 | Huang Neng Fu | Method and system applicable for routing data construction and IP route lookup of super high speed switching router |
US6266706B1 (en) * | 1997-09-15 | 2001-07-24 | Effnet Group Ab | Fast routing lookup system using complete prefix tree, bit vector, and pointers in a routing table for determining where to route IP datagrams |
CN1314706A (en) * | 2000-03-21 | 2001-09-26 | 日本电气株式会社 | Method for forming element isolation zone |
CN1341314A (en) * | 1999-02-26 | 2002-03-20 | 红石通信公司 | Network router search engine using compressed tree forwarding table |
-
2004
- 2004-07-02 CN CNB2004100500691A patent/CN100375463C/en not_active Expired - Lifetime
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6266706B1 (en) * | 1997-09-15 | 2001-07-24 | Effnet Group Ab | Fast routing lookup system using complete prefix tree, bit vector, and pointers in a routing table for determining where to route IP datagrams |
TW410292B (en) * | 1999-01-05 | 2000-11-01 | Huang Neng Fu | Method and system applicable for routing data construction and IP route lookup of super high speed switching router |
CN1341314A (en) * | 1999-02-26 | 2002-03-20 | 红石通信公司 | Network router search engine using compressed tree forwarding table |
CN1314706A (en) * | 2000-03-21 | 2001-09-26 | 日本电气株式会社 | Method for forming element isolation zone |
Also Published As
Publication number | Publication date |
---|---|
CN1588907A (en) | 2005-03-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US7418505B2 (en) | IP address lookup using either a hashing table or multiple hash functions | |
CN101827137B (en) | A High Performance IPv6 Address Lookup Method Based on Hash Table and Extended Memory | |
US7443841B2 (en) | Longest prefix matching (LPM) using a fixed comparison hash table | |
CN101667958B (en) | Method for selecting hash function, and method and device for storing and searching routing table | |
CN101594319B (en) | Entry lookup method and entry lookup device | |
US20150074079A1 (en) | Longest Prefix Match Using Binary Search Tree | |
CN103107945B (en) | A kind of system and method for fast finding IPV6 route | |
Pao et al. | Efficient hardware architecture for fast IP address lookup | |
CN105141525B (en) | IPv6 method for searching route and device | |
CN101491015A (en) | Dynamic tree bitmap for IP lookup and update | |
CN114884877B (en) | IPv6 route searching method combining hash table and HOT | |
CN106330716B (en) | IP routing search method and device | |
CN104780101B (en) | Content center network Forwarding plane fib table structure and its search method | |
CN100375463C (en) | A Method of Realizing Longest Prefix Address Routing Lookup Using Segment Compression Table | |
CN105119834A (en) | Source address and destination address combined searching method based on composite trie tree structure | |
US7085235B2 (en) | Method and apparatus for constructing and searching IP address | |
US20050114393A1 (en) | Dynamic forwarding method using binary search | |
Hsieh et al. | A classified multisuffix trie for IP lookup and update | |
CN106953806A (en) | A method and system for matching IP addresses based on suffix index | |
Huang et al. | Memory-efficient IP lookup using trie merging for scalable virtual routers | |
CN109194574B (en) | IPv6 route searching method | |
KR100364433B1 (en) | IP address look-up method using a bit-vector table | |
Erdem et al. | Value-coded trie structure for high-performance IPv6 lookup | |
Hsiao et al. | A high-throughput and high-capacity IPv6 routing lookup system | |
Wang et al. | Towards dynamic and scalable high-speed IP address lookup based on B+ tree |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CX01 | Expiry of patent term | ||
CX01 | Expiry of patent term |
Granted publication date: 20080312 |