CN117579512A - Message communication method, device, electronic equipment and storage medium - Google Patents

Message communication method, device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117579512A
CN117579512A CN202311611322.5A CN202311611322A CN117579512A CN 117579512 A CN117579512 A CN 117579512A CN 202311611322 A CN202311611322 A CN 202311611322A CN 117579512 A CN117579512 A CN 117579512A
Authority
CN
China
Prior art keywords
message
frame
message frame
abnormal
identifier
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202311611322.5A
Other languages
Chinese (zh)
Inventor
金剑
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Yusur Technology Co ltd
Original Assignee
Yusur Technology Co ltd
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 Yusur Technology Co ltd filed Critical Yusur Technology Co ltd
Priority to CN202311611322.5A priority Critical patent/CN117579512A/en
Publication of CN117579512A publication Critical patent/CN117579512A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks
    • H04L43/08Monitoring or testing based on specific metrics, e.g. QoS, energy consumption or environmental parameters
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/14Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
    • H04L63/1408Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic by monitoring network traffic
    • H04L63/1425Traffic logging, e.g. anomaly detection
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/40Network security protocols

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Environmental & Geological Engineering (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The embodiment of the application provides a message communication method, a message communication device, electronic equipment and a storage medium. The method comprises the following steps: receiving a plurality of message frames included in the message, respectively checking each message frame, and judging whether the message frame is an abnormal message frame or not; if the message frame is an abnormal message frame, processing the message frame according to the abnormal type of the message frame, and storing the processed message frame through a message storage unit when the processed message frame is obtained; if the message frame is a normal message frame, the message frame is stored through a message storage unit; writing the storage address of the processed message frame with the included abnormal identifier meeting the filtering rule into an address set in an address storage unit according to the abnormal identifier included in the processed message frame, and writing the storage address of the message frame determined to be a normal message frame into the address set; and after receiving a data acquisition request for the message, sending a message frame with a corresponding storage address in an address set to a data receiving end.

Description

Message communication method, device, electronic equipment and storage medium
Technical Field
Embodiments of the present application relate to the field of communications, and in particular, to a method, an apparatus, an electronic device, and a storage medium for message communication.
Background
With the continuous improvement of the communication network bandwidth and the development of the inter-device communication in the directions of multithreading, multi-core, multi-dimension and the like, the message communication between the communication devices and between the communication modules in the communication devices is more frequent, and the occurrence frequency of abnormal message frames is also greatly improved, so that the stability of the communication devices is greatly affected. In the related art, when an abnormal message frame is encountered, the abnormal message frame is generally discarded directly so as not to cause adverse effects on the communication equipment, but the abnormal message frame is discarded directly so as to cause a large amount of data loss, thereby causing great loss for users.
Disclosure of Invention
In view of the foregoing, embodiments of the present application provide a method, an apparatus, an electronic device, and a storage medium for message communication, so as to solve the foregoing problems.
According to a first aspect of an embodiment of the present application, there is provided a message communication method, including: receiving a plurality of message frames included in a message, and respectively checking each message frame to judge whether the message frame is an abnormal message frame or not; if the message frame is an abnormal message frame, processing the message frame according to the abnormal type of the message frame, and storing the processed message frame through a message storage unit when the processed message frame is obtained; if the message frame is a normal message frame, storing the message frame through a message storage unit; writing the storage address of the processed message frame, which meets the filtering rule, into an address set in an address storage unit according to an abnormal identifier included in the processed message frame, and writing the storage address of the message frame, which is determined to be a normal message frame, into the address set, wherein the abnormal identifier is used for indicating the abnormal type of the message frame; and after receiving a data acquisition request for the message, sending a message frame corresponding to a storage address in the address set to a data receiving end according to the data acquisition request.
In one possible implementation manner, the processing the message frame according to the anomaly type of the message frame includes: if the message frame lacks the frame header identification, discarding the message frame; and/or if the message frame comprises a plurality of connected frame head identifiers, deleting the frame head identifier before the last frame head identifier in the message frame, and adding a first abnormal identifier in the message frame to obtain the processed message frame, wherein the first abnormal identifier is an abnormal identifier indicating that the message frame comprises a plurality of connected frame head identifiers.
In one possible implementation manner, the processing the message frame according to the anomaly type of the message frame includes: if the message frame lacks the frame tail identifier, adding the frame tail identifier to the last of the message frame, and adding a second abnormal identifier to the message frame to obtain a processed message frame; and/or if the message frame comprises a plurality of connected frame tail identifiers, deleting the frame tail identifier after the first frame tail identifier in the frame tail identifiers, and adding a third abnormal identifier in the message frame to obtain a processed message frame; the second abnormal identifier is an abnormal identifier indicating that the message frame lacks a frame end identifier, and the third abnormal identifier is an abnormal identifier indicating that the message frame comprises a plurality of connected frame end identifiers.
In one possible implementation manner, the processing the message frame according to the anomaly type of the message frame includes: if the data length of the message frame is smaller than the length threshold value, adding a fourth abnormal identifier in the message frame to obtain the processed message frame, wherein the fourth abnormal identifier is an abnormal identifier indicating that the data length of the message frame is smaller than the length threshold value.
In one possible implementation manner, the processing the message frame according to the anomaly type of the message frame includes: if the data length of the message frame is greater than the length threshold, discarding the part exceeding the length threshold after the frame head identification of the message frame, and adding a frame tail identification and a fifth abnormal identification for the rest part of the message frame to obtain the processed message frame; the fifth anomaly identification is an anomaly identification indicating that the data length of the message frame is greater than the length threshold.
In one possible implementation manner, when obtaining the processed message frame, storing the processed message frame through a message storage unit includes: after the processed message frame is obtained, deleting a frame head identifier and a frame tail identifier of the processed message frame to obtain a first message frame field, and storing the first message frame field through a message storage unit; and if the message frame is a normal message frame, storing the message frame by a message storage unit, including: and if the message frame is a normal message frame, deleting the frame head identifier and the frame tail identifier of the message frame to obtain a second message frame field, and storing the second message frame field through a message storage unit.
In one possible implementation, the method further includes: detecting the read-write state of the message storage unit, and if the ratio of the read speed of the message storage unit to the write speed of the message storage unit is smaller than a preset threshold value, discarding the message frame meeting the preset discarding condition
According to a second aspect of an embodiment of the present application, there is provided a packet communication device, including: the receiving judging module is used for receiving a plurality of message frames included in the message, and respectively checking each message frame to judge whether the message frame is an abnormal message frame or not; the first storage module is used for processing the message frame according to the abnormal type of the message frame when the message frame is an abnormal message frame, and storing the processed message frame through the message storage unit when the processed message frame is obtained; when the message frame is a normal message frame, storing the message frame through a message storage unit; the second storage module is used for writing the storage address of the processed message frame, which is included by the abnormal identification and meets the filtering rule, into an address set in an address storage unit according to the abnormal identification included by the processed message frame, and writing the storage address of the message frame, which is determined to be a normal message frame, into the address set, wherein the abnormal identification is used for indicating the abnormal type of the message frame; and the transmission module is used for transmitting the message frame with the corresponding storage address in the address set to the data receiving end according to the data acquisition request after receiving the data acquisition request for the message.
According to a third aspect of embodiments of the present application, there is provided an electronic device, including: the device comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete communication with each other through the communication bus; the memory is configured to store at least one executable instruction that causes the processor to perform the method according to any embodiment of the first aspect.
According to a fourth aspect of embodiments of the present application, there is provided a computer storage medium having stored thereon a computer program which, when executed by a processor, implements a method as described in any of the embodiments of the first aspect above.
In the embodiment of the application, after detecting the message frames in the message and finding the abnormal message frames, the message frames are processed according to the abnormal types of the message frames, so that the processed message frames which can be read normally can be obtained, and therefore all abnormal message frames are not required to be discarded, and then the storage addresses of the message frames in the processed message frames can be determined to be written into the address set in the address storage unit according to the filtering rule, so that after receiving a data acquisition request for the message, the message frames can be sent to the data receiving end, the data loss in heat preservation transmission is reduced, and the large loss caused to a user is avoided.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following description will briefly introduce the drawings that are required to be used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are only some embodiments described in the embodiments of the present application, and other drawings may also be obtained according to these drawings for a person having ordinary skill in the art.
Fig. 1 is a step flowchart of a message communication method provided in an embodiment of the present application;
FIG. 2 is a schematic flow chart of detecting and processing a message frame according to an embodiment of the present application;
FIG. 3 is a schematic flow chart of detecting and processing a message frame according to another embodiment of the present application;
FIG. 4 is a schematic flow chart of detecting and processing a message frame according to another embodiment of the present application;
fig. 5 is a schematic diagram of a data processing flow of a message communication method according to an embodiment of the present application;
fig. 6 is a block diagram of a message communication apparatus according to an embodiment of the present application;
fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application;
Detailed Description
In order to better understand the technical solutions in the embodiments of the present application, the following descriptions will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only some embodiments of the present application, but not all embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the embodiments of the present application shall fall within the scope of protection of the embodiments of the present application.
The terminology used in the present application is for the purpose of describing particular embodiments only and is not intended to be limiting of the present application. As used in this application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise. It should also be understood that the term "and/or" as used herein refers to and encompasses any or all possible combinations of one or more of the associated listed items.
It should be understood that although the terms first, second, third, etc. may be used herein to describe various information, these information should not be limited by these terms. For example, a first message may also be referred to as a second message, and similarly, a second message may also be referred to as a first message, without departing from the scope of the present application. The word "if" as used herein may be interpreted as "at … …" or "at … …" or "responsive to a determination", depending on the context.
A first aspect of the embodiments of the present application provides a method for message communication, so as to solve the foregoing problem.
As shown in fig. 1, the message communication method provided in the embodiment of the present application includes:
s101: and receiving a plurality of message frames included in the message, and respectively checking each message frame to judge whether the message frame is an abnormal message frame or not.
In the embodiment of the application, whether the message frame is abnormal or not can be judged by detecting the frame head, the frame tail and the data volume contained in the message frame. It should be understood that, in this application, a packet frame is a Data frame (Data frame) that includes three parts, namely, a frame header, a Data portion, and a frame tail. Wherein the frame header and frame trailer may contain some necessary control information such as synchronization information, address information, error control information, etc.; the data portion includes message data included in the message frame. The specific structure of the message frame may refer to the related art, and will not be described herein.
S102: if the message frame is an abnormal message frame, the message frame is processed according to the abnormal type of the message frame, and when the processed message frame is obtained, the processed message frame is stored by a message storage unit.
When the message frame is found to be abnormal, the embodiment of the application can process the message frame according to the abnormal type of the message frame. For example, the message frame may be subjected to corresponding repair processing according to the anomaly type of the message frame, so that the message frame may be normally processed in a subsequent operation, and an anomaly identifier may be further added to the message frame to label the anomaly type of the message frame. The message storage unit and the following address storage unit may be a storage device such as a random access memory (Random Access Memory, RAM), a floppy disk, a hard disk, or a magneto-optical disk, or other suitable storage devices, which are all within the scope of the embodiments of the present application.
S103: and if the message frame is a normal message frame, storing the message frame through a message storage unit.
S104: writing the storage address of the processed message frame with the included abnormal identifier meeting the filtering rule into an address set in an address storage unit according to the abnormal identifier included in the processed message frame, and writing the storage address of the message frame determined to be a normal message frame into the address set, wherein the abnormal identifier is used for indicating the abnormal type of the message frame.
The filtering rules may indicate which memory addresses of the message frames corresponding to the anomaly identifications are written to the address set within the address memory location. When the storage address is written into the address set of the address storage unit, the message frame corresponding to the address is sent to the lower data receiving end, so that the filtering rule can be set to set which processed message frames corresponding to abnormal types can be sent to the lower data receiving end, and the lost message data is reduced; and setting which processed message frames corresponding to the abnormal types can be discarded, so that the efficiency of message transmission is improved. The filtering rules in the embodiment of the application can be set according to the requirements of the user, so that the requirements of the user can be better met, and the user experience is improved.
S105: after receiving the data acquisition request for the message, sending a message frame with a corresponding storage address in an address set to a data receiving end according to the data acquisition request.
The data acquisition request may indicate a data receiving end that receives the above-mentioned message. After receiving the data acquisition request, the address storage unit may read the storage address written in the address set in step S104, and according to the storage address, read the corresponding message frame from the message storage unit. And then the message frame with the corresponding storage address in the address set can be sent to the data receiving end. In this embodiment of the present application, the storage address of the message frame may include information such as a start address, an end address, and a data length stored in the message storage unit by the message frame, so that the stored message frame can be read from the message storage unit according to the storage address.
In the embodiment of the application, after detecting the message frames in the message and finding the abnormal message frames, the message frames are processed according to the abnormal types of the message frames, so that the processed message frames which can be read normally can be obtained, and therefore all abnormal message frames are not required to be discarded, and then the storage addresses of the message frames in the processed message frames can be determined to be written into the address set in the address storage unit according to the filtering rule, so that after receiving a data acquisition request for the message, the message frames can be sent to the data receiving end, the data loss in heat preservation transmission is reduced, and the large loss caused to a user is avoided.
It should be understood that the message communication method provided in the embodiment of the present application may be applied to communication devices such as switches and routers, and electronic terminals such as mobile phones and computers that may perform communication, and other external communication modules, which are all within the protection scope of the embodiment of the present application.
In some alternative embodiments, processing the message frame according to the anomaly type of the message frame includes: if the message frame lacks the frame header identification, the message frame is discarded; and/or if the message frame comprises a plurality of connected frame head identifiers, deleting the frame head identifier before the last frame head identifier in the message frame, and adding a first abnormal identifier in the message frame to obtain the processed message frame, wherein the first abnormal identifier is used for indicating that the message frame comprises a plurality of connected frame head identifiers.
The frame Header identifier (SOH) is a marker character located at the beginning Of the frame in the message frame, and the end Of frame identifier (EOT, end Of Transmission) is a marker character located at the last position Of the frame in the message frame, and is used to mark the beginning and end Of the message frame, respectively. The specific setting modes of the frame header identifier and the frame tail identifier can refer to related technologies, and are not repeated herein, and are all within the protection scope of the embodiments of the present application.
As shown in fig. 2, in the embodiment of the present application, after receiving a packet frame included in a packet, frame header identification detection may be performed on the packet frame. If the message frame lacks the frame header identification, discarding the message frame; if the message frame comprises a plurality of connected frame head identifiers, redundant frame head identifiers can be removed, and a first abnormal identifier is added, so that the processed message frame is obtained. Specifically, removing redundant frame header identifiers may delete the frame header identifier before the last frame header identifier, and only the last frame header identifier in the connected frame header identifiers is reserved.
Because the frame head identifier of the message frame is absent, the starting position of the message frame cannot be determined, and thus the message frame cannot be normally analyzed according to the frame head of the message frame. When the message frame is determined to comprise a plurality of connected frame head identifiers, redundant frame head identifiers can be deleted, so that the abnormal condition that the message frame comprises a plurality of connected frame head identifiers is repaired, the data in the message frame can be reserved later, and the loss condition of the data is reduced. In addition, the embodiment of the application can also mark the abnormal type that the message frame comprises a plurality of connected frame head identifiers through the first abnormal identifier, and can simply and conveniently determine the abnormal condition that the message frame comprises a plurality of connected frame head identifiers in the subsequent process through the first abnormal identifier, so that the efficiency of checking the message frame is improved.
In some alternative embodiments, processing the message frame according to the anomaly type of the message frame includes: if the message frame lacks the frame tail mark, adding the frame tail mark at the last of the message frame, and adding a second abnormal mark in the message frame to obtain a processed message frame; and/or if the message frame comprises a plurality of connected frame tail identifiers, deleting the frame tail identifier after the first frame tail identifier in the frame tail identifiers, and adding a third abnormal identifier in the message frame to obtain the processed message frame; the second abnormal identifier is an abnormal identifier indicating that the message frame lacks a frame end identifier, and the third abnormal identifier is an abnormal identifier indicating that the message frame comprises a plurality of connected frame end identifiers.
As shown in fig. 3, in the embodiment of the present application, after receiving a message frame included in a message, frame end identification detection may be performed on the message frame. If the message frame lacks the frame tail identifier, a second abnormal identifier and a frame tail identifier can be added at the end of the message frame; if the message frame comprises a plurality of connected frame tail identifiers, redundant frame tail identifiers can be removed, and a third abnormal identifier can be added, so that the processed message frame is obtained. Specifically, removing the redundant end-of-frame identifiers may delete the end-of-frame identifier after the first end-of-frame identifier, and only the first end-of-frame identifier in the connected end-of-frame identifiers is reserved.
In the embodiment of the application, when the frame end identifier of the message frame is determined to be absent, the frame end identifier is added to the last of the message frame, so that the abnormal condition that the frame end identifier of the message frame is absent is repaired; when the message frame is determined to comprise a plurality of connected frame head identifiers, redundant frame tail identifiers can be deleted, so that the abnormal situation that the message frame comprises a plurality of connected frame head identifiers is repaired; the processed message frames corresponding to the two abnormal types of message frames can be reserved later, so that the loss condition of data is reduced. In addition, the embodiment of the application can also mark the abnormal type of the message frame lacking the frame tail mark through the second abnormal mark, and mark the abnormal type of the message frame comprising a plurality of connected frame tail marks through the third abnormal mark, so that the two abnormal conditions can be simply and conveniently determined through the second abnormal mark and the third abnormal mark in the subsequent process, and the efficiency of checking the message frame is improved.
In some alternative embodiments, processing the message frame according to the anomaly type of the message frame includes: if the data length of the message frame is smaller than the length threshold value, a fourth abnormal identifier is added in the message frame to obtain the processed message frame, wherein the fourth abnormal identifier is an abnormal identifier indicating that the data length of the message frame is smaller than the length threshold value. And/or if the data length of the message frame is greater than the length threshold, discarding the part exceeding the length threshold after the frame head identification of the message frame, and adding a frame tail identification and a fifth abnormal identification to the rest part of the message frame to obtain the processed message frame; the fifth anomaly identification is an anomaly identification indicating that the data length of the message frame is greater than a length threshold value.
As shown in fig. 4, in the embodiment of the present application, after receiving a packet frame included in a packet, data length detection may be performed on the packet frame. If the data length of the message frame is smaller than the length threshold, the message frame can be temporarily not deleted, and a fourth abnormal identifier is added in the message frame to obtain the processed message frame; if the data length of the message frame is greater than the length threshold, the data shortening treatment can be performed on the message frame, for example, the part exceeding the length threshold after the frame head of the message frame is identified is discarded/deleted, and then the frame tail identification and the fifth abnormal identification can be added to the rest part of the message frame, so as to obtain the treated message frame. The length threshold may be determined according to a maximum number of bytes that can be transmitted by the device at one time in the packet transmission process, for example, the length threshold may be smaller than the maximum number of bytes, so that the data length of the processed packet frame obtained after adding the fifth exception identifier and the frame tail identifier does not exceed the maximum number of bytes.
In the embodiment of the present application, when it is determined that the data length of the packet frame is less than the length threshold, the packet frame may not be temporarily deleted, and a fourth abnormal identifier is added to the packet frame, so as to obtain a processed packet frame for subsequent use; when the data length of the message frame is determined to be greater than the length threshold, the part exceeding the length threshold after the frame head of the message frame is identified can be discarded, the data in the message frame is reduced, and the processed message frame is obtained, so that the processed message frame can be conveniently and normally transmitted. Therefore, the embodiment can reserve the processed message frames corresponding to the two abnormal types of message frames, thereby reducing the loss condition of data. In addition, the embodiment of the application can also mark the abnormal type of which the data length of the message frame is smaller than the length threshold value through the fourth abnormal identifier, and mark the abnormal type of which the data length of the message frame is larger than the length threshold value through the fifth abnormal identifier, so that the two abnormal conditions can be simply and conveniently determined through the fourth abnormal identifier and the fifth abnormal identifier in the subsequent process, and the efficiency of checking the message frame is improved.
In some optional embodiments, when obtaining the processed message frame, storing the processed message frame by the message storage unit includes: after the processed message frame is obtained, deleting the frame head mark and the frame tail mark of the processed message frame to obtain a first message frame field, and storing the first message frame field through a message storage unit.
And if the message frame is a normal message frame, storing the message frame by a message storage unit, including: if the message frame is a normal message frame, deleting the frame header identifier and the frame tail identifier of the message frame to obtain a second message frame field, and storing the second message frame field through a message storage unit.
It should be understood that in the process of sending the message frame with the corresponding storage address in the address set to the data receiving end according to the data acquisition request, the frame header identifier and the frame tail identifier may be added to the first message frame field and the second message frame field again, so as to obtain the previous processed message frame and the message frame determined to be the normal message frame, so as to send the processed message frame and the message frame determined to be the normal message frame to the data receiving end.
In the embodiment of the application, when the processed message frame and the normal message frame are stored, the frame head mark and the frame tail mark of the processed message frame and the normal message frame can be deleted, so that the storage space occupied by the processed message frame and the normal message frame is saved, and the utilization rate of the message storage unit is improved.
In order to facilitate understanding of the flow of packet processing according to the embodiments of the present application, the method provided in the present application is described below with reference to an alternative embodiment shown in fig. 5.
As shown in fig. 5, after receiving a message frame of a message, message frame detection may include frame header identification detection, frame tail identification detection, and data length detection, and after detecting that the message frame is an abnormal message frame, abnormal frame processing may be performed, including frame header abnormal processing, frame tail abnormal processing, frame length abnormal processing, and the like. It should be appreciated that frame header anomalies include a lack of a frame header identifier and include a plurality of concatenated frame header identifiers, etc., frame end anomalies include a lack of a frame end identifier and include a plurality of concatenated frame end identifiers, etc., and frame length anomalies include data lengths less than or greater than a length threshold, etc. After the processed message frame is obtained, a storage address is generated for the processed message frame.
If the message frame detection is performed to determine that the message frame is a normal message frame, a storage address can be directly generated for the message frame.
After generating the storage address, storing the message frame according to the storage address, that is, storing the processed message frame and the message frame determined to be the normal message frame into the message storage unit according to the storage address, wherein it should be understood that the storage addresses in the embodiment of the present application are all storage addresses corresponding to the storage area in the message storage unit; and filtering the storage address according to the filtering rule, namely selecting the storage address of the message frame which is determined to be the normal message frame, and selecting the storage address of the processed message frame which meets the filtering rule according to the filtering rule by the abnormal identifier.
After the message frame address filtering, address storage can be performed according to the selected storage address, namely, the storage address of the message frame determined to be the normal message frame is written into the address set in the address storage unit, and the storage address of the processed message frame including the abnormal identifier meeting the filtering rule is written into the address set in the address storage unit.
After receiving the data acquisition request for the message, according to the data acquisition request, acquiring a storage address from an address set in an address storage unit, and according to the acquired storage address, acquiring storage data of the storage address from the message storage unit, thereby acquiring a message frame corresponding to the storage address, and transmitting the acquired message frame to a data receiving end indicated by the data acquisition request. Reference may be made to the above embodiments for specific implementation of the embodiments of the present application, and details are not repeated here.
As an optional implementation manner, the message communication method provided in the embodiment of the present application may further include: and detecting the read-write state of the message storage unit, and if the ratio of the read speed of the message storage unit to the write speed of the message storage unit is smaller than a preset threshold value, discarding the message frame meeting the preset discarding condition.
The preset discard condition is used for indicating which type of message frame is discarded, for example, message frames with longer data length can be discarded, or some abnormal message frames can be discarded, so as to reduce the data quantity required to be stored by the message storage unit. It should be understood that the method provided in the embodiments of the present application may include detecting the data length of the packet frame, so as to identify the packet frame with a longer data length. When the message frames meeting the preset discarding conditions are discarded, the message frames meeting the preset discarding conditions can be discarded before being stored in the message storage unit, or the message frames meeting the preset discarding conditions can be discarded through discarding the storage addresses of the message frames meeting the preset discarding conditions after being stored in the message storage unit, which are all within the protection scope of the embodiment of the application. The preset threshold value can be set according to the read-write capability of the message storage unit, so that the storage unit can maintain a relatively high read-write speed.
It should be noted that, in some alternative embodiments, the flow of the message may also be detected, and if the flow of the message is greater than the flow threshold, the message frame meeting the above-mentioned preset dropping condition is dropped. The flow threshold value can also be set according to the read-write capability of the message storage unit, so that the storage unit can maintain a relatively high read-write speed.
When a message is transmitted, the condition of overlarge message flow is frequently encountered, and the overlarge message flow can cause the reduction of the reading speed of a message storage unit, thereby obviously influencing the efficiency of the message transmission. According to the method and the device, the reading and writing states of the message storage unit can be detected, when the ratio of the reading speed of the message storage unit to the writing speed of the message storage unit is smaller than the preset threshold value, before the storage address is stored through the address storage unit, the message frame meeting the preset discarding condition is discarded, so that the reading operation of the message storage unit is reduced, the reading speed of the message storage unit is improved, and the influence of overlarge message flow on the message transmission efficiency is reduced. And the method can selectively discard some message frames without discarding all the message frames by setting the condition meeting the preset discard condition, thereby increasing the flexibility of message transmission and reducing the lost data.
According to a third aspect of the embodiments of the present application, as shown in fig. 6, there is provided a packet communication device, including:
the receiving judging module 601 is configured to receive a plurality of message frames included in the message, and respectively check each message frame to determine whether the message frame is an abnormal message frame;
the first storage module 602 is configured to process the message frame according to the abnormal type of the message frame when the message frame is an abnormal message frame, and store the processed message frame through the message storage unit when the processed message frame is obtained; when the message frame is a normal message frame, the message frame is stored by a message storage unit;
the second storage module 603 is configured to write, according to an anomaly identifier included in the processed packet frame, a storage address of the processed packet frame that includes the anomaly identifier that satisfies a filtering rule into an address set in the address storage unit, and write, into the address set, a storage address of the packet frame determined to be a normal packet frame, where the anomaly identifier is used to indicate an anomaly type of the packet frame;
and the transmission module 604 is configured to send a message frame with a corresponding storage address in the address set to the data receiving end according to the data acquisition request after receiving the data acquisition request for the message.
In some optional embodiments, the first storage module is configured to discard the packet frame when the packet frame lacks a frame header identifier; and/or deleting the frame header mark before the last frame header mark in the message frame when the message frame comprises a plurality of connected frame header marks, and adding a first abnormal mark in the message frame to obtain the processed message frame, wherein the first abnormal mark is an abnormal mark indicating that the message frame comprises a plurality of connected frame header marks.
In some optional embodiments, the first storage module is configured to, when the message frame lacks a frame end identifier, add a frame end identifier to the last message frame, and add a second abnormal identifier to the message frame, to obtain a processed message frame; and/or deleting the frame tail mark after the first frame tail mark in the frame tail marks when the message frame comprises a plurality of connected frame tail marks, and adding a third abnormal mark in the message frame to obtain the processed message frame; the second abnormal identifier is an abnormal identifier indicating that the message frame lacks a frame end identifier, and the third abnormal identifier is an abnormal identifier indicating that the message frame comprises a plurality of connected frame end identifiers.
In some optional embodiments, the first storage module is configured to add a fourth anomaly identifier to the message frame when the data length of the message frame is less than the length threshold, to obtain a processed message frame, where the fourth anomaly identifier is an anomaly identifier indicating that the data length of the message frame is less than the length threshold.
In some optional embodiments, when the data length of the message frame is greater than the length threshold, the first storage module is configured to discard a portion exceeding the length threshold after the frame header identifier of the message frame, and add a frame tail identifier and a fifth abnormal identifier to the remaining portion of the message frame, so as to obtain a processed message frame; the fifth anomaly identification is an anomaly identification indicating that the data length of the message frame is greater than a length threshold value.
In some optional embodiments, the first storage module is further configured to delete a frame header identifier and a frame tail identifier of the processed packet frame after obtaining the processed packet frame, obtain a first packet frame field, and store the first packet frame field through the packet storage unit; after the message frame is determined to be a normal message frame, deleting the frame header identifier and the frame tail identifier of the message frame to obtain a second message frame field, and storing the second message frame field through a message storage unit.
In some optional embodiments, the message communication device further includes a read-write detection module, configured to detect a read-write state of the message storage unit, and if a ratio of a read speed of the message storage unit to a write speed of the message storage unit is less than a preset threshold, discard a message frame that meets a preset discard condition.
The message communication device provided in the embodiment of the present application and the foregoing embodiment of the message communication method are based on the same inventive concept, so that the same effects can be achieved, and the specific implementation process can be referred to the description in the foregoing embodiment of the data storage method, which is not repeated here.
According to a third aspect of embodiments of the present application, there is also provided an electronic device. The method comprises the following steps: referring to fig. 7, a schematic structural diagram of an electronic device according to an embodiment of the present application is shown, and the specific embodiment of the present application is not limited to a specific implementation of the electronic device.
As shown in fig. 7, the electronic device may include: a processor 702, a communication interface (Communications Interface), a memory 706, and a communication bus 708.
Wherein:
processor 702, communication interface 704, and memory 706 perform communication with each other via a communication bus 708.
Communication interface 704 for communicating with other electronic devices or servers.
The processor 702 is configured to execute the program 710, and may specifically perform relevant steps in the foregoing message communication method embodiment.
In particular, program 710 may include program code including computer-operating instructions.
The processor 702 may be a CPU or a specific integrated circuit ASIC (Application Specific Integrated Circuit) or one or more integrated circuits configured to implement embodiments of the present application. The one or more processors comprised by the smart device may be the same type of processor, such as one or more CPUs; but may also be different types of processors such as one or more CPUs and one or more ASICs.
Memory 706 for storing programs 710. The memory 706 may comprise high-speed RAM memory or may further comprise non-volatile memory (non-volatile memory), such as at least one disk memory.
The program 710 may include a plurality of computer instructions, and the program 710 may specifically enable the processor 702 to perform operations corresponding to the packet communication method described in any one of the foregoing method embodiments through the plurality of computer instructions.
The specific implementation of each step in the program 710 may refer to the corresponding steps and corresponding descriptions in the units in the above method embodiments, and have corresponding beneficial effects, which are not described herein. It will be clear to those skilled in the art that, for convenience and brevity of description, specific working procedures of the apparatus and modules described above may refer to corresponding procedure descriptions in the foregoing method embodiments, which are not repeated herein.
The present application also provides a computer storage medium having stored thereon a computer program which, when executed by a processor, implements the method described in any of the foregoing method embodiments. The computer storage media includes, but is not limited to: a compact disk read Only (Compact Disc Read-Only Memory, CD-ROM), random access Memory (Random Access Memory, RAM), floppy disk, hard disk, magneto-optical disk, or the like.
It should be noted that, according to implementation requirements, each component/step described in the embodiments of the present application may be split into more components/steps, and two or more components/steps or part of operations of the components/steps may be combined into new components/steps, so as to achieve the purposes of the embodiments of the present application.
Those of ordinary skill in the art will appreciate that the elements and method steps of the examples described in connection with the embodiments disclosed herein can be implemented as electronic hardware, or as a combination of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the embodiments of the present application.
The above embodiments are only for illustrating the embodiments of the present application, but not for limiting the embodiments of the present application, and various changes and modifications can be made by one skilled in the relevant art without departing from the spirit and scope of the embodiments of the present application, so that all equivalent technical solutions also fall within the scope of the embodiments of the present application, and the scope of the embodiments of the present application should be defined by the claims.

Claims (10)

1. A method of communicating messages, comprising:
receiving a plurality of message frames included in a message, and respectively checking each message frame to judge whether the message frame is an abnormal message frame or not;
if the message frame is an abnormal message frame, processing the message frame according to the abnormal type of the message frame, and storing the processed message frame through a message storage unit when the processed message frame is obtained;
if the message frame is a normal message frame, storing the message frame through a message storage unit;
writing the storage address of the processed message frame, which meets the filtering rule, into an address set in an address storage unit according to an abnormal identifier included in the processed message frame, and writing the storage address of the message frame, which is determined to be a normal message frame, into the address set, wherein the abnormal identifier is used for indicating the abnormal type of the message frame;
and after receiving a data acquisition request for the message, sending a message frame corresponding to a storage address in the address set to a data receiving end according to the data acquisition request.
2. The method according to claim 1, wherein the processing the message frame according to the anomaly type of the message frame comprises:
if the message frame lacks the frame header identification, discarding the message frame; and/or the number of the groups of groups,
if the message frame comprises a plurality of connected frame head identifiers, deleting the frame head identifier before the last frame head identifier in the message frame, and adding a first abnormal identifier in the message frame to obtain the processed message frame, wherein the first abnormal identifier is an abnormal identifier indicating that the message frame comprises a plurality of connected frame head identifiers.
3. The method according to claim 1, wherein the processing the message frame according to the anomaly type of the message frame comprises:
if the message frame lacks the frame tail identifier, adding the frame tail identifier to the last of the message frame, and adding a second abnormal identifier to the message frame to obtain a processed message frame; and/or the number of the groups of groups,
if the message frame comprises a plurality of connected frame tail identifiers, deleting the frame tail identifier after the first frame tail identifier in the frame tail identifiers, and adding a third abnormal identifier in the message frame to obtain a processed message frame;
the second abnormal identifier is an abnormal identifier indicating that the message frame lacks a frame end identifier, and the third abnormal identifier is an abnormal identifier indicating that the message frame comprises a plurality of connected frame end identifiers.
4. The method according to claim 1, wherein the processing the message frame according to the anomaly type of the message frame comprises:
if the data length of the message frame is smaller than the length threshold value, adding a fourth abnormal identifier in the message frame to obtain the processed message frame, wherein the fourth abnormal identifier is an abnormal identifier indicating that the data length of the message frame is smaller than the length threshold value.
5. The method according to claim 1, wherein the processing the message frame according to the anomaly type of the message frame comprises:
if the data length of the message frame is greater than the length threshold, discarding the part exceeding the length threshold after the frame head identification of the message frame, and adding a frame tail identification and a fifth abnormal identification for the rest part of the message frame to obtain the processed message frame; the fifth anomaly identification is an anomaly identification indicating that the data length of the message frame is greater than the length threshold.
6. The method according to any one of claims 2 to 5, wherein storing the processed message frame by a message storage unit when the processed message frame is obtained, comprises:
after the processed message frame is obtained, deleting a frame head identifier and a frame tail identifier of the processed message frame to obtain a first message frame field, and storing the first message frame field through a message storage unit;
and if the message frame is a normal message frame, storing the message frame by a message storage unit, including:
and if the message frame is a normal message frame, deleting the frame head identifier and the frame tail identifier of the message frame to obtain a second message frame field, and storing the second message frame field through a message storage unit.
7. The method for message communication according to any one of claims 6, further comprising:
detecting the read-write state of the message storage unit, and if the ratio of the read speed of the message storage unit to the write speed of the message storage unit is smaller than a preset threshold value, discarding the message frame meeting the preset discarding condition.
8. A message communication apparatus, comprising:
the receiving judging module is used for receiving a plurality of message frames included in the message, and respectively checking each message frame to judge whether the message frame is an abnormal message frame or not;
the first storage module is used for processing the message frame according to the abnormal type of the message frame when the message frame is an abnormal message frame, and storing the processed message frame through the message storage unit when the processed message frame is obtained; when the message frame is a normal message frame, storing the message frame through a message storage unit;
the second storage module is used for writing the storage address of the processed message frame, which is included by the abnormal identification and meets the filtering rule, into an address set in an address storage unit according to the abnormal identification included by the processed message frame, and writing the storage address of the message frame, which is determined to be a normal message frame, into the address set, wherein the abnormal identification is used for indicating the abnormal type of the message frame;
and the transmission module is used for transmitting the message frame with the corresponding storage address in the address set to the data receiving end according to the data acquisition request after receiving the data acquisition request for the message.
9. An electronic device, comprising: the device comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete communication with each other through the communication bus;
the memory is configured to hold at least one executable instruction that causes the processor to perform the method of any one of claims 1-7.
10. A computer storage medium having stored thereon a computer program which, when executed by a processor, implements the method of any of claims 1-7.
CN202311611322.5A 2023-11-29 2023-11-29 Message communication method, device, electronic equipment and storage medium Pending CN117579512A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311611322.5A CN117579512A (en) 2023-11-29 2023-11-29 Message communication method, device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311611322.5A CN117579512A (en) 2023-11-29 2023-11-29 Message communication method, device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117579512A true CN117579512A (en) 2024-02-20

Family

ID=89889778

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311611322.5A Pending CN117579512A (en) 2023-11-29 2023-11-29 Message communication method, device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117579512A (en)

Similar Documents

Publication Publication Date Title
CN114710224A (en) Frame synchronization method and device, computer readable medium and electronic device
US11444891B2 (en) Electronic control unit, abnormality determination program, and abnormality determination method
CN111541521B (en) Data packet length identification method and system
CN112040001A (en) Request processing method and device based on distributed storage
CN112667527A (en) Method for ensuring data acquisition accuracy of client and client
CN106373616B (en) Method and device for detecting faults of random access memory and network processor
CN113645140B (en) Message statistical method, device, storage medium and network equipment
CN108228476B (en) Data acquisition method and device
CN117579512A (en) Message communication method, device, electronic equipment and storage medium
CN113420035A (en) Data processing method, system, device, electronic equipment and computer storage medium
CN113973091A (en) Message processing method, network equipment and related equipment
CN115934338A (en) Inter-process communication method and device
CN115811516A (en) Method, device, equipment and medium for concurrently reporting multi-frame files
CN113157465B (en) Message sending method and device based on pointer linked list
CN113641604A (en) Data transmission method and system
CN114679425B (en) Message processing method, network equipment and storage medium under 5G network
CN113377522A (en) Method and device for processing memory blocks in memory pool, electronic equipment and storage medium
CN115878351B (en) Message transmission method and device, storage medium and electronic device
CN114520790B (en) Message filtering method and device
CN116055418B (en) Method and device for transmitting Ethernet data, electronic equipment and storage medium
CN117527529B (en) Ethernet data storage method and device capable of automatically recovering from normal state
CN114401223B (en) Information processing device and method
CN111651481B (en) Log processing method, device, equipment and computer readable storage medium
CN118118433A (en) Message processing method and device applied to DPU, computer equipment and storage medium
CN114629824B (en) Packet loss positioning method, device, computing equipment and medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination