Summary of the invention
The problem of the network data poor accuracy obtained from service end for existing client and propose the present invention, for this reason, main purpose of the present invention is to provide a kind of Network Data Capture method and device, to solve the problem.
To achieve these goals, according to an aspect of the present invention, a kind of Network Data Capture method is provided.The method comprises: service end obtains the first request time, wherein, first request time is the time that the last request message sent to service end of client arrives service end, and service end is for gathering numeral, and service end gathers the time interval of numeral for presetting acquisition time interval; Service end obtains the second request time, wherein, the second request time be this request message sent to service end of client arrive service end time; Service end according to the first request time, the second request time and default acquisition time interval calculation digital collection number, wherein, digital collection number be the first request time to the second request time the time interval in service end gather digital number; Service end obtains the numeral gathered in the first request time to the second request time; Service end calculates target number according to the numeral gathered and digital collection number; Target number is sent to client by service end.
Further, service end comprises according to the first request time, the second request time and default acquisition time interval calculation digital collection number: determine default acquisition time interval; Calculate digital collection number in such a way: P=[(T
2-T
1)/t], wherein, P is digital collection number, T
2be the second request time, T
1be the first request time, [(T
2-T
1)/t] for being less than or equal to (T
2-T
1the maximum integer of)/t.
Further, the second request time is client first time arrive the time of service end to the request that service end sends, and service end obtains the first request time and comprises: service end determines that the second request time is the first request time.
Further, service end comprises according to the numeral gathered and digital collection number calculating target number: service end calculates the digital sum gathered; Calculate target number in such a way: Q=A/P, wherein, Q is target number, and A is the digital sum gathered.
Further, before service end obtains the first request time, the method also comprises: client determination polling time interval, and wherein, polling time interval is the time interval that client sends between the first request message and the second request message; According to polling time interval, client sends the first request message, wherein, first request message is that last client-requested obtains the message of data from service end, before service end obtains the second request time, the method also comprises: according to polling time interval, and client sends the second request message, wherein, the second request message is that this client-requested obtains the message of data from service end.
To achieve these goals, according to a further aspect in the invention, provide a kind of Network Data Capture device, this device comprises: the first acquiring unit, obtain the first request time for service end, wherein, the first request time is the time that the last request sent to service end of client arrives service end, service end is for gathering numeral, and service end gathers the time interval of numeral for presetting acquisition time interval; Second acquisition unit, obtains the second request time for service end, wherein, the second request time be this request sent to service end of client arrive service end time; First computing unit, for service end according to the first request time, the second request time and default acquisition time interval calculation digital collection number, wherein, digital collection number be the first request time to the second request time the time interval in service end gather digital number; 3rd acquiring unit, obtains the numeral gathered in the first request time to the second request time for service end; Second computing unit, calculates target number for service end according to the numeral gathered and digital collection number; Transmitting element, sends to client for service end by target number.
Further, the first computing unit comprises: determination module, for determining default acquisition time interval; First computing module, for calculating digital collection number in such a way: P=[(T
2-T
1)/t], wherein, P is digital collection number, and T2 is the second request time, and T1 is the first request time, [(T
2-T
1)/t] for being less than or equal to (T
2-T
1the maximum integer of)/t.
Further, the second request time is client first time arrive the time of service end to the request that service end sends, for service end, the first acquiring unit also determines that the second request time is the first request time.
Further, the second computing unit comprises: the second computing module, calculates the digital sum gathered for service end; 3rd computing module, for calculating target number in such a way: Q=A/P, wherein, Q is target number, and A is the digital sum gathered.
Further, this device also comprises: determining unit, and for client determination polling time interval, wherein, polling time interval is the time interval that client sends between the first request message and the second request message; First request unit, for according to polling time interval, client sends the first request message, and wherein, the first request message is that last client-requested obtains the message of data from service end; Second request unit, for according to polling time interval, client sends the second request message, and wherein, the second request message is that this client-requested obtains the message of data from service end.
Pass through the present invention, adopt the method comprised the following steps: service end obtains the first request time, wherein, first request time is the time that the last request sent to service end of client arrives service end, service end is for gathering numeral, and service end gathers the time interval of numeral for presetting acquisition time interval; Service end obtains the second request time, wherein, the second request time be this request sent to service end of client arrive service end time; Service end according to the first request time, the second request time and default acquisition time interval calculation digital collection number, wherein, digital collection number be the first request time to the second request time the time interval in service end gather digital number; Service end obtains the numeral gathered in the first request time to the second request time; Service end calculates target number according to the numeral gathered and digital collection number; Target number is sent to client by service end, solve client from service end obtain the accuracy of data be overly dependent upon time interval that client sends request and cause with loss client performance for cost improves the problem of the accuracy obtaining data, and then calculate target number by service end according to the numeral gathered and digital collection number, and target number is sent to client, reach and do not need to shorten the effect that time interval of sending request of client can improve the accuracy of the network data that client receives.
Embodiment
The present invention program is understood better in order to make those skilled in the art person, below in conjunction with the accompanying drawing in the embodiment of the present invention, technical scheme in the embodiment of the present invention is clearly and completely described, obviously, described embodiment is only the embodiment of a part of the present invention, instead of whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art, not making the every other embodiment obtained under creative work prerequisite, should belong to the scope of protection of the invention.
It should be noted that, term " first ", " second " etc. in specification of the present invention and claims and above-mentioned accompanying drawing are for distinguishing similar object, and need not be used for describing specific order or precedence.In addition, term " comprises " and " having " and their any distortion, intention is to cover not exclusive comprising, such as, contain those steps or unit that the process of series of steps or unit, method, system, product or equipment is not necessarily limited to clearly list, but can comprise clearly do not list or for intrinsic other step of these processes, method, product or equipment or unit.
When not conflicting, the embodiment in the application and the feature in embodiment can combine mutually.Below with reference to the accompanying drawings and describe the present invention in detail in conjunction with the embodiments.
Fig. 2 is the flow chart of the first embodiment according to Network Data Capture method of the present invention.As shown in Figure 2, the method comprising the steps of S102 is to step S112.
Step S102, service end obtains the first request time, and wherein, the first request time is the time that the last request message sent to service end of client arrives service end, service end is for gathering numeral, and service end gathers the time interval of numeral for presetting acquisition time interval.
Step S104, service end obtains the second request time, wherein, the second request time be this request message sent to service end of client arrive service end time.
When client needs to obtain service end data, request message can be sent to client.Due to reasons such as network delays, can there is the delay of a period of time in the time that sends of time and this request message that this request message reaches service end.The time of service end record client request message arrival each time service end in the present invention.Double request message arrived between the time difference of service end and the client double time interval sending request message does not have restricting relation, due to the randomness of network request, the time difference of double request message arrival service end may be greater than, be less than or equal to the client double time interval sending request message.
The client double time interval sending request can be fixed time interval, also it is possible that change.The time interval of service end collection numeral can be fixed time interval, also it is possible that change.Service end often receives the request message that client is sent, just time of reaching of this request message of instant recording, and is recorded as this time this time, and the front time of once recording is defaulted as the last time.It should be noted that, if the second request time is client first time arrive the time of service end to the request that service end sends, service end will determine that the second request time is the first request time.
Step S106, service end according to the first request time, the second request time and default acquisition time interval calculation digital collection number, wherein, digital collection number be the first request time to the second request time the time interval in service end gather digital number.
Step S108, service end obtains the numeral gathered in the first request time to the second request time.
Service end the first request time and within the second request time time interval in continuous image data, client sent in the time interval between request message can comprise some data, but client does not have request service end sends these data.In the present invention, service end utilizes the first request time, the second request time and default acquisition time interval, the first request time can be calculated and the number of numeral that within the second request time time interval, service end gathers, and determine the first request time and the numeral that within the second request time time interval, client is not asked.Take into full account the first request time and within the second request time time interval service end gather the number of numeral and the numeral within this period, the situation of change of numeral in this period can be embodied better, avoid the comparatively big error on the numeral change global regularity of the numeral only obtaining fixed time (the first request time or the second request time) and the final acquisition brought.
Service end can be carried out according to following steps according to the first request time, the second request time and default acquisition time interval calculation digital collection number: determine default acquisition time interval; Calculate digital collection number in such a way: P=[(T
2-T
1)/t], wherein, P is digital collection number, T
2be the second request time, T
1be the first request time, [(T
2-T
1)/t] for being less than or equal to (T
2-T
1the maximum integer of)/t.Such as, the real time data of service end acquisition is as shown in table 1.First request time is t=1s, and the second request time is t=5s, and default acquisition time is spaced apart 1s, and therefore, can calculate digital collection number according to above-mentioned formula is 4.The numeral of service end collection in this period of time interval is 36,27,19 and 38.Numeral according to digital collection number and collection in this period of time interval can obtain target number, and namely service end will send to the numeral of client.
Table 1
Acquisition time (t) |
1s |
2s |
3s |
4s |
5s |
6s |
… |
Numeral |
25 |
36 |
27 |
19 |
38 |
26 |
… |
Step S110, service end calculates target number according to the numeral gathered and digital collection number.
According to the numeral gathered and digital collection number, service end can calculate target number in such a way: service end calculates the digital sum gathered; Calculate target number in such a way: Q=A/P, wherein, Q is target number, and A is the digital sum gathered.
The first request time and the arithmetic mean in the second request time time interval is calculated according to the numeral gathered and digital collection number, make the target number obtained more can reflect the first request time and the digital Changing Pattern in the second request time time interval, avoid because the numeral of corresponding first request time or the second request time is comparatively large because the reasons such as network depart from, and the first request time causing client to obtain and the digital Changing Pattern in the second request time time interval produce larger error.
Step S112, target number is sent to client by service end.
The target number calculated is sent to client by service end, and client sends time interocclusal record this target number of target number according to service end.According to different user's requests, the multiple target number reaching client within a period of time can be obtained, the plurality of target number is analyzed, the Changing Pattern of the plurality of target number can be obtained.The Changing Pattern of numeral that the Changing Pattern of the target number obtained according to the present invention will gather close to service end more.
Fig. 3 is the schematic diagram of the network data according to the present invention's acquisition.The default acquisition time of service end is spaced apart 1s as can be seen from Figure 3, and the time that client request message arrives service end is t=1s, 5s and 14s.T=1s is arrived the time of service end as last request message, t=5s arrives the time of service end as this request message, the data amount check gathered in t=1s to the t=5s time is 4, the numeral gathered is respectively 69,27,33 and 54, can calculate target number for (69+27+33+54)/4 according to the numeral gathered and digital collection number.T=5s is arrived the time of service end as last request message, t=14s arrives the time of service end as this request message, the data amount check gathered in t=5s to the t=14s time is 9, the numeral gathered is respectively 98,101,77,92,45,27,33,87 and 65, can calculate target number for (98+101+77+92+45+27+33+87+65)/9 according to the numeral gathered and digital collection number.
This embodiment is owing to taking following steps: service end obtains the first request time, wherein, first request time is the time that the last request message sent to service end of client arrives service end, service end is for gathering numeral, and service end gathers the time interval of numeral for presetting acquisition time interval; Service end obtains the second request time, wherein, the second request time be this request message sent to service end of client arrive service end time; Service end according to the first request time, the second request time and default acquisition time interval calculation digital collection number, wherein, digital collection number be the first request time to the second request time the time interval in service end gather digital number; Service end obtains the numeral gathered in the first request time to the second request time; Service end calculates target number according to the numeral gathered and digital collection number; Target number is sent to client by service end, solve client from service end obtain the accuracy of data be overly dependent upon polling time interval and cause with loss client performance for cost improves the problem of the accuracy obtaining data, and then calculate target number by service end according to the numeral gathered and digital collection number, and target number is sent to client, reach and do not need to shorten the effect that time interval of sending request of client can improve the accuracy of the network data that client receives.
Fig. 4 is the flow chart of the second embodiment according to Network Data Capture method of the present invention.This embodiment can as a kind of preferred implementation embodiment illustrated in fig. 2.As shown in Figure 3, the method comprising the steps of S201 is to step S209.
Step S201, client determination polling time interval, wherein, polling time interval is the time interval that client sends between the first request message and the second request message.
Preferably, based on the real-time system of poll, client can preset polling time interval before sending a request message to service end, and often through a polling time interval, client can send a request message to service end.Client can send multiple request message according to demand automatically, is conducive to obtaining a large amount of target number, very favourable for the execution efficiency improving whole flow process.
Such as, client setting polling time interval is 5s, and namely client sends the time interval of the first request message and the second request message is 5s.Like this, client can at t=1s, 5s, 10s ... respectively send a request message to service end.
Step S202, according to polling time interval, client sends the first request message, and wherein, the first request message is that last client-requested obtains the message of data from service end.
Step S203, service end obtains the first request time, and wherein, the first request time is the time that the last request message sent to service end of client arrives service end, service end is for gathering numeral, and service end gathers the time interval of numeral for presetting acquisition time interval.
This step, with step S102, repeats no more here.
Step S204, according to polling time interval, client sends the second request message, and wherein, the second request message is that this client-requested obtains the message of data from service end.
Step S205, service end obtains the second request time, wherein, the second request time be this request message sent to service end of client arrive service end time.
This step, with step S104, repeats no more here.
Step S206, service end according to the first request time, the second request time and default acquisition time interval calculation digital collection number, wherein, digital collection number be the first request time to the second request time the time interval in service end gather digital number.
This step, with step S106, repeats no more here.
Step S207, service end obtains the numeral gathered in the first request time to the second request time.
This step, with step S108, repeats no more here.
Step S208, service end calculates target number according to the numeral gathered and digital collection number;
This step, with step S110, repeats no more here.
Step S209, target number is sent to client by service end.
This step, with step S112, repeats no more here.
This embodiment is owing to taking following steps: client determination polling time interval, and wherein, polling time interval is the time interval that client sends between the first request message and the second request message; According to polling time interval, client sends the first request message, and wherein, the first request message is that last client-requested obtains the message of data from service end; Service end obtains the first request time, wherein, first request time is the time that the last request message sent to service end of client arrives service end, and service end is for gathering numeral, and service end gathers the time interval of numeral for presetting acquisition time interval; According to polling time interval, client sends the second request message, and wherein, the second request message is that this client-requested obtains the message of data from service end; Service end obtains the second request time, wherein, the second request time be this request message sent to service end of client arrive service end time; Service end according to the first request time, the second request time and default acquisition time interval calculation digital collection number, wherein, digital collection number be the first request time to the second request time the time interval in service end gather digital number; Service end obtains the numeral gathered in the first request time to the second request time; Service end calculates target number according to the numeral gathered and digital collection number; Target number is sent to client by service end, makes client can send the message of request msg from trend service end according to polling time interval, is conducive to obtaining a large amount of target number, can improve the execution efficiency of whole Network Data Capture flow process.
It should be noted that, the Network Data Capture device of the embodiment of the present invention may be used for performing the Network Data Capture method that the embodiment of the present invention provides, and the Network Data Capture device that the Network Data Capture method of the embodiment of the present invention also can be provided by the embodiment of the present invention performs.
Fig. 5 is the schematic diagram of the first embodiment according to Network Data Capture device of the present invention.As shown in Figure 5, this apparatus structure comprises: the first acquiring unit 20, second acquisition unit 30, first computing unit 40, the 3rd acquiring unit 50, second computing unit 60 and transmitting element 70.
First acquiring unit 20, obtain the first request time for service end, wherein, the first request time is the time that the last request sent to service end of client arrives service end, service end is for gathering numeral, and service end gathers the time interval of numeral for presetting acquisition time interval.
Second request time is client first time arrive the time of service end to the request that service end sends, for service end, the first acquiring unit 20 also determines that the second request time is the first request time.
Second acquisition unit 30, obtains the second request time for service end, wherein, the second request time be this request sent to service end of client arrive service end time.
First computing unit 40, for service end according to the first request time, the second request time and default acquisition time interval calculation digital collection number, wherein, digital collection number be the first request time to the second request time the time interval in service end gather digital number.
First computing unit 40 can also comprise: determination module, for determining default acquisition time interval; First computing module, for calculating digital collection number in such a way: P=[(T
2-T
1)/t], wherein, P is digital collection number, T
2be the second request time, T
1be the first request time, [(T
2-T
1)/t] for being less than or equal to (T
2-T
1the maximum integer of)/t.
3rd acquiring unit 50, obtains the numeral gathered in the first request time to the second request time for service end.
Second computing unit 60, calculates target number for service end according to the numeral gathered and digital collection number.
Second computing unit 60 comprises: the second computing module, calculates the digital sum gathered for service end; 3rd computing module, for calculating target number in such a way: Q=A/P, wherein, Q is target number, and A is the digital sum gathered.
Transmitting element 70, sends to client for service end by target number.
Alternatively, this device can also comprise: determining unit, and for client determination polling time interval, wherein, polling time interval is the time interval that client sends between the first request message and the second request message; First request unit, for according to polling time interval, client sends the first request message, and wherein, the first request message is that last client-requested obtains the message of data from service end; Second request unit, for according to polling time interval, client sends the second request message, and wherein, the second request message is that this client-requested obtains the message of data from service end.
The Network Data Capture device that the present embodiment provides comprises: the first acquiring unit 20, second acquisition unit 30, first computing unit 40, the 3rd acquiring unit 50, second computing unit 60 and transmitting element 70.By this device, solve client from service end obtain the accuracy of data be overly dependent upon polling time interval and cause with loss client performance for cost improves the problem of the accuracy obtaining data, and then calculate target number by service end according to the numeral gathered and digital collection number, and target number is sent to client, reach and do not need to shorten the effect that time interval of sending request of client can improve the accuracy of the network data that client receives.
Obviously, those skilled in the art should be understood that, above-mentioned of the present invention each module or each step can realize with general calculation element, they can concentrate on single calculation element, or be distributed on network that multiple calculation element forms, alternatively, they can realize with the executable program code of calculation element, thus, they can be stored and be performed by calculation element in the storage device, or they are made into each integrated circuit modules respectively, or the multiple module in them or step are made into single integrated circuit module to realize.Like this, the present invention is not restricted to any specific hardware and software combination.
These are only the preferred embodiments of the present invention, be not limited to the present invention, for a person skilled in the art, the present invention can have various modifications and variations.Within the spirit and principles in the present invention all, any amendment done, equivalent replacement, improvement etc., all should be included within protection scope of the present invention.