Skip to Content.
Sympa Menu

ndt-dev - [ndt-dev] [ndt] r1089 committed - Merged Issue144Staging branch into trunk

Subject: NDT-DEV email list created

List archive

[ndt-dev] [ndt] r1089 committed - Merged Issue144Staging branch into trunk


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt-dev] [ndt] r1089 committed - Merged Issue144Staging branch into trunk
  • Date: Wed, 18 Jun 2014 07:06:26 +0000

Revision: 1089
Author:

Date: Wed Jun 18 07:06:05 2014 UTC
Log: Merged Issue144Staging branch into trunk

http://code.google.com/p/ndt/source/detail?r=1089

Modified:
/trunk
/trunk/flash-client/src/NDTPController.as
/trunk/flash-client/src/NDTUtils.as
/trunk/flash-client/src/TestC2S.as
/trunk/flash-client/src/TestMETA.as
/trunk/flash-client/src/TestS2C.as

=======================================
--- /trunk/flash-client/src/NDTPController.as Wed May 28 11:17:18 2014 UTC
+++ /trunk/flash-client/src/NDTPController.as Wed Jun 18 07:06:05 2014 UTC
@@ -23,6 +23,7 @@
import flash.system.Security;
import flash.utils.Timer;
import mx.resources.ResourceManager;
+ import flash.external.ExternalInterface;

/**
* This class creates (and closes) the Control socket with the server and
@@ -70,6 +71,13 @@
} else {
TestResults.clearResults();
}
+
+ var js_server_hostname:String = NDTUtils.hostnameFromJS();
+ if (js_server_hostname) {
+ Main.server_hostname = js_server_hostname;
+ _hostname = Main.server_hostname;
+ }
+
TestResults.recordStartTime();
TestResults.ndt_test_results::ndtTestFailed = false;
TestResults.ndt_test_results::ndtErrStatus = "Test in progress.";
=======================================
--- /trunk/flash-client/src/NDTUtils.as Wed Jun 18 06:12:24 2014 UTC
+++ /trunk/flash-client/src/NDTUtils.as Wed Jun 18 07:06:05 2014 UTC
@@ -59,6 +59,29 @@
}
}
}
+
+ /**
+ * Function that initializes the NDT server variable.
+ */
+ public static function hostnameFromJS():String {
+ try {
+ var js_server_hostname:String = ExternalInterface.call("getNDTServer");
+ if (js_server_hostname) {
+ TestResults.appendDebugMsg(
+ "Initialized server from JavaScript. Server hostname:"
+ + Main.server_hostname);
+ } else {
+ js_server_hostname = null;
+ }
+ return js_server_hostname;
+ } catch(e:Error) {
+ TestResults.appendDebugMsg("Failed to call getNDTServer(): "
+ + e.toString());
+ return null;
+ }
+ return null;
+ }
+
/**
* Function that reads the HTML parameter tags for the SWF file and
* initializes the variables in the SWF accordingly.
@@ -95,17 +118,9 @@
+ e.toString());
}

- try {
- var js_server_hostname:String = ExternalInterface.call("getNDTServer");
- if (js_server_hostname) {
- Main.server_hostname = js_server_hostname;
- TestResults.appendDebugMsg(
- "Initialized server from JavaScript. Server hostname:"
- + Main.server_hostname);
- }
- } catch(e:Error) {
- TestResults.appendDebugMsg("Failed to call getNDTServer(): "
- + e.toString());
+ var js_server_hostname:String = hostnameFromJS();
+ if (js_server_hostname) {
+ Main.server_hostname = js_server_hostname;
}

try {
=======================================
--- /trunk/flash-client/src/TestC2S.as Wed May 28 11:17:18 2014 UTC
+++ /trunk/flash-client/src/TestC2S.as Wed Jun 18 07:06:05 2014 UTC
@@ -35,13 +35,15 @@
// Valid values for _testStage.
private static const PREPARE_TEST1:int = 0;
private static const PREPARE_TEST2:int = 1;
- private static const START_TEST:int = 2;
- private static const SEND_DATA:int = 3;
- private static const COMPUTE_THROUGHPUT:int = 4;
- private static const COMPARE_SERVER1:int = 5;
- private static const COMPARE_SERVER2:int = 6;
- private static const FINALIZE_TEST:int = 7;
- private static const END_TEST:int = 8;
+ private static const START_TEST1:int = 2;
+ private static const START_TEST2:int = 3;
+ private static const SEND_DATA:int = 4;
+ private static const COMPUTE_THROUGHPUT:int = 5;
+ private static const COMPARE_SERVER1:int = 6;
+ private static const COMPARE_SERVER2:int = 7;
+ private static const FINALIZE_TEST1:int = 8;
+ private static const FINALIZE_TEST2:int = 9;
+ private static const END_TEST:int = 10;

private var _callerObj:NDTPController;
private var _c2sTestSuccess:Boolean;
@@ -111,13 +113,17 @@
break;
case PREPARE_TEST2: prepareTest2();
break;
- case START_TEST: startTest();
+ case START_TEST1: startTest1();
+ break;
+ case START_TEST2: startTest2();
break;
case COMPARE_SERVER1: compareWithServer1();
break;
case COMPARE_SERVER2: compareWithServer2();
break;
- case FINALIZE_TEST: finalizeTest();
+ case FINALIZE_TEST1: finalizeTest1();
+ break;
+ case FINALIZE_TEST2: finalizeTest2();
break;
case END_TEST: endTest();
break;
@@ -191,7 +197,7 @@
_speedUpdateTimer = new Timer(SPEED_UPDATE_TIMER);
_speedUpdateTimer.addEventListener(TimerEvent.TIMER, onSpeedUpdate);
_msg = new Message();
- _testStage = START_TEST;
+ _testStage = START_TEST1;
TestResults.appendDebugMsg("C2S test: START_TEST stage.");

if (_ctlSocket.bytesAvailable > 0)
@@ -199,7 +205,7 @@
// they trigger a single ProgressEvent.SOCKET_DATA event. In such case,
// it's necessary to explicitly call the following function to move to
// the next step.
- startTest();
+ startTest1();
}

private function addC2SSocketEventListeners():void {
@@ -246,8 +252,6 @@
}

private function onC2SProgress(e:OutputProgressEvent):void {
- if (_c2sSocket.bytesPending == 0)
- _c2sSendCount++;
if (_c2sSocket.connected) {
sendData();
} else {
@@ -272,12 +276,21 @@
/ _c2sTestDuration);
}

- private function startTest():void {
+ private function startTest1():void {
if (!_msg.readHeader(_ctlSocket))
return;
+ _testStage = START_TEST2;
+ if (_ctlSocket.bytesAvailable > 0)
+ // In case header and body have arrive together at the client, they
+ // trigger a single ProgressEvent.SOCKET_DATA event. In such case,
+ // it's necessary to explicitly call the following function to move to
+ // the next step.
+ startTest2();
+ }
+
+ private function startTest2():void {
if (!_msg.readBody(_ctlSocket, _msg.length))
return;
-
if (_msg.type != MessageType.TEST_START) {
TestResults.appendErrMsg(ResourceManager.getInstance().getString(
NDTConstants.BUNDLE_NAME, "outboundWrongMessage", null,
@@ -311,6 +324,7 @@
*/
private function sendData():void {
_c2sSocket.writeBytes(_dataToSend, 0, _dataToSend.length);
+ _c2sSendCount++;
_c2sSocket.flush();
}

@@ -343,6 +357,7 @@

private function calculateThroughput():void {
TestResults.appendDebugMsg("C2S test: COMPUTE_THROUGHPUT stage.");
+ TestResults.appendDebugMsg("C2S test: _c2sBytesNotSent: " + _c2sBytesNotSent);

var c2sByteSent:Number = (
_c2sSendCount * NDTConstants.PREDEFINED_BUFFER_SIZE
@@ -422,19 +437,29 @@
+ sc2sSpeed.toFixed(2) + " kbps");

_msg = new Message();
- _testStage = FINALIZE_TEST;
+ _testStage = FINALIZE_TEST1;
TestResults.appendDebugMsg("C2S test: FINALIZE_TEST stage.");
if(_ctlSocket.bytesAvailable > 0)
// If COMPARE_SERVER and TEST_FINALIZE messages arrive together at the
// client, they trigger a single ProgressEvent.SOCKET_DATA event. In
// such case, it's necessary to explicitly call the following function
// to move to the next step.
- finalizeTest();
+ finalizeTest1();
}

- private function finalizeTest():void {
+ private function finalizeTest1():void {
if (!_msg.readHeader(_ctlSocket))
return;
+ _testStage = FINALIZE_TEST2;
+ if (_ctlSocket.bytesAvailable > 0)
+ // In case header and body have arrive together at the client, they
+ // trigger a single ProgressEvent.SOCKET_DATA event. In such case,
+ // it's necessary to explicitly call the following function to move to
+ // the next step.
+ finalizeTest2();
+ }
+
+ private function finalizeTest2():void {
if (!_msg.readBody(_ctlSocket, _msg.length))
return;

=======================================
--- /trunk/flash-client/src/TestMETA.as Wed May 28 11:17:18 2014 UTC
+++ /trunk/flash-client/src/TestMETA.as Wed Jun 18 07:06:05 2014 UTC
@@ -27,10 +27,12 @@
// Valid values for _testStage.
private static const PREPARE_TEST1:int = 0;
private static const PREPARE_TEST2:int = 1;
- private static const START_TEST:int = 2;
- private static const SEND_DATA:int = 3;
- private static const FINALIZE_TEST:int = 4;
- private static const END_TEST:int = 5;
+ private static const START_TEST1:int = 2;
+ private static const START_TEST2:int = 3;
+ private static const SEND_DATA:int = 4;
+ private static const FINALIZE_TEST1:int = 5;
+ private static const FINALIZE_TEST2:int = 6;
+ private static const END_TEST:int = 7;

private var _callerObj:NDTPController;
private var _ctlSocket:Socket;
@@ -86,9 +88,13 @@
break;
case PREPARE_TEST2: prepareTest2();
break;
- case START_TEST: startTest();
+ case START_TEST1: startTest1();
break;
- case FINALIZE_TEST: finalizeTest();
+ case START_TEST2: startTest2();
+ break;
+ case FINALIZE_TEST1:finalizeTest1();
+ break;
+ case FINALIZE_TEST2:finalizeTest2();
break;
case END_TEST: endTest();
break;
@@ -129,7 +135,7 @@
}

_msg = new Message();
- _testStage = START_TEST;
+ _testStage = START_TEST1;
TestResults.appendDebugMsg("META test: START_TEST stage.");

if (_ctlSocket.bytesAvailable > 0)
@@ -137,12 +143,22 @@
// they trigger a single ProgressEvent.SOCKET_DATA event. In such case,
// it's necessary to explicitly call the following function to move to
// the next step.
- startTest();
+ startTest1();
}

- private function startTest():void {
+ private function startTest1():void {
if (!_msg.readHeader(_ctlSocket))
return;
+ _testStage = START_TEST2;
+ if (_ctlSocket.bytesAvailable > 0)
+ // In case header and body have arrive together at the client, they
+ // trigger a single ProgressEvent.SOCKET_DATA event. In such case,
+ // it's necessary to explicitly call the following function to move to
+ // the next step.
+ startTest2();
+ }
+
+ private function startTest2():void {
if (!_msg.readBody(_ctlSocket, _msg.length))
return;

@@ -224,17 +240,29 @@
return;
}

- _testStage = FINALIZE_TEST;
+ _msg = new Message();
+ _testStage = FINALIZE_TEST1;
TestResults.appendDebugMsg("META test: FINALIZE_TEST stage.");
// The following check is probably not necessary. Added anyway, in case
// the TEST_FINALIZE message does not trigger onReceivedData.
if (_ctlSocket.bytesAvailable > 0)
- finalizeTest();
+ finalizeTest1();
}

- private function finalizeTest():void {
+ private function finalizeTest1():void {
if (!_msg.readHeader(_ctlSocket))
return;
+ _testStage = FINALIZE_TEST2;
+ if (_ctlSocket.bytesAvailable > 0)
+ // In case header and body have arrive together at the client, they
+ // trigger a single ProgressEvent.SOCKET_DATA event. In such case,
+ // it's necessary to explicitly call the following function to move to
+ // the next step.
+ finalizeTest2();
+ }
+
+
+ private function finalizeTest2():void {
if (!_msg.readBody(_ctlSocket, _msg.length))
return;

=======================================
--- /trunk/flash-client/src/TestS2C.as Wed Jun 18 06:40:42 2014 UTC
+++ /trunk/flash-client/src/TestS2C.as Wed Jun 18 07:06:05 2014 UTC
@@ -36,14 +36,15 @@
// Valid values for _testStage.
private static const PREPARE_TEST1:int = 0;
private static const PREPARE_TEST2:int = 1;
- private static const START_TEST:int = 2;
- private static const RECEIVE_DATA:int = 3;
- private static const COMPARE_SERVER1:int = 4;
- private static const COMPARE_SERVER2:int = 5;
- private static const COMPUTE_THROUGHPUT:int = 6;
- private static const GET_WEB1001:int = 7;
- private static const GET_WEB1002:int = 8;
- private static const END_TEST:int = 9;
+ private static const START_TEST1:int = 2;
+ private static const START_TEST2:int = 3;
+ private static const RECEIVE_DATA:int = 4;
+ private static const COMPARE_SERVER1:int = 5;
+ private static const COMPARE_SERVER2:int = 6;
+ private static const COMPUTE_THROUGHPUT:int = 7;
+ private static const GET_WEB1001:int = 8;
+ private static const GET_WEB1002:int = 9;
+ private static const END_TEST:int = 10;
private static const THROUGHPUT_VALUE:String = "ThroughputValue";
private static const UNSENT_DATA_AMOUNT:String = "UnsentDataAmount";
private static const TOTAL_SENT_BYTE:String = "TotalSentByte";
@@ -115,7 +116,9 @@
break;
case PREPARE_TEST2: prepareTest2();
break;
- case START_TEST: startTest();
+ case START_TEST1: startTest1();
+ break;
+ case START_TEST2: startTest2();
break;
case COMPARE_SERVER1: compareWithServer1();
break;
@@ -191,7 +194,7 @@
_s2cTimer = new Timer(NDTConstants.S2C_DURATION);
_s2cTimer.addEventListener(TimerEvent.TIMER, onS2CTimeout);
_msg = new Message();
- _testStage = START_TEST;
+ _testStage = START_TEST1;
TestResults.appendDebugMsg("S2C test: START_TEST stage.");

if (_ctlSocket.bytesAvailable > 0)
@@ -199,7 +202,7 @@
// they trigger a single ProgressEvent.SOCKET_DATA event. In such case,
// it's necessary to explicitly call the following function to move to
// the next step.
- startTest();
+ startTest1();
}

private function addS2CSocketEventListeners():void {
@@ -208,7 +211,6 @@
_s2cSocket.addEventListener(IOErrorEvent.IO_ERROR, onS2CError);
_s2cSocket.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
onS2CSecError);
- _s2cSocket.addEventListener(ProgressEvent.SOCKET_DATA, onS2CReceivedData);
}

private function removeS2CSocketEventListeners():void {
@@ -217,8 +219,6 @@
_s2cSocket.removeEventListener(IOErrorEvent.IO_ERROR, onS2CError);
_s2cSocket.removeEventListener(SecurityErrorEvent.SECURITY_ERROR,
onS2CSecError);
- _s2cSocket.removeEventListener(ProgressEvent.SOCKET_DATA,
- onS2CReceivedData);
}

private function onS2CConnect(e:Event):void {
@@ -243,24 +243,28 @@
closeS2CSocket();
endTest();
}
-
- private function onS2CReceivedData(e:ProgressEvent):void {
- _readTimer.stop();
- _readTimer.reset();
- _readTimer.start();
- receiveData();
- }

private function onSpeedUpdate(e:TimerEvent):void {
+ _s2cByteCount = _s2cSocket.bytesAvailable;
_s2cTestDuration = getTimer() - _s2cTestStartTime;
TestResults.ndt_test_results::s2cSpeed = _s2cByteCount
* NDTConstants.BYTES2BITS
/ _s2cTestDuration;
}

- private function startTest():void {
+ private function startTest1():void {
if (!_msg.readHeader(_ctlSocket))
return;
+ _testStage = START_TEST2;
+ if (_ctlSocket.bytesAvailable > 0)
+ // In case header and body have arrive together at the client, they
+ // trigger a single ProgressEvent.SOCKET_DATA event. In such case,
+ // it's necessary to explicitly call the following function to move to
+ // the next step.
+ startTest2();
+ }
+
+ private function startTest2():void {
if (!_msg.readBody(_ctlSocket, _msg.length))
return;

@@ -289,27 +293,12 @@

_testStage = RECEIVE_DATA;
TestResults.appendDebugMsg("S2C test: RECEIVE_DATA stage.");
- if (_s2cSocket.bytesAvailable > 0)
- receiveData();
}

private function onS2CTimeout(e:TimerEvent):void {
TestResults.appendDebugMsg("Timeout for receiving data on S2C socket.");
closeS2CSocket();
}
-
- /**
- * Function that is called repeatedly by the S2C socket response listener
- * for the duration of the test. It processes and keeps track of the total
- * bytes received from the server. The test only goes past this stage if:
- * 1. All data was successfully received and the server closed the socket.
- * 2. A read timeout occured on S2C socket.
- * 3. More than NDTConstants.S2C_DURATION seconds have passed since the
- * beginning of the test.
- */
- private function receiveData():void {
- _s2cByteCount += NDTUtils.readAllBytesAndDiscard(_s2cSocket);
- }

private function closeS2CSocket():void {
// Record end time right after it stops receiving data, to be as accurate
@@ -324,8 +313,7 @@
_readTimer.removeEventListener(TimerEvent.TIMER, onS2CTimeout);
_s2cTimer.removeEventListener(TimerEvent.TIMER, onS2CTimeout);

- if (_s2cSocket.connected)
- _s2cByteCount += _s2cSocket.bytesAvailable;
+ _s2cByteCount = _s2cSocket.bytesAvailable;

removeCtlSocketOnReceivedDataListener();
try {


  • [ndt-dev] [ndt] r1089 committed - Merged Issue144Staging branch into trunk, ndt, 06/18/2014

Archive powered by MHonArc 2.6.16.

Top of Page