[go: up one dir, main page]

CN118827691B - Data transmission method, device, equipment and storage medium - Google Patents

Data transmission method, device, equipment and storage medium

Info

Publication number
CN118827691B
CN118827691B CN202311546205.5A CN202311546205A CN118827691B CN 118827691 B CN118827691 B CN 118827691B CN 202311546205 A CN202311546205 A CN 202311546205A CN 118827691 B CN118827691 B CN 118827691B
Authority
CN
China
Prior art keywords
transmitted
data
server
data block
transmission
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202311546205.5A
Other languages
Chinese (zh)
Other versions
CN118827691A (en
Inventor
李宗明
刘强
吴比
张鹏飞
杨贻成
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Mobile Communications Group Co Ltd
China Mobile IoT Co Ltd
Original Assignee
China Mobile Communications Group Co Ltd
China Mobile IoT Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Mobile Communications Group Co Ltd, China Mobile IoT Co Ltd filed Critical China Mobile Communications Group Co Ltd
Priority to CN202311546205.5A priority Critical patent/CN118827691B/en
Publication of CN118827691A publication Critical patent/CN118827691A/en
Application granted granted Critical
Publication of CN118827691B publication Critical patent/CN118827691B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/104Peer-to-peer [P2P] networks
    • H04L67/1074Peer-to-peer [P2P] networks for supporting data block transmission mechanisms
    • H04L67/1078Resource delivery mechanisms
    • H04L67/108Resource delivery mechanisms characterised by resources being split in blocks or fragments
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/12Protocols specially adapted for proprietary or special-purpose networking environments, e.g. medical networks, sensor networks, networks in vehicles or remote metering networks
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L69/00Network arrangements, protocols or services independent of the application payload and not provided for in the other groups of this subclass
    • H04L69/03Protocol definition or specification 

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Health & Medical Sciences (AREA)
  • Computing Systems (AREA)
  • General Health & Medical Sciences (AREA)
  • Medical Informatics (AREA)
  • Computer Security & Cryptography (AREA)
  • Communication Control (AREA)

Abstract

The invention discloses a data transmission method, a device, equipment and a storage medium, when testing the CoAP protocol block transmission capability of an Internet of things platform, a client acquires the transmission byte number of a data block sent to a server before sending the next data block to the server each time, and when the transmission byte number is not equal to a minimum transmission byte threshold value, the transmission byte number is reduced to send the data block, and then a test result of the data transmission of the client can be determined according to data to be uploaded and a transmission flow thereof. Because the number of transmission bytes of the data block is selectively reduced before the client sends the data block to the server each time, the method can cover a test scene that SZX is smaller than the expected value of the server during the block transmission of the client and can cover a scene that SZX dynamically changes during the block transmission of the CoAP client, the scene accords with the RFC CoAP protocol specification, the universal adaptability of the platform protocol is improved, and the processing efficiency of the data block transmission of the Internet of things platform is improved.

Description

Data transmission method, device, equipment and storage medium
Technical Field
The present invention relates to the field of testing technologies, and in particular, to a data transmission method, apparatus, device, and storage medium.
Background
The CoAP protocol is designed for the internet of things, and because many devices in the internet of things are resource-constrained, namely, only a small amount of memory space and limited computing power are needed, the conventional HTTP protocol is too large to be applicable when applied to the internet of things, and the CoAP protocol can well solve the problem, so that the CoAP protocol is often deployed on nodes and networks with resource limitation. In the prior art, the CoAP protocol blocking transmission capability of the internet of things platform is usually tested by using real industrial equipment, after a client is connected to the internet of things, the client can automatically register and upload to the internet of things platform, then the client can report data (such as detection data of a sensor) acquired by own service to a server, blocking transmission can be performed during the period, and after all the block data are transmitted, the data reporting condition is checked in the internet of things platform equipment attribute function history record, so that the CoAP protocol blocking transmission capability of the internet of things platform is verified.
In the traditional scene of verifying the CoAP protocol Block transmission capability of the Internet of things platform, when a client reports data, the client performs Block transmission according to SZX (Block Size Index) expected by a server by default, and according to CoAP protocol specifications, the SZX is not required to be unchanged in the whole course during the Block transmission of the client, and can be smaller than an SZX expected value. The traditional scheme does not cover a test scene of SZX dynamic adjustment, so that the universal adaptability of the CoAP protocol is poor, and the processing efficiency of the data block transmission of the Internet of things platform is reduced.
Disclosure of Invention
The embodiment of the invention aims to provide a data transmission method, a device, equipment and a storage medium, which are applied to a test scene of a CoAP protocol, and can effectively improve the universal suitability of the CoAP protocol, thereby improving the processing efficiency of the data block transmission of an Internet of things platform.
In order to achieve the above object, an embodiment of the present invention provides a data transmission method, including:
before sending the next data block to the server, acquiring a first transmission byte number of the data block sent to the server last time;
if the first transmission byte number is larger than a preset transmission byte minimum threshold value, reducing the first transmission byte number to obtain a second transmission byte number;
Partitioning the data to be uploaded according to the second transmission byte number to obtain a data block to be transmitted which accords with the second transmission byte number;
And sending the data block to be transmitted to the server.
As an improvement of the above solution, before the obtaining the first transmission byte number of the data block sent to the server, the method further includes:
partitioning data to be uploaded according to a preset initial transmission byte number, so as 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, acquiring a target transmission byte number in the response message;
and when the target transmission byte number is smaller than the initial transmission byte number, re-blocking the data to be uploaded according to the target transmission byte number so as to send the initial data block conforming to the target transmission byte number to the server.
As an improvement of the above solution, the method further includes:
When receiving a timeout retransmission test instruction, after receiving a first response message sent by the server, suspending sending a next data block to be transmitted to the server, 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, respectively obtaining message identifiers of the first response message and the second response message;
When the message identifiers of the first response message and the second response message are the same, judging that the second response message is a timeout retransmission message, and sending the next data block to be transmitted to the server.
As an improvement of the above solution, the method further includes:
when the message identifiers of the first response message and the second response message are different, judging that the second response message is an error response message, continuing to wait for receiving the second response message until the received second response message is the overtime retransmission message, and sending a next data block to be transmitted to the server.
As an improvement of the above solution, before sending the data block to be transmitted to the server, the method further includes:
before sending a current data block to be transmitted to the server, acquiring an identification code in the current data block to be transmitted;
When the identification code is a preset end field, judging the data block to be transmitted as the last data block in the data to be uploaded;
And when the identification code is a preset non-ending field, judging that at least one data block to be transmitted exists in the data to be uploaded and is not transmitted.
As an improvement of the above solution, the method further includes:
And when the first transmission byte number is equal to the transmission byte minimum threshold, partitioning the data to be uploaded according to the transmission byte minimum threshold to obtain a data block to be transmitted which accords with the transmission byte minimum threshold.
As an improvement of the above solution, before the data to be uploaded is blocked according to the preset initial transmission byte number, the method further includes:
And starting a packet grabbing tool, wherein the packet grabbing tool is used for recording data transmission operation of the client and the server.
In order to achieve the above object, an embodiment of the present invention further provides a data transmission device, including:
The byte number adjusting module is used for acquiring a first transmission byte number of a data block which is transmitted to the server before transmitting a next data block to the server, and reducing the first transmission byte number to obtain a second transmission byte number if the first transmission byte number is larger than a preset minimum transmission byte threshold;
The data block partitioning module is used for partitioning the data to be uploaded according to the second transmission byte number to obtain a data block to be transmitted which accords with the second transmission byte number;
and the data block sending module is used for sending the data block to be transmitted to the server.
To achieve the above object, an embodiment of the present invention further provides a data transmission device, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor, where the processor executes the computer program to implement the data transmission method according to any one of the embodiments.
To achieve the above object, an embodiment of the present invention further provides a computer readable storage medium, where the computer readable storage medium includes a stored computer program, where the computer program when executed controls a device where the computer readable storage medium is located to execute the data transmission method according to any one of the embodiments.
Compared with the prior art, the data transmission method, the device, the equipment and the storage medium disclosed by the invention have the advantages that when the CoAP protocol block transmission capability of the Internet of things platform is tested, the client acquires the transmission byte number of the data block which is transmitted to the server before transmitting the next data block to the server each time, and when the transmission byte number is not equal to the minimum transmission byte threshold value, the transmission byte number is reduced to transmit the data block until the transmission of all the data blocks to be transmitted corresponding to the data to be uploaded is detected, and then the test result of the data transmission of the client is determined according to the data to be uploaded and the transmission flow thereof. Because the number of transmission bytes of the data block is reduced before the client sends the data block to the server each time, the test scene that SZX is smaller than the expected value of the server SZX during the block transmission of the client and the scene that SZX dynamically changes during the block transmission of the CoAP client can be covered, the scene accords with the RFC (Request For Comments, request comment) CoAP protocol specification, the universal adaptability of the platform protocol is improved, and the processing efficiency of the data block transmission of the Internet of things platform is improved.
Drawings
FIG. 1 is a block diagram of a data block provided by an embodiment of the present invention;
FIG. 2 is a block diagram of a client according to an embodiment of the present invention;
fig. 3 is a first flowchart of a data transmission method according to an embodiment of the present invention;
FIG. 4 is a second flowchart of a data transmission method according to an embodiment of the present invention;
fig. 5 is a third flowchart of a data transmission method according to an embodiment of the present invention;
fig. 6 is a fourth flowchart of a data transmission method according to an embodiment of the present invention;
fig. 7 is a block diagram of a data transmission device according to an embodiment of the present invention;
fig. 8 is a block diagram of a data transmission device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The CoAP is based on UDP (User Datagram Protocol ), according to the physical characteristics of ethernet, when the UDP data length is greater than 1472 bytes, UDP data fragmentation is performed, which is very unfavorable for nodes and networks with limited resources, and a better solution is to limit the size of transmission data, so the CoAP protocol is extended by RFC7959 chunk transmission, the data to be transmitted is split into a plurality of data chunks by using a "Block" option, the maximum length of each data chunk is 1024 bytes, and even if the header length of the CoAP protocol is added, its total length is also far less than 1472 bytes, so that UDP data fragmentation phenomenon can be avoided. The Block structure is shown in fig. 1, the NUM field indicates the number of the data Block (starting from 0), the M field indicates whether there is a subsequent Block, the 1 field indicates that there is a subsequent Block, 0 indicates that there is a current last Block, the SZX field indicates the index of the size of the data Block, the maximum length of the data block=2 (szx+4), the SZX value range is 0 to 6, if the SZX value is 0, the maximum length of the data block=16, if the SZX value is 6, the maximum length of the data block=1024, and so on, thereby calculating the maximum length value of the data Block [16,32,64,128,256,512,1024].
The module structure of the client (CoAP simulation client) applied in the embodiment of the present invention may refer to fig. 2, including:
The registration module is internally provided with an access machine address+port, a product ID, a device name and a device key, the module is preferentially started after a client program is started, then registration online operation is carried out, and the detailed registration flow please refer to an access mode of an Internet of things platform-document center-CoAP protocol in the prior art and is not repeated here;
The keep-alive module periodically sends heartbeat messages to a server (a CoAP access machine of an Internet of things platform) after the client is online, so that the client can be ensured to continuously keep an online state;
the logout module actively initiates a downloading command to the server by the client, and then the platform-equipment management page of the Internet of things can see that the CoAP equipment is in an offline state;
The data reporting module is provided with a blocking transmission processing function and an identification code caching function, wherein the blocking transmission processing function is used for client SZX adjustment, server SZX expected value comparison and server response message timeout retransmission scene construction during blocking transmission, the identification code caching function is used for a test scene of server response message timeout retransmission, after receiving a response message, the client firstly assigns an identification code in the response message to a global variable, and when the response message is received again next time, the identification code in the response message is compared with the global variable, and if the identification code is consistent, the response message is the timeout retransmission response message.
Referring to fig. 3, fig. 3 is a first flowchart of a data transmission method according to an embodiment of the present invention, where the data transmission method includes:
s1, before a next data block is sent to a server, acquiring a first transmission byte number of the data block which is sent to the server last time;
s2, if the first transmission byte number is larger than a preset minimum transmission byte threshold, reducing the first transmission byte number to obtain a second transmission byte number;
S3, partitioning the data to be uploaded according to the second transmission byte number to obtain a data block to be transmitted which accords with the second transmission byte number;
And S4, sending the data block to be transmitted to the server.
It should be noted that, the data transmission method in the embodiment of the present invention is implemented by executing the client, before the client sends the data to be uploaded to the server, the data to be uploaded is split into a plurality of data blocks and sequentially transmitted to the server, after the client sends the data blocks to the server once, the server returns a response message when receiving the data blocks, and the client sends the next data block after receiving the response message until all the data blocks are sent. In the process, the data transmission process of the client can be tested by means of the Internet of things platform, so that the CoAP protocol blocking transmission capability and application are evaluated.
For example, after the client finishes sending the initial data block (the first data block), before sending the non-initial data block to the server each time, the client needs to obtain the first transmission byte number of the data block sent to the server last time, and then compares the first transmission byte number with a preset minimum transmission byte threshold, for example, the minimum transmission byte threshold is 0 (or is the rest of values in 0-6, which can be set by the tester at will), that is, szx=0 of the data block is satisfied, and the maximum length of the corresponding data block is 16 bytes at this time. If the number of the first transmission bytes is greater than the preset minimum threshold of the transmission bytes, the number of the first transmission bytes is reduced to obtain the number of the second transmission bytes, if the number of the first transmission bytes is 6, the maximum length of the corresponding data block is 1024 bytes, the number of the first transmission bytes is greater than 0, and if the number of the first transmission bytes is adjusted to 5 or adjusted to 4, 3, 2 and other parameters, the mode of specifically adjusting the numerical value is not particularly limited, and a tester can adjust the number of the first transmission bytes by himself. And judging whether all the data blocks to be transmitted corresponding to the data to be uploaded are completely transmitted, entering a subsequent testing step after the transmission is completed, and repeating the steps S1-S4 when the transmission is not completed.
Specifically, in step S2, when the first number of transmission bytes is equal to the minimum transmission byte threshold, the data to be uploaded is blocked according to the minimum transmission byte threshold, so as to obtain a data block to be transmitted that meets the minimum transmission byte threshold.
For example, if the number of first transmission bytes of the previous data block is equal to 0, the number of first transmission bytes of the next data block is also 0, and there is no need to reduce the number of first transmission bytes, and there is a case that the number of first transmission bytes of all the remaining data blocks is equal to 0, that is, the maximum lengths of the remaining data blocks are all 16 bytes. It should be noted that, since the data to be uploaded is not particularly large (generally 2000 bytes to 4000 bytes), the number of divided data blocks is not very large, and the first transmission byte may already transmit the full data when not changing to 0.
In the embodiment of the invention, the number of transmission bytes of the data block is selectively reduced before the client sends the data block to the server each time, so that a test scene that SZX is smaller than the expected value of the server SZX during the block transmission of the client and a scene that SZX dynamically changes during the block transmission of the CoAP client can be covered, the scene accords with the RFC CoAP protocol specification, the universal suitability of a platform protocol is improved, and the processing efficiency of the data block transmission of the Internet of things platform is improved.
Specifically, before executing step S1, referring to fig. 4, fig. 4 is a second flowchart of a data transmission method provided in an embodiment of the present invention, where the method further includes:
s11, partitioning data to be uploaded according to a preset initial transmission byte number, so as to send an initial data block conforming to the initial transmission byte number to the server;
s12, after receiving a response message sent by the server, acquiring a target transmission byte number in the response message;
S13, when the target transmission byte number is smaller than the initial transmission byte number, the data to be uploaded are segmented again according to the target transmission byte number, and initial data blocks conforming to the target transmission byte number are sent to the server.
Specifically, in step S11, at the initial stage of the test, data to be uploaded to the server is prepared, and the length of the data to be uploaded should be within a set range, for example, greater than 2000 bytes, and too short a length may result in too few blocks, which may have poor test results. And partitioning the data to be uploaded according to the preset initial transmission byte number, wherein the initial transmission byte number is 6, namely the maximum length of the initial data block=2 (SZX+4) =1024 bytes. Optionally, the number of the initial transmission bytes may be set according to the length of the data to be uploaded, in direct proportion to the length of the data to be uploaded, if the length of the data to be uploaded is longer, the number of the initial transmission bytes is correspondingly set to be larger, if the length of the data to be uploaded is shorter, the number of the initial transmission bytes is correspondingly set to be smaller, if the length of the data to be uploaded is set to be 0 or 1, and a tester can set according to needs.
Specifically, in step S12, after the client sends the initial block data to the server, the client receives a response message returned by the server, and then the client records the target number of transmission bytes carried in the response message as szx_exit (i.e., SZX expected value, where the range of values is 0-6). Optionally, since the SZX expected value of the CoAP access machine of the internet of things platform is generally not lower than 2, the target number of transmission bytes is generally greater than or equal to 2, that is, the expected value of the maximum length of the data block is generally not lower than 64 bytes.
Specifically, in step S13, when the target number of transmission bytes is smaller than the initial number of transmission bytes, it indicates that the number of transmission bytes that can be received by the server is exceeded, and the data to be uploaded needs to be re-blocked according to the target number of transmission bytes, so as to send the initial data block that conforms to the target number of transmission bytes to the server. When the target transmission byte number is greater than the initial transmission byte number, the method accords with the scene that SZX is smaller than the expected value of SZX during the block transmission of the client, so the client can continuously send the next data block to be transmitted without re-blocking. When the target transmission byte number is equal to the initial transmission byte number, the same client can continue to send the next data block to be transmitted without re-blocking.
In the embodiment of the invention, for the transmission of the initial data block, the initial data block is required to be generated according to the default initial transmission byte number at the client because of the lack of the last referenceable data block transmission mode, so that the initial data can be quickly generated, the data transmission efficiency is improved, and the test efficiency is further improved. In addition, when the initial data block is transmitted, the client can upload the initial data block to the server only when the condition that the initial transmission byte number of the initial data block is smaller than or equal to the target transmission byte number is required to be met, and the scene accords with the RFC CoAP protocol specification.
Specifically, during the period of transmitting data by the client in blocks, each time a data block is transmitted, the server responds, the client receives the response and then transmits the next block of data, during this period, the client may not receive the response due to network fluctuation, and at this time, the server may send a response message (i.e. timeout retransmission) to the client again. But the probability of network fluctuation in the test process is very low, so that the traditional test mode is difficult to cover the test scene of the overtime retransmission of the response message of the server. In order to cover the test scene of the timeout retransmission of the response message of the server, the embodiment of the invention also provides a timeout retransmission test method aiming at the client and the server when transmitting data, wherein the timeout retransmission test instruction can be manually triggered by a tester and is generally only triggered once and used for testing whether the server has a timeout retransmission mechanism.
Specifically, referring to fig. 5, fig. 5 is a third flowchart of a data transmission method according to an embodiment of the present invention, where the method further includes:
s21, when a timeout retransmission test instruction is received, after a first response message sent by the server is received, suspending sending of a next data block to be transmitted to the server;
S22, after receiving a second response message sent by the server, respectively obtaining message identifiers of the first response message and the second response message;
S23, when the message identifiers of the first response message and the second response message are the same, judging that the second response message is a timeout retransmission message, and sending a next data block to be transmitted to the server.
And S24, when the message identifications of the first response message and the second response message are different, judging that the second response message is an error response message, and continuing to wait for receiving the second response message until the received second response message is the overtime retransmission message, and sending a next data block to be transmitted to the server.
Specifically, in step S21, when performing the timeout retransmission test of the server, after receiving the first response message sent by the server, the client pauses sending the next data block to be transmitted to the server, and is used for simulating a scenario that the client does not receive a response due to network fluctuation, 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 to the client after the server receives the data block to be transmitted. After receiving the first response message, the client side 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), and the message identifier is MID (Message ID).
Specifically, in step S22, since the client side does not continue to send the next data block to be transmitted after receiving the first response message, the server will continue to send the second response message to the server at this time, and inform the client side that the next data block to be transmitted can continue to be sent, after receiving the second response message, the client side needs to check the message, compares the message identifier in the second response message with the message identifier in the buffer memory, if the MID is the same, it indicates that the second response message is a timeout retransmission message, the client side can send the next data block to be transmitted to the server, if the MID is different, it determines that the second response message is an error response message, possibly the server has an error, for example, a message responding to other data blocks, at this time, the client side continues to wait to receive the second response message until the received second response message is the timeout retransmission message, and sends the next data block to be transmitted to the server.
In the embodiment of the invention, because the probability of network fluctuation naturally occurs during the CoAP block transmission of the Internet of things platform in the public network is very low and manual control is not good, but the Internet of things platform is used as a provider of protocol access capability, and abnormal conditions are that the platform needs to be tested, so that more stable and high-quality service can be provided for users, therefore, by adopting the test mode of the steps S21-S24, the test scene of the CoAP server for responding to the overtime retransmission of the message can be covered, the universal suitability of the platform protocol is further increased, and the processing efficiency of the Internet of things platform for data block transmission is improved.
Specifically, before executing step S4, referring to fig. 6, fig. 6 is a fourth flowchart of a data transmission method provided in an embodiment of the present invention, where the method further includes:
s31, before sending the current data block to be transmitted to the server, acquiring an identification code of the current data block to be transmitted;
s32, when the identification code is a preset end field, judging the data block to be transmitted as the last data block in the data to be uploaded;
and S33, when the identification code is a preset non-end field, judging that at least one data block to be transmitted exists in the data to be uploaded and is not transmitted.
The identification code is a value of an "M field" of a Block structure, the end field is 0, the non-end field is 1, when the identification code is 1, it indicates that the current data Block to be transmitted is not the last data Block and has a subsequent data Block to be uploaded, when the identification code is 0, it indicates that the current data Block to be transmitted is the last Block, the next step is entered after the transmission is completed, and steps S1-S4 are repeated when the transmission is not completed.
Specifically, before executing step S21, the method further comprises starting a packet grabbing tool, wherein the packet grabbing tool is used for recording data transmission operations of a client and the server.
The method includes the steps that when a client is started, a Wireshark packet grabbing tool is started (a tester is convenient to check the whole CoAP block transmission process), after the data to be uploaded is uploaded by the client, whether the whole CoAP block transmission process is consistent with a test step is checked in the Wireshark, and data reporting history is checked on a CoAP equipment attribute interface of an Internet of things platform to check whether data which is just reported by the client and whether the data are correct or not. And if no abnormality exists, the test is passed, otherwise, the package grabbing file is provided for a developer to conduct problem checking, and therefore the data transmission test process of the client is completed.
Compared with the prior art, in the data transmission method disclosed by the invention, when testing the CoAP protocol block transmission capability of the Internet of things platform, the client acquires the transmission byte number of the data block transmitted to the server before transmitting the next data block to the server each time, and when the transmission byte number is not equal to the minimum transmission byte threshold value, the transmission byte number is reduced to transmit the data block until the transmission of all the data blocks to be transmitted corresponding to the data to be uploaded is detected, and then the test result of the data transmission of the client is determined according to the data to be uploaded and the transmission flow thereof. As the number of transmission bytes of the data block is reduced before the client sends the data block to the server each time, the method can cover a test scene that SZX is smaller than the expected value of the server during the block transmission of the client and a scene that SZX dynamically changes during the block transmission of the CoAP client, the scene accords with the RFC CoAP protocol specification, the universal adaptability of the platform protocol is improved, and the processing efficiency of the data block transmission of the Internet of things platform is improved. In addition, the test method for adding the timeout retransmission mechanism can cover the test scene of the response message timeout retransmission of the CoAP server side, and further increase the universal suitability of the platform protocol, thereby improving the processing efficiency of the data block transmission of the Internet of things platform.
Fig. 7 is a block diagram of a data transmission device 100 according to an embodiment of the present invention, where the data transmission device 100 includes:
the byte number adjusting module 11 is configured to obtain a first transmission byte number of a data block that is sent to the server before sending a next data block to the server;
a data block partitioning module 12, configured to partition data to be uploaded according to the second transmission byte number, so as to obtain a data block to be transmitted according to the second transmission byte number;
And the data block sending module 13 is used for sending the data block to be transmitted to the server.
The data block partitioning module 12 is further configured to partition data to be uploaded according to a preset initial transmission byte number, so as to send an initial data block according 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 re-partition the data to be uploaded according to the target transmission byte number when the target transmission byte number is smaller than the initial transmission byte number, so as to send the initial data block according to the target transmission byte number to the server.
Specifically, the data transmission device 100 further includes:
the waiting module is used for suspending sending of a next data block to be transmitted to the server after receiving a first response message sent by the server when receiving a timeout retransmission test instruction, wherein the first response message is returned by the server after receiving the data block to be transmitted;
The message identifier acquisition module is used for respectively acquiring the message identifiers of the first response message and the second response message after receiving the second response message sent by the server;
The data block transmission module 13 is further configured to:
When the message identifiers of the first response message and the second response message are the same, judging that the second response message is a timeout retransmission message, and sending a next data block to be transmitted to the server;
when the message identifiers of the first response message and the second response message are different, judging that the second response message is an error response message, continuing to wait for receiving the second response message until the received second response message is the overtime retransmission message, and sending a next data block to be transmitted to the server.
The data block sending module 13 is further configured to obtain an identification code of a current data block to be transmitted before sending the current data block to be transmitted to the server, determine that the data block to be transmitted is the last data block in the data to be uploaded when the identification code is a preset end field, and determine that at least one data block to be transmitted is still present in the data to be uploaded when the identification code is a preset non-end field.
Specifically, the data block partitioning module 12 is further configured to, when the first number of transmission bytes is equal to the minimum transmission byte threshold, partition the data to be uploaded according to the minimum transmission byte threshold, so as to obtain a data block to be transmitted that meets the minimum transmission byte threshold.
Specifically, the data transmission device 100 further includes:
the system comprises a packet grabbing module, a packet grabbing tool and a server, wherein the packet grabbing module is used for starting the packet grabbing tool, and the packet grabbing tool is used for recording data transmission operation of the client and the server.
It should be noted that, the working process of each module in the data transmission device 100 according to the embodiment of the present invention may refer to the working process of the data transmission method according to the above embodiment, which is not described herein.
Compared with the prior art, when testing the CoAP protocol block transmission capability of the internet of things platform, the data transmission device 100 disclosed by the invention obtains the transmission byte number of the data block sent to the server before each time the client sends the next data block to the server, and reduces the transmission byte number to send the data block when the transmission byte number is not equal to the minimum transmission byte threshold value until the data block to be transmitted corresponding to the data to be uploaded is detected to be sent completely, and then determining the test result of the data transmission of the client according to the data to be uploaded and the transmission flow thereof. As the number of transmission bytes of the data block is reduced before the client sends the data block to the server each time, the method can cover a test scene that SZX is smaller than the expected value of the server during the block transmission of the client and a scene that SZX dynamically changes during the block transmission of the CoAP client, the scene accords with the RFC CoAP protocol specification, the universal adaptability of the platform protocol is improved, and the processing efficiency of the data block transmission of the Internet of things platform is improved. In addition, the test method for adding the timeout retransmission mechanism can cover the test scene of the response message timeout retransmission of the CoAP server side, and further increase the universal suitability of the platform protocol, thereby improving the processing efficiency of the data block transmission of the Internet of things platform.
Fig. 8 is a block diagram of a data transmission apparatus 200 according to an embodiment of the present invention, the data transmission apparatus 200 including a processor 21, a memory 22, and a computer program stored in the memory 22 and executable on the processor 21. The steps of the above embodiments of the data transmission method, such as steps S1 to S4, are implemented when the processor 21 executes the computer program.
Illustratively, the computer program may be partitioned into one or more modules/units that are stored in the memory 22 and executed by the processor 21 to complete the present invention. The one or more modules/units may be a series of computer program instruction segments capable of performing the specified functions, which instruction segments are used to describe the execution of the computer program in the data transmission device 200.
The data transmission device 200 may include, but is not limited to, a processor 21, a memory 22. It will be appreciated by those skilled in the art that the schematic diagram is merely an example of the data transmission device 200 and does not constitute a limitation of the data transmission device 200, and may include more or less components than illustrated, or may combine certain components, or different components, e.g., the data transmission device 200 may also include input-output devices, network access devices, buses, etc.
The Processor 21 may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (DIGITAL SIGNAL Processor, DSP), application SPECIFIC INTEGRATED Circuit (ASIC), off-the-shelf Programmable gate array (Field-Programmable GATE ARRAY, FPGA) or other Programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. The general purpose processor may be a microprocessor or the processor may be any conventional processor or the like, and the processor 21 is a control center of the data transmission apparatus 200, and connects the respective parts of the entire data transmission apparatus 200 using various interfaces and lines.
The memory 22 may be used to store the computer program and/or module, and the processor 21 may implement various functions of the data transmission device 200 by executing or executing the computer program and/or module stored in the memory 22 and invoking data stored in the memory 22. The memory 22 may mainly include a storage program area that may store an operating system, application programs required for at least one function (such as a sound playing function, an image playing function, etc.), etc., and a storage data area that may store data created according to the use of the cellular phone (such as audio data, a phonebook, etc.), etc. In addition, the memory 22 may include high-speed random access memory, and may also include non-volatile memory, such as a hard disk, memory, plug-in hard disk, smart memory card (SMART MEDIA CARD, SMC), secure Digital (SD) card, flash memory card (FLASH CARD), at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage device.
Wherein the integrated modules/units of the data transmission device 200 may be stored in a computer readable storage medium if implemented in the form of software functional units and sold or used as a stand alone product. Based on such understanding, the present invention may implement all or part of the flow of the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and the computer program may implement the steps of each of the method embodiments described above when executed by the processor 21. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth.
While the foregoing is directed to the preferred embodiments of the present invention, it will be appreciated by those skilled in the art that changes and modifications may be made without departing from the principles of the invention, such changes and modifications are also intended to be within the scope of the invention.

Claims (9)

1.一种数据传输方法,其特征在于,应用于CoAP协议,所述方法包括:1. A data transmission method, characterized in that it is applied to the CoAP protocol, the method comprising: 在发送下一数据块给服务器前,获取上一发送给服务器的数据块的第一传输字节数;Before sending the next data block to the server, obtain the first number of bytes transmitted in the previous data block sent to the server; 若所述第一传输字节数大于预设的传输字节最小阈值,则降低所述第一传输字节数,得到第二传输字节数;If the first number of transmitted bytes is greater than the preset minimum threshold for transmitted bytes, then the first number of transmitted bytes is reduced to obtain the second number of transmitted bytes; 按照所述第二传输字节数对待上传数据进行分块,得到一个符合所述第二传输字节数的待传输数据块;The data to be uploaded is divided into blocks according to the second number of bytes to be transmitted, resulting in a data block to be transmitted that meets the second number of bytes to be transmitted; 将所述待传输数据块发送给所述服务器;Send the data block to be transmitted to the server; 其中,所述获取上一发送给服务器的数据块的第一传输字节数前,所述方法还包括:Before obtaining the first number of transmitted bytes of the data block previously sent to the server, the method further includes: 按照预设的初始传输字节数对待上传数据进行分块,以将符合所述初始传输字节数的初始数据块发送给所述服务器;The data to be uploaded is divided into blocks according to a preset initial number of bytes to be transmitted, and the initial data blocks that meet the initial number of bytes to be transmitted are sent to the server. 在接收到所述服务器发送的响应报文后,获取所述响应报文中的目标传输字节数;After receiving the response message sent by the server, obtain the target number of bytes to be transmitted in the response message; 当所述目标传输字节数小于所述初始传输字节数时,按照所述目标传输字节数对所述待上传数据进行重新分块,以将符合所述目标传输字节数的初始数据块发送给所述服务器。When the target number of bytes to be transmitted is less than the initial number of bytes to be transmitted, the data to be uploaded is re-divided into blocks according to the target number of bytes to be transmitted, so that the initial data blocks that meet the target number of bytes to be transmitted are sent to the server. 2.如权利要求1所述的数据传输方法,其特征在于,所述方法还包括:2. The data transmission method as described in claim 1, characterized in that the method further comprises: 接收到超时重传测试指令时,在接收所述服务器发送的第一响应报文后,暂停发送下一待传输数据块给所述服务器;其中,所述第一响应报文为所述服务器在接收到所述待传输数据块后返回的;Upon receiving a timeout retransmission test command, after receiving the first response message sent by the server, the transmission of the next data block to be transmitted to the server is paused; wherein, the first response message is returned by the server after receiving the data block to be transmitted; 在接收到所述服务器发送的第二响应报文后,分别获取所述第一响应报文和所述第二响应报文的报文标识;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; 当所述第一响应报文和所述第二响应报文的报文标识相同时,判定所述第二响应报文为超时重传报文,并发送下一待传输数据块给所述服务器。When the message identifiers of the first response message and the second response message are the same, the second response message is determined to be a timeout retransmission message, and the next data block to be transmitted is sent to the server. 3.如权利要求2所述的数据传输方法,其特征在于,所述方法还包括:3. The data transmission method as described in claim 2, characterized in that the method further includes: 当所述第一响应报文和所述第二响应报文的报文标识不相同时,判定所述第二响应报文为错误响应报文,继续等待接收第二响应报文,直至接收到的所述第二响应报文为所述超时重传报文时,发送下一待传输数据块给所述服务器。When the message identifiers of the first response message and the second response message are different, the second response message is determined to be an error response message, and the server continues to wait to receive the second response message until the received second response message is the timeout retransmission message, at which point the next data block to be transmitted is sent to the server. 4.如权利要求1所述的数据传输方法,其特征在于,在将所述待传输数据块发送给所述服务器前,所述方法还包括:4. The data transmission method as described in claim 1, characterized in that, before sending the data block to be transmitted to the server, the method further includes: 在发送当前待传输数据块给所述服务器前,获取当前待传输数据块中标识码;Before sending the current data block to be transmitted to the server, obtain the identification code in the current data block to be transmitted; 当所述标识码为预设的结束字段时,判定所述待传输数据块为所述待上传数据中的最后一个数据块;When the identifier is a preset end field, the data block to be transmitted is determined to be the last data block in the data to be uploaded; 当所述标识码为预设的非结束字段时,判定所述待上传数据中还存在至少一个待传输数据块未发送。When the identifier is a preset non-end field, it is determined that there is at least one data block to be transmitted that has not been sent in the data to be uploaded. 5.如权利要求1所述的数据传输方法,其特征在于,所述方法还包括:5. The data transmission method as described in claim 1, characterized in that the method further comprises: 当所述第一传输字节数等于所述传输字节最小阈值时,按照所述传输字节最小阈值对所述待上传数据进行分块,得到符合所述传输字节最小阈值的待传输数据块。When the first number of transmitted bytes is equal to the minimum threshold for transmitted bytes, the data to be uploaded is divided into blocks according to the minimum threshold for transmitted bytes to obtain data blocks to be transmitted that meet the minimum threshold for transmitted bytes. 6.如权利要求1所述的数据传输方法,其特征在于,在按照预设的初始传输字节数对待上传数据进行分块前,所述方法还包括:6. The data transmission method as described in claim 1, characterized in that, before dividing the data to be uploaded into blocks according to a preset initial number of bytes to be transmitted, the method further includes: 启动抓包工具;其中,所述抓包工具用于记录客户端和所述服务器的数据传输操作。Start the packet capture tool; wherein, the packet capture tool is used to record the data transmission operations between the client and the server. 7.一种数据传输装置,其特征在于,应用于CoAP协议,所述装置包括:7. A data transmission apparatus, characterized in that it is applied to the CoAP protocol, the apparatus comprising: 字节数调整模块,用于在发送下一数据块给服务器前,获取上一发送给服务器的数据块的第一传输字节数;若所述第一传输字节数大于预设的传输字节最小阈值,则降低所述第一传输字节数,得到第二传输字节数;The byte count adjustment module is used to obtain the first number of bytes transmitted in the previous data block sent to the server before sending the next data block to the server; if the first number of bytes transmitted is greater than a preset minimum threshold for bytes transmitted, the first number of bytes transmitted is reduced to obtain the second number of bytes transmitted. 数据块分块模块,用于按照所述第二传输字节数对待上传数据进行分块,得到一个符合所述第二传输字节数的待传输数据块;The data block segmentation module is used to segment the data to be uploaded into blocks according to the second number of bytes to be transmitted, so as to obtain a data block to be transmitted that conforms to the second number of bytes to be transmitted; 数据块发送模块,用于将所述待传输数据块发送给所述服务器;A data block sending module is used to send the data block to be transmitted to the server; 其中,所述数据块分块模块还用于:按照预设的初始传输字节数对待上传数据进行分块,以将符合所述初始传输字节数的初始数据块发送给所述服务器;在接收到所述服务器发送的响应报文后,获取所述响应报文中的目标传输字节数;当所述目标传输字节数小于所述初始传输字节数时,按照所述目标传输字节数对所述待上传数据进行重新分块,以将符合所述目标传输字节数的初始数据块发送给所述服务器。The data block segmentation module is further configured to: segment the data to be uploaded into blocks according to a preset initial transmission byte count, so as to send the initial data blocks that conform to the initial transmission byte count to the server; after receiving a response message sent by the server, obtain the target transmission byte count in the response message; when the target transmission byte count is less than the initial transmission byte count, re-segment the data to be uploaded into blocks according to the target transmission byte count, so as to send the initial data blocks that conform to the target transmission byte count to the server. 8.一种数据传输设备,其特征在于,包括处理器、存储器以及存储在所述存储器中且被配置为由所述处理器执行的计算机程序,所述处理器执行所述计算机程序时实现如权利要求1至6中任意一项所述的数据传输方法。8. A data transmission device, characterized in that it comprises 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 implement the data transmission method as described in any one of claims 1 to 6. 9.一种计算机可读存储介质,其特征在于,所述计算机可读存储介质包括存储的计算机程序,其中,在所述计算机程序运行时控制所述计算机可读存储介质所在设备执行如权利要求1至6中任意一项所述的数据传输方法。9. A computer-readable storage medium, characterized in that the computer-readable storage medium includes a stored computer program, wherein, when the computer program is executed, it controls the device where the computer-readable storage medium is located to perform the data transmission method as described in any one of claims 1 to 6.
CN202311546205.5A 2023-11-17 2023-11-17 Data transmission method, device, equipment and storage medium Active CN118827691B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311546205.5A CN118827691B (en) 2023-11-17 2023-11-17 Data transmission method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311546205.5A CN118827691B (en) 2023-11-17 2023-11-17 Data transmission method, device, equipment and storage medium

Publications (2)

Publication Number Publication Date
CN118827691A CN118827691A (en) 2024-10-22
CN118827691B true CN118827691B (en) 2025-12-09

Family

ID=93069141

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311546205.5A Active CN118827691B (en) 2023-11-17 2023-11-17 Data transmission method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN118827691B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101656756A (en) * 2009-09-17 2010-02-24 中国科学院声学研究所 File transferring method with self-adaptive control of transmission speed and system thereof
CN107071826A (en) * 2011-03-17 2017-08-18 华为技术有限公司 The method and apparatus of transmitting data resources

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101825210B1 (en) * 2016-09-06 2018-02-02 한림대학교 산학협력단 OBSERVATION PERIOD ADJUSTMENT SYSTEM AND METHOD OF CoAP SERVER
CN115695262B (en) * 2022-09-27 2026-02-03 南方电网科学研究院有限责任公司 Intelligent gateway test system
CN116016549B (en) * 2022-12-12 2024-10-01 中科南京软件技术研究院 Method and system for dynamically and piecewise uploading data file

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101656756A (en) * 2009-09-17 2010-02-24 中国科学院声学研究所 File transferring method with self-adaptive control of transmission speed and system thereof
CN107071826A (en) * 2011-03-17 2017-08-18 华为技术有限公司 The method and apparatus of transmitting data resources

Also Published As

Publication number Publication date
CN118827691A (en) 2024-10-22

Similar Documents

Publication Publication Date Title
CN109302346B (en) Method and device for transmitting data flow
US8488661B2 (en) Systems and methods for data streaming
CN108429701B (en) Network acceleration system
CN112311628B (en) Network speed measuring method, system, network equipment and storage medium
US20200007427A1 (en) Path metric measurement
WO2024103783A1 (en) Dynamic host configuration protocol testing method, electronic device and computer storage medium
US11991061B2 (en) Processing local area network diagnostic data
CN112910793A (en) Method for connection multiplexing in seven-layer load balancing and load balancer
CN110248379B (en) Performance test method and device for base station in wireless local area network
US11196649B2 (en) Processing local area network diagnostic data
CN104580228A (en) System and method for blacklisting access requests from network
CN113595812A (en) Client identification method, device, storage medium and network equipment
CN107135091B (en) An application quality index mapping method, server and client
CN118827691B (en) Data transmission method, device, equipment and storage medium
CN109194706B (en) Network resource dial testing method and terminal
CN111277449A (en) Security testing method and device for voice service equipment
CN115529243B (en) Method and device for optimizing page loading speed
GB2575246A (en) Processing local area network diagnostic data
US20240179178A1 (en) Control method and apparatus, computing device, and computer-readable storage medium
CN119030972A (en) Processing method, device and storage medium for computing power and network services
CN117938542B (en) Method, device, equipment and medium for determining direction of network traffic data
CN110881213A (en) Method and system for transmitting network test process information
CN116566955B (en) Digital voice call method, device and application based on mqtt
CN115580563B (en) Mirror image data processing method and device of cloud network and electronic equipment
CN112804716B (en) Configuration method and device of data limit value and storage medium

Legal Events

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