Embodiment
For making the object, technical solutions and advantages of the present invention clearer, below in conjunction with accompanying drawing, embodiment of the present invention is described further in detail.
Fig. 1 is the method for limiting speed flow chart that the embodiment of the present invention provides.Referring to Fig. 1, described method flow comprises:
101, obtain current application process information in network connection state and the network data information of current transmission.
102,, according to this application process information and this network data information, determine the transfer of data statistical information of each application process.
103, according to the corresponding relation between application process type and the application process of storage, judge in this each application process whether comprise the first application process, the application process that this first application process is specified type.
104,, in the time that this each application process comprises the first application process, if the transfer of data statistical information of this first application process is less than predetermined threshold value, the second application process is carried out to speed restriction.
In another embodiment provided by the invention, obtaining the current application process information in network connection state comprises: call appointing system API, enumerate the current application process information in network connection state, this application process information comprises any one in process ID, process title, source port number, source IP address, destination port number and target ip address.
In another embodiment provided by the invention, the network data information of obtaining current transmission comprises: the packet header of the network packet to current transmission is analyzed, and obtains the size of data that this network packet is carried and the connection object information of this network packet.
In another embodiment provided by the invention, according to this application process information and this network data information, the transfer of data statistical information of determining each application process comprises: according to the connection object information of any one and this network packet in process ID, process title, source port number, source IP address, destination port number and target ip address in this application process information, determine the size of data of network packet corresponding to each application process information; According to the size of data of network packet corresponding to each application process information, obtain the transmission speed of described each application process.
In another embodiment provided by the invention, in the time that this each application process comprises the first application process, if the transfer of data statistical information of this first application process is less than predetermined threshold value, the second application process is carried out to speed restriction to be comprised: in the time that this first application process is browser class process, if when the transfer of data statistical information of this browser class process is less than the first predetermined threshold value, this second application process is carried out to speed restriction; Or, in the time that this first application process is game on line class process, if when the transfer of data statistical information of this game class process is less than the second predetermined threshold value, this second application process is carried out to speed restriction; Or, in the time that this first application process is online audio-visual class process, if when the transfer of data statistical information of this online audio-visual class process is less than the 3rd predetermined threshold value, this second application process is carried out to speed restriction; Wherein, the first predetermined threshold value is less than the second predetermined threshold value and the 3rd predetermined threshold value.
In another embodiment provided by the invention, in the time that this each application process comprises the first application process, if the transfer of data statistical information of this first application process is less than predetermined threshold value, before the second application process is carried out to speed restriction, described method also comprises: current network bandwidth is tested, obtain current download bandwidth and current uploading bandwidth; The second application process being carried out in the process of speed restriction, adjust the transmission speed of this second application process according to current download bandwidth and current uploading bandwidth.
In another embodiment provided by the invention, the second application process being carried out in the process of speed restriction, according to current download bandwidth and current uploading bandwidth, the transmission speed of adjusting this second application process comprises: in the time that this first application process is browser class process, the uploading speed of this second application process is reduced to first ratio of deserving front uploading bandwidth, the speed of download of this second application process is reduced to second ratio of deserving front download bandwidth; Or, in the time that this first application process is game on line class process, the uploading speed of this second application process is reduced to the 3rd ratio of deserving front uploading bandwidth, the speed of download of this second application process is reduced to the 4th ratio of deserving front download bandwidth; Or, in the time that this first application process is online audio-visual class process, the uploading speed of this second application process is reduced to the 5th ratio of deserving front uploading bandwidth, the speed of download of this second application process is reduced to the 6th ratio of deserving front download bandwidth.
By obtaining current application process information in network connection state and the network data information of current transmission, determine the transfer of data statistical information of each application process; According to the corresponding relation between application process type and the application process of storage, judge the application process that whether comprises specified type in this each application process; In the time that this each application process comprises the application process of specified type, if the transfer of data statistical information of this first application process is less than predetermined threshold value, the second application process is carried out to speed restriction.The technical scheme that the embodiment of the present invention provides, by monitoring the transfer of data of each application process, the transfer of data statistical information that determines whether the first application process is less than predetermined threshold value, because predetermined threshold value is for ensureing the normal operating condition of the first application process, therefore, can determine whether that the application process of specified type is in abnormal running state, thereby the second application process is carried out to speed restriction, the instability problem of not only having avoided application driver to produce, and improve the efficiency of speed restriction, can effectively distribute the network bandwidth, the network that has promoted user is experienced.
Above-mentioned all optional technical schemes, can adopt any combination to form optional embodiment of the present invention, and this is no longer going to repeat them.
Fig. 2 is the method for limiting speed flow chart that the embodiment of the present invention provides.Referring to Fig. 2, described method flow comprises:
201, call appointing system API (Application Program Interface, application programming interfaces), obtain the current application process information in network connection state, this application process information comprises at least one item in process ID, process title, source port number, source IP address, destination port number and target ip address.
Wherein, the API with scanning application process function being provided by terminal operating system is provided appointing system API.Terminal, by calling this appointing system API, can be enumerated all application process information that connect in network under current system, comprises process ID, process title, source port number, source IP address, destination port number and target ip address etc.
By this step 201, can know current each application process of just carrying out network data transmission, and know the specifying information of each application process, as process ID, process title, source port number, source IP address, destination port number and target ip address, certainly, this application process information can also comprise some other for representing the information of running status of this application process, do not repeat at this.
202, the packet header of the network packet to current transmission is analyzed, and obtains the size of data that this network packet is carried and the connection object information of this network packet.
Wherein, the packet header of this network packet can refer to that IP head or the TCP of the received network packet of terminal is first-class, IP head or the TCP that can also refer to the network packet that terminal sends are first-class, in this packet header, include the address information etc. of size of data, connection object and the transmitting terminal of the data of carrying in the type information, bag of network packet, certainly, for the network packet that uses other procotols to transmit, its packet header type is likely different, as first-class in UDP etc., do not repeat at this.
In order to realize the analysis to network packet, can Network card setup be become to promiscuous mode by raw socket (row socket), to carry out the network monitoring based on source socket.Creating after raw socket, need to packet header (as IP head) option of operation be set by setsockopt () function (for the setting options value of any type, free position socket), and then by bind () function (for socket is connected with designated port), raw socket be tied to the local network interface card of terminal.In order to allow raw socket can receive all types of packets, also need to arrange by ioctlsocket () function (for socket is arranged), whether in person process packet header but also can specify.So far, just can start network packet to monitor, thereby the network packet listening to is analyzed.Can as stream socket or Datagram Socket, complete by recv () function obtaining of packet.But different from other two kinds of sockets is, the network packet that raw socket now captures is not merely simple data message, but include the most original data message in IP head, the first-class packet header of TCP, because the network packet in transmission over networks has all been passed through the packing of network layer and transport layer, therefore need according to its additional frame head, network packet to be analyzed, these data messages have retained original appearance when network data wraps in Internet Transmission.
203,, according to the connection object information of any one and this network packet in process ID, process title, source port number, source IP address, destination port number and target ip address in this application process information, determine the size of data of network packet corresponding to each application process information.
Connection object information entrained in the packet header of this network packet can refer to process ID, above-mentioned any application process information such as process title and destination port number, describe as an example of destination port number example, the process of this step 203 can comprise: in the time determining that the connection object information of the network packet of transmitting is first object port numbers, in the application process information that got of judgement, whether comprise first object port numbers, if, determine the first application process corresponding to this first object port numbers, according to the size of data of network packet corresponding to this first object port numbers, obtain the size of data of all packets that this first application process transmits.
It should be noted that, for an application process, its network packet of uploading or downloading can have multiple, now, the size of data of transmitting in order to calculate this application process, can respectively the size of data of uploading be added, and the size of data of downloading is added, with the bandwidth of knowing that this application process really takies.
204,, according to the size of data of network packet corresponding to each application process information, obtain the transmission speed of described each application process.
Particularly, the transmission speed of application process can refer to this application process velocity peak values at a time, also can refer to the speed average of this application process in a set period.Correspondingly, this step 204 can comprise following two kinds of different processes: (1) is every the first default duration, add up the size of data of network packet corresponding to this application process information, the transmission speed using the maximum transfer speed (being the size of data of transmitting in a certain moment) of this application process in this first default duration as this application process.(2) every the second default duration, add up the size of data of network packet corresponding to this application process information, the size of data summation that this application process sent or received in this second default duration is as the transmission speed of this application process.Certainly, these transmission speed computational methods are only giving an example of basis, and its specific algorithm can also be other algorithms that carry out according to analyzing packet header, is not specifically limited at this.And further, for different application processes, can have different transmission speed computational methods, be not specifically limited at this.
205, according to the corresponding relation between application process type and the application process of storage, judge in this each application process whether comprise the first application process, the application process that this first application process is specified type;
If so, execution step 206;
If not, finish.
Wherein, corresponding relation between application process type and application process that server is pre-stored, this corresponding relation can be for determining the type of each application process, application process type can comprise specified type and non-designated type, as, non-designated type can comprise antivirus software class, document class etc., and specified type can comprise online game class, online audio-visual class, browser class etc.In embodiments of the present invention, this specified type is the classification that running status may be subject to the network data transmission impact of the second application process, therefore, need to judge the application process whether in the current application process in network data exchange with specified type, can determine whether to carry out to the second application process the processing such as speed limit.Further, this specified type also can refer to the larger classification of network data transmission impact that is subject to the second application process, for the less application of some transfer of data own, it also can be subject to the network data transmission impact of the second application process, but, may be less on the impact of its operation, therefore, to this class application process, can be not considered.Certainly, specifically which application process belongs to specified type, can be arranged by Server Default, or be arranged according to self-demand by user.As, in setting up procedure, in order to ensure the normal renewal of antivirus software etc., also can antivirus software class be set to the one of specified type.
In embodiments of the present invention, the corresponding relation between application process type and application process can adopt the form of white list, particularly, is the corresponding relation of application process type and application process title (or application process ID) etc.That is to say, when defining an application process in network connection state, according to this application process title (or application process ID), corresponding relation between application process type and application process, obtain application process type corresponding to this application process, judge whether this application process type is specified type, if application process type is specified type, determine that this application process is the first application process, if application process type is not specified type, determine that this application process is not the first application process, if do not comprise the first application process in the current application process in network connection state, determine without the second application process is carried out to speed limit, finish.
206, current network bandwidth is tested, obtain current download bandwidth and current uploading bandwidth.
Wherein, in the process that current network bandwidth is tested, need to test respectively current download bandwidth and current uploading bandwidth, corresponding method of testing comprises the step of following (1)-(2):
(1) for the test of current download bandwidth, download target detection file operation by terminal, and repeat this down operation several times, finally to determine current download bandwidth.
(2), for the test of current uploading bandwidth, by realize on ping command protocols test respective objects network the winding time by reference in terminal, can obtain current uploading bandwidth.
It should be noted that, step 206 can be carried out determining while having the first application process, can also in the time having started the obtaining of application processes information and network data information, carry out, certainly, this specifically the opportunity of carrying out can also be other opportunitys, do not repeat at this.By test bandwidth, make terminal know the actual bandwidth ability of terminal in current network environment of living in.
207,, in the time that this each application process comprises the first application process, if the transmission speed of this first application process is less than predetermined threshold value, the second application process is carried out to speed restriction.
Wherein, in step 207, mentioned transmission speed is transfer of data statistical information, and in network data transmission process, this transfer of data statistical information has determined the network bandwidth that this application process takies.This predetermined threshold value refers to be set for the application process of each specified type, and this predetermined threshold value refers to the speed numerical value that can ensure normal operation.As, for the application process of certain online audio-visual class, its corresponding predetermined threshold value can be 500k/s, that is to say, in the time that the transfer of data statistical information of this application process reaches 500k/s, can normally move, do not affect user's viewing experience,, in the time that the data statistics information of this application process is less than 500k/s, need to carries out speed restriction to the second application process, thereby give way for this online audio-visual class application process.
In embodiments of the present invention, the second application process refers to the object that can carry out speed restriction, and this speed limiting device has the authority that the transmission speed of the second application process is limited.This speed limiting device can call the port of the second application process, and port is carried out to the settings such as speed restriction, to realize the speed restriction to the second application process.Certainly, this speed restriction can comprise restriction to uploading speed and the restriction respectively of speed of download, can be also to uploading speed and speed of download sum, that is to say that the transmission speed of this second application process limits, and is not specifically limited at this.
In the method for limiting speed providing in the present embodiment, the first dissimilar application process is also different to the demand of the network bandwidth, therefore, can be according to this first application program the different demands to the network bandwidth, this second application process is limited, can make speed restriction more targeted, also more effective for the distribution of the network bandwidth.In order to further illustrate, only taking the specified type in the present embodiment as browser class, game on line class and online audio-visual class describe respectively.
Step 207 " in the time that this each application process comprises the first application process; if the transfer of data statistical information of this first application process is less than predetermined threshold value; the second application process is carried out to speed restriction ", can comprise the steps one or more in 207a, 207b and 207c:
207a, in the time that this first application process is browser class process, if when the transfer of data statistical information of this browser class process is less than the first predetermined threshold value, this second application process is carried out to speed restriction.
Wherein, this first predetermined threshold value can be set for this browser class process, and in the time that the transfer of data statistical information of browser class process reaches this first predetermined threshold value, this browser class process can ensure normal operation.
It should be noted that, if when the transfer of data statistical information of this browser class process is less than the first predetermined threshold value, can be according to the actual bandwidth ability of current network, taking of the uploading bandwidth to this second application process and download bandwidth carried out speed restriction respectively.This step 207a specifically comprises: according to current network uploading bandwidth, the uploading speed of this second application process is reduced to first ratio of deserving front uploading bandwidth.According to current network download bandwidth, the speed of download of this second application process is reduced to second ratio of deserving front download bandwidth.
Wherein, this first ratio and the second ratio can be got equal value also can get unequal numerical value, can determine according to the degree of priority of upload and download, preferably, can be by second ratio that is greater than of the first ratio setting, to guarantee the download of the second application process in current terminal.To give way in order realizing effectively, need to, taking current actual bandwidth ability as benchmark, speed to be limited, improved the efficiency of speed restriction.
207b, in the time that this first application process is game on line class process, if when the transfer of data statistical information of this game class process is less than the second predetermined threshold value, this second application process is carried out to speed restriction.
Wherein, this second predetermined threshold value can be set for this game on line class process, and in the time that the transfer of data statistical information of game on line class process reaches this second predetermined threshold value, this game on line class process can ensure normal operation.
This step 207b specifically comprises: in the time that this first application process is game on line class process, according to current network uploading bandwidth, the uploading speed of this second application process is reduced to the 3rd ratio of deserving front uploading bandwidth.In the time that this first application process is game on line class process, according to current network download bandwidth, the speed of download of this second application process is reduced to the 4th ratio of deserving front download bandwidth.
Wherein, the 3rd ratio and the 4th ratio can be got equal value also can get unequal numerical value, can determine according to the degree of priority of upload and download, preferably, can be by the 4th ratio that is greater than of the 3rd ratio setting, to guarantee the download of the second application process in current terminal.To give way in order realizing effectively, need to, taking current actual bandwidth ability as benchmark, speed to be limited, improved the efficiency of speed restriction.
207c, in the time that this first application process is online audio-visual class process, if when the transfer of data statistical information of this online audio-visual class process is less than the 3rd predetermined threshold value, this second application process is carried out to speed restriction.
Wherein, the 3rd predetermined threshold value can be set for this online audio-visual class process, and in the time that the transfer of data statistical information of online audio-visual class process reaches the 3rd predetermined threshold value, this online audio-visual class process can ensure normal operation.Particularly, this step 207c comprises: in the time that this first application process is online audio-visual class process, according to current network uploading bandwidth, the uploading speed of this second application process is reduced to the 5th ratio of deserving front uploading bandwidth.In the time that this first application process is online audio-visual class process, according to current network download bandwidth, the speed of download of this second application process is reduced to the 6th ratio of deserving front download bandwidth.
Wherein, the 5th ratio and the 6th ratio can be got equal value also can get unequal numerical value, can determine according to the degree of priority of upload and download, preferably, can be by the 6th ratio that is greater than of the 5th ratio setting, to guarantee the download of the second application process in current terminal.To give way in order realizing effectively, need to, taking current actual bandwidth ability as benchmark, speed to be limited, improved the efficiency of speed restriction.
It should be noted that, for the first predetermined threshold value in above-mentioned steps 207a-207c, the second predetermined threshold value and the 3rd predetermined threshold value, because browser class process required bandwidth under normal operating condition is less, therefore, the first predetermined threshold value can be less than the second predetermined threshold value and the 3rd predetermined threshold value, and magnitude relationship between the second predetermined threshold value and the 3rd predetermined threshold value can be any relation, at this, magnitude relationship between each threshold value is not done to concrete restriction.
In the method for limiting speed providing in the present embodiment, according to different application process type, speed restriction ratio is set respectively, can make the speed restriction of this second application process more flexible, also more accurate for the distribution of the network bandwidth.
It should be noted that, further, step 201-207 is for only having first application process to describe in the scene of running status.In fact, can also there is the first application process scene in running status simultaneously of multiple specified type, for this scene, can be according to the transfer of data statistical information of the plurality of the first application process, and the actual bandwidth ability of current network, this second application process is carried out to speed restriction.Alternatively, can also reserve certain network bandwidth for the plurality of the first application process, make can compete this reserved network bandwidth between multiple the first application processes.Particularly, can be to carry out according to the mode of the priority for this multiple the first application process for this competition, for the first higher application process of priority is distributed the more network bandwidth, and be that the first application process that priority is lower is distributed the less network bandwidth.Usually, user can arrange according to self-demand the priority of the first application process, server distributes the corresponding network bandwidth according to the priority of each the first application process for it again, as, the priority of game on line class process can be greater than online audio-visual class process, and the priority of online audio-visual class process can be greater than browser class process.
The method that the present embodiment provides, by obtaining current application process information in network connection state and the network data information of current transmission, determines the transfer of data statistical information of each application process; According to the corresponding relation between application process type and the application process of storage, judge the application process that whether comprises specified type in this each application process; In the time that this each application process comprises the application process of specified type, if the transfer of data statistical information of this first application process is less than predetermined threshold value, the second application process is carried out to speed restriction.The technical scheme that the embodiment of the present invention provides, by monitoring the transfer of data of each application process, the transfer of data statistical information that determines whether the first application process is less than predetermined threshold value, because predetermined threshold value is for ensureing the normal operating condition of the first application process, therefore, can determine whether that the application process of specified type is in abnormal running state, thereby the second application process is carried out to speed restriction, the instability problem of not only having avoided application driver to produce, and improve the efficiency of speed restriction, can effectively distribute the network bandwidth, the network that has promoted user is experienced.
Fig. 3 is the speed limiting device structural representation that the embodiment of the present invention provides.Referring to Fig. 3, this device comprises acquisition of information module 301, information determination module 302, application process judge module 303 and speed restriction module 304.
Acquisition of information module 301, for obtaining current application process information in network connection state and the network data information of current transmission;
Information determination module 302, for according to described application process information and described network data information, determines the transfer of data statistical information of each application process;
Whether application process judge module 303, for according to the corresponding relation between application process type and the application process of storage, comprise the first application process, the application process that described the first application process is specified type in described each application process of judgement;
Speed restriction module 304, in the time that described each application process comprises the first application process, if the transfer of data statistical information of described the first application process is less than predetermined threshold value, carries out speed restriction to the second application process.
Alternatively, described acquisition of information module comprises:
API Calls unit, be used for calling appointing system API, enumerate the current application process information in network connection state, described application process information comprises any one in process ID, process title, source port number, source IP address, destination port number and target ip address.
Alternatively, described acquisition of information module comprises:
Information acquisition unit, analyzes for the packet header of the network packet to current transmission, obtains the size of data that described network packet is carried and the connection object information of described network packet.
Alternatively, described information determination module, for according to the connection object information of any one and described network packet in described application process information process ID, process title, source port number, source IP address, destination port number and target ip address, is determined the size of data of network packet corresponding to each application process information; According to the size of data of network packet corresponding to each application process information, obtain the transmission speed of described each application process.
Alternatively, described speed restriction module, in the time that described the first application process is browser class process, if when the transfer of data statistical information of described browser class process is less than the first predetermined threshold value, is carried out speed restriction to described the second application process; Or,
Described speed restriction module, in the time that described the first application process is game on line class process, if when the transfer of data statistical information of described game class process is less than the second predetermined threshold value, is carried out speed restriction to described the second application process; Or,
Described speed restriction module, in the time that described the first application process is online audio-visual class process, if when the transfer of data statistical information of described online audio-visual class process is less than the 3rd predetermined threshold value, is carried out speed restriction to described the second application process;
Wherein, the first predetermined threshold value is less than the second predetermined threshold value and the 3rd predetermined threshold value.
Alternatively, described device also comprises:
Bandwidth test module, for current network bandwidth is tested, obtains current download bandwidth and current uploading bandwidth;
Described speed restriction module, also for the process the second application process being carried out to speed restriction, according to current download bandwidth and current uploading bandwidth, is adjusted the transmission speed of described the second application process.
Alternatively, described speed restriction module is in the time that described the first application process is browser class process, the uploading speed of described the second application process is reduced to the first ratio of described current uploading bandwidth, the speed of download of described the second application process is reduced to the second ratio of described current download bandwidth; Or,
Described speed restriction module is in the time that described the first application process is game on line class process, the uploading speed of described the second application process is reduced to the 3rd ratio of described current uploading bandwidth, the speed of download of described the second application process is reduced to the 4th ratio of described current download bandwidth; Or,
Described speed restriction module is in the time that described the first application process is online audio-visual class process, the uploading speed of described the second application process is reduced to the 5th ratio of described current uploading bandwidth, the speed of download of described the second application process is reduced to the 6th ratio of described current download bandwidth.
By obtaining current application process information in network connection state and the network data information of current transmission, determine the transfer of data statistical information of each application process; According to the corresponding relation between application process type and the application process of storage, judge the application process that whether comprises specified type in this each application process; In the time that this each application process comprises the application process of specified type, if the transfer of data statistical information of this first application process is less than predetermined threshold value, the second application process is carried out to speed restriction.The technical scheme that the embodiment of the present invention provides, by monitoring the transfer of data of each application process, the transfer of data statistical information that determines whether the first application process is less than predetermined threshold value, because predetermined threshold value is for ensureing the normal operating condition of the first application process, therefore, can determine whether that the application process of specified type is in abnormal running state, thereby the second application process is carried out to speed restriction, the instability problem of not only having avoided application driver to produce, and improve the efficiency of speed restriction, can effectively distribute the network bandwidth, the network that has promoted user is experienced.
One of ordinary skill in the art will appreciate that all or part of step that realizes above-described embodiment can complete by hardware, also can carry out the hardware that instruction is relevant by program completes, the program of being somebody's turn to do can be stored in a kind of computer-readable recording medium, the above-mentioned storage medium of mentioning can be read-only memory, disk or CD etc.
This is only preferred embodiment of the present invention above, in order to limit the present invention, within the spirit and principles in the present invention not all, any amendment of doing, is equal to replacement, improvement etc., within all should being included in protection scope of the present invention.