A long chain message distribution method and system
By extracting message length and verification fields in long-connection message distribution, calculating accuracy scores, and dynamically adjusting frame segmentation, the authentication logic bypass problem caused by TCP packet splicing and reassembly is solved, thus improving the security and stability of the system.
Patent Information
- Application Number
- CN202510559529.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-30
- Publication Date
- 2026-01-02
- Estimated Expiration
- 2045-04-30
AI Technical Summary
In existing long-connection message distribution technologies, the packet splicing and unpacking phenomena in TCP communication can cause message boundaries to be misaligned. Attackers can bypass authentication logic by quickly sending authentication messages, which can lead to security vulnerabilities.
By extracting the message length and verification fields, calculating the accuracy score, dynamically adjusting the frame processing, and employing a sliding window adaptive segmentation algorithm, the integrity of the authentication message boundaries and content is ensured.
It effectively prevents unauthorized users from impersonating legitimate individuals to access the system, improves the security and stability of long-connection message distribution, and enhances the system's adaptability in complex network environments.
Smart Images

Figure CN120342989B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of information distribution, and particularly relates to a long connection message distribution method and system. BACKGROUND
[0002] Long connection message distribution refers to that after a persistent connection (such as a TCP long connection or a WebSocket) is established, a server pushes messages to a client in real time through the stable connection. Compared with short connection, long connection can reduce the overhead of frequently establishing and closing connections, realize efficient and low-delay message transmission, and is commonly used in instant messaging, online gaming, Internet of Things and other real-time communication scenarios.
[0003] The prior art has the following deficiencies:
[0004] In the prior art long connection message distribution technology, due to the natural phenomenon of packet sticking and packet disassembling of TCP communication, if the server does not correctly perform frame splitting processing when receiving the authentication message, but directly parses the received Buffer data, the message boundary misplacement problem is easily caused. Attackers can quickly and continuously send authentication messages and ordinary business messages after establishing a connection. If the server mistakenly processes the business message content as authentication data, the authentication logic may be bypassed, so that unauthorized users can impersonate legitimate identities to access the system, causing serious security risks. SUMMARY
[0005] The purpose of the present application is to provide a long connection message distribution method and system to solve the problems in the background art.
[0006] In order to achieve the above purpose, the present application provides the following technical scheme: a long connection message distribution method, comprising:
[0007] The server establishes a long connection with the client and listens to the first message from the client;
[0008] The server parses the received message and extracts field information related to authentication;
[0009] The message length field and the message check field are extracted from the received field information;
[0010] The extracted message length field is compared with the actual received message byte number, and the message body is checked based on the extracted message check field, and the accuracy score of the current message parsing is calculated comprehensively;
[0011] The accuracy of the current frame splitting processing is evaluated according to the accuracy score, and when the accuracy score is lower than a preset threshold, dynamic frame splitting adjustment is performed, including re-dividing the data buffer according to the message length field and independently parsing the authentication message;
[0012] If the authentication information after the frame adjustment passes the verification, the subsequent authentication process is continued; if the authentication information after the frame adjustment still fails to pass the verification, the connection is disconnected and the client access is rejected.
[0013] Preferably, the field information includes Token, user identification and device identification.
[0014] Preferably, the byte comparison deviation index is generated after comparing the extracted message length field value with the actual received byte number.
[0015] The message length field is extracted from the received message, denoted as L expected , indicating the declared length, and the actual received data byte number is counted, denoted as L actual .
[0016] The absolute value difference of the length deviation is calculated, denoted as ΔL: ΔL = |L expected -L actual |; the byte comparison deviation index S is calculated, expressed as: e is the base of natural logarithm; k is the exponential decay coefficient.
[0017] Preferably, the check value comparison abnormality index is generated after comparing the recalculated check value with the extracted check field, and the generation method is:
[0018] The extracted check field is denoted as Cexpected and the recalculated check value is denoted as Cactual, which are converted into binary bit string form.
[0019] Cexpected and Cactual are XORed bit by bit to obtain the XOR result bit string.
[0020] The number of bits with value 1 in the XOR result is counted, denoted as the difference bit number d.
[0021] The total number of check value bits is counted, denoted as n.
[0022] The check value comparison abnormality index R is calculated:
[0023] Preferably, the byte comparison deviation index and the check value comparison abnormality index are normalized to be between 0 and 1, and the normalized byte comparison deviation index and check value comparison abnormality index are weighted and averaged to obtain the accuracy score of the current message parsing.
[0024] Preferably, the accuracy of the current frame processing is evaluated according to the accuracy score, and when the accuracy score is lower than a preset threshold, dynamic frame adjustment is performed:
[0025] The server reads the accuracy score of the current message parsing after completing the comprehensive score based on the message length field and the message check field;
[0026] The server sets a preset threshold value;
[0027] The server compares the current accuracy score with the preset threshold value;
[0028] When the accuracy score is higher than or equal to the preset threshold value, it is determined that the current frame processing is accurate and does not need to be adjusted, and the normal authentication process is continued to be executed;
[0029] When the accuracy score is lower than the preset threshold value, it is determined that the current frame processing is abnormal and needs to be dynamically adjusted.
[0030] Preferably, the adjustment specific steps include:
[0031] Step 1: Extract the target message length Ltarget;
[0032] Step 2: Initialize the sliding window, set the starting pointer pstart to point to the starting position of the cache, and the window size is initially set as W=Ltarget;
[0033] Step 3: Apply the sliding window on the cache area for scanning, and each time the scanning content includes: starting from pstart, a data segment with a length of W is intercepted; and the fast pre-parsing is performed on the data segment;
[0034] Step 4: Dynamically adjust the window size according to the pre-parsing result: if the data segment conforms to the expected protocol structure, it is determined that the current window area is a complete authentication message; if not, the window is slid by a small step and W bytes are re-intercepted for continuous verification; and the maximum sliding offset is set to prevent invalid scanning;
[0035] Step 5: After confirming the complete message boundary, the data is cut as an independent authentication message for formal parsing, and the re-divided authentication message is independently parsed, including basic field extraction, length comparison and content check;
[0036] Step 6: The remaining data continues to repeat the sliding window detection until the cache area data is completely and correctly divided or times out and exits.
[0037] The application also provides a long link message distribution system, which includes a connection management module, a message parsing module, a protocol field extraction module, an accuracy scoring module, a frame management module and an authentication processing module;
[0038] The connection management module: the server establishes a long link with the client and listens to the first message from the client;
[0039] Message parsing module: the server parses the received message and extracts the field information related to authentication;
[0040] Protocol field extraction module: from the received field information, the message length field and the message check field are extracted;
[0041] Accuracy scoring module: based on the extracted message length field and the actual received message byte number, comparison calculation is performed, and based on the extracted message check field, the message body is checked, and the accuracy score of the current message parsing is calculated;
[0042] Frame management module: according to the accuracy score, the accuracy of the current frame processing is evaluated, when the accuracy score is lower than the preset threshold, dynamic frame adjustment is performed, including re-segmenting the data cache according to the message length field and independently parsing the authentication message;
[0043] Authentication processing module: if the authentication information after frame adjustment passes the check, the subsequent authentication process is continued; if the authentication information after frame adjustment still fails the check, the connection is disconnected and the client access is rejected.
[0044] In the above technical solution, the technical effects and advantages provided by the present application are as follows:
[0045] 1. By extracting the fields of the received authentication message, comparing the length and checking the content after establishing a long connection between the server and the client, and combining the byte comparison deviation index and the check value comparison abnormal index, the accuracy score of message parsing is calculated, so as to dynamically evaluate the accuracy of frame processing. When frame anomaly is detected, the sliding window adaptive segmentation algorithm is used to intelligently adjust and independently parse the cached data, ensuring the double integrity of authentication message boundary and content, and effectively solving the problem that the authentication logic is bypassed due to packet sticking and packet splitting in the existing long connection message distribution.
[0046] 2. The method and system provided by the present application can significantly improve the security and stability of the long connection message distribution process, prevent unauthorized users from simulating authentication success access to the system through abnormal messages, and at the same time, through the dynamic frame and accuracy scoring mechanism, the present application enhances the adaptability of the system to message anomalies in complex network environment, improves the robustness and real-time protection capability of the authentication stage, and has good application and popularization value. BRIEF DESCRIPTION OF DRAWINGS
[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments described in the present application, and other drawings can also be obtained by those skilled in the art based on these drawings.
[0048] Figure 1 Mind map for the method of the present application.
[0049] Figure 2 Mind map for the system module of the present application. DETAILED DESCRIPTION
[0050] In order to make the purposes, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are some but not all of the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0051] Embodiment 1, please refer to Figure 1 The long-link message distribution method described in the embodiment includes:
[0052] The server establishes a long link with the client and listens to the first message from the client;
[0053] The server parses the received message and extracts the field information related to authentication;
[0054] The message length field and the message check field are extracted from the received field information;
[0055] The extracted message length field is compared with the actual received message byte number, and the message body is checked based on the extracted message check field, and the accuracy score of the current message parsing is obtained by comprehensive calculation;
[0056] The accuracy of the current frame processing is evaluated according to the accuracy score, and when the accuracy score is lower than a preset threshold, dynamic frame adjustment is performed, including re-segmenting the data buffer according to the message length field and independently parsing the authentication message;
[0057] If the authentication information is verified after the frame adjustment, the subsequent authentication process is continued; if the authentication information is still not verified after the frame adjustment, the connection is disconnected and the client access is rejected.
[0058] The server establishes a long link with the client through a communication protocol, which can be a TCP protocol, a WebSocket protocol or an HTTP / 2 protocol. The process of establishing a connection includes:
[0059] The server receives a connection request from the client;
[0060] Legitimacy verification on the connection request initiated by the client, including but not limited to IP white list verification, port verification, connection rate limitation, etc.
[0061] After verification, the server and the client complete the connection handshake and establish a persistent two-way communication channel.
[0062] After the connection is established, the server initializes the connection session context and allocates a unique connection identifier for subsequent data communication processes.
[0063] The server enters a listening state and is ready to receive the first data message sent by the client on the connection.
[0064] The first message is defined as the initial active sending by the client after the connection is established, which is used for authentication or session initialization.
[0065] The server parses the received message and extracts the basic field information related to authentication, including Token, user identifier, and device identifier.
[0066] When the server receives the first message from the client, the following detailed parsing steps are performed:
[0067] The received data is parsed in the format, which can be JSON format, Protobuf format, XML format, or custom binary format.
[0068] According to the pre-defined message structure protocol, the basic field information related to authentication is located and extracted, including:
[0069] Token field: used to identify the client identity credential, usually a token issued by the server with time limit and signature protection;
[0070] User identifier field: used to identify the user entity corresponding to the current connection, which can be a digital ID, string ID, or other unique identifier.
[0071] Device identifier field: used to identify the terminal device used in the current connection, which can be a device unique serial number (such as IMEI, MAC address, device SN code, etc.);
[0072] Format integrity check is performed on the extracted basic field information, including whether the field exists, whether the field is empty, and whether the field type matches the expected (for example, Token should be a string type, UserID should be a numerical or short string type).
[0073] If the verification is passed, the extracted Token, user identifier, and device identifier are stored in the connection session context for subsequent authentication verification and message distribution.
[0074] If the verification fails, the authentication process is aborted, and the abnormal connection is handled according to a preset strategy (such as directly disconnecting, sending an error prompt message, etc.).
[0075] After the extraction of the basic fields (Token, user identifier, device identifier) is completed, the server continues to deeply parse the received data message, extracts two important parameters representing different verification directions, and uses them for subsequent data integrity verification and frame accuracy evaluation.
[0076] The message length field is used to represent the length information of the message data body, indicating the number of Payload bytes declared by the current authentication message in the logical protocol layer;
[0077] The message length field can be located in the protocol header (Header) area, such as in a custom binary protocol, Protobuf packet, or HTTP / 2 frame format, and is usually read by a fixed offset position;
[0078] The server parses the specific value of this field according to the protocol specification, compares it with the actual received data length, and judges whether there are abnormal situations such as packet sticking, packet splitting, or truncation;
[0079] If the protocol format is a plaintext structure (such as JSON), the message length can be dynamically calculated after parsing the data structure or obtained based on external additional information.
[0080] The message verification field is used to represent the data integrity or correctness information inside the message body, which is an internal verification mechanism for the message content itself;
[0081] The message verification field can include but is not limited to:
[0082] Hash value (such as SHA-256, MD5 hash);
[0083] Signature value (such as HMAC signature, digital signature);
[0084] Checksum (such as CRC32, Adler-32);
[0085] The server extracts the verification field according to the protocol definition after receiving the complete message body, recalculates the message body content locally, and compares it with the extracted verification field;
[0086] Through the comparison result, it is confirmed whether the message content has been tampered with, damaged, or has the risk of packet sticking error parsing in the transmission process.
[0087] The message length field focuses on the data boundary (physical layer consistency) to prevent message misreading caused by TCP packet sticking or packet splitting;
[0088] The message check field concerns the data content (logical layer correctness) and prevents the message content from being tampered with or spliced incorrectly in the network.
[0089] The double extraction and verification mechanism ensures the parsing accuracy and integrity of the authentication message, reducing the risk of authentication bypass, security vulnerabilities and system crashes.
[0090] In the present application, by simultaneously extracting and comprehensively utilizing the message length field and the message check field, the method can realize bidirectional verification of the authentication message from two different directions of physical data integrity and logical data correctness, providing a reliable basis for subsequent frame accuracy evaluation and dynamic adjustment, and further improving the security and stability of the long connection message distribution system.
[0091] After extracting the message length field and the message check field, the server performs the following detailed processing steps:
[0092] The server reads the message length field from the received message data according to the protocol definition; compares the extracted message length field value with the actual received byte number to generate a byte comparison deviation index, the generation method is:
[0093] The message length field is extracted from the received message, denoted as L expected , which represents the declared length, and the actual received data byte number is denoted as L actual .
[0094] The absolute value difference of the length deviation is calculated, denoted as ΔL: ΔL = |L expected -L actual |; the byte comparison deviation index S is calculated, the expression is: e is the base of natural logarithm, approximately equal to 2.71828; k is the exponential decay coefficient, which controls the sensitivity of the deviation; the calculated deviation index S is used as a reference for message parsing accuracy.
[0095] If S is lower than the set deviation threshold, it is determined that the current frame processing is normal; if S is higher than the deviation threshold, it is determined that there is a risk of sticking or disassembling misplacement, triggering dynamic frame adjustment.
[0096] The server extracts the preset check field from the message body according to the protocol requirements; the server recalculates the check value using the corresponding check algorithm (such as hash algorithm, signature algorithm or checksum algorithm) for the received message body part;
[0097] The recalculated check value is compared with the extracted check field to generate a check value comparison anomaly index, the generation method is:
[0098] The extracted check field is denoted as Cexpected and the recalculated check value is denoted as Cactual, which are converted into binary bit strings;
[0099] The Cexpected and Cactual are XORed to obtain an XOR result bit string;
[0100] The number of bits with a value of 1 in the XOR result is counted and denoted as a difference bit number d, which represents the number of bits in which the two check values differ.
[0101] The total number of check value bits is counted and denoted as n.
[0102] The check value comparison anomaly index R is calculated: to evaluate the consistency and integrity of the current message content.
[0103] The byte comparison deviation index and the check value comparison anomaly index are normalized to be within [0, 1], and the normalized byte comparison deviation index and the normalized check value comparison anomaly index are weighted and averaged to obtain an accuracy score of the current message parsing.
[0104] The accuracy score is used to evaluate the accuracy of the current frame processing, and when the accuracy score is lower than a preset threshold, dynamic frame adjustment is performed:
[0105] After the server completes the comprehensive score based on the message length field and the message check field, the accuracy score of the current message parsing is read.
[0106] The server sets a preset threshold, which can be a reasonable score determined according to the actual application scenario.
[0107] The server compares the current accuracy score with the preset threshold to determine the reliability of the current authentication message parsing.
[0108] When the accuracy score is higher than or equal to the preset threshold, it is determined that the current frame processing is accurate and no adjustment is needed, and the normal authentication process is continued.
[0109] When the accuracy score is lower than the preset threshold, it is determined that the current frame processing is abnormal, and there may be packet sticking, packet splitting, or data misplacement, and dynamic adjustment is needed.
[0110] Traditional segmentation methods usually extract the message length field and directly take a fixed-length data block from the data buffer. This method is prone to errors in cases of packet sticking, packet splitting, or streaming out of order. To improve the correctness of segmentation in abnormal network environments, the method uses a sliding window adaptive segmentation algorithm combined with the message length field to achieve more robust data buffer segmentation.
[0111] The specific steps include:
[0112] Step 1: Extract the target message length Ltarget;
[0113] Step 2: Initialize the sliding window, set the starting pointer pstart to point to the starting position of the cache, and the window size is initially set to W = Ltarget;
[0114] Step 3: Apply the sliding window scan on the cache area, each scan includes:
[0115] Starting from pstart, intercept a data segment of length W;
[0116] Perform fast pre-analysis on the data segment (such as structure integrity check, local verification field verification).
[0117] Step 4: Dynamically adjust the window size according to the pre-analysis result: if the data segment conforms to the expected protocol structure, it is determined that the current window area is a complete authentication message; if not, slide the window back by a small step (such as 1-4 bytes), and re-intercept W bytes for verification; set the maximum sliding offset (such as not more than 10% Ltarget) to prevent invalid scanning.
[0118] Step 5: After confirming the complete message boundary, cut the data segment as an independent authentication message for formal analysis. Independently analyze the authentication message re-divided, including basic field extraction, length comparison and content verification.
[0119] Step 6: Continue to repeat the sliding window detection for the remaining data until the cache area data is completely correctly divided or timeout.
[0120] According to the authentication information verification result after frame adjustment, perform subsequent processing:
[0121] After completing the re-division of the data cache according to the message length field and independently analyzing the authentication message, the server performs authentication information verification on the authentication data obtained by re-analysis;
[0122] The authentication information verification includes but is not limited to: basic field (Token, user identification, device identification) verification, message integrity verification (such as length comparison, verification field comparison) and protocol specification compliance verification.
[0123] If the authentication information after frame adjustment is verified to conform to the expectation, that is, the verification is passed, the server continues to perform the subsequent authentication process;
[0124] The subsequent authentication process includes but is not limited to:
[0125] Mark the current connection as authentication success state;
[0126] binding the user identity, the device identity and the connection ID;
[0127] allowing the client to normally send a service message or receive a push message subsequently.
[0128] If the authentication information after the frame adjustment fails to pass the verification, that is, the authentication message still has problems such as format exception, field error, verification failure or incomplete data;
[0129] the server immediately suspends the current authentication process and performs a safe disconnection process, including but not limited to:
[0130] disconnecting the current client connection;
[0131] releasing the server-side resources associated with the connection;
[0132] optionally recording an abnormal event log (including connection IP, timestamp, abnormal reason, etc.) for subsequent analysis;
[0133] optionally taking further security measures such as banning, throttling, and alarming for the abnormal client.
[0134] In the present application, it is ensured that only when the authentication data is complete and correct, the connection can enter the service processing stage; the connection that fails to pass the verification is disconnected in time, effectively preventing system risks caused by malicious data, transmission abnormalities or protocol attacks; the verification fails after the frame adjustment, which is a security design in accordance with the principle of minimum trust, and is particularly suitable for long-link message distribution systems with high security requirements.
[0135] Embodiment 2, please refer to Figure 2 The long-link message distribution system described in the present embodiment comprises a connection management module, a message parsing module, a protocol field extraction module, an accuracy scoring module, a frame management module and an authentication processing module.
[0136] Connection management module: the server establishes a long link with the client and listens to the first message from the client;
[0137] Message parsing module: the server parses the received message and extracts field information related to authentication;
[0138] Protocol field extraction module: extracts the message length field and the message verification field from the received field information;
[0139] Accuracy scoring module: compares and calculates the extracted message length field with the actual received message byte number, and verifies the message body based on the extracted message verification field, and comprehensively calculates the accuracy score of the current message parsing;
[0140] The frame management module: according to the accuracy score, the accuracy of the current frame processing is evaluated, when the accuracy score is lower than the preset threshold, dynamic frame adjustment is performed, including re-segmenting the data buffer according to the message length field and independently parsing the authentication message;
[0141] The authentication processing module: if the authentication information after frame adjustment is verified, the subsequent authentication process is continued; if the authentication information after frame adjustment is still not verified, the connection is disconnected and the client access is refused.
[0142] The above formulas are dimensionless values calculated, and the formulas are obtained by collecting a large amount of data to simulate the latest real situation, and the preset parameters in the formula are set by the person skilled in the art according to the actual situation.
[0143] It should be understood that the term "and / or" herein is only a description of the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B can represent: A exists alone, A and B exist together, and B exists alone, where A and B can be singular or plural. In addition, the character " / " herein generally represents an "or" relationship between the associated objects before and after it, but it can also represent an "and / or" relationship, which can be understood in combination with the context before and after it.
[0144] Those skilled in the art can realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be realized by electronic hardware or a combination of computer software and electronic hardware. Whether the functions are realized in hardware or software depends on the specific application and design constraints of the technical solution. A person skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0145] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto, any person skilled in the art can easily think of changes or replacements within the technical scope disclosed in the present application, which should be covered within the protection scope of the present application.
Claims
1. A method for distributing long-connection messages, characterized in that: include: The server establishes a long-lived connection with the client and listens for the first message from the client; The server parses the received message and extracts authentication-related fields. Extract the message length field and message verification field from the received field information; The accuracy score of the current message parsing is calculated by comparing the extracted message length field with the actual number of received message bytes and verifying the message body based on the extracted message verification field. Specifically, this includes: normalizing the byte alignment deviation index and the check value alignment anomaly index so that they are both between [0,1], and then calculating the accuracy score of the current message parsing by weighted average summation of the normalized byte alignment deviation index and the check value alignment anomaly index. The accuracy of the current frame processing is evaluated based on the accuracy score. When the accuracy score is lower than a preset threshold, dynamic frame adjustment is performed, including re-segmenting the data cache according to the message length field and independently parsing the authentication message. Specifically, it includes: Step 1: Extract the target message length Ltarget; Step 2: Initialize the sliding window, set the start pointer pstart to point to the beginning of the buffer, and initially set the window size to W=Ltarget; Step 3: Apply a sliding window scan to the buffer. Each scan includes: starting from pstart, extracting a data segment of length W; performing fast pre-parsing on the data segment; Step 4: Dynamically adjust the window size based on the pre-parsing results: If the data segment conforms to the expected protocol structure, the current window area is determined to be a complete authentication message; if it does not conform, the window is slid backward by a small step, and W bytes are re-trunculated to continue verification; a maximum sliding offset is set to prevent invalid scanning. Step 5: After confirming the complete message boundaries, the data is split into independent authentication messages for formal parsing. The newly split authentication messages are parsed independently, including basic field extraction, length comparison and content verification. Step 6: Continue to repeat the sliding window detection for the remaining data until all data in the buffer is correctly segmented or the process times out. If the authentication information passes verification after frame adjustment, the subsequent authentication process continues; if the authentication information still fails verification after frame adjustment, the connection is disconnected and client access is rejected.
2. The long-connection message distribution method according to claim 1, characterized in that: Field information, including Token, User ID, and Device ID.
3. The long-connection message distribution method according to claim 1, characterized in that: The extracted message length field value is compared with the actual number of bytes received to generate a byte comparison deviation index. The generation method is as follows: Extract the message length field from the received message, denoted as... , indicating the required length of the message declaration, and counting the actual number of bytes received, denoted as . ; The absolute difference in length deviation is calculated and denoted as ΔL: ; The byte alignment deviation index S is calculated as follows: ; e is the base of the natural logarithm; k is the exponential decay coefficient.
4. The long-connection message distribution method according to claim 3, characterized in that: The recalculated checksum is compared with the extracted checksum field to generate a checksum comparison anomaly index. The generation method is as follows: The extracted verification field, denoted as Cexpected, and the recalculated verification value, denoted as Cactual, are converted into binary bit string form. Perform a bitwise XOR operation between Cexpected and Cactual to obtain the resulting bit string; The number of bits that are 1 in the XOR result is denoted as the difference bit length d; The total number of digits in the check value is denoted as n; Calculate the anomaly index R for the checksum comparison: .
5. The long-connection message distribution method according to claim 1, characterized in that: The accuracy of the current frame processing is evaluated based on the accuracy score. When the accuracy score is lower than a preset threshold, dynamic frame adjustment is performed. After completing a comprehensive score based on the message length field and the message verification field, the server reads the accuracy score of the current message parsing. The server is set with a preset threshold. The server compares the current accuracy score with a preset threshold. When the accuracy score is higher than or equal to the preset threshold, the current frame processing is determined to be accurate, no adjustment is needed, and the normal authentication process continues. When the accuracy score is lower than the preset threshold, it is determined that there is an anomaly in the current frame processing and dynamic adjustment needs to be performed.
6. A long-connection message distribution system, used to implement the long-connection message distribution method according to any one of claims 1-5, characterized in that: It includes a connection management module, a message parsing module, a protocol field extraction module, an accuracy scoring module, a frame management module, and an authentication processing module; Connection Management Module: The server establishes a long-lived connection with the client and listens for the first message from the client; Message parsing module: The server parses the received messages and extracts authentication-related field information; Protocol field extraction module: Extracts the message length field and message verification field from the received field information; Accuracy scoring module: It compares the extracted message length field with the actual number of received message bytes and verifies the message body based on the extracted message verification field. The overall calculation yields the accuracy score of the current message parsing. Frame management module: Evaluates the accuracy of the current frame processing based on the accuracy score. When the accuracy score is lower than a preset threshold, it performs dynamic frame adjustment, including re-segmenting the data cache according to the message length field and independently parsing the authentication message. Authentication processing module: If the authentication information passes the verification after frame adjustment, the subsequent authentication process continues; if the authentication information still fails the verification after frame adjustment, the connection is disconnected and the client access is rejected.
Citation Information
Patent Citations
Data processing method and server
CN117768407A
Automatic industrial control protocol reverse system and method based on global voting expert algorithm
CN119105384A