Detailed Description
Embodiments of the present disclosure are described in detail below, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to like or similar elements or elements having like or similar functions throughout. The embodiments described below by referring to the drawings are exemplary and intended for the purpose of explaining the present disclosure and are not to be construed as limiting the present disclosure.
Data transmission methods, apparatuses, electronic devices, and computer-readable storage media of the embodiments of the present disclosure are described below with reference to the accompanying drawings.
Fig. 1 is a flowchart of a data transmission method according to an embodiment of the disclosure. In the present disclosure, the inventor finds that in the field of video coding, a GOP (video compression technology used by MPEG) has a good compression effect, so that transmission efficiency can be improved, and the GOP can completely play video content without concern about its context.
In the present disclosure, a standard GOP is set to include a full-size data frame I and a difference data frame P, where the full-size data frame includes complete data, and the difference data frame includes a difference between data sent this time and data of the full-size data frame sent last time.
As shown in fig. 1, the method comprises the steps of:
step 101, determining whether the frame interval of the last transmission of the full data frame to the client accords with 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 present disclosure may be performed by the data transmission device of the embodiment of the present disclosure, and the data transmission device of the embodiment of the present disclosure may be configured in any server to perform the data transmission method of the embodiment of the present disclosure, where the server may be a local server or a server disposed in a cloud.
The client refers to an application program, a web page, a terminal device, or the like which is served by the server.
Wherein the frame interval is used to indicate the last time a full data frame was transmitted to the total number of frames that have been currently transmitted. The set frame number is a preset frame number indicating the frame number included between two transmission of the full-size data frame. That is, it is set in the present disclosure that the full data frame is transmitted every set number of frames. For example, if the number of frames is 10, a full-frame data frame is transmitted every 10 frames.
In the present disclosure, the number of frames that have been transmitted for the last transmission of the full-size data frame is compared with the set number of frames according to the distance indicated by the frame interval to determine whether the set number of frames is met.
For example, the frame number is set to be 10 frames, the full-quantity data frames are sent by 0 frames, and if the frame interval between the frame to be sent currently and the frame which is sent the full-quantity data frames to the client last time is determined to be 7 frames, the frame interval 7 frames do not accord with the set frame number of 10 frames; if the frame interval between the frame to be transmitted and the frame which transmits the full data frame to the client last time is 10 frames, the frame interval 10 frames accords with the set frame number 10 frames.
Step 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 accords with the set frame number, the full-volume data frame with larger data volume is sent to the client, and compared with the mode of only sending the full-volume data frame in the prior art, the flow data consumed by the client when receiving the data frame is reduced, so that the flow of the client is controllable.
Step 103, if the frame interval does not meet 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.
In this embodiment, if it is determined that the sent frame number indicated by the frame interval meets the set frame number, the requirement of sending the full-size data frame to the client based on the set frame number is met, the full-size data frame is sent to the client, if the requirement of sending the full-size data frame to the client based on the set frame number is not met, the full-size data frame or the difference data frame can be determined to be sent to the client according to the time interval of sending the full-size data frame to the client last time, so as to meet the accuracy requirement of data sending, meanwhile, the flow consumption of the client is considered, and compared with the prior art, the accuracy of displaying data by the client is improved by only sending the difference data frame.
In a possible implementation manner of the embodiment of the present disclosure, it is determined that the frame interval does not conform to the set frame number, and according to a time interval of last sending of a full-size data frame to the client, if the time interval is greater than or equal to a threshold duration, it is determined that the full-size data frame is sent to the client, and if the time interval is less than the threshold duration, it is determined that the difference data frame is sent to the client, so that when the frame interval does not conform to the set frame number, it is determined whether to send the full-size data frame or the difference data frame according to the time interval, so as to meet a requirement of data frame sending, and improve accuracy of data sending.
In the data transmission method of this embodiment, it is determined whether the frame interval of the full-size data frame that was last transmitted to the client matches the set frame number, if the frame interval matches the set frame number, it is determined to transmit the full-size data frame to the client, and if the frame interval does not match the set frame number, it is determined to transmit the full-size data frame or the difference data frame to the client according to the time interval of the full-size data frame that was last transmitted to the client. In this embodiment, based on the set frame number and the sending time interval, the sending of the full-volume data frame or the difference data frame is determined, and because the difference data frame is the difference data sent for each client, the data volume is smaller, so that the client flow is controllable, and because the full-volume data frame contains comprehensive data, no data loss exists, and therefore the accuracy of issuing data is also satisfied.
Based on the above embodiment, the present embodiment provides another data transmission method, taking a securities application scenario among application scenarios issued by large-flow data as an example, and fig. 2 is a flow chart of another data transmission method provided by the embodiment of the present disclosure.
As shown in fig. 2, the method comprises the steps of:
step 201, successfully establishing connection with the client, and setting the round value corresponding to the client as an initial value.
The execution subject of the present disclosure is a server, where the server is a server of a security application, and the client is all applications of the security installed in a terminal device of a user, or may be a web page, an application program, or the like used by a manager or a developer of the security application to manage and maintain the security application, which is not limited in the embodiments of the present disclosure.
In this embodiment, after a connection is established between the server and the client, the round value corresponding to the client is set to 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, inquiring a round value corresponding to the client, wherein the round value is used for indicating the total frame number of the data frames sent to the client, and the data frames comprise a full data frame and a difference data frame.
The round value is dynamically changed, and when the server transmits the data frames to the client, the round value corresponding to the client is added with 1, so that the round value is used for indicating the total frame number of the data frames sent to the client, and the data frames comprise full data frames and difference data frames.
In step 203, if the round value is an integer multiple of the set frame number, it is determined that the frame interval matches the set frame number.
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 disclosure, according to the obtained round value, it is determined whether the round value is an integer multiple of the set frame number, if the round value is the integer multiple, it is determined that the frame interval accords with the set frame number, that is, the frame which has been transmitted currently accords with the set frame number relative to the frame which has been transmitted last time to the client, and the full-size data frame can be transmitted to the client.
For example, the number of frames is set to 10 frames, that is, a full-frame data frame is transmitted every 10 frames, the acquired round value is 30 frames, the round value is 30 frames which are 3 times as large as the set number of frames 10 frames, and the frame interval between the frame to be currently transmitted and the full-frame data frame to be transmitted last is determined to be 10 frames, and the 10 frames are consistent with the set number of frames 10 frames, so that it is determined that the full-frame data frame can be transmitted again to the client.
In a possible implementation manner of the embodiment of the present disclosure, before the full-size data frame is sent to the client, the full-size data frame to be sent may be obtained from the first interface, that is, the full-size data frame is obtained through a dedicated first interface, and by setting an independent first interface at the server, the full-size data frame is obtained through the first interface, so that protocol analysis is not required, and the full-size data frame can be directly sent to the corresponding client after being obtained, thereby reducing the delay of data sending.
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, the obtained round value is 36 frames, the 36 frames are not integer multiples of the set frame number 10 frames, the frame interval is determined to be 6, the set frame number 10 frames are not met, whether the full-size data frames can be transmitted or not is determined according to the frame interval, further, in order to improve the accuracy of the frames to be transmitted, the time interval for transmitting the full-size data frames can be set, whether the full-size data frames are transmitted or the difference data frames are transmitted is determined according to the time interval, and the accuracy of data transmission is improved.
Step 206, determining whether the time interval is greater than or equal to the threshold duration according to the time interval of the last transmission of the full data frame to the client, 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-size data frame is satisfied according to the time interval for retransmitting the full-size data frame to the client, and when the time interval for retransmitting the full-size data frame is not satisfied, the transmission of the difference data frame is performed, so as to improve the accuracy of the data displayed to the client, and reduce the traffic consumption of the client.
Step 207, determining to send the difference data frame to the client, and sending the difference data frame to the client.
In this embodiment, when it is determined that the difference data frame is sent to the client, so that when the total data frame is not sent again, the difference data frame is sent, so as to reduce the flow requirement of the client, and ensure the accuracy of the display data of the client.
In another embodiment of the present disclosure, before sending the difference data frame to the client, the difference data frame to be sent may be obtained from the second interface, that is, the difference data frame is obtained through a dedicated second interface, and by setting an independent second interface at the server, the difference data frame is obtained through the second interface, so that protocol analysis is not required, and the difference data frame can be directly sent to the corresponding client after being obtained, thereby reducing the delay of data sending.
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, it may be queried 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, and conversely, if the query determines that the round value corresponding to the client is an initial value, it may be determined that the server and the client have not performed service data communication, and cannot send the difference data frame to the client, and discard the obtained difference data frame and do not send the difference data frame to the corresponding client.
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 a difference data frame which is different from the last transmitted full-size data frame.
For example, there are 5000 stocks, the total data frame is all data of 5000 stocks, and the difference data frame indicates that only 200 stocks are updated compared with the 5000 stocks transmitted last time, so the difference data frame transmitted this time is the data of 200 stocks updated with data, and the data of 4800 stocks not updated is not transmitted.
Wherein the data of each stock may contain the following fields:
head: a header field holding some meta information, wherein frame_type is key parameter information for representing a frame type;
op_code: an operation code;
code: a security code;
buy_value: total commission purchase amount;
sel_value: total commission sales;
but_volume: total commission purchase amount;
sel_volume: total commission sales;
detail: list of specific structures, detailed information.
The specific structure list may include the following fields:
price: price of securities;
volume: stock exchange;
level: a transaction gear;
and (3) flag: a transaction direction;
major_volume: stock order consignment;
and the order list is the detailed order information.
And step 208, updating the round value corresponding to the client.
In this embodiment, the round value is used to indicate the total frame number of the data frames sent to the client, where the data frames include a full data frame and a difference data frame, so that after the difference 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, the round value corresponding to the client may be added by 1 in an accumulated manner to update.
In the data transmission method of this embodiment, it is determined whether the frame interval of the full-size data frame that was last transmitted to the client matches the set frame number, if the frame interval matches the set frame number, it is determined to transmit the full-size data frame to the client, and if the frame interval does not match the set frame number, it is determined to transmit the full-size data frame or the difference data frame to the client according to the time interval of the full-size data frame that was last transmitted to the client. In this embodiment, based on the set frame number and the sending time interval, the sending of the full-volume data frame or the difference data frame is determined, and because the difference data frame is the difference data sent for each client, the data volume is smaller, so that the client flow is controllable, and because the full-volume data frame contains comprehensive data, no data loss exists, and therefore the accuracy of issuing data is also satisfied.
In order to implement the above embodiment, the present disclosure further proposes a data transmission device.
Fig. 3 is a schematic structural diagram of a data transmission device according to an embodiment of the disclosure.
As shown in fig. 3, the apparatus includes: an interval determining module 31, a first transmitting module and a second transmitting module.
The interval determining module is used for determining whether the frame interval of the full data frame which is transmitted to the client last time accords with the set frame number;
the first determining module is used for determining to send the full data frame to the client if the frame interval accords with the 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 the last full data frame sent to the client if the frame interval does not accord with the set frame number.
Further, in one possible implementation manner of the embodiment of the 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 time length, determining to send the difference data frame to the client.
In one possible implementation of the embodiments of the present disclosure, the interval determining module includes:
the inquiring unit is used for inquiring the round value corresponding to the client; the round value is used for indicating the total frame number of the data frames sent to the client; the data frames comprise the full data frame and the difference data frame;
a determining unit, configured to determine that the frame interval conforms to 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 one possible implementation of an embodiment of the disclosure, the apparatus further includes:
the acquisition module is used for acquiring the total data frames to be transmitted from the first interface; and/or obtaining the difference data frame to be transmitted from the second interface.
The sending module is used for sending the data frames to the client;
and the updating module is used for updating the round value corresponding to the client.
In one possible implementation manner of the embodiment of the present disclosure, the interval determining module further includes:
and the setting unit is used for successfully establishing the connection with the client, and setting the round value corresponding to the client as an initial value.
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 of the embodiment of the data transmission method is also applicable to the data transmission device of this embodiment, and the principle is the same, and will not be repeated here.
In the data transmission device of this embodiment, it is determined whether the frame interval of the full-size data frame that was last transmitted to the client matches the set frame number, if the frame interval matches the set frame number, it is determined to transmit the full-size data frame to the client, and if the frame interval does not match the set frame number, it is determined to transmit the full-size data frame or the difference data frame to the client according to the time interval of the full-size data frame that was last transmitted to the client. In this embodiment, based on the set frame number and the sending time interval, the sending of the full-volume data frame or the difference data frame is determined, and because the difference data frame is the difference data sent for each client, the data volume is smaller, so that the client flow is controllable, and because the full-volume data frame contains comprehensive data, no data loss exists, and therefore the accuracy of issuing data is also satisfied.
To achieve the above embodiments, an embodiment of the present disclosure proposes 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 transmission method of the foregoing method embodiment.
In one embodiment of the present disclosure, an electronic device is presented, and referring now to FIG. 4, a schematic diagram of a configuration of an electronic device suitable for use in implementing embodiments of the present disclosure is shown. The electronic device in the embodiment of the disclosure may be a single server or a server cluster. The electronic device shown in fig. 4 is merely an example and should not be construed to limit the functionality and scope of use of the disclosed embodiments.
As shown in fig. 4, the electronic device 800 may include a processing means (e.g., a central processor, a graphics processor, etc.) 801, which may perform various appropriate actions and processes according to programs stored in a Read Only Memory (ROM) 802 or programs loaded from a storage 808 into a Random Access Memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 are also stored. The processing device 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 the bus 804.
In general, the following devices may be connected to the I/O interface 805: input devices 806 including, for example, a touch screen, touchpad, keyboard, mouse, camera, microphone, accelerometer, gyroscope, and the like; an output device 807 including, for example, a Liquid Crystal Display (LCD), speakers, vibrators, etc.; storage 808 including, for example, magnetic tape, hard disk, etc.; communication means 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 shows 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 be implemented or provided instead.
In particular, according to embodiments of the present disclosure, the processes described above with reference to 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 shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via communication device 809, or installed from storage device 808, or installed from ROM 802. When the computer program is executed by the processing device 801, the above-described functions defined in the data transmission method of the embodiment of the present disclosure are performed.
In particular, according to embodiments of the present disclosure, the processes described above with reference to 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 shown in the flowcharts. In such an embodiment, the computer program may be downloaded and installed from a network via communication device 809, or installed from storage device 808, or installed from ROM 802. When the computer program is executed by the processing device 801, the above-described functions defined in the data transmission method of the embodiment of the present disclosure are performed.
It should be noted that the computer readable medium described in the present disclosure may be a computer readable signal medium or a computer readable storage medium, or any combination of the two. The computer readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or a combination of any 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 context of this 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 the present disclosure, however, the computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, with the computer-readable program code embodied therein. Such a propagated data signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination of the foregoing. 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, fiber optic cables, RF (radio frequency), and the like, or any suitable combination of the foregoing.
The computer readable medium may be contained in the access control server; or may exist alone without being assembled into the access control server.
The above computer-readable medium carries one or more programs that, when executed by the access control server, cause the access control server to: determining whether a frame interval of the full-size data frame which is transmitted to the client last time accords with a set frame number, if the frame interval accords with the set frame number, determining to transmit the full-size data frame to the client, and if the frame interval does not accord with the set frame number, determining to transmit the full-size data frame or the difference data frame to the client according to a time interval of the full-size data frame which is transmitted to the client last time.
Computer program code for carrying out operations of the present disclosure may be written in 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 kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to an external computer (for example, through the Internet using an Internet service provider).
The flowcharts 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 involved in the embodiments of the present disclosure may be implemented by means of software, or may be implemented by means of hardware. Wherein the names of the units do not constitute a limitation of the units themselves in some cases.
In order to implement the above-mentioned 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 according to the above-mentioned method embodiments.
Fig. 5 is a schematic structural view of a computer-readable storage medium provided by an embodiment of the present disclosure. As shown in fig. 5, a computer-readable storage medium 300 according to an embodiment of the present disclosure has computer instructions 301 stored thereon. When executed by a processor, the computer instructions 301 perform all or part of the steps of the data transmission methods of the various embodiments of the present disclosure described previously.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by means of software plus necessary general hardware platforms, or of course may be implemented by means of hardware. Based on this understanding, the foregoing technical solution may be embodied essentially or in a part contributing to the prior art 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), etc., and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the data transmission method described in the respective embodiments or some parts of the embodiments.
Finally, it should be noted that: the above embodiments are merely for illustrating the technical solution of the present disclosure, and are not limiting thereof; 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 scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present disclosure.