CN112737734A - Verification information generation method, verification method and device - Google Patents
Verification information generation method, verification method and device Download PDFInfo
- Publication number
- CN112737734A CN112737734A CN202011642845.2A CN202011642845A CN112737734A CN 112737734 A CN112737734 A CN 112737734A CN 202011642845 A CN202011642845 A CN 202011642845A CN 112737734 A CN112737734 A CN 112737734A
- Authority
- CN
- China
- Prior art keywords
- data
- rolling code
- code
- message
- data message
- 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.)
- Granted
Links
Images
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L1/00—Arrangements for detecting or preventing errors in the information received
- H04L1/004—Arrangements for detecting or preventing errors in the information received by using forward error control
- H04L1/0056—Systems characterized by the type of code used
- H04L1/0061—Error detection codes
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L12/00—Data switching networks
- H04L12/28—Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
- H04L12/40—Bus networks
- H04L2012/40208—Bus networks characterized by the use of a particular bus standard
- H04L2012/40215—Controller Area Network CAN
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Detection And Correction Of Errors (AREA)
- Detection And Prevention Of Errors In Transmission (AREA)
Abstract
The embodiment of the invention discloses a verification information generation method, a verification method and a verification device, wherein the method comprises the following steps: calculating a cyclic redundancy check code and generating a rolling code for data to be transmitted; performing XOR operation on the cyclic redundancy check code and the rolling code to obtain a data check sum; and taking the data check sum as the check information of the currently sent data message. After receiving a data message, carrying out checksum XOR operation on the cyclic redundancy check code and the received data to obtain a rolling code; when the rolling code is continuous with the rolling code of the last received data message; and when the rolling code is in the effective range, the verification information is determined to be correct. According to the scheme of the embodiment, each data message can carry more effective data, the utilization rate of the bus is improved, the load of the bus is reduced, and the reliability of the bus is improved.
Description
Technical Field
The invention relates to the technical field of data verification, in particular to a verification information generation method, a verification method and a verification device.
Background
The CAN bus is a short name for a Controller Area Network (Controller Area Network), and is a serial communication bus based on a message broadcast mode developed by BOSCH corporation, and then is confirmed as an international standard (ISO11898) by the international organization for standardization (ISO). The CAN bus is widely applied to the fields of automobiles, industrial automation, ships, medical treatment and the like due to the characteristics of simplicity, practicability, reliability and the like.
The international standard for CAN bus only defines the implementation of OSI (open systems reference model) physical layer and data link layer, and does not define the implementation of application layer. Different application layer implementations may be customized in different application domains, organizations, and vendors. In most application layer implementations, in order to ensure the safety and reliability of data, some data verification functions are added in the application layer. The most common method is to add rolling counter and Checksum to the data of each frame of message. Thus, although the reliability of data is improved, some bus resources are occupied, and the utilization rate of the bus is reduced. Because at most 64 bits of data CAN be transmitted per frame of CAN message, the RollingCounter and Checksum typically occupy 11-16 bits. When a large amount of data needs to be transmitted in the CAN bus, a lower bus utilization rate means a higher bus load, and the higher the bus load is, the lower the reliability of the bus is, and even the hardware cost of the device may be increased.
In the prior art, the roll counter and Checksum need to occupy more message spaces, so that effective data carried by each frame of CAN message is reduced, the utilization rate of a CAN bus is reduced, the load of the CAN bus is possibly improved, and the reliability of the CAN bus is reduced.
Disclosure of Invention
The embodiment of the invention aims to solve the technical problem that: the utility model provides a verification information generation method, a verification method and a verification device, which solve the problem of optimization of verification information in CAN bus communication in the prior art.
According to an aspect of the present invention, there is provided a verification information generating method, including:
calculating Cyclic Redundancy Check (CRC) according to data to be transmitted;
generating a rolling code according to the message sequence of the data to be sent;
performing exclusive or operation on the cyclic redundancy check code CRC and the rolling code RollingCounter to obtain a data Checksum;
and taking the data check sum as check information of the currently sent data message.
Preferably, the method further comprises:
the rolling code RollingCounter is a counter, and the counter is incremented every time a data message is sent.
Preferably, the method further comprises:
and adding the data check sum to the end of the data message as the check information of the currently sent data message.
According to another aspect of the present invention, there is provided a verification information reception verification method, including:
calculating a Cyclic Redundancy Check (CRC) according to the received data message;
performing XOR operation on the cyclic redundancy check code CRC and the received data Checksum to obtain a rolling code RollingCounter;
when the rolling code RollingCounter and the rolling code RollingCounter of the last received data messageprevContinuously; and when the rolling code RollingCounter is in the effective range, the verification information is determined to be correct.
Preferably, the method further comprises:
for the first data message received in the process of initializing and receiving the data message, when the rolling code RollingCounter is determined to be in the effective range, recording the rolling code RollingCounter as the rolling code RollingCounter of the previous data messageprevFor subsequent data message verification; and discarding the data packet.
Preferably, the rolling code RollingCounter and the rolling code RollingCounter of the last received data packetprevAnd (2) continuously, comprising:
when the rolling code RollingCounter is the rolling code RollingCounter of the previous data messageprevWhen the value of (1) is added, determining the rolling code RollingCounter and the rolling code RollingCounter of the last received data messageprevAnd (4) continuous.
Preferably, the rolling code rolling counter is in a valid range, and includes:
the rolling code RollingCounter is at the set minimum rolling code RollingCounterMINAnd maximum rolling code RollingCounterMAXIn the meantime.
According to another aspect of the present invention, there is provided a verification information generation apparatus, including:
a cyclic redundancy check code generating unit, configured to calculate a cyclic redundancy check code CRC according to data to be transmitted;
the rolling code generating unit is used for generating rolling codes according to the message sequence of the data to be sent;
the data Checksum calculation unit is used for carrying out exclusive or operation on the cyclic redundancy check code CRC and the rolling code RollingCounter to obtain a data Checksum;
and the verification information generating unit is used for taking the data verification sum as verification information of the currently sent data message.
Preferably, the rolling code generating unit includes a counter, and the counter is incremented every time a data packet is sent.
Preferably, the apparatus further comprises:
and the verification information adding unit is used for adding the data verification sum to the end of the data message as the verification information of the currently sent data message.
According to another aspect of the present invention, there is provided a verification information reception verifying apparatus, the apparatus including:
a cyclic redundancy check code receiving unit, which is used for calculating cyclic redundancy check code CRC according to the received data message;
a rolling code receiving unit, configured to perform xor operation on the cyclic redundancy check CRC and the received data Checksum to obtain a rolling code rolling counter;
a verification information verifying unit, configured to verify the verification result when the rolling code RollingCounter and the rolling code RollingCounter of the last received data packet are the sameprevContinuously; and when the rolling code RollingCounter is in the effective range, the verification information is determined to be correct.
Preferably, the verification information verifying unit is further configured to:
for the first data message received in the process of initializing and receiving the data message, when the rolling code RollingCounter is determined to be in the effective range, the rolling code RollingCounter is recordedr is the rolling code of the previous data messageprevFor subsequent data message verification; and discarding the data packet.
Preferably, the apparatus further comprises:
a rolling code storage unit for storing the rolling code of the previous data messageprev;
The verification information verification unit acquires the rolling code RollingCounter of the previous data message from the previous rolling code storage unitprevAnd determining the rolling code RollingCounter and the rolling code RollingCounter of the last received data messageprevWhether or not to continue.
Preferably, the apparatus further comprises:
a rolling code extreme value setting unit for setting and storing the minimum rolling code RollingCounterMINAnd maximum rolling code RollingCounterMAX;
The verification information verification unit acquires the minimum rolling code RollingCounter from the rolling code extreme value setting unitMINAnd maximum rolling code RollingCounterMAXAnd according to said minimum rolling code RollingCounterMINAnd maximum rolling code RollingCounterMAXIt is determined whether the current rolling code is within a valid range.
According to another aspect of the present invention, there is provided an electronic apparatus including:
a memory for storing a computer program;
a processor for executing the computer program stored in the memory, and when the computer program is executed, implementing any of the methods described above.
According to another aspect of the invention, there is provided a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements any of the methods described above.
Based on the verification information generation and verification scheme provided by the embodiment of the invention, a cyclic redundancy check code is calculated through data to be transmitted and a rolling code is generated; performing XOR operation on the cyclic redundancy check code and the rolling code to obtain a data check sum; and taking the data check sum as the check information of the currently sent data message. After receiving a data message, carrying out checksum XOR operation on the cyclic redundancy check code and the received data to obtain a rolling code; when the rolling code is continuous with the previous rolling code of the last received data message; and when the rolling code is in the effective range, the verification information is determined to be correct.
According to the scheme of the embodiment, the space occupied by the check information in the bus communication is compressed by redesigning a Checksum mode, so that the purposes of improving the utilization rate of the bus, reducing the load of the bus and improving the reliability of the bus are achieved. The redesigned Checksum will contain both CRC information and RollingCounter information and will only occupy 8 bits. More effective data can be carried by each data message, the utilization rate of the bus is improved, the load of the bus is reduced, and the reliability of the bus is improved.
The technical solution of the present invention is further described in detail by the accompanying drawings and embodiments.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the description, serve to explain the principles of the invention.
Meanwhile, it should be understood that the sizes of the respective portions shown in the drawings are not drawn in an actual proportional relationship for the convenience of description.
The invention will be more clearly understood from the following detailed description, taken with reference to the accompanying drawings, in which:
fig. 1 is a schematic flow chart of a verification information generating method according to an embodiment of the present invention.
Fig. 2 is a schematic flow chart of a verification information generating method according to another embodiment of the present invention.
Fig. 3 is a schematic flow chart of a verification information receiving verification method according to an embodiment of the present invention.
Fig. 4 is a schematic flow chart of a verification information receiving and verifying method according to another embodiment of the present invention.
Fig. 5 is a schematic structural diagram of a verification information generating apparatus according to an embodiment of the present invention.
Fig. 6 is a schematic structural diagram of a verification information receiving and verifying apparatus according to an embodiment of the present invention.
Detailed Description
Various exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be noted that: the relative arrangement of the components and steps, the numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless specifically stated otherwise.
The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the invention, its application, or uses.
The roll counting and Checksum need to occupy more message space, so that the effective data carried by each frame of CAN message is reduced, and the utilization rate of the CAN bus is reduced. The load of the CAN bus CAN be improved, and the reliability of the CAN bus CAN be reduced. The embodiments of the present invention aim to optimize the length of the check information in the application layer by a method, thereby improving the utilization rate of the CAN bus, reducing the load of the CAN bus, and achieving the purpose of improving the reliability of the CAN bus.
Specifically, the RollingCounter is a counter that is used to prevent frame dropping during communication. When the sender sends a message, the counter is increased by one, if the receiver finds that the counter is discontinuous, the condition of frame loss is proved to be sent. The RollingCounter is typically 3-8 bits long. The Checksum is a security check, and is calculated by using other data except the Checksum in the CAN message, and is used for judging the correctness of the data. A commonly used checking algorithm in CAN communication is Cyclic Redundancy Check (CRC), which is typically 8 bits long. The total length of the RollingCounter and Checksum is typically 11-16 bits.
In each embodiment of the invention, the space occupied by the check information in the CAN bus communication is compressed by redesigning a Checksum mode, so that the purposes of improving the utilization rate of the CAN bus, reducing the load of the CAN bus and improving the reliability of the CAN bus are achieved. The redesigned Checksum will contain both CRC information and RollingCounter information and will only occupy 8 bits.
Specifically, as shown in fig. 1, a schematic flow chart of a verification information generating method provided in this embodiment is provided, wherein,
and step 11, calculating a Cyclic Redundancy Check (CRC) according to the data to be transmitted.
And step 12, generating rolling codes according to the message sequence of the data to be sent.
And step 13, performing XOR operation on the cyclic redundancy check code and the rolling code to obtain a data checksum.
And step 14, taking the data checksum as the check information of the currently sent data message so as to verify the data message according to the check information.
In the embodiment, the space occupied by the check information in the bus communication is compressed by redesigning the Checksum mode, so that the purposes of improving the utilization rate of the bus, reducing the load of the bus and improving the reliability of the bus are achieved.
In an embodiment of the present invention, the rolling code is a counter, and the counter is incremented by one every time a data packet is sent. And adding the data checksum to the end of the data message as the check information of the currently sent data message.
Specifically, the redesigned Checksum of the present embodiment will contain both CRC information and RollingCounter information, and occupy only 8 bits. The method for calculating the Checksum after redesigning is as follows:
checksum ═ rolling counter ≠ CRC equation (1)
Wherein, the RollingCounter is a counter, and the counter is increased by one every time a message is sent. The CRC may be calculated using the CRC8 algorithm with data in the CAN message other than Checksum.
When a sender sends data, the CRC is calculated according to the data to be sent, then the Checksum is calculated according to the formula (1), and the Checksum is added to the end of the data to be sent.
As shown in fig. 2, a schematic flow chart of another verification information generating method provided in this embodiment is provided, wherein,
And 103, calculating Checksum according to the formula (1) and adding the Checksum to the end of the data to be sent.
And step 104, sending the CAN message.
In an embodiment of the invention, after the verification initialization stage succeeds in data verification twice, the normal verification stage is entered.
In the verification initialization stage, this stage mainly occurs when the device is just started, or the receiver finds a verification information error in the normal verification stage, i.e., the RollingCounter is discontinuous or a CRC error, the receiver exits the normal verification stage, and re-enters the verification initialization stage.
As shown in fig. 3, a verification information receiving and verifying method provided in this embodiment is provided, wherein,
and step 21, calculating a cyclic redundancy check code according to the received data message.
And step 22, performing a checksum XOR operation on the cyclic redundancy check code and the received data to obtain a rolling code.
In this embodiment, after receiving a CAN message each time, the receiver first calculates a CRC value from the received data, and then calculates a rolling code according to the received Checksum to verify the message data. Due to the simplification of the verification information, the verification method is simpler and more convenient, and the calculated amount is smaller.
When the rolling code is determined to be in the effective range, recording the rolling code as the previous rolling code RollingCounter of the previous data message for the first data message received in the process of initializing and receiving the data messageprevFor subsequent data message verification; and discarding the data packet.
In an embodiment of the present invention, the rolling code is consecutive to a previous rolling code of a last received data packet, and includes: and when the rolling code is the numerical value of the previous rolling code of the previous data message plus 1, determining that the rolling code is continuous with the previous rolling code of the received previous data message.
In one embodiment of the present invention, the rolling code is in a valid range, including: the rolling code is at the set minimum rolling code RollingCounterMINAnd maximum rolling code RollingCounterMAXIn the meantime.
Specifically, after receiving the CAN packet each time, the receiver first calculates a CRC value from the received data, and then calculates a RollingCounter according to the received Checksum using the following formula (2):
CRC equation (2) for roll country ═ Checksum-
If the calculated RollingCounter is continuous with the RollingCounter of the previous frame of CAN message, i.e. RollingCounter ═ RollingCounterprev+1, and RollingCounter is in the effective range, i.e. RollingCounterMIN≤RollingCounter≤RollingCounterMAXThe RollingCounter and CRC check are correct and vice versa.
As shown in fig. 4, a schematic flow chart of another verification information receiving and verifying method provided in this embodiment is shown, wherein,
Step 203, determining whether the RollingCounter is in the effective range, i.e. determining whether the RollingCounter is satisfiedMIN≤RollingCounter≤RollingCounterMAX. If yes, carrying out the next step; if not, the CRC of the frame message fails, the data is invalid, and the next frame message is waited.
And step 204, if the RollingCounter is in the effective range, judging whether the recorded RollingCounter exists in the system.
And step 208, if the RollingCounter is continuous, indicating that the data verification is successful, and storing the RollingCounter value.
In an embodiment of the present invention, the receiver workflow in the verification initialization stage is specifically as follows:
and receiving the CAN message, and calculating CRC according to the received data. The RollingCounter is calculated according to equation (2). Judging whether the RollingCounter is in the effective range, namely judging whether the RollingCounter is satisfiedMIN≤RollingCounter≤RollingCounterMAX. If so, recording the RollingCounter as the RollingCounterprevThe frame message is not analyzed, and is directly discarded to wait for the next frame message; if not, the CRC of the frame message fails, the data is invalid, the step 1 is skipped, and the verification initialization stage is restarted.
And receiving a new CAN message, and calculating CRC according to the received data. The RollingCounter is calculated according to equation (2). Judging whether the RollingCounter is in the effective range, namely judging whether the RollingCounter is satisfiedMIN≤RollingCounter≤RollingCounterMAX. If yes, carrying out the next step; if not, the CRC of the frame message fails, the data is invalid, the step 1 is skipped, and the verification initialization stage is restarted.
Judging whether RollingCounter is continuous or not, and judging that RollingCounter is RollingCounterprevAnd +1 is satisfied. If yes, the verification is successful, and the RollingCounter is recorded as the RollingCounterprevEntering a normal verification stage, and beginning to analyze the message; if not, Ro is indicatedAnd (3) the lingcounter is discontinuous, the CAN bus has frame loss, or the CRC fails, the data is invalid, the step 1 is skipped, and the verification initialization stage is restarted.
The following illustrates the specific principles of the present invention by taking a specific verification example as an example. The scheme of the invention is not limited to the optimization of the checking information of the CAN bus, but the space occupation of the checking information CAN be optimized by the invention as long as the application layer protocol uses the RollingCounter and the CRC to check the data.
The RollingCounter range in this example is 0x 00-0 x 0F.
In this embodiment, both the sender and the receiver are just started, so the RollingCounter of the sender starts from 0, and the receiver is in the verification initialization stage. RollingCounterprevIs 0 xFF.
The CRC-8 algorithm used in this example is described in detail below:
polynomial expression: 0x2F
Initial value: 0xFF
The result is the exclusive or value: 0xFF
The data that the sending end needs to send are as follows:
data 1: 0x00010203040506
Data 2: 0x01010203040506
Data 3: 0x02010203040506
Data 4: 0x03010203040506
Data 5: 0x04010203040506
Data 6: 0x05010203040506
Data 7: 0x06010203040506
In the following description, all CAN messages are by default CAN messages of the same ID, so ID description is omitted.
The transmitting end calculates CRC according to data 1, the calculation result is 0x5D, at this time, the RollingCounter is 0x00, Checksum is 0x00 ≦ 0x5D ≦ 0x5D, and finally the CAN message transmitted by the transmitting end is 0x 000102030405065D.
The CAN message received by the receiving end is 0x000102030405675D, where 0x00010203040567 is valid data and 0x5D is Checksum. And calculating to obtain CRC of 0xE7 according to valid data 0x00010203040567, wherein RollingCounter is 0x5D and 0xE7 is 0xBA,0xBA is not in the valid range of RollingCounter, which indicates that the CRC check of the CAN message fails, the data is invalid, and the next frame of CAN message is waited, wherein RollingCounterprev is an initial value of 0 xFF.
The transmitting end calculates CRC according to data 2, and the calculation result is 0xA9, where the rolling counter is 0x01, Checksum is 0x01 ≦ 0xA9 ≦ 0xA8, and finally the CAN message transmitted by the transmitting end is 0x01010203040506 A8.
The CAN message received by the receiving end is 0x01010203040506a8, wherein 0x01010203040506 is valid data, and 0xA8 is Checksum. The CRC calculated from the validity data 0x01010203040506 is 0xA9, where RollingCounter 0xA8 and 0xA9 are 0x01, and 0x01 is within the validity range of RollingCounter. At this time, since the rollingcountrprev is 0xFF, which indicates that there is no RollingCounter recorded in the system, the rollingcountrprev is 0x01, and the next frame CAN message is waited without analyzing the valid data.
The transmitting end calculates CRC according to the data 3, and the calculation result is 0x9A, where the rolling counter is 0x02, Checksum is 0x02 and 0x9A is 0x98, and the final CAN message transmitted by the transmitting end is 0x 02010203040698.
The CAN message received by the receiving end is 0x0201020304050698, wherein 0x02010203040506 is valid data, and 0x98 is Checksum. CRC calculated from the validity data 0x02010203040506 is 0x9A, RollingCounter 0x98 | _ 0x9A | _ 0x02, and 0x02 is within the validity range of RollingCounter. Since the rllingcountrprev is 0x01 and the rllingcountorjrllingcountrprev +1 is satisfied, it indicates that the rllingcounter is continuous, the CRC and the rllingcounter are both correct, the data check is successful, and the system enters the normal check phase. Update RollingCounterprev to 0x 02. And analyzing the effective data in the frame message.
The transmitting end calculates CRC according to the data 4, the calculation result is 0x6E, at this time, the RollingCounter is 0x03, Checksum is 0x03 ≦ 0x6E ≦ 0x6D, and finally the CAN message transmitted by the transmitting end is 0x 030102030405066D.
The CAN message received by the receiving end is 0x030102030405066F, where 0x03010203040506 is valid data and 0x6F is Checksum. The CRC calculated from the valid data 0x03010203040506 is 0x6E, rllingcounter 0x6F and 0x6E is 0x01, and 0x01 is within the valid range of the rllingcounter. At this time, rollingcountrprev is 0x02, and rollingcountorv +1 is not satisfied, which means that the RollingCounter is discontinuous, that the CAN bus has a frame loss, or that the CRC check fails, and that the data is invalid. And the system reinitializes the RollingCounterprev to be 0xFF and reenters the verification initialization phase. Because the check fails and the data is invalid, the frame message is not analyzed.
The transmitting end calculates CRC according to the data 5, and the calculation result is 0xFC, where the rolling counter is 0x04, Checksum is 0x04 ≦ 0xF8, and finally the CAN message transmitted by the transmitting end is 0x04010203040506F 8.
The CAN message received by the receiving end is 0x04010203040506F8, wherein 0x04010203040506 is valid data, and 0xF8 is Checksum. CRC is calculated as 0xFC from valid data 0x04010203040506, RollingCounter 0xF8 | 0xFC | -0 x04, and 0x04 is within the valid range of RollingCounter. At this time, since the rollingcountrprev is 0xFF, which indicates that there is no RollingCounter recorded in the system, the rollingcountrprev is 0x04, and the next frame CAN message is waited without analyzing the valid data.
The transmitting end calculates CRC according to the data 6, and the calculation result is 0x08, where the rolling counter is 0x05, Checksum is 0x05 ≦ 0x08 ≦ 0x0D, and finally the CAN message transmitted by the transmitting end is 0x 050102030405060D.
The CAN message received by the receiving end is 0x050102030405060D, where 0x05010203040506 is valid data and 0x0D is Checksum. The CRC calculated from the valid data 0x05010203040506 is 0x08, the rllingcounter is 0x0D, and 0x08 is 0x05, and 0x05 is within the valid range of the rllingcounter. Since the rllingcountrprev is 0x04 and the rllingcountorjrllingcountrprev +1 is satisfied, it indicates that the rllingcounter is continuous, the CRC and the rllingcounter are both correct, the data check is successful, and the system enters the normal check phase. Update RollingCounterprev to 0x 05. And analyzing the effective data in the frame message.
The transmitting end calculates CRC according to the data 7, and the calculation result is 0x3B, where the rolling counter is 0x06, Checksum is 0x06 ≦ 0x3B ≦ 0x3D, and finally the CAN message transmitted by the transmitting end is 0x 060102030405063D.
The CAN message received by the receiving end is 0x060102030405063D, where 0x06010203040506 is valid data and 0x3D is Checksum. The CRC calculated from the valid data 0x06010203040506 is 0x3B, rllingcounter 0x3D | _ 0x3B | _ 0x06, and 0x06 is within the valid range of the rllingcounter. Since the result shows that the rllingcounter is continuous, the CRC and the rllingcounter are both correct, the data check is successful, and the rllingcounter rprev is updated to 0x06, because the rllingcounter is 0x05 and the rllingcounter +1 is satisfied. And analyzing the effective data in the frame message.
Fig. 5 is a schematic structural diagram of a verification information generating apparatus according to an embodiment of the present invention, wherein,
a cyclic redundancy check code generating unit 51, configured to calculate a cyclic redundancy check code according to data to be transmitted;
a rolling code generating unit 52, configured to generate rolling codes according to a message sequence of data to be sent;
a data checksum calculation unit 53, configured to perform an xor operation on the cyclic redundancy check code and the rolling code to obtain a data checksum;
a unit 54 for generating check information, configured to use the data checksum as the check information of the currently sent data packet.
In one embodiment of the present invention, the rolling code generation unit 52 includes a counter, and the counter is incremented by one every time a data packet is sent.
In one embodiment of the invention, the apparatus further comprises:
a check information adding unit 55, configured to add the data check sum to the end of the data packet as the check information of the currently sent data packet.
In this embodiment, the space occupied by check information in bus communication is compressed by redesigning the Checksum manner, so as to achieve the purposes of improving the utilization rate of the bus, reducing the load of the bus, and improving the reliability of the bus.
Fig. 6 is a schematic structural diagram of a verification information receiving and verifying apparatus according to an embodiment of the present invention, wherein,
a cyclic redundancy check code receiving unit 61, configured to calculate a cyclic redundancy check code according to the received data packet;
a rolling code receiving unit 62, configured to perform a checksum xor operation on the cyclic redundancy check code and the received data to obtain a rolling code;
a verification information verifying unit 63, configured to verify the rolling code and the previous rolling code of the received previous data packet when the rolling code is receivedprevContinuously; and when the rolling code is in the effective range, the verification information is determined to be correct.
In an embodiment of the present invention, the verification information verifying unit 63 is further configured to:
initializing a first data message received in a receiving process of the data message, and recording the rolling code as a previous rolling code of a previous data message when the rolling code is determined to be in an effective range so as to be used for checking a subsequent data message; and discarding the data packet.
In one embodiment of the invention, the apparatus further comprises:
a previous rolling code storage unit 64, configured to store a previous rolling code of a previous data packet;
the verification information verifying unit 63 obtains the previous rolling code of the previous data packet from the previous rolling code storage unit 64, and determines whether the rolling code is continuous with the previous rolling code of the received previous data packet.
In one embodiment of the invention, the apparatus further comprises:
a rolling code extreme value setting unit 65 for setting and storing a minimum rolling code and a maximum rolling code;
the verification information verifying unit 63 obtains the minimum rolling code and the maximum rolling code from the rolling code extreme value setting unit 65, and determines whether the current rolling code is within the valid range according to the minimum rolling code and the maximum rolling code.
In this embodiment, after receiving a CAN message each time, the receiver first calculates a CRC value from the received data, and then calculates a rolling code according to the received Checksum to verify the message data. Due to the simplification of the verification information, the verification method is simpler and more convenient, and the calculated amount is smaller.
An embodiment of the present invention further provides an electronic device, including:
a memory for storing a computer program;
a processor for executing the computer program stored in the memory, and when the computer program is executed, implementing the method of any of the above embodiments.
An embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the computer program implements the method described in any of the above embodiments.
Based on the verification information generation and verification scheme provided by the embodiment of the invention, a cyclic redundancy check code is calculated through data to be transmitted and a rolling code is generated; performing XOR operation on the cyclic redundancy check code and the rolling code to obtain a data check sum; and taking the data check sum as the check information of the currently sent data message. After receiving a data message, carrying out checksum XOR operation on the cyclic redundancy check code and the received data to obtain a rolling code; when the rolling code is continuous with the previous rolling code of the last received data message; and when the rolling code is in the effective range, the verification information is determined to be correct. According to the scheme of the embodiment, each data message can carry more effective data, the utilization rate of the bus is improved, the load of the bus is reduced, and the reliability of the bus is improved.
Techniques, methods, and apparatus known to those of ordinary skill in the relevant art may not be discussed in detail but are intended to be part of the specification where appropriate.
It should be noted that: like reference numbers and letters refer to like items in the following figures, and thus, once an item is defined in one figure, further discussion thereof is not required in subsequent figures.
Those of ordinary skill in the art will understand that: all or part of the steps for implementing the method embodiments may be implemented by hardware related to program instructions, and the program may be stored in a computer readable storage medium, and when executed, the program performs the steps including the method embodiments; and the aforementioned storage medium includes: various media that can store program codes, such as ROM, RAM, magnetic or optical disks.
In the present specification, the embodiments are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same or similar parts in the embodiments are referred to each other. For the system embodiment, since it basically corresponds to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The method and apparatus of the present invention may be implemented in a number of ways. For example, the methods and apparatus of the present invention may be implemented in software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order for the steps of the method is for illustrative purposes only, and the steps of the method of the present invention are not limited to the order specifically described above unless specifically indicated otherwise. Furthermore, in some embodiments, the present invention may also be embodied as a program recorded in a recording medium, the program including machine-readable instructions for implementing a method according to the present invention. Thus, the present invention also covers a recording medium storing a program for executing the method according to the present invention.
The description of the present invention has been presented for purposes of illustration and description, and is not intended to be exhaustive or limited to the invention in the form disclosed. Many modifications and variations will be apparent to practitioners skilled in this art. The embodiment was chosen and described in order to best explain the principles of the invention and the practical application, and to enable others of ordinary skill in the art to understand the invention for various embodiments with various modifications as are suited to the particular use contemplated.
Claims (10)
1. A verification information generation method, characterized in that the method comprises:
calculating Cyclic Redundancy Check (CRC) according to data to be transmitted;
generating a rolling code according to the message sequence of the data to be sent;
performing XOR operation on the cyclic redundancy check code and the rolling code to obtain a data check sum;
and taking the data check sum as check information of the currently sent data message so as to verify the data message according to the check information.
2. The method of claim 1, wherein the generating rolling codes according to the message order of the data to be transmitted comprises:
the rolling code is a counter, and the counter is increased by one every time a data message is sent.
3. The method of claim 1, wherein the using the data checksum as the check information of the currently transmitted data packet comprises:
and adding the data checksum to the end of the data message as the check information of the currently sent data message.
4. A verification information receiving verification method is characterized by comprising the following steps:
calculating a cyclic redundancy check code according to the received data message;
performing a checksum XOR operation on the cyclic redundancy check code and the received data to obtain a rolling code;
when the rolling code and the previous rolling code RollingCounter of the last data message receivedprevAnd when the rolling code is continuous and in the valid range, the verification information is determined to be correct.
5. The method of claim 4, wherein after xoring the cyclic redundancy check code with the received data checksum to obtain a rolling code, further comprising:
initializing a first data message received in a receiving process of the data message, and recording the rolling code as a previous rolling code of a previous data message when the rolling code is determined to be in an effective range so as to be used for checking a subsequent data message; and discarding the data packet.
6. The method of claim 5, wherein the rolling code is consecutive to a previous rolling code of a last received data message, comprising:
and when the rolling code is the numerical value of the previous rolling code of the previous data message plus 1, determining that the rolling code is continuous with the previous rolling code of the received previous data message.
7. A verification information generation apparatus, characterized in that the apparatus comprises:
a cyclic redundancy check code generating unit, configured to calculate a cyclic redundancy check code according to data to be transmitted;
the rolling code generating unit is used for generating rolling codes according to the message sequence of the data to be sent;
the data check sum calculation unit is used for carrying out XOR operation on the cyclic redundancy check code and the rolling code to obtain a data check sum;
and the verification information generating unit is used for taking the data verification sum as the verification information of the currently sent data message so as to verify the data message according to the verification information.
8. A verification information reception verification apparatus, characterized in that the apparatus comprises:
the cyclic redundancy check code receiving unit is used for calculating a cyclic redundancy check code according to the received data message;
the rolling code receiving unit is used for carrying out checksum XOR operation on the cyclic redundancy check code and the received data to obtain a rolling code;
the verification information verification unit is used for judging whether the rolling code is continuous with the previous rolling code of the last received data message; and when the rolling code is in the effective range, the verification information is determined to be correct.
9. An electronic device, comprising:
a memory for storing a computer program;
a processor for executing a computer program stored in the memory, and when executed, implementing the method of any of the preceding claims 1-6.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the method of any one of the preceding claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011642845.2A CN112737734B (en) | 2020-12-30 | 2020-12-30 | Verification information generation method, verification method and verification device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011642845.2A CN112737734B (en) | 2020-12-30 | 2020-12-30 | Verification information generation method, verification method and verification device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112737734A true CN112737734A (en) | 2021-04-30 |
CN112737734B CN112737734B (en) | 2023-10-20 |
Family
ID=75609182
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011642845.2A Active CN112737734B (en) | 2020-12-30 | 2020-12-30 | Verification information generation method, verification method and verification device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112737734B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114339765A (en) * | 2021-11-25 | 2022-04-12 | 国网河南省电力公司电力科学研究院 | Differential protection data interactive chain type verification method and system based on 5G communication |
CN114389755A (en) * | 2022-01-12 | 2022-04-22 | 上海黑眸智能科技有限责任公司 | Data verification method, device, storage medium and terminal |
CN115085867A (en) * | 2022-06-15 | 2022-09-20 | 北斗星通智联科技有限责任公司 | E2E verification method and device for CAN bus message |
Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6424632B1 (en) * | 1998-09-16 | 2002-07-23 | International Business Machines Corporation | Method and apparatus for testing packet data integrity using data check field |
CN102546097A (en) * | 2010-12-15 | 2012-07-04 | 西门子公司 | Method for data transmission in an automation system using dynamic frame packing |
CN103856288A (en) * | 2012-12-04 | 2014-06-11 | 北汽福田汽车股份有限公司 | CAN communication signal verification and transmission method and system for automobile |
CN104932447A (en) * | 2014-03-20 | 2015-09-23 | 英飞凌科技股份有限公司 | Communication of Information |
US20180359196A1 (en) * | 2017-06-09 | 2018-12-13 | Steering Solutions Ip Holding Corporation | Message sequence evaluation for redundant communication system |
CN110716823A (en) * | 2018-07-12 | 2020-01-21 | 马克西姆综合产品公司 | System and method for continuously verifying device state integrity |
CN112003773A (en) * | 2020-07-15 | 2020-11-27 | 东风汽车集团有限公司 | End-to-end checking method and system for CAN bus safety data |
-
2020
- 2020-12-30 CN CN202011642845.2A patent/CN112737734B/en active Active
Patent Citations (7)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6424632B1 (en) * | 1998-09-16 | 2002-07-23 | International Business Machines Corporation | Method and apparatus for testing packet data integrity using data check field |
CN102546097A (en) * | 2010-12-15 | 2012-07-04 | 西门子公司 | Method for data transmission in an automation system using dynamic frame packing |
CN103856288A (en) * | 2012-12-04 | 2014-06-11 | 北汽福田汽车股份有限公司 | CAN communication signal verification and transmission method and system for automobile |
CN104932447A (en) * | 2014-03-20 | 2015-09-23 | 英飞凌科技股份有限公司 | Communication of Information |
US20180359196A1 (en) * | 2017-06-09 | 2018-12-13 | Steering Solutions Ip Holding Corporation | Message sequence evaluation for redundant communication system |
CN110716823A (en) * | 2018-07-12 | 2020-01-21 | 马克西姆综合产品公司 | System and method for continuously verifying device state integrity |
CN112003773A (en) * | 2020-07-15 | 2020-11-27 | 东风汽车集团有限公司 | End-to-end checking method and system for CAN bus safety data |
Cited By (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114339765A (en) * | 2021-11-25 | 2022-04-12 | 国网河南省电力公司电力科学研究院 | Differential protection data interactive chain type verification method and system based on 5G communication |
CN114339765B (en) * | 2021-11-25 | 2024-01-19 | 国网河南省电力公司电力科学研究院 | Differential protection data interactive chain type verification method and system based on 5G communication |
CN114389755A (en) * | 2022-01-12 | 2022-04-22 | 上海黑眸智能科技有限责任公司 | Data verification method, device, storage medium and terminal |
CN114389755B (en) * | 2022-01-12 | 2023-08-11 | 深圳华芯信息技术股份有限公司 | Data verification method and device, storage medium and terminal |
CN115085867A (en) * | 2022-06-15 | 2022-09-20 | 北斗星通智联科技有限责任公司 | E2E verification method and device for CAN bus message |
CN115085867B (en) * | 2022-06-15 | 2024-01-19 | 北斗星通智联科技有限责任公司 | E2E verification method and device for CAN bus message |
Also Published As
Publication number | Publication date |
---|---|
CN112737734B (en) | 2023-10-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112737734B (en) | Verification information generation method, verification method and verification device | |
US9197246B2 (en) | Iterative decoding of blocks with cyclic redundancy checks | |
US8397151B2 (en) | Integrity of low bandwidth communications | |
CN101031110B (en) | Apparatus and method for processing bursts in wireless communication system | |
CN109818962B (en) | Service data processing method and device, electronic equipment and storage medium | |
US11368250B1 (en) | Adaptive payload extraction and retransmission in wireless data communications with error aggregations | |
CN202663412U (en) | Sending equipment, receiving equipment and transmission system | |
US8166375B2 (en) | Radio communications device and reception method | |
CN113824731B (en) | Method, equipment and computer readable storage medium for analyzing serial port protocol frame | |
US20100023846A1 (en) | Methods and apparatuses for performing error detection and error correction for synchronization frame | |
CN103684684A (en) | Method and apparatus for grouping from processing end to end-to-end network connection wireless segment | |
CN111752579A (en) | Bluetooth terminal upgrading method and device, storage medium and electronic equipment | |
CN111082896A (en) | Data transmission method and transmitting and receiving device | |
US7571374B2 (en) | Method for transmitting and processing command and data | |
CN113098746B (en) | CAN bus communication method and device for work machine | |
CN111246428A (en) | Network reliable communication method, system, device and storage medium | |
CN113141263A (en) | Upgrading method, device, system and storage medium | |
KR101639929B1 (en) | Communication device and communication method | |
CN113162628B (en) | Data encoding method, data decoding method, terminal and storage medium | |
CN112564858B (en) | CRC error correction method and system for satellite navigation | |
US6948110B2 (en) | Transmission data loss detection system | |
CN112019485A (en) | Message generation and verification method and device | |
JP2000312201A (en) | Communication equipment and error control method | |
CN118488024A (en) | CAN communication-based large data packet transmission method, equipment and system | |
CN110784285B (en) | Transparent transmission data structure protection method, device, equipment and storage 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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |