Background technology
Along with the mankind carry out the increase of information interchange by network, in data communication network, it is more and more higher that network connects complexity.Behind community user and the enterprise's network accessing Internet, the application of setting up trans-regional connection by ISP is becoming more and more general.
In the practical application at present, the simple charge method of not doing the assurance of service quality and flow according to the time can not be met the need of market.For example, always chargeing by service time, but along with the development of data communication, the emerging in large numbers of various new business thisly can not be met consumers' demand according to the mode of time-based charging purely in data communication field.For example, along with carrying out of wireless data service, the mode of chargeing by data traffic has appearred.
In addition, operator wishes the data flow of different content is carried out different chargings in order to carry out some new business better.For example adopt cheap rates, the Internet resources of outside are adopted high rate for more inner Internet resources; Adopt cheap rate for the big business of some data volumes, video flowing for example, for the little business of some data volumes, for example stock information then adopts high rate etc.Some campus networks and enterprise network also press for the mode that the network equipment (switch or router) can support to be undertaken by the content of packet flexible charging, and these all need the data flow is added up.
At present, for data service, the normal charging method that adopts has two kinds, and is promptly charged according to time and charge by data traffic.Described charged according to time be exactly the time of only calculating user online, charge by the length of surf time.This charge system generally comprises two parts, a part is an authentification of user, guarantee that exactly the user is a validated user, the process of the process of authentication user's login just, have only the user's ability logon by authentication, another part is exactly the zero-time and the off line time of the online of Verification System recording user, and these data are mail to the charging center, be used for time-based charging.
Described charging by flow chargeed by the data traffic of the actual generation of user exactly.Because it is charge than the consumption situation of user that more can truly reflect charged according to time, therefore more reasonable to Internet resources by data traffic.Data flux statistics method at present relatively more commonly used is to be that characteristic item carries out the packet statistics with packet by source, purpose IP address on the network equipment; Or be that characteristic item carries out packet statistics by source, purpose IP address, port numbers, protocol type with packet, can be as accurate as concrete network address according to purpose IP address, there have been destination slogan and protocol type to can be as accurate as certain service that the website provides, like this can different according to user capture flexibly network address, even Tong business is not chargeed, and such charge information is very detailed.
In this method all packets all fix by source, purpose IP address, source, destination slogan, protocol number is that characteristic item carries out statistic of classification, though it is very comprehensive to do statistics like this, but because classification is too thin, need take big quantitative statistics resource, for example, if only need add up the data traffic that certain user sends, just the data flow of all services of this user capture all must be carried out statistic of classification according to this method, if this user capture up to ten thousand services then need set up up to ten thousand statistical items, this can consume a large amount of system resource.Simultaneously, owing to also need to transmit great number of statistic data, also can seriously reduce the performance of whole system.
And in this method all packets are added up, and then charge according to statistic flow, but, do not need at present such charging precision, it is just passable generally only need to carry out statistic of classification to the website of certain class, there is no need each website is all carried out detailed record, the data volume of the charging that such charging precision will cause is huge, and the treatment facility of metering data and transmission equipment all proposed very high requirement.Simultaneously, this method is also added up the packet that does not need to charge in a large number, wastes system resource.
In addition, there is inevitable defective in described method in networking, if counting equipment is serially connected in the outlet of network traffics, the introducing of counting equipment can influence the Performance And Reliability of network, if rate of discharge is mirrored to scheme on the counting equipment but adopt, though to network performance and not influence of reliability, the user can realize free use by a large amount of modes that consume the charging resource.
Summary of the invention
The technical problem that the present invention solves provides a kind of statistical method of data traffic, to solve at present because the charging of precision causes the huge of flow that charge, and takies a large amount of counting equipment problem of resource.
For addressing the above problem, the invention provides a kind of statistical method of data traffic, may further comprise the steps:
A, pre-configured charging configuration set table;
B, generate statistics stream table according to charging group information and IP address;
C, when packet arrives, according to the source IP and the purpose IP address of described packet, and remove to search statistics stream table in conjunction with the configuration information in the described charging configuration set table, if inquire statistics stream table, then write down the corresponding flow information of this packet.
The group of charging described in the steps A is the set with a plurality of IP address of identical charging property.
Adopting the mode of the network segment is user's configuring charging configuration set table in advance, and the content of described charging configuration set table comprises: charging group ID, the purpose IP address of visit, subnet mask.
Described statistics stream table comprises IP address and charging group ID corresponding with it, and uplink packet counting, downstream packets counting or up byte count, descending byte count.
The data flow of showing to obtain described packet with the source IP address and the purpose IP address lookup statistics stream of described packet respectively among the step C, as if inquiring, then the data flow of described packet is for needing the upstream data or the downlink data of charging statistics; Otherwise this packet does not need the statistics of chargeing.
Among the step C according to the IP address lookup charging configuration set table of described data flow, if can from this table, obtain this user's charging group ID, then add up this user number-of-packet and the byte number of corresponding charging group ID, its specific implementation process comprises:
Purpose IP address lookup charging configuration set table according to described upstream data, if inquire, then obtain the charging group ID of this user uplink data, and should add one or/and pairing up byte count adds the byte number of the above packet by the pairing uplink packet counting of charging group ID;
Or according to the source IP address of described downlink data inquiry charging configuration set table, if inquire, then obtain the charging group ID of this user's downlink data, and should add one or/and pairing descending byte count adds the byte number of the above packet by the pairing downstream packets counting of charging group ID.
In addition, the present invention also provides the method for a kind of network equipment according to charge on traffic, may further comprise the steps:
A, will divide into groups with the peer IP address of telex network on the network equipment, the IP address that wherein charging property is identical is located at same charging group;
B, when the network equipment is received packet, inquire about this packet rs destination IP address and source IP address, and mate,, then the packet corresponding flow is noted, in order to generate charge information if the match is successful with above-mentioned IP address and charging group.
In step B, further the judgment data bag is descending or upstream data with respect to the user, and record is carried out in uplink and downlink respectively.
The set of the IP address that described charging group is the same network segment.
Compared with prior art, the present invention has following beneficial effect: the present invention comes this user's data flow is carried out statistic of classification by the source IP address and the purpose IP group of addresses of packet, be that the present invention can carry out the sorting flow statistics according to the object of visit, it is more flexible to make that data flux statistics charges.The statistical efficiency height is only just added up need the charge packet of statistics of user, does not have unnecessary packet like this and is added up, the statistics resource of minimizing system.Simultaneously, the method of the invention also is controlled to taking of resource of statistics, and realize simple, the fail safe of charge system is good, can guarantee the accuracy and the reliability of charging, can be good at resisting the influence of various attack to chargeing and gathering again, the data volume of gathering of chargeing simultaneously is little, to the transmission of metering data and less demanding to counting equipment.In addition, the method for the invention configuration is simple, can also directly be serially connected in the network, also can adopt the mode of mirror image data bag to carry out the charging statistics of data traffic, not only can guarantee to charge accurately, and networking is more convenient.
Embodiment
Core of the present invention is to be user's configuring charging configuration set table according to different station addresses, and described charging configuration set table and user generate statistics stream table by the information of authentication online; When packet reaches, source IP address and purpose IP address according to described packet are inquired about charge configuration set table and statistics stream table respectively, obtain the flow direction (upstream or downstream) and the charging group ID of described packet from described charging configuration set table and statistics stream table respectively; And add up number-of-packet or the byte number of the corresponding charging group of this user ID, if not when charging configuration set table or statistics stream table obtain the flow direction of described packet or charging group ID, then do not add up described packet.Therefore, the present invention comes this user's data flow is added up by the source IP address and the purpose IP group of addresses of packet, thereby can carry out statistic of classification by the object of visit, and it is more flexible to make that data flux statistics charges.Simultaneously, the method for the invention is controlled to taking of resource of statistics, and realizes simply, and the statistical efficiency height can guarantee the accuracy and the reliability of chargeing.Can be good at resisting the influence of various attack to chargeing and gathering again, the data volume of gathering of chargeing simultaneously is little, to the transmission of metering data and less demanding to counting equipment.
The present invention is described further below in conjunction with accompanying drawing.
Please refer to Fig. 1, be the flow chart of the statistical method of data traffic of the present invention.Described method comprises step:
Step F 10: pre-configured charging configuration set table;
Step F 11: generate statistics stream table according to charging group information and IP address;
Step F 12: when packet arrives, source IP and purpose IP address according to described packet, and remove to search statistics stream table in conjunction with the configuration information in the described charging configuration set table, if inquire statistics stream table, then write down the corresponding flow information of this packet (step F 13).
In the step C of described method, can search statistics stream table or charging configuration set table respectively according to the source IP and the purpose IP address of described packet, obtain the data flow or the charging group ID of described packet, again according to the data flow or the charging group ID of described this packet that inquires, remove to search corresponding charging configuration set table or charging stream table, and write down the corresponding flow information of this packet.Concrete implementation please refer to Fig. 2 and shown in Figure 3:
Please refer to Fig. 2, be the flow chart of an embodiment of the statistical method of data traffic of the present invention.Described method comprises step:
Step S10: pre-configured charging configuration set table;
Step S11: generate statistics stream table according to charging group information and IP address;
Step S12: when the user's data bag arrives, search charging configuration set table,, then add up number-of-packet or the byte number (step S13) of the corresponding charging group of this user ID if can therefrom find this user's charging group ID according to the data flow of described packet; Otherwise, do not add up described packet (step S14).
In step S10, described IP address according to different web sites is user's configuring charging configuration set table in advance.Described charging group disposes according to user's charging policy, just is meant one group of IP address with same charging characteristic, shows that the charging characteristic of this IP address of same user capture is identical.Such as, be the same if visit the rate of the flow of domestic network address, just domestic network address is configured to a charging group; If the rate of the flow of the network address of visit Japan is the same, then the network address of Japan is configured to a charging group.In fact, similar to the charging and the charging that we make a phone call of the data traffic of online, we can divide the city into a charging group, suburbs and counties under the jurisdiction of a large city divide a charging group into, domestic divide a charging group into, international divide a charging group into, the mobile subscriber divides a charging group into.Telephone rate if the user makes a phone call in by network same group is the same.Therefore, data traffic and the above-mentioned principle of making a phone call to user's online is similar.And the method for the invention generally adopts the mode of the network segment to be configured, but is not limited to this configuration in order to search and to dispose conveniently, can also be configured according to alternate manner.When the mode of the employing network segment is configured, come configuring charging configuration set table according to several main parameters such as the IP address of configuring charging group ID, network, subnet masks when it is main, and described charging configuration set table can also comprise charging property, if free, the charging center is not taken just passable to this charging batch total.Described charging group ID is used to characterize this charging group, and the IP address of network is exactly that the purpose IP address that need visit of user cooperates with subnet mask, and forms a purpose IP network section.Please refer to table 1, for come configuring charging configuration set table in the mode of the network segment.
Table 1
The IP address |
Mask |
Charging group ID |
60.10.0.0 |
255.255.0.0 |
2 |
192.168.1.0 |
255.255.255.0 |
2 |
In step S11,, generate statistics stream table according to charging configuration set information and the user who surfs the Net by authentication.The generative process of described statistics stream table is: if after the user by authentication surfs the Net, its user's source IP address is 10.10.10.10, suppose charging policy according to the user, and be that it has disposed N charging group, and that each charging group comprises is up, downstream packets counter and up, descending byte counter, all these parameters just are configured to a statistics stream list item, and if the statistics stream table that has disposed N charging group for the user see table 2 for details.
Table 2
IP address | Charging group ID1 | … | Charging group IDN |
The uplink packet counting | The downstream packets counting | Up byte count | Descending byte count | … | The uplink packet counting | The downstream packets counting | Up byte count | Descending byte count |
10.10.10.10 | 43 | 466 | 34562 | 34466 | … | 34 | 432 | 5143 | 83415 |
10.10.10.12 | 13 | 246 | 4562 | 14466 | … | 74 | 932 | 11431 | 93415 |
As shown in Table 2, the content of a list item of the statistics of described N charging group stream comprises: user's source IP address, charging group ID, and described charging group ID comprises uplink packet counter, downstream packets counter, up byte counter and descending byte counter.These four counters among the described charging group ID can be deleted according to user's request adaptability.If the user only need add up charge by byte number, in described statistics stream table, only need a byte count just passable, if but want to charge by different rates according to up, descending byte number, just need add up charging by up, descending two byte counts.If the user had both needed to add up charging according to the number of packet, need again to add up charging according to the byte number of packet, and the two all needs, and branch is up, descending adds up charging respectively, has then just comprised up, downstream packets counting and up, descending byte count item in the configuration of described statistical form.That is to say, described statistics stream table comprises user's source IP address and statistical counter, described statistical counter is used for writing down the statistics of different charge group ID correspondence, need the data of statistics that up, downlink data byte number and up, downstream packets number are arranged or only add up up, descending byte number and bag number, also can only add up among both, described in a word statistics stream table is to determine according to the charging demand of particular user.
In addition, described statistics stream table is just to have immobilized after generation because the number of users of its online and configuring charging group number all fix, so the statistics stream table that generates also fix, and described statistics stream table to generate the back irrelevant with this user's behavior.
In step S12, when packet enters charge system, inquire about described statistics stream table with the source IP address of described packet earlier, if in statistics stream table, inquire (promptly hitting), then show it is that the flow direction of described packet is up, and described packet is a upstream data; If in this statistics stream table, do not inquire (promptly not hitting), then come query statistic stream table with the purpose IP address of packet again, if inquire (promptly hitting), the flow direction that described packet then is described is descending, and described packet is a downlink data.But with the process of the source IP address of packet or two inquiries in purpose IP address in no particular order, who all it doesn't matter after whom earlier.If statistics stream table is not all hit in source IP address or purpose IP address with this packet, illustrate that then described packet is not the packet that needs statistics to charge, and then abandons.In addition, the flow direction of described packet not only can obtain by looking into the stream table, can also obtain by other method, for example can be according to designated port, if outbound port is upstream data, then inbound port is exactly a downlink data, or the like.Because it has been prior art that described port according to appointment obtains the flow of packet, here just repeat no more.
And, if described packet is a upstream data, then again with the purpose IP address lookup charging configuration set table of this packet, if inquire, then obtain the charging group ID of this user uplink data, simultaneously the relevant counter of the correspondence charging group ID of the corresponding occurrence of resulting statistics stream table among the step S11 is added up, promptly for upstream data, need and should add one by the pairing uplink packet counting of charging group ID, up byte count that simultaneously should charging group ID correspondence adds the byte number of this described packet.
If described packet is a downlink data, then inquire about charging configuration set table with the source IP address of this packet again, if inquire, then obtain the charging group ID of this user's downlink data, simultaneously the relevant counter of the correspondence charging group ID of the corresponding occurrence of resulting statistics stream table among the step S11 is added up, promptly for downlink data, need and should add one by the pairing downstream packets counting of charging group ID, descending byte count that simultaneously should charging group ID correspondence adds the byte number (step S13) of this described packet.
If when all not hitting (or inquiring) with the purpose IP address lookup charging configuration set table of this packet again, illustrate that then described packet is not need to add up the packet of charging or surf the Net free packet, will abandon for upstream data or downlink data.
Also please refer to Fig. 3, be the flow chart of another embodiment of statistical method of data traffic of the present invention, described method comprises step:
Step H10: pre-configured charging configuration set table;
Step H11: generate statistics stream table according to charging group information and IP address;
Step H12: when the user's data bag arrives, obtain this user's charging group ID by inquiry charging configuration set table, and according to the source IP address query statistic of described charging group ID and packet stream table, if in looking into, then obtain the flow direction of this packet, add up this user number-of-packet or the byte number (step H13) of corresponding charging group ID; Otherwise, do not add up described packet (step H14).
The step S10 of described step H10 and said method is user's configuring charging configuration set table in advance, and the implementation procedure of its configuring charging group is also identical.Wherein, charging configuration set table sees above-mentioned table 1 for details.The charging group just is meant one group of IP address of the same charging characteristic of tool described in table 1, shows that the charging characteristic of same this IP of user capture is identical, in order to search and to dispose conveniently.The method of the invention generally adopts the mode of the network segment to be configured charging configuration set table.It mainly disposes according to several characterisitic parameters such as charging group ID, IP address, subnet mask and charging property, described charging group ID is used to characterize this charging group, described IP address is exactly the purpose IP address of visit, and this IP address cooperates with subnet mask and identifies a purpose IP network section.
In step H11,, generate statistics stream table according to charging configuration set information and the user who surfs the Net by authentication.The generative process of described statistics stream table is: if the user is by its source IP address 61.10.0.0 online, and disposed charging group ID2, then generate four countings that above-mentioned list item comprises this charging group correspondence, if also disposed charging group ID3 then one of regeneration, for charging group ID is 3, dispose several charging groups and just generated several, this is the same with the method for front in fact, the charging group of front is all in a record nothing but, and described method is split into several records to it, and its content is the same.Because the number of users and the configuring charging group number of online are all fixed, so the statistics stream table that generates is also fixed.It is irrelevant with this user's behavior that described statistics stream table generates the back.Its described statistics stream table sees table 3 for details.As shown in Table 3, described statistics stream table content comprises source IP address, charging group ID and statistical counter; And described statistical counter is to be used for writing down up, downlink traffic byte number and up, downstream packets number or only to add up up, descending byte number and bag number or only add up among both one, and described in a word statistics stream table is to determine according to user's concrete charging demand.
Table 3
The address | Charging group ID | The uplink packet counting | The downstream packets counting | Up byte count | Descending byte count |
10.10.10.10 | 2 | 43 | 466 | 34562 | 34466 |
10.10.10.12 | 2 | 13 | 246 | 4562 | 14466 |
In step H12, after packet enters charge system, with the source IP address and the purpose IP address lookup charging configuration set table of this packet,, just obtain charging group ID respectively if in this charging configuration set table, inquire (or hitting charging group polling table); If twice does not all inquire, illustrate that described packet is not need to charge the data of statistics, will abandon described packet.
If the source IP address with packet obtains charging group ID by inquiry charging configuration set table, then described should charging group ID and the source IP address of described packet go coupling (inquiry) statistics stream to show, if hit, show it is downlink data, the following counter of line correlation add up, be about to the pairing downstream packets of this charging group ID count add one and pairing descending byte count add the byte number of the above packet.If the purpose IP with packet inquires charging group ID, the source IP address of then described charging group ID and packet removes coupling (coupling) statistics stream table, if hit, then the upstream data counter that upstream data is relevant is added up, be about to the pairing uplink packet counting of this charging group ID add one and pairing up byte count add the byte number of the above packet.All do not hit (obtaining charging group ID) if inquire about charging configuration set table with the source IP address of packet and purpose IP address, perhaps flow when showing with the source of the charging group ID that obtains and described packet or purpose IP matching addresses (inquiry) statistics, when also not hitting (finding), the described packet statistics of need not chargeing is described then.
In addition, the present invention also provides the method for a kind of network equipment according to charge on traffic, and the flow chart of described method sees Fig. 4 for details, said method comprising the steps of:
Step M10: will divide into groups with the peer IP address of telex network on the network equipment, the IP address that wherein charging property is identical is located at same charging group;
Step M11: when the network equipment is received packet, inquire about this packet rs destination IP address and source IP address, and mate, if the match is successful with above-mentioned IP address and charging group, then the packet corresponding flow is noted, in order to generate charge information (step M12).
In step M11, search statistics stream table according to described packet rs destination IP address and source IP address, if then with purpose IP address lookup, illustrate that then described packet is a downlink data, if when inquiring, illustrate that then described packet is a upstream data, and search charging configuration set table according to the purpose IP address and the source IP address of described upstream data or downlink data with source IP address, obtain charging group ID, and the pairing uplink and downlink data traffic of described charging group ID is carried out record.Concrete implementation procedure as previously mentioned.Wherein, the set of the described charging group IP address that is the same network segment.
The above only is a preferred implementation of the present invention, does not constitute the qualification to protection range of the present invention.Should be understood that; for those skilled in the art; under the prerequisite that does not break away from the principle of the invention, can also make some modifications, be equal to and replace and improvement etc., these modifications, be equal to replace and improve and all should be included within the claim protection range of the present invention.