• How to test server-to-client bandwidth for RTMP clients

    This article describes how to use a bandwidth checker provided by forum contributor Roger. It is a Wowza Media Server/Java version of the bandwidth checker:

    To install the BWCheck package


    1. Download BWChecker.zip and extract the contents from the compressed (zipped) folder.
    2. Copy the lib/wms-plugin-bwcheck.jar file in the package to the [install-dir]/lib folder.
    3. If Wowza Media Server® is running, restart the server.


    To configure the bandwidth checker on the server


    1. Create a folder named [install-dir]/applications/bwcheck.
    2. Create a folder named [install-dir]/conf/bwcheck.
    3. Copy the [install-dir]/conf/Application.xml file to the new [install-dir]/conf/bwcheck folder.
    4. Open the [install-dir]/conf/bwcheck/Application.xml file in a text editor and either remove or comment-out the flvplayback module reference:
      Code:
      <!--Remove or comment-out this section.-->
      <Module>
      	<Name>flvplayback</Name>
      	<Description>FLVPlayback</Description>
      	<Class>com.wowza.wms.module.ModuleFLVPlayback</Class>
      </Module>
    5. Add the following module reference as the last entry in the <Modules> section (it is important that it be the last entry):
      Code:
      <Module>
      	<Name>BWCheck</Name>
      	<Description>BWCheck</Description>
      	<Class>com.wowza.wms.plugin.bwcheck.ModuleBWCheck2</Class>
      </Module>

    Note: The ModuleBWCheck2 module source code is included in the src folder that you extracted from the BWChecker.zip file.

    To configure bandwidth checker clients


    Copy the client folder that you extracted from the BWChecker.zip file to a client computer. The client folder contains the following renditions of the bandwidth checker client:

    bwchecker.html

    This is an interactive tool that tests server-to-client bandwidth every 5 seconds.

    1. Install the bandwidth checker client:
      • On Windows® operating systems, right-click install.bat, and then select Run as administrator.
      • On Linux® operating systems, run ./install.sh.
      • On Mac OS® X, run ./install.command in a terminal window.
    2. Open the bwchecker.html file in a web browser and update the Server field with the IP address of the remote Wowza Media Server that you configured in the previous section (for example, rtmp://[wowza-ip-address]/bwcheck).
    3. Click Start.

    The sample application will return the download speed and latency value between the remote Wowza Media Server and your local browser approximately once every 5 seconds.

    bwcheck.fla
    This is an example of how you might call the bandwidth checker on the server from your Adobe® Flash® client application. You can integrate the example code in this file into your Flash-based player to test bandwidth before playing a media stream. When the bandwidth checker is done, it will call onBWDone with the calculated bandwidth in kilobits-per-second (kbps).



    Comments 29 Comments
    1. skookie -
      Should the "code" example have the #2 at the end of "com.wowza.wms.plugin.bwcheck.ModuleBWCheck2" ?
    1. rrlanham -
      That's the name of the module. If you are building it yourself in the Wowza IDE, you can use any name.

      Richard
    1. GraemeBull -
      The link at the top of the article doesn't exist anymore on Adobe's site. Needs updating.
    1. charlie -
      I fixed it. Thanks for the head up.

      Charlie
    1. GraemeBull -
      Working with this, I sometimes get numbers as high as 190Mbps. Is this algorithm reliable? I've had good experiences with it but a client of mine swore that he could never ever get anything consistent. I put something together that showed him it was reliable but that was very short lived. Now I've got huge inconsistencies:

      Mbps: 4.98
      Mbps: 1.74
      Mbps: 1.57
      Mbps: 190.35
      Mbps: 190.35
      Mbps: 1.74
      Mbps: 1.74
      Mbps: 1.74
      Mbps: 190.35
      Mbps: 40.07
      Mbps: 3.43

      I can barely get an average out of that.. Any advice here?
    1. shamrock -
      like any bandwidth checker there are *many* factors that can effect the result the primary one with Flash is CPU, and even a short lived spike can have a massive detremental effect on the overall result.

      I have done quite a bit of testing and the main three factors I have found are ( in this order)

      i) CPU on the client machine
      ii) How busy the server is and how much CPU it is chewing up
      iii) Actual available bandwidth

      Shamrock
    1. charlie -
      We don't have a great answer. The dynamic streaming options seems like a better way to go since they are monitoring constantly during the streaming process. Trying to do it in a short burst before streaming starts is just tough to do. The shorter the test the less accurate the results. The longer the test the more accurate but more annoying. We do provide the source code so you can have a go at it to see if there is a better way that fits your needs.

      Charlie
    1. rogerlittin -
      The main problem with using a bandwidth checker with flash is the latency. Flash uses a polling mechanism for checking NetConnection calls which on average takes about 15ms to loop which means that the latency reported will be at least multiples of this. If your real latency is less than this then it will give inaccurate results. It could be possible if the packet size that is used for the test is too small that the test loop will be complete in less time than the reported latency so the result would be calculated as taking very little time for the packet to be sent giving the very high results. Using a larger packet size will overcome this but you run the risk of the test taking a long time to complete for low bandwidth clients.

      Removing the latency calculations from the result and sending larger packets should give more consistent results.
    1. GraemeBull -
      Funniest thing though is that the latency isn't the issue here. It always came in at around 70ms or so. It's the packets coming back too fast? or something that causes the output to be 190Mbps! That's not even right.

      I'll try to play with the java file, recompile and see what I can come up with. In our case it's ok if it takes a few seconds. In fact, I'm running the check 10 times and grabbing the average of the middle 6 (discarding the 2 lowest and 2 highest thinking that they are probably anomalies). I'm not sure how I'd remove the latency calculations but I'll take a look and if I have any more questions then I'll post back. Thanks for the insight and help so far.
    1. clegault -
      Can someone explain what the output means? For example:


      onBWDone: kbitDown:720 deltaDown:259.888 deltaTime:0.361 latency:241

      I presume kbitDown is my download speed from the server to the client
      deltaDown: ?? Is this the difference of upload vs download ?
      deltaTime: ?? Is this how long it took for packets to traverse?
      latency: this one is clear.

      thanks!
    1. rrlanham -
      You can see in the source at top:

      Code:
      // tidy up
      // and compute bandwidth
      deltaDown = (double) ((totalStats.getMessagesOutBytes() - bytesOutStart) * 8) / 1000; // bytes
      // to
      // kbits
      deltaTime = (double) ((now - start) - (latency * cumLatency)) / 1000;
      However, I don't know what, or if there is any, practical use for those numbers in the client. kbitDown is the useful number.

      If you have content that is properly key frame aligned, it is preferable, and possibly easier, to implement multi-bitrate streaming, for example using Flash Dynamic Streaming. JW player does it with easy configuration:
      http://www.longtailvideo.com/support...rate-switching

      MS Expression Encoder is a good encoder for this purpose if you are doing vod:
      http://www.wowzamedia.com/forums/con...ideo-on-Demand

      Richard
    1. clegault -
      Thanks for the quick reply! I must have glossed over that in the source. I am actually trying to do live stream and determine necessary BW in both directions. I am currently capturing this now in the client, and it seems to be OK. However the video stream seems to be choking the audio stream causing the RTMP connection to just drop suddenly with almost no warning. :-/ I am trying to see if there is a way to dynamically set the BW lower for the live video stream in order to maintain the connection.
    1. rrlanham -
      BWCheck is not related to dynamic streaming.... maybe some implementations blended BWCheck with dynamic streaming, like JW player, but they're not doing that currently. This Module runs and the data is returned following the NetConnection.connect, before streaming starts.

      For this to do anything, you have to develop your own system of naming convention, and use that kbitDown number to choose which media file to stream. You would process this in the player, using the result in the NetStream.play command.

      Code:
      var streamName:String="mp4:sample.mp4";
      			
      if (kbitDown>=500)
      {
      	streamName="mp4:sample_500.mp4";
      }
      netstream.play(streamName);
      If each version is properly key frame aligned, or you are willing to encode them for key frame alignment, is easier to do true dynamic streaming.

      You can use this method:
      http://www.longtailvideo.com/support...amic-streaming

      See this post for encoding suggestions for key frame alignment:
      http://www.wowzamedia.com/forums/con...ideo-on-Demand

      If you do dynamic streaming, you can implement it through player configuration and not have to modify actionscript, and the switching can happen as necessary throughout a Flash streaming session. And you can use the same files for multi-bitrate streaming with iOS devices, Silverlight and Flash HTTP, each of which are covered in the Wowza tutorials.

      Richard
    1. Chabalab -
      Could not run the examples from BWChecker CtoSBWCheck.html and bwcheck.html. Do you have a flex version of these (as3 and flex 4).
      The CtoSBWCheck could be very useful when making live session and want use the best upload param

      some answer
      http://www.wowzamedia.com/forums/sho...Check%29/page9
    1. Inspiring -
      Quote Originally Posted by GraemeBull View Post
      Working with this, I sometimes get numbers as high as 190Mbps. Is this algorithm reliable? I've had good experiences with it but a client of mine swore that he could never ever get anything consistent. I put something together that showed him it was reliable but that was very short lived. Now I've got huge inconsistencies:

      Mbps: 4.98
      Mbps: 1.74
      Mbps: 1.57
      Mbps: 190.35
      Mbps: 190.35
      Mbps: 1.74
      Mbps: 1.74
      Mbps: 1.74
      Mbps: 190.35
      Mbps: 40.07
      Mbps: 3.43

      I can barely get an average out of that.. Any advice here?
      We are experiencing the same problems using Wowza 2 Server. However, the BWDetect works correctly with our Wowza 1.7.0 - Does anybody have an updated script for Wowza 2?
    1. charlie -
      The source code is included. You can certainly play around with how the numbers are calculated. There are no updates that I know of.

      Charlie
    1. smaddock -
      Does bwcheck need to be it's own application that is used solely for bandwidth checking? Or is it okay to be the same app as a live or vod stream?

      -shawn
    1. rrlanham -
      You could add the module to a vod application (StreamType "default"). Remember to replace the ModuleFLVPlayback. I don't think it will work in a live app

      Richard
    1. sdbhabal -
      Hello Experts, I have installed Wowza Media Server 3 trial period on my centos 5.7 I have configured Dynamic Bandwidth Detection (BWCheck) as per above instruction. I am done till configuration changes in Application.xml I dont know what to do next? how do i check my bandwidth usage of streams. Please guide. Regards Santosh
    1. rrlanham -
      You need multiple versions of a video or live stream each with a different bitrate to make using the BWCheck technique useful. If you need hands-on help and are able to hire someone, write to support@wowza.com and request the list of independent consultants.

      For vod streaming, take a look at the encoding suggestions:
      http://www.wowza.com/forums/content....ideo-on-Demand

      For live streaming, you will have to setup multiple streams in your live encoder, or use the Wowza Transcoder:
      http://www.wowza.com/forums/content....wza-Transcoder

      If you use Transcoder or encode your videos using Expression 4 encoder, you can do multi-bitrate streaming, as a much better technique than using BWCheck. Each of the tutorials covers multi-bitrate streaming with server-side smil for Cupertino (iOS), San Jose (Flash HTTP) and Smooth (Silverlight) streaming:
      http://www.wowza.com/forums/content.php?4

      For Flash RTMP multi-bitrate streaming, JW Player has a good implentation of Dynamic Streaming:
      http://www.longtailvideo.com/support...amic-streaming

      Richard