Data transmission method and system

By using a counter and encrypted verification code mechanism between the gas meter device and the server, the problem of replay attacks on gas meter devices is solved, improving the security of gas operations and the accuracy of the counting values.

CN119922003BActive Publication Date: 2025-11-04BEIJING YAHUA WULIAN TECH DEV CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510109147.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-23
Publication Date
2025-11-04
Estimated Expiration
2045-01-23

AI Technical Summary

Technical Problem

Existing technologies lack the means to defend against replay attacks on gas meter devices, which adversely affects gas business operations.

Method used

By using a counter and encrypted verification code mechanism between the server and the gas meter device, the synchronization of counter values ​​and the encrypted transmission of parameters are ensured, preventing replay attacks.

Benefits of technology

Effectively resist replay attacks, improve the safety of gas operations, and ensure the accuracy of counting values ​​and the legality of operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119922003B_ABST
    Figure CN119922003B_ABST
Patent Text Reader

Abstract

The present disclosure relates to the technical field of computers, and discloses a data transmission method and system. The method comprises: a server updating a count value of a first counter on the server to a first count value; sending the first count value, ciphertext, and a first check code to a gas meter device; when the received count value is not greater than a current count value of a second counter on the gas meter device, determining that a target operation fails to be executed; when the received count value is greater than the current count value, determining a second check code according to the count value and the ciphertext received by the gas meter device; when the first check code is different from the second check code, determining that the target operation fails to be executed; when the first check code is the same as the second check code, executing the target operation according to parameters, determining that the target operation is successfully executed after the target operation is executed, updating the count value of the second counter to the first count value, and sending feedback information to the server.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of computer, in particular to a data transmission method and system. BACKGROUND

[0002] In the operation of gas business, gas meter devices often need to perform some operations such as recharging operation, fee deduction operation, etc. Illegal attackers may perform replay attacks on gas meter devices related to corresponding operations.

[0003] At present, there is a lack of means to resist replay attacks on gas meter devices related to corresponding operations. Once the gas meter device encounters a replay attack, it will have an adverse effect on the operation of gas business. How to resist replay attacks on gas meter devices has become a problem to be solved. SUMMARY

[0004] Therefore, the embodiments of the present disclosure provide a data transmission method and system.

[0005] In a first aspect, the embodiments of the present disclosure provide a data transmission method, comprising:

[0006] The server receives a request indicating that a target operation needs to be performed by a gas meter device, updates a count value of a first counter corresponding to a target operation type of the target operation and the gas meter device on the server from a current count value of the first counter to a first count value, the first count value being greater than the current count value;

[0007] The server encrypts a parameter of the target operation to obtain ciphertext of the parameter;

[0008] The server determines a first check code according to the first count value and the ciphertext;

[0009] The server sends the first count value, the ciphertext and the first check code to the gas meter device;

[0010] The gas meter device determines that the target operation fails when the received count value is not greater than a current count value of a second counter corresponding to the target operation type on the gas meter device;

[0011] The gas meter device determines a second check code according to the received count value and the ciphertext when the received count value is greater than the current count value of the second counter;

[0012] The gas meter device determines that the target operation fails when the first check code is different from the second check code;

[0013] The gas meter device decrypts the ciphertext to obtain the parameter, performs a target operation according to the parameter, and after the target operation is performed, determines that the target operation is successfully performed, and updates the count value of the second counter from the current count value of the second counter to the first count value;

[0014] The gas meter device sends feedback information indicating that the gas meter device determines that the target operation is successfully performed or that the target operation fails to the server.

[0015] In one possible implementation, after the gas meter device sends the feedback information to the server, the method further includes:

[0016] When the gas meter device determines that the target operation is successfully performed, the gas meter device updates the count value of the second counter from the first count value to a second count value greater than the first count value.

[0017] The gas meter device encrypts the response parameter of the target operation to obtain ciphertext of the response parameter of the target operation.

[0018] The gas meter device determines a third check code according to the second count value and the ciphertext of the response parameter of the target operation.

[0019] The gas meter device sends the second count value, the ciphertext of the response parameter of the target operation, and the third check code to the server.

[0020] The server determines that the target operation fails when the count value corresponding to the gas meter device received is not greater than the current count value of the first counter.

[0021] The server determines a fourth check code according to the count value corresponding to the gas meter device received by the server and the ciphertext of the response parameter of the target operation when the count value corresponding to the gas meter device received by the server is greater than the current count value of the first counter.

[0022] The server determines that the target operation fails when the third check code is different from the fourth check code.

[0023] The server determines that the target operation is successfully performed when the third check code is the same as the fourth check code, and updates the count value of the first counter to the second count value, and updates information corresponding to the type of the target operation according to the response parameter of the target operation.

[0024] In one possible implementation, determining the first check code according to the first count value and the ciphertext includes:

[0025] Determining the first check code according to the first count value and the ciphertext of the parameter of the target operation by using a key corresponding to the type of the target operation.

[0026] Determining the second check code according to the count value received by the gas meter device and the ciphertext of the parameter of the target operation includes:

[0027] Determining the second check code according to the count value received by the gas meter device and the ciphertext of the parameter of the target operation by using the key corresponding to the target operation type.

[0028] In one possible implementation, the determining the third check code according to the second count value and the ciphertext of the response parameter of the target operation includes:

[0029] Determining the third check code according to the second count value and the ciphertext of the response parameter of the target operation by using the key corresponding to the target operation type; and

[0030] Determining the fourth check code according to the ciphertext of the response parameter of the target operation corresponding to the count value of the gas meter device received by the server includes:

[0031] Determining the fourth check code according to the ciphertext of the response parameter of the target operation corresponding to the count value of the gas meter device received by the server by using the key corresponding to the target operation type.

[0032] In one possible implementation, the target operation is one of the following: a recharge operation, a deduction operation.

[0033] In a second aspect, the embodiments of the present disclosure provide a data transmission system, which includes: a server and a gas meter device.

[0034] The server is configured to receive a request indicating that a target operation needs to be performed by the gas meter device, update a count value of a first counter corresponding to a target operation type of the target operation of the gas meter device on the server from a current count value of the first counter to a first count value, the first count value being greater than the current count value, encrypt a parameter of the target operation to obtain a ciphertext of the parameter, determine a first check code according to the first count value and the ciphertext, and send the first count value, the ciphertext and the first check code to the gas meter device.

[0035] The gas meter device is configured to: determine that the target operation is executed unsuccessfully when a received count value is not greater than a current count value of a second counter corresponding to the target operation type on the gas meter device; determine a second check code according to the received count value and the ciphertext when the received count value is greater than the current count value of the second counter; determine that the target operation is executed unsuccessfully when the first check code is different from the second check code; determine that the target operation is executed successfully when the first check code is the same as the second check code, decrypt the ciphertext to obtain the parameter, execute the target operation according to the parameter, and update the count value of the second counter from the current count value of the second counter to the first count value after the target operation is executed completely; and send feedback information indicating that the target operation is executed successfully or unsuccessfully to the server.

[0036] In a possible implementation, the gas meter device is further configured to: update the count value of the second counter from the first count value to a second count value greater than the first count value when the gas meter device determines that the target operation is executed successfully after the gas meter device sends the feedback information to the server; encrypt a response parameter of the target operation to obtain ciphertext of the response parameter of the target operation; determine a third check code according to the second count value and the ciphertext of the response parameter of the target operation; and send the second count value, the ciphertext of the response parameter of the target operation, and the third check code to the server.

[0037] In a possible implementation, the server is further configured to: determine that the target operation is executed unsuccessfully when a received count value corresponding to the gas meter device is not greater than the current count value of the first counter; determine a fourth check code according to the received count value corresponding to the gas meter device and the ciphertext of the parameter of the target operation when the received count value corresponding to the gas meter device is greater than the current count value of the first counter; determine that the target operation is executed successfully when the third check code is the same as the fourth check code, and update the count value of the first counter to the second count value and update information corresponding to the target operation type according to the response parameter of the target operation.

[0038] In a possible implementation, the gas meter device is further configured to determine a third check code according to the second count value and the ciphertext of the response parameter of the target operation by using the key corresponding to the target operation type; and the server is further configured to determine a fourth check code according to the received ciphertext of the response parameter of the target operation corresponding to the count value of the gas meter device by using the key corresponding to the target operation type.

[0039] The data transmission method provided by the embodiments of the present disclosure considers that if an attacker performs a replay attack on the gas meter device in relation to a corresponding operation, the attacker will repeatedly send information including the same count value before the current time. However, the updating of the count value of the counter in the data transmission method provided by the embodiments of the present disclosure can make the count value received by the gas meter device before the current time not greater than the current count value of the counter on the gas meter device in a normal case. In the case that the attacker performs a replay attack on the gas meter device in relation to a corresponding operation, the gas meter device can determine that a replay attack occurs according to that the count value of the counter is not greater than the current count value of the corresponding counter on the gas meter device, and will not perform the corresponding operation. Thus, the replay attack is resisted, and the security of gas operation is improved. BRIEF DESCRIPTION OF DRAWINGS

[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure or the prior art, the drawings needed to be used in the specific embodiments or prior art description will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the present disclosure, and other drawings can be obtained by those skilled in the art without creative labor.

[0041] Figure 1 is a structural schematic diagram of the data transmission system provided by the embodiments of the present disclosure;

[0042] Figure 2 is a flowchart of the data transmission method provided by the embodiments of the present disclosure;

[0043] Figure 3 is a flowchart of one example of the gas meter device determining whether the target operation is successfully executed or the target operation fails;

[0044] Figure 4 is a flowchart of one example of the server determining whether the target operation is successfully executed or the target operation fails. DETAILED DESCRIPTION

[0045] To make the purposes, technical solutions, and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be described clearly and completely below with reference to the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are some but not all of the embodiments of the present disclosure. Based on the embodiments in the present disclosure, all other embodiments obtained by a person of ordinary skill in the art without creative effort are within the protection scope of the present disclosure.

[0046] Reference Figure 1 FIG. 1 shows a structure schematic diagram of a data transmission system provided by an embodiment of the present disclosure.

[0047] The gas meter device can also be called a remote gas meter device. Figure 1 The gas meter device 1, the gas meter device 2, and the like are shown. The gas meter device is communicatively connected to a server by a wireless communication mode, for example, LTE or 5G.

[0048] The gas meter device 1 stores keys such as a key corresponding to a recharge operation type, that is, a recharge key, and a key corresponding to a deduction operation type, that is, a deduction key. The gas meter device 2 stores keys such as a key corresponding to a recharge operation type, that is, a recharge key, and a key corresponding to a deduction operation type, that is, a deduction key.

[0049] The gas meter device 1 has a counter corresponding to a recharge operation type and a counter corresponding to a deduction operation type. The gas meter device 2 has a counter corresponding to a recharge operation type and a counter corresponding to a deduction operation type.

[0050] The server can include one or more servers. The server stores keys such as a key corresponding to a recharge operation type, that is, a recharge key, and a key corresponding to a deduction operation type, that is, a deduction key. The server has a counter corresponding to the gas meter device 1 and a recharge operation type, and a counter corresponding to the gas meter device 1 and a deduction operation type. The server has a counter corresponding to the gas meter device 2 and a recharge operation type, and a counter corresponding to the gas meter device 2 and a deduction operation type.

[0051] It should be noted that the counter corresponding to the recharge operation type on the gas meter device and the counter corresponding to the recharge operation type on the server both have the same initial count value, for example, 1. The initial value is the count value of the counter corresponding to the recharge operation type before the data transmission method provided by the present disclosure is performed for the first time. The counter corresponding to the deduction operation type on the gas meter device and the counter corresponding to the deduction operation type on the server both have the same initial count value, for example, 1.

[0052] Reference Figure 2 FIG. 2 shows a flow schematic diagram of a data transmission method provided by an embodiment of the present disclosure.

[0053] It should be noted that, in the embodiments of the present disclosure, the current count value of the corresponding counter is not specifically the count value of the corresponding counter at a certain time, but is relative to the step in which the current count value of the corresponding counter appears.

[0054] In step S201, the server receives a request indicating that the gas meter device needs to perform a target operation, and updates a count value of a first counter corresponding to the gas meter device and a target operation type of the target operation on the server to a first count value.

[0055] In the embodiments of the present disclosure, the operation type of the target operation is called the target operation type of the target operation.

[0056] The target operation can be any operation that the gas meter device can perform.

[0057] As an example, the target operation is a recharge operation or a deduction operation. The first counter corresponding to the gas meter device and the target operation type of the target operation on the server is a first counter corresponding to the gas meter device and a recharge operation type on the server or a first counter corresponding to the gas meter device and a deduction operation type on the server.

[0058] It should be noted that, for operation type i, the counter corresponding to operation type i on the gas meter device and the counter corresponding to operation type i on the server both have the same initial count value, for example, 1. The initial value is the count value of the counter corresponding to operation type i before the data transmission method provided by the embodiments of the present disclosure is performed for the first time.

[0059] The first count value can be the current count value of the first counter corresponding to the gas meter device and the target operation type of the target operation on the server + 1.

[0060] It should be noted that, in step S201, the current count value of the count value of the first counter corresponding to the gas meter device and the target operation type of the target operation can refer to the count value of the first counter corresponding to the gas meter device and the target operation type of the target operation on the server at the time when step S201 is started.

[0061] In step S202, the server encrypts the parameters of the target operation using the key corresponding to the target operation type to obtain the ciphertext of the parameters of the target operation.

[0062] As an example, the target operation is a recharge operation, and the parameter of the target operation is a recharge value of the recharge operation. In step S202, the recharge value of the recharge operation is encrypted according to the key corresponding to the recharge operation type using a symmetric encryption algorithm to obtain the ciphertext of the recharge value of the recharge operation.

[0063] As another example, the target operation is a deduction operation, and the parameter of the target operation is a deduction amount of the deduction operation. In step S202, the deduction amount of the deduction operation is encrypted according to the key corresponding to the type of the deduction operation by using the symmetric encryption algorithm, to obtain the ciphertext of the deduction amount of the deduction operation.

[0064] In step S203, the server determines the first check code according to the first count value and the ciphertext of the parameter of the target operation.

[0065] In one possible implementation, in step S203, the server determining the first check code according to the first count value and the ciphertext of the parameter of the target operation includes: splicing the first count value and the ciphertext of the parameter of the target operation to obtain a splicing result of the first count value and the ciphertext of the parameter of the target operation. The splicing result of the first count value and the ciphertext of the parameter of the target operation is composed of the first count value and the ciphertext of the parameter of the target operation. The splicing result of the first count value and the ciphertext of the parameter of the target operation is taken as the first check code.

[0066] In another possible implementation, in step S203, the server determining the first check code according to the first count value and the ciphertext of the parameter of the target operation includes: splicing the first count value and the ciphertext of the parameter of the target operation to obtain a splicing result of the first count value and the ciphertext of the parameter of the target operation. The splicing result of the first count value and the ciphertext of the parameter of the target operation is encrypted according to the key corresponding to the type of the target operation by using the symmetric encryption algorithm, to obtain the first check code.

[0067] In step S204, the server sends the first count value, the ciphertext of the parameter of the target operation, and the first check code to the gas meter device.

[0068] In step S204, the server can send a command including the first count value, the ciphertext of the parameter of the target operation, and the first check code to the gas meter device.

[0069] As an example, the target operation is a recharge operation, and in step S204, the server sends a recharge command including the first count value, the ciphertext of the parameter of the recharge operation, and the first check code to the gas meter device.

[0070] As another example, the target operation is a deduction operation, and in step S204, the server sends a deduction command including the first count value, the ciphertext of the parameter of the deduction operation, and the first check code to the gas meter device.

[0071] In step S205, when the gas meter device determines that the count value received by the gas meter device is not greater than the current count value of the second counter corresponding to the type of the target operation on the gas meter device, the gas meter device determines that the target operation fails.

[0072] It should be noted that the current count value of the second counter corresponding to the target operation type in step S205 can refer to the count value of the second counter corresponding to the target operation type at the time when the gas meter device receives the count value received by the gas meter device.

[0073] If the gas meter device determines that the received count value is not greater than the current count value of the second counter corresponding to the target operation type on the gas meter device, the gas meter device can determine that a replay attack occurs in step S205. The gas meter device determines that the target operation fails when the gas meter device determines that the received count value is not greater than the current count value of the second counter corresponding to the target operation type on the gas meter device.

[0074] In step S206, when the gas meter device determines that the count value received by the gas meter device is greater than the current count value of the second counter corresponding to the target operation type on the gas meter device, the gas meter device determines the second check code according to the count value received by the gas meter device and the ciphertext of the parameter of the target operation.

[0075] The current count value of the second counter corresponding to the target operation type in step S206 can refer to the count value of the second counter corresponding to the target operation type at the time when the gas meter device receives the count value received by the gas meter device.

[0076] It should be noted that if the count value received by the gas meter device is the first count value, the gas meter device can determine that the count value received by the gas meter device is greater than the current count value of the second counter corresponding to the target operation type on the gas meter device in step S206.

[0077] In one possible implementation, in step S206, determining the second check code according to the count value received by the gas meter device and the ciphertext of the parameter of the target operation includes: the gas meter device concatenates the count value received by the gas meter device and the ciphertext of the parameter of the target operation to obtain a concatenation result of the count value received by the gas meter device and the ciphertext of the parameter of the target operation. The concatenation result of the count value received by the gas meter device and the ciphertext of the parameter of the target operation is composed of the count value received by the gas meter device and the ciphertext of the parameter of the target operation. The concatenation result of the count value received by the gas meter device and the ciphertext of the parameter of the target operation is taken as the second check code.

[0078] In another possible implementation, in step S206, determining the second check code according to the count value received by the gas meter device and the ciphertext of the parameter of the target operation comprises: the gas meter device concatenating the count value received by the gas meter device and the ciphertext of the parameter of the target operation to obtain a concatenation result of the count value received by the gas meter device and the ciphertext of the parameter of the target operation. The concatenation result of the count value received by the gas meter device and the ciphertext of the parameter of the target operation is encrypted according to the key corresponding to the target operation type by using the symmetric encryption algorithm to obtain the second check code.

[0079] In step S207, when the gas meter device determines that the first check code is different from the second check code, the gas meter device determines that the target operation fails to be executed.

[0080] In step S208, when the gas meter device determines that the first check code is same as the second check code, the gas meter device decrypts the ciphertext of the parameter of the target operation to obtain the ciphertext of the parameter of the target operation, executes the target operation according to the ciphertext of the parameter of the target operation, and after the target operation is executed, the gas meter device determines that the target operation is successfully executed, and updates the count value of the second counter corresponding to the target operation type on the gas meter device from the current count value of the second counter to the first count value.

[0081] It should be noted that if the count value received by the gas meter device is the first count value, the first check code is same as the second check code. The first count value is greater than the current count value of the second counter.

[0082] In step S209, the gas meter device sends feedback information indicating that the gas meter device determines that the target operation is successfully executed or the target operation fails to be executed to the server.

[0083] If the gas meter device determines that the target operation is successfully executed, the gas meter device sends feedback information indicating that the gas meter device determines that the target operation is successfully executed to the server. If the gas meter device determines that the target operation fails to be executed, the gas meter device sends feedback information indicating that the gas meter device determines that the target operation fails to be executed to the server.

[0084] In one possible implementation, after the gas meter device sends feedback information indicating that the gas meter device determines that the target operation is successfully executed or the target operation fails to be executed to the server, steps S210-S217 are further included.

[0085] In step S210, when the gas meter device determines that the target operation is successfully executed, the gas meter device updates the second counter corresponding to the target operation type on the gas meter device from the first count value to a second count value greater than the first count value.

[0086] The second count value can be: the first count value+1.

[0087] In step S211, the gas meter device encrypts the response parameter of the target operation corresponding to the target operation type by using the key, to obtain the ciphertext of the response parameter of the target operation.

[0088] The response parameter of the target operation can be a value corresponding to the target operation type stored by the gas meter device after the target operation is executed.

[0089] As an example, the target operation is a recharge operation, and the parameter of the target operation is a recharge value. The recharge value is a recharge amount or a recharge cubic meter. The response parameter of the target operation is a value corresponding to the recharge operation type stored by the gas meter device after the recharge operation is executed, which is a remaining amount or a remaining cubic meter count stored by the gas meter device. The remaining amount can indicate how much gas with the amount available for the user of the gas meter device. The remaining cubic meter count can indicate how much gas with the cubic meter available for the user of the gas meter device. The value corresponding to the recharge operation type stored by the gas meter device after the recharge operation is executed is the sum of the value corresponding to the recharge operation type stored by the gas meter device at the time when the recharge operation is started and the recharge value.

[0090] As another example, the target operation is a deduction operation, and the parameter of the target operation is a deduction value. The deduction value is a deduction amount or a deduction cubic meter. The response parameter of the deduction operation is a value corresponding to the deduction operation stored by the gas meter device after the deduction operation is executed, which is a remaining amount or a remaining cubic meter count stored by the gas meter device. The value corresponding to the deduction operation stored by the gas meter device after the deduction operation is executed is the value stored by the gas meter device at the time when the deduction operation is started minus the deduction value.

[0091] In step S212, the gas meter device determines the third check code according to the second count value and the ciphertext of the response parameter of the target operation.

[0092] In a possible implementation, in step S212, the gas meter device determining the third check code according to the second count value and the ciphertext of the response parameter of the target operation includes: splicing the second count value and the ciphertext of the response parameter of the target operation to obtain a splicing result of the second count value and the ciphertext of the response parameter of the target operation. The splicing result of the second count value and the ciphertext of the response parameter of the target operation is composed of the second count value and the ciphertext of the response parameter of the target operation. The splicing result of the second count value and the ciphertext of the response parameter of the target operation is taken as the third check code.

[0093] In another possible implementation, the gas meter device determines the third check code according to the second count value and the ciphertext of the response parameter of the target operation in step S212 includes: concatenating the second count value and the ciphertext of the response parameter of the target operation to obtain a concatenation result of the second count value and the ciphertext of the response parameter of the target operation. The concatenation result of the second count value and the ciphertext of the response parameter of the target operation is encrypted according to the key corresponding to the target operation type by using the symmetric encryption algorithm to obtain the third check code.

[0094] In step S213, the gas meter device sends the second count value, the ciphertext of the response parameter of the target operation, and the third check code to the server.

[0095] In step S214, when the server determines that the count value corresponding to the gas meter device received by the server is not greater than the current count value of the first counter corresponding to the gas meter device and the target operation type on the server, the server determines that the target operation fails.

[0096] It should be noted that the current count value of the first counter corresponding to the gas meter device and the target operation type in step S214 can refer to the count value of the first counter corresponding to the gas meter device and the target operation type at the time when the count value corresponding to the gas meter device is received. The current count value of the first counter corresponding to the gas meter device and the target operation type in step S214 is actually the first count value.

[0097] In step S215, when the server determines that the count value corresponding to the gas meter device received by the server is greater than the current count value of the first counter corresponding to the gas meter device and the target operation type on the server, the server determines a fourth check code according to the count value corresponding to the gas meter device received by the server and the ciphertext of the response parameter of the target operation.

[0098] It should be noted that the current count value of the first counter corresponding to the gas meter device and the target operation type in step S215 is actually the first count value.

[0099] In step S215, if the count value corresponding to the gas meter device received by the server is the second count value, the server can determine that the count value corresponding to the gas meter device received by the server is greater than the current count value of the first counter corresponding to the gas meter device and the target operation type on the server, that is, the first count value.

[0100] In a possible implementation, at step S215, determining the fourth check code according to the ciphertext of the count value corresponding to the gas meter device and the response parameter of the target operation received by the server comprises: splicing the ciphertext of the count value corresponding to the gas meter device and the response parameter of the target operation received by the server to obtain a splicing result of the ciphertext of the count value corresponding to the gas meter device and the response parameter of the target operation received by the server. The splicing result of the ciphertext of the count value corresponding to the gas meter device and the response parameter of the target operation received by the server is composed of the ciphertext of the count value corresponding to the gas meter device and the response parameter of the target operation received by the server. The splicing result of the ciphertext of the count value corresponding to the gas meter device and the response parameter of the target operation received by the server is taken as the fourth check code.

[0101] In another possible implementation, at step S215, determining the fourth check code according to the ciphertext of the count value corresponding to the gas meter device and the response parameter of the target operation received by the server comprises: splicing the ciphertext of the count value corresponding to the gas meter device and the response parameter of the target operation received by the server to obtain a splicing result of the ciphertext of the count value corresponding to the gas meter device and the response parameter of the target operation received by the server. The splicing result of the ciphertext of the count value corresponding to the gas meter device and the response parameter of the target operation received by the server is encrypted according to the key corresponding to the target operation type by using a symmetric encryption algorithm to obtain the fourth check code.

[0102] At step S216, when the server determines that the third check code and the fourth check code are different, the server determines that the target operation fails.

[0103] At step S217, when the server determines that the third check code and the fourth check code are the same, the server determines that the target operation succeeds, updates the count value of the first counter corresponding to the gas meter device and the target operation type on the server to the second count value, and updates the information corresponding to the target operation type according to the response parameter of the target operation.

[0104] Updating the count value of the first counter corresponding to the gas meter device and the target operation type on the server to the second count value can specifically mean updating the count value of the first counter corresponding to the gas meter device and the target operation type on the server from the first count value to the second count value.

[0105] The information corresponding to the target operation type can be information that needs to be updated in the case that the target operation type succeeds. The information corresponding to the target operation type and the response parameter of the target operation can be information of the same type.

[0106] At step S217, the information corresponding to the target operation type can be updated to the response parameter of the target operation.

[0107] As an example, the target operation is a recharge operation, and the parameter of the target operation is a recharge value. The recharge value is a recharge amount or a recharge cubic meter. The response parameter of the target operation is a value corresponding to the recharge operation type stored by the gas meter device after the recharge operation is performed, and the value corresponding to the recharge operation type stored by the gas meter device is a remaining amount or a remaining cubic meter count stored by the gas meter device. The information corresponding to the recharge operation type is a value corresponding to the recharge operation type stored by the server. The remaining amount can indicate how much gas with the amount available for the user of the gas meter device. The remaining cubic meter count can indicate how much gas with the cubic meter available for the user of the gas meter device. The value corresponding to the recharge operation type stored by the gas meter device after the recharge operation is performed is the sum of the value corresponding to the recharge operation type stored by the gas meter device at the time when the recharge operation is started and the recharge value. In step S217, the value corresponding to the recharge operation type stored by the server is updated to the response parameter of the target operation.

[0108] As another example, the target operation is a deduction operation, and the parameter of the target operation is a deduction value. The deduction value is a deduction amount or a deduction cubic meter. The deduction value is a deduction amount or a deduction cubic meter. The response parameter of the deduction operation is a value corresponding to the deduction operation stored by the gas meter device after the deduction operation is performed, and the value corresponding to the deduction operation stored by the gas meter device is a remaining amount or a remaining cubic meter count stored by the gas meter device. The information corresponding to the deduction operation type is a value corresponding to the deduction operation type stored by the server. The value corresponding to the deduction operation stored by the gas meter device after the deduction operation is performed is the value stored by the gas meter device at the time when the deduction operation is started minus the deduction value. In step S217, the value corresponding to the recharge operation type stored by the server is updated to the response parameter of the target operation.

[0109] Reference is made to Figure 3 which shows a flowchart illustrating one example of the gas meter device determining whether the target operation is successfully executed or the target operation fails.

[0110] In this example, the gas meter device is the gas meter device A, the target operation is a recharge operation, and the key corresponding to the recharge operation type is called the recharge key.

[0111] The server increments the current count value of the first counter pCNT corresponding to the gas meter device A and the recharge operation type on the server by 1 to obtain a first count value pCNTnew.

[0112] The server encrypts the parameter of the recharge operation, i.e., the recharge parameter, using the recharge key to obtain the ciphertext of the recharge parameter, i.e., ENC1.

[0113] The server obtains the first check code, i.e., MAC1, according to the splicing result of the first count value and the ciphertext of the recharge parameter, i.e., pCNTnew+ENC1, by using the recharge key.

[0114] The server sends the recharge command including pCNTnew1, ENC1, and MAC1 to the gas meter device A.

[0115] When the gas meter device A determines that the received count value is not greater than the current count value of the second counter dCNT corresponding to the recharge operation type on the gas meter device A, the gas meter device A determines that the recharge operation fails.

[0116] When the gas meter device A determines that the received count value is greater than the current count value of dCNT on the gas meter device A, the gas meter device A determines the second check code MAC2 according to the splicing result of the received count value and ENC1, i.e., the received count value+ENC1, by using the recharge key. If the gas meter device A determines that MAC1 and MAC2 are the same, the gas meter device A performs the recharge operation according to the recharge parameter. After the completion of the recharge operation, the gas meter device A determines that the recharge operation succeeds. When the gas meter device A determines that the recharge operation succeeds, the gas meter device A updates the count value of dCNT on the gas meter device A to the first count value, i.e., pCNTnew. When the gas meter device A determines that the recharge operation succeeds, the gas meter device A returns feedback information indicating that the gas meter device A determines that the recharge operation succeeds to the server.

[0117] It should be noted that if the received count value of the gas meter device A is PCNTnew, the gas meter device A determines that the received count value is greater than the current count value of dCNT on the gas meter device A.

[0118] When the gas meter device A determines that the received count value is not greater than the current count value of dCNT, the gas meter device A returns feedback information indicating that the gas meter device A determines that the recharge operation fails to the server.

[0119] Reference Figure 4 which shows a flowchart of one example of the server determining that the target operation succeeds or fails.

[0120] In this example, the gas meter device is the gas meter device A, and the target operation is the recharge operation.

[0121] After the recharge operation succeeds, the gas meter device A obtains the second count value, i.e., dCNTnew, according to the current count value of dCNT on the gas meter device A, i.e., pCNTnew+1.

[0122] The gas meter device A encrypts the response parameter of the recharge operation, i.e., the recharge response parameter, by using the recharge key, to obtain ciphertext ENC2 of the response parameter of the recharge operation.

[0123] The gas meter device A determines a third check code MAC3 according to a splicing result of the second count value and the ciphertext of the response parameter of the recharge operation, i.e., dCNTnew+ENC2, by using the recharge key.

[0124] The gas meter device A sends dCNTnew, ENC2 and MAC3 to the server.

[0125] The server determines that the recharge operation fails when it is determined that the count value corresponding to the gas meter device A received by the server is not greater than the current count value pCNTnew of pCNT on the server.

[0126] The server determines a fourth check code MAC4 according to the count value corresponding to the gas meter device A received by the server and the ciphertext of the response parameter of the recharge operation by using the recharge key when it is determined that the count value corresponding to the gas meter device A received by the server is greater than the current count value pCNTnew of pCNT on the server.

[0127] It should be noted that if the count value corresponding to the gas meter device A received by the server is the second count value dCNTnew, the server determines that the count value corresponding to the gas meter device A received by the server is greater than the current count value pCNTnew of pCNT on the server.

[0128] The server determines that the recharge operation fails when it is determined that MAC3 and MAC4 are different.

[0129] The server determines that the recharge operation succeeds when it is determined that MAC3 and MAC4 are the same, and updates the count value of pCNT on the server to dCNTnew.

[0130] Embodiments of the present disclosure provide a data transmission system. The system is used to implement the above-mentioned embodiments and preferred embodiments, which have been described and will not be repeated. As used below, the term "unit" can be a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, hardware, or a combination of software and hardware, implementation is also possible and is contemplated.

[0131] The data transmission system comprises a server and a gas meter device.

[0132] The server is configured to receive a request indicating that a target operation needs to be performed by the gas meter device, update a count value of a first counter corresponding to the target operation type of the target operation of the gas meter device on the server from a current count value of the first counter to a first count value, the first count value being greater than the current count value, encrypt a parameter of the target operation to obtain ciphertext of the parameter, determine a first check code according to the first count value and the ciphertext, and send the first count value, the ciphertext and the first check code to the gas meter device.

[0133] The gas meter device is configured to determine that the target operation fails to be performed when the received count value is not greater than a current count value of a second counter corresponding to the target operation type on the gas meter device, determine a second check code according to the count value received by the gas meter device and the ciphertext when the received count value is greater than the current count value of the second counter, determine that the target operation fails to be performed when the first check code is different from the second check code, decrypt the ciphertext to obtain the parameter when the first check code is the same as the second check code, perform the target operation according to the parameter, determine that the target operation succeeds to be performed after the target operation is performed, update the count value of the second counter from the current count value of the second counter to the first count value, and send feedback information indicating that the target operation succeeds to be performed or the target operation fails to be performed to the server.

[0134] In one possible implementation, the gas meter device is further configured to update the count value of the second counter from the first count value to a second count value greater than the first count value when the gas meter device determines that the target operation succeeds to be performed after the gas meter device sends the feedback information to the server, encrypt a response parameter of the target operation to obtain ciphertext of the response parameter of the target operation, determine a third check code according to the second count value and the ciphertext of the response parameter of the target operation, and send the second count value, the ciphertext of the response parameter of the target operation and the third check code to the server. The server is further configured to determine that the target operation fails to be performed when the received count value corresponding to the gas meter device is not greater than the current count value of the first counter, determine a fourth check code according to the count value corresponding to the gas meter device received by the server and the ciphertext of the response parameter of the target operation when the received count value corresponding to the gas meter device is greater than the current count value of the first counter, determine that the target operation succeeds to be performed when the third check code is the same as the fourth check code, and update the count value of the first counter to the second count value and update information corresponding to the target operation type according to the response parameter of the target operation.

[0135] In a possible implementation, the server is further configured to determine a first check code according to the first count value and the ciphertext of the parameter of the target operation by using the key corresponding to the target operation type; and the gas meter device is further configured to determine a second check code according to the count value received by the gas meter device and the ciphertext of the parameter of the target operation by using the key corresponding to the target operation type.

[0136] In a possible implementation, the gas meter device is further configured to determine a third check code according to the second count value and the ciphertext of the response parameter of the target operation by using the key corresponding to the target operation type; and the server is further configured to determine a fourth check code according to the received ciphertext of the response parameter of the target operation corresponding to the count value of the gas meter device by using the key corresponding to the target operation type.

[0137] Although the embodiments of the present disclosure are described in conjunction with the accompanying drawings, various modifications and changes can be made by those skilled in the art without departing from the spirit and scope of the present disclosure, and such modifications and changes fall within the scope defined by the appended claims.

Claims

1. A data transmission method, characterized by, The method comprises: The server receives a request indicating that the gas meter device needs to perform a target operation, updates a count value of a first counter corresponding to the target operation type of the target operation on the server and the gas meter device from a current count value of the first counter to a first count value, the first count value being greater than the current count value; The server encrypts parameters of the target operation to obtain ciphertext of the parameters; The server determines a first check code according to the first count value and the ciphertext; The server sends the first count value, the ciphertext and the first check code to the gas meter device; The gas meter device determines that the target operation fails when the received count value is not greater than a current count value of a second counter corresponding to the target operation type on the gas meter device; The gas meter device determines a second check code according to the count value received by the gas meter device and the ciphertext when the received count value is greater than the current count value of the second counter; The gas meter device determines that the target operation fails when the first check code is different from the second check code; The gas meter device decrypts the ciphertext to obtain the parameters when the first check code is the same as the second check code, performs the target operation according to the parameters, and determines that the target operation succeeds after the target operation is performed, updates the count value of the second counter from the current count value of the second counter to the first count value; The gas meter device sends feedback information indicating that the gas meter device determines that the target operation succeeds or the target operation fails to the server.

2. The method of claim 1, wherein, After the gas meter device sends the feedback information to the server, the method further comprises: The gas meter device updates the count value of the second counter from the first count value to a second count value greater than the first count value when the gas meter device determines that the target operation succeeds; The gas meter device encrypts response parameters of the target operation to obtain ciphertext of the response parameters of the target operation; The gas meter device determines a third check code according to the second count value and the ciphertext of the response parameters of the target operation; The gas meter device sends the second count value, the ciphertext of the response parameters of the target operation and the third check code to the server; The server determines that the target operation fails when the received count value corresponding to the gas meter device is not greater than the current count value of the first counter; The server determines a fourth check code according to the count value corresponding to the gas meter device received by the server and the ciphertext of the response parameters of the target operation when the received count value corresponding to the gas meter device is greater than the current count value of the first counter; The server determines that the target operation fails when the third check code is different from the fourth check code; The server determines that the target operation succeeds when the third check code is the same as the fourth check code, updates the count value of the first counter to the second count value, and updates information corresponding to the target operation type according to the response parameters of the target operation.

3. The method of claim 1, wherein, The determination of the first check code according to the first count value and the ciphertext comprises: determining a first check code according to the first count value, and ciphertext of a parameter of the target operation, by using a key corresponding to a target operation type; and determining a second check code according to the count value received by the gas meter device and the ciphertext comprises: determining a second check code according to the count value received by the gas meter device and ciphertext of a parameter of the target operation, by using a key corresponding to a target operation type.

4. The method of claim 2, wherein, determining a third check code according to the second count value and ciphertext of a response parameter of the target operation comprises: determining a third check code according to the second count value and ciphertext of a response parameter of the target operation, by using a key corresponding to a target operation type; and determining a fourth check code according to the count value corresponding to the gas meter device received by the server and ciphertext of a response parameter of the target operation comprises: determining a fourth check code according to the count value corresponding to the gas meter device received by the server and ciphertext of a response parameter of the target operation, by using a key corresponding to a target operation type.

5. The method according to any one of claims 1-4, characterized in that, The target operation is one of the following: a recharge operation, a deduction operation.

6. A data transmission system, characterized by The system comprises: a server and a gas meter device; The server is configured to receive a request indicating that a target operation needs to be performed by the gas meter device, update a count value of a first counter corresponding to a target operation type of the target operation of the gas meter device on the server from a current count value of the first counter to a first count value, the first count value being greater than the current count value, encrypt a parameter of the target operation to obtain ciphertext of the parameter, determine a first check code according to the first count value and the ciphertext, and send the first count value, the ciphertext and the first check code to the gas meter device. The gas meter device is configured to determine that the target operation fails to be performed when the received count value is not greater than a current count value of a second counter corresponding to the target operation type on the gas meter device, determine a second check code according to the count value received by the gas meter device and the ciphertext when the received count value is greater than the current count value, determine that the target operation fails to be performed when the first check code is different from the second check code, decrypt the ciphertext to obtain the parameter when the first check code is the same as the second check code, perform the target operation according to the parameter, and determine that the target operation is successfully performed after the target operation is performed, update the count value of the second counter from the current count value of the second counter to the first count value, and send feedback information indicating that the gas meter device determines that the target operation is successfully performed or that the target operation fails to be performed to the server.

7. The system of claim 6, wherein, The gas meter device is further configured to update the count value of the second counter from the first count value to a second count value greater than the first count value when the gas meter device determines that the target operation is successfully performed after the gas meter device sends the feedback information to the server. encrypting a response parameter of the target operation to obtain ciphertext of the response parameter of the target operation; determining a third check code according to the second count value and ciphertext of the response parameter of the target operation; determining a third check code according to the second count value and ciphertext of the response parameter of the target operation; and The service end is further configured to: send the second counter value, the ciphertext of the response parameter of the target operation, and a third check code to the gas meter device; when the received counter value corresponding to the gas meter device is not greater than the current counter value of the first counter, determine that the target operation fails; when the received counter value corresponding to the gas meter device is greater than the current counter value of the first counter, determine a fourth check code according to the received counter value corresponding to the gas meter device and the ciphertext of the response parameter of the target operation; when the third check code is different from the fourth check code, determine that the target operation fails; when the third check code is the same as the fourth check code, determine that the target operation succeeds, update the counter value of the first counter to the second counter value, and update the information corresponding to the target operation type according to the response parameter of the target operation.

8. The system of claim 6, wherein, The service end is further configured to: determine a first check code according to the first counter value and the ciphertext of the parameter of the target operation by using the key corresponding to the target operation type; and the gas meter device is further configured to: determine a second check code according to the received counter value and the ciphertext of the parameter of the target operation by using the key corresponding to the target operation type.

9. The system of claim 7, wherein, The gas meter device is further configured to: determine a third check code according to the second counter value and the ciphertext of the response parameter of the target operation by using the key corresponding to the target operation type; and the service end is further configured to: determine a fourth check code according to the received counter value corresponding to the gas meter device and the ciphertext of the response parameter of the target operation by using the key corresponding to the target operation type.

10. The system of any one of claims 6-9, wherein, The target operation is one of the following: a recharge operation and a deduction operation.

Citation Information

Patent Citations

  • Data transmission method and related device

    CN114884622A

  • Sending and receiving methods and devices, unmanned equipment and storage medium

    CN116506061A