WO2020093737A1 - Message processing method and device, storage medium and optical network terminal - Google Patents

Message processing method and device, storage medium and optical network terminal Download PDF

Info

Publication number
WO2020093737A1
WO2020093737A1 PCT/CN2019/098130 CN2019098130W WO2020093737A1 WO 2020093737 A1 WO2020093737 A1 WO 2020093737A1 CN 2019098130 W CN2019098130 W CN 2019098130W WO 2020093737 A1 WO2020093737 A1 WO 2020093737A1
Authority
WO
WIPO (PCT)
Prior art keywords
message
offset
address
custom
hash
Prior art date
Application number
PCT/CN2019/098130
Other languages
French (fr)
Chinese (zh)
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 WO2020093737A1 publication Critical patent/WO2020093737A1/en

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
    • 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
    • H04QSELECTING
    • H04Q11/00Selecting arrangements for multiplex systems
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04QSELECTING
    • H04Q11/00Selecting arrangements for multiplex systems
    • H04Q11/0001Selecting arrangements for multiplex systems using optical switching
    • H04Q11/0062Network aspects
    • H04Q11/0067Provisions for optical access or distribution networks, e.g. Gigabit Ethernet Passive Optical Network (GE-PON), ATM-based Passive Optical Network (A-PON), PON-Ring

Definitions

  • This application relates to the technical field of passive optical networks (PON, Passive, Optical Networks), for example, to a message processing method and device, a storage medium, and an optical network terminal.
  • PON passive optical networks
  • Passive Optical Networks
  • GPON Gigabit passive optical network
  • ADSL Asymmetric Digital Subscriber Loop
  • the optical network terminal (ONU, Optical, Network Unit) of GPON is one of the core chips of the GPON suite.
  • the detection and processing of Ethernet packets is a very important link.
  • the ONU chip needs to identify various packets in the network and have different processing methods for different packets.
  • the location and content of different message extraction may be different, which makes the extraction rules corresponding to each port of the ONU chip become more and more more.
  • PON PON
  • Ethernet Passive Optical Network EPON
  • XGPON GPON
  • XGPON symmetric XGPON
  • XEPON XEPON
  • the parameter of the packet processing entry also needs to consider whether the DDR bandwidth is sufficient.
  • all the packets use the same physical port to access DDR. Because there are more types of packets, the number of rules under this physical port will be larger. Each packet needs to Multiple rules are matched, resulting in a larger DDR bandwidth.
  • the embodiments of the present application provide a message processing method and device, a storage medium, and an optical network terminal.
  • a message processing method includes:
  • a message processing device including:
  • the parsing unit is configured to parse the message, and determine the expansion port corresponding to the message according to the first rule based on the analysis result, and the expansion port is used to offload the message;
  • a determining unit configured to determine the target entry corresponding to the packet based on the second rule corresponding to the expansion port
  • the processing unit is configured to process the message using the target entry.
  • a storage medium stores a computer program, and when the computer program is executed by a processor, the foregoing message processing method is realized.
  • An optical network terminal includes a memory and a processor, and a computer-executable instruction is stored on the memory, and the computer-executable instruction is executed by the processor to implement the foregoing message processing method.
  • FIG. 1 is a schematic flowchart 1 of a packet processing method according to an embodiment of the present application
  • FIG. 2 is a second schematic flowchart of the packet processing method according to an embodiment of the present application.
  • FIG. 3 is a schematic diagram of a packet format according to an embodiment of this application.
  • FIG. 4 is a schematic diagram of a process for acquiring an expansion port according to an embodiment of the present application.
  • FIG. 5 is a schematic flowchart of obtaining an absolute offset according to an embodiment of this application.
  • FIG. 6 is a first schematic diagram of the structural composition of a message processing device according to an embodiment of this application.
  • FIG. 7 is a second schematic diagram of the structural composition of the packet processing device according to an embodiment of the present application.
  • data extraction rules are used to indicate where to extract data in the message. For example: extract data in the 10th byte of the message.
  • the target entry in the HASH list for example, find the target entry in each HASH bucket of the HASH list.
  • the HASH list is stored in the DDR outside the ONU.
  • the number of rules, the number of entries, performance, and HASH utilization rate are relevant. Specifically, the increase in the number of matching rules required for a single message processing will increase the number of entries read, which will increase the DDR bandwidth; the performance improvement will also increase the DDR bandwidth; the increase in the number of HASH buckets will also increase the DDR bandwidth .
  • DDR bandwidth refers to the rate of access to DDR.
  • how to configure more entries in the case of the same capacity, and the resources occupied by the rule number itself are also factors that need to be considered.
  • how to provide a configuration interface for software (facing users) more conveniently is an important manifestation of user experience.
  • FIG. 1 is a first schematic flowchart of a message processing method according to an embodiment of the present application. As shown in FIG. 1, the message processing method includes the following steps.
  • Step 101 Parse the message, and determine the expansion port corresponding to the message according to the first rule based on the parsing result, and the expansion port is used to offload the message.
  • the header of the packet is parsed to obtain each field included in the header of the packet; based on the first rule, it is determined that each field in the header of the packet corresponds to A custom offset as a custom offset corresponding to the message, wherein the first rule includes a correspondence between the custom offset and a field; based on the custom offset corresponding to the message Quantity to determine the expansion port corresponding to the message.
  • the first rule includes the correspondence between 6 sets of custom offsets and fields, as shown in Table 1 below:
  • Custom offset Field (header) OFFSET1 Field 1 OFFSET 2 Field 2 OFFSET3 Field 3 OFFSET 4 Field 4 OFFSET 5 Field 5 OFFSET 6 Field 6
  • Parsing the header of the message to obtain the header of the message includes the following fields: Field 1 and Field 3. Based on Table 1, the custom offsets corresponding to the message are OFFSET 1 and OFFSET 3. In an embodiment, each custom offset in the first rule is represented by a bit, and the custom offset corresponding to the message is set to 1, and the other custom offsets are set to 0 Then, based on the custom offset corresponding to the message, the following information can be obtained: 101000, which is used as the port index information to determine the expansion port, and different expansion ports can be matched according to different port index information .
  • different types of packets have different headers, so that different types of packets can be distributed to different expansion ports. If there is no expansion port matching the port index information, the target entry corresponding to the packet is determined based on the third rule corresponding to the physical port; in this embodiment, the third rule corresponding to the physical port The number is greater than the number of second rules corresponding to the expansion port.
  • the address at the preset position in the field is used as a custom offset corresponding to the field Custom offset address.
  • Custom offset Field Custom offset address OFFSET1 Field 1 End address of field 1 (Adress1) OFFSET 2 Field 2 First address of field 2 (Adress2) OFFSET3 Field 3 First address of field 3 (Adress3) OFFSET 4 Field 4 First address of field 4 (Adress4) OFFSET 5 Field 5 First address of field 5 (Adress5) OFFSET 6 Field 6 First address of field 6 (Adress6)
  • Parsing the header of the packet to obtain the header of the packet includes the following fields: Field 1 and Field 3, based on Table 2, the custom offsets corresponding to the packet are OFFSET1 and OFFSET3,
  • the custom offset address of OFFSET1 is the tail address of field 1 in the message
  • the custom offset address of OFFSET2 is the first address of field 2 in the message.
  • Step 102 Determine the target entry corresponding to the packet based on the second rule corresponding to the expansion port.
  • a second rule is bound to the expansion port, based on the second rule corresponding to the expansion port and the custom offset address corresponding to each of the custom offsets, from the message
  • the second rule is used to extract the target data.
  • the target entry is searched in the HASH list. For example, the target entry can be found in each HASH bucket of the HASH list.
  • the second rule includes one or more extraction rules corresponding to the target data to be extracted, the extraction rule includes: an offset address, a type of offset address, and a type of a custom offset, In this embodiment, the type of the offset address is used to indicate whether the offset address is a relative offset address or an absolute offset address;
  • extracting target data from the message includes: Two rules, determine the offset address corresponding to the target data to be extracted; if the offset address corresponding to the target data to be extracted is a relative offset address, determine a custom offset corresponding to the relative offset address; Determine whether the custom offset corresponding to the relative offset address is a custom offset corresponding to the message; if the custom offset corresponding to the relative offset address is corresponding to the message For a custom offset, an absolute offset address is calculated based on the custom offset address corresponding to the custom offset and the relative offset address, and based on the absolute offset address from the message Extract the target data.
  • the target data is extracted from the message based on the absolute offset address.
  • searching for the target entry in the HASH list for example, searching for the target entry in each HASH bucket of the HASH list
  • the effective HASH bucket refers to: in the case where an entry is stored in the first HASH address of the first HASH bucket, the first HASH bucket is an effective HASH bucket of the first HASH address; from the effective A valid entry corresponding to the HASH address is read in the HASH bucket; the target data is compared with each valid entry, and a valid entry matching the target data is determined as the target entry.
  • a new pre-processing step is added in the process of HASH processing, that is, an effective HASH bucket is determined from each HASH bucket in the HASH list, as a HASH bucket to be read, and the effective HASH bucket is based on the HASH address Reading valid entries in the system makes the overall DDR bandwidth requirements of the message lower.
  • Step 103 Use the target entry to process the message.
  • the execution subject of each step above may be an ONU.
  • the concept of an expansion port is introduced. Different types of packets are shunted to different expansion ports. In this way, a message only needs to find a target entry from the DDR through the rules under the corresponding expansion port Therefore, there is no need to find the target entry from the DDR through multiple rules under the physical port, which reduces the number of times the entry is read from the DDR, that is, reduces the bandwidth of the DDR.
  • the concept of custom offsets is introduced.
  • the packet format is summarized in advance (the packet format here can express the first rule, and the first rule includes Define the correspondence between offset and field), and configure the expansion port.
  • the user-defined offset and the user-defined offset address corresponding to the respective defined offset can be determined based on the packet format, and the expansion port can be determined based on the user-defined offset, so as to transfer the packet transmitted from the user side Perform classification processing.
  • a second rule that is, a data extraction rule
  • a new pre-processing step is added in the process of HASH processing, that is, an effective HASH bucket is determined from each HASH bucket in the HASH list, as a HASH bucket to be read, and the effective HASH bucket is based on the HASH address Reading valid entries in the system makes the overall DDR bandwidth requirements of the message lower.
  • the utilization rate of HASH can be improved in disguise, the total number of rules can be optimized, and the configuration operation can be realized by software to facilitate user operations.
  • FIG. 2 is a second schematic flowchart of a message processing method according to an embodiment of the present application. As shown in FIG. 2, the message processing method includes the following steps:
  • Step 201 Analyze the message to obtain the custom offset information corresponding to the message.
  • the custom offset information includes: a custom offset corresponding to the message, and a corresponding offset corresponding to each defined offset. Custom offset address.
  • This step specifically includes:
  • each field included in the header of the packet can be obtained.
  • LLC logical link control
  • SNAP subnet access protocol
  • IP Protocol IP protocol
  • the following fields can be obtained: SIP, DIP, IP Protocol, source port (Sport, Source), destination port (Dport, Destination port), the embodiments of the present application collectively refer to the above five fields as quintuples.
  • TCP Transmission Control Protocol
  • DIP Transmission Control Protocol
  • IP Protocol IP Protocol
  • source port Sport, Source
  • destination port Dport, Destination port
  • the embodiments of the present application collectively refer to the above five fields as quintuples.
  • the following fields can be obtained: destination address (DA, Destination, Address).
  • the preset correspondence is generated in advance, where the preset correspondence is a correspondence between a custom offset and a field.
  • the address corresponding to the head or tail of the field is used as the custom offset address of the custom offset corresponding to the field.
  • L2_OFFSET When the protocol of the message is EthernetV2, the custom offset corresponds to the length / type (lenth / type) field, and the custom offset address points to the head position of lenth / type.
  • L3_OFF SET_V4 When the protocol of the packet is EthernetV2, the custom offset corresponds to the IPV4 header field, and the custom offset address points to the head position of the IPV4 header.
  • the IPV4 header includes: ordinary V4 header, PPPOE encapsulated V4 header, V4 IN V6, PPPOE encapsulated V4 IN V6, V6 IN V4, PPPOE encapsulated V4 IN V6.
  • L3_OFFSET_V6 When the protocol of the packet is EthernetV2, the custom offset corresponds to the IPV6 header field, and the custom offset address points to the head position of the IPV6 header.
  • the IPV6 header includes: ordinary V6 header, PPPOE encapsulated V6 header, V6 IN V4, PPPOE encapsulated V6 IN V6, V4 IN V6, PPPOE encapsulated V6 IN V4.
  • L3_OFFSET_V6_LAST When the protocol of the packet is EthernetV2, the custom offset corresponds to the field of the IPV6 last hop extension header or user-defined extension header, and the custom offset address points to the IPV6 last hop extension header or user-defined If the IPV6 has only one extension header, it will point to the position of the first extension header.
  • the extended header includes: ordinary V6 header, PPPOE encapsulated V6 header, V6 IN V4, PPPOE encapsulated V6 IN V4.
  • L4_OFFSET When the protocol of the packet is EthernetV2, the custom offset corresponds to the TCP / UDP header field, and the custom offset address points to the head position of the TCP / UDP header.
  • L5_OFFSET When the protocol of the message is EthernetV2, the custom offset corresponds to the TCP payload (payload) field, and the custom offset address points to the header position of TCP payload.
  • the custom offset of the packet and the custom offset address corresponding to the respective defined offsets are obtained, here .
  • the custom offset corresponding to SIP is L2_OFFSET
  • the custom offset corresponding to DIP is L3_OFFSET_V4
  • the custom offset corresponding to IP Protocol is L3_OFFSET_V6.
  • the custom offset address corresponding to the same custom offset may be different.
  • Step 202 Determine the data extraction rule corresponding to the message based on the custom offset corresponding to the message.
  • This step specifically includes:
  • port index information is generated
  • each custom offset is represented by a bit, the corresponding custom offset of the message is set to 1, and the other The custom offset is set to 0. If the message corresponds to two custom offsets, which are the first and third of the six custom offsets, then the port index information is 101000; for another example, the message corresponds to 5 custom offsets The amount is the first 5 of the 6 custom offsets, then the port index information is 111110. According to different port index information, different expansion ports can be matched.
  • a rule number is determined based on the expansion port; according to the rule number, a data extraction rule is obtained, wherein the data extraction rule includes one or more extraction rules corresponding to target data to be extracted, the The extraction rule includes: an offset address, an offset address type, and a custom offset type, where the offset address type is used to indicate whether the offset address is a relative offset address or an absolute offset address .
  • one data extraction rule can be configured under each expansion port, or multiple data extraction rules can also be configured in order to meet the requirements of a wide variety of services.
  • the data extraction rules include one or more extraction rules corresponding to the target data to be extracted, and each extraction rule includes: an offset address, an offset address type, and a custom offset type, for example:
  • Data extraction rules include: extraction rule 1, extraction rule 2, extraction rule 3, in this embodiment, extraction rule 1 includes: offset address 1, the type of offset address 1 is a relative offset address (that is, start a custom offset Function), the type of the custom offset is L2_OFFSET; extraction rule 2 includes: offset address 2, the type of offset address 1 is the absolute offset address (that is, the custom offset function is not activated), the custom offset The type is L3_OFFSET_V4; the extraction rule 3 includes: offset address 3, the type of offset address 3 is the relative offset address (that is, the custom offset function is activated), and the type of the custom offset is L4_OFFSET.
  • each custom offset function corresponds to a switch to control whether to enable the custom offset function so that a rule can better adapt to multiple situations.
  • Step 203 Extract target data from the packet based on the data extraction rule and the custom offset address corresponding to the respective defined offset.
  • This step specifically includes:
  • the number of the target data to be extracted is one or more;
  • the custom offset corresponding to the relative offset address is the custom offset corresponding to the message, based on the custom offset address corresponding to the custom offset and the relative offset Shift the address, calculate an absolute offset address, and extract target data from the message based on the absolute offset address.
  • the custom offset corresponding to the relative offset address is not the custom offset corresponding to the message, it is determined that the data extraction rule is an invalid rule.
  • the target data is extracted from the message based on the absolute offset address.
  • step 102 if there is no extended port that matches the port index information during the process performed in step 102, then based on the data extraction rule (third rule) corresponding to the physical port, from the packet Extract the target data.
  • Step 204 Based on the target data, search for a target entry in the hash HASH list, for example, find a target entry in each HASH bucket of the hash HASH list, and use the target entry to process the message.
  • This step specifically includes:
  • a cyclic redundancy check (CRC, Cyclic Redundancy Check) algorithm is used to calculate the HASH address.
  • a valid HASH bucket is determined from each HASH bucket in the HASH list as the HASH bucket to be read, and each of the pre-configuration information records Correspondence between HASH address and valid HASH bucket; read valid entries from the valid HASH bucket based on the HASH address, the number of valid HASH buckets is one or more; compare the target data with Each valid entry read is compared, and a valid entry matching the target data is determined as a target entry corresponding to the HASH address.
  • the HASH bucket corresponding to the HASH address is an effective HASH bucket. For example, after a user writes an entry on address 1 of HASH bucket 1, record this information, indicating that HASH bucket 1 corresponding to address 1 is valid, otherwise, a HASH bucket that is not recorded is regarded as an invalid HASH bucket. In this way, when reading the HASH bucket, only valid HASH buckets can be read.
  • the following preprocessing process is performed according to the HASH address: it is determined that the HASH bucket in the DDR needs to be read several times.
  • the pre-processing process is mainly based on the pre-configuration information.
  • the configuration is an entry (such as writing an entry)
  • the specific HASH address and HASH bucket of the specific configuration are recorded.
  • you can know the valid HASH bucket that needs to be read that is, determine how many times you need to read DDR (an effective HASH bucket corresponds to reading DDR once), instead of reading each time Take all the HASH buckets.
  • the key value is compared with the valid entries in sequence, and if there is an entry matching the key value, the action and packet of the matching entry Modify, enqueue information, speed limit information and other related results to process the message. If there is no entry matching the key value, the packet is processed by default.
  • the technical solution of the embodiments of the present application greatly reduces the DDR bandwidth occupancy rate in the case of complex service types and large traffic, so that the ONU message processing function (specifically, the flow classification function) can be more easily upgraded to 10G performance ; And, in the event of HASH conflicts, by configuring the entries, the HASH conflicts can be resolved more conveniently. In addition, the total number of rules has been optimized through software configuration.
  • FIG. 4 is a schematic diagram of an expansion port acquisition process according to an embodiment of the present application. As shown in FIG. 4, the process includes the following steps:
  • Step 401 Analyze the message to obtain N custom offsets.
  • Step 402 Determine whether the expansion port matches the ith custom offset. If the expansion port matches the ith custom offset, perform step 403. If the expansion port matches the ith custom offset If they do not match, go to step 404.
  • Step 404 Output the information of the original physical port.
  • Step 405 Output the information of the expansion port.
  • FIG. 5 is a schematic flowchart of obtaining an absolute offset address according to an embodiment of the present application. As shown in FIG. 5, the process includes the following steps:
  • Step 501 Acquire N extraction rules corresponding to the target data to be extracted from the data extraction rules.
  • the extraction rules include: an offset address, a type of offset address, and a type of a custom offset.
  • Step 502 For the ith extraction rule, determine whether the type of the offset address is a relative offset address. If the type of the offset address is a relative offset address, perform step 503. If the type of the offset address is not a relative offset Address, go to step 505.
  • Step 503 Determine whether the custom offset corresponding to the relative offset address is the custom offset corresponding to the message, and if the custom offset corresponding to the relative offset address is the report For the custom offset corresponding to the message, step 504 is executed, and if the custom offset corresponding to the relative offset address is not the custom offset corresponding to the message, step 506 is executed.
  • Step 504 Calculate the absolute offset address based on the custom offset address corresponding to the custom offset and the relative offset address, and perform step 507.
  • Step 505 Use the offset address as an absolute offset address, and perform step 507.
  • Step 506 Determine that the data extraction rule is an invalid rule, and perform step 507.
  • Step 508 All absolute offset address processing related to the data extraction rule is completed.
  • Expansion port 1 The three fields of the first packet flow correspond to the following custom offsets: L2_OFFSET, L3_OFFSET_V4, L3_OFFSET_V6. Expansion port 1 matches this set of custom offsets.
  • Expansion port 2 The five fields of the second packet flow correspond to the following custom offsets: L2_OFFSET, L3_OFFSET_V4, L4_OFFSET, L5_OFFSET. Expansion port 2 matches this set of custom offsets.
  • Expansion port 3 One field of the third message flow corresponds to the following custom offset: L2_OFFSET. Expansion port 3 matches this custom offset.
  • Configure rule 2 under expansion port 2 calculate the absolute offset address based on rule 2, and extract the data.
  • Configure rule 3 under expansion port 3 calculate the absolute offset address based on rule 3, and extract the data.
  • the occupancy of DDR bandwidth is reduced by HASH preprocessing.
  • the HASH address of the corresponding entry of the message flow is calculated as B, and the entry is written into a HASH bucket in DDR, and the occupancy of the HASH bucket at address B is recorded.
  • write an entry to the HASH bucket b in DDR and record the following information:
  • the HASH bucket b corresponding to the address B is a valid HASH bucket (that is, the HASH bucket b is occupied).
  • the HASH address of the entry corresponding to the message stream is calculated as C, and the entry is written into a HASH bucket in DDR, and the occupancy of the HASH bucket at address C is recorded.
  • write an entry to the HASH bucket c in DDR and record the following information:
  • the HASH bucket c corresponding to the address C is a valid HASH bucket (that is, the HASH bucket c is occupied).
  • each message stream accesses the DDR according to the occupancy of the HASH bucket related to the HASH address.
  • the HASH address calculated by the first message flow is A, and the effective HASH bucket corresponding to address A is determined to be HASH bucket a according to the record information. Then, only the HASH in DDR is accessed Bucket a is sufficient, there is no need to access other HASH buckets, that is, each packet stream only accesses the DDR space once. If HASH preprocessing is not enabled, each packet stream will access all the HASH buckets in the DDR. Taking 4 ASH buckets in the DDR as an example, it can be known from the comparison that using HASH preprocessing to occupy the bandwidth of DDR is 1 / previous 4.
  • the three packet streams can share an extended port.
  • a rule is configured under the extended port, and the custom offset configured for the rule is L2_OFFSET.
  • the software does not need to care about what type of message, it only needs to consider that the target data to be extracted is after the TAG field.
  • the type / lenth data is extracted, then the relative offset address is 0.
  • each offset address corresponds to 2 bytes of data.
  • the user can only care about the target data that needs to be extracted, and the length of the data before the target data can be ignored.
  • This configuration is also more convenient, and the variable is extracted during maintenance It's also easier to understand.
  • the software takes into account the rule number in the key value used for HASH calculation. Specifically, when the current ONU is working, 5K entries have been configured due to continuous application for new services. When you want to configure the 5K + 1th entry, the software finds that the HASH bucket (that is, the entry) of the HASH address has been completely filled. , The entry corresponding to the newly added message flow cannot be added. Based on the expansion port corresponding to the packet flow, the software re-establishes a new rule number, recalculates the HASH address based on the rule number, and writes the new entry. When the software is configured to 8K entries, the HASH conflict cannot be written again, and a new rule number is created, and the entry is added based on the new rule number.
  • FIG. 6 is a schematic structural diagram 1 of a packet processing apparatus according to an embodiment of the present application. As shown in FIG. 6, the packet processing apparatus includes:
  • the parsing unit 601 is configured to parse the message, and determine an expansion port corresponding to the message according to the first rule based on the analysis result, and the expansion port is used to distribute the message;
  • the determining unit 602 is configured to determine the target entry corresponding to the packet based on the second rule corresponding to the expansion port;
  • the processing unit 603 is configured to process the message using the target entry.
  • the parsing unit 601 is configured to parse the header of the packet to obtain each field included in the header of the packet; based on the first rule, determine the A custom offset corresponding to each field in the header, wherein the first rule includes a correspondence between the custom offset and the field; based on the custom offset corresponding to the packet, determine The expansion port corresponding to the message.
  • the parsing unit 601 is further configured to use an address at a preset position in the field as a custom corresponding to the field for each field in the header of the message Custom offset address for offset.
  • the determining unit 602 includes:
  • the extraction subunit 6021 is set to extract target data from the packet based on the second rule corresponding to the expansion port and the custom offset address corresponding to each of the custom offsets, and the first Two rules are used to extract target data;
  • the search subunit 6022 is set to search for a target entry in the HASH list based on the target data, for example, to search for a target entry in each HASH bucket of the HASH list.
  • the search subunit 6022 is configured to calculate a HASH address based on the target data; based on the HASH address and configuration information, a valid HASH is determined from each HASH bucket in the HASH list Bucket, as a HASH bucket to be read, the configuration information records the correspondence between each HASH address and a valid HASH bucket; read the valid entry corresponding to the HASH address from the valid HASH bucket; The target data is compared with each valid entry, and a valid entry matching the target data is determined as the target entry.
  • each module in the message processing apparatus shown in FIG. 6 can be understood by referring to the related description of the foregoing message processing method.
  • the function of each module in the message processing apparatus shown in FIG. 6 may be realized by a program running on a processor, or may be realized by a specific logic circuit.
  • each unit in the message processing device can be implemented by a central processing unit (CPU, Central Processing Unit) or a microprocessor (MPU, Micro Processor) located in the message processing device Unit), or digital signal processor (DSP, Digital Processor), or field programmable gate array (FPGA, Field Programmable Gate Array) and so on.
  • CPU Central Processing Unit
  • MPU Micro Processor
  • DSP Digital Processor
  • FPGA Field Programmable Gate Array
  • FIG. 7 is a second structural composition diagram of a message processing apparatus according to an embodiment of the present application.
  • the message processing apparatus includes: a message analysis module 701, a rule acquisition module 702, a data extraction module 703, and HASH processing Module 704, message processing module 705, port acquisition module 706, in this embodiment, the parsing unit 601 in FIG. 6 corresponds to the message analysis module 601, port acquisition module 706, and rule acquisition module 602 in FIG. 7, in FIG. 6
  • the determination unit 602 corresponds to the data extraction module 703 and the HASH processing module 704 in FIG. 7, and the processing unit 603 in FIG. 6 corresponds to the message processing module 705 in FIG.
  • the message analysis module 701 is configured to parse the message to obtain the custom offset information corresponding to the message.
  • the custom offset information includes: the custom offset corresponding to the message and their respective definitions Custom offset address corresponding to offset;
  • the rule obtaining module 702 is set to determine the data extraction rule corresponding to the message based on the custom offset corresponding to the message;
  • the data extraction module 703 is configured to extract target data from the message based on the data extraction rule and the custom offset address corresponding to the respective defined offset;
  • the HASH processing module 704 is set to search for a target entry in the HASH list based on the target data, for example, to search for a target entry in each HASH bucket of the HASH list;
  • the message processing module 705 is configured to process the message using the target entry.
  • the device further includes: a port acquisition module 706, configured to determine an expansion port corresponding to the message based on a custom offset corresponding to the message;
  • the rule acquisition module 702 is configured to determine the data extraction rule corresponding to the message based on the expansion port.
  • each module is as follows: the message is input from the message analysis module, and the custom offset information (the custom offset and the custom offset corresponding to the respective defined offsets) is analyzed and obtained Address); send the obtained custom offset information to the port acquisition module to obtain the extended port; send the extended port to the rule acquisition module to obtain the corresponding data extraction rule; send the data extraction rule and the message (packet header data) Enter the data extraction module to get the target data to be compared; send the target data to the HASH calculation module for HASH operation to obtain the HASH address; send the HASH address to the HASH search module, use the HASH address to index out the corresponding valid entries, and then target the data Match the valid entries to determine the matching valid entries; send the matching valid entries to the message processing module to process the message.
  • the HASH calculation module and the HASH search module are collectively referred to as the HASH processing module.
  • the message analysis module 701 includes:
  • the parsing submodule 7011 is configured to parse the header of the message to obtain each field included in the header of the message;
  • the determination submodule 7012 is set to determine a custom offset corresponding to each field in the header of the packet as a custom offset corresponding to the packet based on a preset correspondence relationship, wherein, the The preset correspondence is the correspondence between the custom offset and the field; for each field in the header of the packet, the address at the preset position in the field is taken as corresponding to the field The custom offset address of the custom offset.
  • the port acquisition module 706 is configured to generate port index information based on the custom offset corresponding to the message and the custom offset included in the preset correspondence relationship; based on The port index information determines the expansion port corresponding to the message.
  • the device further includes:
  • the predefined module 707 is set to generate the preset correspondence, and for each field in the preset correspondence, the address corresponding to the head or tail of the field is used as the custom bias corresponding to the field Custom offset address of the shift amount.
  • the rule acquisition module 702 is configured to determine a rule number based on the expansion port; according to the rule number, obtain a data extraction rule, the data extraction rule includes one or more targets to be extracted The extraction rule corresponding to the data.
  • the extraction rule includes: an offset address, an offset address type, and a custom offset type.
  • the offset address type is used to indicate that the offset address is a relative offset address Or an absolute offset address.
  • the data extraction module 703 includes:
  • the first determining submodule 7031 is configured to determine the offset address corresponding to the target data to be extracted based on the data extraction rule, and the number of the target data to be extracted is one or more;
  • the second determination submodule 7032 is set to determine a custom offset corresponding to the relative offset address if the offset address corresponding to the target data to be extracted is a relative offset address;
  • the judgment sub-module 7033 is set to judge whether the custom offset corresponding to the relative offset address is the custom offset corresponding to the message;
  • the calculation submodule 7034 is set to be based on the custom offset address corresponding to the custom offset if the custom offset corresponding to the relative offset address is the custom offset corresponding to the message And the relative offset address to calculate the absolute offset address;
  • the extraction submodule 7035 is configured to extract target data from the message based on the absolute offset address.
  • the data extraction module 703 further includes: a third determination submodule 7036, which is set to if the custom offset corresponding to the relative offset address is not the custom offset corresponding to the message If the shift amount is determined, the data extraction rule is determined to be an invalid rule.
  • the extraction submodule 7035 is further configured to extract from the message based on the absolute offset address if the offset address corresponding to the target data to be extracted is an absolute offset address The target data.
  • the data extraction module 703 is further configured to extract the target from the packet based on the data extraction rule corresponding to the physical port if there is no expansion port matching the port index information data.
  • the HASH processing module 704 is configured to calculate a HASH address based on the target data; based on the HASH address, search for a target entry corresponding to the HASH address in the HASH list, for example, in the HASH list In each HASH bucket, search for the target entry corresponding to the HASH address.
  • the HASH processing module 704 is configured to input the target data and the rule number as key values into a HASH function to calculate a HASH address.
  • the HASH processing module 704 is configured to determine a valid HASH bucket from each HASH bucket in the HASH list as the HASH bucket to be read based on the HASH address and pre-configuration information ,
  • the pre-configuration information records the correspondence between each HASH address and an effective HASH bucket.
  • the effective HASH bucket refers to: when an entry is stored in the first HASH address of the first HASH bucket, the first The HASH bucket is an effective HASH bucket of the first HASH address; based on the HASH address, valid entries are read from the effective HASH bucket, and the number of the effective HASH buckets is one or more;
  • the target data is compared with each valid entry read, and a valid entry matching the target data is determined as a target entry corresponding to the HASH address.
  • each module in the message processing apparatus shown in FIG. 7 can be understood by referring to the related description of the foregoing message processing method.
  • the function of each module in the message processing device shown in FIG. 7 can be realized by a program running on a processor, or by a specific logic circuit.
  • each unit in the message processing device can be implemented by a CPU, MPU, DSP, or FPGA located in the message processing device.
  • the rule number In actual use, in order to confirm the uniqueness of the matching data, the rule number needs to be added.
  • the HASH conflict occurs, because the rules are obtained based on the expansion port, multiple rules can be used under each expansion port, then you can use the Configure another rule under the expansion port. Based on the new rule, configure the items that could not be configured due to HASH conflicts before, increase the utilization of HASH buckets under the same resources, and provide a good solution for HASH conflicts.
  • An embodiment of the present application also provides an optical network terminal, including a memory and a processor, and the memory stores computer-executable instructions, and the computer-executable instructions implement the following steps when executed by the processor:
  • the first rule Based on the first rule, determine the custom offset corresponding to each field in the header of the packet as the custom offset corresponding to the packet.
  • the first rule includes the custom offset and Correspondence between fields;
  • the expansion port corresponding to the message is determined based on the custom offset corresponding to the message.
  • the address at the preset position in the field is used as the custom offset address of the custom offset corresponding to the field.
  • the target entry is searched in the HASH list, for example, in each HASH bucket of the HASH list.
  • the second rule includes one or more extraction rules corresponding to the target data to be extracted, the extraction rule includes: an offset address, a type of offset address, and a type of a custom offset, The type of the offset address is used to indicate whether the offset address is a relative offset address or an absolute offset address;
  • the offset address corresponding to the target data to be extracted is a relative offset address, determine a custom offset corresponding to the relative offset address;
  • the custom offset corresponding to the relative offset address is the custom offset corresponding to the message, based on the custom offset address corresponding to the custom offset and the relative offset address , Calculate an absolute offset address, and extract target data from the message based on the absolute offset address.
  • the target data is extracted from the message based on the absolute offset address.
  • a valid HASH bucket is determined from each HASH bucket in the HASH list as the HASH bucket to be read, and the configuration information records each HASH address and valid HASH bucket
  • the corresponding HASH bucket refers to: when an entry is stored in the first HASH address of the first HASH bucket, the first HASH bucket is an effective HASH bucket of the first HASH address;
  • the target data is compared with each valid entry, and a valid entry matching the target data is determined as the target entry.
  • the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of a hardware embodiment, a software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer usable program code.
  • a computer usable storage media including but not limited to disk storage and optical storage, etc.
  • These computer program instructions can be provided to the processor of a general-purpose computer, special-purpose computer, embedded processing machine, or other programmable data processing device to produce a machine that enables the generation of instructions executed by the processor of the computer or other programmable data processing device
  • These computer program instructions may also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, the instructions The device implements the functions specified in one block or multiple blocks of the flowchart one flow or multiple flows and / or block diagrams.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operating steps are performed on the computer or other programmable device to produce computer-implemented processing, which is executed on the computer or other programmable device
  • the instructions provide steps for implementing the functions specified in one block or multiple blocks of the flowchart one flow or multiple flows and / or block diagrams.
  • the embodiments of the present application also provide a storage medium on which a computer program is stored, and when the computer program is executed by the processor, the above message processing method is implemented.

Landscapes

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

Abstract

Disclosed are a message processing method and device, a storage medium and an optical network terminal. The method comprises: parsing a message, and determining, according to a first rule and based on a parsing result, an extension port corresponding to the message, wherein the extension port is used for diverting the message; determining, based on a second rule corresponding to the extension port, a target entry corresponding to the message; and processing the message using the target entry.

Description

一种报文处理方法及装置、存储介质、光网络终端Message processing method and device, storage medium, and optical network terminal
本申请要求在2018年11月09日提交中国专利局、申请号为201811333746.9的中国专利申请的优先权,该申请的全部内容通过引用结合在本申请中。This application requires the priority of the Chinese patent application filed with the Chinese Patent Office and the application number 201811333746.9 on November 9, 2018. The entire contents of this application are incorporated by reference in this application.
技术领域Technical field
本申请涉及无源光网络(PON,Passive Optical Networks)技术领域,例如涉及一种报文处理方法及装置、存储介质、光网络终端。This application relates to the technical field of passive optical networks (PON, Passive, Optical Networks), for example, to a message processing method and device, a storage medium, and an optical network terminal.
背景技术Background technique
千兆无源光网络(GPON,Gigabit-capable Passive Optical Networks)技术是PON系列技术中架构最完备、标准内容最完整的网络技术。GPON大量使用于接入网,是取代非对称数字用户环路(ADSL,Asymmetric Digital Subscriber Line)接入技术的最佳方案。Gigabit passive optical network (GPON, Gigabit-capable, Passive, Optical Networks) technology is the most complete network technology in the PON series of technology and the most complete standard content. GPON is widely used in the access network and is the best solution to replace the Asymmetric Digital Subscriber Loop (ADSL, Asymmetric Digital Subscriber Line) access technology.
GPON的光网络终端(ONU,Optical Network Unit)是GPON套片的核心芯片之一。对于ONU芯片而言,以太网报文的探测和处理是一个非常重要的环节,ONU芯片需要识别网络中各式各样的报文,且针对不同的报文有不同的处理方式。The optical network terminal (ONU, Optical, Network Unit) of GPON is one of the core chips of the GPON suite. For the ONU chip, the detection and processing of Ethernet packets is a very important link. The ONU chip needs to identify various packets in the network and have different processing methods for different packets.
随着业务的不断丰富,加上不同的报文有不同的处理方式,就会导致不同的报文提取的位置和内容可能不同,这使得ONU芯片的每个端口对应的提取规则变得越来越多。With the continuous enrichment of services and the different processing methods of different messages, the location and content of different message extraction may be different, which makes the extraction rules corresponding to each port of the ONU chip become more and more more.
此外,芯片厂商对于报文处理的条目参数越来越重视,并将条目参数这个指标当成运营商采集的一个重要指标,存储条目参数的容量不断地扩大,单纯地使用随机存取存储器(RAM,Random-Access Memory)已经无法满足存储需求,必须使用片外双倍速率同步动态随机存储器(DDR,Double Data Rate)来存储条目参数。In addition, chip manufacturers pay more and more attention to the item parameters of message processing, and regard the item parameter as an important index collected by operators. The capacity for storing item parameters is continuously expanding, and the random access memory (RAM, Random-Access Memory) can no longer meet the storage requirements, you must use off-chip double-rate synchronous dynamic random access memory (DDR, Double Data) to store the entry parameters.
随着技术不断向前发展,网络性能不断提升,PON的类型不仅仅是GPON、以太网无源光网络(EPON,Ethernet Passive Optical Network),还可以是非对称XGPON、对称XGPON、XEPON。PON由1G向10G升级后,报文处理的 条目参数在使用片外DDR的过程中,还需要考虑DDR带宽是否充足。相关技术中,全部的报文均使用同一个物理端口来访问DDR,由于报文的种类较多,因而这个物理端口下的规则数目就会较多,每个报文均需要对物理端口下的多个规则进行匹配,导致DDR的带宽较大。With the continuous development of technology and the continuous improvement of network performance, the types of PON are not only GPON, Ethernet Passive Optical Network (EPON), but also asymmetric XGPON, symmetric XGPON, XEPON. After PON is upgraded from 1G to 10G, in the process of using the off-chip DDR, the parameter of the packet processing entry also needs to consider whether the DDR bandwidth is sufficient. In the related art, all the packets use the same physical port to access DDR. Because there are more types of packets, the number of rules under this physical port will be larger. Each packet needs to Multiple rules are matched, resulting in a larger DDR bandwidth.
发明内容Summary of the invention
本申请实施例提供了一种报文处理方法及装置、存储介质、光网络终端。The embodiments of the present application provide a message processing method and device, a storage medium, and an optical network terminal.
一种报文处理方法,所述方法包括:A message processing method, the method includes:
对报文进行解析,基于解析结果按照第一规则确定所述报文对应的扩展端口,所述扩展端口用于对所述报文进行分流;Parse the message, and determine the expansion port corresponding to the message according to the first rule based on the analysis result, and the expansion port is used to distribute the message;
基于所述扩展端口对应的第二规则,确定所述报文对应的目标条目;Determine the target entry corresponding to the message based on the second rule corresponding to the expansion port;
利用所述目标条目对所述报文进行处理。Use the target entry to process the message.
一种报文处理装置,包括:A message processing device, including:
解析单元,设置为对报文进行解析,基于解析结果按照第一规则确定所述报文对应的扩展端口,所述扩展端口用于对所述报文进行分流;The parsing unit is configured to parse the message, and determine the expansion port corresponding to the message according to the first rule based on the analysis result, and the expansion port is used to offload the message;
确定单元,设置为基于所述扩展端口对应的第二规则,确定所述报文对应的目标条目;A determining unit, configured to determine the target entry corresponding to the packet based on the second rule corresponding to the expansion port;
处理单元,设置为利用所述目标条目对所述报文进行处理。The processing unit is configured to process the message using the target entry.
一种存储介质,存储有计算机程序,所述计算机程序被处理器执行时实现前述报文处理方法。A storage medium stores a computer program, and when the computer program is executed by a processor, the foregoing message processing method is realized.
一种光网络终端,所述光网络终端包括存储器和处理器,所述存储器上存储有计算机可执行指令,所述计算机可执行指令被所述处理器执行时实现前述报文处理方法。An optical network terminal includes a memory and a processor, and a computer-executable instruction is stored on the memory, and the computer-executable instruction is executed by the processor to implement the foregoing message processing method.
附图说明BRIEF DESCRIPTION
附图以示例而非限制的方式大体示出了本文中所讨论的多个实施例。The drawings generally illustrate various embodiments discussed herein by way of example and not limitation.
图1为本申请实施例的报文处理方法的流程示意图一;FIG. 1 is a schematic flowchart 1 of a packet processing method according to an embodiment of the present application;
图2为本申请实施例的报文处理方法的流程示意图二;2 is a second schematic flowchart of the packet processing method according to an embodiment of the present application;
图3为本申请实施例的包格式的示意图;3 is a schematic diagram of a packet format according to an embodiment of this application;
图4为本申请实施例的扩展端口的获取流程示意图;4 is a schematic diagram of a process for acquiring an expansion port according to an embodiment of the present application;
图5为本申请实施例的绝对偏移量的获取流程示意图;FIG. 5 is a schematic flowchart of obtaining an absolute offset according to an embodiment of this application;
图6为本申请实施例的报文处理装置的结构组成示意图一;FIG. 6 is a first schematic diagram of the structural composition of a message processing device according to an embodiment of this application;
图7为本申请实施例的报文处理装置的结构组成示意图二。FIG. 7 is a second schematic diagram of the structural composition of the packet processing device according to an embodiment of the present application.
具体实施方式detailed description
下面结合附图对本申请实施例的实现进行详细阐述。The implementation of the embodiments of the present application will be described in detail below with reference to the drawings.
ONU对报文进行处理的过程大致如下:The process for ONU to process the message is as follows:
1)确定报文的数据提取规则。1) Determine the data extraction rules of the message.
这里,数据提取规则用于指示在报文的哪些位置提取数据。例如:在报文的第10个字节提取数据。Here, data extraction rules are used to indicate where to extract data in the message. For example: extract data in the 10th byte of the message.
2)根据数据提取规则提取数据后,基于数据计算HASH地址。2) After extracting the data according to the data extraction rules, calculate the HASH address based on the data.
3)基于HASH地址,在HASH列表中查找目标条目,例如在HASH列表的每个HASH桶中查找目标条目。这里,HASH列表存储在ONU外部的DDR中。3) Based on the HASH address, find the target entry in the HASH list, for example, find the target entry in each HASH bucket of the HASH list. Here, the HASH list is stored in the DDR outside the ONU.
ONU对报文进行处理的过程中,规则数、条目数、性能、HASH利用率这些因素是有相关性的。具体地,单个报文处理需要匹配的规则数增加,会引起条目的读取次数增加,进而引起DDR带宽增加;性能提升,也会引起DDR带宽增加;HASH桶数增加,也会引起DDR带宽增加。这里,DDR带宽是指访问DDR的速率。此外,如何在同样容量的情况下配置更多的条目进去,以及规则数本身占用的资源,也是需要考虑的因素。另外,如何更为方便地给软件(面向用户)提供配置接口,是用户体验的一个重要表现。During the processing of packets by the ONU, the number of rules, the number of entries, performance, and HASH utilization rate are relevant. Specifically, the increase in the number of matching rules required for a single message processing will increase the number of entries read, which will increase the DDR bandwidth; the performance improvement will also increase the DDR bandwidth; the increase in the number of HASH buckets will also increase the DDR bandwidth . Here, DDR bandwidth refers to the rate of access to DDR. In addition, how to configure more entries in the case of the same capacity, and the resources occupied by the rule number itself, are also factors that need to be considered. In addition, how to provide a configuration interface for software (facing users) more conveniently is an important manifestation of user experience.
图1为本申请实施例的报文处理方法的流程示意图一,如图1所示,所述报文处理方法包括以下步骤。FIG. 1 is a first schematic flowchart of a message processing method according to an embodiment of the present application. As shown in FIG. 1, the message processing method includes the following steps.
步骤101:对报文进行解析,基于解析结果按照第一规则确定所述报文对应 的扩展端口,所述扩展端口用于对所述报文进行分流。Step 101: Parse the message, and determine the expansion port corresponding to the message according to the first rule based on the parsing result, and the expansion port is used to offload the message.
在一实施例中,对报文的头部进行解析,得到所述报文的头部所包括的每个字段;基于第一规则,确定所述报文的头部中每个字段分别对应的自定义偏移量作为所述报文对应的自定义偏移量,其中,所述第一规则包括自定义偏移量与字段之间的对应关系;基于所述报文对应的自定义偏移量,确定所述报文对应的扩展端口。In an embodiment, the header of the packet is parsed to obtain each field included in the header of the packet; based on the first rule, it is determined that each field in the header of the packet corresponds to A custom offset as a custom offset corresponding to the message, wherein the first rule includes a correspondence between the custom offset and a field; based on the custom offset corresponding to the message Quantity to determine the expansion port corresponding to the message.
例如:第一规则中包括6组自定义偏移量与字段之间的对应关系,如下表1所示:For example, the first rule includes the correspondence between 6 sets of custom offsets and fields, as shown in Table 1 below:
自定义偏移量Custom offset 字段(头部)Field (header)
OFFSET 1 OFFSET1 字段1Field 1
OFFSET 2OFFSET 2 字段2Field 2
OFFSET 3OFFSET3 字段3Field 3
OFFSET 4OFFSET 4 字段4Field 4
OFFSET 5OFFSET 5 字段5Field 5
OFFSET 6OFFSET 6 字段6Field 6
表1Table 1
假设:对报文的头部进行解析,得到所述报文的头部包括如下字段:字段1和字段3,基于表1,该报文对应的自定义偏移量为OFFSET 1和OFFSET 3。在一实施方式中,第一规则中的每个自定义偏移量通过一个比特位来表示,将报文对应的自定义偏移量设置为1,将其他的自定义偏移量设置为0,那么基于所述报文对应的自定义偏移量,可得出如下信息:101000,将这个信息作为端口索引信息,用于确定扩展端口,根据不同的端口索引信息可以匹配到不同的扩展端口。Assumption: Parsing the header of the message to obtain the header of the message includes the following fields: Field 1 and Field 3. Based on Table 1, the custom offsets corresponding to the message are OFFSET 1 and OFFSET 3. In an embodiment, each custom offset in the first rule is represented by a bit, and the custom offset corresponding to the message is set to 1, and the other custom offsets are set to 0 Then, based on the custom offset corresponding to the message, the following information can be obtained: 101000, which is used as the port index information to determine the expansion port, and different expansion ports can be matched according to different port index information .
在一实施例中,不同类型的报文具有不同的头部,这样,不同类型的报文可以分流到不同的扩展端口下。如果不存在与所述端口索引信息相匹配的扩展端口,则基于物理端口对应的第三规则,确定所述报文对应的目标条目;本实施例中,所述物理端口对应的第三规则的数目大于所述扩展端口对应的第二规则的数目。In an embodiment, different types of packets have different headers, so that different types of packets can be distributed to different expansion ports. If there is no expansion port matching the port index information, the target entry corresponding to the packet is determined based on the third rule corresponding to the physical port; in this embodiment, the third rule corresponding to the physical port The number is greater than the number of second rules corresponding to the expansion port.
上述方案中,在对报文进行解析时,针对所述报文的头部中的每个字段,将所述字段中预设位置处的地址,作为与所述字段对应的自定义偏移量的自定义偏移地址。In the above solution, when parsing the message, for each field in the header of the message, the address at the preset position in the field is used as a custom offset corresponding to the field Custom offset address.
例如,在表1的基础上,增加字段与自定义偏移地址的对应关系,第一规则扩展成如下表2所示:For example, on the basis of Table 1, the correspondence between the field and the custom offset address is added, and the first rule is expanded as shown in Table 2 below:
自定义偏移量Custom offset 字段(头部)Field (header) 自定义偏移地址Custom offset address
OFFSET 1OFFSET1
字段1Field 1 字段1的尾地址(Adress1)End address of field 1 (Adress1)
OFFSET 2OFFSET 2 字段2Field 2 字段2的首地址(Adress2)First address of field 2 (Adress2)
OFFSET 3OFFSET3 字段3Field 3 字段3的首地址(Adress3)First address of field 3 (Adress3)
OFFSET 4OFFSET 4 字段4Field 4 字段4的首地址(Adress4)First address of field 4 (Adress4)
OFFSET 5OFFSET 5 字段5Field 5 字段5的首地址(Adress5)First address of field 5 (Adress5)
OFFSET 6OFFSET 6 字段6Field 6 字段6的首地址(Adress6)First address of field 6 (Adress6)
表2Table 2
假设:对报文的头部进行解析,得到所述报文的头部包括如下字段:字段1和字段3,基于表2,该报文对应的自定义偏移量为OFFSET 1和OFFSET 3,本实施例中,OFFSET 1的自定义偏移地址为该报文中字段1的尾地址,OFFSET2的自定义偏移地址为该报文中字段2的首地址。Assumption: Parsing the header of the packet to obtain the header of the packet includes the following fields: Field 1 and Field 3, based on Table 2, the custom offsets corresponding to the packet are OFFSET1 and OFFSET3, In this embodiment, the custom offset address of OFFSET1 is the tail address of field 1 in the message, and the custom offset address of OFFSET2 is the first address of field 2 in the message.
步骤102:基于所述扩展端口对应的第二规则,确定所述报文对应的目标条目。Step 102: Determine the target entry corresponding to the packet based on the second rule corresponding to the expansion port.
本申请实施例中,扩展端口下绑定有第二规则,基于所述扩展端口对应的第二规则,以及每个所述自定义偏移量对应的自定义偏移地址,从所述报文中提取出目标数据,所述第二规则用于提取目标数据;基于所述目标数据,在HASH列表中查找目标条目,例如可以在HASH列表的每个HASH桶中查找目标条目。In the embodiment of the present application, a second rule is bound to the expansion port, based on the second rule corresponding to the expansion port and the custom offset address corresponding to each of the custom offsets, from the message The second rule is used to extract the target data. Based on the target data, the target entry is searched in the HASH list. For example, the target entry can be found in each HASH bucket of the HASH list.
在一实施方式中,所述第二规则包括一个或多个待提取的目标数据对应的提取规则,所述提取规则包括:偏移地址、偏移地址的类型以及自定义偏移量的类型,本实施方式中,所述偏移地址的类型用于表示所述偏移地址为相对偏移地址或是绝对偏移地址;In an embodiment, the second rule includes one or more extraction rules corresponding to the target data to be extracted, the extraction rule includes: an offset address, a type of offset address, and a type of a custom offset, In this embodiment, the type of the offset address is used to indicate whether the offset address is a relative offset address or an absolute offset address;
基于所述扩展端口对应的第二规则,以及每个所述自定义偏移量对应的自定义偏移地址,从所述报文中提取出目标数据,包括:基于所述扩展端口对应的第二规则,确定待提取的目标数据对应的偏移地址;如果所述待提取的目标数据对应的偏移地址为相对偏移地址,则确定所述相对偏移地址对应的自定义偏移量;判断所述相对偏移地址对应的自定义偏移量,是否为所述报文对应的自定义偏移量;如果所述相对偏移地址对应的自定义偏移量为所述报文对应的自定义偏移量,则基于所述自定义偏移量对应的自定义偏移地址以及所述相对偏移地址,计算绝对偏移地址,并基于所述绝对偏移地址从所述报文中提取出目标数据。Based on the second rule corresponding to the expansion port and the custom offset address corresponding to each of the custom offsets, extracting target data from the message includes: Two rules, determine the offset address corresponding to the target data to be extracted; if the offset address corresponding to the target data to be extracted is a relative offset address, determine a custom offset corresponding to the relative offset address; Determine whether the custom offset corresponding to the relative offset address is a custom offset corresponding to the message; if the custom offset corresponding to the relative offset address is corresponding to the message For a custom offset, an absolute offset address is calculated based on the custom offset address corresponding to the custom offset and the relative offset address, and based on the absolute offset address from the message Extract the target data.
上述方案中,如果所述待提取的目标数据对应的偏移地址为绝对偏移地址,则基于所述绝对偏移地址从所述报文中提取出目标数据。In the above solution, if the offset address corresponding to the target data to be extracted is an absolute offset address, the target data is extracted from the message based on the absolute offset address.
上述方案中,在HASH列表中查找目标条目,例如在HASH列表的每个HASH桶中查找目标条目,可以通过以下方式实现:基于所述目标数据,计算HASH地址;基于所述HASH地址以及配置信息,从所述HASH列表的每个HASH桶中确定出有效的HASH桶,作为需要读取的HASH桶,本方案中,所述配置信息记录有每个HASH地址与有效的HASH桶的对应关系,所述有效的HASH桶是指:在第一HASH桶的第一HASH地址内存储条目的情况下,所述第一HASH桶为所述第一HASH地址的有效的HASH桶;从所述有效的HASH桶中读取与所述HASH地址对应的有效条目;将所述目标数据与每个有效条目进行比较,确定出与所述目标数据相匹配的有效条目,作为所述目标条目。In the above solution, searching for the target entry in the HASH list, for example, searching for the target entry in each HASH bucket of the HASH list, can be achieved by: calculating the HASH address based on the target data; based on the HASH address and configuration information , Determine an effective HASH bucket from each HASH bucket in the HASH list as the HASH bucket to be read, in this solution, the configuration information records the correspondence between each HASH address and the effective HASH bucket, The effective HASH bucket refers to: in the case where an entry is stored in the first HASH address of the first HASH bucket, the first HASH bucket is an effective HASH bucket of the first HASH address; from the effective A valid entry corresponding to the HASH address is read in the HASH bucket; the target data is compared with each valid entry, and a valid entry matching the target data is determined as the target entry.
这里,在HASH处理的过程中新增预处理步骤,即:从HASH列表的每个HASH桶中确定出有效的HASH桶,作为需要读取的HASH桶,基于HASH地址从所述有效的HASH桶中读取有效条目,使得报文整体对DDR的带宽需求降低。Here, a new pre-processing step is added in the process of HASH processing, that is, an effective HASH bucket is determined from each HASH bucket in the HASH list, as a HASH bucket to be read, and the effective HASH bucket is based on the HASH address Reading valid entries in the system makes the overall DDR bandwidth requirements of the message lower.
步骤103:利用所述目标条目对所述报文进行处理。Step 103: Use the target entry to process the message.
在一实施例中,上述每个步骤的执行主体可以为ONU。In an embodiment, the execution subject of each step above may be an ONU.
本申请实施例中,引入了扩展端口的概念,不同类型的报文被分流到不同的扩展端口下,这样,一条报文只需要通过与其对应的扩展端口下的规则来从DDR中查找目标条目,从而无需通过物理端口下的多个规则来从DDR中查找 目标条目,减少了从DDR中读取条目的次数,也即降低了DDR的带宽。此外,引入了自定义偏移量的概念。根据以太网协议、传输控制协议/因特网互联协议(TCP/IP,Transmission Control Protocol/Internet Protocol)等网络协议预先总结归纳出包格式(这里的包格式能够表示出第一规则,第一规则包括自定义偏移量与字段之间的对应关系),以及配置扩展端口。对于某个报文,可以基于包格式确定出自定义偏移量和各自定义偏移量对应的自定义偏移地址,基于自定义偏移量确定出扩展端口,从而将用户侧传输来的报文进行分类处理。基于扩展端口确定出第二规则(也即数据提取规则),基于所述第二规则以及所述各自定义偏移量对应的自定义偏移地址,从所述报文中提取出目标数据,并进行HASH处理。这里,在HASH处理的过程中新增预处理步骤,即:从HASH列表的每个HASH桶中确定出有效的HASH桶,作为需要读取的HASH桶,基于HASH地址从所述有效的HASH桶中读取有效条目,使得报文整体对DDR的带宽需求降低。再者,通过对预处理过程进行灵活配置可以变相地提升HASH利用率,优化规则总数,配置操作可以通过软件实现,方便用户操作。In the embodiment of the present application, the concept of an expansion port is introduced. Different types of packets are shunted to different expansion ports. In this way, a message only needs to find a target entry from the DDR through the rules under the corresponding expansion port Therefore, there is no need to find the target entry from the DDR through multiple rules under the physical port, which reduces the number of times the entry is read from the DDR, that is, reduces the bandwidth of the DDR. In addition, the concept of custom offsets is introduced. According to the Ethernet protocol, transmission control protocol / Internet interconnection protocol (TCP / IP, Transmission Control / Protocol / Internet Protocol) and other network protocols, the packet format is summarized in advance (the packet format here can express the first rule, and the first rule includes Define the correspondence between offset and field), and configure the expansion port. For a certain packet, the user-defined offset and the user-defined offset address corresponding to the respective defined offset can be determined based on the packet format, and the expansion port can be determined based on the user-defined offset, so as to transfer the packet transmitted from the user side Perform classification processing. Determining a second rule (that is, a data extraction rule) based on the expansion port, extracting target data from the message based on the second rule and the custom offset address corresponding to the respective defined offset, and Perform HASH processing. Here, a new pre-processing step is added in the process of HASH processing, that is, an effective HASH bucket is determined from each HASH bucket in the HASH list, as a HASH bucket to be read, and the effective HASH bucket is based on the HASH address Reading valid entries in the system makes the overall DDR bandwidth requirements of the message lower. Furthermore, by flexibly configuring the preprocessing process, the utilization rate of HASH can be improved in disguise, the total number of rules can be optimized, and the configuration operation can be realized by software to facilitate user operations.
图2为本申请实施例的报文处理方法的流程示意图二,如图2所示,所述报文处理方法包括以下步骤:FIG. 2 is a second schematic flowchart of a message processing method according to an embodiment of the present application. As shown in FIG. 2, the message processing method includes the following steps:
步骤201:对报文进行解析,得到所述报文对应的自定义偏移信息,所述自定义偏移信息包括:所述报文对应的自定义偏移量、各自定义偏移量对应的自定义偏移地址。Step 201: Analyze the message to obtain the custom offset information corresponding to the message. The custom offset information includes: a custom offset corresponding to the message, and a corresponding offset corresponding to each defined offset. Custom offset address.
本步骤具体包括:This step specifically includes:
1)对报文的头部进行解析,得到所述报文的头部所包括的每个字段;1) Analyze the header of the packet to obtain each field included in the header of the packet;
2)基于预设对应关系,确定所述报文的头部中每个字段分别对应的自定义偏移量作为所述报文对应的自定义偏移量,本步骤中,所述预设对应关系为自定义偏移量与字段之间的对应关系;2) Based on the preset correspondence, determine the custom offset corresponding to each field in the header of the packet as the custom offset corresponding to the packet. In this step, the preset correspondence The relationship is the correspondence between the custom offset and the field;
3)针对所述报文的头部中的每个字段,将所述字段中预设位置处的地址,作为与所述字段对应的自定义偏移量的自定义偏移地址。3) For each field in the header of the message, use the address at a preset position in the field as the custom offset address of the custom offset corresponding to the field.
对于上述1),对报文的头部进行解析后,可以得到报文的头部所包括的每个字段。例如:对逻辑链路控制(LLC,Logic Link Control)+子网接入协议(SNAP,SubNetwork Access Protocol)格式的dslite报文的头部进行解析后,可以得到如 下字段:源IP(SIP,Source IP)、目的IP(DIP,Destination IP)、IP协议(IP Protocol),本申请实施例将上述三个字段统称为三元组。再例如:对以太网(ethernet)V2格式的ipv4的传输控制协议(TCP,Transmission Control Protocol)报文的头部进行解析后,可以得到如下字段:SIP、DIP、IP Protocol、源端口(Sport,Source port)、目的端口(Dport,Destination port),本申请实施例将上述五个字段统称为五元组。又例如:对普通LLC报文的头部进行解析后,可以得到如下字段:目的地址(DA,Destination,Address)。For the above 1), after parsing the header of the packet, each field included in the header of the packet can be obtained. For example: after parsing the header of a dslite packet in the format of logical link control (LLC, Logic Link Control) + subnet access protocol (SNAP, SubNetwork Access Protocol), the following fields can be obtained: source IP IP), destination IP (DIP, Destination IP), IP protocol (IP Protocol), the embodiments of the present application collectively refer to the above three fields as triples. As another example: after parsing the header of the IPv4 transmission control protocol (TCP, Transmission Control) Protocol of the Ethernet (Ethernet) V2 format, the following fields can be obtained: SIP, DIP, IP Protocol, source port (Sport, Source), destination port (Dport, Destination port), the embodiments of the present application collectively refer to the above five fields as quintuples. For another example: after parsing the header of a common LLC message, the following fields can be obtained: destination address (DA, Destination, Address).
对于上述2),预先生成所述预设对应关系,其中,所述预设对应关系为自定义偏移量与字段之间的对应关系。这里,针对所述预设对应关系中的每个字段,将所述字段的头部或尾部对应的地址作为与所述字段对应的自定义偏移量的自定义偏移地址。For the above 2), the preset correspondence is generated in advance, where the preset correspondence is a correspondence between a custom offset and a field. Here, for each field in the preset correspondence, the address corresponding to the head or tail of the field is used as the custom offset address of the custom offset corresponding to the field.
实际应用中,根据以太网协、TCP\IP协议以及RFC协议等现有协议的多种包格式,总结的包格式如图3所示。在图3中,(a)、(b)、(c)、(d)分别为总结出的四种包格式,其中,每种包格式都由多个字段组成。以下对图3中涉及到的自定义偏移量(OFFSET)与字段之间的对应关系进行如下说明:In actual application, according to the multiple packet formats of the existing protocols such as Ethernet protocol, TCP \ IP protocol and RFC protocol, the summarized packet format is shown in Figure 3. In FIG. 3, (a), (b), (c), and (d) are the four packet formats summarized, wherein each packet format is composed of multiple fields. The following describes the correspondence between the custom offset (OFFSET) and the fields involved in Figure 3:
L2_OFFSET:当报文的协议是EthernetV2时,该自定义偏移量对应长度/类型(lenth/type)字段,自定义偏移地址指向lenth/type的头部位置。L2_OFFSET: When the protocol of the message is EthernetV2, the custom offset corresponds to the length / type (lenth / type) field, and the custom offset address points to the head position of lenth / type.
L3_OFF SET_V4:当报文的协议是EthernetV2时,该自定义偏移量对应IPV4头字段,自定义偏移地址指向IPV4头的头部位置。这里,IPV4头包括:普通V4头,PPPOE封装的V4头,V4 IN V6,PPPOE封装的V4 IN V6,V6 IN V4,PPPOE封装的V4 IN V6。L3_OFF SET_V4: When the protocol of the packet is EthernetV2, the custom offset corresponds to the IPV4 header field, and the custom offset address points to the head position of the IPV4 header. Here, the IPV4 header includes: ordinary V4 header, PPPOE encapsulated V4 header, V4 IN V6, PPPOE encapsulated V4 IN V6, V6 IN V4, PPPOE encapsulated V4 IN V6.
L3_OFFSET_V6:当报文的协议是EthernetV2时,该自定义偏移量对应IPV6头字段,自定义偏移地址指向IPV6头的头部位置。IPV6头包括:普通V6头,PPPOE封装的V6头,V6 IN V4,PPPOE封装的V6 IN V6,V4 IN V6,PPPOE封装的V6 IN V4。L3_OFFSET_V6: When the protocol of the packet is EthernetV2, the custom offset corresponds to the IPV6 header field, and the custom offset address points to the head position of the IPV6 header. The IPV6 header includes: ordinary V6 header, PPPOE encapsulated V6 header, V6 IN V4, PPPOE encapsulated V6 IN V6, V4 IN V6, PPPOE encapsulated V6 IN V4.
L3_OFFSET_V6_LAST:当报文的协议是EthernetV2时,该自定义偏移量对应IPV6最后一跳扩展头或者用户自定义的扩展头的字段,自定义偏移地址指向IPV6最后一跳扩展头或者用户自定义的扩展头的头部位置,如果IPV6只有一个扩展头,则指向第一个扩展头的位置。这里,扩展头包括:普通V6头,PPPOE 封装的V6头,V6 IN V4,PPPOE封装的V6 IN V4。L3_OFFSET_V6_LAST: When the protocol of the packet is EthernetV2, the custom offset corresponds to the field of the IPV6 last hop extension header or user-defined extension header, and the custom offset address points to the IPV6 last hop extension header or user-defined If the IPV6 has only one extension header, it will point to the position of the first extension header. Here, the extended header includes: ordinary V6 header, PPPOE encapsulated V6 header, V6 IN V4, PPPOE encapsulated V6 IN V4.
L4_OFFSET:当报文的协议是EthernetV2时,该自定义偏移量对应TCP/UDP头字段,自定义偏移地址指向TCP/UDP头的头部位置。L4_OFFSET: When the protocol of the packet is EthernetV2, the custom offset corresponds to the TCP / UDP header field, and the custom offset address points to the head position of the TCP / UDP header.
L5_OFFSET:当报文的协议是EthernetV2时,该自定义偏移量对应TCP有效载荷(payload)字段,自定义偏移地址指向TCP payload的头部位置。L5_OFFSET: When the protocol of the message is EthernetV2, the custom offset corresponds to the TCP payload (payload) field, and the custom offset address points to the header position of TCP payload.
对于上述3),根据以上总结到的包格式结合报文的头部所包括的每个字段,得到该报文的自定义偏移量以及各自定义偏移量对应的自定义偏移地址,这里,可以得到多个自定义偏移量以及相应的自定义偏移地址。For the above 3), according to the packet format summarized above and each field included in the header of the packet, the custom offset of the packet and the custom offset address corresponding to the respective defined offsets are obtained, here , You can get multiple custom offsets and corresponding custom offset addresses.
例如:对LLC+SNAP格式的dslite报文的头部进行解析后,可以得到如下字段:SIP、DIP、IP Protocol。其中,SIP对应的自定义偏移量为L2_OFFSET,DIP对应的自定义偏移量为L3_OFFSET_V4,IP Protocol对应的自定义偏移量为L3_OFFSET_V6。对于不同的报文,由于每个字段的位置可能不同,因而对于同一自定义偏移量对应的自定义偏移地址可能不同。For example: after parsing the header of the dslite message in LLC + SNAP format, the following fields can be obtained: SIP, DIP, IP Protocol. Among them, the custom offset corresponding to SIP is L2_OFFSET, the custom offset corresponding to DIP is L3_OFFSET_V4, and the custom offset corresponding to IP Protocol is L3_OFFSET_V6. For different packets, since the position of each field may be different, the custom offset address corresponding to the same custom offset may be different.
步骤202:基于所述报文对应的自定义偏移量,确定所述报文对应的数据提取规则。Step 202: Determine the data extraction rule corresponding to the message based on the custom offset corresponding to the message.
本步骤具体包括:This step specifically includes:
1)基于所述报文对应的自定义偏移量,确定所述报文对应的扩展端口;1) Determine the expansion port corresponding to the message based on the custom offset corresponding to the message;
2)基于所述扩展端口,确定所述报文对应的数据提取规则。2) Based on the expansion port, determine a data extraction rule corresponding to the message.
对于上述1),基于所述报文对应的自定义偏移量以及所述预设对应关系中所包括的自定义偏移量,生成端口索引信息;For the above 1), based on the custom offset corresponding to the message and the custom offset included in the preset correspondence, port index information is generated;
基于所述端口索引信息,确定所述报文对应的扩展端口。Based on the port index information, determine the expansion port corresponding to the packet.
例如:预设对应关系中所包括的自定义偏移量总用有6个,每个自定义偏移量通过一个比特位来表示,报文对应的自定义偏移量设置为1,其他的自定义偏移量设置为0。假如报文对应两个自定义偏移量,分别为6个自定义偏移量中的第一个和第三个,那么端口索引信息为101000;再例如,报文对应5个自定义偏移量,分别为6个自定义偏移量中的前5个,那么端口索引信息为111110。根据不同的端口索引信息可以匹配到不同的扩展端口。For example: there are 6 custom offsets included in the preset correspondence, each custom offset is represented by a bit, the corresponding custom offset of the message is set to 1, and the other The custom offset is set to 0. If the message corresponds to two custom offsets, which are the first and third of the six custom offsets, then the port index information is 101000; for another example, the message corresponds to 5 custom offsets The amount is the first 5 of the 6 custom offsets, then the port index information is 111110. According to different port index information, different expansion ports can be matched.
对于上述2),基于所述扩展端口,确定规则编号;根据所述规则编号,获 取数据提取规则,其中,所述数据提取规则包括一个或多个待提取的目标数据对应的提取规则,所述提取规则包括:偏移地址、偏移地址的类型以及自定义偏移量的类型,其中,所述偏移地址的类型用于表示所述偏移地址为相对偏移地址或是绝对偏移地址。For the above 2), a rule number is determined based on the expansion port; according to the rule number, a data extraction rule is obtained, wherein the data extraction rule includes one or more extraction rules corresponding to target data to be extracted, the The extraction rule includes: an offset address, an offset address type, and a custom offset type, where the offset address type is used to indicate whether the offset address is a relative offset address or an absolute offset address .
本申请实施例中,每个扩展端口下可以配置一个数据提取规则,也可以配置多个数据提取规则,以便适用业务种类繁多的需求。In the embodiment of the present application, one data extraction rule can be configured under each expansion port, or multiple data extraction rules can also be configured in order to meet the requirements of a wide variety of services.
本申请实施例中,数据提取规则包括一个或多个待提取的目标数据对应的提取规则,每个提取规则包括:偏移地址、偏移地址的类型、自定义偏移量的类型,例如:数据提取规则包括:提取规则1、提取规则2、提取规则3,本实施例中,提取规则1包括:偏移地址1、偏移地址1的类型为相对偏移地址(即启动自定义偏移功能)、自定义偏移量的类型为L2_OFFSET;提取规则2包括:偏移地址2、偏移地址1的类型为绝对偏移地址(即不启动自定义偏移功能)、自定义偏移量的类型为L3_OFFSET_V4;提取规则3包括:偏移地址3、偏移地址3的类型为相对偏移地址(即启动自定义偏移功能)、自定义偏移量的类型为L4_OFFSET。In the embodiment of the present application, the data extraction rules include one or more extraction rules corresponding to the target data to be extracted, and each extraction rule includes: an offset address, an offset address type, and a custom offset type, for example: Data extraction rules include: extraction rule 1, extraction rule 2, extraction rule 3, in this embodiment, extraction rule 1 includes: offset address 1, the type of offset address 1 is a relative offset address (that is, start a custom offset Function), the type of the custom offset is L2_OFFSET; extraction rule 2 includes: offset address 2, the type of offset address 1 is the absolute offset address (that is, the custom offset function is not activated), the custom offset The type is L3_OFFSET_V4; the extraction rule 3 includes: offset address 3, the type of offset address 3 is the relative offset address (that is, the custom offset function is activated), and the type of the custom offset is L4_OFFSET.
可见,每个自定义偏移功能对应一个开关,用来控制是否启该用自定义偏移功能,以便一个规则能够更好地适配多种情况。It can be seen that each custom offset function corresponds to a switch to control whether to enable the custom offset function so that a rule can better adapt to multiple situations.
步骤203:基于所述数据提取规则以及所述各自定义偏移量对应的自定义偏移地址,从所述报文中提取出目标数据。Step 203: Extract target data from the packet based on the data extraction rule and the custom offset address corresponding to the respective defined offset.
本步骤具体包括:This step specifically includes:
1)基于所述数据提取规则,确定待提取的目标数据对应的偏移地址,本步骤中,所述待提取的目标数据的个数为一个或多个;1) Determine the offset address corresponding to the target data to be extracted based on the data extraction rule. In this step, the number of the target data to be extracted is one or more;
2)如果所述待提取的目标数据对应的偏移地址为相对偏移地址,则确定所述相对偏移地址对应的自定义偏移量;2) If the offset address corresponding to the target data to be extracted is a relative offset address, determine a custom offset corresponding to the relative offset address;
3)判断所述相对偏移地址对应的自定义偏移量,是否为所述报文对应的自定义偏移量;3) Determine whether the custom offset corresponding to the relative offset address is the custom offset corresponding to the message;
4)如果所述相对偏移地址对应的自定义偏移量为所述报文对应的自定义偏移量,则基于所述自定义偏移量对应的自定义偏移地址以及所述相对偏移地址,计算绝对偏移地址,并基于所述绝对偏移地址从所述报文中提取出目标数据。4) If the custom offset corresponding to the relative offset address is the custom offset corresponding to the message, based on the custom offset address corresponding to the custom offset and the relative offset Shift the address, calculate an absolute offset address, and extract target data from the message based on the absolute offset address.
对于上述4),如果所述相对偏移地址对应的自定义偏移量,不是所述报文对应的自定义偏移量,则确定所述数据提取规则为无效规则。For the above 4), if the custom offset corresponding to the relative offset address is not the custom offset corresponding to the message, it is determined that the data extraction rule is an invalid rule.
对于上述2),如果所述待提取的目标数据对应的偏移地址为绝对偏移地址,则基于所述绝对偏移地址从所述报文中提取出目标数据。For the above 2), if the offset address corresponding to the target data to be extracted is an absolute offset address, the target data is extracted from the message based on the absolute offset address.
本申请实施例中,如果在步骤102执行的过程中,不存在与所述端口索引信息相匹配的扩展端口,则基于物理端口对应的数据提取规则(第三规则),从所述报文中提取出目标数据。In the embodiment of the present application, if there is no extended port that matches the port index information during the process performed in step 102, then based on the data extraction rule (third rule) corresponding to the physical port, from the packet Extract the target data.
步骤204:基于所述目标数据,在哈希HASH列表中查找目标条目,例如在哈希HASH列表的每个HASH桶中查找目标条目,并利用所述目标条目对所述报文进行处理。Step 204: Based on the target data, search for a target entry in the hash HASH list, for example, find a target entry in each HASH bucket of the hash HASH list, and use the target entry to process the message.
本步骤具体包括:This step specifically includes:
1)基于所述目标数据,计算HASH地址;1) Based on the target data, calculate the HASH address;
2)基于所述HASH地址,在HASH列表的每个HASH桶中查找与所述HASH地址对应的目标条目;2) Based on the HASH address, search for a target entry corresponding to the HASH address in each HASH bucket of the HASH list;
3)利用所述目标条目对所述报文进行处理。3) Use the target entry to process the message.
对于上述1),将所述目标数据以及所述规则编号作为key值输入HASH函数中,计算HASH地址。在一实施方式中,采用循环冗余校验(CRC,Cyclic Redundancy Check)算法计算HASH地址。For 1) above, enter the target data and the rule number as key values into the HASH function to calculate the HASH address. In one embodiment, a cyclic redundancy check (CRC, Cyclic Redundancy Check) algorithm is used to calculate the HASH address.
对于上述2),基于所述HASH地址以及预配置信息,从所述HASH列表的每个HASH桶中确定出有效的HASH桶,作为需要读取的HASH桶,所述预配置信息记录有每个HASH地址与有效的HASH桶的对应关系;基于所述HASH地址从所述有效的HASH桶中读取有效条目,所述有效的HASH桶的个数为一个或多个;将所述目标数据与读取到的每个有效条目进行比较,确定出与所述目标数据相匹配的有效条目,作为与所述HASH地址对应的目标条目。For the above 2), based on the HASH address and pre-configuration information, a valid HASH bucket is determined from each HASH bucket in the HASH list as the HASH bucket to be read, and each of the pre-configuration information records Correspondence between HASH address and valid HASH bucket; read valid entries from the valid HASH bucket based on the HASH address, the number of valid HASH buckets is one or more; compare the target data with Each valid entry read is compared, and a valid entry matching the target data is determined as a target entry corresponding to the HASH address.
上述方案中,用户在一个HASH桶的一个HASH地址上写入条目时,这个HASH地址对应的这个HASH桶即为有效的HASH桶。例如:用户在HASH桶1的地址1上写入条目后,记录这个信息,表明与地址1对应的HASH桶1是有效的,反之,没有被记录的HASH桶则被视为无效的HASH桶。这样,在读 取HASH桶时,可以只读取有效的HASH桶。In the above solution, when a user writes an entry on a HASH address of a HASH bucket, the HASH bucket corresponding to the HASH address is an effective HASH bucket. For example, after a user writes an entry on address 1 of HASH bucket 1, record this information, indicating that HASH bucket 1 corresponding to address 1 is valid, otherwise, a HASH bucket that is not recorded is regarded as an invalid HASH bucket. In this way, when reading the HASH bucket, only valid HASH buckets can be read.
实际应用中,根据HASH地址执行如下预处理过程:确定需要读取几次DDR中的HASH桶。预处理过程主要基于预配置信息实现,当用户通过软件实现配置操作时,如果配置的是条目(如写入条目),则记录下具体配置的哪个HASH地址的哪个HASH桶,这样,在查找条目的过程中,只要获取到HASH地址,就能够得知需要读取的有效的HASH桶,即确定出需要读几次DDR(一个有效的HASH桶对应读一次DDR),而不是需要每次都读取所有的HASH桶。In actual applications, the following preprocessing process is performed according to the HASH address: it is determined that the HASH bucket in the DDR needs to be read several times. The pre-processing process is mainly based on the pre-configuration information. When the user implements the configuration operation through the software, if the configuration is an entry (such as writing an entry), the specific HASH address and HASH bucket of the specific configuration are recorded. In the process, as long as the HASH address is obtained, you can know the valid HASH bucket that needs to be read, that is, determine how many times you need to read DDR (an effective HASH bucket corresponds to reading DDR once), instead of reading each time Take all the HASH buckets.
本申请实施例中,基于HASH地址在有效的HASH桶中读出有效条目后,将key值与有效条目依次进行比对,如果有条目与key值相匹配,则根据匹配的条目的动作、包修改、入队信息、限速信息等相关结果对报文进行处理。如果不存在与key值相匹配的条目,则对报文进行默认处理。In the embodiment of the present application, after reading valid entries in a valid HASH bucket based on the HASH address, the key value is compared with the valid entries in sequence, and if there is an entry matching the key value, the action and packet of the matching entry Modify, enqueue information, speed limit information and other related results to process the message. If there is no entry matching the key value, the packet is processed by default.
本申请实施例的技术方案,在业务种类复杂、大流量的情况下,大大降低了DDR带宽的占用率,使得ONU的报文处理功能(具体为流分类功能)能够更容易地提升到10G性能;并且,在出现HASH冲突时,通过对条目进行配置,能够更方便地解决HASH冲突。此外,通过软件配置优化了规则总数。The technical solution of the embodiments of the present application greatly reduces the DDR bandwidth occupancy rate in the case of complex service types and large traffic, so that the ONU message processing function (specifically, the flow classification function) can be more easily upgraded to 10G performance ; And, in the event of HASH conflicts, by configuring the entries, the HASH conflicts can be resolved more conveniently. In addition, the total number of rules has been optimized through software configuration.
图4为本申请实施例的扩展端口的获取流程示意图,如图4所示,所述流程包括以下步骤:FIG. 4 is a schematic diagram of an expansion port acquisition process according to an embodiment of the present application. As shown in FIG. 4, the process includes the following steps:
步骤401:对报文进行分析,得到N个自定义偏移量。Step 401: Analyze the message to obtain N custom offsets.
步骤402:判断扩展端口是否与第i个自定义偏移量相匹配,若扩展端口与第i个自定义偏移量相匹配,执行步骤403,若扩展端口与第i个自定义偏移量不匹配,执行步骤404。Step 402: Determine whether the expansion port matches the ith custom offset. If the expansion port matches the ith custom offset, perform step 403. If the expansion port matches the ith custom offset If they do not match, go to step 404.
这里,1≤i≤N。初始时,设置i=1。Here, 1≤i≤N. Initially, set i = 1.
步骤403:判断i是否等于N,若i不等于N,执行i=i+1的赋值操作并执行步骤402,若i等于N,执行步骤405。Step 403: Determine whether i is equal to N. If i is not equal to N, perform the assignment operation of i = i + 1 and perform step 402. If i is equal to N, perform step 405.
步骤404:输出原始物理端口的信息。Step 404: Output the information of the original physical port.
步骤405:输出扩展端口的信息。Step 405: Output the information of the expansion port.
图5为本申请实施例的绝对偏移地址的获取流程示意图,如图5所示,所述流程包括以下步骤:FIG. 5 is a schematic flowchart of obtaining an absolute offset address according to an embodiment of the present application. As shown in FIG. 5, the process includes the following steps:
步骤501:从数据提取规则中获取N个待提取的目标数据对应的提取规则,所述提取规则包括:偏移地址、偏移地址的类型以及自定义偏移量的类型。Step 501: Acquire N extraction rules corresponding to the target data to be extracted from the data extraction rules. The extraction rules include: an offset address, a type of offset address, and a type of a custom offset.
步骤502:针对第i个提取规则,判断偏移地址的类型是否为相对偏移地址,若偏移地址的类型为相对偏移地址,执行步骤503,若偏移地址的类型不为相对偏移地址,执行步骤505。Step 502: For the ith extraction rule, determine whether the type of the offset address is a relative offset address. If the type of the offset address is a relative offset address, perform step 503. If the type of the offset address is not a relative offset Address, go to step 505.
步骤503:判断所述相对偏移地址对应的自定义偏移量,是否为所述报文对应的自定义偏移量,若所述相对偏移地址对应的自定义偏移量为所述报文对应的自定义偏移量,执行步骤504,若所述相对偏移地址对应的自定义偏移量不为所述报文对应的自定义偏移量,执行步骤506。Step 503: Determine whether the custom offset corresponding to the relative offset address is the custom offset corresponding to the message, and if the custom offset corresponding to the relative offset address is the report For the custom offset corresponding to the message, step 504 is executed, and if the custom offset corresponding to the relative offset address is not the custom offset corresponding to the message, step 506 is executed.
步骤504:基于所述自定义偏移量对应的自定义偏移地址以及所述相对偏移地址,计算绝对偏移地址,执行步骤507。Step 504: Calculate the absolute offset address based on the custom offset address corresponding to the custom offset and the relative offset address, and perform step 507.
步骤505:将所述偏移地址作为绝对偏移地址,执行步骤507。Step 505: Use the offset address as an absolute offset address, and perform step 507.
步骤506:确定所述数据提取规则为无效规则,执行步骤507。Step 506: Determine that the data extraction rule is an invalid rule, and perform step 507.
步骤507:针对第i个提取规则的绝对偏移地址处理完成,判断i是否等于N,若i不等于N,执行i=i+1的赋值操作并执行步骤502,若i等于N,执行步骤508。Step 507: the absolute offset address processing for the i-th extraction rule is completed, determine whether i is equal to N, if i is not equal to N, perform the assignment operation of i = i + 1 and perform step 502, if i is equal to N, perform 508.
步骤508:与数据提取规则相关的所有绝对偏移地址处理完成。Step 508: All absolute offset address processing related to the data extraction rule is completed.
以下结合具体应用示例对本申请实施例的技术方案作进一步描述。The technical solutions of the embodiments of the present application will be further described below in conjunction with specific application examples.
应用示例一Application example one
本示例中,针对不同的报文格式(也即协议信息)得到不同的扩展端口,从而将报文分流,降低对DDR的带宽占用。In this example, different expansion ports are obtained for different message formats (that is, protocol information), so as to distribute the message and reduce the bandwidth consumption of DDR.
1)输入第一条报文流,分析为LLC+SNAP格式的dslite报文,对该报文进行解析,得到该报文的如下字段:SIP、DIP、IP Protocol,这些字段统称为三元组。1) Input the first message stream, analyze it into LLC + SNAP format dslite message, and parse the message to get the following fields of the message: SIP, DIP, IP Protocol, these fields are collectively called triple .
输入第二条报文流,分析为ethernetV2格式的ipv4的TCP报文,对该报文进行解析,得到该报文的如下字段:SIP、DIP、IP Protocol、Sport、Dprort,这些字段统称为五元组信息。Enter the second packet stream, analyze it as ipv4 TCP packet in ethernetV2 format, and parse the packet to get the following fields of the packet: SIP, DIP, IP Protocol, Sport, Dprort, these fields are collectively called five Tuple information.
输入第三条报文流,分析为普通LLC报文,对该报文进行解析,得到该报 文的如下字段:DA。Enter the third message stream, analyze it as a normal LLC message, and parse the message to get the following field of the message: DA.
2)基于如图3所示的包格式(对应本申请实施例的预设对应关系),依次确定出与上述三条报文流的每个字段对应的三个扩展端口。2) Based on the packet format shown in FIG. 3 (corresponding to the preset correspondence relationship in the embodiment of the present application), three extension ports corresponding to each field of the above three packet streams are determined in sequence.
扩展端口1:第一条报文流的三个字段分别对应如下自定义偏移量:L2_OFFSET、L3_OFFSET_V4、L3_OFFSET_V6。扩展端口1与这组自定义偏移量匹配。Expansion port 1: The three fields of the first packet flow correspond to the following custom offsets: L2_OFFSET, L3_OFFSET_V4, L3_OFFSET_V6. Expansion port 1 matches this set of custom offsets.
扩展端口2:第二条报文流的五个字段分别对应如下自定义偏移量:L2_OFFSET、L3_OFFSET_V4、L4_OFFSET、L5_OFFSET。扩展端口2与这组自定义偏移量匹配。Expansion port 2: The five fields of the second packet flow correspond to the following custom offsets: L2_OFFSET, L3_OFFSET_V4, L4_OFFSET, L5_OFFSET. Expansion port 2 matches this set of custom offsets.
扩展端口3:第三条报文流的一个字段对应如下自定义偏移量:L2_OFFSET。扩展端口3与这个自定义偏移量匹配。Expansion port 3: One field of the third message flow corresponds to the following custom offset: L2_OFFSET. Expansion port 3 matches this custom offset.
3)在扩展端口1下配置规则1,基于规则1计算绝对偏移地址,并提取数据。3) Configure rule 1 under expansion port 1, calculate the absolute offset address based on rule 1, and extract the data.
在扩展端口2下配置规则2,基于规则2计算绝对偏移地址,并提取数据。Configure rule 2 under expansion port 2, calculate the absolute offset address based on rule 2, and extract the data.
在扩展端口3下配置规则3,基于规则3计算绝对偏移地址,并提取数据。Configure rule 3 under expansion port 3, calculate the absolute offset address based on rule 3, and extract the data.
4)在同一通路同时发送三条报文流,由于扩展端口的存在,每条报文流仅使用一个规则即可实现数据的提取。如果未有扩展端口实现分流,也即一个物理端口下需要配置三个规则,这种情况下,三条报文流中的每条报文流均会使用三个规则来提取数据。每个规则均需要执行一套访问DDR的逻辑(根据数据计算HASH地址,根据HASH地址访问DDR中的每个HASH桶中的条目),因而通过对比可知使用扩展端口对DDR的带宽占用为之前的1/3。4) Three message streams are sent at the same time in the same channel. Due to the existence of the expansion port, only one rule can be used for each message stream to extract data. If there is no expansion port to achieve traffic distribution, that is, three rules need to be configured on a physical port, in this case, each of the three packet flows will use three rules to extract data. Each rule needs to implement a set of logic to access DDR (calculate the HASH address based on the data, and access the entries in each HASH bucket in the DDR according to the HASH address), so by comparison we can see that the bandwidth occupied by the expansion port for DDR is the previous 1/3.
应用示例二:Application example two:
本示例中,通过HASH预处理来降低DDR带宽的占用率。In this example, the occupancy of DDR bandwidth is reduced by HASH preprocessing.
1)针对第一条报文流,计算得到该报文流对应条目的HASH地址为A,将该条目写入DDR中的某个HASH桶中,并记录地址A的HASH桶占用情况。例如:将条目写入DDR中的HASH桶a中,记录如下信息:地址A对应的HASH桶a为有效HASH桶(即HASH桶a被占用)。1) For the first message flow, calculate the HASH address of the corresponding entry of the message flow as A, write the entry into a HASH bucket in DDR, and record the occupancy of the HASH bucket at address A. For example, write an entry to the HASH bucket a in DDR, and record the following information: The HASH bucket a corresponding to the address A is a valid HASH bucket (that is, the HASH bucket a is occupied).
针对第二条报文流,计算得到该报文流对应条目的HASH地址为B,将该 条目写入DDR中的某个HASH桶中,并记录地址B的HASH桶占用情况。例如:将条目写入DDR中的HASH桶b中,记录如下信息:地址B对应的HASH桶b为有效HASH桶(即HASH桶b被占用)。For the second message flow, the HASH address of the corresponding entry of the message flow is calculated as B, and the entry is written into a HASH bucket in DDR, and the occupancy of the HASH bucket at address B is recorded. For example, write an entry to the HASH bucket b in DDR, and record the following information: The HASH bucket b corresponding to the address B is a valid HASH bucket (that is, the HASH bucket b is occupied).
针对第三条报文流,计算得到该报文流对应条目的HASH地址为C,将该条目写入DDR中的某个HASH桶中,并记录地址C的HASH桶占用情况。例如:将条目写入DDR中的HASH桶c中,记录如下信息:地址C对应的HASH桶c为有效HASH桶(即HASH桶c被占用)。For the third message stream, the HASH address of the entry corresponding to the message stream is calculated as C, and the entry is written into a HASH bucket in DDR, and the occupancy of the HASH bucket at address C is recorded. For example, write an entry to the HASH bucket c in DDR, and record the following information: The HASH bucket c corresponding to the address C is a valid HASH bucket (that is, the HASH bucket c is occupied).
2)发送这三条报文流,每条报文流根据与HASH地址相关的HASH桶占用情况,对DDR进行访问。以第一条报文流为例,第一条报文流计算得到的HASH地址为A,根据记录信息确定出与地址A对应有效HASH桶为HASH桶a,那么,就只访问DDR中的HASH桶a即可,无需访问其他的HASH桶,即每条报文流都只访问一次DDR空间。如果未启用HASH预处理,则每条报文流会访问DDR中所有的HASH桶,以DDR中包括4个HASH桶为例,通过对比可知使用HASH预处理对DDR的带宽占用为之前的1/4。2) Send these three message streams, and each message stream accesses the DDR according to the occupancy of the HASH bucket related to the HASH address. Taking the first message flow as an example, the HASH address calculated by the first message flow is A, and the effective HASH bucket corresponding to address A is determined to be HASH bucket a according to the record information. Then, only the HASH in DDR is accessed Bucket a is sufficient, there is no need to access other HASH buckets, that is, each packet stream only accesses the DDR space once. If HASH preprocessing is not enabled, each packet stream will access all the HASH buckets in the DDR. Taking 4 ASH buckets in the DDR as an example, it can be known from the comparison that using HASH preprocessing to occupy the bandwidth of DDR is 1 / previous 4.
应用示例三:Application example three:
本示例中,对规则进行了优化,以及方便用户实现配置操作。In this example, the rules are optimized, and the user is convenient to implement the configuration operation.
1)输入第一条报文流,分析为ethernetV2格式的未标识(UTAG)的802.1X报文,对该报文进行解析,得到该报文的如下字段:type/lenth。1) Enter the first message stream, analyze it into an unidentified (UTAG) 802.1X message in ethernetV2 format, and parse the message to obtain the following field of the message: type / lenth.
输入第二条报文流,分析为ethernetV2格式的单TAG的pppoe报文,对该报文进行解析,得到该报文的如下字段:type/lenth。Enter the second message stream, analyze it as a single TAG pppoe message in the ethernetV2 format, and parse the message to obtain the following field of the message: type / lenth.
输入第三条报文流,分析为ethernetV2格式的双TAG的ipv4报文,对该报文进行解析,得到该报文的如下字段:type/lenth。Enter the third message stream, analyze it as an ipv4 message with dual TAG in ethernetV2 format, and parse the message to get the following field of the message: type / lenth.
2)根据上述的三条报文流,虽然不同报文流中的type/lenth字段的绝对偏移地址不同,但是这三条报文流的自定义偏移量相同,所以可以使用相同的规则。2) According to the above three message streams, although the absolute offset address of the type / lenth field in different message streams is different, the custom offsets of the three message streams are the same, so the same rules can be used.
由于三条报文流可以共用一个规则,因而三条报文流可以共用一个扩展端口,在该扩展端口下配置一个规则,且针对该规则配置的自定义偏移量为L2_OFFSET。如此,软件不用关心是何种类型的报文,只需要考虑所要提取的目标数据在TAG字段之后即可。在一实施方式中,提取的是type/lenth数据, 那么相对偏移地址为0,本示例中,每个偏移地址对应2字节的数据。Since the three packet streams can share a rule, the three packet streams can share an extended port. A rule is configured under the extended port, and the custom offset configured for the rule is L2_OFFSET. In this way, the software does not need to care about what type of message, it only needs to consider that the target data to be extracted is after the TAG field. In an embodiment, the type / lenth data is extracted, then the relative offset address is 0. In this example, each offset address corresponds to 2 bytes of data.
3)同时发送三条业务流,此时三条业务流匹配同一个规则。假如没有使用自定义偏移量的话,那么总共需要为三条业务流配置三个规则,对比之下,使用自定义偏移量节省了2个规则,每个规则均需要执行一套访问DDR的逻辑(根据数据计算HASH地址,根据HASH地址访问DDR中的每个HASH桶中的条目),因而使得DDR带宽的占用是之前的1/3。3) Three service flows are sent at the same time. At this time, the three service flows match the same rule. If you do n’t use a custom offset, you need to configure a total of three rules for three business flows. In contrast, using a custom offset saves 2 rules. Each rule needs to execute a set of logic to access DDR (Calculate the HASH address based on the data, and access the entries in each HASH bucket in the DDR according to the HASH address), thus making the DDR bandwidth occupancy 1/3 of the previous.
本申请实施例中,通过对自定义偏移量的设置,用户可以只关心需要提取的目标数据,目标数据前的数据的长度可以不用关心,这样配置起来也更为方便,维护时对于提取变量也更容易理解。In the embodiment of the present application, by setting the custom offset, the user can only care about the target data that needs to be extracted, and the length of the data before the target data can be ignored. This configuration is also more convenient, and the variable is extracted during maintenance It's also easier to understand.
应用示例四:Application example four:
本示例中,针对HASH冲突的情况进行处理。In this example, the HASH conflict is handled.
在用于进行HASH计算的key值中将规则编号考虑进去。具体地,当前ONU工作时,由于新的业务不断申请,已经配置了5K个条目,当想配置第5K+1个条目时,软件发现该HASH地址的HASH桶(也即条目)已经全部写满,无法将新增报文流对应的条目添加进去。软件基于该报文流对应的扩展端口,重新建立一个新的规则编号,基于该规则编号重新计算HASH地址,将新增条目写入。当软件配置到8K个条目,再次出现HASH冲突无法写入的情况,再建立一个新的规则编号,基于新增规则编号添加该条目。Take into account the rule number in the key value used for HASH calculation. Specifically, when the current ONU is working, 5K entries have been configured due to continuous application for new services. When you want to configure the 5K + 1th entry, the software finds that the HASH bucket (that is, the entry) of the HASH address has been completely filled. , The entry corresponding to the newly added message flow cannot be added. Based on the expansion port corresponding to the packet flow, the software re-establishes a new rule number, recalculates the HASH address based on the rule number, and writes the new entry. When the software is configured to 8K entries, the HASH conflict cannot be written again, and a new rule number is created, and the entry is added based on the new rule number.
图6为本申请实施例的报文处理装置的结构组成示意图一,如图6所示,所述报文处理装置包括:FIG. 6 is a schematic structural diagram 1 of a packet processing apparatus according to an embodiment of the present application. As shown in FIG. 6, the packet processing apparatus includes:
解析单元601,设置为对报文进行解析,基于解析结果按照第一规则确定所述报文对应的扩展端口,所述扩展端口用于对所述报文进行分流;The parsing unit 601 is configured to parse the message, and determine an expansion port corresponding to the message according to the first rule based on the analysis result, and the expansion port is used to distribute the message;
确定单元602,设置为基于所述扩展端口对应的第二规则,确定所述报文对应的目标条目;The determining unit 602 is configured to determine the target entry corresponding to the packet based on the second rule corresponding to the expansion port;
处理单元603,设置为利用所述目标条目对所述报文进行处理。The processing unit 603 is configured to process the message using the target entry.
在一实施方式中,所述解析单元601,是设置为对报文的头部进行解析,得到所述报文的头部所包括的每个字段;基于第一规则,确定所述报文的头部中每个字段分别对应的自定义偏移量,其中,所述第一规则包括自定义偏移量与 字段之间的对应关系;基于所述报文对应的自定义偏移量,确定所述报文对应的扩展端口。In an embodiment, the parsing unit 601 is configured to parse the header of the packet to obtain each field included in the header of the packet; based on the first rule, determine the A custom offset corresponding to each field in the header, wherein the first rule includes a correspondence between the custom offset and the field; based on the custom offset corresponding to the packet, determine The expansion port corresponding to the message.
在一实施方式中,所述解析单元601,还设置为针对所述报文的头部中的每个字段,将所述字段中预设位置处的地址,作为与所述字段对应的自定义偏移量的自定义偏移地址。In an embodiment, the parsing unit 601 is further configured to use an address at a preset position in the field as a custom corresponding to the field for each field in the header of the message Custom offset address for offset.
在一实施方式中,所述确定单元602包括:In an embodiment, the determining unit 602 includes:
提取子单元6021,设置为基于所述扩展端口对应的第二规则,以及每个所述自定义偏移量对应的自定义偏移地址,从所述报文中提取出目标数据,所述第二规则用于提取目标数据;The extraction subunit 6021 is set to extract target data from the packet based on the second rule corresponding to the expansion port and the custom offset address corresponding to each of the custom offsets, and the first Two rules are used to extract target data;
查找子单元6022,设置为基于所述目标数据,在HASH列表中查找目标条目,例如在HASH列表的每个HASH桶中查找目标条目。The search subunit 6022 is set to search for a target entry in the HASH list based on the target data, for example, to search for a target entry in each HASH bucket of the HASH list.
在一实施方式中,所述查找子单元6022,设置为基于所述目标数据,计算HASH地址;基于所述HASH地址以及配置信息,从所述HASH列表的每个HASH桶中确定出有效的HASH桶,作为需要读取的HASH桶,所述配置信息记录有每个HASH地址与有效的HASH桶的对应关系;从所述有效的HASH桶中读取与所述HASH地址对应的有效条目;将所述目标数据与每个有效条目进行比较,确定出与所述目标数据相匹配的有效条目,作为所述目标条目。In one embodiment, the search subunit 6022 is configured to calculate a HASH address based on the target data; based on the HASH address and configuration information, a valid HASH is determined from each HASH bucket in the HASH list Bucket, as a HASH bucket to be read, the configuration information records the correspondence between each HASH address and a valid HASH bucket; read the valid entry corresponding to the HASH address from the valid HASH bucket; The target data is compared with each valid entry, and a valid entry matching the target data is determined as the target entry.
本领域技术人员应当理解,图6所示的报文处理装置中的每个模块的实现功能可参照前述报文处理方法的相关描述而理解。图6所示的报文处理装置中的每个模块的功能可通过运行于处理器上的程序而实现,也可通过具体的逻辑电路而实现。Those skilled in the art should understand that the implementation function of each module in the message processing apparatus shown in FIG. 6 can be understood by referring to the related description of the foregoing message processing method. The function of each module in the message processing apparatus shown in FIG. 6 may be realized by a program running on a processor, or may be realized by a specific logic circuit.
在实际应用中,所述报文处理装置中的每个单元所实现的功能,均可由位于报文处理装置中的中央处理器(CPU,Central Processing Unit)、或微处理器(MPU,Micro Processor Unit)、或数字信号处理器(DSP,Digital Signal Processor)、或现场可编程门阵列(FPGA,Field Programmable Gate Array)等实现。In practical applications, the functions implemented by each unit in the message processing device can be implemented by a central processing unit (CPU, Central Processing Unit) or a microprocessor (MPU, Micro Processor) located in the message processing device Unit), or digital signal processor (DSP, Digital Processor), or field programmable gate array (FPGA, Field Programmable Gate Array) and so on.
图7为本申请实施例的报文处理装置的结构组成示意图二,如图7所示,所述报文处理装置包括:报文分析模块701、规则获取模块702、数据提取模块703、HASH处理模块704、报文处理模块705,端口获取模块706,本实施例中, 图6中的解析单元601对应图7中的报文分析模块601、端口获取模块706和规则获取模块602,图6中的确定单元602对应图7中的数据提取模块703和HASH处理模块704,图6中的处理单元603对应图7中的报文处理模块705。FIG. 7 is a second structural composition diagram of a message processing apparatus according to an embodiment of the present application. As shown in FIG. 7, the message processing apparatus includes: a message analysis module 701, a rule acquisition module 702, a data extraction module 703, and HASH processing Module 704, message processing module 705, port acquisition module 706, in this embodiment, the parsing unit 601 in FIG. 6 corresponds to the message analysis module 601, port acquisition module 706, and rule acquisition module 602 in FIG. 7, in FIG. 6 The determination unit 602 corresponds to the data extraction module 703 and the HASH processing module 704 in FIG. 7, and the processing unit 603 in FIG. 6 corresponds to the message processing module 705 in FIG.
报文分析模块701,设置为对报文进行解析,得到所述报文对应的自定义偏移信息,所述自定义偏移信息包括:所述报文对应的自定义偏移量、各自定义偏移量对应的自定义偏移地址;The message analysis module 701 is configured to parse the message to obtain the custom offset information corresponding to the message. The custom offset information includes: the custom offset corresponding to the message and their respective definitions Custom offset address corresponding to offset;
规则获取模块702,设置为基于所述报文对应的自定义偏移量,确定所述报文对应的数据提取规则;The rule obtaining module 702 is set to determine the data extraction rule corresponding to the message based on the custom offset corresponding to the message;
数据提取模块703,设置为基于所述数据提取规则以及所述各自定义偏移量对应的自定义偏移地址,从所述报文中提取出目标数据;The data extraction module 703 is configured to extract target data from the message based on the data extraction rule and the custom offset address corresponding to the respective defined offset;
HASH处理模块704,设置为基于所述目标数据,在HASH列表中查找目标条目,例如在HASH列表的每个HASH桶中查找目标条目;The HASH processing module 704 is set to search for a target entry in the HASH list based on the target data, for example, to search for a target entry in each HASH bucket of the HASH list;
报文处理模块705,设置为利用所述目标条目对所述报文进行处理。The message processing module 705 is configured to process the message using the target entry.
本申请实施例中,所述装置还包括:端口获取模块706,设置为基于所述报文对应的自定义偏移量,确定所述报文对应的扩展端口;In the embodiment of the present application, the device further includes: a port acquisition module 706, configured to determine an expansion port corresponding to the message based on a custom offset corresponding to the message;
所述规则获取模块702,设置为基于所述扩展端口,确定所述报文对应的数据提取规则。The rule acquisition module 702 is configured to determine the data extraction rule corresponding to the message based on the expansion port.
通过图7可以看到每个模块之间的大致关系如下:报文从报文分析模块输入,分析得到自定义偏移信息(自定义偏移量和各自定义偏移量对应的自定义偏移地址);将获取到的自定义偏移信息送入端口获取模块,得到扩展端口;将扩展端口送入规则获取模块,得到相应的数据提取规则;将数据提取规则以及报文(包头数据)送入数据提取模块,得到需要比较的目标数据;将目标数据送入HASH计算模块进行HASH运算,得到HASH地址;将HASH地址送入HASH查找模块,用HASH地址索引出对应的有效条目,将目标数据与有效条目进行匹配,确定出相匹配的有效条目;将相匹配的有效条目送入报文处理模块对报文进行处理。这里,HASH计算模块和HASH查找模块统称为HASH处理模块。It can be seen from Figure 7 that the general relationship between each module is as follows: the message is input from the message analysis module, and the custom offset information (the custom offset and the custom offset corresponding to the respective defined offsets) is analyzed and obtained Address); send the obtained custom offset information to the port acquisition module to obtain the extended port; send the extended port to the rule acquisition module to obtain the corresponding data extraction rule; send the data extraction rule and the message (packet header data) Enter the data extraction module to get the target data to be compared; send the target data to the HASH calculation module for HASH operation to obtain the HASH address; send the HASH address to the HASH search module, use the HASH address to index out the corresponding valid entries, and then target the data Match the valid entries to determine the matching valid entries; send the matching valid entries to the message processing module to process the message. Here, the HASH calculation module and the HASH search module are collectively referred to as the HASH processing module.
在一实施方式中,所述报文分析模块701,包括:In one embodiment, the message analysis module 701 includes:
解析子模块7011,设置为对报文的头部进行解析,得到所述报文的头部所包括的每个字段;The parsing submodule 7011 is configured to parse the header of the message to obtain each field included in the header of the message;
确定子模块7012,设置为基于预设对应关系,确定所述报文的头部中每个字段分别对应的自定义偏移量作为所述报文对应的自定义偏移量,其中,所述预设对应关系为自定义偏移量与字段之间的对应关系;针对所述报文的头部中的每个字段,将所述字段中预设位置处的地址,作为与所述字段对应的自定义偏移量的自定义偏移地址。The determination submodule 7012 is set to determine a custom offset corresponding to each field in the header of the packet as a custom offset corresponding to the packet based on a preset correspondence relationship, wherein, the The preset correspondence is the correspondence between the custom offset and the field; for each field in the header of the packet, the address at the preset position in the field is taken as corresponding to the field The custom offset address of the custom offset.
在一实施方式中,所述端口获取模块706,设置为基于所述报文对应的自定义偏移量以及所述预设对应关系中所包括的自定义偏移量,生成端口索引信息;基于所述端口索引信息,确定所述报文对应的扩展端口。In an embodiment, the port acquisition module 706 is configured to generate port index information based on the custom offset corresponding to the message and the custom offset included in the preset correspondence relationship; based on The port index information determines the expansion port corresponding to the message.
在一实施方式中,所述装置还包括:In an embodiment, the device further includes:
预定义模块707,设置为生成所述预设对应关系,针对所述预设对应关系中的每个字段,将所述字段的头部或尾部对应的地址作为与所述字段对应的自定义偏移量的自定义偏移地址。The predefined module 707 is set to generate the preset correspondence, and for each field in the preset correspondence, the address corresponding to the head or tail of the field is used as the custom bias corresponding to the field Custom offset address of the shift amount.
在一实施方式中,所述规则获取模块702,设置为基于所述扩展端口,确定规则编号;根据所述规则编号,获取数据提取规则,所述数据提取规则包括一个或多个待提取的目标数据对应的提取规则,所述提取规则包括:偏移地址、偏移地址的类型以及自定义偏移量的类型,所述偏移地址的类型用于表示所述偏移地址为相对偏移地址或是绝对偏移地址。In an embodiment, the rule acquisition module 702 is configured to determine a rule number based on the expansion port; according to the rule number, obtain a data extraction rule, the data extraction rule includes one or more targets to be extracted The extraction rule corresponding to the data. The extraction rule includes: an offset address, an offset address type, and a custom offset type. The offset address type is used to indicate that the offset address is a relative offset address Or an absolute offset address.
在一实施方式中,所述数据提取模块703,包括:In an embodiment, the data extraction module 703 includes:
第一确定子模块7031,设置为基于所述数据提取规则,确定待提取的目标数据对应的偏移地址,所述待提取的目标数据的个数为一个或多个;The first determining submodule 7031 is configured to determine the offset address corresponding to the target data to be extracted based on the data extraction rule, and the number of the target data to be extracted is one or more;
第二确定子模块7032,设置为如果所述待提取的目标数据对应的偏移地址为相对偏移地址,则确定所述相对偏移地址对应的自定义偏移量;The second determination submodule 7032 is set to determine a custom offset corresponding to the relative offset address if the offset address corresponding to the target data to be extracted is a relative offset address;
判断子模块7033,设置为判断所述相对偏移地址对应的自定义偏移量,是否为所述报文对应的自定义偏移量;The judgment sub-module 7033 is set to judge whether the custom offset corresponding to the relative offset address is the custom offset corresponding to the message;
计算子模块7034,设置为如果所述相对偏移地址对应的自定义偏移量为所述报文对应的自定义偏移量,则基于所述自定义偏移量对应的自定义偏移地址 以及所述相对偏移地址,计算绝对偏移地址;The calculation submodule 7034 is set to be based on the custom offset address corresponding to the custom offset if the custom offset corresponding to the relative offset address is the custom offset corresponding to the message And the relative offset address to calculate the absolute offset address;
提取子模块7035,设置为基于所述绝对偏移地址从所述报文中提取出目标数据。The extraction submodule 7035 is configured to extract target data from the message based on the absolute offset address.
在一实施方式中,所述数据提取模块703,还包括:第三确定子模块7036,设置为如果所述相对偏移地址对应的自定义偏移量,不是所述报文对应的自定义偏移量,则确定所述数据提取规则为无效规则。In an embodiment, the data extraction module 703 further includes: a third determination submodule 7036, which is set to if the custom offset corresponding to the relative offset address is not the custom offset corresponding to the message If the shift amount is determined, the data extraction rule is determined to be an invalid rule.
在一实施方式中,所述提取子模块7035,还设置为如果所述待提取的目标数据对应的偏移地址为绝对偏移地址,则基于所述绝对偏移地址从所述报文中提取出目标数据。In one embodiment, the extraction submodule 7035 is further configured to extract from the message based on the absolute offset address if the offset address corresponding to the target data to be extracted is an absolute offset address The target data.
在一实施方式中,所述数据提取模块703,还设置为如果不存在与所述端口索引信息相匹配的扩展端口,则基于物理端口对应的数据提取规则,从所述报文中提取出目标数据。In one embodiment, the data extraction module 703 is further configured to extract the target from the packet based on the data extraction rule corresponding to the physical port if there is no expansion port matching the port index information data.
在一实施方式中,所述HASH处理模块704,设置为基于所述目标数据,计算HASH地址;基于所述HASH地址,在HASH列表中查找与所述HASH地址对应的目标条目,例如在HASH列表的每个HASH桶中查找与所述HASH地址对应的目标条目。In one embodiment, the HASH processing module 704 is configured to calculate a HASH address based on the target data; based on the HASH address, search for a target entry corresponding to the HASH address in the HASH list, for example, in the HASH list In each HASH bucket, search for the target entry corresponding to the HASH address.
在一实施方式中,所述HASH处理模块704,设置为将所述目标数据以及所述规则编号作为key值输入HASH函数中,计算HASH地址。In one embodiment, the HASH processing module 704 is configured to input the target data and the rule number as key values into a HASH function to calculate a HASH address.
在一实施方式中,所述HASH处理模块704,设置为基于所述HASH地址以及预配置信息,从所述HASH列表的每个HASH桶中确定出有效的HASH桶,作为需要读取的HASH桶,所述预配置信息记录有每个HASH地址与有效的HASH桶的对应关系,所述有效的HASH桶是指:当在第一HASH桶的第一HASH地址内存储条目时,所述第一HASH桶为所述第一HASH地址的有效的HASH桶;基于所述HASH地址从所述有效的HASH桶中读取有效条目,所述有效的HASH桶的个数为一个或多个;将所述目标数据与读取到的每个有效条目进行比较,确定出与所述目标数据相匹配的有效条目,作为与所述HASH地址对应的目标条目。In one embodiment, the HASH processing module 704 is configured to determine a valid HASH bucket from each HASH bucket in the HASH list as the HASH bucket to be read based on the HASH address and pre-configuration information , The pre-configuration information records the correspondence between each HASH address and an effective HASH bucket. The effective HASH bucket refers to: when an entry is stored in the first HASH address of the first HASH bucket, the first The HASH bucket is an effective HASH bucket of the first HASH address; based on the HASH address, valid entries are read from the effective HASH bucket, and the number of the effective HASH buckets is one or more; The target data is compared with each valid entry read, and a valid entry matching the target data is determined as a target entry corresponding to the HASH address.
本领域技术人员应当理解,图7所示的报文处理装置中的每个模块的实现功能可参照前述报文处理方法的相关描述而理解。图7所示的报文处理装置中 的每个模块的功能可通过运行于处理器上的程序而实现,也可通过具体的逻辑电路而实现。Those skilled in the art should understand that the implementation function of each module in the message processing apparatus shown in FIG. 7 can be understood by referring to the related description of the foregoing message processing method. The function of each module in the message processing device shown in FIG. 7 can be realized by a program running on a processor, or by a specific logic circuit.
在实际应用中,所述报文处理装置中的每个单元所实现的功能,均可由位于报文处理装置中的CPU、或MPU、或DSP、或FPGA等实现。In practical applications, the functions implemented by each unit in the message processing device can be implemented by a CPU, MPU, DSP, or FPGA located in the message processing device.
本申请实施例的报文处理装置,(1)对报文进行分析后得到自定义偏移量,并以此为基础获取扩展端口,将不同的报文根据不同的需求细分到不同的扩展端口下。基于扩展端口获取规则,比现有的基于物理端口获取规则数量上会少很多;每个报文需要处理的规则数减少,这样需要进行HASH运算的情况也变少了,需要查找的HASH条目也减少了,那么也就是访问DDR的次数减少,降低了对DDR带宽的占用。(2)在HASH条目查找前进行预处理,增加一个配置记录信息,从而避免查找时对无效条目的访问,如果没有这个预处理,那么有几个HASH桶,硬件就会访问几次DDR空间,而存在这个预处理,只是访问有效条目,只要HASH桶没有占满,那访问DDR的次数也会更少,即降低了对DDR带宽的占用。(3)引入自定义偏移量以及相对偏移量,可以方便地将需要提取的目标数据进行归类,比起现有的绝对偏移量的提取方式,可以节省更多的规则,节省规则一方面可以优化资源,更重要的是在查找时可以少查找一些规则,可以降低对DDR带宽的占用。(4)实际使用中,为了确认匹配数据的唯一性,需要加上规则编号,当发生HASH冲突时,由于是基于扩展端口获取规则,每个扩展端口下可以使用多个规则,那么可以在该扩展端口下再配置一个规则,基于新的规则把之前由于HASH冲突无法配置的条目配置进去,在同样资源的情况下提高了HASH桶的利用率,为HASH冲突提供了很好的解决方案。The packet processing device of the embodiment of the present application, (1) analyzes the packet to obtain a custom offset, and uses this as a basis to obtain an expansion port, and subdivide different packets into different expansions according to different needs Under the port. The acquisition rules based on the extended port are much less than the existing acquisition rules based on the physical port; the number of rules to be processed per message is reduced, so that the number of HASH operations required is reduced, and the HASH entries that need to be found Reduced, that is, the number of times to access DDR is reduced, reducing the occupation of DDR bandwidth. (2) Perform preprocessing before HASH entry search, add a configuration record information, so as to avoid access to invalid entries during the search, if there is no preprocessing, then there are several HASH buckets, the hardware will access the DDR space several times, And this pre-processing exists, only to access valid entries, as long as the HASH bucket is not full, then the number of times to access DDR will be less, that is, the occupation of DDR bandwidth is reduced. (3) Introduce custom offset and relative offset, you can easily classify the target data that needs to be extracted, compared with the existing absolute offset extraction method, you can save more rules and save rules On the one hand, resources can be optimized, and more importantly, fewer rules can be searched during the search, which can reduce the occupation of DDR bandwidth. (4) In actual use, in order to confirm the uniqueness of the matching data, the rule number needs to be added. When the HASH conflict occurs, because the rules are obtained based on the expansion port, multiple rules can be used under each expansion port, then you can use the Configure another rule under the expansion port. Based on the new rule, configure the items that could not be configured due to HASH conflicts before, increase the utilization of HASH buckets under the same resources, and provide a good solution for HASH conflicts.
本申请实施例还提供了一种光网络终端,包括存储器和处理器,所述存储器上存储有计算机可执行指令,所述计算机可执行指令被所述处理器执行时实现如下步骤:An embodiment of the present application also provides an optical network terminal, including a memory and a processor, and the memory stores computer-executable instructions, and the computer-executable instructions implement the following steps when executed by the processor:
对报文进行解析,基于解析结果按照第一规则确定所述报文对应的扩展端口,所述扩展端口用于对所述报文进行分流;Parse the message, and determine the expansion port corresponding to the message according to the first rule based on the analysis result, and the expansion port is used to distribute the message;
基于所述扩展端口对应的第二规则,确定所述报文对应的目标条目;Determine the target entry corresponding to the message based on the second rule corresponding to the expansion port;
利用所述目标条目对所述报文进行处理。Use the target entry to process the message.
在一实施方式中,所述计算机可执行指令被所述处理器执行时还实现如下步骤:In one embodiment, when the computer-executable instructions are executed by the processor, the following steps are further implemented:
对报文的头部进行解析,得到所述报文的头部所包括的每个字段;Parse the header of the message to obtain each field included in the header of the message;
基于第一规则,确定所述报文的头部中每个字段分别对应的自定义偏移量作为所述报文对应的自定义偏移量,所述第一规则包括自定义偏移量与字段之间的对应关系;Based on the first rule, determine the custom offset corresponding to each field in the header of the packet as the custom offset corresponding to the packet. The first rule includes the custom offset and Correspondence between fields;
基于所述报文对应的自定义偏移量,确定所述报文对应的扩展端口。The expansion port corresponding to the message is determined based on the custom offset corresponding to the message.
在一实施方式中,所述计算机可执行指令被所述处理器执行时还实现如下步骤:In one embodiment, when the computer-executable instructions are executed by the processor, the following steps are further implemented:
针对所述报文的头部中的每个字段,将所述字段中预设位置处的地址,作为与所述字段对应的自定义偏移量的自定义偏移地址。For each field in the header of the message, the address at the preset position in the field is used as the custom offset address of the custom offset corresponding to the field.
在一实施方式中,所述计算机可执行指令被所述处理器执行时还实现如下步骤:In one embodiment, when the computer-executable instructions are executed by the processor, the following steps are further implemented:
基于所述扩展端口对应的第二规则,以及所述各自定义偏移量对应的自定义偏移地址,从所述报文中提取出目标数据,所述第二规则用于提取目标数据;Extract target data from the packet based on the second rule corresponding to the expansion port and the custom offset address corresponding to the respective defined offset, and the second rule is used to extract target data;
基于所述目标数据,在HASH列表中查找目标条目,例如在HASH列表的每个HASH桶中查找目标条目。Based on the target data, the target entry is searched in the HASH list, for example, in each HASH bucket of the HASH list.
在一实施方式中,所述第二规则包括一个或多个待提取的目标数据对应的提取规则,所述提取规则包括:偏移地址、偏移地址的类型以及自定义偏移量的类型,所述偏移地址的类型用于表示所述偏移地址为相对偏移地址或是绝对偏移地址;In an embodiment, the second rule includes one or more extraction rules corresponding to the target data to be extracted, the extraction rule includes: an offset address, a type of offset address, and a type of a custom offset, The type of the offset address is used to indicate whether the offset address is a relative offset address or an absolute offset address;
所述计算机可执行指令被所述处理器执行时还实现如下步骤:When the computer-executable instructions are executed by the processor, the following steps are also implemented:
基于所述扩展端口对应的第二规则,确定待提取的目标数据对应的偏移地址;Determine the offset address corresponding to the target data to be extracted based on the second rule corresponding to the expansion port;
如果所述待提取的目标数据对应的偏移地址为相对偏移地址,则确定所述相对偏移地址对应的自定义偏移量;If the offset address corresponding to the target data to be extracted is a relative offset address, determine a custom offset corresponding to the relative offset address;
判断所述相对偏移地址对应的自定义偏移量,是否为所述报文对应的自定义偏移量;Determine whether the custom offset corresponding to the relative offset address is a custom offset corresponding to the message;
如果所述相对偏移地址对应的自定义偏移量为所述报文对应的自定义偏移量,则基于所述自定义偏移量对应的自定义偏移地址以及所述相对偏移地址,计算绝对偏移地址,并基于所述绝对偏移地址从所述报文中提取出目标数据。If the custom offset corresponding to the relative offset address is the custom offset corresponding to the message, based on the custom offset address corresponding to the custom offset and the relative offset address , Calculate an absolute offset address, and extract target data from the message based on the absolute offset address.
在一实施方式中,所述计算机可执行指令被所述处理器执行时还实现如下步骤:In one embodiment, when the computer-executable instructions are executed by the processor, the following steps are further implemented:
如果所述待提取的目标数据对应的偏移地址为绝对偏移地址,则基于所述绝对偏移地址从所述报文中提取出目标数据。If the offset address corresponding to the target data to be extracted is an absolute offset address, the target data is extracted from the message based on the absolute offset address.
在一实施方式中,所述计算机可执行指令被所述处理器执行时还实现如下步骤:In one embodiment, when the computer-executable instructions are executed by the processor, the following steps are further implemented:
基于所述目标数据,计算HASH地址;Based on the target data, calculate the HASH address;
基于所述HASH地址以及配置信息,从所述HASH列表的每个HASH桶中确定出有效的HASH桶,作为需要读取的HASH桶,所述配置信息记录有每个HASH地址与有效的HASH桶的对应关系,所述有效的HASH桶是指:当在第一HASH桶的第一HASH地址内存储条目时,所述第一HASH桶为所述第一HASH地址的有效的HASH桶;Based on the HASH address and configuration information, a valid HASH bucket is determined from each HASH bucket in the HASH list as the HASH bucket to be read, and the configuration information records each HASH address and valid HASH bucket The corresponding HASH bucket refers to: when an entry is stored in the first HASH address of the first HASH bucket, the first HASH bucket is an effective HASH bucket of the first HASH address;
从所述有效的HASH桶中读取与所述HASH地址对应的有效条目;Reading valid entries corresponding to the HASH address from the valid HASH bucket;
将所述目标数据与每个有效条目进行比较,确定出与所述目标数据相匹配的有效条目,作为所述目标条目。The target data is compared with each valid entry, and a valid entry matching the target data is determined as the target entry.
本领域内的技术人员应明白,本申请的实施例可提供为方法、***、或计算机程序产品。因此,本申请可采用硬件实施例、软件实施例、或结合软件和硬件方面的实施例的形式。而且,本申请可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器和光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may take the form of a hardware embodiment, a software embodiment, or an embodiment combining software and hardware. Moreover, the present application may take the form of a computer program product implemented on one or more computer usable storage media (including but not limited to disk storage and optical storage, etc.) containing computer usable program code.
本申请是参照根据本申请实施例的方法、设备(***)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个 流程和/或方框图一个方框或多个方框中指定的功能的装置。This application is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the application. It should be understood that each flow and / or block in the flowchart and / or block diagram and a combination of the flow and / or block in the flowchart and / or block diagram may be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, special-purpose computer, embedded processing machine, or other programmable data processing device to produce a machine that enables the generation of instructions executed by the processor of the computer or other programmable data processing device An apparatus for realizing the functions specified in one block or multiple blocks of one flow or multiple flows of a flowchart and / or one block or multiple blocks of a block diagram.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。These computer program instructions may also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, the instructions The device implements the functions specified in one block or multiple blocks of the flowchart one flow or multiple flows and / or block diagrams.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operating steps are performed on the computer or other programmable device to produce computer-implemented processing, which is executed on the computer or other programmable device The instructions provide steps for implementing the functions specified in one block or multiple blocks of the flowchart one flow or multiple flows and / or block diagrams.
相应地,本申请实施例还提供一种存储介质,所述存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现上述的报文处理方法。Correspondingly, the embodiments of the present application also provide a storage medium on which a computer program is stored, and when the computer program is executed by the processor, the above message processing method is implemented.

Claims (16)

  1. 一种报文处理方法,包括:A message processing method, including:
    对报文进行解析,基于解析结果按照第一规则确定所述报文对应的扩展端口,所述扩展端口用于对所述报文进行分流;Parse the message, and determine the expansion port corresponding to the message according to the first rule based on the analysis result, and the expansion port is used to distribute the message;
    基于所述扩展端口对应的第二规则,确定所述报文对应的目标条目;Determine the target entry corresponding to the message based on the second rule corresponding to the expansion port;
    利用所述目标条目对所述报文进行处理。Use the target entry to process the message.
  2. 根据权利要求1所述的方法,其中,所述对报文进行解析,基于解析结果按照第一规则确定所述报文对应的扩展端口,包括:The method according to claim 1, wherein the parsing the packet and determining the expansion port corresponding to the packet based on the parsing result according to the first rule includes:
    对所述报文的头部进行解析,得到所述报文的头部所包括的每个字段;Parse the header of the message to obtain each field included in the header of the message;
    基于所述第一规则,确定所述报文的头部中每个字段分别对应的自定义偏移量作为所述报文对应的自定义偏移量,其中,所述第一规则包括自定义偏移量与字段之间的对应关系;Based on the first rule, determine a custom offset corresponding to each field in the header of the packet as a custom offset corresponding to the packet, wherein the first rule includes a custom offset Correspondence between offset and field;
    基于所述报文对应的自定义偏移量,确定所述报文对应的扩展端口。The expansion port corresponding to the message is determined based on the custom offset corresponding to the message.
  3. 根据权利要求2所述的方法,其中,所述基于所述报文对应的自定义偏移量,确定所述报文对应的扩展端口,包括:The method according to claim 2, wherein the determining the expansion port corresponding to the message based on the custom offset corresponding to the message comprises:
    基于所述报文对应的自定义偏移量,生成端口索引信息;Generate port index information based on the custom offset corresponding to the message;
    基于所述端口索引信息匹配出所述报文对应的扩展端口。The expansion port corresponding to the packet is matched based on the port index information.
  4. 根据权利要求3所述的方法,还包括:The method of claim 3, further comprising:
    如果不存在与所述端口索引信息相匹配的扩展端口,则基于物理端口对应的第三规则,确定所述报文对应的目标条目;其中,所述物理端口对应的第三规则的数目大于所述扩展端口对应的第二规则的数目。If there is no expansion port matching the port index information, the target entry corresponding to the packet is determined based on the third rule corresponding to the physical port; where the number of third rules corresponding to the physical port is greater than The number of second rules corresponding to the expansion port is described.
  5. 根据权利要求2所述的方法,还包括:The method of claim 2, further comprising:
    针对所述报文的头部中的每个字段,将所述字段中预设位置处的地址,作为与所述字段对应的自定义偏移量的自定义偏移地址。For each field in the header of the message, the address at the preset position in the field is used as the custom offset address of the custom offset corresponding to the field.
  6. 根据权利要求5所述的方法,其中,所述基于所述扩展端口对应的第二规则,确定所述报文对应的目标条目,包括:The method according to claim 5, wherein the determining the target entry corresponding to the packet based on the second rule corresponding to the expansion port includes:
    基于所述扩展端口对应的第二规则,以及每个所述自定义偏移量对应的自定义偏移地址,从所述报文中提取出目标数据,所述第二规则用于提取目标数 据;Extract target data from the packet based on the second rule corresponding to the expansion port and the custom offset address corresponding to each of the custom offsets, and the second rule is used to extract target data ;
    基于所述目标数据,在哈希HASH列表中查找目标条目。Based on the target data, the target entry is searched in the hash HASH list.
  7. 根据权利要求6所述的方法,其中,所述第二规则包括一个或多个待提取的目标数据对应的提取规则,所述提取规则包括:偏移地址、偏移地址的类型以及自定义偏移量的类型,其中,所述偏移地址的类型用于表示所述偏移地址为相对偏移地址或是绝对偏移地址;The method according to claim 6, wherein the second rule includes one or more extraction rules corresponding to the target data to be extracted, and the extraction rules include: an offset address, a type of offset address, and a custom offset Type of shift, wherein the type of the offset address is used to indicate whether the offset address is a relative offset address or an absolute offset address;
    所述基于所述扩展端口对应的第二规则,以及每个所述自定义偏移量对应的自定义偏移地址,从所述报文中提取出目标数据,包括:The extracting target data from the packet based on the second rule corresponding to the expansion port and the custom offset address corresponding to each of the custom offsets includes:
    基于所述扩展端口对应的第二规则,确定待提取的目标数据对应的偏移地址;Determine the offset address corresponding to the target data to be extracted based on the second rule corresponding to the expansion port;
    如果所述待提取的目标数据对应的偏移地址为相对偏移地址,则确定所述相对偏移地址对应的自定义偏移量;If the offset address corresponding to the target data to be extracted is a relative offset address, determine a custom offset corresponding to the relative offset address;
    判断所述相对偏移地址对应的自定义偏移量,是否为所述报文对应的自定义偏移量;Determine whether the custom offset corresponding to the relative offset address is a custom offset corresponding to the message;
    如果所述相对偏移地址对应的自定义偏移量为所述报文对应的自定义偏移量,则基于所述自定义偏移量对应的自定义偏移地址以及所述相对偏移地址,计算绝对偏移地址,并基于所述绝对偏移地址从所述报文中提取出目标数据。If the custom offset corresponding to the relative offset address is the custom offset corresponding to the message, based on the custom offset address corresponding to the custom offset and the relative offset address , Calculate an absolute offset address, and extract target data from the message based on the absolute offset address.
  8. 根据权利要求7所述的方法,还包括:The method of claim 7, further comprising:
    如果所述待提取的目标数据对应的偏移地址为绝对偏移地址,则基于所述绝对偏移地址从所述报文中提取出目标数据。If the offset address corresponding to the target data to be extracted is an absolute offset address, the target data is extracted from the message based on the absolute offset address.
  9. 根据权利要求6至8任一项所述的方法,其中,所述基于所述目标数据,在哈希HASH列表中查找目标条目,包括:The method according to any one of claims 6 to 8, wherein the searching for a target entry in a hash HASH list based on the target data includes:
    基于所述目标数据,计算HASH地址;Based on the target data, calculate the HASH address;
    基于所述HASH地址以及配置信息,从所述HASH列表的每个HASH桶中确定出有效的HASH桶,作为需要读取的HASH桶,其中,所述配置信息记录有HASH地址与有效的HASH桶的对应关系;Based on the HASH address and configuration information, an effective HASH bucket is determined from each HASH bucket in the HASH list as a HASH bucket to be read, wherein the configuration information records a HASH address and an effective HASH bucket Corresponding relationship;
    从所述有效的HASH桶中读取与所述HASH地址对应的有效条目;Reading valid entries corresponding to the HASH address from the valid HASH bucket;
    将所述目标数据与每个有效条目进行比较,确定出与所述目标数据相匹配的有效条目,作为所述目标条目。The target data is compared with each valid entry, and a valid entry matching the target data is determined as the target entry.
  10. 一种报文处理装置,包括:A message processing device, including:
    解析单元,设置为对报文进行解析,基于解析结果按照第一规则确定所述报文对应的扩展端口,所述扩展端口用于对所述报文进行分流;The parsing unit is configured to parse the message, and determine the expansion port corresponding to the message according to the first rule based on the analysis result, and the expansion port is used to offload the message;
    确定单元,设置为基于所述扩展端口对应的第二规则,确定所述报文对应的目标条目;A determining unit, configured to determine the target entry corresponding to the packet based on the second rule corresponding to the expansion port;
    处理单元,设置为利用所述目标条目对所述报文进行处理。The processing unit is configured to process the message using the target entry.
  11. 根据权利要求10所述的装置,其中,所述解析单元,是设置为对报文的头部进行解析,得到所述报文的头部所包括的每个字段;基于第一规则,确定所述报文的头部中每个字段分别对应的自定义偏移量作为所述报文对应的自定义偏移量,所述第一规则包括自定义偏移量与字段之间的对应关系;基于所述报文对应的自定义偏移量,确定所述报文对应的扩展端口。The apparatus according to claim 10, wherein the parsing unit is configured to parse the header of the packet to obtain each field included in the header of the packet; based on the first rule, determine the A custom offset corresponding to each field in the header of the message is used as a custom offset corresponding to the message, and the first rule includes a correspondence between the custom offset and the field; The expansion port corresponding to the message is determined based on the custom offset corresponding to the message.
  12. 根据权利要求11所述的装置,其中,所述解析单元,还设置为针对所述报文的头部中的每个字段,将所述字段中预设位置处的地址,作为与所述字段对应的自定义偏移量的自定义偏移地址。The apparatus according to claim 11, wherein the parsing unit is further configured to use an address at a preset position in the field as the field for each field in the header of the message The custom offset address of the corresponding custom offset.
  13. 根据权利要求12所述的装置,其中,所述确定单元包括:The apparatus according to claim 12, wherein the determination unit comprises:
    提取子单元,设置为基于所述扩展端口对应的第二规则,以及所述各自定义偏移量对应的自定义偏移地址,从所述报文中提取出目标数据,所述第二规则用于提取目标数据;The extraction subunit is set to extract target data from the packet based on the second rule corresponding to the expansion port and the custom offset address corresponding to the respective defined offset, the second rule is used To extract target data;
    查找子单元,设置为基于所述目标数据,在HASH列表中查找目标条目。The search subunit is set to search for a target entry in the HASH list based on the target data.
  14. 根据权利要求13所述的装置,其中,所述查找子单元,是设置为基于所述目标数据,计算HASH地址;基于所述HASH地址以及配置信息,从所述HASH列表的每个HASH桶中确定出有效的HASH桶,作为需要读取的HASH桶,所述配置信息记录有每个HASH地址与有效的HASH桶的对应关系;从所述有效的HASH桶中读取与所述HASH地址对应的有效条目;将所述目标数据与每个有效条目进行比较,确定出与所述目标数据相匹配的有效条目,作为所述目标条目。The apparatus according to claim 13, wherein the search subunit is configured to calculate a HASH address based on the target data; based on the HASH address and configuration information, from each HASH bucket in the HASH list A valid HASH bucket is determined as a HASH bucket to be read, and the configuration information records the correspondence between each HASH address and a valid HASH bucket; reading from the valid HASH bucket corresponds to the HASH address Valid entries of; compare the target data with each valid entry to determine valid entries that match the target data as the target entries.
  15. 一种存储介质,存储有计算机程序,所述计算机程序被处理器执行时实现权利要求1至9任一项所述的报文处理方法。A storage medium storing a computer program, which when executed by a processor implements the message processing method according to any one of claims 1 to 9.
  16. 一种光网络终端,包括存储器和处理器,所述存储器上存储有计算机可执行指令,所述计算机可执行指令被所述处理器执行时实现权利要求1至9任一项所述的报文处理方法。An optical network terminal includes a memory and a processor, and a computer-executable instruction is stored on the memory, and when the computer-executable instruction is executed by the processor, the message according to any one of claims 1 to 9 is realized Approach.
PCT/CN2019/098130 2018-11-09 2019-07-29 Message processing method and device, storage medium and optical network terminal WO2020093737A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201811333746.9A CN111181857B (en) 2018-11-09 2018-11-09 Message processing method and device, storage medium and optical network terminal
CN201811333746.9 2018-11-09

Publications (1)

Publication Number Publication Date
WO2020093737A1 true WO2020093737A1 (en) 2020-05-14

Family

ID=70612288

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/098130 WO2020093737A1 (en) 2018-11-09 2019-07-29 Message processing method and device, storage medium and optical network terminal

Country Status (2)

Country Link
CN (1) CN111181857B (en)
WO (1) WO2020093737A1 (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113489593A (en) * 2021-06-30 2021-10-08 深圳前海微众银行股份有限公司 JSON message checking method and JSON message checking device
CN113595931A (en) * 2021-07-08 2021-11-02 杭州海康威视数字技术股份有限公司 Message processing method, device, equipment and storage medium
CN114244916A (en) * 2021-11-19 2022-03-25 国网经济技术研究院有限公司 Port identification method of intelligent electronic equipment, electronic equipment and storage medium

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112491828B (en) * 2020-11-13 2023-03-24 北京金山云网络技术有限公司 Message analysis method, device, server and storage medium
CN112822722B (en) * 2020-12-30 2022-09-23 联想未来通信科技(重庆)有限公司 Data message transmission method and device
CN116600031B (en) * 2023-07-18 2023-10-31 无锡沐创集成电路设计有限公司 Message processing method, device, equipment and storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2010130210A1 (en) * 2009-05-15 2010-11-18 华为技术有限公司 Method, apparatus and system for message transmission in passive optical network
CN102388566A (en) * 2011-09-26 2012-03-21 华为技术有限公司 Method, device and system for converting identifier of terminal device
CN105634985A (en) * 2016-01-21 2016-06-01 烽火通信科技股份有限公司 Processing method of FTTdp (Fiber to the Distribution Point) multi DSL (Digital Subscriber Line) port ONU (Optical Network Unit) service flow
CN106357534A (en) * 2016-08-25 2017-01-25 江苏省未来网络创新研究院 Network flow monitoring system and method based on SDN

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102025593B (en) * 2009-09-21 2013-04-24 ***通信集团公司 Distributed user access system and method
US8625594B2 (en) * 2009-11-02 2014-01-07 Marvell World Trade Ltd. Switching apparatus and method based on virtual interfaces
CN101789904A (en) * 2010-02-04 2010-07-28 杭州华三通信技术有限公司 Method and equipment for controlling flow
CN102143074B (en) * 2011-03-25 2015-09-16 中兴通讯股份有限公司 The sharing method of network load, system and network processing unit
CN107666627A (en) * 2016-07-28 2018-02-06 上海诺基亚贝尔股份有限公司 Data forwarding controlling method and its device in a kind of PON

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2010130210A1 (en) * 2009-05-15 2010-11-18 华为技术有限公司 Method, apparatus and system for message transmission in passive optical network
CN102388566A (en) * 2011-09-26 2012-03-21 华为技术有限公司 Method, device and system for converting identifier of terminal device
CN105634985A (en) * 2016-01-21 2016-06-01 烽火通信科技股份有限公司 Processing method of FTTdp (Fiber to the Distribution Point) multi DSL (Digital Subscriber Line) port ONU (Optical Network Unit) service flow
CN106357534A (en) * 2016-08-25 2017-01-25 江苏省未来网络创新研究院 Network flow monitoring system and method based on SDN

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113489593A (en) * 2021-06-30 2021-10-08 深圳前海微众银行股份有限公司 JSON message checking method and JSON message checking device
CN113489593B (en) * 2021-06-30 2022-11-08 深圳前海微众银行股份有限公司 JSON message checking method and JSON message checking device
CN113595931A (en) * 2021-07-08 2021-11-02 杭州海康威视数字技术股份有限公司 Message processing method, device, equipment and storage medium
CN113595931B (en) * 2021-07-08 2024-01-16 杭州海康威视数字技术股份有限公司 Message processing method, device, equipment and storage medium
CN114244916A (en) * 2021-11-19 2022-03-25 国网经济技术研究院有限公司 Port identification method of intelligent electronic equipment, electronic equipment and storage medium
CN114244916B (en) * 2021-11-19 2022-11-18 国网经济技术研究院有限公司 Port identification method of intelligent electronic equipment, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN111181857B (en) 2020-12-29
CN111181857A (en) 2020-05-19

Similar Documents

Publication Publication Date Title
WO2020093737A1 (en) Message processing method and device, storage medium and optical network terminal
US10735221B2 (en) Flexible processor of a port extender device
US10404605B2 (en) Packet processing method, device and computer storage medium
US9444915B2 (en) Method and device for modifying and forwarding message in data communication network
US9276853B2 (en) Hashing of network packet flows for efficient searching
CN101442489A (en) Method for recognizing flux based on characteristic library
WO2021104393A1 (en) Method for achieving multi-rule flow classification, device, and storage medium
CN112953949B (en) Message header processing method, device, equipment and storage medium of network message
CN109547288B (en) Programmable flow measuring method for protocol independent forwarding network
WO2024067336A1 (en) Packet processing method, programmable network card device, physical server, and storage medium
US20220070091A1 (en) Open fronthaul network system
KR20220159456A (en) Service processing methods, devices, facilities and storage media
WO2022222750A1 (en) Packet forwarding method and apparatus, network device, and storage medium
CN115174676A (en) Convergence and shunt method and related equipment thereof
US20110249676A1 (en) Method and System for Forwarding and Switching Traffic in a Network Element
US20160248652A1 (en) System and method for classifying and managing applications over compressed or encrypted traffic
WO2017219904A1 (en) Data processing method and device
US20230254246A1 (en) Mechanisms for packet path tracing and per-hop delay measurement in segment routing with multiprotocol label switching (sr-mpls) networks
JP2016523062A (en) Method and apparatus for generating input parameters
CN105721627B (en) A kind of online de-identification method of IP network flow data
US20240056393A1 (en) Packet forwarding method and device, and computer readable storage medium
JP7289303B2 (en) Network communication method and apparatus
CN116319535A (en) Path switching method, path switching device, network equipment and network system
US11882039B1 (en) UDF-based traffic offloading methods and systems
WO2023088226A1 (en) Packet forwarding method and related 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: 19882591

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: 19882591

Country of ref document: EP

Kind code of ref document: A1