Background technology
Statistical report according to the China Internet Network Information Center (CNNIC) issue shows that by in by the end of June, 2010, Chinese netizen's scale reaches 4.2 hundred million, has broken through 400,000,000 high pointes, and than increasing by 3,600 ten thousand people the end of the year 2009, Internet penetration rises to 31.8%.Above data are enough to show, the Internet is to the influence degree of people's work, life, study, and by this platform of the Internet, we can surf the web, and watch film and television, check information, reading, chat etc.Enjoying the Internet simultaneously easily, we are also ceaselessly consuming various resources, and as Internet resources, server resource, information resources etc., wherein, Internet resources have the greatest impact to the user's.The situation of China is more special, and most of netizens surf the Net by the ADSL dialing and the mode in fixed network broadband, and major part all is to use shared bandwidth and local area network (LAN).In this case, if network traffics increase, will influence other users' network speed, because of these processes all are to operate on the backstage, therefore, the user often can't learn the situation of the shared bandwidth resources of current certain function of local computer, and whether certain function that also can't learn own internet usage can exert an influence and produce great influence other users.In the present stage computer application, there are a lot of softwares can realize the monitoring of network traffics, as DU Meter, QQ doctor, QQ computer house keeper, 360 security guards etc., but these softwares all need to download and install, can make amendment to user's computer like this, read operation and some controls of registration are installed, bring serious potential safety hazard to the user.In addition, these softwares can only carry out traffic monitoring to single software, usually, having a plurality of modules in the single software operates network, if can't monitor to the module in the single software, equally also the concrete condition that network traffics expend can't be learnt, the problem that exists in the network flow monitoring can't be solved up hill and dale.
Realize the method for Flash network flow monitoring on a kind of webpage, be intended to solve the problem that exists in the present stage realization network monitoring, this technology need not to download any control, need not the support of third party's application framework and application system, fully just can realize specific monitoring to the network traffics of each the Flash module in the webpage based on webpage, easy to operate, quick, reaction is a kind of popular technology of truly can popularizing in time.And realize that principle is simple, can embed easily in the various internet, applications.
Summary of the invention
The objective of the invention is: the method that realizes the Flash network flow monitoring on a kind of webpage is provided.
In order to achieve the above object, technical scheme of the present invention is: realize the method for Flash network flow monitoring on a kind of webpage, may further comprise the steps:
1) source user is opened webpage, webpage loads the Flash plug-in unit automatically, after Flash loads successfully, calls the setInterval function, the turn-on flow rate monitoring regularly gathers, the turn-on flow rate monitoring regularly gathers, and wherein, described function is represented with variable netInterval, being used for that network traffics are carried out stage regularly gathers, wherein, can dispose or be provided with the blanking time of netInterval, Flash global traffic record array carried out circle statistics analyze aggregation process;
2) user's operation web page, Flash is initiated the network operation instruction, Flash calls API and carries out the network processes operation, wherein, described network processes operation refers to the audio frequency and video broadcast, audio frequency and video are recorded, the audio frequency and video issue, resource loads, the example of Flash initialization this moment network operation related object, described network operation related object refers to NetConnection, NetStream, wherein, NetConnection represents with variable nc, NetStream represents with variable ns, after NetStream is initialised success, by calling the info attribute of ns, obtain the NetStreamInfo object of ns institute storage networking flow, wherein, NetStreamInfo represents with variable nsInfo, by obtaining the currentBytesPerSecond attribute of nsInfo, can obtain the byte number of the Network Transmission that ns current this second taken place, by judging the generation source of ns,, just be designated downloading flow if the source is to be produced by the mode of going into, if the source is what to be produced by the mode that goes out, just be designated and upload flow, and after this ns identified, with upload relevant with ns, download message deposits in the Flash global traffic record array;
3) after the flow information tabulate statistics, Flash invoking web page JavaScript flow immediately handles function, import into gather upload data such as flow, downloading flow, webpage processs and displays importing data into, promptly realizes fully the Flash network flow monitoring based on webpage.
In the technique scheme, step 1) comprises following process:
Source user is opened webpage, webpage loads the Flash plug-in unit automatically, after Flash loads successfully, call setInterval function (netInterval represents with variable), be used for that network traffics are carried out regularly stage and gather that (can dispose or be provided with the blanking time of netInterval, be defaulted as for 1 second), promptly Flash global traffic record array is carried out circle statistics and analyze aggregation process.
In the technique scheme, step 2) comprise following process:
2a) (these instructions comprise the function call that the user registers by ExternalInterface.addCallback JavaScript function call Flash by webpage whenever Flash receives new dependent instruction, the operational order that Flash oneself initiates, other network connects the operational order of initiation etc.) when carrying out network operation;
2b) Flash calls that API carries out that audio frequency and video are play, audio frequency and video are recorded, audio frequency and video issues, the network operation processing is carried out in resource loading etc., this moment Flash initialization NetConnection (nc represents with variable), NetStream network operation related objects such as (ns represent with variable) example, after NetStream is initialised success, by calling the info attribute of ns, obtain NetStreamInfo (nsInfo represents with the variable) object of ns institute storage networking flow;
2c) by obtaining the currentBytesPerSecond attribute of nsInfo, can obtain the byte number of the Network Transmission that ns current this second taken place, by judging the generation source of ns, if the source is by broadcast, the mode that loading etc. is gone into produces, just be designated downloading flow, if the source is by recording, the mode that issue etc. go out produces, just be designated and upload flow, and after this ns identified, with upload relevant with ns, download message deposits in the Flash global traffic record array, if there has been the flow information of this ns before, then this ns data on flows information in the Flash global traffic record array is upgraded;
2d) because netInterval periodically analyzes aggregation process to the Flash global traffic, so when the global traffic array has change, netInterval can gather out immediately, and handles function by ExternalInterface.call function call webpage JavaScript flow.
In the technique scheme, step 3) comprises following process:
Webpage JavaScript flow is handled function and is received after the network traffics combined data handles, and on webpage network traffic information is operated or is shown, promptly realizes the Flash network flow monitoring on the webpage.
The present invention compared with prior art has the following advantages:
1) realizes based on webpage fully, do not need to download any control, do not need third party's application system to support.
2) can monitor and add up the single information relevant among the single Flash of webpage, the single Flash, can fundamentally understand the network traffic information of the Flash in the current web page, in time, accurately, in detail with network traffics.
3) realize that principle is simple, fully based on webpage, do not need to download any plug-in unit, green, environmental protection can be widely used in the internet, applications such as Web conference, long-distance education.
Embodiment
Realize the method for Flash network flow monitoring on a kind of webpage, may further comprise the steps:
1) source user is opened webpage, and webpage loads the Flash plug-in unit, and the turn-on flow rate monitoring regularly gathers;
2) user's operation web page, Flash is initiated the network operation instruction, Flash calls that API carries out that audio frequency and video are play, audio frequency and video are recorded, audio frequency and video issues, resource loading etc. carried out network processes and operated, write down the flow information of each new network processes operation simultaneously, recorded information comprises flow information, the downloading flow information etc. uploaded, and regularly the flow information of all records is carried out the time interval tabulate statistics of timing;
3) after the flow information tabulate statistics, Flash is the invoking web page function immediately, import into gather upload data such as flow, downloading flow, webpage processs and displays importing data into, promptly realizes fully the Flash network flow monitoring based on webpage.
Further describe method of the present invention below:
Referring to Figure of description, source user is opened webpage, webpage loads the Flash plug-in unit automatically, after Flash loads successfully, call setInterval function (netInterval represents with variable), be used for that network traffics are carried out stage regularly and gather (can dispose or be provided with the blanking time of netInterval, was defaulted as for 1 second), promptly Flash global traffic record array is carried out circle statistics and analyze aggregation process; (these instructions comprise the function call that the user registers by ExternalInterface.addCallback JavaScript function call Flash by webpage whenever Flash accepts new dependent instruction, the operational order that Flash oneself initiates, other network connects the operational order of initiation etc.) when carrying out network operation; Flash calls that API carries out that audio frequency and video are play, audio frequency and video are recorded, audio frequency and video issues, resource loading etc. carried out the network operation processing, the example of Flash meeting this moment initialization NetConnection (nc represents with variable), NetStream network operation related objects such as (ns represent with variable), after NetStream is initialised success, by calling the info attribute of ns, obtain NetStreamInfo (nsInfo represents with the variable) object of ns institute storage networking flow; By obtaining the currentBytesPerSecond attribute of nsInfo, can obtain the byte number of the Network Transmission that current this second of ns take place, by judging the generation source of ns, if the source is by broadcast, the mode that loading etc. is gone into produces, just be designated downloading flow, if the source is by recording, the mode that issue etc. go out produces, just be designated and upload flow, and after this ns identified, with upload relevant with ns, download message deposits in the Flash global traffic record array, if there has been the flow information of this ns before, then this ns data on flows information in the Flash global traffic record array is upgraded; Because netInterval periodically analyzes aggregation process to the Flash global traffic, so when the global traffic array has change, netInterval can gather out immediately, and handles function by ExternalInterface.call function call webpage JavaScript flow; Webpage JavaScript flow is handled function and is received after the network traffics combined data handles, and on webpage network traffic information is operated or is shown, promptly realizes the Flash network flow monitoring on the webpage.