WO2020078012A1 - 一种压缩方法及装置、计算机可读存储介质 - Google Patents

一种压缩方法及装置、计算机可读存储介质 Download PDF

Info

Publication number
WO2020078012A1
WO2020078012A1 PCT/CN2019/089961 CN2019089961W WO2020078012A1 WO 2020078012 A1 WO2020078012 A1 WO 2020078012A1 CN 2019089961 W CN2019089961 W CN 2019089961W WO 2020078012 A1 WO2020078012 A1 WO 2020078012A1
Authority
WO
WIPO (PCT)
Prior art keywords
bit
searched
value
key value
index
Prior art date
Application number
PCT/CN2019/089961
Other languages
English (en)
French (fr)
Inventor
蒋震
胡国兴
方沛昱
周伟
Original Assignee
盛科网络(苏州)有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 盛科网络(苏州)有限公司 filed Critical 盛科网络(苏州)有限公司
Publication of WO2020078012A1 publication Critical patent/WO2020078012A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • H04L45/745Address table lookup; Address filtering
    • H04L45/7453Address table lookup; Address filtering using hashing
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/38Flow control; Congestion control by adapting coding or compression rate

Definitions

  • the present application relates to the field of communication technology, and in particular, to a compression method and device, and a computer-readable storage medium.
  • the forwarding engine of data communication equipment is the main component of data network exchange.
  • the forwarding engine needs to have a variety of information tables, including address tables and policy tables. By querying the information table, you can get forwarding destinations and policies for data streams.
  • For packet switching networks when data packets pass, forward The engine will generate key values based on the data packet header in the data packet, which contains the forwarding address and other information, which is used to index the information table. If there is an entry in the index information table that matches this key value, the associated data is retrieved.
  • the associated data (Associated Date, AD) stores the forwarding or policy behavior that the data packet should perform. By applying the pre-set Behavior, the forwarding engine implements forwarding or supervision of data packets.
  • the hash table is the logical organization method of the information table, it is stored in the random access memory (Random Access Memory, RAM), and the records in the hash table are accessed by mapping the key value to a location in the hash table, which constitutes forwarding
  • RAM Random Access Memory
  • the key value is regarded as a field, and the hash table is compressed by deleting some of the fields, and there is a problem that the RAM depth of the hash table is limited.
  • the embodiments of the present application are expected to provide a compression method and device, and a computer-readable storage medium, which can save storage space, and at the same time, the RAM depth is not limited.
  • an embodiment of the present application provides a compression method.
  • the method includes:
  • n bits of key value to be searched from the message to be forwarded n is a positive integer
  • n-bit to-be-searched key value splits the n-bit to-be-searched key value to obtain m-bit to-be-searched key value and n-m-to-be-searched key value; m is a positive integer less than n;
  • an embodiment of the present application provides a compression device.
  • the compression device includes:
  • the first obtaining module is configured to obtain n key values to be found from the message to be forwarded;
  • the first splitting module is configured to split the n-bit to-be-searched key values according to preset routing specifications to obtain m-bit to-be-searched key values and n-m-to-be-searched key values;
  • the first obtaining module is configured to perform a hash operation on the n-m-bit to-be-searched key value to obtain an m-bit updated intermediate value;
  • the second obtaining module is configured to perform a reversible operation on the m-bit updated intermediate value and the m-bit to-be-searched key value to obtain an m-bit to-be-searched index value, and the m-bit to-be-searched index value is used to index the corresponding Association data, the association data includes a forwarding port.
  • an embodiment of the present application provides a compression device, wherein the compression device includes at least a processor, a memory storing executable instructions of the processor, and a device for connecting the processor and the memory On the bus, when the instruction is executed, the processor implements the compression method provided in the foregoing embodiment when executed.
  • an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the compression method provided by the foregoing embodiment is implemented.
  • Embodiments of the present application provide a compression method and device, and a computer-readable storage medium.
  • the compression method includes: obtaining n-bit to-be-searched key values from a message to be forwarded; according to a preset routing rule, Split the search key value to obtain m-bit search key value and nm-bit search key value; perform hash operation on the nm-bit search key value to obtain m-bit updated intermediate value; update the m-bit update value And the m-bit to-be-searched key value is subjected to a reversible operation to obtain an m-bit to-be-searched index value, and the m-bit to-be-searched index value is used to index corresponding associated data, and the associated data includes a forwarding port.
  • the original n-bit to be searched key value is improved to only need the nm-bit to be searched key value to obtain the m-bit to be searched index value, thereby compressing the bit width of the table entry and
  • FIG. 1 is a schematic flowchart 1 of an implementation method of a compression method according to an embodiment of the present application
  • FIG. 2 is a second schematic flowchart of an implementation method of a compression method according to an embodiment of the present application
  • FIG. 3 is a schematic flowchart 3 of an implementation method of a compression method according to an embodiment of the present application
  • FIG. 4 is a fourth schematic flowchart of an implementation method of a compression method according to an embodiment of the present application.
  • FIG. 5 is a schematic flowchart 5 of an implementation method of a compression method according to an embodiment of the present application.
  • FIG. 6 is a sixth schematic flowchart of an implementation method of a compression method according to an embodiment of the present application.
  • FIG. 7A is a schematic diagram 1 of an exemplary key value storage provided by an embodiment of the present application.
  • FIG. 7B is a second schematic diagram of an exemplary key value storage provided by an embodiment of the present application.
  • FIG. 8 is a schematic diagram of existing related data search
  • FIG. 9 is an example diagram of searching for related data after compression provided by an embodiment of the present application.
  • FIG. 10 is a schematic diagram of a process of specifically searching for related data after compression in an embodiment of the present application.
  • FIG. 11 is a schematic structural diagram 1 of a composition of a compression device according to an embodiment of this application.
  • FIG. 12 is a second schematic structural diagram of a compression device according to an embodiment of the present application.
  • FIG. 1 is a schematic flowchart 1 of an implementation method of a compression method according to an embodiment of the present application.
  • a compression device is used as a router as an example.
  • the method for the router to implement compression may include the following steps:
  • Step 101 Obtain n-bit to-be-searched key values from the message to be forwarded; n is a positive integer.
  • the router when the router receives the packet to be forwarded, at the forwarding level, the packet to be forwarded comes in from the router ingress port, the router parses the destination address of the packet to be forwarded, and the corresponding virtual route is processed by the packet engine Forwarding identification (Virtual RoutingForwardingIdentification, VRFID), if the message to be forwarded is expected to be routed, you can use the key to find ⁇ address, VRFID ⁇ to look up the table engine search, this search method is to find the hash table, which The hash configuration process and the search process must be the same, and the subsequent compression method is implemented based on the key value to be searched.
  • VRFID Virtual RoutingForwardingIdentification
  • the router has multiple interfaces for forwarding packets to be forwarded in the network
  • the routing table is stored in the router's memory, and is used to instruct the router to forward the packets to be forwarded to the correct destination.
  • the functional level of the router Including the control plane and the forwarding plane, where the control plane forms and maintains a routing table, and the forwarding plane uses the global routing table to forward the packets to be forwarded.
  • IP Internet Protocol
  • the index value to be searched is obtained according to the key value to be searched, the target key value stored corresponding to the index value is taken out, and the packet to be forwarded is forwarded based on the target key value and the key value to be forwarded.
  • the key value to be searched for is ⁇ address: 32’h01010101, VRFID: 16’h1D3D ⁇ .
  • Step 102 Split the n-bit to-be-searched key values according to the preset routing specifications to obtain m-bit to-be-searched key values and n-m-to-be-searched key values; m is a positive integer less than n.
  • the router may first calculate m by calculating the routing specifications, and then split the n-bit key value to be searched according to the calculated m to obtain the m-bit key value to be searched. And nm to find the key value.
  • the key value to be searched is ⁇ address: 32'h01010101, VRFID: 16'h1D3D ⁇
  • the key value to be searched is split, and the search is to be performed VRFID in the key value: 16'h1D3D split to get VRFID 0 to 10 bits is 16'h53D, that is, 11 bit VRFID is 11'h53D; VRFID 11 bits to 15 bits is 5'h3, that is, 5 bit VRFID is 5'h3.
  • Step 103 Perform a hash operation on the n-m-bit to-be-searched key value to obtain an m-bit updated intermediate value.
  • the router after generating the updated key value, can transform the updated key value through a hash operation to obtain a fixed-length m-bit updated intermediate value.
  • the hash operation is to convert an input of any length into a fixed-length output through a hash algorithm.
  • Step 104 Perform a reversible operation on the m-bit updated intermediate value and the m-bit to-be-searched key value to obtain the m-bit to-be-searched index value.
  • the router may perform XOR processing on the two to obtain the m-bit to-be-searched index value, and the m-bit to-be-searched index value is used for indexing
  • the associated data includes a forwarding port through which the packet to be forwarded is forwarded.
  • the reversible operation may be the same or the inverse operation or the exclusive or inverse operation, which is not limited herein in the embodiments of the present application.
  • the 11-bit updated intermediate value is 11'h4dd
  • the 11-bit VRFID is 11'h53D
  • 11'h4dd and 11'h53D are XORed
  • the 11-bit search index value is 11'h220.
  • FIG. 2 is a second schematic flowchart of an implementation of a compression method according to an embodiment of the present application.
  • the router searches n bits of the key to be searched according to preset routing rules
  • the key value is split to obtain the m-bit key value to be searched and the nm-bit key value to be searched, that is, the method for the router 102 to implement compression may include the following steps:
  • Step 102a According to the routing specifications of the message to be forwarded, obtain the index value of the preset hash table in m bits.
  • step 102b according to the index value of the preset hash table, the n-bit to-be-searched key value is split into m-bit to-be-searched key value and n-m-to-be-searched key value.
  • the router stores the key value to be searched in RAM, and the number of entries stored in the RAM may be the routing specification of the packet to be forwarded.
  • the routing specification of the packet to be forwarded is 2048, which is performed through log 2 (2048)
  • FIG. 3 is a schematic diagram 3 of an implementation method of a compression method according to an embodiment of the present application.
  • the router performs reversible on the intermediate value and m-bit to-be-searched key value after m-bit update
  • the method for the router to implement compression may further include the following steps:
  • Step 105 Index the m-bit to-be-searched index value in a preset hash table.
  • the router may use the m-bit to-be-searched index value to index the target key value stored in a corresponding position in advance.
  • Step 106a When it is determined that the index position corresponding to the m-bit to-be-searched index value is empty, stop forwarding the packet to be forwarded.
  • Step 106b When it is determined that the index position corresponding to the m-bit index value to be searched is not empty, acquire the n-m-bit target key value stored at the index position corresponding to the m-bit index value to be searched.
  • the router after obtaining the m-bit index value to be searched, the router also needs to retrieve the target key value stored at the corresponding position of the m-bit index value to be searched, and splice the target key value to obtain the n-bit search key value, and Compare with the key value to be searched to confirm whether to forward the packet to be forwarded.
  • the router needs to determine the m-bit Find whether the index position corresponding to the index value is empty, if it is determined to be empty, it means that the index value to be found through m bits cannot index the corresponding associated data, that is, the forwarding of the packet to be forwarded needs to be stopped, if it is determined to be non-empty, then Acquire the target key value stored in the index position corresponding to the m-bit index value to be searched, which is used to subsequently obtain the key value after the search, and further determine whether the packet to be forwarded can be forwarded.
  • the address to be forwarded is 3.3.3.3
  • the VRFID is 3479
  • the key value to be searched is ⁇ address: 32'h03030303
  • 11-bit VRFID is 11'h597 and 5-bit VRFID is 5'h1
  • the updated key value is ⁇ address: 32'h03030303, VRFID: 5'h1 ⁇
  • the hash value of the updated key value is calculated Get the 11-bit updated intermediate value 11'h17F, XOR the 11-bit updated intermediate value 11'h17F with the 11-bit VRFID to 11'h597, get the 11-bit index value 11'h4E8 to be searched, take out 11 bits to find The storage record corresponding to the index value 11'h4E8.
  • the packet to be forwarded will not be forwarded. If it is found to be non-empty, the 11-bit index value 11'h4E8 corresponding to the index to be found is obtained The stored nm-bit target key value of the location.
  • FIG. 4 is a fourth schematic flowchart of an implementation of a compression method proposed in an embodiment of the present application.
  • the router indexes the preset hash table according to the index value to be searched for in m bits before, that is, before step 105, the method for the router to implement compression may also include the following steps:
  • Step 109 Compress the n-bit pre-configured key value to obtain a preset hash table, and the preset hash table stores n-m-bit pre-configured key values after compression processing.
  • the router needs to configure the hash table so that it can be found in the preset hash table according to the way of storing data during configuration Corresponding to the stored associated data, so as to forward the packet to be forwarded through the found associated data.
  • the embodiment of the present application splits the pre-configured key value, that is, the n-bit pre-configured key value, to obtain the compressed nm-bit pre-configured key value, and then performs a hash operation on the nm-bit pre-configured key value to obtain the m-bit pre-configured intermediate value.
  • the router is used to store key values and corresponding associated data required for packet forwarding.
  • FIG. 5 is a schematic flowchart 5 of an implementation of a compression method according to an embodiment of the present application.
  • the router obtains m when the index position corresponding to the m-bit index value to be searched is not empty.
  • the method for the router to implement compression may further include the following steps:
  • Step 107b According to the n-m-bit target key value and the m-bit index value to be searched, obtain the n-bit search key value.
  • the router after acquiring the nm-bit target key value corresponding to the position of the m-bit search index value, the router needs to perform splicing and restoration on the nm-bit target key value and the m-bit search index value to obtain the n-bit search key value .
  • Step 108b Forward the packet to be forwarded based on the n-bit search key value and the n-bit search key value.
  • the router after obtaining the searched key value, the router needs to compare the searched key value with the searched key value to confirm whether to forward the packet to be forwarded.
  • the searched key value is n bits
  • the search key value is different, stop forwarding the message to be forwarded; when it is determined that the n-bit search key value is the same as the n-bit search key value, the index is obtained according to the m-bit search index value to obtain the forwarding port stored in the corresponding location. The forwarding port forwards the packet to be forwarded.
  • FIG. 6 is a schematic flowchart 6 of an implementation of a compression method proposed in an embodiment of the present application.
  • the router obtains n-bit search according to the nm-bit target key value and m-bit search index value
  • the post key value that is, the method for the router to achieve compression in step 107b, may include the following steps:
  • Step 107b1 Perform a hash operation on the n-m-bit target key value to obtain an m-bit target intermediate value.
  • Step 107b2 Perform a reversible operation on the m-bit target intermediate value and the m-bit to-be-searched index value to obtain the m-bit target key value.
  • Step 107b3 According to the m-bit target key value and the n-m target key value, generate an n-bit search key value.
  • the router stitches and restores the m-bit target key value and the n-m target key value to obtain the searched key value.
  • the target key value includes a 32-bit target address and a 5-bit VRFID, that is, the target key value is ⁇ target address: 32'h02020202, the target VRFID: 5'h3 ⁇ , and the 11-bit target key value is 11'h404.
  • the 37-bit target key value and 11-bit target VRFID are combined to obtain 48-bit search key value ⁇ target address: 32'h02020202, target VRFID: 16'h1c04 ⁇ .
  • the packet to be forwarded is forwarded, that is, the method for implementing compression in step 108b may include the following steps:
  • Step 108b1 when it is determined that the key value after n-bit search is different from the key value to be searched for n bits, stop forwarding the packet to be forwarded.
  • Step 108b2 When it is determined that the n-bit search key value is the same as the n-bit search key value, indexing is performed according to the m-bit search index value to obtain a forwarding port corresponding to the location storage; the forwarding packet is forwarded through the forwarding port.
  • the router after obtaining the searched key value, the router needs to compare the searched key value with the searched key value to confirm whether to forward the packet to be forwarded.
  • the 48-bit to-be-searched key value is ⁇ address: 32'hC0A80303, VRFID: 16'd5124 ⁇
  • the updated key value is ⁇ address: 32'hC0A80303, VRFID: 5'h1 ⁇ , hash the updated key value to obtain 11-bit updated intermediate value 11'h624, and 11-bit updated intermediate value
  • the value 11'h624 and the remaining 11 bits of the VRFID to be forwarded are XORed to 11'h404 to obtain the 11-bit search index value 11'h220, take out the 11-bit search index value 11'h220 corresponding to the stored 37 bits
  • the target key value includes 32-bit target address 32'h02020202 and 5-bit target VRFID 5'h3, 37-bit target key value ⁇ target address: 32'h02020202,
  • the 32-bit to-be-forwarded address in the message to be forwarded is 1.1.1.1 and the 16-bit VRFID is 7485
  • the 48-bit to-be-searched key value is ⁇ address: 32'h01010101, VRFID: 16'd7485 ⁇
  • the updated key value Including 32-bit address 32'h01010101 and 5-bit VRFID is 5'h3, that is, the updated key value is ⁇ address: 32'h01010101, VRFID: 5'h3 ⁇
  • the 11-bit updated intermediate value 11'h1E0 and the remaining 11 VRFID in the message to be forwarded are XORed to 11'h53d to get 11 bits to be searched.
  • the index value is 11'h4dd, take out 11 bits
  • the 37-bit target key value corresponding to the search index value 11'h4dd includes the 32-bit target address 32'h01010101 and the 5-bit target VRFID 5'h3, and the 37-bit target key value ⁇ target address: 32'h01010101, target VRFID: 5'h3 ⁇ and 11-bit target key value 11'h53d are combined to obtain 48-bit search key value ⁇ target address: 32'h01010101, target VRFID: 16'd7485 ⁇ , after 48-bit search key value ⁇ target address : 32'h01010101, target VRFID: 16'd7485 ⁇ and 48-bit key value to be found ⁇ Address: 32'h01010101, VRFI D: 16'd7485 ⁇
  • the key value to be searched is exactly the same as the key value after the search, and the match is considered successful.
  • the 11-bit index value 11'h4dd to be searched is indexed to the
  • FIG. 7A is an exemplary schematic diagram of key value storage provided by an embodiment of the present application, as shown in FIG. 7A
  • the key value stored in the router before compression is 48 bits.
  • FIG. 7B is a schematic diagram 2 of an exemplary key value storage provided by an embodiment of the present application.
  • An embodiment of the present application provides a compression method.
  • the compression method includes: obtaining n-bit to-be-searched key values from a message to be forwarded; according to preset routing rules, splitting n-bit to-be-searched key values to obtain m-bit to-be-searched values Find the key value and nm-bit key value to be searched; perform hash operation on the nm-bit key value to be searched to obtain the m-bit updated intermediate value; perform the m-bit updated key value and the m-bit to be searched key value Reversible operation to obtain m-bit index value to be searched.
  • the m-bit index value to be searched is used to index the associated data corresponding to the index data.
  • the associated data includes the forwarding port. In this way, the original n-bit to be searched key value is improved to only need Through the updated key value of the nm bit, the m-bit index value to be searched can be obtained, thereby compressing the bit width of the table entry and saving the
  • the router directly obtains the key value to be found from the packet to be forwarded.
  • the address to be forwarded in the packet to be forwarded and the VRFID can be formed into a key according to the bit width of the original information.
  • FIG. 8 is a schematic diagram of an existing search for associated data. As shown in FIG.
  • the router obtains the key value Key ′ in the packet to be forwarded, and obtains the m-bit index value by configuring the same hash operation on the key value Key ′ Index ', read the m-bit index value Index' corresponding to the key value stored at the corresponding position, and compare with the key value Key ', if they are the same, it means that the match, can be indexed to the corresponding index by the m-bit index value Index' Associated data, to forward the packet to be forwarded, if it is different, it means that there is no match, and the packet cannot be forwarded, so the width of the key is the width of the original information, without compression, not As to save storage space effect.
  • the router compresses the n-bit key value, that is, when configuring, the n-bit pre-configured key value is split to obtain the nm-bit pre-configuration Key value and m-bit pre-configured key value, and then hash operation of nm-bit pre-configured key value to obtain m-bit pre-configured intermediate value, through the m-bit pre-configured intermediate value and n-bit pre-configured key value, the remaining m Perform reversible calculation on the bit pre-configured key value to obtain m-bit pre-configured index value.
  • FIG. 9 is a schematic diagram of searching for related data after compression provided by an embodiment of the present application.
  • the hash table is pre-stored after being configured.
  • the router obtains the index value according to the configuration method and then retrieves the pre- The stored key value, and then restore the pre-stored key value to obtain the searched key value, compare the searched key value with the searched key value, so as to realize the forwarding of the message to be forwarded
  • FIG. 10 is an embodiment of this application
  • a schematic diagram of a specific search process for related data after compression is provided.
  • the method for implementing compression in a router according to an embodiment of the present application may include the following steps:
  • Step 201 Acquire the key value Key nm after the nm bit update according to the n-bit key value Key n to be found.
  • the router first obtains the preset hash table index value as m bits according to the routing specifications, and then disassembles the n-bit key value in the key value Key n to be searched according to the preset hash table index value as m bits. It is divided into nm-bit key value to be searched and m-bit key value to be searched, and the key value Key nm after nm-bit update is obtained.
  • Step 202 Perform a hash operation on the key value Key nm after the nm bits are to be updated to obtain m-bit updated intermediate values Temp m .
  • Step 203 The m-bit to-be-searched intermediate value Temp m is XORed with the remaining m-bit to-be-searched key values Key m to obtain the m-bit to-be-searched index value Index m .
  • Index m OP (Temp m , Key m ), the router is used to store the key value and corresponding associated data needed for packet forwarding, and here the m-bit index value to be searched Index m is used for index correspondence The key value and corresponding associated data stored in the location.
  • Step 204 Index the nm-bit target key value Key nm 'stored in the corresponding position through the m-bit index value to be found Index m .
  • the router can index the nm-bit target stored in the corresponding position through the m-bit index value to be searched Index m Key value Key nm '.
  • Step 205 Perform a hash operation on the nm-bit target key value Key nm 'to obtain the m-bit target intermediate value Temp m '.
  • Step 206 Perform a reversible operation on the m-bit target intermediate value Temp m 'and the m-bit index value to be found Index m to obtain the m-bit target key value Key m '.
  • Step 207 According to the nm-bit target key value Key nm 'and the m-bit target key value Key m ', obtain the n-bit searched key value Key n '.
  • the router after obtaining the m-bit target key value, merges the nm-bit target key value Key nm ′ and the m-bit target key value Key m ′ to obtain the n-bit search key value Key n ′.
  • Step 208 Based on the n-bit key value Key n 'and the n-bit key value Key n to be searched, obtain the associated data AD corresponding to the m-bit search index value.
  • the router compares the key value n after searching n bits and the key value n to search for n , and when it is determined that the key value after searching n bits is different from the key value to search for n, stop forwarding The packet to be forwarded; when it is determined that the n-bit search key value is the same as the n-bit search key value, the index is obtained according to the m-bit search index value to obtain the forwarding port of the corresponding location storage, and the forwarded packet is forwarded through the forwarding port .
  • the embodiment of the present application can improve the original n-bit to-be-searched key value to only need to update the n-m-bit key value to obtain the m-bit to-be-searched index value, thereby compressing the bit width of the table entry and saving storage space.
  • FIG. 11 is a schematic structural diagram 1 of a compression device proposed by an embodiment of the present application.
  • the compression device 1100 includes a first obtaining module 1101, a first splitting module 1102, a first obtaining module 1103, and a second obtaining module 1104, where,
  • the first obtaining module 1101 is configured to obtain n-bit to-be-searched key values from the message to be forwarded;
  • the first splitting module 1102 is configured to split the n-bit to-be-searched key values according to preset routing specifications to obtain m-bit to-be-searched key values and n-m-to-be-searched key values;
  • the first obtaining module 1103 is configured to perform a hash operation on the n-m-bit to-be-checked key value to obtain an m-bit updated intermediate value;
  • the second obtaining module 1104 is configured to perform a reversible operation on the m-bit updated intermediate value and the m-bit to-be-searched key value to obtain an m-bit to-be-searched index value, which is used for index correspondence Associated data, the associated data includes a forwarding port.
  • the first splitting module 1102 is configured to: according to the routing specification of the packet to be forwarded, obtain the index value of the preset hash table as m bits; according to the index value of the preset hash table as m Bit, the n-bit key value to be searched is divided into m-bit key value to be searched and nm-bit key value to be searched.
  • the compression device 1100 may further include:
  • the index module 1105 is configured to index the m-bit to-be-searched index value in a preset hash table search
  • the determining module 1106 is configured to stop forwarding the packet to be forwarded when it is determined that the index position corresponding to the m-bit index value to be searched is empty; when it is determined that the index position corresponding to the m-bit index value to be searched is not empty To obtain the nm-bit target key value stored in the index position corresponding to the m-bit to-be-searched index value.
  • the compression device 1100 may further include:
  • the third obtaining module 1107 is configured to compress the n-bit pre-configured key value to obtain a preset hash table, and the preset hash table stores n-m-bit pre-configured key values after compression processing.
  • the compression device 1100 may further include:
  • the fourth obtaining module 1108 is configured to obtain the n-bit search key value according to the n-m-bit target key value and the m-bit search index value;
  • the forwarding module 1109 is configured to forward the message to be forwarded based on the n-bit search key value and the n-bit search key value.
  • the fourth obtaining module 1108 is configured to: hash the nm-bit target key value to obtain an m-bit target intermediate value; and perform the m-bit target intermediate value and the m-bit target value Perform a reversible operation on the search index value to obtain an m-bit target key value; generate an n-bit search key value according to the m-bit target key value and the nm-bit target key value.
  • the forwarding module 1109 is configured to stop forwarding the packet to be forwarded when it is determined that the n-bit to-be-searched key value and the n-bit to-be-searched key value are different; when it is determined that the When the n-bit to-be-searched key value is the same as the n-bit to-be-searched key value, indexing is performed according to the m-bit to-be-searched index value to obtain a forwarding port for the corresponding location storage; the forwarding port is used to perform the forwarding packet Forward.
  • An embodiment of the present application provides a compression device, which can improve the original n-bit key value to be searched to obtain the m-bit search index value only by updating the key value through nm bits, thereby compressing the bit of the table entry Wide and saves storage space.
  • FIG. 12 is a schematic structural diagram 2 of a composition of a compression device provided by an embodiment of the present application.
  • the above compression device At least includes a processor 01, a memory 02, a communication interface 03, and a communication bus 04, wherein the communication bus 04 is used to implement connection communication between the processor and the memory; the communication interface 03 is used to receive and send information; the processor 01 is used
  • the compression program stored in the memory 02 is executed to implement the steps in the compression method provided in the first to third embodiments.
  • the compression device provided by the embodiment of the present application can improve the original n-bit to be searched key value to obtain the m-bit to be searched index value only by the key value updated through the nm bit, thereby compressing the bit width of the table entry and saving Storage space.
  • the processor can be an application specific integrated circuit (Application Specific Integrated Circuit, ASIC) for forwarding high-speed network data
  • the memory can be an embedded static random access memory (embedded Static Random-Access Memory, eSRAM And embedded dynamic random access memory (embedded Dynamic Random Access Memory, eDRAM).
  • each component in this embodiment may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware or software function module.
  • the compression device provided in the above embodiment performs compression
  • only the above division of each program module is used as an example for illustration.
  • the above processing may be allocated by different program modules according to needs, that is, the device The internal structure of is divided into different program modules to complete all or part of the processing described above.
  • the compression device and the compression method embodiment provided in the above embodiments belong to the same concept. For the specific implementation process, refer to the method embodiment, and details are not described here.
  • embodiments of the present application provide a computer-readable storage medium on which a compression program is stored, and when the compression program is executed by a processor, the compression method in one or more embodiments described above is implemented.
  • the disclosed device and method may be implemented in other ways.
  • the device embodiments described above are only schematic.
  • the division of the unit is only a division of logical functions.
  • there may be another division manner for example, multiple units or components may be combined, or Can be integrated into another system, or some features can be ignored, or not implemented.
  • the coupling or direct coupling or communication connection between the displayed or discussed components may be through some interfaces, and the indirect coupling or communication connection of the device or unit may be electrical, mechanical, or other forms of.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本申请实施例公开了一种压缩方法及装置、计算机可读存储介质,所述压缩方法包括:从待转发报文中获取n位待查找键值;根据预设路由规格,将所述n位待查找键值进行拆分得到m位待查找键值和n-m位待查找键值;对所述n-m位待查找键值进行哈希运算,得到m位更新后的中间值;对所述m位更新后的中间值和所述m位待查找键值进行可逆运算,得到m位待查找索引值,所述m位待查找索引值用于索引对应关联数据,关联数据包括转发端口。

Description

一种压缩方法及装置、计算机可读存储介质
相关申请的交叉引用
本申请基于申请号为201811215545.9、申请日为2018年10月18日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此以引入方式并入本申请。
技术领域
本申请涉及通信技术领域,尤其涉及一种压缩方法及装置、计算机可读存储介质。
背景技术
数据通信设备的转发引擎,是数据网络交换的主要部件。转发引擎内部需要有多种信息表,包括地址表、策略表等,通过查询信息表,可以得到针对数据流的转发目的地、策略等信息,对于包交换网络,当数据报文通过时,转发引擎会根据数据报文中的数据报文包头,其中包头含有转发地址等信息来产生键值,用于索引信息表。如果索引信息表中有符合这个键值的条目,则取出其关联数据,其中关联数据(Associated Date,AD)中存储了数据报文应当进行的转发或策略行为,通过对报文应用预先设置的行为,转发引擎实现了对数据报文的转发或监管。
鉴于散列表是信息表的逻辑组织方法,其存储在随机存取存储器(Random Access Memory,RAM)中,通过将键值映射到散列表中的一个位置来访问散列表中的记录,构成了转发引擎的主要设计成本。然而,现有技术是将键值视为字段,通过删除其中部分字段来进行压缩散列表,存在散列表的RAM深度受限制的问题。
发明内容
本申请实施例期望提供一种压缩方法及装置、计算机可读存储介质,能够节省存储空间,同时RAM深度也不会被限制。
本申请实施例的技术方案是这样实现的:
第一方面,本申请实施例提供一种压缩方法,所述方法包括:
从待转发报文中获取n位待查找键值;n为正整数;
根据预设路由规格,将所述n位待查找键值进行拆分得到m位待查找键值和n-m位待查找键值;m为小于n的正整数;
对所述n-m位待查找键值进行哈希运算,得到m位更新后的中间值;
对所述m位更新后的中间值和所述m位待查找键值进行可逆运算,得到m位待查找索引值,所述m位待查找索引值用于索引对应关联数据,关联数据包括转发端口。
第二方面,本申请实施例提供一种压缩装置,所述压缩装置包括:
第一获取模块,配置为从待转发报文中获取n位待查找键值;
第一拆分模块,配置为根据预设路由规格,将所述n位待查找键值进行拆分得到m位待查找键值和n-m位待查找键值;
第一得到模块,配置为对所述n-m位待查找键值进行哈希运算,得到m位更新后中间值;
第二得到模块,配置为对所述m位更新后中间值和所述m位待查找键值进行可逆运算,得到m位待查找索引值,所述m位待查找索引值用于索引对应的关联数据,所述关联数据包括转发端口。
第三方面,本申请实施例提供一种压缩装置,其中,所述压缩装置至少包括处理器、存储有所述处理器可执行指令的存储器,和用于连接所述处理器、所述存储器的总线,当所述指令被执行时,所述处理器执行时实现上述实施例提供的压缩方法。
第四方面,本申请实施例提供一种计算机可读存储介质,其上存储计算机程序,所述计算机程序被处理器执行时实现上述实施例提供的压缩方法。
本申请实施例提供了一种压缩方法及装置、计算机可读存储介质,该压缩方法包括:从待转发报文中获取n位待查找键值;根据预设路由规则,将所述n位待查找键值进行拆分得到m位待查找键值和n-m位待查找键值;对所述n-m位待查找键值进行哈希运算,得到m位更新后的中间值;对所述m位更新后的中间值和所述m位待查找键值进行可逆运算,得到m位待查找索引值,所述m位待查找索引值用于索引对应的关联数据,所述关联数据包括转发端口,如此,将原来需要n位待查找键值改进成只需要通过n-m位待查找键值便可以得到m位待查找索引值,从而压缩了表项的位宽,节省了存储空间。
附图说明
图1为本申请实施例提出的一种压缩方法的实现流程示意图一;
图2为本申请实施例提出的一种压缩方法的实现流程示意图二;
图3为本申请实施例提出的一种压缩方法的实现流程示意图三;
图4为本申请实施例提出的一种压缩方法的实现流程示意图四;
图5为本申请实施例提出的一种压缩方法的实现流程示意图五;
图6为本申请实施例提出的一种压缩方法的实现流程示意图六;
图7A为本申请实施例提供的一种示例性的键值存储示意图一;
图7B为本申请实施例提供的一种示例性的键值存储示意图二;
图8为现有的查找关联数据的示意图;
图9为本申请实施例提供的压缩后查找关联数据的示例图;
图10为本申请实施例压缩后具体查找关联数据的流程示意图;
图11为本申请实施例提出的一种压缩装置组成结构示意图一;
图12为本申请实施例提供的一种压缩装置组成结构示意图二。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述。
实施例一
本申请实施例提供一种压缩方法,图1为本申请实施例提出的一种压缩方法的实现流程示意图一,如图1所示,在本申请实施例中,以压缩装置为路由器为例进行本实施例的说明,路由器实现压缩的方法可以包括以下步骤:
步骤101、从待转发报文中获取n位待查找键值;n为正整数。
本申请实施例中,路由器接收到待转发报文的时候,在转发层面,待转发报文从路由器入端口进来,路由器解析得到待转发报文的目的地址,经过包引擎处理得到对应的虚拟路由转发标识(Virtual Routing Forwarding Identification,VRFID),如果待转发报文期望做路由,则可以使用待查找键值{地址,VRFID}去查表引擎查找,这种查找方式就是查找散列表的方式,其散列配置过程和查找过程必须相同,基于待查找键值进行后续的压缩的方法的实现。
需要说明的是,路由器具有多个接口,用于在网络中转发待转发报文,路由表存储在路由器的内存中,用于指示路由器将待转发报文转发至正确目的地,路由器的功能层面包括控制层面和转发层面,其中控制层面形成和维护路由表,转发层面使用全局路由表进行待转发报文的转发。
在控制层面,如果是网际协议(Internet Protocol,IP)路由转发,在VRFID为7485进行路由转发时,期望如下:当待转发的报文中的地址是1.1.1.1,期望转发目的端口为端口4;当待转发的报文中的地址是2.2.2.2,期望其转发目的端口为端口2,这时在控制层面会配置对应的键值并存储 RAM中。
在转发层面,根据待查找键值获取待查找的索引值,取出索引值对应存储的目标键值,基于目标键值和待转发键值,实现对待转发报文的转发。
示例性地,待转发报文中32位地址为32’h01010101和16位VRFID为16’h1D3D,则待查找键值为{地址:32’h01010101,VRFID:16’h1D3D}。
步骤102、根据预设路由规格,将n位待查找键值进行拆分得到m位待查找键值和n-m位待查找键值;m为小于n的正整数。
本申请实施例中,在获取待查找键值之后,路由器可以先通过对路由规格进行计算得到m,再根据计算得到的m,将n位待查找键值进行拆分得到m位待查找键值和n-m位待查找键值。
示例性地,待查找键值为{地址:32’h01010101,VRFID:16’h1D3D},取路由规格为2048,即2048=2 11得到m=11,将待查找键值进行拆分,对待查找键值中的VRFID:16’h1D3D拆分得到VRFID的0位到10位为16’h53D,即11位VRFID为11’h53D;VRFID的11位到15位为5’h3,即5位VRFID为5’h3。
步骤103、对n-m位待查找键值进行哈希运算,得到m位更新后的中间值。
本申请实施例中,在生成更新后的键值之后,路由器通过哈希运算可以将更新后的键值进行变换得到固定长度的m位更新后中间值。
需要说明的是,哈希运算是把任意长度的输入,通过哈希算法变换成固定长度的输出。
示例性地,待查找键值为{地址:32’h01010101,VRFID:16’h1D3D},取m=11,对待转发键值进行拆分,将VRFID:16’h1D3D进行拆分得到11位VRFID为11’h53D;5位VRFID为5’h3,则更新后的键值为{地址:32’h01010101,VRFID:5’h3}进行哈希运算可以得11位更新后中间值为 11’h4dd。
步骤104、对m位更新后的中间值和m位待查找键值进行可逆运算,得到m位待查找索引值。
本申请实施例中,在得到m位更新后中间值和m位待查找键值之后,路由器可以对两者进行异或处理,得到m位待查找索引值,m位待查找索引值用于索引对应位置的键值和对应位置存储的关联数据,关联数据包括转发端口,待转发报文通过该转发端口进行转发。
需要说明的是,可逆运算可以是同或逆运算也可以是异或逆运算,本申请实施例这里不做限定。
示例性地,11位更新后中间值为11’h4dd,11位VRFID为11’h53D,对11’h4dd和11’h53D进行异或处理,可得11位待查找索引值为11’h220。
图2为本申请实施例提出的一种压缩方法的实现流程示意图二,如图2所示,在本申请实施例中,路由器根据预设路由规则,将待查找键值中的n位待查找键值进行拆分得到m位待查找键值和n-m位待查找键值,即步骤102路由器实现压缩的方法可以包括以下步骤:
步骤102a、根据待转发报文的路由规格,获取预设散列表的索引值为m位。
步骤102b、按照预设散列表的索引值为m位,将n位待查找键值进行拆分得到m位待查找键值和n-m位待查找键值。
本申请实施例中,路由器将待查找键值存储在RAM中,RAM存储条目数可以为待转发报文的路由规格,例如,待转发报文的路由规格为2048,通过log 2(2048)进行计算得到预设散列表的索引值为11位,然后取m=11,将待查找键值中的n位待查找键值进行拆分得到11位待查找键值和n-11位待查找键值。
图3为本申请实施例提出的一种压缩方法的实现流程示意图三,如图3 所示,在本申请实施例中,路由器在对m位更新后中间值和m位待查找键值进行可逆运算,得到m位待查找索引值之后,即步骤104之后路由器实现压缩的方法还可以包括以下步骤:
步骤105、对m位待查找索引值在预设散列表中进行索引。
本申请实施例中,在得到m位待查找索引值之后,路由器可以通过m位待查找索引值索引对应位置预先存储的目标键值。
步骤106a、当确定m位待查找索引值对应索引位置为空时,停止转发待转发的报文。
步骤106b、当确定m位待查找索引值对应索引位置为非空时,获取m位待查找索引值对应索引位置存储的n-m位目标键值。
本申请实施例中,在得到m位待查找索引值之后,路由器还需要取出存储在m位待查找索引值对应位置的目标键值,将目标键值拼接恢复得到n位查找后键值,并与待查找键值进行对比,确认是否对待转发报文进行转发,因此,在得到m位待查找索引值之后,且在查找后键值与待查找键值进行对比之前,路由器需要判断m位待查找索引值对应索引位置是否为空,如果确定为空,则说明通过m位待查找索引值并不能索引到对应的关联数据,即需要停止转发待转发的报文,如果确定为非空,则获取m位待查找索引值对应索引位置存储的目标键值,用于后续得到查找后键值,进一步确定能否对待转发的报文进行转发。
示例性地,待转发报文中待转发地址为3.3.3.3,VRFID为3479,待查找键值为{地址:32’h03030303,VRFID:16’h3479},取m=11,对待转发键值进行拆分,得到11位VRFID为11’h597和5位VRFID为5’h1,则更新后键值为{地址:32’h03030303,VRFID:5’h1},对更新后的键值进行哈希计算得到11位更新后的中间值11’h17F,将11位更新后的中间值11’h17F与11位VRFID为11’h597进行异或得到11位待查找索引值11’h4E8,取出 11位待查找索引值11’h4E8对应的存储记录,如果发现为空,说明没有匹配到,那么待转发报文就不会被转发,如果发现为非空,则获取11位待查找索引值11’h4E8对应索引位置的存储的n-m位目标键值。
图4为本申请实施例提出的一种压缩方法的实现流程示意图四,如图4所示,在本申请实施例中,路由器在根据m位待查找索引值在预设散列表找中进行索引之前,即步骤105之前路由器实现压缩的方法还可以包括以下步骤:
步骤109、对n位预配置键值进行压缩得到预设散列表,预设散列表中存储的为经过压缩处理后的n-m位预配置键值。
需要说明的是,在通过m位待查找索引值在预设散列表找中进行索引之前,路由器需要先配置散列表,以便能够按照配置时存储数据的方式,在预设散列表中能够查找到对应存储的关联数据,从而通过查找得到的关联数据对待转发的报文进行转发。
本申请实施例中,如果路由器按照原始信息的宽度即n位预配置键值进行索引,不进行合理的压缩,这样路由器实现报文转发开销还是比较大的,因此,为了减少键值存储空间,本申请实施例对预配置键值即n位预配置键值进行拆分,得到压缩处理后的n-m位预配置键值,再对n-m位预配置键值进行哈希运算得到m位预配置中间值,通过对m位预配置中间值和n位预配置键值中剩下的m位预配置键值进行可逆运算,可以得到m位预配置索引值,最后将拆分得到的n-m位预配置键值存储在m位预配置索引值对应的位置上,如此,实现了在信息无损的情况下将n位键值压缩成了n-m位键值,减少了表项的宽度,从而减少了存储空间。
需要说明的是,路由器用于存储报文转发所需要的键值和对应的关联数据。
图5为本申请实施例提出的一种压缩方法的实现流程示意图五,如图5 所示,本申请实施例中,路由器当确定m位待查找索引值对应索引位置为非空时,获取m位待查找索引值对应索引位置存储的目标键值之后,即步骤106b之后路由器实现压缩的方法还可以包括以下步骤:
步骤107b、根据n-m位目标键值和m位待查找索引值,得到n位查找后键值。
本申请实施例中,在获取m位待查找索引值对应位置的n-m位目标键值之后,路由器需要对n-m位目标键值和m位待查找索引值,进行拼接恢复得到n位查找后键值。
步骤108b、基于n位查找后键值与n位待查找键值,对待转发报文进行转发。
本申请实施例中,在得到查找后键值之后,路由器需要对查找后键值与待查找键值进行对比,确认是否对待转发报文进行转发,当确定n位查找后键值与n位待查找键值不同时,停止转发待转发的报文;当确定n位查找后键值与n位待查找键值相同时,根据m位待查找索引值进行索引得到对应位置存储的转发端口,通过转发端口对待转发报文进行转发。
图6为本申请实施例提出的一种压缩方法的实现流程示意图六,如图6所示,本申请实施例中,路由器根据n-m位目标键值和m位待查找索引值,得到n位查找后键值,即步骤107b路由器实现压缩的方法可以包括以下步骤:
步骤107b1、对n-m位目标键值进行哈希运算,得到m位目标中间值。
步骤107b2、对m位目标中间值和m位待查找索引值进行可逆运算,得到m位目标键值。
步骤107b3、根据m位目标键值和n-m位目标键值,生成n位查找后键值。
本申请实施例中,路由器对m位目标键值和n-m位目标键值进行拼接 恢复得到查找后键值。
示例性地,目标键值包括32位目标地址和5位VRFID,即目标键值为{目标地址:32’h02020202,目标VRFID:5’h3},11位目标键值为11’h404,通过对37位目标键值和11位目标VRFID进行拼合可以得到48位查找后键值为{目标地址:32’h02020202,目标VRFID:16’h1c04}。
对应地,基于查找后键值与待查找键值,对待转发报文进行转发,即步骤108b实现压缩的方法可以包括以下步骤:
步骤108b1、当确定n位查找后键值与n位待查找键值不同时,停止转发待转发的报文。
步骤108b2、当确定n位查找后键值与n位待查找键值相同时,根据m位待查找索引值进行索引得到对应位置存储的转发端口;通过转发端口对待转发报文进行转发。
本申请实施例中,在得到查找后键值之后,路由器需要对查找后键值与待查找键值进行对比,确认是否对待转发报文进行转发。
示例性的,如果待转发报文中32位地址为192.168.3.3,16位VRFID为16’5124,对应地,48位待查找键值为{地址:32’hC0A80303,VRFID:16’d5124},取m=11,更新后键值为{地址:32’hC0A80303,VRFID:5’h1},对更新后键值进行哈希运算得到11位更新后中间值11’h624,将11位更新后中间值11’h624和待转发报文中剩下的11位VRFID为11’h404进行异或得到11位待查找索引值为11’h220,取出11位待查找索引值11’h220对应存储的37位目标键值包括32位目标地址为32’h02020202和5位目标VRFID为5’h3,将37位目标键值{目标地址:32’h02020202,目标VRFID:5’h3}和11位目标VRFID为11’h404进行拼合,得到48位查找后键值{目标地址:32’h02020202,目标VRFID:16’d7172},经过将48位查找后键值{目标地址:32’h02020202,目标VRFID:16’d7172}与48位待查找键值{地 址:32’hC0A80303,VRFID:16’d5124}进行比较可得待查找键值与查找后键值不同,则认为没有匹配到,那么待转发报文将不会被转发。
如果待转发报文中32位待转发地址为1.1.1.1,16位VRFID为7485,对应地,48位待查找键值为{地址:32’h01010101,VRFID:16’d7485},更新后键值包括32位地址32’h01010101和5位VRFID为5’h3即更新后键值为{地址:32’h01010101,VRFID:5’h3},对更新后键值进行哈希运算得到11位更新后中间值11’h1E0,将11位更新后中间值11’h1E0和待转发报文中剩下的11位VRFID为11’h53d进行异或得到11位待查找索引值为11’h4dd,取出11位待查找索引值11’h4dd对应存储的37位目标键值包括32位目标地址为32’h01010101和5位目标VRFID为5’h3,将37位目标键值{目标地址:32’h01010101,目标VRFID:5’h3}和11位目标键值11’h53d进行拼合,得到48位查找后键值{目标地址:32’h01010101,目标VRFID:16’d7485},经过将48位查找后键值{目标地址:32’h01010101,目标VRFID:16’d7485}与48位待查找键值{地址:32’h01010101,VRFID:16’d7485}进行比较可得待查找键值与查找后键值完全一致,则认为匹配成功,那么通过11位待查找索引值11’h4dd索引到对应的关联数据,得到关联数据中的转发端口,通过转发端口对待转发报文进行转发。
通过上述举例可得,本申请实施例只需要通过37位键值便可以实现对待转发报文的转发,图7A为本申请实施例提供的一种示例性的键值存储示意图一,如图7A所示,压缩之前路由器中存储的键值为48位,图7B为本申请实施例提供的一种示例性的键值存储示意图二,如图7B所示,压缩之后路由器中存储的键值为37位,与压缩之前的48位键值相比,本申请实施例能够节省(48-37)*2048=225228字节的存储空间。
本申请实施例提供了一种压缩方法,该压缩方法包括:从待转发报文中获取n位待查找键值;根据预设路由规则,将n位待查找键值进行拆分 得到m位待查找键值和n-m位待查找键值;对n-m位待查找键值进行哈希运算,得到m位更新后中间值;对所述m位更新后中间值和所述m位待查找键值进行可逆运算,得到m位待查找索引值,所述m位待查找索引值用于索引对应的关联数据,所述关联数据包括转发端口,如此,将原来需要n位待查找键值改进成只需要通过n-m位更新后的键值便可以得到m位待查找索引值,从而压缩了表项的位宽,节省了存储空间。
实施例二
相关现有技术中,路由器直接从待转发报文中获取待查找键值,如可以将待转发报文中的待转发地址和VRFID按照原始信息的位宽组成键值Key,配置散列表时,通过哈希运算得到一个m位的索引值Index,即Index=Hash(Key),然后将键值Key写入m位的索引值Index对应的位置上,再按照配置的方式进行查找得到关联数据,图8为现有的查找关联数据的示意图,如图8所示,路由器获取待转发报文中的键值Key’,对该键值Key’通过配置一样的哈希运算得到m位的索引值Index’,读取m位的索引值Index’对应位置上存储的键值Key,并与键值Key’进行比较,如果相同则说明匹配到,能够通过m位的索引值Index’索引到对应的关联数据,对待转发报文进行转发,如果不同,则说明没有匹配到,不能对待转发报文进行转发,这样键值Key的宽度是原始信息的宽度,没有进行压缩,并不能达到节省存储空间的效果。
基于节省键值存储空间的目的,本申请实施例对上述现有技术进行了改进,路由器将n位键值进行压缩,即配置时,将n位预配置键值进行拆分得到n-m位预配置键值和m位预配置键值,再对n-m位预配置键值进行哈希运算得到m位预配置中间值,通过对m位预配置中间值和n位预配置键值中剩下的m位预配置键值进行可逆运算,可以得到m位预配置索引值,最后将n-m位预配置键值存储在m位预配置索引值对应的位置上,再按照 配置的方式得到索引值,通过判断索引存储的目标键值与待查找的键值进行比较来确定是否对待转发的报文进行转发,如此压缩后只需要通过n-m位键值便可以查找到m位索引值,即改进后的宽度与改进前相比减少了m位,占用的存储容量减少了m*2 m字节。
图9为本申请实施例提供的压缩后查找关联数据的示意图,如图9所示,散列表是经过配置后预先存储的,本申请实施例中,路由器按照配置的方法得到索引值进而取出预先存储的键值,再对预先存储的键值进行恢复得到查找后的键值,将查找后键值与待查找键值进行比较,从而实现对待转发报文的转发,图10为本申请实施例提供的压缩后具体查找关联数据的流程示意图,如图10所示,本申请实施例路由器实现压缩方法可以包括以下步骤:
步骤201、根据n位待查找键值Key n,获取n-m位更新后键值Key n-m
本申请实施例中,路由器先根据路由规格,得到预设散列表索引值为m位,再根据预设散列表索引值为m位,将待查找键值Key n中的n位键值进行拆分为n-m位待查找键值和m位待查找键值,得到n-m位更新后键值Key n-m
步骤202、对n-m位待更新后键值Key n-m进行哈希运算得到m位更新后中间值Temp m
本申请实施例中,哈希运算是将n-m位待更新后键值转化为固定长度即m位的更新后中间值Temp m=Hash(Key n-m)。
步骤203、m位待查找中间值Temp m与n位待查找键值中剩下的m位待查找键值Key m进行异或,得到m位待查找索引值Index m
本申请实施例中,Index m=OP(Temp m,Key m),路由器用于存储报文转发所需要的键值和对应的关联数据,这里得到m位待查找索引值Index m用于索引对应位置存储的键值和对应的关联数据。
步骤204、通过m位待找索引值Index m索引对应位置存储的n-m位目标键值Key n-m’。
本申请实施例中,由于在配置过程中将n-m位键值Key存储在m位索引值对应的位置上,因此,路由器通过m位待查找索引值Index m能够索引到对应位置存储的n-m位目标键值Key n-m’。
步骤205、对n-m位目标键值Key n-m’进行哈希运算得到m位目标中间值Temp m’。
本申请实施例中,哈希运算是将n-m位目标键值Key n-m’转化为固定长度即m位的目标中间值,Temp m’=Hash(Key n-m’)。
步骤206、对m位目标中间值Temp m’和m位待找索引值Index m进行可逆运算得到m位目标键值Key m’。
本申请实施例中,路由器对m位目标中间Temp m’和m位待找索引值Index m进行可逆运算得到m位目标键值Key m’=OPINV(Temp m’,Index m)。
步骤207、根据n-m位目标键值Key n-m’和m位目标键值Key m’,得到n位查找后的键值Key n’。
本申请实施例,在得到m位目标键值之后,路由器将n-m位目标键值Key n-m’和m位目标键值Key m’进行拼合得到n位查找后的键值Key n’。
步骤208、基于n位查找后的键值Key n’和n位待查找键值Key n,获取m位待找索引值对应的关联数据AD。
本申请实施例中,路由器将n位查找后的键值Key n’和n位待查找键值Key n进行比较,当确定n位查找后键值与n位待查找键值不同时,停止转发待转发的报文;当确定n位查找后键值与n位待查找键值相同时,根据m位待查找索引值进行索引得到对应位置存储的转发端口,通过转发端口对待转发报文进行转发。
本申请实施例能够将原来需要n位待查找键值改进成只需要通过n-m 位更新后的键值便可以得到m位待查找索引值,从而压缩了表项的位宽,节省了存储空间。
实施例三
基于实施例一至实施例二的同一申请构思,本申请实施例提供一种压缩装置,图11为本申请实施例提出的一种压缩装置组成结构示意图一,如图11所示,在本申请实施例中,压缩装置1100包括第一获取模块1101、第一拆分模块1102、第一得到模块1103和第二得到模块1104,其中,
第一获取模块1101,配置为从待转发报文中获取n位待查找键值;
第一拆分模块1102,配置为根据预设路由规格,将所述n位待查找键值进行拆分得到m位待查找键值和n-m位待查找键值;
第一得到模块1103,配置为对所述n-m位待查键值进行哈希运算,得到m位更新后中间值;
第二得到模块1104,配置为对所述m位更新后中间值和所述m位待查找键值进行可逆运算,得到m位待查找索引值,所述m位待查找索引值用于索引对应的关联数据,所述关联数据包括转发端口。
在其他实施例中,所述第一拆分模块1102配置为:根据待转发报文的路由规格,获取预设散列表的索引值为m位;按照所述预设散列表的索引值为m位,将所述n位待查找键值划分为m位待查找键值和n-m位待查找键值。
在其他实施例中,所述压缩装置1100还可以包括:
索引模块1105,配置为对所述m位待查找索引值在预设散列表找中进行索引;
确定模块1106,配置为当确定所述m位待查找索引值对应索引位置为空时,停止转发所述待转发的报文;当确定所述m位待查找索引值对应索引位置为非空时,获取所述m位待查找索引值对应索引位置存储的n-m位 目标键值。
在其他实施例中,所述压缩装置1100还可以包括:
第三得到模块1107,配置为对所述n位预配置键值进行压缩得到预设散列表,所述预设散列表中存储的为经过压缩处理后的n-m位预配置键值。
在其他实施例中,所述压缩装置1100还可以包括:
第四得到模块1108,配置为根据所述n-m位目标键值和所述m位待查找索引值,得到n位查找后键值;
转发模块1109,配置为基于所述n位查找后键值与所述n位待查找键值,对所述待转发报文进行转发。
在其他实施例中,所述第四得到模块1108配置为:对所述n-m位目标键值进行哈希运算,得到m位目标中间值;对所述m位目标中间值和所述m位待查找索引值进行可逆运算,得到m位目标键值;根据所述m位目标键值和所述n-m位目标键值,生成n位查找后的键值。
在其他实施例中,所述转发模块1109配置为:当确定所述n位待查找键值与所述n位待查找键值不同时,停止转发所述待转发的报文;当确定所述n位待查找键值与所述n位待查找键值相同时,根据所述m位待查找索引值进行索引得到对应位置存储的转发端口;通过所述转发端口对所述待转发报文进行转发。
本申请实施例提供了一种压缩装置,能够将原来需要n位待查找键值改进成只需要通过n-m位更新后的键值便可以得到m位待查找索引值,从而压缩了表项的位宽,节省了存储空间。
实施例四
基于实施例一至实施例三的同一申请构思,本申请实施例提供的一种压缩装置,图12为本申请实施例提供的一种压缩装置组成结构示意图二,如图12所示,上述压缩装置至少包括处理器01、存储器02、通信接口03 及通信总线04,其中,通信总线04用于实现处理器和存储器之间的连接通信;通信接口03用于信息的接收和发送;处理器01用于执行存储器02中存储的压缩程序,以实现上述实施例一至实施例三提供的压缩方法中的步骤。
本申请实施例提供的压缩装置能够将原来需要n位待查找键值改进成只需要通过n-m位更新后的键值便可以得到m位待查找索引值,从而压缩了表项的位宽,节省了存储空间。
在实际应用中,处理器可以为专用集成电路(Application Specific Integrated Circuit,ASIC),用于对高速网络数据进行转发处理,存储器可以为嵌入的静态随机存取存储器(embedded Static Random-Access Memory,eSRAM和嵌入的动态随机存取存储器(embedded Dynamic Random Access Memory,eDRAM)。
另外,在本实施例中的各组成部分可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。
需要说明的是:上述实施例提供的压缩装置在进行压缩时,仅以上述各程序模块的划分进行举例说明,实际应用中,可以根据需要而将上述处理分配由不同的程序模块完成,即将装置的内部结构划分成不同的程序模块,以完成以上描述的全部或者部分处理。另外,上述实施例提供的压缩装置与压缩方法实施例属于同一构思,其具体实现过程详见方法实施例,这里不再赘述。
基于前述实施例,本申请实施例提供了一种计算机可读存储介质,其上存储有压缩程序,上述压缩程序被处理器执行时实现上述一个或多个实施例中的压缩方法。
在本申请所提供的几个实施例中,应该理解到,所揭露的设备和方法,可以通过其它的方式实现。以上所描述的设备实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,如:多个单元或组件可以结合,或可以集成到另一个系统,或一些特征可以忽略,或不执行。另外,所显示或讨论的各组成部分相互之间的耦合、或直接耦合、或通信连接可以是通过一些接口,设备或单元的间接耦合或通信连接,可以是电性的、机械的或其它形式的。
本申请所提供的几个方法实施例中所揭露的方法,在不冲突的情况下可以任意组合,得到新的方法实施例。
本申请所提供的几个产品实施例中所揭露的特征,在不冲突的情况下可以任意组合,得到新的产品实施例。
本申请所提供的几个方法或设备实施例中所揭露的特征,在不冲突的情况下可以任意组合,得到新的方法实施例或设备实施例。
以上所述,仅为本申请的可选实施例而已,并非用于限定本申请的保护范围。

Claims (10)

  1. 一种压缩方法,所述方法包括:
    从待转发报文中获取n位待查找键值;n为正整数;
    根据预设路由规格,将所述n位待查找键值进行拆分得到m位待查找键值和n-m位待查找键值;m为小于n的正整数;
    对所述n-m位待查找键值进行哈希运算,得到m位更新后的中间值;
    对所述m位更新后的中间值和所述m位待查找键值进行可逆运算,得到m位待查找索引值,所述m位待查找索引值用于索引对应关联数据,关联数据包括转发端口。
  2. 根据权利要求1所述方法,其中,所述根据预设路由规格,将所述n位待查找键值进行拆分得到m位待查找键值和n-m位待查找键值,包括:
    根据待转发报文的路由规格,获取预设散列表的索引值为m位;
    按照所述预设散列表的索引值为m位,将所述n位待查找键值划分为m位待查找键值和n-m位待查找键值。
  3. 根据权利要求1所述的方法,其中,在所述对所述m位更新后的中间值和所述m位待查找键值进行可逆运算,得到m位待查找索引值之后,所述方法还包括:
    对所述m位待查找索引值在预设散列表找中进行索引;
    当确定所述m位待查找索引值对应索引位置为空时,停止转发所述待转发的报文;
    当确定所述m位待查找索引值对应索引位置为非空时,获取所述m位待查找索引值对应索引位置存储的n-m位目标键值。
  4. 根据权利要求3所述的方法,其中,在所述对所述m位待查找索引值在预设散列表找中进行索引之前,所述方法还包括:
    对n位预配置键值进行压缩得到预设散列表,所述预设散列表中存储 的为经过压缩处理后的n-m位预配置键值。
  5. 根据权利要求3所述的方法,其中,在所述当确定所述m位待查找索引值对应位置为非空时,获取所述m位待查找索引值对应位置存储的目标键值之后,所述方法还包括:
    根据所述n-m位目标键值和所述m位待查找索引值,得到n位查找后键值;
    基于所述n位查找后键值与所述n位待查找键值,对所述待转发报文进行转发。
  6. 根据权利要求5所述方法,其中,所述根据所述n-m位目标键值和所述m位待查找索引值,得到查找后键值,包括:
    对所述n-m位目标键值进行哈希运算,得到m位目标中间值;
    对所述m位目标中间值和所述m位待查找索引值进行可逆运算,得到m位目标键值;
    根据所述m位目标键值和所述n-m位目标键值,生成n位查找后键值。
  7. 根据权利要求5所述方法,其中,所述基于所述n位查找后键值与所述n位待查找键值,对所述待转发报文进行转发,所述方法还包括:
    当确定所述n位查找后键值与所述n位待查找键值不同时,停止转发所述待转发的报文;
    当确定所述n位查找后键值与所述n位待查找键值相同时,根据所述m位待查找索引值进行索引得到对应位置存储的转发端口;通过所述转发端口对所述待转发报文进行转发。
  8. 一种压缩装置,所述装置包括:
    第一获取模块,配置为从待转发报文中获取n位待查找键值;n为正整数;
    第一拆分模块,配置为根据预设路由规格,将所述n位待查找键值进 行拆分得到m位待查找键值和n-m位待查找键值;m为小于n的正整数;
    第一得到模块,配置为对所述n-m位待查找键值进行哈希运算,得到m位更新后中间值;
    第二得到模块,配置为对所述m位更新后中间值和所述m位待查找键值进行可逆运算,得到m位待查找索引值,所述m位待查找索引值用于索引对应的关联数据,所述关联数据包括转发端口。
  9. 一种压缩装置,所述压缩装置至少包括处理器、存储有所述处理器可执行指令的存储器,和用于连接所述处理器、所述存储器的总线,当所述指令被执行时,所述处理器执行时实现如权利要求1至7任一项所述的方法。
  10. 一种计算机可读存储介质,其上存储计算机程序,所述计算机程序被处理器执行时实现如权利要求1至7任一项所述的方法。
PCT/CN2019/089961 2018-10-18 2019-06-04 一种压缩方法及装置、计算机可读存储介质 WO2020078012A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811215545.9 2018-10-18
CN201811215545.9A CN109525503B (zh) 2018-10-18 2018-10-18 一种压缩方法及装置、计算机可读存储介质

Publications (1)

Publication Number Publication Date
WO2020078012A1 true WO2020078012A1 (zh) 2020-04-23

Family

ID=65772679

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/089961 WO2020078012A1 (zh) 2018-10-18 2019-06-04 一种压缩方法及装置、计算机可读存储介质

Country Status (2)

Country Link
CN (1) CN109525503B (zh)
WO (1) WO2020078012A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109525503B (zh) * 2018-10-18 2021-12-14 苏州盛科通信股份有限公司 一种压缩方法及装置、计算机可读存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040236720A1 (en) * 2000-04-06 2004-11-25 International Business Machines Corporation Longest prefix match lookup using hash function
US20090041017A1 (en) * 2007-08-08 2009-02-12 King Wayne Luk Hash lookup table method and apparatus
CN101635680A (zh) * 2009-08-07 2010-01-27 中国电信股份有限公司 一种业务路由方法和系统
CN102194002A (zh) * 2011-05-25 2011-09-21 中兴通讯股份有限公司 哈希表的表项添加、删除、查找方法及哈希表存储装置
CN109525503A (zh) * 2018-10-18 2019-03-26 盛科网络(苏州)有限公司 一种压缩方法及装置、计算机可读存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040236720A1 (en) * 2000-04-06 2004-11-25 International Business Machines Corporation Longest prefix match lookup using hash function
US20090041017A1 (en) * 2007-08-08 2009-02-12 King Wayne Luk Hash lookup table method and apparatus
CN101635680A (zh) * 2009-08-07 2010-01-27 中国电信股份有限公司 一种业务路由方法和系统
CN102194002A (zh) * 2011-05-25 2011-09-21 中兴通讯股份有限公司 哈希表的表项添加、删除、查找方法及哈希表存储装置
CN109525503A (zh) * 2018-10-18 2019-03-26 盛科网络(苏州)有限公司 一种压缩方法及装置、计算机可读存储介质

Also Published As

Publication number Publication date
CN109525503B (zh) 2021-12-14
CN109525503A (zh) 2019-03-26

Similar Documents

Publication Publication Date Title
US11102120B2 (en) Storing keys with variable sizes in a multi-bank database
US9871728B2 (en) Exact match hash lookup databases in network switch devices
US10389633B2 (en) Hash-based address matching
US7760720B2 (en) Translating native medium access control (MAC) addresses to hierarchical MAC addresses and their use
US6654701B2 (en) Method and apparatus for measuring protocol performance in a data communication network
US7916656B2 (en) Providing a symmetric key for efficient session identification
JP4716909B2 (ja) ネットワーク接続テーブルを提供するための方法および装置
CN113519144B (zh) 用于网络设备的精确匹配和三元内容可寻址存储器(tcam)混合查找
EP3196776B1 (en) Method and device for data processing
WO2005074555A2 (en) Memory efficient hashing algorithm
WO2014127605A1 (zh) 基于哈希表和tcam表的mac地址硬件学习方法及系统
US9979648B1 (en) Increasing entropy across routing table segments
WO2017124693A1 (zh) 一种报文解封装处理、数据写入方法及装置
US20190222648A1 (en) Data Processing Method, Storage System, and Switching Device
US10659361B2 (en) Packet processing
CN115941598A (zh) 一种流表半卸载方法、设备及介质
WO2020078012A1 (zh) 一种压缩方法及装置、计算机可读存储介质
US20230041395A1 (en) Method and Device for Processing Routing Table Entries
US20230336457A1 (en) Method and apparatus for processing forwarding entry
US10185783B2 (en) Data processing device, data processing method, and non-transitory computer readable medium
CN111641592A (zh) 基于中间件的数据传输方法、装置和计算机设备
Rosa et al. A Hash-Free method for FIB and LNPM in ICN programmable data planes
CN107204926B (zh) 预处理cache的路由快速查找方法
US20050117588A1 (en) System and method for network address port translation
EP4102784A1 (en) Data stream processing method and device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19874220

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 19874220

Country of ref document: EP

Kind code of ref document: A1