locked
Bandwidth detection RRS feed

  • Question

  • User606582925 posted

    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




    Friday, November 13, 2009 5:00 AM

Answers

  • User1566012831 posted

    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.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 15, 2009 1:01 AM

All replies

  • User-837620913 posted

    Or you could try JavaScript:

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

    Friday, November 13, 2009 8:08 AM
  • User606582925 posted

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

    Thanks

    MK



    Friday, November 13, 2009 10:03 AM
  • User1566012831 posted

    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.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 15, 2009 1:01 AM