WO2023125116A1 - 报文的处理方法、装置、存储介质和电子装置 - Google Patents

报文的处理方法、装置、存储介质和电子装置 Download PDF

Info

Publication number
WO2023125116A1
WO2023125116A1 PCT/CN2022/140096 CN2022140096W WO2023125116A1 WO 2023125116 A1 WO2023125116 A1 WO 2023125116A1 CN 2022140096 W CN2022140096 W CN 2022140096W WO 2023125116 A1 WO2023125116 A1 WO 2023125116A1
Authority
WO
WIPO (PCT)
Prior art keywords
message
field
target
fields
checksum
Prior art date
Application number
PCT/CN2022/140096
Other languages
English (en)
French (fr)
Inventor
蒋震
崔兴龙
方沛昱
Original Assignee
苏州盛科通信股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 苏州盛科通信股份有限公司 filed Critical 苏州盛科通信股份有限公司
Publication of WO2023125116A1 publication Critical patent/WO2023125116A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/24Traffic characterised by specific attributes, e.g. priority or QoS
    • H04L47/2425Traffic characterised by specific attributes, e.g. priority or QoS for supporting services specification, e.g. SLA
    • H04L47/2433Allocation of priorities to traffic types
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L47/00Traffic control in data switching networks
    • H04L47/10Flow control; Congestion control
    • H04L47/24Traffic characterised by specific attributes, e.g. priority or QoS
    • H04L47/2425Traffic characterised by specific attributes, e.g. priority or QoS for supporting services specification, e.g. SLA
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/565Conversion or adaptation of application format or content

Definitions

  • Embodiments of the present invention relate to the field of message processing, and in particular, relate to a message processing method, device, storage medium, and electronic device.
  • the traditional checksum calculation is processed based on the editing method of specification fields, such as the change of TTL (Time To Live, time-to-live) of IP (Internet Protocol, Internet Protocol) packets, DSCP (Differential atend Services Code Point, Differentiated Services Code Point) field changes, etc. Therefore, when updating the Checksum (checksum), the incremental calculation method is used. For example, the original checksum in the message is incrementally calculated by considering the original TTL and the changed TTL value to obtain a new checksum; then the incremental calculation is performed considering the original DSCP value and the changed DSCP value, Get the final checksum; fill the final checksum into the message.
  • This calculation method needs to edit and divide each field of the message in advance, and set a named field, so complex pre-operations are required.
  • Embodiments of the present invention provide a message processing method, device, storage medium and electronic device, so as to at least solve the problem of low message verification and calculation efficiency in the related art.
  • a method for processing a message including: obtaining a target message whose checksum is to be calculated in a message processing device; The field bit width and field priority of each message field in the message field determine the processing sequence of the multiple message fields, wherein the processing sequence is used to indicate that each message in the multiple message fields
  • the processing opportunity of the field in the message checksum determination process, the priority of the field is the priority between the message fields of the same field bit width; according to the processing sequence, according to the priority of each message field
  • the field bit width and the field position of each message field in the target message are processed to obtain the target checksum corresponding to the target message, wherein the The target checksum is used to instruct the packet processing device to perform a packet processing operation corresponding to the target checksum on the target packet.
  • the determining the processing order of the multiple message fields according to the field information field bit width and field priority of each of the multiple message fields included in the target message includes: : Determining the message fields corresponding to the bit width of the first numerical value among the plurality of message fields as the first field set, and determining the corresponding field bit width of the second numerical value among the plurality of message fields
  • the message field is determined as the second field set, wherein the field bit width of the message field is divided into the first value and the second value;
  • the processing sequence is determined as first according to the first field set includes Process the first message field in the first field set according to the field priority corresponding to the first message field in the first field set, and then according to the field priority corresponding to the second message field included in the second field set
  • a stage processes the second message fields in the second set of fields.
  • Determining the message field of the second numerical value as the second field set includes: determining that the first numerical value is 8bit, and that the second numerical value is 4bit; setting the bit width of the corresponding field in the plurality of message fields to 8bit
  • the message fields of the plurality of message fields are determined as the first field set, and the corresponding message fields with a field bit width of 4 bits among the plurality of message fields are determined as the second field set.
  • the multiple The message field is processed to obtain the target checksum corresponding to the target message, including: traversing each message field according to the processing order as the target message field; storing the target message field in multiple On the target collection position of the collector corresponding to the target field bit width and target field position of the target message field in the initial collectors, a plurality of target collectors are obtained, wherein each of the initial collectors is divided into A plurality of collection positions conforming to the field bit width of the message field; performing check value calculation on the message field stored by each target collector in the multiple target collectors to obtain multiple check values; The cumulative sum of check values is determined as the target check sum.
  • the storing the target message field in the target collection position of the collector corresponding to the target field bit width and target field position of the target message field among the multiple initial collectors includes: determining The position of the target field in the target unit scale, wherein the target message is divided into multiple unit scales, and the target unit scale is the target message field in the multiple unit scales The unit scale where it is located; according to the collection order of the multiple initial collectors, obtain from the multiple initial collectors candidate collectors that do not store data at the collection position corresponding to the target scale position, wherein each of the The data collection amount of the initial collector is equal to the data amount of a unit scale; the collection position corresponding to the target scale position in the candidate collector is used as the target collection position to store the target message field.
  • the method further includes: acquiring the checksum calculation granularity corresponding to the message checksum determination process; The verification and calculation granularity is determined as the data volume of a unit scale.
  • the method further includes: when the message processing device is a message sending device In the case of , adding the target checksum to the target message to obtain a message to be sent, wherein the message sending device is used to send the message to be sent; in the message processing When the device is a message receiving device, comparing the target checksum with the reference checksum carried in the target message to obtain a first comparison result, wherein the message receiving device uses performing a message processing operation corresponding to the first comparison result on the target message; when the message processing device is a message conversion device, the target message includes a message before conversion and a message after conversion In the case of , comparing the target checksum corresponding to the pre-conversion message with the target checksum corresponding to the converted message to obtain a second comparison result, wherein the report The text converting device is configured to determine that the target checksum corresponding to the pre-converted message matches the target checksum corresponding to the converted message when the second comparison result
  • a message processing device including: a first acquisition module configured to acquire a target message to be calculated in a message processing device; a first determination module is set to determine the processing order of the multiple message fields according to the field bit width and field priority of each of the multiple message fields included in the target message, wherein the processing The sequence is used to indicate the processing timing of each of the message fields in the message checksum determination process, and the field priority is the priority between message fields with the same field bit width.
  • the processing module is configured to, according to the processing sequence, according to the field bit width of each message field and the field position of each message field in the target message, to the Process multiple message fields to obtain a target checksum corresponding to the target message, where the target checksum is used to instruct the message processing device to perform the target checksum on the target message and the corresponding message processing operations.
  • a computer-readable storage medium is also provided, and a computer program is stored in the computer-readable storage medium, wherein the computer program is configured to perform any one of the above methods when running Steps in the examples.
  • an electronic device including a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to run the computer program to perform any of the above Steps in the method examples.
  • the target message to be calculated in the message processing device by obtaining the target message to be calculated in the message processing device; according to the field bit width and field priority of each message field in the multiple message fields included in the target message, Determine the processing order of multiple message fields, where the processing order is used to indicate the processing timing of each message field in the message checksum determination process in the multiple message fields, and the field priority is the same field bit width
  • the priority among the message fields according to the processing sequence, according to the field bit width of each message field and the field position of each message field in the target message, multiple message fields are processed to obtain the target message
  • the target checksum corresponding to the message where the target checksum is used to instruct the message processing device to perform the message processing operation corresponding to the target checksum on the target message, that is, according to the field bit width and field priority of the message Calculate the checksum of the message according to the level and field position of the message, determine the processing order of multiple message fields in the target message according to the field bit width and field priority of the message, and then know the processing timing of each field
  • Fig. 1 is the block diagram of mobile terminal hardware structure of the processing method of the message of the embodiment of the present invention
  • FIG. 2 is a flowchart of a message processing method according to an embodiment of the present invention.
  • Fig. 3 is a schematic diagram of a selected message calibration according to an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of optional message editing information according to an embodiment of the present invention.
  • Fig. 5 is a schematic diagram of an optional message field writing collector according to an embodiment of the present invention.
  • Fig. 6 is an optional checksum calculation flow chart according to an embodiment of the present invention.
  • Fig. 7 is a structural block diagram of a message processing device according to an embodiment of the present invention.
  • FIG. 1 is a block diagram of a hardware structure of a mobile terminal according to a message processing method according to an embodiment of the present invention.
  • the mobile terminal may include one or more (only one is shown in Figure 1) processors 102 (the processor 102 may include but not limited to a microprocessor MCU (Microcontroller Unit, micro control unit) or programmable A processing device such as a logic device FPGA (Field Programmable Gate Array, editable logic array) and a memory 104 for storing data, wherein the above-mentioned mobile terminal may also include a transmission device 106 and an input and output device 108 for communication functions.
  • a microprocessor MCU Microcontroller Unit, micro control unit
  • FPGA Field Programmable Gate Array, editable logic array
  • FIG. 1 is only for illustration, and it does not limit the structure of the above mobile terminal.
  • the mobile terminal may also include more or fewer components than those shown in FIG. 1 , or have a different configuration from that shown in FIG. 1 .
  • the memory 104 can be set to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the message processing method in the embodiment of the present invention, and the processor 102 runs the computer program stored in the memory 104 , so as to perform various functional applications and data processing, that is, to realize the above-mentioned method.
  • the memory 104 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.
  • the memory 104 may further include a memory that is remotely located relative to the processor 102, and these remote memories may be connected to the mobile terminal through a network. Examples of the aforementioned networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
  • the transmission device 106 is arranged to receive or transmit data via a network.
  • the aforementioned network example may include a wireless network provided by a mobile terminal's communication provider.
  • the transmission device 106 includes a Network Interface Controller (NIC for short), which can be connected to other network devices through a base station so as to communicate with the Internet.
  • the transmission device 106 may be a radio frequency (Radio Frequency, referred to as RF) module, which is configured to communicate with the Internet in a wireless manner.
  • RF Radio Frequency
  • FIG. 2 is a flowchart of a method for processing a message according to an embodiment of the present invention. As shown in FIG. 2 , the process includes the following steps:
  • Step S202 obtaining the target message in the message processing device for which the checksum is to be calculated
  • Step S204 according to the field bit width and field priority of each of the multiple message fields included in the target message, determine the processing sequence of the multiple message fields, wherein the processing sequence It is used to indicate the processing timing of each of the message fields in the message checksum determination process, and the field priority is the priority between message fields with the same field bit width ;
  • Step S206 according to the processing sequence, according to the field bit width of each message field and the field position of each message field in the target message, the multiple message fields performing processing to obtain a target checksum corresponding to the target message, where the target checksum is used to instruct the message processing device to perform the target checksum corresponding to the target message Text processing operations.
  • the packet processing device may include, but is not limited to, routers, switches, servers, and the like.
  • the format of the target message of this solution is not limited.
  • the target message can include but is not limited to a message in IPv4 (Internet Protocol Version 4, Internet Protocol Version 4) format, IPv6 ( Internet Protocol Version 6, Internet Protocol Version 6) formatted message.
  • the priority of the fields may be determined according to the order of the fields in the message, or according to the order of editing when the message is edited, or according to The bit width of the field is determined, which is not limited in this solution.
  • the processing sequence may be the processing sequence of each field classification after field classification is performed on multiple fields, and the field classification may be based on the field bit width, or according to the Characters are classified, this scheme does not limit it.
  • the processing of multiple message fields may, but is not limited to, include sorting fields in multiple message fields, grouping fields, and comparing fields in the order of sorting to checksum calculation In-store editing, checksum calculations, etc.
  • the message processing operations may include, but are not limited to, operations such as message editing and message forwarding.
  • the multiple message fields are determined according to the field information field bit width and field priority of each message field in the multiple message fields included in the target message processing sequence, including:
  • the text field is determined as a second field set, wherein the field bit width of the message field is divided into the first value and the second value;
  • Determining the processing sequence is to first process the first message field in the first field set according to the field priority corresponding to the first message field included in the first field set, and then process the first message field in the first field set according to the priority of the first message field included in the first field set.
  • the fields corresponding to the second message fields included in the two field sets process the second message fields in the second field set with priority.
  • the first numerical value may be set to 4, 6, 8 and so on.
  • the second value may be set to 4, 8, 12, 16 and so on.
  • processing the first message field in the first field set and processing the second message field in the combination of the second field are used to determine the first message field and the second message field in
  • the calculation timing when performing the calculation can be by storing the first message field and the second message in the target register.
  • the target register includes multiple register units, and the bit width and checksum calculation of each register unit The calculation granularity is equal, by storing the first message field and the second message field in the register successively, so that the calculation unit obtained by combining the first message field and the second message field can satisfy the calculation of the checksum granularity.
  • the message fields whose corresponding field bit width is the first value among the plurality of message fields are determined as the first field set, and the The message field whose corresponding field bit width is the second value is determined as the second field set, including:
  • the corresponding field bit width in the plurality of message fields is determined as the first field set, and the corresponding field bit width in the plurality of message fields is determined as the message field of 4bit as The second set of fields.
  • the first value and the second value may also be set to other values, such as 12bit, 16bit and so on.
  • Processing the multiple message fields to obtain a target checksum corresponding to the target message including:
  • a cumulative sum of the plurality of check values is determined as the target check sum.
  • the field bit width that the initial collector can store matches the calculation granularity when the checksum is calculated.
  • the initial collector The maximum bit width of the field that can be stored can be set to 8, 16, etc.
  • the target message field is stored in the target collection position of the corresponding collector according to the field bit width and the target field position, so as to ensure the calculation sequence between the message fields during checksum calculation , to avoid the impact on the consistency of the message field checksum due to different calculation sequences, and improve the reliability and consistency of the calculated checksum.
  • the storing the target message field in the target collection position of the collector corresponding to the target field bit width and target field position of the target message field among the multiple initial collectors on including:
  • the target unit scale is the position of the target message field in the multiple unit scales
  • the unit scale where is located in;
  • the collection order of the plurality of initial collectors obtain from the plurality of initial collectors candidate collectors that do not store data at the collection position corresponding to the target scale position, wherein the data of each of the initial collectors
  • the amount of collection is equal to the amount of data of one unit scale
  • the data volume of a unit scale matches the calculation granularity of the checksum.
  • the data volume of a unit scale can be set to be equal to or a multiple of the calculation granularity. No limit.
  • Fig. 3 is a schematic diagram of a selected message calibration according to an embodiment of the present invention. As shown in Fig. 3, it may include, but is not limited to, the following content: the data volume of a unit scale is 16 bits, and the unit scale is used to convert the data in the message The edit position is calibrated. In Figure 3, multiple unit scales are used to calibrate a message. Each unit scale can be divided into four 4bit edit positions and two 8bit edit positions, so as to calibrate each The relative position of the bit-width field in the message.
  • Fig. 4 is a schematic diagram of optional message editing information according to an embodiment of the present invention.
  • the message includes 4-bit editing information (that is, the message field) and 5 groups of 8-bit editing information (that is, the message field), sort the editing information according to the importance or sequence of each editing information when editing the message, so as to determine the
  • the order in which each message field is stored in the collector shows the relative position of each field in the message marked by the scale shown in Figure 3, and the order in which each message field is edited into the memory Sequence, as shown in the figure, g4[0] is the first to be edited into the collector in the 4bit editing information, g4[0] is in the second position of the 4bit relative position, and g8[0] is in the 8bit editing information It is the first one to be edited into the collector, and g8[0] is at the 8th position of the 8bit relative position.
  • Fig. 5 is a schematic diagram of an optional message field writing collector according to an embodiment of the present invention, which is applied to the embodiments of Fig. 3 and Fig. 4. As shown in Fig. 5, it may include but not limited to the following steps, the report
  • the text includes 5 groups of 4bit message fields (4bit editing information) and 5 groups of 8bit message fields (8bit editing information).
  • each 8-bit message field is sequentially edited into the mobile device according to its relative position in the unit scale in the message, as shown in Figure 4 and Figure 5, g8[0] is located on the unit scale Therefore, g8[0] is stored in the 8-bit edit position 2 of collector 0, and g8[1] is also located in the last 8-bit edit position of the unit scale, so the sequence is from small to large according to the serial number of the collector Find the free area of the last 8bit editing position in the collector, so edit g8[1] to the 8bit editing position 2 of collector 1, similarly, after editing other 8bit messages into the collector, edit the 4bit message According to the same principle, it is edited in the collector.
  • Fig. 6 is an optional checksum calculation flow chart according to an embodiment of the present invention, which is applied to the embodiments of Fig. 3 to Fig. 5, as shown in Fig. 6, may include, but is not limited to, the following:
  • the message editing and processing information includes 4bit editing and 8bit editing.
  • the 4bit editing can search the editable position according to the 4bit granularity of the message, that is, the editing offset (offset) is 4bit, and the message is set to 16bit Unit scale, find out the relative position of each 4bit field in the message.
  • the 8-bit editor can search for an editable position according to the 8-bit granularity of the message, that is, the editing offset (offset) is 8 bits, and find out the relative position of each 8-bit field in the message.
  • S603 write the edited message field into the corresponding position of the 16bit collector according to the relative position of the scale in the message according to the way of putting the 8bit field first, and then put it into the 4bit message field, and then edit , edit in sequence according to the order of the collectors, that is, if collector 0 is used up, put it into collector 1 until all mobile devices are full.
  • the unit scale provides a basis for placing each message field in the message in the corresponding storage location of the mobile phone, thereby ensuring the calculation order of the message fields when performing multiple checks and calculations on a message No change, improving checksum consistency.
  • the method before the determining that the target field position is at the target scale position in the target unit scale, the method further includes:
  • the checksum calculation granularity is determined as the data volume of a unit scale.
  • the checksum calculation granularity may be, but not limited to, set to 16 bits, 32 bits, etc., which is not limited in this solution.
  • the method further includes:
  • the target checksum is added to the target message to obtain a message to be sent, wherein the message sending device is used to send the State the message to be sent;
  • the message processing device is a message receiving device, comparing the target checksum with the reference checksum carried in the target message to obtain a first comparison result, wherein the The message receiving device is configured to perform a message processing operation corresponding to the first comparison result on the target message;
  • the message processing device is a message conversion device
  • the target message includes a message before conversion and a message after conversion
  • the message converting device is configured to indicate that the pre-converted message corresponds to the If the target checksum matches the target checksum corresponding to the converted message, it is determined that the message is converted successfully.
  • the matching of the target checksum corresponding to the pre-transformed message and the target checksum corresponding to the converted message may be, but not limited to, include the target checksum corresponding to the pre-converted message and the converted The target checksums corresponding to the subsequent packets are equal, which is not limited in this solution.
  • FIG. 7 is a structural block diagram of a device for processing a message according to an embodiment of the present invention. As shown in FIG. 7 , the device includes:
  • the first obtaining module 72 is configured to obtain the target message to be calculated in the message processing device
  • the first determining module 74 is configured to determine the processing order of the multiple message fields according to the field bit width and field priority of each of the multiple message fields included in the target message, wherein, the processing order is used to indicate the processing timing of each of the message fields in the message checksum determination process in the plurality of message fields, and the priority of the fields is the message with the same field bit width Priority between fields;
  • the processing module 76 is configured to, according to the processing sequence, according to the field bit width of each message field and the field position of each message field in the target message, for the multiple message fields to obtain the target checksum corresponding to the target message, wherein the target checksum is used to instruct the message processing device to perform the target checksum on the target message The corresponding message processing operation.
  • the first determining module includes: a first determining unit configured to determine a message field whose corresponding field bit width is a first value among the plurality of message fields as a first field set, and Determining a message field with a corresponding field bit width of a second value among the plurality of message fields as a second field set, wherein the field bit width of a message field is divided into the first value and the second value Two values; the second determining unit is configured to determine the processing sequence as first processing the first field set in the first field set according to the field priority corresponding to the first message field included in the first field set The first message field, and then process the second message field in the second field set according to the field priority corresponding to the second message field included in the second field set.
  • the first determination unit is configured to: determine that the first value is 8bit, and the second value is 4bit;
  • the fields are determined as the first field set, and the corresponding message fields with a field bit width of 4 bits among the plurality of message fields are determined as the second field set.
  • the processing module includes: a processing unit configured to traverse each message field as a target message field according to the processing sequence; a storage unit configured to store the target message field in A plurality of target collectors are obtained at the target collection positions of the collectors corresponding to the target field bit width and target field position of the target message field among the multiple initial collectors, wherein each of the initial collectors is divided into It is a plurality of collection positions conforming to the field bit width of the message field; the calculation unit is set to perform check value calculation on the message field stored by each target collector in the multiple target collectors, and obtain multiple checksums check value; a third determination unit configured to determine the cumulative sum of the multiple check values as the target check sum.
  • the storage unit is configured to: determine the target scale position of the target field position in the target unit scale, wherein the target message is divided into multiple unit scales, and the target unit scale is the The unit scale where the target message field is located in the multiple unit scales; according to the collection sequence of the multiple initial collectors, the collection position corresponding to the target scale position is obtained from the multiple initial collectors.
  • Candidate collectors for storing data wherein the amount of data collected by each of the initial collectors is equal to the amount of data of a unit scale; the collection position corresponding to the position of the target scale in the candidate collectors is used as the target collection The location stores the target message field.
  • the device further includes: a second obtaining module, configured to obtain a message verification and verification corresponding to the determination process before determining that the target field position is at the target scale position in the target unit scale. and calculation granularity; the second determination module is configured to determine the checksum calculation granularity as the data volume of a unit scale.
  • the device further includes: an adding module, configured to process the multiple message fields and obtain the target checksum corresponding to the target message, When the device is a message sending device, adding the target checksum to the target message to obtain a message to be sent, wherein the message sending device is set to send the message to be sent ;
  • the first comparison module is configured to compare the target checksum with the reference checksum carried in the target message when the message processing device is a message receiving device, Obtaining a first comparison result, wherein the message receiving device is configured to perform a message processing operation corresponding to the first comparison result on the target message;
  • the second comparison module is configured to The message processing device is a message conversion device, and when the target message includes a message before conversion and a message after conversion, the target checksum corresponding to the message before conversion is compared with the converted message The target checksum corresponding to the message is compared to obtain a second comparison result, wherein the message conversion device is configured to indicate that the pre-conversion message corresponds to the second comparison result. If the target checksum matches the
  • the above-mentioned modules can be realized by software or hardware. For the latter, it can be realized by the following methods, but not limited to this: the above-mentioned modules are all located in the same processor; or, the above-mentioned modules can be combined in any combination The forms of are located in different processors.
  • Embodiments of the present invention also provide a computer-readable storage medium, in which a computer program is stored, wherein the computer program is set to execute the steps in any one of the above method embodiments when running.
  • the above-mentioned computer-readable storage medium may include but not limited to: U disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM) , mobile hard disk, magnetic disk or optical disk and other media that can store computer programs.
  • ROM read-only memory
  • RAM random access memory
  • mobile hard disk magnetic disk or optical disk and other media that can store computer programs.
  • An embodiment of the present invention also provides an electronic device, including a memory and a processor, where a computer program is stored in the memory, and the processor is configured to run the computer program to perform the steps in any one of the above method embodiments.
  • the electronic device may further include a transmission device and an input and output device, wherein the transmission device is connected to the processor, and the input and output device is connected to the processor.
  • each module or each step of the above-mentioned present invention can be realized by a general-purpose computing device, and they can be concentrated on a single computing device, or distributed in a network formed by multiple computing devices In fact, they can be implemented in program code executable by a computing device, and thus, they can be stored in a storage device to be executed by a computing device, and in some cases, can be performed in an order different from that shown here. Or described steps, or they are made into individual integrated circuit modules, or multiple modules or steps among them are made into a single integrated circuit module to realize. As such, the present invention is not limited to any specific combination of hardware and software.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Communication Control (AREA)
  • Debugging And Monitoring (AREA)

Abstract

本发明实施例提供了一种报文的处理方法、装置、存储介质和电子装置,其中,该方法包括:获取报文处理设备中待计算校验和的目标报文;根据目标报文所包括的多个报文字段中每个报文字段的字段位宽和字段优先级,确定多个报文字段的处理顺序,其中,处理顺序用于指示多个报文字段中每个报文字段在报文校验和确定过程中的处理时机,字段优先级为相同字段位宽的报文字段之间的优先级;按照处理顺序,根据每个报文字段的字段位宽和每个报文字段在目标报文中的字段位置,对多个报文字段进行处理,得到目标报文对应的目标校验和。通过本发明,解决了相关技术中存在的报文校验和计算效率较低的问题,达到了提高报文校验和的计算效率的效果。

Description

报文的处理方法、装置、存储介质和电子装置
本发明要求于2021年12月30日提交中国专利局、申请号为202111663239.3、发明名称“报文的处理方法、装置、存储介质和电子装置”的中国专利申请的优先权,其全部内容通过引用结合在本发明中。
技术领域
本发明实施例涉及报文处理领域,具体而言,涉及一种报文的处理方法、装置、存储介质和电子装置。
背景技术
近年来,随着信息化技术的快速发展,网络上的数据交换量变得越开越大,芯片的处理能力不断上升,从而要求对数据报文的处理变得越来越灵活,在实际应用中,为了报文处理后的报文的一致性,校验和作为检验报文一致性的手段被广泛应用。
传统的校验和计算是基于具名字段(specification fields)的编辑方式进行处理的,比如IP(Internet Protocol,网际互连协议)报文的TTL(Time To Live,生存时间值)变化,DSCP(Differentiatend Services Code Point,差分服务代码点)字段变化等。因此,在进行Checksum(校验和)更新的时候,通过使用增量计算的计算方式。比如,将报文中原始的校验和,考虑原始TTL和变化后的TTL值进行增量计算,得到新的校验和;再考虑原始的DSCP值和变化后的DSCP值进行增量计算,得到最终的校验和;将最终的校验和填入报文。这种计算方法需要预先对报文各个字段进行编辑和划分,设置具名字段,因此需要复杂的前期操作。
针对相关技术中存在的报文校验和计算效率较低的问题,目前尚未提出有效的解决方案。
发明内容
本发明实施例提供了一种报文的处理方法、装置、存储介质和电子装置,以至少解决相关技术中存在的报文校验和计算效率较低的问题。
根据本发明的一个实施例,提供了一种报文的处理方法,包括:获取报文处理设备中待计算校验和的目标报文;根据所述目标报文所包括的多个报文字段中每个报文字段的字段位宽和字段优先级,确定所述多个报文字段的处理顺序,其中,所述处理顺序用于指示所述多个报文字段中所述每个报文字段在报文校验和确定过程中的处理时机,所述字段优先级为相同字段位宽的报文字段之间的优先级;按照所述处理顺序,根据所述每个报文字段的所述字段位宽和所述每个报文字段在所述目标报文中的字段位置,对所述多个报文字段进行处理,得到所述目标报文对应的目标校验和,其中,所述目标校验和用于指示所述报文处理设备对所述目标报文执行所述目标校验和所对应的报文处理操作。
可选的,所述根据所述目标报文所包括的多个报文字段中每个报文字段的字段信息字段位宽和字段优先级,确定所述多个报文字段的处理顺序,包括:将所述多个报文字段中对应的字段位宽为第一数值的报文字段确定为第一字段集合,并将所述多个报文字段中对应的字段位宽为第二数值的报文字段确定为第二字段集合,其中,报文字段的字段位宽被划分为所述第一数值和所述第二数值;确定所述处理顺序为先按照所述第一字段集合中包括的第一报文字段所对应的字段优先级处理所述第一字段集合中的所述第一报文字段,再按照所述第二字段集合中包括的第二报文字段所对应的字段优先级处理所述第二字段集合中的所述第二报文字段。
可选的,所述将所述多个报文字段中对应的字段位宽为第一数值的报文字段确定为第一字段集合,并将所述多个报文字段中对应的字段位宽为第二数值的报文字段确定为第二字段集合,包括:确定所述第一数值为8bit,所述第二数值为4bit;将所述多个报文字段中对应的字段位宽为8bit的报文字段确定为第一字段集合,并将所述多个报文字段中对应的字段位宽为 4bit的报文字段确定为第二字段集合。
可选的,所述按照所述处理顺序,根据所述每个报文字段的所述字段位宽和所述每个报文字段在所述目标报文中的字段位置,对所述多个报文字段进行处理,得到所述目标报文对应的目标校验和,包括:按照所述处理顺序遍历所述每个报文字段作为目标报文字段;将所述目标报文字段存储在多个初始收集器中与所述目标报文字段的目标字段位宽和目标字段位置对应的收集器的目标收集位置上,得到多个目标收集器,其中,每个所述初始收集器被划分为多个符合报文字段的字段位宽的收集位置;对所述多个目标收集器中每个目标收集器存储的报文字段进行校验值计算,得到多个校验值;将所述多个校验值的累加和确定为所述目标校验和。
可选的,所述将所述目标报文字段存储在多个初始收集器中与所述目标报文字段的目标字段位宽和目标字段位置对应的收集器的目标收集位置上,包括:确定所述目标字段位置在目标单位标尺中的目标标尺位置,其中,所述目标报文被划分为多个单位标尺,所述目标单位标尺是所述目标报文字段在所述多个单位标尺中所在的单位标尺;按照所述多个初始收集器的收集顺序,从所述多个初始收集器中获取所述目标标尺位置对应的收集位置未存储数据的候选收集器,其中,每个所述初始收集器的数据收集量与一个单位标尺的数据量相等;将所述候选收集器中所述目标标尺位置对应的收集位置作为所述目标收集位置存储所述目标报文字段。
可选的,在所述确定所述目标字段位置在目标单位标尺中的目标标尺位置之前,所述方法还包括:获取报文校验和确定过程对应的校验和计算粒度;将所述校验和计算粒度确定为一个单位标尺的数据量。
可选的,在所述对所述多个报文字段进行处理,得到所述目标报文对应的目标校验和之后,所述方法还包括:在所述报文处理设备为报文发送设备的情况下,将所述目标校验和添加到所述目标报文中,得到待发送报文,其中,所述报文发送设备用于发送所述待发送报文;在所述报文处理设备为报文接收设备的情况下,将所述目标校验和与所述目标报文中携带 的参考校验和进行比对,得到第一比对结果,其中,所述报文接收设备用于对所述目标报文执行所述第一比对结果对应的报文处理操作;在所述报文处理设备为报文转换设备,所述目标报文包括转换前报文和转换后报文的情况下,将所述转换前报文对应的所述目标校验和与所述转换后报文对应的所述目标校验和进行比对,得到第二比对结果,其中,所述报文转换设备用于在所述第二比对结果指示所述转换前报文对应的所述目标校验和与所述转换后报文对应的所述目标校验和匹配的情况下,确定报文转换成功。
根据本发明的又一个实施例,还提供了一种报文的处理装置,包括:第一获取模块,被设置为获取报文处理设备中待计算校验和的目标报文;第一确定模块,被设置为根据所述目标报文所包括的多个报文字段中每个报文字段的字段位宽和字段优先级,确定所述多个报文字段的处理顺序,其中,所述处理顺序用于指示所述多个报文字段中所述每个报文字段在报文校验和确定过程中的处理时机,所述字段优先级为相同字段位宽的报文字段之间的优先级;处理模块,被设置为按照所述处理顺序,根据所述每个报文字段的所述字段位宽和所述每个报文字段在所述目标报文中的字段位置,对所述多个报文字段进行处理,得到所述目标报文对应的目标校验和,其中,所述目标校验和用于指示所述报文处理设备对所述目标报文执行所述目标校验和所对应的报文处理操作。
根据本发明的又一个实施例,还提供了一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机程序,其中,所述计算机程序被设置为运行时执行上述任一项方法实施例中的步骤。
根据本发明的又一个实施例,还提供了一种电子装置,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器被设置为运行所述计算机程序以执行上述任一项方法实施例中的步骤。
通过本发明实施例,通过获取报文处理设备中待计算校验和的目标报文;根据目标报文所包括的多个报文字段中每个报文字段的字段位宽和字 段优先级,确定多个报文字段的处理顺序,其中,处理顺序用于指示多个报文字段中每个报文字段在报文校验和确定过程中的处理时机,字段优先级为相同字段位宽的报文字段之间的优先级;按照处理顺序,根据每个报文字段的字段位宽和每个报文字段在目标报文中的字段位置,对多个报文字段进行处理,得到目标报文对应的目标校验和,其中,目标校验和用于指示报文处理设备对目标报文执行目标校验和所对应的报文处理操作,即,根据报文的字段位宽、字段优先级和字段位置计算报文的校验和,根据报文的字段位宽和字段优先级确定目标报文中的多个报文字段的处理顺序,进而知道报文中各字段的处理时机,在进行报文的校验和处理时根据报文的字段位宽和字段在报文中的位置对报文的多个字段进行处理,从而实现根据报文的字段位宽对报文的校验和进行计算,而不需要在进行校验和计算时对报文中的字段名称进行复杂的标注工作,简化了操作流程和计算速度,从而在保证校验和计算的准确性的前提下实现校验和的高效快速计算,,因此,解决了相关技术中存在的报文校验和计算效率较低的问题,达到了提高报文校验和的计算效率的效果。
附图说明
图1是本发明实施例的报文的处理方法的移动终端硬件结构框图;
图2是根据本发明实施例的报文的处理方法的流程图;
图3是根据本发明实施例的一种选的报文标定示意图;
图4是根据本发明实施例的一种可选的报文编辑信息示意图;
图5是根据本发明实施例的一种可选的报文字段写入收集器的示意图;
图6是根据本发明实施例的一种可选的校验和计算流程图;
图7是根据本发明实施例的报文的处理装置的结构框图。
具体实施方式
下文中将参考附图并结合实施例来详细说明本发明的实施例。
需要说明的是,本发明的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后顺序。
本申请实施例中所提供的方法实施例可以在移动终端、计算机终端或者类似的运算装置中执行。以运行在移动终端上为例,图1是本发明实施例的报文的处理方法的移动终端硬件结构框图。如图1所示,移动终端可以包括一个或多个(图1中仅示出一个)处理器102(处理器102可以包括但不限于微处理器MCU(Microcontroller Unit,微控制单元)或可编程逻辑器件FPGA(Field Programmable Gate Array,可编辑逻辑阵列)等的处理装置)和用于存储数据的存储器104,其中,上述移动终端还可以包括用于通信功能的传输设备106以及输入输出设备108。本领域普通技术人员可以理解,图1所示的结构仅为示意,其并不对上述移动终端的结构造成限定。例如,移动终端还可包括比图1中所示更多或者更少的组件,或者具有与图1所示不同的配置。
存储器104可被设置为存储计算机程序,例如,应用软件的软件程序以及模块,如本发明实施例中的报文的处理方法对应的计算机程序,处理器102通过运行存储在存储器104内的计算机程序,从而执行各种功能应用以及数据处理,即实现上述的方法。存储器104可包括高速随机存储器,还可包括非易失性存储器,如一个或者多个磁性存储装置、闪存、或者其他非易失性固态存储器。在一些实例中,存储器104可进一步包括相对于处理器102远程设置的存储器,这些远程存储器可以通过网络连接至移动终端。上述网络的实例包括但不限于互联网、企业内部网、局域网、移动通信网及其组合。
传输装置106被设置为经由一个网络接收或者发送数据。上述的网络实例可包括移动终端的通信供应商提供的无线网络。在一个实例中,传输装置106包括一个网络适配器(Network Interface Controller,简称为NIC), 其可通过基站与其他网络设备相连从而可与互联网进行通讯。在一个实例中,传输装置106可以为射频(Radio Frequency,简称为RF)模块,其被设置为通过无线方式与互联网进行通讯。
在本实施例中提供了一种报文的处理方法,图2是根据本发明实施例的报文的处理方法的流程图,如图2所示,该流程包括如下步骤:
步骤S202,获取报文处理设备中待计算校验和的目标报文;
步骤S204,根据所述目标报文所包括的多个报文字段中每个报文字段的字段位宽和字段优先级,确定所述多个报文字段的处理顺序,其中,所述处理顺序用于指示所述多个报文字段中所述每个报文字段在报文校验和确定过程中的处理时机,所述字段优先级为相同字段位宽的报文字段之间的优先级;
步骤S206,按照所述处理顺序,根据所述每个报文字段的所述字段位宽和所述每个报文字段在所述目标报文中的字段位置,对所述多个报文字段进行处理,得到所述目标报文对应的目标校验和,其中,所述目标校验和用于指示所述报文处理设备对所述目标报文执行所述目标校验和所对应的报文处理操作。
通过上述步骤,根据报文的字段位宽、字段优先级和字段位置计算报文的校验和,根据报文的字段位宽和字段优先级确定目标报文中的多个报文字段的处理顺序,进而知道报文中各字段的处理时机,在进行报文的校验和处理时根据报文的字段位宽和字段在报文中的位置对报文的多个字段进行处理,从而实现根据报文的字段位宽对报文的校验和进行计算,而不需要在进行校验和计算时对报文中的字段名称进行复杂的标注工作,简化了操作流程和计算速度,从而在保证校验和计算的准确性的前提下实现校验和的高效快速计算,因此,解决了相关技术中存在的报文校验和计算效率较低的问题,达到了提高报文校验和的计算效率的效果。
在上述步骤S202提供的技术方案中,报文处理设备可以但不限于包 括路由器、交换机、服务器等等。
可选地,在本实施例中,本方案目标报文的格式不做限定,比如目标报文可以但不限于包括IPv4(Internet Protocol Version 4,互联网协议第四版)格式的报文、IPv6(Internet Protocol Version 6,互联网协议第六版)格式的报文。
在上述步骤S204提供的技术方案中,字段的优先级可以是根据字段在报文中的先后顺序确定的,还可以是根据在进行报文编辑时编辑的先后顺序确定的,或者还可以是根据字段的位宽确定的,本方案对此不做限定。
可选地,在本实施例中,处理顺序可以是多个字段进行字段分类后的每个字段分类的处理顺序,字段分类可以是根据字段位宽进行分类的,还可以是根据字段中包括的字符进行分类的,本方案对此不做限定。
在上述步骤S206提供的技术方案中,对多个报文字段进行的处理可但不限于包括对多个报文字段中的字段进行字段排序、字段分组、将字段按照排序顺序相校验和计算存储区域内编辑、校验和计算等等。
可选地,在本实施例中,报文处理操作可但不限于包括报文编辑、报文转发等操作。
作为一种可选的实施例,所述根据所述目标报文所包括的多个报文字段中每个报文字段的字段信息字段位宽和字段优先级,确定所述多个报文字段的处理顺序,包括:
将所述多个报文字段中对应的字段位宽为第一数值的报文字段确定为第一字段集合,并将所述多个报文字段中对应的字段位宽为第二数值的报文字段确定为第二字段集合,其中,报文字段的字段位宽被划分为所述第一数值和所述第二数值;
确定所述处理顺序为先按照所述第一字段集合中包括的第一报文字段所对应的字段优先级处理所述第一字段集合中的所述第一报文字段,再 按照所述第二字段集合中包括的第二报文字段所对应的字段优先级处理所述第二字段集合中的所述第二报文字段。
可选地,在本实施例中,第一数值可以被设置为4、6、8等等。
可选地,在本实施例中,第二数值可以被设置为4、8、12、16等等。
可选地,在本实施例中,处理第一字段集合中的第一报文字段和处理第二字段结合中的第二报文字段用于确定第一报文字段和第二报文字段在进行计算时的计算时机,可以是通过将第一报文字段和第二报文存储在目标寄存器内的方式,目标寄存器内包括多个寄存单元,每个寄存单元的位宽与校验和计算的计算粒度相等,通过将第一报文字段和第二报文字段先后存储在寄存器内,从而使得第一报文字段和第二报文字段组合得到的计算单元能够满足计算校验和的计算粒度。
作为一种可选的实施例,所述将所述多个报文字段中对应的字段位宽为第一数值的报文字段确定为第一字段集合,并将所述多个报文字段中对应的字段位宽为第二数值的报文字段确定为第二字段集合,包括:
确定所述第一数值为8bit,所述第二数值为4bit;
将所述多个报文字段中对应的字段位宽为8bit的报文字段确定为第一字段集合,并将所述多个报文字段中对应的字段位宽为4bit的报文字段确定为第二字段集合。
可选地,在本实施例中,第一数值和第二数值还可以被设置为其他数值,比如12bit、16bit等等。
作为一种可选的实施例,所述按照所述处理顺序,根据所述每个报文字段的所述字段位宽和所述每个报文字段在所述目标报文中的字段位置,对所述多个报文字段进行处理,得到所述目标报文对应的目标校验和,包括:
按照所述处理顺序遍历所述每个报文字段作为目标报文字段;
将所述目标报文字段存储在多个初始收集器中与所述目标报文字段的目标字段位宽和目标字段位置对应的收集器的目标收集位置上,得到多个目标收集器,其中,每个所述初始收集器被划分为多个符合报文字段的字段位宽的收集位置;
对所述多个目标收集器中每个目标收集器存储的报文字段进行校验值计算,得到多个校验值;
将所述多个校验值的累加和确定为所述目标校验和。
可选地,在本实施例中,初始收集器可存储的字段位宽与校验和计算时的计算粒度匹配,比如,在进行校验和计算时是以16bit为粒度的,则初始收集器可存储的字段最大位宽可设置为8、16等。
通过以上步骤,通过设置收集器,按照字段位宽和目标字段位置将目标报文字段存储在对应的收集器的目标收集位置上,从而保证校验和计算时各个报文字段之间的计算顺序,避免因计算顺序不同对报文字段校验和的一致性造成影响,提高计算得到的校验和的可靠性以及一致性。
作为一种可选的实施例,所述将所述目标报文字段存储在多个初始收集器中与所述目标报文字段的目标字段位宽和目标字段位置对应的收集器的目标收集位置上,包括:
确定所述目标字段位置在目标单位标尺中的目标标尺位置,其中,所述目标报文被划分为多个单位标尺,所述目标单位标尺是所述目标报文字段在所述多个单位标尺中所在的单位标尺;
按照所述多个初始收集器的收集顺序,从所述多个初始收集器中获取所述目标标尺位置对应的收集位置未存储数据的候选收集器,其中,每个所述初始收集器的数据收集量与一个单位标尺的数据量相等;
将所述候选收集器中所述目标标尺位置对应的收集位置作为所述目标收集位置存储所述目标报文字段。
可选地,在本实施例中,一个单位标尺的数据量与校验和的计算粒度匹配,比如单位标尺的数据量可以设置为与计算粒度相等、或者是计算粒度的倍数,本方案对此不做限定。
图3是根据本发明实施例的一种选的报文标定示意图,如图3所示,可以但不限于包括以下内容:一个单位标尺的数据量为16bit,使用单位标尺从而将报文中的编辑位置进行标定,在图3中,使用多个单位标尺对一条报文进行标定,每个单位标尺可被划分为4个4bit编辑位置和两个8bit编辑位置,从而标定出报文中的各个位宽的字段在报文中的相对位置。
图4是根据本发明实施例的一种可选的报文编辑信息示意图,本实施例仅是示例性的举例,如图4所示,可以但不限于包括如下内容:报文中包括5组4bit的编辑信息(即报文字段)和5组8bit的编辑信息(即报文字段),根据每个编辑信息在报文编辑时的重要程度或者先后顺序对编辑信息进行排序,从而确定出每个报文字段在存入收集器的先后顺序,如图给出了各个字段在如图3所示的标尺标定的报文中的相对位置,以及每个报文字段在编辑到存储器中的先后顺序,如图所示,g4[0]在4bit编辑信息中是第一个被编辑到收集器中的,g4[0]在4bit相对位置的第2位置,g8[0]在8bit编辑信息中是第一个被编辑到收集器中的,g8[0]在8bit相对位置的第8位置。
图5是根据本发明实施例的一种可选的报文字段写入收集器的示意图,应用于图3和图4的实施例,如图5所示,可以但不限于包括如下步骤,报文中包括5组4bit的报文字段(4bit编辑信息)和5组8bit的报文字段(8bit编辑信息),在将报文字段编辑到编辑器中时,优先将8bit的报文字段编辑到收集器中,将每个8bit的报文字段按照在报文中的单位标尺中的相对位置依次编辑到手机器中进行占位,如图4和图5所示,g8[0]位于单位标尺的后8bit编辑位置,因此将g8[0]存储在收集器0的8bit编辑位置2处,g8[1]同样位于单位标尺的后8bit编辑位置,因此从按照收集器序号的从小到大顺序依次在收集器中寻找后8bit编辑位置空闲区域,因此将 g8[1]编辑到收集器1的8bit编辑位置2处,同理,将其他8bit报文编辑到收集器中后,在将4bit报文按照同样的原理编辑到收集器中,在8bit报文和4bit报文全部编辑完毕后如果有编辑位置是空的时,用字符“0”补位,这样收集器内就编辑了报文中的全部报文字段,因为计算校验和时是以16bit为计算粒度的,因此计算时每次计算一个编辑器的校验和,并将全部编辑器的校验和进行累加,从而得到报文的校验和。
图6是根据本发明实施例的一种可选的校验和计算流程图,应用于图3至图5的实施例中,如图6所示,可以但不限于包括以下内容:
S601,报文编辑处理信息包括4bit编辑、8bit编辑,4bit编辑可以将报文按照4bit为粒度,寻找可编辑的位置,即编辑的偏移量(offset)为4bit,并对报文设置16bit的单位标尺,将每个4bit字段在报文中的标尺相对位置找出。
S602,8bit编辑可以将报文按照8bit为粒度,寻找可编辑的位置,即编辑的偏移量(offset)为8bit,将每个8bit字段在报文中的标尺相对位置找出。
S603,按照优先放入8bit字段的方式,将编辑的报文字段按照字段在报文中的标尺的相对位置写入到16bit的收集器的对应位置,其次再放入4bit报文字段,在编辑时,按照收集器的先后顺序依次编辑,即如果收集器0使用完毕,则放入收集器1,直到所有手机器都存满。
S604,对各个收集器内的字段进行校验和计算,并对各个收集器的校验和进行累加计算,从而得到报文的校验和。
通过以上步骤,通过设置单位标尺,从而为将报文中的各个报文字段放置在手机器的对应存储位置提供依据,进而保证对一个报文进行多次校验和计算时报文字段的计算顺序不发生变化,提高校验和的一致性。
作为一种可选的实施例,在所述确定所述目标字段位置在目标单位标尺中的目标标尺位置之前,所述方法还包括:
获取报文校验和确定过程对应的校验和计算粒度;
将所述校验和计算粒度确定为一个单位标尺的数据量。
可选地,在本实施例中,校验和计算粒度可以但不限于包设置为16bit、32bit等等,本方案对此不做限定。
作为一种可选的实施例,在所述对所述多个报文字段进行处理,得到所述目标报文对应的目标校验和之后,所述方法还包括:
在所述报文处理设备为报文发送设备的情况下,将所述目标校验和添加到所述目标报文中,得到待发送报文,其中,所述报文发送设备用于发送所述待发送报文;
在所述报文处理设备为报文接收设备的情况下,将所述目标校验和与所述目标报文中携带的参考校验和进行比对,得到第一比对结果,其中,所述报文接收设备用于对所述目标报文执行所述第一比对结果对应的报文处理操作;
在所述报文处理设备为报文转换设备,所述目标报文包括转换前报文和转换后报文的情况下,将所述转换前报文对应的所述目标校验和与所述转换后报文对应的所述目标校验和进行比对,得到第二比对结果,其中,所述报文转换设备用于在所述第二比对结果指示所述转换前报文对应的所述目标校验和与所述转换后报文对应的所述目标校验和匹配的情况下,确定报文转换成功。
可选地,在本实施例中,转换前报文对应的目标校验和与转换后报文对应的目标校验和匹配可以但不限与包括转换前报文对应的目标校验和与转换后报文对应的目标校验和相等,本方案对此不做限定。
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到根据上述实施例的方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理 解,本发明实施例的技术方案本质上或者说对现有技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM(Read-Only Memory,只读存储器)/RAM(Rondam Access Memory,随机存取存储器)、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,或者网络设备等)执行本发明各个实施例所述的方法。
在本实施例中还提供了一种报文的处理装置,图7是根据本发明实施例的报文的处理装置的结构框图,如图7所示,该装置包括:
第一获取模块72,被设置为获取报文处理设备中待计算校验和的目标报文;
第一确定模块74,被设置为根据所述目标报文所包括的多个报文字段中每个报文字段的字段位宽和字段优先级,确定所述多个报文字段的处理顺序,其中,所述处理顺序用于指示所述多个报文字段中所述每个报文字段在报文校验和确定过程中的处理时机,所述字段优先级为相同字段位宽的报文字段之间的优先级;
处理模块76,被设置为按照所述处理顺序,根据所述每个报文字段的所述字段位宽和所述每个报文字段在所述目标报文中的字段位置,对所述多个报文字段进行处理,得到所述目标报文对应的目标校验和,其中,所述目标校验和用于指示所述报文处理设备对所述目标报文执行所述目标校验和所对应的报文处理操作。
可选的,所述第一确定模块包括:第一确定单元,被设置为将所述多个报文字段中对应的字段位宽为第一数值的报文字段确定为第一字段集合,并将所述多个报文字段中对应的字段位宽为第二数值的报文字段确定为第二字段集合,其中,报文字段的字段位宽被划分为所述第一数值和所述第二数值;第二确定单元,被设置为确定所述处理顺序为先按照所述第一字段集合中包括的第一报文字段所对应的字段优先级处理所述第一字 段集合中的所述第一报文字段,再按照所述第二字段集合中包括的第二报文字段所对应的字段优先级处理所述第二字段集合中的所述第二报文字段。
可选的,所述第一确定单元被设置为:确定所述第一数值为8bit,所述第二数值为4bit;将所述多个报文字段中对应的字段位宽为8bit的报文字段确定为第一字段集合,并将所述多个报文字段中对应的字段位宽为4bit的报文字段确定为第二字段集合。
可选的,所述处理模块包括:处理单元,被设置为按照所述处理顺序遍历所述每个报文字段作为目标报文字段;存储单元,被设置为将所述目标报文字段存储在多个初始收集器中与所述目标报文字段的目标字段位宽和目标字段位置对应的收集器的目标收集位置上,得到多个目标收集器,其中,每个所述初始收集器被划分为多个符合报文字段的字段位宽的收集位置;计算单元,被设置为对所述多个目标收集器中每个目标收集器存储的报文字段进行校验值计算,得到多个校验值;第三确定单元,被设置为将所述多个校验值的累加和确定为所述目标校验和。
可选的,所述存储单元被设置为:确定所述目标字段位置在目标单位标尺中的目标标尺位置,其中,所述目标报文被划分为多个单位标尺,所述目标单位标尺是所述目标报文字段在所述多个单位标尺中所在的单位标尺;按照所述多个初始收集器的收集顺序,从所述多个初始收集器中获取所述目标标尺位置对应的收集位置未存储数据的候选收集器,其中,每个所述初始收集器的数据收集量与一个单位标尺的数据量相等;将所述候选收集器中所述目标标尺位置对应的收集位置作为所述目标收集位置存储所述目标报文字段。
可选的,所述装置还包括:第二获取模块,被设置为在所述确定所述目标字段位置在目标单位标尺中的目标标尺位置之前,获取报文校验和确定过程对应的校验和计算粒度;第二确定模块,被设置为将所述校验和计算粒度确定为一个单位标尺的数据量。
可选的,所述装置还包括:添加模块,被设置为在所述对所述多个报文字段进行处理,得到所述目标报文对应的目标校验和之后,在所述报文处理设备为报文发送设备的情况下,将所述目标校验和添加到所述目标报文中,得到待发送报文,其中,所述报文发送设备被设置为发送所述待发送报文;第一比对模块,被设置为在所述报文处理设备为报文接收设备的情况下,将所述目标校验和与所述目标报文中携带的参考校验和进行比对,得到第一比对结果,其中,所述报文接收设备被设置为对所述目标报文执行所述第一比对结果对应的报文处理操作;第二比对模块,被设置为在所述报文处理设备为报文转换设备,所述目标报文包括转换前报文和转换后报文的情况下,将所述转换前报文对应的所述目标校验和与所述转换后报文对应的所述目标校验和进行比对,得到第二比对结果,其中,所述报文转换设备被设置为在所述第二比对结果指示所述转换前报文对应的所述目标校验和与所述转换后报文对应的所述目标校验和匹配的情况下,确定报文转换成功。
需要说明的是,上述各个模块是可以通过软件或硬件来实现的,对于后者,可以通过以下方式实现,但不限于此:上述模块均位于同一处理器中;或者,上述各个模块以任意组合的形式分别位于不同的处理器中。
本发明的实施例还提供了一种计算机可读存储介质,该计算机可读存储介质中存储有计算机程序,其中,该计算机程序被设置为运行时执行上述任一项方法实施例中的步骤。
在一个示例性实施例中,上述计算机可读存储介质可以包括但不限于:U盘、只读存储器(Read-Only Memory,简称为ROM)、随机存取存储器(Random Access Memory,简称为RAM)、移动硬盘、磁碟或者光盘等各种可以存储计算机程序的介质。
本发明的实施例还提供了一种电子装置,包括存储器和处理器,该存储器中存储有计算机程序,该处理器被设置为运行计算机程序以执行上述任一项方法实施例中的步骤。
在一个示例性实施例中,上述电子装置还可以包括传输设备以及输入输出设备,其中,该传输设备和上述处理器连接,该输入输出设备和上述处理器连接。
本实施例中的示例可以参考上述实施例及示例性实施方式中所描述的示例,本实施例在此不再赘述。
显然,本领域的技术人员应该明白,上述的本发明的各模块或各步骤可以用通用的计算装置来实现,它们可以集中在单个的计算装置上,或者分布在多个计算装置所组成的网络上,它们可以用计算装置可执行的程序代码来实现,从而,可以将它们存储在存储装置中由计算装置来执行,并且在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤,或者将它们分别制作成各个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。这样,本发明不限制于任何特定的硬件和软件结合。
以上所述仅为本发明的优选实施例而已,并不用于限制本发明,对于本领域的技术人员来说,本发明可以有各种更改和变化。凡在本发明的原则之内,所作的任何修改、等同替换、改进等,均应包含在本发明的保护范围之内。

Claims (10)

  1. 一种报文的处理方法,包括:
    获取报文处理设备中待计算校验和的目标报文;
    根据所述目标报文所包括的多个报文字段中每个报文字段的字段位宽和字段优先级,确定所述多个报文字段的处理顺序,其中,所述处理顺序用于指示所述多个报文字段中所述每个报文字段在报文校验和确定过程中的处理时机,所述字段优先级为相同字段位宽的报文字段之间的优先级;
    按照所述处理顺序,根据所述每个报文字段的所述字段位宽和所述每个报文字段在所述目标报文中的字段位置,对所述多个报文字段进行处理,得到所述目标报文对应的目标校验和,其中,所述目标校验和用于指示所述报文处理设备对所述目标报文执行所述目标校验和所对应的报文处理操作。
  2. 根据权利要求1所述的方法,其中,所述根据所述目标报文所包括的多个报文字段中每个报文字段的字段信息字段位宽和字段优先级,确定所述多个报文字段的处理顺序,包括:
    将所述多个报文字段中对应的字段位宽为第一数值的报文字段确定为第一字段集合,并将所述多个报文字段中对应的字段位宽为第二数值的报文字段确定为第二字段集合,其中,报文字段的字段位宽被划分为所述第一数值和所述第二数值;
    确定所述处理顺序为先按照所述第一字段集合中包括的第一报文字段所对应的字段优先级处理所述第一字段集合中的所述第一报文字段,再按照所述第二字段集合中包括的第二报文字段所对应的字段优先级处理所述第二字段集合中的所述第二报文字段。
  3. 根据权利要求2所述的方法,其中,所述将所述多个报文字段中对 应的字段位宽为第一数值的报文字段确定为第一字段集合,并将所述多个报文字段中对应的字段位宽为第二数值的报文字段确定为第二字段集合,包括:
    确定所述第一数值为8bit,所述第二数值为4bit;
    将所述多个报文字段中对应的字段位宽为8bit的报文字段确定为第一字段集合,并将所述多个报文字段中对应的字段位宽为4bit的报文字段确定为第二字段集合。
  4. 根据权利要求1所述的方法,其中,所述按照所述处理顺序,根据所述每个报文字段的所述字段位宽和所述每个报文字段在所述目标报文中的字段位置,对所述多个报文字段进行处理,得到所述目标报文对应的目标校验和,包括:
    按照所述处理顺序遍历所述每个报文字段作为目标报文字段;
    将所述目标报文字段存储在多个初始收集器中与所述目标报文字段的目标字段位宽和目标字段位置对应的收集器的目标收集位置上,得到多个目标收集器,其中,每个所述初始收集器被划分为多个符合报文字段的字段位宽的收集位置;
    对所述多个目标收集器中每个目标收集器存储的报文字段进行校验值计算,得到多个校验值;
    将所述多个校验值的累加和确定为所述目标校验和。
  5. 根据权利要求4所述的方法,其中,所述将所述目标报文字段存储在多个初始收集器中与所述目标报文字段的目标字段位宽和目标字段位置对应的收集器的目标收集位置上,包括:
    确定所述目标字段位置在目标单位标尺中的目标标尺位置,其中,所述目标报文被划分为多个单位标尺,所述目标单位标尺是所述目标报文字段在所述多个单位标尺中所在的单位标尺;
    按照所述多个初始收集器的收集顺序,从所述多个初始收集器中获取所述目标标尺位置对应的收集位置未存储数据的候选收集器,其中,每个所述初始收集器的数据收集量与一个单位标尺的数据量相等;
    将所述候选收集器中所述目标标尺位置对应的收集位置作为所述目标收集位置存储所述目标报文字段。
  6. 根据权利要求5所述的方法,其中,在所述确定所述目标字段位置在目标单位标尺中的目标标尺位置之前,所述方法还包括:
    获取报文校验和确定过程对应的校验和计算粒度;
    将所述校验和计算粒度确定为一个单位标尺的数据量。
  7. 根据权利要求6所述的方法,其中,在所述对所述多个报文字段进行处理,得到所述目标报文对应的目标校验和之后,所述方法还包括:
    在所述报文处理设备为报文发送设备的情况下,将所述目标校验和添加到所述目标报文中,得到待发送报文,其中,所述报文发送设备用于发送所述待发送报文;
    在所述报文处理设备为报文接收设备的情况下,将所述目标校验和与所述目标报文中携带的参考校验和进行比对,得到第一比对结果,其中,所述报文接收设备用于对所述目标报文执行所述第一比对结果对应的报文处理操作;
    在所述报文处理设备为报文转换设备,所述目标报文包括转换前报文和转换后报文的情况下,将所述转换前报文对应的所述目标校验和与所述转换后报文对应的所述目标校验和进行比对,得到第二比对结果,其中,所述报文转换设备用于在所述第二比对结果指示所述转换前报文对应的所述目标校验和与所述转换后报文对应的所述目标校验和匹配的情况下,确定报文转换成功。
  8. 一种报文的处理装置,包括:
    第一获取模块,被设置为获取报文处理设备中待计算校验和的目标报文;
    第一确定模块,被设置为根据所述目标报文所包括的多个报文字段中每个报文字段的字段位宽和字段优先级,确定所述多个报文字段的处理顺序,其中,所述处理顺序用于指示所述多个报文字段中所述每个报文字段在报文校验和确定过程中的处理时机,所述字段优先级为相同字段位宽的报文字段之间的优先级;
    处理模块,被设置为按照所述处理顺序,根据所述每个报文字段的所述字段位宽和所述每个报文字段在所述目标报文中的字段位置,对所述多个报文字段进行处理,得到所述目标报文对应的目标校验和,其中,所述目标校验和用于指示所述报文处理设备对所述目标报文执行所述目标校验和所对应的报文处理操作。
  9. 一种计算机可读存储介质,所述计算机可读存储介质中存储有计算机程序,其中,所述计算机程序被处理器执行时实现所述权利要求1至7任一项中所述的方法的步骤。
  10. 一种电子装置,包括存储器、处理器以及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现所述权利要求1至7任一项中所述的方法的步骤。
PCT/CN2022/140096 2021-12-30 2022-12-19 报文的处理方法、装置、存储介质和电子装置 WO2023125116A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111663239.3 2021-12-30
CN202111663239.3A CN116418752A (zh) 2021-12-30 2021-12-30 报文的处理方法、装置、存储介质和电子装置

Publications (1)

Publication Number Publication Date
WO2023125116A1 true WO2023125116A1 (zh) 2023-07-06

Family

ID=86997721

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/140096 WO2023125116A1 (zh) 2021-12-30 2022-12-19 报文的处理方法、装置、存储介质和电子装置

Country Status (2)

Country Link
CN (1) CN116418752A (zh)
WO (1) WO2023125116A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107786471A (zh) * 2017-10-23 2018-03-09 深圳市风云实业有限公司 多fpga芯片间数据处理方法及转换装置
CN111131061A (zh) * 2019-12-30 2020-05-08 中国联合网络通信集团有限公司 一种数据传输方法及网络设备
WO2021058254A1 (de) * 2019-09-23 2021-04-01 Beckhoff Automation Gmbh Datenübertragungsverfahren, segment-telegramm und automatisierungskommunikationsnetzwerk
CN112866139A (zh) * 2019-11-27 2021-05-28 深圳市中兴微电子技术有限公司 一种多规则流分类的实现方法、设备和存储介质

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107786471A (zh) * 2017-10-23 2018-03-09 深圳市风云实业有限公司 多fpga芯片间数据处理方法及转换装置
WO2021058254A1 (de) * 2019-09-23 2021-04-01 Beckhoff Automation Gmbh Datenübertragungsverfahren, segment-telegramm und automatisierungskommunikationsnetzwerk
CN112866139A (zh) * 2019-11-27 2021-05-28 深圳市中兴微电子技术有限公司 一种多规则流分类的实现方法、设备和存储介质
CN111131061A (zh) * 2019-12-30 2020-05-08 中国联合网络通信集团有限公司 一种数据传输方法及网络设备

Also Published As

Publication number Publication date
CN116418752A (zh) 2023-07-11

Similar Documents

Publication Publication Date Title
RU2608464C2 (ru) Устройство, способ и сетевой сервер для обнаружения структур данных в потоке данных
EP1788490B1 (en) Method and apparatus for monitoring traffic in a network
CN110177013B (zh) 一种基于FPGA的EtherCAT主从站设计与实现方法
CN108696492B (zh) Ip报文的处理方法与装置
CN108462642B (zh) 基于fpga的udp/ip硬件协议栈及实现方法
CN110096628B (zh) 一种基于字符串的快速匹配识别方法和装置
CN114006928B (zh) 一种基于多协议实时通信的物联网数据处理方法
CN102932285B (zh) 报文封装方法、解析方法及装置
CN109377383A (zh) 产品数据同步方法、装置、计算机设备及存储介质
CN110213756A (zh) 一种数据传输方法、装置及其相关设备
US11134129B2 (en) System for determining whether to forward packet based on bit string within the packet
CN113225320A (zh) 一种用户可配置报文格式保密的网络报文解析方法
US20050172025A1 (en) Method of selecting and sorting packets provided to a piece of equipment by a data packet transmission network
CN115883681A (zh) 报文解析方法、装置、电子设备及存储介质
CN105450359A (zh) 自定义二进制结构化协议数据的发送和接收方法
WO2023125116A1 (zh) 报文的处理方法、装置、存储介质和电子装置
US7653070B2 (en) Method and system for supporting efficient and cache-friendly TCP session lookup operations based on canonicalization tags
CN112787938B (zh) 一种路由表项配置方法及装置
US20020009056A1 (en) Route retrieving system, method therefor and a router device to be used in the same
CN116701300B (zh) 一种基于互联网的计算机文件管理系统
CN117221224A (zh) 一种表项构建、查找方法、装置、网络设备及存储介质
CN116521602A (zh) 一种总线数据的传输方法和装置及存储介质
CN107248903B (zh) 一种基于fpga的tcp/ip首部校验装置及方法
CN106789440B (zh) 一种ip包包头检测方法及装置
CN104135439A (zh) 一种icmp差错报文快速生成方法

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

Country of ref document: EP

Kind code of ref document: A1