Bandwidth detection

Last post 11-15-2009 1:01 AM by RickNZ. 3 replies.

Sort Posts:

  • Bandwidth detection

    11-13-2009, 5:00 AM
    • Member
      80 point Member
    • kruvi
    • Member since 07-22-2004, 12:43 PM
    • Posts 26

    Hi,

    I'm trying to detect clien't bandwidth, with the following limitations:

    1. No client-side programming (=>can't download an image for instance and once loaded redirect sending elapsed time).

    2. Process should be totally seamless to client.


    I came up with the following method:

    1. I added a hidden image to my ASPX page.

    2. Image SRC is set to an ASHX handler.

    3. Handler reads a file of known size into buffer and sends it to client using context.Response.BinaryWrite(buffer), while timing delivery time (DateTime.Now before and after).

    4. Calculated bandwidth (filesize/delivery time) is saved in session variable for future usage.


    In my handler code I have set OutputBuffering to False, so content is delivered 'progressively' without buffering.


    Will this method give me the actual download time for that file?

    What would be the best delivery methos for achieving this (response.Write/response.transmitFile, etc.)?


    Thanks

    MK




  • Re: Bandwidth detection

    11-13-2009, 8:08 AM
    • All-Star
      54,996 point All-Star
    • DarrellNorton
    • Member since 04-04-2003, 3:49 PM
    • VA, USA
    • Posts 6,621
    • Moderator

    Or you could try JavaScript:

    http://forums.asp.net/p/1186366/2027381.aspx

    Darrell Norton, MVP
    Darrell Norton's Blog


    Please mark this post as answered if it helped you!
  • Re: Bandwidth detection

    11-13-2009, 10:03 AM
    • Member
      80 point Member
    • kruvi
    • Member since 07-22-2004, 12:43 PM
    • Posts 26

    Ye well, I'm targeting mobile devices, so as I mentioned - no JS...

    Thanks

    MK



  • Re: Bandwidth detection

    11-15-2009, 1:01 AM
    Answer
    • Contributor
      5,226 point Contributor
    • RickNZ
    • Member since 01-01-2009, 8:43 AM
    • Nelson, New Zealand
    • Posts 872

    I'm pretty sure that using an unbuffered write won't impact the timing measurements, but it will put more load on the server.  You should be able to accomplish the same thing by doing a buffered write, followed by Response.Flush().  I think the Flush() won't return until the client has received the written data.  You could use a tool like WireShark to monitor the TCP connection, and then compare your measurements to the actual times.

    One thing to be careful of, though, is that some browsers can request more than one object at a time.  For example, if a page has two images, the browser might request both of them at the same time.  You can get around that by having a page that only has one downloadable object on it.

    Also, make sure that your image doesn't have output caching or browser caching enabled....

    Another approach that might be better would be to have an HttpModule that you register to handle events from all files, including static files (with the Integrated IIS pipeline).  Then, look at the incoming URLs from both the pre-request and post-request events, and make your measurements there, instead.

Page 1 of 1 (4 items)