CN107733556B - Message checking method and device - Google Patents

Message checking method and device Download PDF

Info

Publication number
CN107733556B
CN107733556B CN201610666355.3A CN201610666355A CN107733556B CN 107733556 B CN107733556 B CN 107733556B CN 201610666355 A CN201610666355 A CN 201610666355A CN 107733556 B CN107733556 B CN 107733556B
Authority
CN
China
Prior art keywords
message
header
check
complete
length
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.)
Active
Application number
CN201610666355.3A
Other languages
Chinese (zh)
Other versions
CN107733556A (en
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.)
Beijing Aiqi Technology Co ltd
Beijing Xiaomi Mobile Software Co Ltd
Original Assignee
Beijing Aiqi Technology Co ltd
Beijing Xiaomi Mobile Software 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 Beijing Aiqi Technology Co ltd, Beijing Xiaomi Mobile Software Co Ltd filed Critical Beijing Aiqi Technology Co ltd
Priority to CN201610666355.3A priority Critical patent/CN107733556B/en
Publication of CN107733556A publication Critical patent/CN107733556A/en
Application granted granted Critical
Publication of CN107733556B publication Critical patent/CN107733556B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/004Arrangements for detecting or preventing errors in the information received by using forward error control
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L1/00Arrangements for detecting or preventing errors in the information received
    • H04L1/004Arrangements for detecting or preventing errors in the information received by using forward error control
    • H04L1/0056Systems characterized by the type of code used
    • H04L1/0061Error detection codes
    • H04L1/0063Single parity check

Abstract

The disclosure relates to a message checking method and a message checking device, and belongs to the technical field of communication. The method comprises the following steps: performing header check on the received header; if the header passes the header check, receiving the complete message; carrying out tail check on the tail of the complete message; and if the tail is verified through tail verification, performing data verification on the message data according to the verification bits contained in the complete message. The embodiment of the disclosure solves the problems that in the related art, after a complete message needs to be received, the message data can be checked only according to the check bits in the message, the check efficiency is low, and the safety and the reliability are poor; the method achieves the effect of verifying the message by using three verification modes of header verification, trailer verification and data verification at different stages of message receiving, thereby improving the verification efficiency, safety and reliability of the message.

Description

Message checking method and device
Technical Field
The present disclosure relates to the field of communications technologies, and in particular, to a method and an apparatus for message verification.
Background
In order to improve the security and reliability of message transmission in the communication system, the receiving-side device needs to check the received message.
In the related art, after receiving a complete message sent by a sender device, a receiver device obtains a check bit included in the message, and checks message data included in the message according to the check bit. Common Check methods include an exclusive or Check, a Cyclic Redundancy Check (CRC), a Longitudinal Redundancy Check (LRC), and the like.
Disclosure of Invention
The embodiment of the disclosure provides a message checking method and a device, and the technical scheme is as follows:
according to a first aspect of the embodiments of the present disclosure, a method for checking a packet is provided, where the method includes:
performing header check on the received header;
if the header passes the header check, receiving the complete message;
carrying out tail check on the tail of the complete message;
and if the tail is verified through tail verification, performing data verification on the message data according to the verification bits contained in the complete message.
Optionally, performing header check on the received header, including:
detecting whether the header conforms to a predetermined header format;
if the header conforms to the predetermined header format, it is determined that the header check is passed.
Optionally, the complete message includes a message length, and the message length is used to indicate a total length from the header to the trailer;
the method further comprises the following steps:
acquiring the message length contained in the complete message;
detecting whether the length of the received complete message is consistent with the length of the message;
and if the length of the complete message is consistent with the length of the message, executing a step of carrying out tail check on the tail of the complete message.
Optionally, the tail checking is performed on the tail of the complete message, and the method includes:
determining the position of the tail in the complete message according to the message length;
detecting whether the tail accords with a preset tail format or not;
and if the tail meets the preset tail format, determining that the tail passes the tail check.
Optionally, the complete message includes an i-level message type, the i-level message type is used for indicating the use of the complete message, and i is greater than or equal to 2;
wherein, the j +1 th level message type is the subclass of the j level message type, j is more than or equal to 1 and j +1 is more than or equal to i.
According to a second aspect of the embodiments of the present disclosure, there is provided a packet checking apparatus, including:
a first checking module configured to perform header checking on the received header;
a receiving module configured to receive a complete message when the header passes the header check;
the second check module is configured to perform tail check on the tail of the complete message;
and the third checking module is configured to perform data checking on the message data according to the check bits contained in the complete message when the trailer passes the trailer checking.
Optionally, the first inspection module includes:
a first detection sub-module configured to detect whether the header conforms to a predetermined header format;
a first determining sub-module configured to determine that the header check is passed when the header conforms to a predetermined header format.
Optionally, the complete message includes a message length, and the message length is used to indicate a total length from the header to the trailer;
the device also comprises:
the acquisition module is configured to acquire the message length contained in the complete message;
the fourth checking module is configured to detect whether the length of the received complete message is consistent with the length of the message;
and the second check module is configured to execute a step of performing tail check on the tail of the complete message when the length of the complete message is consistent with the length of the message.
Optionally, the second check module includes:
the second determining submodule is configured to determine the position of the tail in the complete message according to the message length;
a second detection submodule configured to detect whether the trailer complies with a predetermined trailer format;
a third determining submodule configured to determine that the trailer passes the trailer verification when the trailer conforms to the predetermined trailer format.
Optionally, the complete message includes an i-level message type, the i-level message type is used for indicating the use of the complete message, and i is greater than or equal to 2;
wherein, the j +1 th level message type is the subclass of the j level message type, j is more than or equal to 1 and j +1 is more than or equal to i.
According to a third aspect of the embodiments of the present disclosure, there is provided a packet checking apparatus, including:
an MCU (Micro Controller Unit, Micro control Unit);
a memory for storing MCU executable instructions;
wherein the MCU is configured to:
performing header check on the received header;
if the header passes the header check, receiving the complete message;
carrying out tail check on the tail of the complete message;
and if the tail is verified through tail verification, performing data verification on the message data according to the verification bits contained in the complete message.
The technical scheme provided by the embodiment of the disclosure can have the following beneficial effects:
by performing header check on the received header; if the header passes the header check, receiving the complete message; carrying out tail check on the tail of the complete message; if the tail is verified through tail verification, performing data verification on the message data according to the verification bits contained in the complete message; the problems that in the related art, after a complete message needs to be received, the message data can be checked only according to the check bits in the message, the check efficiency is low, and the safety and the reliability are poor are solved; the method achieves the effect of verifying the message by using three verification modes of header verification, trailer verification and data verification at different stages of message receiving, thereby improving the verification efficiency, safety and reliability of the message.
It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and together with the description, serve to explain the principles of the disclosure.
Fig. 1 is a method flow diagram illustrating a message verification method according to an exemplary embodiment of the present disclosure;
FIG. 2 is a method flow diagram illustrating a message verification method according to another exemplary embodiment of the present disclosure;
FIG. 3 is a block diagram illustrating a message checking apparatus according to an exemplary embodiment of the present disclosure;
FIG. 4 is a block diagram illustrating a message checking apparatus according to another example embodiment of the present disclosure;
fig. 5 is a block diagram illustrating a message checking apparatus 500 according to an example embodiment.
Detailed Description
Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, like numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the exemplary embodiments below are not intended to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present disclosure, as detailed in the appended claims.
The message verification method provided by each embodiment of the disclosure is applicable to a System on Chip (SoC) having message transceiving and processing functions, and any content can be transmitted by adopting the message format shown in each embodiment of the disclosure, and a transmission medium (which can be a wireless network, an optical fiber or a twisted pair, etc.) and an MCU (micro control unit) used by the SoC are not limited, so that the method has general applicability.
In a possible implementation manner, the message checking method can be executed by electronic devices such as a smart phone, a tablet computer, an electronic book reader, an MP3 player (Moving Picture Experts Group Audio Layer III, Moving Picture Experts compression standard Audio Layer 3) or an MP4 player (Moving Picture Experts Group Audio Layer IV, Moving Picture Experts compression standard Audio Layer 4); in other possible embodiments, the message checking method may also be performed by a sensor configured with an MCU, which is not limited in this disclosure.
For convenience of description, the following embodiments only use the message verification method for an electronic device as an example for schematic illustration, and do not limit the disclosure.
Fig. 1 is a flowchart illustrating a method of message verification according to an exemplary embodiment of the present disclosure. The embodiment takes the example that the message verification method is applied to the electronic device with message receiving and processing capabilities as an example. The method may include the following steps.
In step 101, a header check is performed on the received header.
The method comprises the steps that in the process of receiving a message, an electronic device firstly obtains a header of the message and checks the header; if the header passes the header check, the electronic device further receives the complete message (i.e. the message content after the header); if the header fails the header check, the electronic device determines that the message does not conform to the predetermined message format and stops receiving subsequent message content.
Compared with the traditional message verification mode, in the embodiment, for some messages obviously not conforming to the message format, the messages can be filtered through header verification, and the messages do not need to be verified through verification bits, so that the message verification pressure of the electronic equipment is reduced.
In step 102, if the header passes the header check, the complete message is received.
In step 103, a trailer check is performed on the trailer of the complete message.
After receiving the complete message, the electronic equipment further checks the tail of the complete message; if the tail of the message passes the verification, the electronic equipment performs data verification on the message data according to the verification bits in the complete message; and if the tail is not verified, the electronic equipment discards the received complete message.
In step 104, if the trailer passes the trailer check, the data check is performed on the message data according to the check bits included in the complete message.
When the message passes through the header check and the trailer check, the electronic equipment checks the message data according to the check bits contained in the complete message, so that the accuracy of the message data is further ensured. The data checking method adopted by the electronic device includes, but is not limited to, xor checking, CRC and LRC.
In summary, the message checking method provided in this embodiment performs header checking on the received header; if the header passes the header check, receiving the complete message; carrying out tail check on the tail of the complete message; if the tail is verified through tail verification, performing data verification on the message data according to the verification bits contained in the complete message; the problems that in the related art, after a complete message needs to be received, the message data can be checked only according to the check bits in the message, the check efficiency is low, and the safety and the reliability are poor are solved; the method achieves the effect of verifying the message by using three verification modes of header verification, trailer verification and data verification at different stages of message receiving, thereby improving the verification efficiency, safety and reliability of the message.
Fig. 2 is a flowchart illustrating a method of message verification according to another exemplary embodiment of the present disclosure. The embodiment takes the example that the message verification method is applied to the electronic device with message receiving and processing capabilities as an example. The method may include the following steps.
In step 201 it is detected whether the received header conforms to a predetermined header format.
The electronic equipment stores a standard message format in advance, detects whether the received message conforms to the standard message format or not in the process of receiving the message, and if the received message conforms to the standard message format, the electronic equipment needs to perform data verification on the message; if the received message does not conform to the standard message format, the electronic equipment determines that the message is an illegal message and directly discards the illegal message. In the embodiments of the present disclosure, the standard message format is as shown in the following table.
Watch 1
Figure BDA0001077674800000061
The message length is used for indicating the total length from the header to the trailer, and the unit is byte or bit; the type of an i-level message contained in the message is used for indicating the purpose of the message, and i is more than or equal to 2; the data content is the effective load of the message; the check bits are used for data checking of each part between the check bits. It should be noted that the length of the header, the type of the packet, and the length of the trailer in the standard packet format are fixed, and the length of the packet, the data content, and the length of the trailer in the standard packet format dynamically change according to the transmitted data content.
The header in the standard message format conforms to a predetermined header format, and the electronic device receives the header of the message first and detects whether the received header conforms to the predetermined header format.
As a possible implementation manner, n header formats (n ≧ 1) are stored in advance in the electronic device, when the header of the message is received, the electronic device detects whether the header matches with one of the n header formats, when the header matches with one of the n header formats, the electronic device determines that the header conforms to the predetermined header format, and performs step 203; when the header does not match any of the n header formats, the electronic device determines that the message is an illegal message and performs step 202 described below.
In step 202, the reception of the complete message is stopped if the header does not conform to the predetermined header format.
For a message whose header conforms to a predetermined header format, the electronic device determines that the message is illegal and stops receiving the subsequent message content of the header.
For some messages obviously not conforming to the message format, the messages can be filtered through header verification, and the complete messages are prevented from being received, so that the flow is saved; meanwhile, the electronic equipment does not need to carry out message verification on the filtered messages, so that the message verification pressure of the electronic equipment is reduced, and the message verification efficiency is improved.
In step 203, if the header conforms to the predetermined header format, it is determined that the header check is passed, and the complete message is received.
If the header passes the header check, the electronic device receives a subsequent complete message of the header and further checks the message according to the complete message.
In step 204, the message length included in the complete message is obtained, and the message length is used to indicate the total length from the header to the trailer.
As shown in the above table one, the complete message received by the message receiver includes the message length, and the message length is added when the message sender sends the message; when the message transmission environment fluctuates, part of bytes in the message may be lost (or repeatedly transmitted), so that the length of the actual message (the length of the message actually received by the message receiver) is smaller (or larger) than the length of the message. Therefore, after receiving the complete message, the electronic device further obtains the message length contained in the complete message, and performs length detection on the complete message according to the message length, thereby determining whether the received complete message is consistent with the message sent by the message sender.
For example, the length of the message contained in the complete message obtained by the electronic device is 40 bytes.
In step 205, it is detected whether the length of the received complete message is consistent with the length of the message.
Further, the electronic device detects whether the length of the complete message is consistent with the length of the message, and when the length of the complete message is consistent with the length of the message, the following step 207 is executed to further check the complete message; when the length of the complete message is not consistent with the length of the message, the electronic device determines that the received message is abnormal, discards the received complete message, and performs step 206 described below.
In step 206, if the length of the complete packet is not consistent with the length of the packet, the received complete packet is discarded.
For example, the electronic device obtains that the length of the message included in the complete message is 40 bytes, but the actual length of the received complete message is 38 bytes, that is, it is determined that the message is lost during transmission, and discards the complete message.
Obviously, if a part of bytes of a message are lost in the transmission process, the result of checking the message data by using the check bits carried in the message is that the check is definitely not passed. In the embodiment, a length check mechanism is introduced, and the message with the byte loss is filtered before check bit check is performed, so that the process of performing check bit check on the message is omitted, the message check efficiency is improved, and the message check pressure of the electronic equipment is reduced.
In step 207, if the length of the complete message is consistent with the length of the message, the position of the trailer in the complete message is determined according to the length of the message.
When the length of the complete message is consistent with the length of the message, the electronic equipment determines the position of the tail in the complete message according to the length of the message, so that tail checking is further performed on the tail of the complete message.
For example, the length of the message included in the complete message is 40 bytes, and the length of the byte occupied by the trailer is 2 bytes (agreed in advance between the message transceivers), and since the trailer is located at the tail of the complete message, the electronic device determines that the 39 th and 40 th bytes in the complete message are the trailers of the message.
In step 208, it is checked whether the trailer conforms to a predetermined trailer format.
Similar to the header check method, the electronic device extracts the trailer from the complete message according to the position of the trailer, and detects whether the trailer conforms to a predetermined trailer format.
In a possible implementation manner, since the header corresponds to the trailer, the electronic device searches for a trailer format corresponding to the header format, and detects whether the acquired trailer conforms to the trailer format, if so, further performs data verification on the message data, and performs the following step 210; if the obtained trailer does not conform to the trailer format, the complete message is discarded and the following step 209 is performed.
In step 209, if the trailer does not conform to the predetermined trailer format, the received complete message is discarded.
For some messages which obviously do not conform to the message format, the electronic equipment can filter the messages through tail-end check without performing data check on the messages, so that the message check pressure of the electronic equipment is reduced, and the message check efficiency is improved.
In step 210, if the trailer conforms to the predetermined trailer format, it is determined that the trailer passes the trailer check.
Through the steps 201 to 210, in the process of receiving the message, the electronic device performs header check, length check and tail check on the message respectively, and filters a part of the message which does not conform to the standard message format or has byte loss; compared with the data verification of all the received messages in the related technology, the method greatly reduces the verification pressure of the electronic equipment and improves the message verification efficiency.
In step 211, if the trailer passes the trailer check, the data check is performed on the message data according to the check bits included in the complete message.
When the received message passes through header check, length check and tail check, the electronic equipment acquires check bits contained in the complete message and performs data check on message data according to the check bits, wherein the message data refers to all bytes between the check bits.
In a possible implementation manner, the electronic device performs exclusive or operation on a header before a check bit, a message length, an i-level message type and data content to obtain an operation value, detects whether the operation value is consistent with the check bit, determines that data verification fails if the operation value is not consistent with the check bit, and instructs a message sender to resend a message; if the two are consistent, the data check is determined to be passed, and the message is subjected to subsequent processing.
As shown in the above table i, the standard message format agreed between the electronic devices includes i-level message types, the i-level message types are used to indicate the usage of the complete message, and in the i-level message types, the j + 1-level message type is a subclass of the j-level message type, where j is greater than or equal to 1 and less than or equal to j +1 and less than or equal to i.
For example, the electronic device needs to implement x kinds of primary functions according to a received message, and each primary function includes y kinds of secondary functions, and each secondary function includes z kinds of tertiary functions. If the function realized by the message is identified by adopting a single message type, the expression mode of the message type is very complex (x multiplied by y multiplied by z expression modes in total), and the subsequent message processing is not facilitated; in the embodiment of the present disclosure, the function realized by the message is identified by using multiple levels of message types (the level 1 message type identifies a first level function, the level 2 message type identifies a second level function, and the level 3 message type identifies a third level function), so that the complex information is simplified, the message is more hierarchical, and the subsequent message processing is facilitated.
In summary, the message checking method provided in this embodiment performs header checking on the received header; if the header passes the header check, receiving the complete message; carrying out tail check on the tail of the complete message; if the tail is verified through tail verification, performing data verification on the message data according to the verification bits contained in the complete message; the problems that in the related art, after a complete message needs to be received, the message data can be checked only according to the check bits in the message, the check efficiency is low, and the safety and the reliability are poor are solved; the method achieves the effect of verifying the message by using three verification modes of header verification, trailer verification and data verification at different stages of message receiving, thereby improving the verification efficiency, safety and reliability of the message.
In the embodiment, for some messages obviously not conforming to the message format, the electronic equipment filters the messages in a header check mode, so that the complete messages are prevented from being received, and the flow is saved; meanwhile, the electronic equipment does not need to carry out message verification on the filtered messages, so that the message verification pressure of the electronic equipment is reduced, and the message verification efficiency is improved.
In the embodiment, a length check mechanism is introduced, and the message with the byte loss is filtered before check bit check is performed, so that the process of performing check bit check on the message is omitted, the message check efficiency is improved, and the message check pressure of the electronic equipment is reduced.
In this embodiment, for some messages that obviously do not conform to the message format, the electronic device filters the messages in a tail-end-reporting verification manner, and does not need to perform data verification on the messages, thereby reducing the message verification pressure of the electronic device and improving the message verification efficiency.
In this embodiment, the usage of the message is identified by using a multi-level message type, and the complex information is simplified, so that the message is more hierarchical, and the subsequent message processing is facilitated.
The following are embodiments of the disclosed apparatus that may be used to perform embodiments of the disclosed methods. For details not disclosed in the embodiments of the apparatus of the present disclosure, refer to the embodiments of the method of the present disclosure.
Fig. 3 is a block diagram illustrating a message checking apparatus according to an exemplary embodiment of the present disclosure. The message checking device can be realized to be all or part of the electronic equipment with message receiving and processing capabilities through hardware or combination of the hardware and the software. The message checking device comprises:
a first checking module 310 configured to perform header checking on the received header;
a receiving module 320 configured to receive the complete message when the header passes the header check;
a second checking module 330, configured to perform tail check on the tail of the complete message;
and the third checking module 340 is configured to, when the trailer passes the trailer checking, perform data checking on the message data according to the check bits included in the complete message.
In summary, the message checking apparatus provided in this embodiment performs header checking on the received header; if the header passes the header check, receiving the complete message; carrying out tail check on the tail of the complete message; if the tail is verified through tail verification, performing data verification on the message data according to the verification bits contained in the complete message; the problems that in the related art, after a complete message needs to be received, the message data can be checked only according to the check bits in the message, the check efficiency is low, and the safety and the reliability are poor are solved; the method achieves the effect of verifying the message by using three verification modes of header verification, trailer verification and data verification at different stages of message receiving, thereby improving the verification efficiency, safety and reliability of the message.
Fig. 4 is a block diagram illustrating a message checking apparatus according to another exemplary embodiment of the present disclosure. The message checking device can be realized to be all or part of the electronic equipment with message receiving and processing capabilities through hardware or combination of the hardware and the software. The message checking device comprises:
a first checking module 410 configured to perform header checking on the received header;
a receiving module 420 configured to receive the complete message when the header passes the header check;
a second check module 430 configured to perform a trailer check on the trailer of the complete message;
and a third checking module 440 configured to perform data checking on the message data according to the check bits included in the complete message when the trailer passes the trailer checking.
Optionally, the first verification module 410 includes:
a first detection sub-module 411 configured to detect whether the header conforms to a predetermined header format;
a first determining sub-module 412 configured to determine that the header check is passed when the header conforms to the predetermined header format.
Optionally, the complete message includes a message length, and the message length is used to indicate a total length from the header to the trailer;
the device also comprises:
an obtaining module 450, configured to obtain a message length included in the complete message;
a fourth checking module 460, configured to detect whether the length of the received complete message is consistent with the message length;
and the second checking module 430 is configured to perform a step of performing tail checking on the tail of the complete message when the length of the complete message is consistent with the length of the message.
Optionally, the second check module 430 includes:
a second determining submodule 431, configured to determine, according to the message length, the position of the trailer in the complete message;
a second detection submodule 432 configured to detect whether the trailer complies with a predetermined trailer format;
a third determining submodule 433 configured to determine that the trailer passes the trailer check when the trailer complies with a predetermined trailer format.
Optionally, the complete message includes an i-level message type, the i-level message type is used for indicating the use of the complete message, and i is greater than or equal to 2;
wherein, the j +1 th level message type is the subclass of the j level message type, j is more than or equal to 1 and j +1 is more than or equal to i.
In summary, the message checking apparatus provided in this embodiment performs header checking on the received header; if the header passes the header check, receiving the complete message; carrying out tail check on the tail of the complete message; if the tail is verified through tail verification, performing data verification on the message data according to the verification bits contained in the complete message; the problems that in the related art, after a complete message needs to be received, the message data can be checked only according to the check bits in the message, the check efficiency is low, and the safety and the reliability are poor are solved; the method achieves the effect of verifying the message by using three verification modes of header verification, trailer verification and data verification at different stages of message receiving, thereby improving the verification efficiency, safety and reliability of the message.
In the embodiment, for some messages obviously not conforming to the message format, the electronic equipment filters the messages in a header check mode, so that the complete messages are prevented from being received, and the flow is saved; meanwhile, the electronic equipment does not need to carry out message verification on the filtered messages, so that the message verification pressure of the electronic equipment is reduced, and the message verification efficiency is improved.
In the embodiment, a length check mechanism is introduced, and the message with the byte loss is filtered before check bit check is performed, so that the process of performing check bit check on the message is omitted, the message check efficiency is improved, and the message check pressure of the electronic equipment is reduced.
In this embodiment, for some messages that obviously do not conform to the message format, the electronic device filters the messages in a tail-end-reporting verification manner, and does not need to perform data verification on the messages, thereby reducing the message verification pressure of the electronic device and improving the message verification efficiency.
In this embodiment, the usage of the message is identified by using a multi-level message type, and the complex information is simplified, so that the message is more hierarchical, and the subsequent message processing is facilitated.
Fig. 5 is a block diagram illustrating a message checking apparatus 500 according to an example embodiment. For example, the apparatus 500 may be an electronic device such as a smart phone or a tablet computer having message receiving and processing capabilities.
Referring to fig. 5, the apparatus 500 may include one or more of the following components: processing component 502, memory 504, power component 506, multimedia component 508, audio component 510, input/output (I/O) interface 512, sensor component 514, and communication component 516.
The processing component 502 generally controls overall operation of the device 500, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. Processing component 502 may include one or more MCUs 520 to execute instructions to perform all or a portion of the steps of the methods described above. Further, the processing component 502 can include one or more modules that facilitate interaction between the processing component 502 and other components. For example, the processing component 502 can include a multimedia module to facilitate interaction between the multimedia component 508 and the processing component 502.
The memory 504 is configured to store various types of data to support operations at the apparatus 500. Examples of such data include instructions for any application or method operating on device 500, contact data, phonebook data, messages, pictures, videos, and so forth. The memory 504 may be implemented by any type or combination of volatile or non-volatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disks.
The power supply component 506 provides power to the various components of the device 500. The power components 506 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the apparatus 500.
The multimedia component 508 includes a screen that provides an output interface between the device 500 and the user. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundary of a touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 508 includes a front facing camera and/or a rear facing camera. The front camera and/or the rear camera may receive external multimedia data when the device 500 is in an operating mode, such as a shooting mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.
The audio component 510 is configured to output and/or input audio signals. For example, audio component 510 includes a Microphone (MIC) configured to receive external audio signals when apparatus 500 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may further be stored in the memory 504 or transmitted via the communication component 516. In some embodiments, audio component 610 further includes a speaker for outputting audio signals.
The I/O interface 512 provides an interface between the processing component 502 and peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to: a home button, a volume button, a start button, and a lock button. In this embodiment, the I/O interface 512 may be a physical key disposed on the front side or the peripheral side of the terminal, and a fingerprint identification module is disposed in the physical key and is used for collecting a fingerprint of a user; this I/O interface 512 still can be for setting up the fingerprint identification district at the terminal back, contains the fingerprint identification module in this fingerprint identification district.
The sensor assembly 514 includes one or more sensors for providing various aspects of status assessment for the device 500. For example, the sensor assembly 514 may detect an open/closed state of the apparatus 500, the relative positioning of the components, such as a display and keypad of the apparatus 500, the sensor assembly 514 may also detect a change in the position of the apparatus 500 or a component of the apparatus 500, the presence or absence of user contact with the apparatus 500, orientation or acceleration/deceleration of the apparatus 500, and a change in the temperature of the apparatus 500. The sensor assembly 514 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 514 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications.
The communication component 516 is configured to facilitate communication between the apparatus 500 and other devices in a wired or wireless manner. The apparatus 500 may access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 516 receives a broadcast signal or broadcast related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 516 further includes a Near Field Communication (NFC) module to facilitate short-range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, Ultra Wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the apparatus 500 may be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors or other electronic components for performing the above-described methods.
In an exemplary embodiment, a non-transitory computer-readable storage medium comprising instructions, such as the memory 504 comprising instructions, executable by the MCU 520 of the apparatus 500 to perform the above-described method is also provided. For example, the non-transitory computer readable storage medium may be a ROM, a Random Access Memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, and the like.
A non-transitory computer readable storage medium, wherein instructions when executed by an MCU of the apparatus 500 enable the apparatus 500 to perform the above-described message verification method.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This application is intended to cover any variations, uses, or adaptations of the disclosure following, in general, the principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It will be understood that the present disclosure is not limited to the precise arrangements described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims (7)

1. A message checking method is characterized in that the method comprises the following steps:
detecting whether a received header is matched with one of n header formats, when the header is matched with one of the n header formats, determining that the header conforms to a preset header format, and when the header is not matched with any one of the n header formats, determining that the message is an illegal message, wherein the n header formats are header formats stored in the electronic equipment in advance;
if the header passes the header check, receiving a complete message;
determining the position of the tail in the complete message according to the message length;
detecting whether the obtained message tail conforms to a message tail format corresponding to the header format, and if the obtained message tail does not conform to the message tail format, discarding the message;
if the obtained trailer conforms to the trailer format, further performing data verification on message data, and performing data verification on the message data according to check bits contained in the complete message, wherein the complete message comprises an i-level message type, the i-level message type is used for indicating the use of the complete message, the i-level message type identifies the hierarchical function realized by the complete message, i is more than or equal to 2, and the message data are all bytes between the check bits;
performing exclusive or operation on the header, the message length, the i-level message type and the data content before the check bit to obtain an operation value;
if the check bit is consistent with the operation value, the complete message passes through the data check; if the check bit is not consistent with the operation value, the complete message does not pass the data check;
wherein, the j +1 th level message type is the subclass of the j level message type, j is more than or equal to 1 and j +1 is more than or equal to i.
2. The method of claim 1, wherein the full packet comprises a packet length, and wherein the packet length is used to indicate a total length from the header to the trailer;
the method further comprises the following steps:
acquiring the message length contained in the complete message;
detecting whether the length of the received complete message is consistent with the length of the message;
and if the length of the complete message is consistent with that of the message, executing the step of carrying out tail check on the tail of the complete message.
3. A message verification apparatus, the apparatus comprising:
a first checking module configured to detect whether a received header matches any of n header formats, determine that the header conforms to a predetermined header format when the header matches any of the n header formats, and determine that the message is an illegal message when the header does not match any of the n header formats, the n header formats being header formats pre-stored in an electronic device;
a receiving module configured to receive a complete message when the header passes the header check;
the second determining submodule is configured to determine the position of the tail in the complete message according to the message length;
the second detection submodule is configured to detect whether the obtained trailer meets a trailer format corresponding to the header format;
the third determining submodule is configured to further perform data verification on the message data when the obtained trailer conforms to the trailer format; when the obtained message is not in accordance with the message format, discarding the message;
a third checking module, configured to, when the trailer passes the trailer checking, perform data checking on message data according to a check bit included in the complete message, where the complete message includes an i-level message type, the i-level message type is used to indicate a use of the complete message, the i-level message type identifies a hierarchical function implemented by the complete message, i is greater than or equal to 2, and the message data is all bytes between the check bits;
performing exclusive or operation on the header, the message length, the i-level message type and the data content before the check bit to obtain an operation value;
if the check bit is consistent with the operation value, the complete message passes through the data check; if the check bit is not consistent with the operation value, the complete message does not pass the data check;
wherein, the j +1 th level message type is the subclass of the j level message type, j is more than or equal to 1 and j +1 is more than or equal to i.
4. The apparatus according to claim 3, wherein the full packet includes a packet length, and the packet length is used to indicate a total length from the header to the trailer;
the device, still include:
the acquisition module is configured to acquire the message length contained in the complete message;
the fourth checking module is configured to detect whether the length of the received complete message is consistent with the length of the message;
and the second check module is configured to execute the step of performing tail check on the tail of the complete message when the length of the complete message is consistent with the length of the message.
5. A message verification apparatus, the apparatus comprising:
a Micro Control Unit (MCU);
a memory for storing MCU executable instructions;
wherein the MCU is configured to:
detecting whether a received header is matched with one of n header formats, when the header is matched with one of the n header formats, determining that the header conforms to a preset header format, and when the header is not matched with any one of the n header formats, determining that the message is an illegal message, wherein the n header formats are header formats stored in the electronic equipment in advance;
if the header passes the header check, receiving a complete message;
determining the position of the tail in the complete message according to the message length;
detecting whether the obtained message tail conforms to a message tail format corresponding to the header format, and if the obtained message tail does not conform to the message tail format, discarding the message;
if the obtained trailer conforms to the trailer format, further performing data verification on message data, and performing data verification on the message data according to check bits contained in the complete message, wherein the complete message comprises an i-level message type, the i-level message type is used for indicating the use of the complete message, the i-level message type identifies the hierarchical function realized by the complete message, i is more than or equal to 2, and the message data are all bytes between the check bits;
performing exclusive or operation on the header, the message length, the i-level message type and the data content before the check bit to obtain an operation value;
if the check bit is consistent with the operation value, the complete message passes through the data check; if the check bit is not consistent with the operation value, the complete message does not pass the data check;
wherein, the j +1 th level message type is the subclass of the j level message type, j is more than or equal to 1 and j +1 is more than or equal to i.
6. A computer-readable storage medium, characterized in that the storage medium comprises instructions that are executed by an MCU of an electronic device having message receiving and processing capabilities to perform a method of verification of a message according to any of claims 1 or 2.
7. An electronic device, characterized in that the electronic device comprises an embedded system for executing the message verification method according to any of claims 1 or 2.
CN201610666355.3A 2016-08-12 2016-08-12 Message checking method and device Active CN107733556B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610666355.3A CN107733556B (en) 2016-08-12 2016-08-12 Message checking method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610666355.3A CN107733556B (en) 2016-08-12 2016-08-12 Message checking method and device

Publications (2)

Publication Number Publication Date
CN107733556A CN107733556A (en) 2018-02-23
CN107733556B true CN107733556B (en) 2021-09-07

Family

ID=61201451

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610666355.3A Active CN107733556B (en) 2016-08-12 2016-08-12 Message checking method and device

Country Status (1)

Country Link
CN (1) CN107733556B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108880746A (en) * 2018-05-25 2018-11-23 共享智能铸造产业创新中心有限公司 The acquisition method and its acquisition system of correct data in radio communication data
CN109379326B (en) * 2018-08-29 2021-07-06 中国建设银行股份有限公司 XML message rule checking method, equipment and storage medium
CN110830497A (en) * 2019-11-15 2020-02-21 天津光电通信技术有限公司 ACARS message identification method, device, server and storage medium
CN112491513B (en) * 2020-11-13 2023-06-16 北京经纬恒润科技股份有限公司 SPI communication method, device and system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101123485A (en) * 2007-09-20 2008-02-13 杭州华三通信技术有限公司 iSCSI packet processing method and device, error recovery method and device
CN101645756A (en) * 2009-09-04 2010-02-10 深圳英飞拓科技股份有限公司 Ethernet slow-down transmission system and method thereof
CN103312452A (en) * 2012-12-21 2013-09-18 深圳市富晶科技有限公司 Communication method between automatic selling terminal and upper computer of automatic selling terminal
CN104681033A (en) * 2013-12-02 2015-06-03 联想(北京)有限公司 Information encoding and decoding methods and electronic equipment
CN105791128A (en) * 2016-01-28 2016-07-20 东南大学 IP message receiving processing method and device
CN105812086A (en) * 2014-12-30 2016-07-27 深圳市科曼医疗设备有限公司 Monitor communication method and system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101123485A (en) * 2007-09-20 2008-02-13 杭州华三通信技术有限公司 iSCSI packet processing method and device, error recovery method and device
CN101645756A (en) * 2009-09-04 2010-02-10 深圳英飞拓科技股份有限公司 Ethernet slow-down transmission system and method thereof
CN103312452A (en) * 2012-12-21 2013-09-18 深圳市富晶科技有限公司 Communication method between automatic selling terminal and upper computer of automatic selling terminal
CN104681033A (en) * 2013-12-02 2015-06-03 联想(北京)有限公司 Information encoding and decoding methods and electronic equipment
CN105812086A (en) * 2014-12-30 2016-07-27 深圳市科曼医疗设备有限公司 Monitor communication method and system
CN105791128A (en) * 2016-01-28 2016-07-20 东南大学 IP message receiving processing method and device

Non-Patent Citations (5)

* Cited by examiner, † Cited by third party
Title
ICMP type and code IDs;IBM;《IBM Knowledge Center》;20160621;第1-5页 *
ICMP Type Numbers;gorry fairhurst;《university of Aberdeen》;20031217;第1-4页 *
Internet Small Computer System Interface (iSCSI) Protocol;Internet Engineering Task Force (IETF);《Internet Engineering Task Force (IETF)Request for Comments》;20140430;全文 *
Internet Small Computer Systems Interface (iSCSI);Internet Engineering Task Force (IETF);《Internet Engineering Task Force (IETF)Request for Comments》;20040430;全文 *
网络技术教程 (三级);胡道元;《google图书》;清华大学出版社有限公司;20051231;第206页 *

Also Published As

Publication number Publication date
CN107733556A (en) 2018-02-23

Similar Documents

Publication Publication Date Title
CN106709399B (en) Fingerprint identification method and device
CN104615920B (en) Notification information display method and device
US10610152B2 (en) Sleep state detection method, apparatus and system
CN109076558B (en) Method and device for identifying downlink transmission
CN107733556B (en) Message checking method and device
RU2647638C2 (en) Fingerprint identification method and apparatus, and mobile terminal
WO2019191948A1 (en) Determination method and device for size of downlink control information format
CN104298547A (en) Terminal setting method and device
KR20080017854A (en) Mobile communications terminal and method for manageing photograph image file thereof
WO2017197786A1 (en) Method and apparatus for accessing base station
US11394495B2 (en) Hybrid automatic repeat request (HARQ) feedback method and device and data receiving apparatus
CN110677551B (en) Image encryption method, device, equipment and storage medium
CN111654354B (en) Method and device for detecting maximum transmission unit MTU and storage medium
CN107612058B (en) Charging method and device
US10193991B2 (en) Methods and apparatuses for providing information of video capture device
CN111953980B (en) Video processing method and device
US11444927B2 (en) Method and apparatus for encrypting data
US11051170B2 (en) Unlocking mobile terminal in augmented reality
CN107396415B (en) Communication method of dual-card intelligent terminal and terminal
WO2019140696A1 (en) Information transmission method, device and system, and storage medium
CN106484261B (en) Information acquisition method and device, information transmission method and device, and terminal
CN112636402A (en) Charging method and device and electronic equipment
CN111988110A (en) Wireless charging method and device
CN110139230B (en) Method and device for forwarding short message and intelligent equipment
CN109417463A (en) Determine the method and apparatus for needing the PUCCH transmitted

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
GR01 Patent grant
GR01 Patent grant