Data transmission method, apparatus, device, and storage medium

By dynamically adjusting the number of bytes transmitted in a data block and adding a timeout retransmission mechanism during CoAP protocol testing, the problem of insufficient adaptability of CoAP protocol block transmission is solved, the data block transmission efficiency of the IoT platform is improved, and it complies with the RFC CoAP protocol specification.

CN118827691BActive Publication Date: 2025-12-09CHINA MOBILE M2M +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311546205.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-11-17
Publication Date
2025-12-09
Estimated Expiration
2043-11-17

AI Technical Summary

Technical Problem

In existing technologies, in the test scenarios of the CoAP protocol block transmission capability of IoT platforms, the client defaults to block transmission according to the SZX value expected by the server, which fails to cover the scenario of dynamic adjustment of SZX, resulting in poor general adaptability and reduced processing efficiency of data block transmission.

Method used

Before sending the next data block, the number of bytes transmitted in the previous data block is obtained, and the number of bytes transmitted is reduced when it exceeds a preset threshold. The block size is dynamically adjusted to cover scenarios where SZX is less than the server's expected value, and a timeout retransmission mechanism is added to simulate network fluctuations.

Benefits of technology

It improves the universal compatibility of the CoAP protocol on the IoT platform, enhances the processing efficiency of data block transmission, covers test scenarios of dynamic changes in SZX and network fluctuations, and complies with the RFC CoAP protocol specification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118827691B_ABST
    Figure CN118827691B_ABST
Patent Text Reader

Abstract

The application discloses a data transmission method, device and equipment and a storage medium. When the CoAP protocol block transmission capability of a test Internet of Things platform is tested, the client obtains the transmission byte number of the last data block sent to the server before sending the next data block to the server each time. When the transmission byte number is not equal to the minimum threshold of the transmission byte, the transmission byte number is reduced to send the data block. The test result of the client data transmission can be determined according to the to-be-uploaded data and the transmission process. Since the transmission byte number of the data block is selectively reduced before the client sends the data block to the server each time, the test scene that the SZX of the client block transmission is less than the expected value of the server SZX during the block transmission of the CoAP client can be covered, and the scene that the SZX dynamically changes during the block transmission of the CoAP client can be covered. The scene conforms to the RFC CoAP protocol specification, the general adaptability of the platform protocol is increased, and therefore the processing efficiency of the data block transmission of the Internet of Things platform is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of testing, in particular to a data transmission method, device, equipment and storage medium. BACKGROUND

[0002] CoAP protocol is a protocol designed for the Internet of Things. Since many devices in the Internet of Things are resource-limited, that is, they have only a small amount of memory space and limited computing power, the traditional HTTP protocol is too large to be applied to the Internet of Things, and the CoAP protocol can well solve this problem, so it is often deployed on resource-limited nodes and networks. In the prior art, the CoAP protocol block transmission capability of the Internet of Things platform is usually tested using real industrial devices. After the client accesses the Internet of Things, it will automatically register online to the Internet of Things platform, and then the client will report the data collected by its own business (such as sensor detection data) to the server. During this period, block transmission will be performed, and after all block data transmission is completed, the data reporting situation is checked in the device attribute function history record of the Internet of Things platform to verify the CoAP protocol block transmission capability of the Internet of Things platform.

[0003] In the traditional verification scene of the CoAP protocol block transmission capability of the Internet of Things platform, the client will perform block transmission according to the expected SZX (Block Size Index, index of data block size) of the server when reporting data, but according to the CoAP protocol specification, the SZX during client block transmission is not required to remain unchanged throughout the process, and it can also be less than the expected value of SZX. The traditional scheme does not cover the test scene of dynamic adjustment of SZX, resulting in poor general adaptability of the CoAP protocol, and thus reducing the processing efficiency of the Internet of Things platform for data block transmission. SUMMARY

[0004] The purpose of the embodiment of the present application is to provide a data transmission method, device, equipment and storage medium, which is applied in the test scene of the CoAP protocol, can effectively improve the general adaptability of the CoAP protocol, and thus improve the processing efficiency of the Internet of Things platform for data block transmission.

[0005] To achieve the above purpose, the embodiment of the present application provides a data transmission method, comprising:

[0006] Before sending the next data block to the server, the first transmission byte number of the last data block sent to the server is obtained;

[0007] If the first transmission byte number is greater than the preset minimum threshold of transmission bytes, the first transmission byte number is reduced to obtain a second transmission byte number;

[0008] According to the second transmission byte number, the to-be-uploaded data is blocked to obtain a to-be-transmitted data block conforming to the second transmission byte number.

[0009] The to-be-transmitted data block is sent to the server.

[0010] As an improvement of the above scheme, before the first transmission byte number of the last data block sent to the server is obtained, the method further comprises:

[0011] According to a preset initial transmission byte number, the to-be-uploaded data is blocked to send an initial data block conforming to the initial transmission byte number to the server.

[0012] After receiving the response message sent by the server, the target transmission byte number in the response message is obtained.

[0013] When the target transmission byte number is less than the initial transmission byte number, the to-be-uploaded data is re-blocked according to the target transmission byte number, so as to send an initial data block conforming to the target transmission byte number to the server.

[0014] As an improvement of the above scheme, the method further comprises:

[0015] When the timeout retransmission test instruction is received, after receiving the first response message sent by the server, the sending of the next to-be-transmitted data block to the server is suspended; wherein the first response message is returned by the server after receiving the to-be-transmitted data block.

[0016] After receiving the second response message sent by the server, the message identifiers of the first response message and the second response message are obtained respectively.

[0017] When the message identifiers of the first response message and the second response message are the same, it is determined that the second response message is a timeout retransmission message, and the next to-be-transmitted data block is sent to the server.

[0018] As an improvement of the above scheme, the method further comprises:

[0019] When the message identifiers of the first response message and the second response message are different, it is determined that the second response message is an error response message, and the receiving of the second response message is continued until the received second response message is the timeout retransmission message, and then the next to-be-transmitted data block is sent to the server.

[0020] As an improvement of the above scheme, before the to-be-transmitted data block is sent to the server, the method further comprises:

[0021] acquiring an identification code in the current data block to be transmitted before transmitting the current data block to be transmitted to the server;

[0022] when the identification code is a preset ending field, determining that the data block to be transmitted is the last data block in the data to be uploaded;

[0023] when the identification code is a preset non-ending field, determining that there is at least one data block to be transmitted in the data to be uploaded which has not been transmitted.

[0024] As an improvement of the above-mentioned scheme, the method further comprises:

[0025] when the first number of transmission bytes is equal to the minimum threshold of transmission bytes, the data to be uploaded is blocked according to the minimum threshold of transmission bytes, so as to obtain a data block to be transmitted which meets the minimum threshold of transmission bytes.

[0026] As an improvement of the above-mentioned scheme, before blocking the data to be uploaded according to the preset initial number of transmission bytes, the method further comprises:

[0027] starting a packet capturing tool; wherein the packet capturing tool is used to record the data transmission operation of the client and the server.

[0028] To achieve the above-mentioned purpose, the embodiment of the present application further provides a data transmission device, comprising:

[0029] a byte number adjusting module, used to acquire a first number of transmission bytes of a data block transmitted to the server last time before transmitting a next data block to the server; if the first number of transmission bytes is greater than a preset minimum threshold of transmission bytes, the first number of transmission bytes is reduced to obtain a second number of transmission bytes.

[0030] a data block blocking module, used to block the data to be uploaded according to the second number of transmission bytes, so as to obtain a data block to be transmitted which meets the second number of transmission bytes.

[0031] a data block transmitting module, used to transmit the data block to be transmitted to the server.

[0032] To achieve the above-mentioned purpose, the embodiment of the present application further provides a data transmission device, comprising a processor, a memory and a computer program stored in the memory and configured to be executed by the processor, wherein the processor executes the computer program to realize the data transmission method as described in any of the above-mentioned embodiments.

[0033] To achieve the above object, the embodiment of the present application further provides a computer readable storage medium, which comprises a stored computer program, wherein the computer readable storage medium controls a device where the computer readable storage medium is located to execute the data transmission method according to any one of the above embodiments when the computer program runs.

[0034] Compared with the prior art, the data transmission method, device, equipment and storage medium disclosed by the present application, when testing the block transmission capability of the CoAP protocol of the Internet of Things platform, the client obtains the transmission byte number of the data block sent to the server last time before sending the next data block to the server each time, and when the transmission byte number is not equal to the minimum threshold of the transmission byte, the transmission byte number is reduced to send the data block, until after detecting that all the to-be-transmitted data blocks corresponding to the to-be-uploaded data are sent, the test result of the client data transmission is determined according to the to-be-uploaded data and the transmission process. Since the transmission byte number of the data block is reduced before the client sends the data block to the server each time, the test scene that the SZX is less than the expected value of the server side SZX during the block transmission of the client can be covered, and the scene that the SZX dynamically changes during the block transmission of the CoAP client can be covered, which conforms to the RFC (Request For Comments, Request for Comments) CoAP protocol specification, increases the general adaptability of the platform protocol, and thus improves the processing efficiency of the data block transmission of the Internet of Things platform. BRIEF DESCRIPTION OF DRAWINGS

[0035] Figure 1 is a block diagram of a data block provided by the embodiment of the present application;

[0036] Figure 2 is a structural block diagram of a client provided by the embodiment of the present application;

[0037] Figure 3 is a first flowchart of a data transmission method provided by the embodiment of the present application;

[0038] Figure 4 is a second flowchart of a data transmission method provided by the embodiment of the present application;

[0039] Figure 5 is a third flowchart of a data transmission method provided by the embodiment of the present application;

[0040] Figure 6 is a fourth flowchart of a data transmission method provided by the embodiment of the present application;

[0041] Figure 7 is a structural block diagram of a data transmission device provided by the embodiment of the present application;

[0042] Figure 8is a structural block diagram of a data transmission device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0043] The technical solutions in the embodiments of the present application will be clearly and completely described in connection with the drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.

[0044] CoAP is based on UDP (User Datagram Protocol), according to the physical characteristics of Ethernet, when the length of UDP data is greater than 1472 bytes, UDP data fragmentation will be performed, which is very unfavorable for resource-limited nodes and networks. A better solution is to limit the size of the transmission data, therefore, the RFC 7959 Blockwise Transmission extends the CoAP protocol, uses the 'Block' option to split the data to be sent into many data blocks, and the maximum length of each data block is 1024 bytes. Even if the length of the CoAP protocol header is added, the total length is much smaller than 1472 bytes, so the UDP data fragmentation phenomenon can be avoided. The Block structure is shown in Figure 1 The NUM field represents the number of data blocks (starting from 0); the M field represents whether there is a subsequent block, 1 represents that there is a subsequent block, and 0 represents that the current is the last block; the SZX field represents the exponent of the data block size, the maximum length of the data block = 2^(SZX+4), and the value range of SZX is 0-6, for example, when the value of SZX is 0, the maximum length of the data block = 16, when the value of SZX is 6, the maximum length of the data block = 1024, and so on. The maximum length of the data block is calculated to be [16, 32, 64, 128, 256, 512, 1024].

[0045] The module structure of the client (CoAP simulation client) applied in the embodiments of the present application can refer to Figure 2 , including:

[0046] The registration module has an access machine address + port, a product ID, a device name and a device key. After the client program is started, the module will be started preferentially, and then the registration online operation is performed. For details of the registration process, please refer to the existing technology Internet of Things Platform-Document Center-CoAP Protocol Access Method, which will not be described here.

[0047] The keep-alive module periodically sends a heartbeat message to the server (Internet of Things Platform CoAP access machine) after the client is online, to ensure that the client can continuously maintain the online state.

[0048] The logout module initiates a logout command to the server, and then the Internet of Things platform-device management page can see that the CoAP device becomes offline.

[0049] The data reporting module has a block transmission processing function and an identification code caching function; the block transmission processing function is used for client SZX adjustment, server SZX expected value comparison, and server response message timeout retransmission scenario construction when block transmission is performed; and the identification code caching function is used for a test scenario of server response message timeout retransmission; after the client receives a response message, the identification code in the response message is assigned to a global variable, and when the next response message is received, the identification code in the response message is compared with the global variable; if they are consistent, it is indicated that the response message is a timeout retransmission response message.

[0050] Referring to Figure 3 , Figure 3 is a first flowchart of a data transmission method provided by the embodiment of the application, and the data transmission method comprises:

[0051] S1, before sending a next data block to a server, a first transmission byte number of a last data block sent to the server is acquired;

[0052] S2, if the first transmission byte number is greater than a preset minimum threshold of transmission bytes, the first transmission byte number is reduced to obtain a second transmission byte number;

[0053] S3, the to-be-uploaded data is blocked according to the second transmission byte number to obtain a to-be-transmitted data block conforming to the second transmission byte number;

[0054] S4, the to-be-transmitted data block is sent to the server.

[0055] It is worth noting that the data transmission method provided by the embodiment of the application is implemented by a client; before the client sends to-be-uploaded data to a server, the to-be-uploaded data is split into multiple data blocks, and the data blocks are transmitted to the server in sequence; after the client sends a data block to the server each time, the server returns a response message when the data block is received; the client sends a next data block after the response message is received, and the process is repeated until all data blocks are sent.

[0056] For example, after sending the initial data block (the first data block), the client needs to obtain the first transmission byte number of the last data block sent to the server before sending each non-initial data block to the server, and then compare the first transmission byte number with the preset minimum transmission byte threshold. If the minimum transmission byte threshold is 0 (or 0-6, which can be set by the tester), that is, the SZX of the data block satisfies SZX = 0, the maximum length of the corresponding data block is 16 bytes. If the first transmission byte number is greater than the preset minimum transmission byte threshold, the first transmission byte number is reduced to obtain the second transmission byte number. For example, if the first transmission byte number is 6, the maximum length of the corresponding data block is 1024 bytes, and the first transmission byte number is greater than 0. At this time, the first transmission byte number is reduced, for example, the first transmission byte number is adjusted to 5, or to 4, 3, 2, etc. The specific adjustment value is not limited here, and the tester can adjust it. Then it is judged whether all the to-be-transmitted data blocks corresponding to the to-be-uploaded data are sent completely. If yes, the subsequent test steps are entered, and if not, steps S1-S4 are repeated.

[0057] Specifically, in step S2, when the first transmission byte number is equal to the minimum transmission byte threshold, the to-be-uploaded data is blocked according to the minimum transmission byte threshold to obtain the to-be-transmitted data block meeting the minimum transmission byte threshold.

[0058] For example, if the first transmission byte number of the last data block is equal to 0, the first transmission byte number of the next data block is also 0, and the first transmission byte number does not need to be reduced. In this case, the first transmission byte number of all the remaining data blocks is equal to 0, that is, the maximum length of the remaining data blocks is 16 bytes. It is worth noting that the to-be-uploaded data to be transmitted is not particularly large (generally 2000-4000 bytes), so the number of data blocks is not large. When the first transmission byte number is not equal to 0, the entire data is sent.

[0059] In the embodiment of the application, before the client sends the data block to the server each time, the transmission byte number of the data block is selectively reduced, so as to cover the test scenario that the SZX of the client is less than the expected value of the server during the block transmission, and cover the scenario that the SZX dynamically changes during the block transmission of the CoAP client. This scenario meets the RFC CoAP protocol specification, increases the general adaptability of the platform protocol, and improves the processing efficiency of the data block transmission of the Internet of Things platform.

[0060] Specifically, before step S1 is performed, refer to Figure 4 , Figure 4is a second flowchart of a data transmission method provided by an embodiment of the application, and the method further comprises:

[0061] S11, the data to be uploaded is blocked according to a preset initial transmission byte number, so as to send an initial data block meeting the initial transmission byte number to the server;

[0062] S12, after receiving the response message sent by the server, the target transmission byte number in the response message is obtained;

[0063] S13, when the target transmission byte number is less than the initial transmission byte number, the data to be uploaded is re-blocked according to the target transmission byte number, so as to send an initial data block meeting the target transmission byte number to the server.

[0064] Specifically, in step S11, the data to be uploaded which needs to be uploaded to the server is prepared in the initial stage of the test, and the length of the data to be uploaded should be within a set range, such as greater than 2000 bytes. Too short length will result in too few blocks, and the test effect is not good. The data to be uploaded is blocked according to a preset initial transmission byte number, such as the initial transmission byte number is 6, that is, the maximum length of the initial data block = 2^(SZX+4) = 1024 bytes. Alternatively, the initial transmission byte number can be set according to the length of the data to be uploaded, which is in a positive proportional relationship with the length of the data to be uploaded. If the length of the data to be uploaded is relatively long, the initial transmission byte number corresponding to this time is set to be relatively large, such as 5 or 6. If the length of the data to be uploaded is relatively short, the initial transmission byte number corresponding to this time is set to be relatively small, such as 0 or 1. The tester can set it as needed.

[0065] Specifically, in step S12, after the client sends the initial block data to the server, the client will receive the response message returned by the server, and then the client records the target transmission byte number carried in the response message as SZX_EXPECT (that is, the expected value of SZX, the value range is 0-6). Alternatively, since the SZX expected value of the Internet of Things platform CoAP access machine is generally not less than 2, the target transmission byte number is generally greater than or equal to 2, that is, the expected value of the maximum length of the data block is generally not less than 64 bytes.

[0066] Specifically, in step S13, when the target transmission byte number is less than the initial transmission byte number, it indicates that the server can receive the transmission byte number at this time, and the to-be-uploaded data needs to be re-blocked according to the target transmission byte number to send the initial data block conforming to the target transmission byte number to the server. When the target transmission byte number is greater than the initial transmission byte number, the scenario of "the SZX during the client block transmission is less than the SZX expected value" is met at this time, and therefore the client can continue to send the next to-be-transmitted data block without re-blocking. When the target transmission byte number is equal to the initial transmission byte number, the client can continue to send the next to-be-transmitted data block without re-blocking.

[0067] In the embodiment of the application, for the transmission of the initial data block, because the last referenceable data block transmission mode is missing, the client needs to generate the initial data block according to the default initial transmission byte number, so that the initial data block can be quickly generated, the data transmission efficiency is improved, and the test efficiency is further improved. In addition, when the initial transmission byte number of the initial data block needs to be less than or equal to the target transmission byte number, the client can upload the initial data block to the server, and the scenario meets the RFC CoAP protocol specification.

[0068] Specifically, during the client block transmission of data, the server needs to respond after each data block is sent, and the client will send the next data block after receiving the response. During this period, the client may not receive the response due to network fluctuations, and the server will send the response message (i.e., timeout retransmission) to the client again. However, the probability of naturally occurring network fluctuations during the test process is very low, and therefore the traditional test method is difficult to cover the test scenario of the timeout retransmission of the server response message. In order to cover the test scenario of the timeout retransmission of the server response message, the embodiment of the application further provides a timeout retransmission test method for the transmission of data by the client and the server. The timeout retransmission test instruction can be triggered artificially by the tester, is generally triggered only once, and is used to test whether the server has a timeout retransmission mechanism.

[0069] Specifically, referring to Figure 5 , Figure 5 is a third flowchart of a data transmission method provided by the embodiment of the application, and the method further includes:

[0070] S21, when the timeout retransmission test instruction is received, after receiving the first response message sent by the server, the next to-be-transmitted data block is paused from being sent to the server;

[0071] S22, after receiving the second response message sent by the server, the packet identifiers of the first response message and the second response message are acquired, respectively.

[0072] S23, when the message identifiers of the first response message and the second response message are the same, determining that the second response message is a timeout retransmission message, and sending a next to-be-transmitted data block to the server.

[0073] S24, when the message identifiers of the first response message and the second response message are different, determining that the second response message is an error response message, continuing to wait for receiving a second response message, and when the received second response message is the timeout retransmission message, sending a next to-be-transmitted data block to the server.

[0074] Specifically, in step S21, when performing the timeout retransmission test of the server, the client pauses sending a next to-be-transmitted data block to the server after receiving a first response message sent by the server, at this time, a scenario that the client does not receive a response due to network fluctuation is simulated, so that the server considers that the response message does not reach the destination, and triggers the timeout retransmission mechanism. Preferably, the first response message is returned by the server to the client after receiving the to-be-transmitted data block. After receiving the first response message, the client writes the message identifier of the first response message into a cache (which can be realized by assigning the message identifier to a global variable), such as the message identifier being MID (Message ID).

[0075] Specifically, in step S22, since the client does not continue to send a next to-be-transmitted data block after receiving the first response message, at this time, the server continues to send a second response message to the server, informing the client that it can continue to send a next to-be-transmitted data block. After receiving the second response message, the client needs to verify the message identifier in the second response message and the message identifier in the cache, and if the MIDs are the same, it indicates that the second response message is a timeout retransmission message, and the client can send a next to-be-transmitted data block to the server. If the MIDs are different, it is determined that the second response message is an error response message, which may be a response message of other data blocks sent by mistake by the server. At this time, the client continues to wait for receiving a second response message, and when the received second response message is the timeout retransmission message, sends a next to-be-transmitted data block to the server.

[0076] In the embodiment of the present application, since the probability of natural network fluctuation is low during the CoAP block transmission of the Internet of Things platform in the public network, it is difficult to be artificially controlled, but as a provider of protocol access capability, the Internet of Things platform must be tested in abnormal conditions, so that the platform can provide more stable and high-quality services for users, therefore, the test method of steps S21-S24 can cover the test scene of CoAP server response message timeout retransmission, further increase the general adaptability of the platform protocol, thereby improving the processing efficiency of the Internet of Things platform for data block transmission.

[0077] Specifically, before step S4 is executed, referring to Figure 6 , Figure 6 is a fourth flow chart of a data transmission method provided by the embodiment of the present application, and the method further comprises:

[0078] S31, before sending the current to-be-transmitted data block to the server, obtaining an identification code in the current to-be-transmitted data block;

[0079] S32, when the identification code is a preset end field, determining that the to-be-transmitted data block is the last data block in the to-be-uploaded data;

[0080] S33, when the identification code is a preset non-end field, determining that there is at least one to-be-transmitted data block in the to-be-uploaded data which has not been sent.

[0081] Illustratively, the identification code is the value of the "M field" of the Block structure, the end field is 0, and the non-end field is 1, when the identification code is 1, it indicates that the to-be-transmitted data block currently to be transmitted is not the last data block, and there is a subsequent data block to be uploaded; when the identification code is 0, it indicates that the to-be-transmitted data block is the last block, and after sending, the next step is entered, and if it is not sent, steps S1-S4 are repeated.

[0082] Specifically, before step S21 is executed, the method further comprises: starting a packet capturing tool; wherein the packet capturing tool is used to record the data transmission operation of the client and the server.

[0083] Illustratively, when the client is started, the Wireshark packet capturing tool is started (to facilitate the tester to view the whole process of CoAP block transmission), after the to-be-uploaded data is uploaded in the client, whether the whole process of CoAP block transmission is consistent with the test steps is checked in the Wireshark, and whether the data just uploaded by the client is reported and whether the data is correct is checked in the CoAP device attribute interface of the Internet of Things platform. If all are normal, the test is passed, otherwise, the packet capturing file is provided to the developer for problem troubleshooting, thereby completing the data transmission test process of the client.

[0084] Compared with the prior art, the data transmission method disclosed by the application can, when testing the block transmission capability of the CoAP protocol of the Internet of Things platform, obtain the transmission byte number of the data block sent to the server last time before the client sends the next data block to the server each time, reduce the transmission byte number when the transmission byte number is not equal to the minimum threshold of the transmission byte, and send the data block until, after detecting that all the to-be-transmitted data blocks corresponding to the to-be-uploaded data are sent, the test result of the data transmission of the client is determined according to the to-be-uploaded data and the transmission process. Since the transmission byte number of the data block is reduced before the client sends the data block to the server each time, the test scene in which the SZX is less than the expected value of the server SZX during the block transmission of the client can be covered, and the scene in which the SZX dynamically changes during the block transmission of the CoAP client can be covered, which conforms to the RFC CoAP protocol specification, increases the general adaptability of the platform protocol, and thus improves the processing efficiency of the data block transmission of the Internet of Things platform. In addition, the test method of increasing the timeout retransmission mechanism can cover the test scene of the timeout retransmission of the CoAP server response message, further increase the general adaptability of the platform protocol, and thus improve the processing efficiency of the data block transmission of the Internet of Things platform.

[0085] Figure 7 is a structural block diagram of a data transmission device 100 provided by an embodiment of the application, and the data transmission device 100 comprises:

[0086] The byte number adjusting module 11 is configured to obtain a first transmission byte number of a data block sent to the server last time before the next data block is sent to the server, and reduce the first transmission byte number to obtain a second transmission byte number if the first transmission byte number is greater than a preset minimum threshold of the transmission byte.

[0087] The data block block module 12 is configured to block the to-be-uploaded data according to the second transmission byte number to obtain a to-be-transmitted data block conforming to the second transmission byte number.

[0088] The data block sending module 13 is configured to send the to-be-transmitted data block to the server.

[0089] Specifically, the data block block module 12 is further configured to block the to-be-uploaded data according to a preset initial transmission byte number to send an initial data block conforming to the initial transmission byte number to the server, obtain a target transmission byte number in a response message sent by the server after the response message is received, and re-block the to-be-uploaded data according to the target transmission byte number to send an initial data block conforming to the target transmission byte number to the server when the target transmission byte number is less than the initial transmission byte number.

[0090] Specifically, the data transmission device 100 further comprises:

[0091] a waiting module, configured to, when receiving a timeout retransmission test instruction, pause sending a next to-be-transmitted data block to the server after receiving a first response message sent by the server; wherein the first response message is returned by the server after receiving the to-be-transmitted data block;

[0092] a message identifier acquisition module, configured to, after receiving a second response message sent by the server, acquire message identifiers of the first response message and the second response message respectively;

[0093] Therefore, the data block sending module 13 is further configured to:

[0094] when the message identifiers of the first response message and the second response message are the same, determine that the second response message is a timeout retransmission message, and send a next to-be-transmitted data block to the server;

[0095] when the message identifiers of the first response message and the second response message are different, determine that the second response message is an error response message, continue to wait for receiving a second response message, and when the received second response message is the timeout retransmission message, send a next to-be-transmitted data block to the server.

[0096] Specifically, the data block sending module 13 is further configured to: before sending a current to-be-transmitted data block to the server, acquire an identification code in the current to-be-transmitted data block; when the identification code is a preset end field, determine that the to-be-transmitted data block is the last data block in the to-be-uploaded data; and when the identification code is a preset non-end field, determine that there is at least one to-be-transmitted data block in the to-be-uploaded data that has not been sent.

[0097] Specifically, the data block dividing module 12 is further configured to, when the first transmission byte number is equal to the minimum transmission byte threshold, divide the to-be-uploaded data according to the minimum transmission byte threshold to obtain a to-be-transmitted data block conforming to the minimum transmission byte threshold.

[0098] Specifically, the data transmission device 100 further comprises:

[0099] a packet capturing module, configured to start a packet capturing tool; wherein the packet capturing tool is used to record data transmission operations of the client and the server.

[0100] It should be noted that the working processes of the various modules in the data transmission device 100 described in the embodiments of the present application can refer to the working processes of the data transmission method described in the above embodiments, which will not be described here in detail.

[0101] Compared with the prior art, the data transmission device 100 disclosed by the application, when testing the block transmission capability of the CoAP protocol of the Internet of Things platform, the client obtains the transmission byte number of the data block sent to the server last time before sending the next data block to the server each time, and when the transmission byte number is not equal to the minimum threshold of the transmission byte number, the transmission byte number is reduced to send the data block, until after detecting that all the to-be-transmitted data blocks corresponding to the to-be-uploaded data are sent, the test result of the data transmission of the client is determined according to the to-be-uploaded data and the transmission process. Since the transmission byte number of the data block is reduced before the client sends the data block to the server each time, the test scene that the SZX is less than the expected value of the server SZX during the block transmission of the client can be covered, and the scene that the SZX dynamically changes during the block transmission of the CoAP client can be covered, which conforms to the RFC CoAP protocol specification, increases the general adaptability of the platform protocol, and thus improves the processing efficiency of the data block transmission of the Internet of Things platform. In addition, the test method of increasing the timeout retransmission mechanism can cover the test scene of the timeout retransmission of the CoAP server response message, further increase the general adaptability of the platform protocol, and thus improve the processing efficiency of the data block transmission of the Internet of Things platform.

[0102] Figure 8 is a structural block diagram of a data transmission device 200 provided by an embodiment of the application, and the data transmission device 200 includes a processor 21, a memory 22, and a computer program stored in the memory 22 and executable on the processor 21. The processor 21 implements the steps in each of the data transmission method embodiments described above when executing the computer program, such as steps S1-S4.

[0103] For example, the computer program can be divided into one or more modules / units, which are stored in the memory 22 and executed by the processor 21 to complete the application. The one or more modules / units can be a series of computer program instruction segments capable of completing a specific function, which are used to describe the execution process of the computer program in the data transmission device 200.

[0104] The data transmission device 200 can include, but is not limited to, the processor 21 and the memory 22. Those skilled in the art can understand that the schematic diagram is only an example of the data transmission device 200 and does not limit the data transmission device 200, which can include more or fewer components than the diagram, or combine certain components, or different components, for example, the data transmission device 200 can also include an input / output device, a network access device, a bus, etc.

[0105] The processor 21 can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic components, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The processor 21 is a control center of the data transmission device 200, and is connected with various parts of the data transmission device 200 through various interfaces and lines.

[0106] The memory 22 can be used to store computer programs and / or modules. The processor 21 realizes various functions of the data transmission device 200 by running or executing the computer programs and / or modules stored in the memory 22, and calling data stored in the memory 22. The memory 22 can mainly include a program storage area and a data storage area. The program storage area can store an operating system, at least one application program required by a function (such as a sound playing function, an image playing function, etc.), etc. The data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 22 can include a high-speed random access memory, and can also include a nonvolatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, at least one disk storage device, a flash memory device, or other volatile solid-state memory devices.

[0107] The modules / units of the data transmission device 200 are stored in a computer readable storage medium if they are realized in the form of software function units and sold or used as independent products. Based on this understanding, all or part of the processes in the above-mentioned embodiments can also be completed by a computer program instructing related hardware, and the computer program can be stored in a computer readable storage medium. The computer program includes computer program code, which can be in the form of source code, object code, executable files or some intermediate forms, etc. The computer readable medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal and software distribution medium, etc.

[0108] The above is the preferred embodiment of the present application. It should be pointed out that for those skilled in the art, without departing from the principles of the present application, a number of improvements and refinements can be made, which are also considered within the scope of protection of the present application.

Claims

1. A data transmission method, characterized by, The method is applied to a CoAP protocol, and the method comprises: Before sending a next data block to a server, obtaining a first transmission byte number of a last data block sent to the server; If the first transmission byte number is greater than a preset minimum threshold of transmission bytes, reducing the first transmission byte number to obtain a second transmission byte number; According to the second transmission byte number, the data to be uploaded is divided into blocks to obtain a data block to be transmitted conforming to the second transmission byte number; The data block to be transmitted is sent to the server; Before the first transmission byte number of the last data block sent to the server is obtained, the method further comprises: According to a preset initial transmission byte number, the data to be uploaded is divided into blocks to send an initial data block conforming to the initial transmission byte number to the server; After receiving a response message sent by the server, a target transmission byte number in the response message is obtained; When the target transmission byte number is less than the initial transmission byte number, the data to be uploaded is re-divided into blocks according to the target transmission byte number to send an initial data block conforming to the target transmission byte number to the server.

2. The data transmission method of claim 1, wherein, The method further comprises: When a timeout retransmission test instruction is received, after receiving a first response message sent by the server, sending of a next data block to be transmitted to the server is suspended, wherein the first response message is returned by the server after receiving the data block to be transmitted; After receiving a second response message sent by the server, message identifiers of the first response message and the second response message are obtained respectively; When the message identifiers of the first response message and the second response message are the same, it is determined that the second response message is a timeout retransmission message, and a next data block to be transmitted is sent to the server.

3. The data transmission method of claim 2, wherein, The method further comprises: When the message identifiers of the first response message and the second response message are different, it is determined that the second response message is an error response message, and the second response message is continuously received until the second response message received is the timeout retransmission message, and a next data block to be transmitted is sent to the server.

4. The data transmission method of claim 1, wherein, Before the data block to be transmitted is sent to the server, the method further comprises: Before sending a current data block to be transmitted to the server, an identifier code in the current data block to be transmitted is obtained; When the identifier code is a preset end field, it is determined that the data block to be transmitted is the last data block in the data to be uploaded; When the identifier code is a preset non-end field, it is determined that there is at least one data block to be transmitted in the data to be uploaded which has not been sent.

5. The data transmission method of claim 1, wherein, The method further comprises: When the first transmission byte number is equal to the minimum threshold of transmission bytes, the data to be uploaded is divided into blocks according to the minimum threshold of transmission bytes to obtain a data block to be transmitted conforming to the minimum threshold of transmission bytes.

6. The data transmission method of claim 1, wherein, Before the data to be uploaded is divided into blocks according to the preset initial transmission byte number, the method further comprises: A packet capturing tool is started, wherein the packet capturing tool is used to record data transmission operations of a client and the server.

7. A data transmission apparatus, characterized by comprising: The device is applied to a CoAP protocol, and the device comprises: The byte number adjusting module is configured to obtain a first transmission byte number of a data block sent to the server last time before sending a next data block to the server; if the first transmission byte number is greater than a preset minimum threshold of transmission bytes, the first transmission byte number is reduced to obtain a second transmission byte number; The data block dividing module is configured to divide the data to be uploaded according to the second transmission byte number to obtain a data block to be transmitted conforming to the second transmission byte number; The data block sending module is configured to send the data block to be transmitted to the server. The data block dividing module is further configured to divide the data to be uploaded according to a preset initial transmission byte number to send an initial data block conforming to the initial transmission byte number to the server; obtain a target transmission byte number in a response message sent by the server after receiving the response message; and when the target transmission byte number is less than the initial transmission byte number, re-divide the data to be uploaded according to the target transmission byte number to send an initial data block conforming to the target transmission byte number to the server.

8. A data transmission device, characterized by The computer readable storage medium comprises a stored computer program, wherein the computer program, when running, controls a device where the computer readable storage medium is located to perform the data transmission method according to any one of claims 1 to 6.

9. A computer-readable storage medium, characterized in that, The computer readable storage medium comprises a stored computer program, wherein the computer program, when running, controls a device where the computer readable storage medium is located to perform the data transmission method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • File transferring method with self-adaptive control of transmission speed and system thereof

    CN101656756A

  • Method and equipment for transmitting data resources

    CN107071826A