# Dynamic Bandwidth Detection (BWCheck)

**URL:** <https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73>\
**Category:** Wowza Streaming Engine\
**Created:** [March 15, 2007, 6:40am UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73 "2007-03-15T06:40:15Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [February 4, 2009, 5:12pm UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73/41 "2009-02-04T17:12:32Z")

</div>

Yes, send to richard.lanham@gmail.com

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [February 4, 2009, 5:54pm UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73/42 "2009-02-04T17:54:59Z")

</div>

I think I see the problem. You have to re-order the flow.

When onBWDone returns kbitdown is when you should call createPlayStream.

Also you are closing the connection onBWDone, don’t do that.

There are 3 changes below should do it:

```auto
nc.onBWDone = function(kbitDown, deltaDown, deltaTime, latency) {
trace("onBWDone: kbitDown:"+kbitDown+" deltaDown:"+deltaDown+" deltaTime:"+deltaTime+" latency:"+latency);
// app logic based on the bandwidth detected follows here
detected_bw = kbitDown;
createPlayStream(); // insert this here
// close the Netconnection to bwcheck
//this.close();
}
function doConnect()
....
enablePlayControls(true);
// createPlayStream(); // comment this out
videoLastW = 0;
videoLastH = 0;

```

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [August 18, 2009, 11:25am UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73/43 "2009-08-18T11:25:20Z")

</div>

When do you call this function from the client? It might be too soon. You should wait till you get “NetStream.Play.Start” notification in your NetStatus event handler. Something like:

```auto
protected function statusHandler(evt:NetStatusEvent):void {
	switch (evt.info.code) {
		case 'NetStream.Play.Start'
		netconnection.call("getStreamStats",new Responder(handleResponse),"someStream");
...

```

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [September 17, 2009, 5:28pm UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73/44 "2009-09-17T17:28:54Z")

</div>

The approach is to use the bandwidth checker to determine available bandwidth to the client, then use that information to play a video with appropriate bit rate for that connection. The buffer is not something you want to adjust for this purpose.

And bandwidth checking is not automatic. And what you do with the results of the bandwidth checking is not automatic. You have to add the module to Application.xml, and you have to run the bandwith checking functions in the player, and you have to take the result and do something with it: play a version of the video that you have encoded to a bit rate for that connection speed.

[http://community.wowza.com/t/-/31](http://community.wowza.com/t/-/31)

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [September 21, 2009, 2:31pm UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73/45 "2009-09-21T14:31:45Z")

</div>

Yes, the source code for bandwidth checker is in first post of this thread. You can compile your own version in the Wowza IDE to make adjustments.

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [September 29, 2009, 9:09pm UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73/46 "2009-09-29T21:09:47Z")

</div>

Did you add the jar file to wowza/lib folder then restart Wowza, and did you add the module to Application.xml. You want to connect to the Wowza server that you added that jar to, and to the application that you added the Module to.

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [October 27, 2009, 11:26am UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73/47 "2009-10-27T11:26:06Z")

</div>

There is a Actionscript 3 version of ctosbwcheck in [wowza-install-dir]/examples/BWCheck/CtoSBWCheck.fla

The results of the bwcheck do vary from moment to moment, which is normal result of varying network conditions.

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [October 28, 2009, 11:07am UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73/48 "2009-10-28T11:07:57Z")

</div>

It should be here:

[install dir]\examples\BWChecker\client\CtoSBWCheck.fla

I’ll send it to that email too.

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [January 21, 2010, 8:03pm UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73/49 "2010-01-21T20:03:39Z")

</div>

There is a working AS3 example here:

[wowza-install-dir]/examples/BWChecker/client/bwchecker.fla

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [March 6, 2010, 7:36pm UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73/50 "2010-03-06T19:36:39Z")

</div>

It’s on page 2 of this thread. You have to build it in the [Wowza IDE](http://wowza.com/labs.html)

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

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [September 24, 2010, 2:25am UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73/51 "2010-09-24T02:25:36Z")

</div>

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

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [September 19, 2012, 2:13pm UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73/52 "2012-09-19T14:13:49Z")

</div>

I think you are talking about using Netstream.play2() and netstreaminfo object. This what is used to implement Flash Dynamic Streaming, for example [JW Player’s implementation](http://www.longtailvideo.com/support/jw-player/jw-player-for-flash-v5/16012/setting-up-rtmp-dynamic-streaming)

You can search around but here is one article that looks useful

[http://help.adobe.com/en\_US/flashmediaserver/devguide/WSae44d1d92c7021ff-1f5381712889cd7b56-8000.html](http://help.adobe.com/en_US/flashmediaserver/devguide/WSae44d1d92c7021ff-1f5381712889cd7b56-8000.html)

Here is how the simple, before connect method to check bandwidth

[https://www.wowza.com/docs/how-to-test-server-to-client-bandwidth-for-rtmp-clients](https://www.wowza.com/docs/how-to-test-server-to-client-bandwidth-for-rtmp-clients)

I think that camera.setQuality() will have an affect on a stream after you do netstream.publish()

Richard

---

<div class="post-metadata">

**Author:** ![Richard\_Lanham](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@Richard\_Lanham](https://community.wowza.com/u/Richard_Lanham)\
**Post date:** [September 19, 2012, 3:07pm UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73/53 "2012-09-19T15:07:21Z")

</div>

You’re English is great. Thanks for the update.

Richard

---

<div class="post-metadata">

**Author:** ![Kenny\_Geeraerts](https://avatars.discourse-cdn.com/v4/letter/k/6f9a4e/32.png) [@Kenny\_Geeraerts](https://community.wowza.com/u/Kenny_Geeraerts)\
**Post date:** [February 27, 2008, 3:15pm UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73/54 "2008-02-27T15:15:04Z")

</div>

i’m having some problems with converting the BWChecker to AS3.

this is what i’ve got :

```auto
var constring="rtmp://localhost/bwcheck";
var detected_bw:String;
var counter:Number=0;
var nc:NetConnection=new NetConnection;
nc.client=this;
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler );
function netStatusHandler (e:NetStatusEvent):void{
	trace("Level: "+e.info.level+" Code: "+e.info.code);
	if (e.info.code == "NetConnection.Connect.Success") {
		trace("--- connected to: " + nc.uri);	//this.uri
	}
}
function onBWCheck(latency:String):Number{
	trace("in onBWCheck");
	return ++counter; // Serverside, just ignore any return value, For now return the call count
}
function onBWDone(kbitDown, deltaDown, deltaTime, latency):void{
	trace("==>in onBW_DONE");
	trace("onBWDone: kbitDown:"+kbitDown+" deltaDown:"+deltaDown+" deltaTime:"+deltaTime+" latency:"+latency);
	//detected_bw = kbitDown;
	nc.close();
}
nc.connect(constring, true);
stop();

```

and i get this as a result (haven’t changed anything to serverside code, or is it necessary that i do that?):

in onBWCheck

Level: status Code: NetConnection.Connect.Success

— connected to: rtmp://localhost/bwcheck

---

<div class="post-metadata">

**Author:** ![Kenny\_Geeraerts](https://avatars.discourse-cdn.com/v4/letter/k/6f9a4e/32.png) [@Kenny\_Geeraerts](https://community.wowza.com/u/Kenny_Geeraerts)\
**Post date:** [February 28, 2008, 12:05pm UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73/55 "2008-02-28T12:05:33Z")

</div>

ok , works like a charm now. Thanks a lot !

---

<div class="post-metadata">

**Author:** ![Dean\_Sills](https://avatars.discourse-cdn.com/v4/letter/d/ecd19e/32.png) [@Dean\_Sills](https://community.wowza.com/u/Dean_Sills)\
**Post date:** [April 7, 2008, 6:13am UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73/56 "2008-04-07T06:13:00Z")

</div>

Hi Craigweb,

You may find netlimiter useful:

[http://www.netlimiter.com](http://www.netlimiter.com)

Regards,

Dean

---

<div class="post-metadata">

**Author:** ![Bingo\_Bongo](https://avatars.discourse-cdn.com/v4/letter/b/f4b2a3/32.png) [@Bingo\_Bongo](https://community.wowza.com/u/Bingo_Bongo)\
**Post date:** [October 3, 2008, 1:14pm UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73/57 "2008-10-03T13:14:03Z")

</div>

Hi Charlie,

like _balint.pelhos_ , I need to calculate the actual bandwidth after the stream has started without start another connection and generating an extra traffic.

I read your reply about it, but I’m not able to use **IOPerformanceCounter interface** like you suggested…

Is it possible have some indication or some reference how to implement it (server side and client side).

Thanks!

---

<div class="post-metadata">

**Author:** ![Ravi\_Ravishankar](https://avatars.discourse-cdn.com/v4/letter/r/d78d45/32.png) [@Ravi\_Ravishankar](https://community.wowza.com/u/Ravi_Ravishankar)\
**Post date:** [November 19, 2008, 1:39pm UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73/58 "2008-11-19T13:39:08Z")

</div>

For using the bandwidth checker module, the instruction (posted below) asks for the FLVPlayback module to be removed. I would like to know why this needs to be done?

thanks

maple01

Configuration:

Create a folder named [install-dir]/applications/bwcheck

Create a folder named [install-dir]/conf/bwcheck

Copy [install-dir]/conf/Application.xml into new bwcheck config folder

Edit copied Application.xml file and remove the module reference to ModuleFLVPlayback and add the module reference below as the last entry in the section (it is important that it is the last entry):

---

<div class="post-metadata">

**Author:** ![jason\_hummel](https://avatars.discourse-cdn.com/v4/letter/j/eada6e/32.png) [@jason\_hummel](https://community.wowza.com/u/jason_hummel)\
**Post date:** [September 17, 2008, 1:12pm UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73/59 "2008-09-17T13:12:32Z")

</div>

> A complete built version can be downloaded from [here](http://www.thru-tone-media-iptv.com/java/bwcheck.zip). Follow Charlie’s instructions at the top of the page to install.
> 
> Please let me know if there are any problems.
> 
> Roger.

This link is dead, can anyone help? Ive tried to compile it myself but im ignorant when it comes java. Thanks.

-jason

---

<div class="post-metadata">

**Author:** ![jason\_hummel](https://avatars.discourse-cdn.com/v4/letter/j/eada6e/32.png) [@jason\_hummel](https://community.wowza.com/u/jason_hummel)\
**Post date:** [September 17, 2008, 7:48pm UTC](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73/60 "2008-09-17T19:48:44Z")

</div>

thanks! you guys are top notch support - jason

[Previous page](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73.md?page=2)

[Next page](https://community.wowza.com/t/dynamic-bandwidth-detection-bwcheck/73.md?page=4)
