0

I'm trying to build a simple latency meter using sockets in as3. It works ok in Windows and in Chrome on both Linux and OS X, when using Chromes Flash player. But when I use Adobes Flash player on Linux or OS X the results is quite bad.

My setup, client side, is a 1 Gbit/s internet connection throttle by a 100 Mbit/s switch. On the server side, I have an Apache web server on a 1 Gbit/s internet connection.

I download a small txt-file, measuring the time between just after we send http-request and until I receive an answer from the web server. When measuring response time, using a packet analyzer, I have average of 1 ms, so that the baseline.

All tests are preformed on version 11.6.602.180 except for Adobe Flash player on Ubuntu were the 11.2 r202 version. Adobe Flash player on Firefox 19.0.2 (other browsers were tested with similar results) and Google Flash player on Chrome 26.0.1410.43. The operating systems were Windows 7 Enterprise (64-bit), Mac OS X 10.6.8 (64 bit) and Ubuntu 12.10 (64 bit). Each OS/player was tested 5 * 20 times.

Windows Adobe avg. 4.30 ms
Windows Chrome avg. 4.25 ms
OS X Adobe 66.67 ms
OS X Chrome 4.28 ms
Ubuntu Adobe 10.49 ms
Ubuntu Chrome 4.19 ms

doConnect();

private function doConnect():void{
    socket = new Socket(url,port);
    socket.addEventListener(Event.CONNECT, connectHandler);
    socket.addEventListener(ProgressEvent.SOCKET_DATA, socketDataHandler);
}
private function connectHandler(event:Event):void{
    writeln("GET " + path + " HTTP/1.1");
    writeln("Host: " + url);
    socket.flush();
    nStart = new Date().time;

}
private function writeln(str:String):void{
    str +=  "\n";
    socket.writeUTFBytes(str);
}
private function socketDataHandler(event:ProgressEvent):void{
    var latecy:Number = new Date().time - nStart; // latency in ms
}

Any ideas to get around this problem?

6
  • This test is invalid since ProgressEvent.SOCKET_DATA will only trigger when the buffer gets full. Well a few other things will trigger it but this is the notable one.
    – The_asMan
    Apr 4, 2013 at 15:47
  • Is there a list triggers for ProgressEvent.SOCKET_DATA? I can only find "Dispatched when a socket has received data" in Adobes reference guide and I can't find a list using Google. Apr 8, 2013 at 11:50
  • It is more in the way of knowing how sockets work then finding the actual "list". socket_write() does not necessarily write all bytes from the given buffer. It's valid that, depending on the network buffers etc., only a certain amount of data, even one byte, is written though your buffer is greater. You have to watch out so you don't unintentionally forget to transmit the rest of your data. php.net/manual/en/function.socket-write.php
    – The_asMan
    Apr 8, 2013 at 13:19
  • My big questions is why, with Chromes version of flash, the event triggers within 3 ms on all OS, but Adobes trigger after 3 ms on Windows, 7 ms on Linux (older version of Flash) and 64 ms on Mac. Apr 8, 2013 at 15:11
  • The key element you are not understanding is that even-though your code is the same, the platform is different and socket connections use the platform (IE: the network card and os) to connect to the server. This means that no matter what code you write you are still slave to the platform.
    – The_asMan
    Apr 8, 2013 at 15:38

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.