Detailed Description
Reference will now be made in detail to the embodiments of the present disclosure, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the drawings are exemplary and intended to be illustrative of the present disclosure, and should not be construed as limiting the present disclosure.
A data transmission method, an apparatus, an electronic device, and a computer-readable storage medium of the embodiments of the present disclosure are described below with reference to the accompanying drawings.
Fig. 1 is a schematic flow chart of a data transmission method according to an embodiment of the present disclosure. In the present disclosure, the inventor finds that in the field of video coding, a GOP (a video compression technology used by MPEG) has a good compression effect, and can improve transmission efficiency, and the GOP can completely play video content without concerning the context thereof.
In this disclosure, a standard GOP is set to include a full data frame I and a difference data frame P, where the full data frame includes complete data, and the difference data frame includes a difference between data of this time of transmission and data of a last time of transmission of the full data frame.
As shown in fig. 1, the method comprises the steps of:
step 101, determining whether the frame interval of the last sending of the full data frame to the client meets the set frame number.
The execution subject of the data transmission method of the present disclosure is a server. The data transmission method of the embodiment of the disclosure can be executed by the data transmission device of the embodiment of the disclosure, and the data transmission device of the embodiment of the disclosure can be configured in any server to execute the data transmission method of the embodiment of the disclosure, wherein the server can be a local server or a server arranged at a cloud.
The client refers to an application, a web page, a terminal device, or the like that is served by the server.
Wherein the frame interval is used to indicate the total number of frames that have been transmitted from the last time the full data frame was transmitted to the current frame. The set frame number is a predetermined number indicating the number of frames included between two transmissions of the full data frame. That is, the present disclosure sets that the full data frame is transmitted once every set number of frames. For example, if the number of frames is set to 10, a full data frame is transmitted every 10 frames.
In the present disclosure, the number of frames that have been transmitted according to the frame interval indication from the last transmission of the full data frame is compared with the set number of frames to determine whether the set number of frames is met.
For example, setting the frame number to be 10 frames, sending a full data frame by 0 frame, and if determining that the frame interval between the current frame to be sent and the frame for sending the full data frame to the client at the latest time is 7 frames, the frame interval of 7 frames does not conform to the setting frame number of 10 frames; if the frame interval between the current frame to be sent and the frame for sending the full data frame to the client for the last time is determined to be 10 frames, the frame interval of 10 frames accords with the set frame number of 10 frames.
And 102, if the frame interval accords with the set frame number, determining to send the full data frame to the client.
In this embodiment, when the frame interval meets the set frame number, the full data frame with a large data volume is sent to the client, and compared with the prior art in which only the full data frame is sent, the method reduces the traffic data consumed when the client receives the data frame, so that the traffic of the client is controllable.
And 103, if the frame interval does not accord with the set frame number, determining to send the full data frame or the difference data frame to the client according to the time interval of sending the full data frame to the client at the last time.
In this embodiment, if it is determined that the sent frame number indicated by the frame interval meets the set frame number, the requirement for sending the full data frame to the client again based on the set frame number is met, the full data frame is sent to the client, and if the requirement for sending the full data frame to the client again based on the set frame number is not met, the full data frame or the differential data frame may be determined to be sent to the client according to the time interval of sending the full data frame to the client for the last time, so as to meet the accuracy requirement of data sending, and meanwhile, the traffic consumption of the client is considered.
In a possible implementation manner of the embodiment of the present disclosure, it is determined that a frame interval does not conform to a set frame number, and according to a time interval of sending a full data frame to a client for the last time, if the time interval is greater than or equal to a threshold duration, it is determined to send the full data frame to the client, and if the time interval is less than the threshold duration, it is determined to send a difference data frame to the client, so that when the frame interval does not conform to the set frame number, it may be determined whether to send the full data frame or send the difference data frame according to the time interval, so as to meet a requirement of sending the data frame, and improve accuracy of sending the data.
In the data transmission method of this embodiment, it is determined whether a frame interval at which a full data frame is last sent to the client meets a set frame number, if the frame interval meets the set frame number, it is determined to send the full data frame to the client, and if the frame interval does not meet the set frame number, it is determined to send the full data frame or a difference data frame to the client according to a time interval at which the full data frame is last sent to the client. In this embodiment, the sending of the full data frame or the differential data frame is determined based on the set frame number and the sending time interval, the traffic of the client is controllable because the differential data frame is the differential data sent by each client, and the accuracy of data sending is also satisfied because the full data frame contains comprehensive data and there is no data loss.
Based on the previous embodiment, this embodiment provides another data transmission method, which is described by taking a security application scenario in an application scenario in which large-flow data is issued as an example, and fig. 2 is a schematic flow chart of another data transmission method provided in this embodiment of the present disclosure.
As shown in fig. 2, the method comprises the following steps:
step 201, if the connection with the client is successfully established, setting the round value corresponding to the client as an initial value.
The execution subject of the present disclosure is a server, the server is a server of a certain security application, and the client is all the security applications installed in the terminal device of the user, and may also be a web page, an application, and the like used by a manager and a developer of the security applications to manage and maintain the security applications, which is not limited in the embodiment of the present disclosure.
In this embodiment, after the connection is established between the server and the client, the round value corresponding to the client is set as an initial value to indicate that no service data communication has been performed between the client and the server, that is, the server has not sent any data frame to the client.
Step 202, querying a round value corresponding to the client, where the round value is used to indicate a total frame number of data frames sent to the client, and the data frames include a full data frame and a differential data frame.
The turn value is dynamically changed, and each time the server issues a data frame to the client, the turn value corresponding to the client is added with 1, so that the turn value is used for indicating the total number of data frames sent to the client, and the data frames comprise full data frames and difference data frames.
Step 203, if the round value is an integral multiple of the set frame number, determining that the frame interval accords with the set frame number.
And step 204, determining to send the full data frame to the client, and sending the full data frame to the client.
In the embodiment of the present disclosure, according to the obtained round value, it is determined whether the round value is an integer multiple of the set frame number, and if the round value is the integer multiple, it is determined that the frame interval corresponds to the set frame number, that is, the frame that has been currently sent corresponds to the set frame number with respect to the last sending of the full data frame to the client, and the full data frame can be sent to the client.
For example, the set frame number is 10 frames, that is, a full data frame is sent every 10 frames, the obtained round value is 30 frames, the round value of 30 frames is 3 times of the set frame number of 10 frames, and is an integer multiple, the frame interval between the current frame to be sent and the most recently sent full data frame is determined to be 10 frames, and 10 frames are consistent with the set frame number of 10 frames, so it is determined that the full data frame can be sent to the client again.
In a possible implementation manner of the embodiment of the present disclosure, before sending the full data frame to the client, the full data frame to be sent may also be obtained from the first interface, that is, the full data frame is obtained through the dedicated first interface, and by setting the independent first interface at the server and obtaining the full data frame through the first interface, protocol analysis may not be required, and the full data frame may be directly sent to the corresponding client after being obtained, so that a time delay of data sending is reduced.
In step 205, if the round value is not an integer multiple of the set frame number, it is determined that the frame interval does not conform to the set frame number.
For example, if the obtained round value is 36 frames, and the 36 frames are not integer multiples of 10 frames of the set frame number, it is determined that the frame interval is 6, the frame interval is not 10 frames of the set frame number, and it is not determined whether the full data frame can be sent according to the frame interval.
Step 206, according to the time interval of the last sending of the full data frame to the client, determining whether the time interval is greater than or equal to the threshold duration, if so, executing step 204, and if not, executing step 207.
In this embodiment, when it is determined that the frame interval does not meet the set frame number, it is further determined whether the time interval for retransmitting the full data frame is satisfied according to the time interval for transmitting the full data frame to the client for the last time, so as to ensure the transmission of the full data frame, and when the time interval for retransmitting the full data frame is not satisfied, the differential data frame is transmitted, so as to improve the accuracy of data transmitted to the client for display, and reduce the traffic consumption of the client.
Step 207, if it is determined that the difference data frame is sent to the client, the difference data frame is sent to the client.
In the embodiment, the difference data frame is sent to the client when the difference data frame is determined to be sent to the client, so that the difference data frame is sent when the full data frame is not sent again, the flow requirement of the client is reduced, and the accuracy of data display of the client is ensured.
In another embodiment of the present disclosure, before the differential data frame is sent to the client, the differential data frame to be sent may also be obtained from the second interface, that is, the differential data frame performs data acquisition through the dedicated second interface, and by setting the independent second interface at the server and using the second interface to perform differential data frame acquisition, it may be implemented that no protocol analysis is required, and the differential data frame may be directly sent to the corresponding client after being obtained, so as to reduce the time delay of data sending.
It should be noted that the first interface and the second interface are independent interfaces.
In another embodiment of the present disclosure, before sending the difference data frame to the client, a query may be performed to determine that the round value corresponding to the client is not an initial value, that is, when the round value corresponding to the client is not an initial value, it may be determined that the server and the client have performed service data communication, and the difference data frame may be sent to the client.
It should be noted that, when the full-size data frame and the difference data frame in the video are applied to the stock industry, the full-size data frame represents all stock data, and the difference data frame represents the difference data frame that is different from the full-size data frame that was transmitted last time.
For example, there are 5000 stocks, and the full data frame is all data of 5000 stocks, while the difference data frame indicates that only 200 stocks are updated compared with 5000 stocks sent recently, so the difference data frame sent this time is data of 200 stocks with updated data, and data of 4800 stocks not updated is not sent.
The data for each stock may include the following fields:
a header: a header field holding some meta information, where frame _ type is key parameter information for indicating a frame type;
op _ code: an operation code;
code: a security code;
buy _ value: total committed bid amount;
sel _ value: total commission sales;
buy _ volume: total committed bid amount;
self _ volume: total committed sales volume;
detail: specific structure list and detailed information.
The specific structure list may include the following fields:
price: the price of the security;
volume: the amount of securities traded;
level: a transaction gear;
flag: the direction of the transaction;
major _ volume: the volume of orders for securities;
orders, delegation lists, detailed delegation information.
And step 208, updating the corresponding round value of the client.
In this embodiment, the round value is used to indicate a total number of data frames sent to the client, where the data frames include a full data frame and a differential data frame, so that after the differential data frame or the full data frame is sent to the client, the round value corresponding to the client needs to be updated, and optionally, 1 may be added to the round value corresponding to the client in an accumulated manner to perform the update.
In the data transmission method of this embodiment, it is determined whether a frame interval at which a full data frame is last sent to the client meets a set frame number, if the frame interval meets the set frame number, it is determined to send the full data frame to the client, and if the frame interval does not meet the set frame number, it is determined to send the full data frame or a difference data frame to the client according to a time interval at which the full data frame is last sent to the client. In this embodiment, the sending of the full data frame or the differential data frame is determined based on the set frame number and the sending time interval, the traffic of the client is controllable because the differential data frame is the differential data sent by each client, and the accuracy of data sending is also satisfied because the full data frame contains comprehensive data and there is no data loss.
In order to implement the above embodiments, the present disclosure further provides a data transmission device.
Fig. 3 is a schematic structural diagram of a data transmission device according to an embodiment of the present disclosure.
As shown in fig. 3, the apparatus includes: an interval determination module 31, a first transmission module and a second transmission module.
The interval determining module is used for determining whether the frame interval of the last sending of the full data frame to the client accords with the set frame number;
a first determining module, configured to determine to send a full amount of data frames to the client if the frame interval matches a set frame number;
and the second determining module is used for determining to send the full data frame or the difference data frame to the client according to the time interval of sending the full data frame to the client at the latest time if the frame interval does not accord with the set frame number.
Further, in a possible implementation manner of the embodiment of the present disclosure, the second determining module is specifically configured to:
if the time interval is greater than or equal to a threshold duration, determining to send the full data frame to the client; and if the time interval is smaller than the threshold duration, determining to send the difference data frame to the client.
In a possible implementation manner of the embodiment of the present disclosure, the interval determining module includes:
the query unit is used for querying the round value corresponding to the client; the turn value is used for indicating the total number of data frames sent to the client; the data frames include the full data frame and the difference data frame;
a determining unit, configured to determine that the frame interval matches the set frame number if the round value is an integer multiple of the set frame number; and if the round value is not an integral multiple of the set frame number, determining that the frame interval does not accord with the set frame number.
In a possible implementation manner of the embodiment of the present disclosure, the apparatus further includes:
the acquisition module is used for acquiring a full data frame to be sent from a first interface; and/or acquiring a difference data frame to be transmitted from the second interface.
The sending module is used for sending data frames to the client;
and the updating module is used for updating the round value corresponding to the client.
In a possible implementation manner of the embodiment of the present disclosure, the interval determining module further includes:
and the setting unit is used for setting the round value corresponding to the client as an initial value if the connection with the client is successfully established.
Furthermore, as a possible implementation manner, the apparatus further includes a query module, configured to query to determine that the round value corresponding to the client is not the initial value if the difference data frame is to be sent.
It should be noted that the foregoing explanation on the embodiment of the data transmission method is also applicable to the data transmission apparatus of the embodiment, and the principle is the same, and is not described herein again.
In the data transmission apparatus of this embodiment, it is determined whether a frame interval at which a full data frame is last sent to the client meets a set frame number, if the frame interval meets the set frame number, it is determined to send the full data frame to the client, and if the frame interval does not meet the set frame number, it is determined to send the full data frame or a difference data frame to the client according to a time interval at which the full data frame is last sent to the client. In this embodiment, the sending of the full data frame or the differential data frame is determined based on the set frame number and the sending time interval, the traffic of the client is controllable because the differential data frame is the differential data sent by each client, and the accuracy of data sending is also satisfied because the full data frame contains comprehensive data and there is no data loss.
In order to implement the above embodiments, an embodiment of the present disclosure provides an electronic device, including at least one processor; and a memory communicatively coupled to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being configured to perform the data transfer method of the preceding method embodiment.
In one embodiment of the present disclosure, an electronic device is proposed, and referring to fig. 4, a schematic structural diagram of an electronic device suitable for implementing an embodiment of the present disclosure is shown. The electronic device in the embodiments of the present disclosure may be a single server or a server cluster. The electronic device shown in fig. 4 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present disclosure.
As shown in fig. 4, the electronic device 800 may include a processing means (e.g., a central processing unit, a graphics processor, etc.) 801 that may perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)802 or a program loaded from a storage means 808 into a Random Access Memory (RAM) 803. In the RAM 803, various programs and data necessary for the operation of the electronic apparatus 800 are also stored. The processing apparatus 801, the ROM 802, and the RAM 803 are connected to each other by a bus 804. An input/output (I/O) interface 805 is also connected to bus 804.
Generally, the following devices may be connected to the I/O interface 805: input devices 806 including, for example, a touch screen, touch pad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, etc.; output devices 807 including, for example, a Liquid Crystal Display (LCD), speakers, vibrators, and the like; storage 808 including, for example, magnetic tape, hard disk, etc.; and a communication device 809. The communication means 809 may allow the electronic device 800 to communicate wirelessly or by wire with other devices to exchange data. While fig. 4 illustrates an electronic device 800 having various means, it is to be understood that not all illustrated means are required to be implemented or provided. More or fewer devices may alternatively be implemented or provided.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication means 809, or installed from the storage means 808, or installed from the ROM 802. The computer program performs the above-described functions defined in the data transmission method of the embodiment of the present disclosure when executed by the processing apparatus 801.
In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication means 809, or installed from the storage means 808, or installed from the ROM 802. The computer program performs the above-described functions defined in the data transmission method of the embodiment of the present disclosure when executed by the processing apparatus 801.
It should be noted that the computer readable medium in the present disclosure can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In contrast, in the present disclosure, a computer readable signal medium may comprise a propagated data signal with computer readable program code embodied therein, either in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: electrical wires, optical cables, RF (radio frequency), etc., or any suitable combination of the foregoing.
The computer readable medium may be embodied in the access control server; or may exist separately without being installed in the access control server.
The computer readable medium carries one or more programs which, when executed by the access control server, cause the access control server to: and determining whether the frame interval of the last full data frame sent to the client accords with the set frame number, if the frame interval accords with the set frame number, determining to send the full data frame to the client, and if the frame interval does not accord with the set frame number, determining to send the full data frame or the difference data frame to the client according to the time interval of the last full data frame sent to the client.
Computer program code for carrying out operations for aspects of the present disclosure may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C + +, and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The units described in the embodiments of the present disclosure may be implemented by software or hardware. Where the name of an element does not in some cases constitute a limitation on the element itself.
In order to achieve the above embodiments, the present disclosure also proposes a computer-readable storage medium storing computer-readable instructions for causing a computer to execute the data transmission method described in the foregoing method embodiments.
Fig. 5 is a schematic structural diagram of a computer-readable storage medium provided by an embodiment of the disclosure. As shown in fig. 5, a computer readable storage medium 300 having stored thereon computer instructions 301 according to an embodiment of the present disclosure. The computer instructions 301, when executed by a processor, perform all or a portion of the steps of the data transmission methods of the various embodiments of the present disclosure as previously described.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. Based on such understanding, the above technical solutions may be embodied in the form of a software product, which may be stored in a non-transitory storage medium, such as a magnetic disk, an optical disk, a read-only memory (ROM) or a Random Access Memory (RAM), and so on, and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute the data transmission method according to each embodiment or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solutions of the present disclosure, not to limit them; although the present disclosure has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present disclosure.