Page 9 of 10 FirstFirst ... 78910 LastLast
Results 81 to 90 of 94

Thread: Dynamic Bandwidth Detection (BWCheck)

  1. #81
    Join Date
    Dec 2007
    Posts
    28,412

    Default

    There is a working AS3 example here:
    [wowza-install-dir]/examples/BWChecker/client/bwchecker.fla

    Richard

  2. #82
    Join Date
    Jun 2009
    Posts
    146

    Default

    Hi Richard/Charlie,

    Do you have a ready built mdoule for me to use for upload bandwidth checker? I seem to have only the download check in the examples folder. In one of the threads above, there was a discussion of the upload test code, but the link gave me a 404. I am using 1.7.2 Wowza EC2. Thanks, Ramesh

  3. #83
    Join Date
    Dec 2007
    Posts
    28,412

    Default

    It's on page 2 of this thread. You have to build it in the Wowza IDE

    It tests from client to server. The default one at the top tests from server to client.

    Richard

  4. #84
    Join Date
    Jun 2009
    Posts
    146

    Default

    Richard, I will send you a DM on this, if you don't mind. Thanks, Ramesh

  5. #85
    Join Date
    Jun 2009
    Posts
    146

    Default Flex code for CtoSBwCheck needs resolution

    Hi Richard/Charlie, based on yours and Roger's code, I attempted to write a small flex app to detect upload BW check code and i run into an error. When I ask the debugger to continue, it seems to run and provide the result. However, I would very much like to solve the error. Do you have an idea as to why this might be happening? The code is below...

    The error I get is :

    SWF] Users:adminocuments:Flex Builder 3:flexTestApps:bin-debug:FlexUploadBWCheck.swf - 633,710 bytes after decompression
    ArgumentError: Error #1063: Argument count mismatch on FlexUploadBWCheck/onBWDone(). Expected 4, got 0.
    asyncErrorEvtHanlder: [AsyncErrorEvent type="asyncError" bubbles=false cancelable=false eventPhase=2 text="Error #2095: flash.net.NetConnection was unable to invoke callback onBWDone." error=ArgumentError: Error #1063: Argument count mismatch on FlexUploadBWCheck/onBWDone(). Expected 4, got 0.]
    testing CtoS performance...

    Thanks, Ramesh

    ------------------ code ------
    Code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()">
    
    	<mx:Script>
    		<![CDATA[
    			import flash.net.NetConnection;
    			import flash.net.NetStream;
    			import mx.managers.SystemManager;
    			
    			private var nc:NetConnection;
    			private	var thumb:NetStream; 
    			private var connectionObj:Object; 	
    			private var res:Object;	
    			private	var payload:Array = new Array();
    
                private function init():void {
    				res = new Object();
    				res.latency = 0;
    				res.cumLatency = 1;
    				res.bwTime = 0;
    				res.count = 0;
    				res.sent = 0;
    				res.kbitUp = 0;
    				res.deltaUp = 0;
    				res.deltaTime = 0;
    				//res.client = p_client;
    				//var stats = p_client.getStats();
    				res.pakSent = new Array();
    				res.pakRecv = new Array();
    				res.beginningValues = {};
    				
    				for (var i:int=0; i<1200; i++){
    					payload[i] = Math.random();	//16K approx
    				}
    				samplePlay();
                }
    
    			private function samplePlay():void{
    				nc=new NetConnection() ;
    				nc.client = this;
    				nc.addEventListener (NetStatusEvent.NET_STATUS,checkConnect);
    				nc.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorEvtHandler);
    				var rtmpNow:String = "rtmp://localhost/bwcheck";
    				nc.connect (rtmpNow);
    			}
    			private function checkConnect(e:NetStatusEvent):void{
    				if(e.info.code == "NetConnection.Connect.Success"){
    					doClientBWCheck();
    				}
    			}
    			private function doClientBWCheck():void {
    				nc.call("onClientBWCheck", new Responder(getBWCheckData, noBWData), null);
    				trace("testing CtoS performance...");
    				
    			}
    			public function getBWCheckData(p_res:Object):void {
    				trace ("ClientBWResult: ");
    				var now:Number = (new Date()).getTime()/1;
    				if(res.sent == 0) {
    					res.beginningValues = p_res;
    					res.beginningValues.time = now;
    					res.pakSent[res.sent++] = now;
    					nc.call("onClientBWCheck", new Responder(getBWCheckData, noBWData), now);
    				} else {
    					res.pakRecv[res.count] = now;
    					trace( "Packet interval = " + (res.pakRecv[res.count] - res.pakSent[res.count])*1  );
    					res.count++;
    					var timePassed:Number = (now - res.beginningValues.time);
    			
    					if (res.count == 1) {
    						res.latency = Math.min(timePassed, 800);
    						res.latency = Math.max(res.latency, 10);
    						res.overhead = p_res.cOutBytes - res.beginningValues.cOutBytes;
    						trace("overhead: "+res.overhead);
    						res.pakSent[res.sent++] = now;
    						nc.call("onClientBWCheck", new Responder(getBWCheckData, noBWData), now, payload);
    					}
    					trace("count: "+res.count+ " sent: "+res.sent+" timePassed: "+timePassed+" latency: "+res.latency);
    				
    					// If we have a hi-speed network with low latency send more to determine
    					// better bandwidth numbers, send no more than 6 packets
    					if ( (res.count >= 1) && (timePassed<1000))
    					{
    						res.pakSent[res.sent++] = now;
    						res.cumLatency++;
    						nc.call("onClientBWCheck", new Responder(getBWCheckData, noBWData), now, payload);
    					} else if ( res.sent == res.count ) {	
    						// See if we need to normalize latency
    						if ( res.latency >= 100 )
    						{ // make sure we detect sattelite and modem correctly
    							if (  res.pakRecv[1] - res.pakRecv[0] > 1000 )
    							{
    								res.latency = 100;
    							}
    						}
    						payload = null;
    						System.gc();
    						//delete payload;
    						// Got back responses for all the packets compute the bandwidth.
    						var stats:Object = p_res;
    						var deltaUp:Number = (stats.cOutBytes - res.beginningValues.cOutBytes)*8/1000;
    						var deltaTime:Number = ((now - res.beginningValues.time) - (res.latency * res.cumLatency) )/1000;
    						if ( deltaTime <= 0 )
    							deltaTime = (now - res.beginningValues.time)/1000;
    						
    						var kbitUp:Number = Math.round(deltaUp/deltaTime);
    				
    						trace("getBWCheckData: kbitUp = " + kbitUp + ", deltaUp= " + deltaUp + ", deltaTime = " + deltaTime + ", latency = " + res.latency + " KBytes " + (stats.cOutBytes - res.beginningValues.cOutBytes)/1024) ;
    					}
    				}
    				
    			}
    			public function onBWDone(kbitDown:Number, deltaDown:Number, deltaTime:Number, latency:Number):void
    			{
    				trace("onBWDone: kbitDown:"+kbitDown+" deltaDown:"+deltaDown+" deltaTime:"+deltaTime+" latency:"+latency);
    				// app logic based on the bandwidth detected follows here
    				var detected_bw:Number = kbitDown;
    				// close the Netconnection to bwcheck
    			}
    			private function noBWData(result:Object):void{
    				trace("No BandWidth data: ", result);
    			}	
    			public function asyncErrorEvtHandler(result:Object):void {
    				trace("asyncErrorEvtHanlder: ", result);
    			}
    			private function onMetaData(o:Object):void{	}
    			private function onPlayStatus(o:Object):void{}
    		]]>
    	</mx:Script>
    </mx:Application>

  6. #86

    Default

    I think the problem is obvious isn't it. Your client-side method is:

    Code:
    public function onBWDone(kbitDown:Number, deltaDown:Number, deltaTime:Number, latency:Number):void
    It is looking for a version of this method with no parameter.

    Code:
    public function onBWDone():void
    Charlie

  7. #87
    Join Date
    Jun 2009
    Posts
    146

    Default

    Sorry, what a dreadfully silly mistake. In my mind, I was sure that that onBWDone should be having parameters because the download test had a lot of parameters in teh code. Embarrassing!! Thanks

  8. #88
    Join Date
    Sep 2010
    Posts
    1

    Default

    Quote Originally Posted by ramesh_manian View Post
    Sorry, what a dreadfully silly mistake. In my mind, I was sure that that onBWDone should be having parameters because the download test had a lot of parameters in teh code. Embarrassing!! Thanks
    Im sorry my ignorance about this but...

    What should I put on

    var rtmpNow:String = "rtmp://localhost/";


    I which address should I use for rtmp? I always get ... connection failed... Do i have to export a release version of this, and put the address of the application as : localhost/TestingBandwidth/TestBandwith.html ??

    thank you Id appreciate it

  9. #89
    Join Date
    Dec 2007
    Posts
    28,412

    Default

    I don't understand the question. Can you explain?

    Richard

  10. #90
    Join Date
    Aug 2010
    Posts
    1

    Default Update to get Bandwidth Client Upload Speed to work in ActionScript 3, the right way.

    Roger,
    I didn't have to change much to get your actionscript to work correctly. Adobe has done away with the onResponse callback on its own, it now has to become a Responder object with a specific callback, onResponse or onFault or both.

    This following actionscript file can be used as is and works great. I have a reference to the Object res, but the responder calls itself, and references the res Object from within its code.

    To anyone else who had issues getting the actionscript part of this to work, I hope this saves some headache.

    Roger thanks for the Java class and for the logic to get this to work.

    Cheers,
    Scott Haines

    ----------------------------------------------------------

    var nc:NetConnection;
    var res;
    var payload;
    var ro;

    function doClientBWCheck() {
    trace("testing CtoS performance...");
    nc.call("onClientBWCheck", ro, null);
    }


    function netConnectionStatusHandler(e:NetStatusEvent):void
    {
    if (e.info.code == "NetConnection.Connect.Success") {
    doClientBWCheck();
    }
    }

    function ncOnBWDone()
    {
    trace("BW Done");
    }

    function ncOnBWCheck()
    {
    trace("BW Check");
    }

    function onClientResponse()
    {
    trace("got info");
    }
    var totalCount = 10;
    function onResult(arg){
    trace("Got some Args Bytes Out"+arg["cOutBytes"]+" Bytes In: "+arg["cInBytes"]+" Time: "+arg["time"]);

    var now = (new Date()).getTime()/1;

    if(res.sent == 0)
    {
    res.beginningValues = arg;
    res.beginningValues.time = now;
    res.pakSent[res.sent++] = now;
    nc.call("onClientBWCheck", ro, now);
    }
    else
    {
    res.pakRecv[res.count] = now;
    trace( "Packet interval = " + (res.pakRecv[res.count] - res.pakSent[res.count])*1 );
    res.count++;
    var timePassed = ( now - res.beginningValues.time );

    if (res.count == 1)
    {
    res.latency = Math.min(timePassed, 800);
    res.latency = Math.max(res.latency, 10);
    res.overhead = arg.cOutBytes - res.beginningValues.cOutBytes;
    trace("overhead: "+res.overhead);
    res.pakSent[res.sent++] = now;
    nc.call("onClientBWCheck", ro, now, payload);
    }
    trace("count: "+res.count+ " sent: "+res.sent+" timePassed: "+timePassed+" latency: "+res.latency);
    // If we have a hi-speed network with low latency send more to determine
    // better bandwidth numbers, send no more than 6 packets

    if ( (res.count >= 1) && (timePassed < 1000))
    {
    res.pakSent[res.sent++] = now;
    res.cumLatency++;
    nc.call("onClientBWCheck", ro, now, payload);
    }
    else if (res.sent == res.count)
    {
    // See if we need to normalize latency
    if ( this.latency >= 100 )
    {
    if ( res.pakRecv[1] - res.pakRecv[0] > 1000 )
    {
    res.latency = 100;
    }
    }
    payload.length = 0;

    // Got back responses for all packets, compute bandwidth upspeed
    var stats = arg;
    var deltaUp = (stats.cOutBytes - res.beginningValues.cOutBytes)*8/1000;
    var deltaTime = ((now - res.beginningValues.time) - (res.latency * res.cumLatency) )/1000;

    if ( deltaTime <= 0 )
    deltaTime = ( now - res.beginningValues.time) / 1000;

    var kbitUp = Math.round(deltaUp/deltaTime);

    trace("onBWDone: kbitUp = " + kbitUp + ", deltaUp= "+ deltaUp + " , deltaTime = " + deltaTime + ", latency = " + res.latency + " KBytes " + (stats.cOutBytes - res.beginningValues.cOutBytes)/1024) ;
    }


    }

    };


    function init()
    {
    nc = new NetConnection();
    nc.addEventListener(NetStatusEvent.NET_STATUS,netConnectionStatusHandler);
    ro = new Responder(onResult);

    res = new Object;
    res.latency = 0;
    res.cumLatency = 1;
    res.bwTime = 0;
    res.count = 0;
    res.sent = 0;
    res.kbitUp = 0;
    res.deltaUp = 0;
    res.deltaTime = 0;
    //res.client = p_client;
    //var stats = p_client.getStats();
    res.pakSent = new Array();
    res.pakRecv = new Array();
    res.beginningValues = {};

    nc.objectEncoding = ObjectEncoding.AMF0;

    var ncClientObj:Object = new Object();
    nc.client = ncClientObj;
    ncClientObj.onBWDone = ncOnBWDone;
    ncClientObj.onBWCheck = ncOnBWCheck;

    payload = new Array();
    for (var i=0; i<1200; i++){
    payload[i] = Math.random(); //16K approx
    }

    nc.connect("rtmp://localhost/bwcheck");
    }
    init();

    -----------------------------------------------------------------------------
    Last edited by newfront; 09-28-2010 at 10:18 AM.

Page 9 of 10 FirstFirst ... 78910 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •