A packet splicing method based on a sliding window

By using a sliding window-based message concatenation method, Redis caching and the sliding window algorithm are utilized to optimize message processing on the energy storage vehicle device side, solving the system resource consumption problem caused by multiple message transmissions and improving system processing efficiency and flexibility.

CN120186236BActive Publication Date: 2025-12-12BEIJING CHEXUN JUNDU INTERNET CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510660263.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-22
Publication Date
2025-12-12
Estimated Expiration
2045-05-22

AI Technical Summary

Technical Problem

In existing technologies, messages sent by the energy storage vehicle device may be transmitted multiple times, causing the server to be unable to receive them completely. Repeated transmissions consume computing and network resources, reducing the system's service capabilities.

Method used

A message concatenation method based on a sliding window is adopted. A unique identifier key is generated by obtaining the frame type and energy storage vehicle code of the message information. The message information that fails to be verified is stored in the Redis database, and the cached messages are retrieved from the sliding window queue for concatenation. The message processing is optimized by using Redis caching and the sliding window algorithm.

Benefits of technology

This effectively solves the problem of incomplete message transmission in multiple parts, reduces the number of times the device sends messages repeatedly, reduces the consumption of computing power and network resources, and improves the system's processing efficiency and flexibility.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120186236B_ABST
    Figure CN120186236B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of data information communication, and especially relates to a message splicing method based on a sliding window, comprising: moving on a received message data sequence according to a window value, checking a message header, when the message header check is successful, performing back-end check on the message information, when the back-end check fails, obtaining a frame type and a storage vehicle code of the message information, and generating a unique identifier key, simultaneously storing the message information with the failed check as Value in a Redis database, associating the unique identifier key with a sliding window queue, obtaining a new message, calling the key from the sliding window, and splicing the cached message in the Redis according to the key with the new message to obtain a spliced message, the present application solves the problem of incomplete message sending in multiple times, reduces the number of repeated message sending of the equipment end, and reduces the occupation of computing power and network resources.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of data information communication, and in particular to a message splicing method based on a sliding window. BACKGROUND

[0002] In the energy storage vehicle product application of the Internet of Things industry, the energy storage vehicle terminal is connected to the server through a socket and communicates according to a protocol, such as connecting the energy storage vehicle terminal to the server, heartbeat detection, remotely starting the energy storage vehicle terminal, synchronizing the billing strategy, starting charging, order end notification, and other operations, all of which are configured by using an XML file to frame the message and the actual class, and the reflection technology is used to correspond different message headers to specific business processing classes. After the business processing class processes the business, a response message or a sending instruction is returned, and a message is pushed to the business system through MQ.

[0003] The prior art CN112804129A discloses a message transmission method and system, a sending end VPN device and a GRE splicing device, which comprises: in the case where there are multiple GRE tunnels in the transmission path, the sending end VPN device sends a first GRE message encapsulating a destination IP address, which is the address of the integrated processing end VPN device.

[0004] However, in the message processing process, a hard code method is usually used to configure the corresponding relationship, which has the problem of inconvenient maintenance. Meanwhile, when the message is transmitted, the message (such as a charging completion transaction end message) sent by the device end (such as a charging vehicle) may be transmitted to the server end in multiple times. If the server cannot process the incomplete message, the device end will repeatedly send it at intervals of 5-10 seconds, and it usually takes 30-50 seconds to complete the complete message reception, thereby reducing the message processing efficiency. Further, the repeated transmission occupies a large amount of computing power and network resources, and reduces the system service capability. SUMMARY

[0005] The present application is to solve the problems in the background art, and proposes a message splicing method based on a sliding window.

[0006] In order to achieve the above-mentioned purpose, the present application adopts the following technical solutions:

[0007] A message splicing method based on a sliding window, which specifically comprises the following steps:

[0008] Step 1: When the integrated processing end detects a check signal, the message information transmitted by the device end is acquired, and the message header is checked. If the message header is inconsistent with the preset starting identifier, the received message data sequence is moved according to the window value until the message header check is consistent.

[0009] Step two: the back-end check is performed on the message information, when the back-end check fails, the frame type and the energy storage vehicle code of the message information are acquired, a unique identifier key is generated, the message information of the check failure is written as a value into the Redis database for storage, the unique identifier key is associated with the sliding window queue;

[0010] Step three: the new message is acquired, the key is called from the sliding window, and the cached message in the Redis according to the key is spliced with the new message to obtain a spliced message;

[0011] Step four: the frame type in the spliced message is acquired, and the specific business logic is executed and the business is processed according to the business processing method corresponding to the frame type.

[0012] As a further scheme of the application, the device end includes an energy storage vehicle device end and a user device end, the energy storage vehicle device end is used to generate an order end message and transmit the order end message to the integrated processing end, and the user device end is used to generate an order generation message and transmit the order generation message to the integrated processing end.

[0013] As a further scheme of the application, the method for checking the message header includes:

[0014] S1: the message information is acquired, whether the message header in the message information is a preset starting identifier is detected, if the message header is consistent with the preset starting identifier, a pass signal is generated, otherwise, if the message header is inconsistent with the preset starting identifier, a verification failure signal is generated;

[0015] S2: when the verification failure signal is detected, the sliding step in the sliding window algorithm is used to move on the received message data sequence according to the window value, after the movement is completed, the message header is regenerated, and then the new message header is compared with the preset starting identifier, if the comparison is consistent, the pass signal is generated, if the comparison is inconsistent, the sliding window is moved again according to the above method, until the pass signal is generated.

[0016] As a further scheme of the application, the message information is a communication message complying with the IEC 104 protocol, and the communication message of this type usually sets 68 as the preset starting identifier, so the preset starting identifier is set to 68.

[0017] As a further scheme of the application, the back-end check includes message length check, data length check and frame check field, if all the back-end checks pass, a verification success signal is generated, otherwise, if any one of the back-end checks fails, the message header is re-identified and the message header is checked.

[0018] As a further scheme of the present application, the energy storage vehicle code is the unique identification code of the energy storage vehicle, the frame type indicates classification according to specific rules or purposes, and the frame type includes an end frame and an instruction frame, wherein the end frame is used for a message for notifying the end of an order, and the instruction frame is used for a message for starting a charging instruction; according to the different frame types, the data structure and field composition in the message are different.

[0019] As a further scheme of the present application, the method for obtaining the spliced message comprises:

[0020] When a new message arrives at the integrated processing end and the new message is subjected to back-end verification again, if the back-end verification still fails, the key is called from the sliding window, and the spliced message is obtained by splicing the cached message in Redis according to the key and the new message.

[0021] The spliced message is subjected to frame check field verification, if the verification passes, the key in Redis is removed, and a verification success signal is generated, if the verification fails, the sliding window is traversed, and the message splicing segment is searched and spliced until the verification passes.

[0022] As a further scheme of the present application, when the message is subjected to back-end verification, the frame type in the message information is obtained and the instruction corresponding to the string of the frame type is identified, then the reflection mechanism is used to find the class corresponding to the string of the frame type at runtime, and an instance object of the class is created, wherein the instance object stores a pre-defined business processing method and business logic;

[0023] When the verification success signal is detected, the method in the instance object is directly called to execute the specific business logic and perform business processing;

[0024] After the execution is completed, the system sends a settlement notification information to the business party through the MQ message queue, and updates the order state of the energy storage vehicle in the database in real time.

[0025] As a further scheme of the present application, the configuration file of the server in the integrated processing end is an XML configuration file, so that the device end generates the message information according to the format of the XML configuration when generating the message information, and the message information uses 16 hexadecimal, the data type uses BCD code and BIN code, and the message information check code uses CRC16 algorithm verification, further, the message information includes a message header, a data field and a frame check field.

[0026] Compared with the prior art, the present application has the following advantages:

[0027] The application obtains the frame type of the message information and the energy storage vehicle code, generates a unique identifier key, stores the message information of the failed check as Value in the Redis database, associates the unique identifier key with the sliding window queue, then obtains new message information, retrieves the key from the sliding window, splices the cached message in the Redis according to the key and the new message to obtain the spliced message, and effectively solves the problem of incomplete message sending in multiple times, reduces the number of repeated message sending of the device end, and reduces the occupation of computing power and network resources.

[0028] The application obtains the frame type in the message information and the instruction of identifying the string corresponding to the frame type, finds the class corresponding to the string of the frame type by using the reflection mechanism during the running, creates an instance object of the class, then directly calls the method in the instance object, executes the specific business logic and performs the business processing, so that the system is more flexible and expandable when facing different types of messages. BRIEF DESCRIPTION OF DRAWINGS

[0029] Figure 1 The method flowchart of the application;

[0030] Figure 2 The message optimization processing flowchart of the application. DETAILED DESCRIPTION

[0031] The technical solutions in the embodiments of the application will be clearly and completely described below with reference to the drawings in the embodiments of the application. Obviously, the described embodiments are only part of the embodiments of the application, not all the embodiments of the application.

[0032] Referring to Figure 1 and Figure 2 A message splicing method based on a sliding window, which specifically comprises the following steps:

[0033] Step 1: The integrated processing end is used for identifying and detecting the message information transmitted by the device end, and when the integrated processing end detects the message information, a check signal is generated, wherein the device end includes an energy storage vehicle device end and a user device end, further, the energy storage vehicle device end is used for generating an order end message and transmitting it to the integrated processing end, and the user device end is used for generating an order generation message and transmitting it to the integrated processing end;

[0034] It should be further pointed out that in this embodiment, the configuration file of the server in the integrated processing end is an XML configuration file, so when the device end generates the message information, the message information is generated according to the format of the XML configuration, and the message information uses 16 hexadecimal, the data type uses BCD code and BIN code, and the message information check code uses CRC16 algorithm check;

[0035] Step two: when the server of the integrated processing end detects the check signal, the message information is obtained, and the message header in the message information is checked, wherein the message information includes the message header, the data field and the frame check field, and further, the method for checking the message header of the message information includes:

[0036] S1: obtain the message information, detect whether the message header in the message information is the preset starting identifier, if the message header is consistent with the preset starting identifier, a pass signal is generated, otherwise, if the message header is inconsistent with the preset starting identifier, a verification failure signal is generated;

[0037] In the embodiment, the message information is a communication message complying with IEC 104 protocol, and the communication message of this type usually sets 68 as the preset starting identifier, so the preset starting identifier in the embodiment is set to 68;

[0038] S2: when the verification failure signal is detected, based on the sliding step in the sliding window algorithm, the received message data sequence is moved according to the window value, after the movement is completed, the message header is regenerated, and then the new message header is compared with the preset starting identifier, if the comparison is consistent, the pass signal is generated, if the comparison is inconsistent, the sliding window is moved again according to the above method, until the pass signal is generated;

[0039] Step three: when the pass signal is generated, the message information is checked in the back end, wherein the back end check includes message length check, data length check and frame check field, if all the back end checks pass, a verification success signal is generated, otherwise, if any one of the back end checks fails, return to step two, and the message header is re-identified according to the method in step two, and the message header is checked;

[0040] Step four: when there is a check failure in the back end check, a unique identifier key is generated according to the frame type of the message information and the energy storage vehicle code;

[0041] The message information corresponding to the check failure is obtained and marked as defect information, and then the defect information is written as Value into the Redis database for storage, and the unique identifier key is associated with the sliding window queue;

[0042] Wherein, the energy storage vehicle code is the unique identification code of the energy storage vehicle, the frame type indicates classification according to specific rules or purposes, through the frame type, the system can quickly identify the function of the message, and then timely call the corresponding business processing logic, in the embodiment, the frame type includes an end frame and an instruction frame, wherein, the end frame is used for a message for notifying order end, and the instruction frame is used for a message for starting a charging instruction, according to the difference of the frame type, the data structure and field composition in the message are different, for example, the order end message contains order number, end time and cost fields;

[0043] Step five: when the new message arrives at the integrated processing end, and the new message is checked again, if the back-end check still fails, the key is retrieved from the sliding window, and according to the message cached in Redis according to the key, the cached message and the new message are spliced to obtain a spliced message;

[0044] The spliced message is checked in the frame check field, if the check is passed, the key in Redis is removed, and a verification success signal is generated, if the check fails, the sliding window is traversed, and the message splicing segment is found for splicing, until the check is passed;

[0045] Step six: when the message is checked in the back-end, the frame type in the message information is obtained and the instruction of the string corresponding to the frame type is identified, then the reflection mechanism is used to find the class corresponding to the string of the frame type at runtime, and an instance object of the class is created, wherein, the instance object stores the pre-defined business processing method and business logic;

[0046] When the verification success signal is detected, the method in the instance object is directly called, the specific business logic is executed and the business is processed;

[0047] When the execution is completed, the system sends the settlement notification information to the business party through the MQ message queue, and the order state of the energy storage vehicle in the database is updated in real time, wherein, the order state of the energy storage vehicle includes charging, end, etc.

[0048] The above is only the preferred specific embodiment of the present application, but the protection scope of the present application is not limited to this, any skilled person in the art can make equivalent replacement or change according to the technical solution and the inventive concept of the present application within the technical range disclosed by the present application, which should be covered in the protection scope of the present application.

Claims

1. A message splicing method based on a sliding window, characterized in that, The method specifically includes the following steps: Step 1: When the integrated processing terminal detects the verification signal, it obtains the message information transmitted by the device and verifies the message header. If the message header is inconsistent with the preset start identifier, it moves according to the window value on the received message data sequence until the message header verification is consistent. Methods for verifying message headers include: S1: Obtain message information and check whether the message header in the message information is a preset start identifier. If the message header is consistent with the preset start identifier, generate a pass signal; otherwise, if the message header is inconsistent with the preset start identifier, generate a verification failure signal. S2: When a verification failure signal is detected, the received message data sequence is moved according to the window value based on the sliding step size in the sliding window algorithm. After the movement is completed, the message header is regenerated. Then the new message header is compared with the preset start identifier. If the comparison matches, a pass signal is generated. If the comparison does not match, the sliding window is moved again according to the above method until a pass signal is generated. Step 2: Perform backend verification on the message information. When the backend verification fails, obtain the frame type and energy storage vehicle code of the message information, generate a unique identifier key, and write the message information that failed verification as the value into the Redis database for storage. Associate the unique identifier key with the sliding window queue. Step 3: Retrieve the new message, retrieve the key from the sliding window, and concatenate the cached message with the new message based on the message cached in Redis to obtain the concatenated message; Methods for obtaining concatenated messages include: When a new message arrives at the integration processing end and the new message is validated by the backend, if the backend validation still fails, the key is retrieved from the sliding window, and the cached message is concatenated with the new message based on the message cached in Redis to obtain the concatenated message. The concatenated message is validated using the frame verification field. If the validation passes, the key is removed from Redis and a validation success signal is generated. If the validation fails, the sliding window is traversed and message concatenation fragments are searched for and concatenated until the validation passes. Step 4: Obtain the frame type in the concatenated message, and execute the specific business logic and perform business processing according to the business processing method corresponding to the frame type.

2. The message splicing method based on a sliding window according to claim 1, characterized in that, The equipment side includes the energy storage vehicle equipment side and the user equipment side. The energy storage vehicle equipment side is used to generate the order completion message and transmit it to the integration processing end. The user equipment side is used to generate the order generation message and transmit it to the integration processing end.

3. The message splicing method based on a sliding window according to claim 1, characterized in that, The message information is a communication message that conforms to the IEC 104 protocol.

4. The message splicing method based on a sliding window according to claim 1, characterized in that, Backend verification includes message length verification, data length verification, and frame verification field. If all backend verifications pass, a verification success signal is generated. Otherwise, if any one of the backend verifications fails, the message header is re-identified and verified.

5. The message splicing method based on a sliding window according to claim 1, characterized in that, The energy storage vehicle code is a unique identifier for the energy storage vehicle. The frame types include end frames and instruction frames. The end frame is used to notify the end of the order, and the instruction frame is used to initiate the charging instruction. The data structure and field composition inside the message are different depending on the frame type.

6. The message splicing method based on a sliding window according to claim 1, characterized in that, When performing backend verification on the message, the frame type in the message information is obtained and the instruction corresponding to the string of the frame type is identified. Then, using the reflection mechanism, the class corresponding to the string of the frame type is found at runtime, and an instance object of that class is created. The instance object stores predefined business processing methods and business logic. When a successful verification signal is detected, the method in the instance object is directly called to execute the specific business logic and perform business processing. Once the execution is complete, the system sends a settlement notification to the business party via the MQ message queue and updates the order status of the energy storage vehicle in the database in real time.

7. The message splicing method based on a sliding window according to claim 1, characterized in that, The configuration file of the server in the integrated processing terminal is an XML configuration file. When the device generates message information, it generates message information according to the format of the XML configuration. The message information uses hexadecimal, the data type uses BCD code and BIN code, and the message information check code uses the CRC16 algorithm for verification. The message information includes a message header, a data field, and a frame check field.

Citation Information

Patent Citations

  • Message transmission method and system, sending end VPN device and GRE splicing device

    CN112804129A

  • Cache-based efficient multi-source stream data fusion method and system

    CN118427774A

  • Frame header detection method and device

    WO2016184291A1