Summary of the invention
In order to address the above problem, provide the transmission speed control method of a kind of multicast package (multi-cast package) at this, it is for making a network card (network interface card, NIC) send multiple multicast packages with a target velocity.The transmission speed control method of multicast package comprises: size and target velocity according to multicast package are calculated a standard time, and record the cumulative errors time; Send one of multicast package, and calculate a transmitting time of the multicast package sending; The difference of calculating standard time and transmitting time, is recorded as this error time by the difference of standard time and transmitting time, cumulative errors time and this error time is added up to, and aggregate result is recorded to a predetermined dormancy time; In the time that predetermined dormancy time is greater than an error threshold value, carry out following steps: the predetermined dormancy time of dormancy; In dormancy, be waken up, and calculate an actual dormancy time; And to calculate the new cumulative errors time be that predetermined dormancy time subtracts actual dormancy time; And get back to the above-mentioned size according to multicast package and target velocity calculating standard time, and record the step of cumulative errors time, to send next multicast package.
Wherein calculate a standard time in the size according to multicast package and target velocity, and record among the step of a cumulative errors time, separately can comprise: set up an accumulative total transmitting time.And sending one of multicast package, and before calculating the step of a transmitting time of the multicast package sending, the processing method of multicast package separately can comprise: calculate an accumulative total transmitting time; And be greater than a cumulative time when threshold value when accumulative total transmitting time, cumulative errors time and accumulative total transmitting time are reset to 0.
According to an enforcement example, the transmission speed control method of multicast package separately can comprise: in the time that predetermined dormancy time is not more than an error threshold value, using predetermined dormancy time as the new cumulative errors time.Wherein transmitting time can be that the system time before and after the multicast package transmission of transmission is subtracted each other and obtained.
In addition, above-mentioned cumulative time threshold value can be 1 second (s).Error threshold value can be 1 millisecond (ms).Actual dormancy time can be to be greater than 10 milliseconds.
In sum, the transmission speed control method utilization of multicast package is the delay function of low precision originally, but realizes high accuracy multicast control speed.See through and in real time the accumulated error time is fed back to delay function, and the technology regularly being emptied, the transmission speed control method of multicast package can guarantee that the efficient stable of network data transmission does not take again too much central processing unit (central processor unit, CPU) resource.
Embodiment
In execution mode, describe below detailed features of the present invention and advantage in detail; its content is enough to make any those skilled in the art understand technology contents of the present invention and implement according to this; and according to the disclosed content of this specification, claim protection range and accompanying drawing, any those skilled in the art can understand object and the advantage that the present invention is relevant easily.
The present invention is about the transmission speed control method of a kind of multicast package (multi-cast package), and it is for making a network card (network interface card, NIC) send multiple multicast packages with a target velocity.
Please refer to Fig. 1, is the flow chart of the transmission speed control method of the multicast package of an enforcement example.
First the transmission speed control method of multicast package calculates a standard time according to size and the target velocity of the multicast package that will transmit, and records the cumulative errors time (step S110).Wherein the standard time is that the size of multicast package is divided by the quotient of target velocity.Follow another network card reality and send a multicast package with target velocity, and calculate a transmitting time (step S120) of the multicast package sending.
Transmitting time can be that the system time before and after the multicast package transmission of transmission is subtracted each other and obtained.In more detail, can read the system time that comprises that the calculator of this network card is safeguarded before and after multicast package sending, then the time before and after sending is subtracted each other and just can obtain the transmitting time that this multicast package of actual transmission spends.
Then calculate the difference of standard time and transmitting time, the difference of standard time and transmitting time is recorded as to this error time; Cumulative errors time and this error time are added up to, and aggregate result is recorded to a predetermined dormancy time (step S130).That is to say, in step S130, the cumulative errors time is fed back to predetermined dormancy time, to react more delicately and to adjust transmission speed.
Obtain after predetermined dormancy time, judge whether predetermined dormancy time is greater than an error threshold value (step S140).According to an enforcement example, error threshold value can be 1 millisecond (ms).Error threshold value can positively be grasped the precision of the control of transmission speed, can, according to the actual setting that needs that sends multicast package, it not limited at this.
In the time that predetermined dormancy time is greater than error threshold value, make the predetermined dormancy time of network card dormancy one, wherein predetermined dormancy time be add this error time the cumulative errors time and (step S160).Can be through application programming interfaces (application program interface, API) implementations such as time delay (Sleep) functions of such as window (Windows) system in step S160.Relative, in the time that predetermined dormancy time is not more than error threshold value, can be using predetermined dormancy time as the new cumulative errors time (step S150).
Can be seen and be known by step S150 and S160, this error time that the transmission speed control method of multicast package produces each time delay retains, rather than abandons.This error time being fed back in real time in time delay control next time, and can dynamic compensation error, thereby reduce delay time error and improve control precision.In addition, owing to utilizing this error compensation mechanism, even if the error that the contract measurement time produces also can obtain effective compensation.
Network card dormancy in dormancy, be waken up after predetermined dormancy time, and calculate actual dormancy time (step S170).Similarly, also the system time before and after network card dormancy can be subtracted each other, to obtain actual dormancy time.Because the precision surveyed of Sleep function is greater than 10 milliseconds, therefore generally speaking actual dormancy time all can be greater than 10 milliseconds.
The transmission speed control method of multicast package is then calculated predetermined dormancy time and deducts the difference of actual dormancy time, and the difference that predetermined dormancy time is deducted to actual dormancy time is as the new cumulative errors time (step S180).And all can judge whether whole multicast packages to be sent completely to (step S190) after multicast package of every transmission.If so, can finishing control.If not, get back to step S110 to send next multicast package.
It is noted that, above-mentioned " error threshold value ", the numerical value that " actual dormancy time " and " cumulative time threshold value " gives an example all can, according to the actual setting that needs that sends multicast package, not limit it at this.See through and adjust these numerical value, can set the scope of dynamic error compensation, and how soon can return to goal-setting speed etc.
Please refer to Fig. 2, for another implements the part flow chart of transmission speed control method of the multicast package of example.In this enforcement example, also can set up an accumulative total transmitting time at step S110 simultaneously.And sending multicast package (step S120) in reality can carry out following in order to reset the cumulative errors time before.
Before each transmission multicast package, first calculate accumulative total transmitting time (step S210); Namely calculating that accumulative total transmitting time is established or is reset is 0 to have spent up till now the time how long.Then judge whether transmitting time is greater than a cumulative time threshold value (step S220); When being greater than the cumulative time when threshold value, cumulative errors time and accumulative total transmitting time are reset to 0 (step S230).
According to an enforcement example, accumulated error threshold value can be 1 second (s).Accumulated error threshold value also can, according to the actual setting that needs that sends multicast package, not limit it at this.Owing to just the accumulated error time being reset to 0 at set intervals, therefore can guarantee that the accumulated error time carries out dynamic error compensation within a bit of time.
Please refer to Fig. 3, is the curve chart of the transmission speed of an enforcement example.Can be seen and be known by atransmission speed curve 20 of Fig. 3, network card has just started to start fashion and has carried out the actions such as the configuration of environment and cannot transmit fast multicast package.But for the multicast package of accumulation is spread out of in real time, become and do not need to carry out delay function completely subsequently, can pass and how soon how soon pass and reach the transmission speed upper limit of network card.But in order to adjust too fast transmission speed, the transmission speed control method of multicast package is promptly returned to target velocity by transmission speed through the accumulated error time.
In sum, the transmission speed control method of multicast package feeds back to delay function by the accumulated error time in real time, and timing is emptied.Therefore the transmission speed control method of multicast package can guarantee that the efficient stable of network data transmission does not take again too much central processing unit (central processor unit, CPU) resource.In other words, the transmission speed control method of multicast package can reach the effect of low-resource utilance and high accuracy control simultaneously.Further, this method can comprise the pressure of the multicast server of this network card, and guarantees multi-case data energy high speed stable transfer, and has reduced the possibility that network data transmission is made mistakes.
Below better concrete enforcement example is for more clearly describing feature of the present invention and spirit, not with above-mentioned disclosed better concrete enforcement example, category of the present invention being limited.On the contrary, the deformation program of various changes and tool equality is all covered by scope of patent protection of the present invention.