Skip to Content.
Sympa Menu

ndt-dev - [ndt-dev] [ndt] r1059 committed - added json-smart library to svn, added descriptions of new functions, ...

Subject: NDT-DEV email list created

List archive

[ndt-dev] [ndt] r1059 committed - added json-smart library to svn, added descriptions of new functions, ...


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt-dev] [ndt] r1059 committed - added json-smart library to svn, added descriptions of new functions, ...
  • Date: Tue, 27 May 2014 14:19:55 +0000

Revision: 1059
Author:

Date: Tue May 27 14:19:34 2014 UTC
Log: added json-smart library to svn, added descriptions of new functions, unified formatting (tab instead of space)
http://code.google.com/p/ndt/source/detail?r=1059

Added:
/branches/Issue146/Applet/src/edu/internet2/ndt/lib
/branches/Issue146/Applet/src/edu/internet2/ndt/lib/json-smart-1.1.1.jar
Modified:
/branches/Issue146/Applet/src/edu/internet2/ndt/JSONUtils.java
/branches/Issue146/Applet/src/edu/internet2/ndt/Protocol.java
/branches/Issue146/Applet/src/edu/internet2/ndt/Tcpbw100.java

=======================================
--- /dev/null
+++ /branches/Issue146/Applet/src/edu/internet2/ndt/lib/json-smart-1.1.1.jar Tue May 27 14:19:34 2014 UTC
Binary file, no diff available.
=======================================
--- /branches/Issue146/Applet/src/edu/internet2/ndt/JSONUtils.java Wed May 21 09:09:42 2014 UTC
+++ /branches/Issue146/Applet/src/edu/internet2/ndt/JSONUtils.java Tue May 27 14:19:34 2014 UTC
@@ -6,42 +6,64 @@
import java.util.Map;

/**
- * Created by sebastian on 13.05.14.
+ * Created by Sebastian Malecki on 13.05.14.
*/
public class JSONUtils {
- public static final int JSON_SINGLE_VALUE = 1;
- public static final int JSON_MULTIPLE_VALUES = 2;
- public static final int JSON_KEY_VALUE_PAIRS = 3;

- public static String getSingleMessage(String jsonTxt) {
- return getValueFromJsonObj(jsonTxt, "msg");
- }
+ /**
+ * Function that return value from json object represented by jsontext containing a single message
+ * which is assigned to "msg" key.
+ * @param {String} JSON object
+ * @return {int} obtained value from JSON object
+ */
+ public static String getSingleMessage(String jsonTxt) {
+ return getValueFromJsonObj(jsonTxt, "msg");
+ }

- public static String getValueFromJsonObj(String jsonTxt, String key) {
- JSONValue jsonParser = new JSONValue();
- Map json = (Map)jsonParser.parse(new String(jsonTxt));
- Iterator iter = json.entrySet().iterator();
- while(iter.hasNext()){
- Map.Entry entry = (Map.Entry)iter.next();
- if (entry.getKey().equals(key)) {
- return entry.getValue().toString();
- }
- }
- return null;
- }
+ /**
+ * Function that return value for given key from json object represented by jsontext
+ * @param {String} JSON object
+ * @param {int} key by which value should be obtained from JSON map
+ * @return {int} obtained value from JSON map
+ */
+ public static String getValueFromJsonObj(String jsonTxt, String key) {
+ JSONValue jsonParser = new JSONValue();
+ Map json = (Map)jsonParser.parse(new String(jsonTxt));
+ Iterator iter = json.entrySet().iterator();
+ while(iter.hasNext()){
+ Map.Entry entry = (Map.Entry)iter.next();
+ if (entry.getKey().equals(key)) {
+ return entry.getValue().toString();
+ }
+ }
+ return null;
+ }

- public static String addValueToJsonObj(String jsonTxt, String key, String value) {
- JSONValue jsonParser = new JSONValue();
- JSONObject json = (JSONObject)jsonParser.parse(new String(jsonTxt));
- json.put(key, value);
+ /**
+ * Function that add new value to JSON map
+ * @param {String} JSON object
+ * @param {String} key by which value should be assigned to JSON map
+ * @param {String} value for given key
+ * @return {String} json object with added value.
+ */
+ public static String addValueToJsonObj(String jsonTxt, String key, String value) {
+ JSONValue jsonParser = new JSONValue();
+ JSONObject json = (JSONObject)jsonParser.parse(new
String(jsonTxt));
+ json.put(key, value);

- return json.toJSONString();
- }
+ return json.toJSONString();
+ }

- public static byte[] createJsonObj(byte[] msg) {
- JSONObject obj = new JSONObject();
- obj.put("msg", new String(msg));
+ /**
+ * Function that return json object represented by jsontext and
included
+ * single message assigned to "msg" key
+ * @param {byte[]} message which should be assigned to json object
+ * @return {byte[]} json object represented by jsontext and encodes into a sequence of bytes
+ */
+ public static byte[] createJsonObj(byte[] msg) {
+ JSONObject obj = new JSONObject();
+ obj.put("msg", new String(msg));

- return obj.toJSONString().getBytes();
- }
+ return obj.toJSONString().getBytes();
+ }
}
=======================================
--- /branches/Issue146/Applet/src/edu/internet2/ndt/Protocol.java Wed May 21 09:09:42 2014 UTC
+++ /branches/Issue146/Applet/src/edu/internet2/ndt/Protocol.java Tue May 27 14:19:34 2014 UTC
@@ -14,7 +14,7 @@
public class Protocol {
private InputStream _ctlInStream;
private OutputStream _ctlOutStream;
- private boolean jsonSupport = true;
+ private boolean jsonSupport = true;

/**
* Constructor that accepts socket over which to communicate as
parameter
@@ -46,42 +46,41 @@
send_msg(bParamType, tab);
}

- /**
- * Send message given its Type and data byte
- *
- * @param bParamType
- * Control Message Type
- * @param bParamToSend
- * Data value to send
- * @throws IOException
- * If data cannot be successfully written to the Output Stream
- *
- * */
- public void send_json_msg(byte bParamType, byte bParamToSend) throws IOException {
- byte[] tab = new byte[] { bParamToSend };
- send_json_msg(bParamType, tab);
- }
+ /**
+ * Send message given its Type and data byte
+ *
+ * @param bParamType
+ * Control Message Type
+ * @param bParamToSend
+ * Data value to send
+ * @throws IOException
+ * If data cannot be successfully written to the Output
Stream
+ *
+ * */
+ public void send_json_msg(byte bParamType, byte bParamToSend) throws IOException {
+ byte[] tab = new byte[] { bParamToSend };
+ send_json_msg(bParamType, tab);
+ }

- /**
- * Send protocol messages given their type and data byte array
- *
- * @param bParamType
- * Control Message Type
- * @param bParamToSend
- * Data value array to send
- * @throws IOException
- * If data cannot be successfully written to the Output Stream
- *
- * */
- public void send_json_msg(byte bParamType, byte[] bParamToSend)
- throws IOException {
- if (jsonSupport) {
- send_msg(bParamType, JSONUtils.createJsonObj(bParamToSend));
- } else {
- send_msg(bParamType, bParamToSend);
- }
-
- }
+ /**
+ * Send protocol messages given their type and data byte array
+ *
+ * @param bParamType
+ * Control Message Type
+ * @param bParamToSend
+ * Data value array to send
+ * @throws IOException
+ * If data cannot be successfully written to the Output
Stream
+ *
+ * */
+ public void send_json_msg(byte bParamType, byte[] bParamToSend)
+ throws IOException {
+ if (jsonSupport) {
+ send_msg(bParamType,
JSONUtils.createJsonObj(bParamToSend));
+ } else {
+ send_msg(bParamType, bParamToSend);
+ }
+ }

/**
* Send protocol messages given their type and data byte array
@@ -171,7 +170,7 @@
length += (int) yaMsgBody[2] & 0xFF;

if (readn(msgParam, length) != length) {
- return 3;
+ return 3;
}
return 0;
}
@@ -188,8 +187,8 @@
}
}

- public void setJsonSupport(boolean jsonSupport) {
- this.jsonSupport = jsonSupport;
- }
+ public void setJsonSupport(boolean jsonSupport) {
+ this.jsonSupport = jsonSupport;
+ }

} // end class Protocol
=======================================
--- /branches/Issue146/Applet/src/edu/internet2/ndt/Tcpbw100.java Wed May 21 09:09:42 2014 UTC
+++ /branches/Issue146/Applet/src/edu/internet2/ndt/Tcpbw100.java Tue May 27 14:19:34 2014 UTC
@@ -167,7 +167,7 @@
NewFrame _frameWeb100Vars, _frameDetailedStats, _frameOptions;
// String s; Unused, commenting out
double _dTime;
- int _s2cspdUpdateTime = 500, _c2sspdUpdateTime = 500; // ms
+ int _s2cspdUpdateTime = 500, _c2sspdUpdateTime = 500; // ms
int _iECNEnabled, _iNagleEnabled, MSSSent, MSSRcvd;
int _iSACKEnabled, _iTimestampsEnabled, _iWinScaleRcvd,
_iWinScaleSent;
int _iFastRetran, _iAckPktsOut, _iSmoothedRTT, _iCurrentCwnd,
_iMaxCwnd;
@@ -177,7 +177,7 @@
int _iSumRTT, _iCountRTT, _iCurrentMSS, _iTimeouts, _iPktsRetrans;
int _iSACKsRcvd, _iDupAcksIn, _iMaxRwinRcvd, _iMaxRwinSent;
int _iDataPktsOut, _iRcvbuf, _iSndbuf, _iAckPktsIn;
- long _iDataBytesOut;
+ long _iDataBytesOut;
int _iPktsOut, _iCongestionSignals, _iRcvWinScale;
// int _iPkts, _iLength=8192, _iCurrentRTO;
int _iPkts, _iLength = NDTConstants.PREDEFINED_BUFFER_SIZE,
_iCurrentRTO;
@@ -191,7 +191,7 @@
double _dS2cspd, _dC2sspd, _dSc2sspd, _dSs2cspd;
int _iSsndqueue;
double _dSbytes;
- byte[] _yabuff2Write;
+ byte[] _yabuff2Write;

/**
* Added by Martin Sandsmark, UNINETT AS Internationalization
@@ -265,7 +265,7 @@
private String pub_AccessTech = "unknown";
private String pub_natBox = "unknown";
private int pub_DupAcksOut = 0;
- private int pub_DupAcksIn = 0;
+ private int pub_DupAcksIn = 0;
private Date pub_TimeStamp;
private String pub_isReady = new String("no");
private String pub_clientIP = "unknown";
@@ -279,8 +279,8 @@
private long pub_bytes = 0;
private String _sIsAutoRun;
private String _sUserAgent = null;
- private boolean jsonSupport = true;
- private boolean retry = false;
+ private boolean jsonSupport = true;
+ private boolean retry = false;

/**
* public static void main for invoking as an Application
@@ -300,9 +300,9 @@
}
});
applet._bIsApplication = true;
- if (args.length > 1) {
- applet._sClient = args[1];
- }
+ if (args.length > 1) {
+ applet._sClient = args[1];
+ }
frame.getContentPane().add(applet);
frame.setSize(700, 320);
applet.init();
@@ -420,7 +420,7 @@
}

public String get_optimalRcvrBuffer() {
- //buffer size in bits
+ //buffer size in bits
return Integer.toString(pub_MaxRwinRcvd *
NDTConstants.KILO_BITS);
}

@@ -436,9 +436,9 @@
return Integer.toString(pub_DupAcksOut);
}

- public String get_DupAcksIn() {
- return Integer.toString(pub_DupAcksIn);
- }
+ public String get_DupAcksIn() {
+ return Integer.toString(pub_DupAcksIn);
+ }

public String get_TimeStamp() {
String result = "unknown";
@@ -484,7 +484,7 @@
}

public String get_instSpeed() {
- //Get speed in bits, hence multiply by 8 for byte->bit
conversion
+ //Get speed in bits, hence multiply by 8 for byte->bit
conversion
return Double.toString((NDTConstants.EIGHT * pub_bytes)
/ (System.currentTimeMillis() - pub_time));
}
@@ -523,7 +523,7 @@
* Set Client->Server fire-wall test results.
*
* @param iParamC2SRes
- * integer indicating C->S test results
+ * integer indicating C->S test results
* */
public void setC2sSFWTestResults(int iParamC2SRes) {
this._iC2sSFWResult = iParamC2SRes;
@@ -893,7 +893,7 @@
_chkboxPreferIPv6 = new JCheckBox(
_resBundDisplayMsgs.getString("preferIPv6"));
_chkboxPreferIPv6.setSelected(true);
- _chkboxPreferIPv6.addActionListener(this);
+ _chkboxPreferIPv6.addActionListener(this);
// 2. Conduct default tests?
_chkboxDefaultTest = new JCheckBox(

_resBundDisplayMsgs.getString("defaultTests"));
@@ -1124,10 +1124,10 @@
_frameWeb100Vars.setResizable(true);
_frameWeb100Vars.setVisible(true);

- if (NDTUtils.isNotEmpty(_txtDiagnosis.getText())) {
- // enable copy button only if there is details informations
- _buttonDetailsCopy.setEnabled(true);
- }
+ if (NDTUtils.isNotEmpty(_txtDiagnosis.getText())) {
+ // enable copy button only if there is
details informations
+ _buttonDetailsCopy.setEnabled(true);
+ }
}
// "More Details" Web100 variables window to be closed
else if (source == _buttonDetailsDismiss) {
@@ -1145,8 +1145,8 @@
}
// "Statistics" copy button functionality
else if (source == _buttonStatsCopy) {
- copy(_txtStatistics);
- }
+ copy(_txtStatistics);
+ }
// Show "statistics" window
else if (source == _buttonStatistics) {
_frameDetailedStats.setResizable(true);
@@ -1159,7 +1159,7 @@
}
// prefer IPv6 checkbox
else if (source == _chkboxPreferIPv6) {
- setsHostName(sHostName);
+ setsHostName(sHostName);
}
// mail to functionality
else if (source == _buttonMailTo) {
@@ -1218,33 +1218,31 @@
} // end mail-to functionality
} // actionPerformed()

- /**
- * Copy text from JTextarea to clipboard
- *
- * @param _txt
- * Source copied text to clipboard
- * */
- private void copy (JTextArea _txt) {
- try {
- Clipboard clipbd = getToolkit().getSystemClipboard();
- _bCanCopy = true;
- String sTemp = _txt.getText();
- StringSelection ssTemp = new StringSelection(sTemp);
- clipbd.setContents(ssTemp, ssTemp);
- } catch (SecurityException e) {
- _bCanCopy = false;
- // this Exception is only when the client cannot copy
- // some data, and is acted on by disabling the
- // copy button.
- System.err.println(" You may not have some security Permissions. Please confirm");
- }
- }
+ /**
+ * Copy text from JTextarea to clipboard
+ *
+ * @param _txt Source copied text to clipboard
+ * */
+ private void copy (JTextArea _txt) {
+ try {
+ Clipboard clipbd = getToolkit().getSystemClipboard();
+ _bCanCopy = true;
+ String sTemp = _txt.getText();
+ StringSelection ssTemp = new StringSelection(sTemp);
+ clipbd.setContents(ssTemp, ssTemp);
+ } catch (SecurityException e) {
+ _bCanCopy = false;
+ // this Exception is only when the client cannot copy
+ // some data, and is acted on by disabling the
+ // copy button.
+ System.err.println(" You may not have some security Permissions. Please confirm");
+ }
+ }

/**
* Display current status in Applet window.
*
- * @param msg
- * String value of status
+ * @param msg String value of status
* */
public void showStatus(String msg) {
if (!_bIsApplication) {
@@ -1411,65 +1409,65 @@

// Append server address as seen by the client
// to the Test Results obtained from server
- if (jsonSupport) {
- String sClientSideServerIp;
- try {
- // Get Client reported server IP
- sClientSideServerIp = midSrvrSockObj.getInetAddress() + "";
- } catch (SecurityException e) {
- System.err
- .println("Unable to obtain Servers IP addresses: using "
- + sHostName);
- _sErrMsg = "getInetAddress() called failed\n";
- sClientSideServerIp = sHostName;
- _resultsTxtPane.append(_resBundDisplayMsgs
- .getString("lookupError") + "\n");
- }
- int k = sClientSideServerIp.indexOf("/");
- sClientSideServerIp = sClientSideServerIp.substring(k + 1);
- _sMidBoxTestResult = JSONUtils.addValueToJsonObj(_sMidBoxTestResult, "ClientSideServerIp", sClientSideServerIp);
+ if (jsonSupport) {
+ String sClientSideServerIp;
+ try {
+ // Get Client reported server IP
+ sClientSideServerIp =
midSrvrSockObj.getInetAddress() + "";
+ } catch (SecurityException e) {
+ System.err
+ .println("Unable to obtain
Servers IP addresses: using "
+ +
sHostName);
+ _sErrMsg = "getInetAddress() called
failed\n";
+ sClientSideServerIp = sHostName;
+
_resultsTxtPane.append(_resBundDisplayMsgs
+ .getString("lookupError") +
"\n");
+ }
+ int k = sClientSideServerIp.indexOf("/");
+ sClientSideServerIp =
sClientSideServerIp.substring(k + 1);
+ _sMidBoxTestResult = JSONUtils.addValueToJsonObj(_sMidBoxTestResult, "ClientSideServerIp", sClientSideServerIp);


- // Append local address to the Test results obtained from server
- System.err.println("calling in2Socket.getLocalAddress()");
- String sClientSideClientIp;
- try {
- sClientSideClientIp = midSrvrSockObj.getLocalAddress() + ";";
- } catch (SecurityException e) {
- System.err
- .println("Unable to obtain local IP address: using 127.0.0.1");
- _sErrMsg = "getLocalAddress() call failed\n";
- sClientSideClientIp = NDTConstants.LOOPBACK_ADDRS_STRING + ";";
- }
+ // Append local address to the Test results
obtained from server
+ System.err.println("calling
in2Socket.getLocalAddress()");
+ String sClientSideClientIp;
+ try {
+ sClientSideClientIp =
midSrvrSockObj.getLocalAddress() + ";";
+ } catch (SecurityException e) {
+ System.err
+ .println("Unable to obtain
local IP address: using 127.0.0.1");
+ _sErrMsg = "getLocalAddress() call
failed\n";
+ sClientSideClientIp =
NDTConstants.LOOPBACK_ADDRS_STRING + ";";
+ }

- k = sClientSideClientIp.indexOf("/");
- sClientSideClientIp = sClientSideClientIp.substring(k + 1);
- _sMidBoxTestResult = JSONUtils.addValueToJsonObj(_sMidBoxTestResult, "ClientSideClientIp", sClientSideClientIp);
- } else {
- try {
- _sMidBoxTestResult += midSrvrSockObj.getInetAddress() + ";";
- } catch (SecurityException e) {
- System.err
- .println("Unable to obtain Servers IP addresses: using "
- + sHostName);
- _sErrMsg = "getInetAddress() called failed\n";
- _sMidBoxTestResult += sHostName + ";";
- _resultsTxtPane.append(_resBundDisplayMsgs
- .getString("lookupError") + "\n");
- }
+ k = sClientSideClientIp.indexOf("/");
+ sClientSideClientIp =
sClientSideClientIp.substring(k + 1);
+ _sMidBoxTestResult = JSONUtils.addValueToJsonObj(_sMidBoxTestResult, "ClientSideClientIp", sClientSideClientIp);
+ } else {
+ try {
+ _sMidBoxTestResult +=
midSrvrSockObj.getInetAddress() + ";";
+ } catch (SecurityException e) {
+ System.err
+ .println("Unable to obtain
Servers IP addresses: using "
+ +
sHostName);
+ _sErrMsg = "getInetAddress() called
failed\n";
+ _sMidBoxTestResult += sHostName + ";";
+
_resultsTxtPane.append(_resBundDisplayMsgs
+ .getString("lookupError") +
"\n");
+ }


- // Append local address to the Test results obtained from server
- System.err.println("calling in2Socket.getLocalAddress()");
- try {
- _sMidBoxTestResult += midSrvrSockObj.getLocalAddress() + ";";
- } catch (SecurityException e) {
- System.err
- .println("Unable to obtain local IP address: using 127.0.0.1");
- _sErrMsg = "getLocalAddress() call failed\n";
- _sMidBoxTestResult += NDTConstants.LOOPBACK_ADDRS_STRING + ";";
- }
- }
+ // Append local address to the Test results
obtained from server
+ System.err.println("calling
in2Socket.getLocalAddress()");
+ try {
+ _sMidBoxTestResult +=
midSrvrSockObj.getLocalAddress() + ";";
+ } catch (SecurityException e) {
+ System.err
+ .println("Unable to obtain
local IP address: using 127.0.0.1");
+ _sErrMsg = "getLocalAddress() call
failed\n";
+ _sMidBoxTestResult +=
NDTConstants.LOOPBACK_ADDRS_STRING + ";";
+ }
+ }

// wrap up test set up
srvin2.close();
@@ -1511,7 +1509,7 @@
* server. Tests are performed in both directions.
*
* @param protocolObj
- * Protocol Object used for message exchange
+ * Protocol Object used for message exchange
* @return boolean, true if test was not completed, false if test was
* completed.
* @throws IOException
@@ -1565,26 +1563,26 @@
// single space

int iSrvPort, iTestTime;
- if (jsonSupport) {
- try {
- iSrvPort = Integer.parseInt(JSONUtils.getValueFromJsonObj(new String(msg.getBody()), "empheralPortNumber"));
- iTestTime = Integer.parseInt(JSONUtils.getValueFromJsonObj(new String(msg.getBody()), "testTime"));
- } catch (Exception e) {
- _sErrMsg = _resBundDisplayMsgs.getString("sfwWrongMessage")
- + "\n";
- return true;
- }
- } else {
- try {
- int k = sMsgBody.indexOf(" ");
- iSrvPort = Integer.parseInt(sMsgBody.substring(0, k));
- iTestTime = Integer.parseInt(sMsgBody.substring(k + 1));
- } catch (Exception e) {
- _sErrMsg = _resBundDisplayMsgs.getString("sfwWrongMessage")
- + "\n";
- return true;
- }
- }
+ if (jsonSupport) {
+ try {
+ iSrvPort = Integer.parseInt(JSONUtils.getValueFromJsonObj(new String(msg.getBody()), "empheralPortNumber"));
+ iTestTime = Integer.parseInt(JSONUtils.getValueFromJsonObj(new String(msg.getBody()), "testTime"));
+ } catch (Exception e) {
+ _sErrMsg =
_resBundDisplayMsgs.getString("sfwWrongMessage")
+ + "\n";
+ return true;
+ }
+ } else {
+ try {
+ int k = sMsgBody.indexOf(" ");
+ iSrvPort =
Integer.parseInt(sMsgBody.substring(0, k));
+ iTestTime =
Integer.parseInt(sMsgBody.substring(k + 1));
+ } catch (Exception e) {
+ _sErrMsg =
_resBundDisplayMsgs.getString("sfwWrongMessage")
+ + "\n";
+ return true;
+ }
+ }

System.out.println("SFW: port=" + iSrvPort);
System.out.println("SFW: testTime=" + iTestTime);
@@ -1648,8 +1646,8 @@
iTestTime *
NDTConstants.KILO);

Protocol sfwCtl = new Protocol(sfwSocket);
- sfwCtl.setJsonSupport(jsonSupport);
-
+ sfwCtl.setJsonSupport(jsonSupport);
+
// send a simple string message over this
socket
sfwCtl.send_json_msg(MessageType.TEST_MSG,
new String(

NDTConstants.SFW_PREDEFINED_TEST_MESSAGE).getBytes());
@@ -1830,7 +1828,7 @@
if (c == 'z') {
c = '0';
}
- _yabuff2Write[i] = c++;
+ _yabuff2Write[i] = c++;
}
System.err.println("******Send buffer size =" + i);

@@ -1861,14 +1859,14 @@
}
}.start();

- Timer c2sspdUpdateTimer = new Timer();
- c2sspdUpdateTimer.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- pub_c2sspd = ((NDTConstants.EIGHT * _iPkts * _yabuff2Write.length) / NDTConstants.KILO)
- / (System.currentTimeMillis() - _dTime);
- }
- }, 100, _c2sspdUpdateTime);
+ Timer c2sspdUpdateTimer = new Timer();
+ c2sspdUpdateTimer.scheduleAtFixedRate(new TimerTask()
{
+ @Override
+ public void run() {
+ pub_c2sspd = ((NDTConstants.EIGHT * _iPkts * _yabuff2Write.length) / NDTConstants.KILO)
+ /
(System.currentTimeMillis() - _dTime);
+ }
+ }, 100, _c2sspdUpdateTime);

// While the 10 s timer ticks, write buffer data into
server socket
while (true) {
@@ -1895,7 +1893,7 @@
pub_bytes = (_iPkts * _iLength);
}

- c2sspdUpdateTimer.cancel();
+ c2sspdUpdateTimer.cancel();
_dTime = System.currentTimeMillis() - _dTime;
System.err.println(_dTime + " millisec test completed" +
","
+ _yabuff2Write.length + ","+ _iPkts);
@@ -1937,12 +1935,12 @@
return true;
}
// Get throughput as calculated by server
- String tmpstr3;
- if (jsonSupport) {
- tmpstr3 = JSONUtils.getSingleMessage(new String(msg.getBody()));
- } else {
- tmpstr3 = new String(msg.getBody());
- }
+ String tmpstr3;
+ if (jsonSupport) {
+ tmpstr3 = JSONUtils.getSingleMessage(new
String(msg.getBody()));
+ } else {
+ tmpstr3 = new String(msg.getBody());
+ }

_dSc2sspd = Double.parseDouble(tmpstr3) /
NDTConstants.KILO;

@@ -2088,14 +2086,14 @@
_dTime = System.currentTimeMillis();
pub_time = _dTime;

- Timer s2cspdUpdateTimer = new Timer();
- s2cspdUpdateTimer.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- pub_s2cspd = ((NDTConstants.EIGHT * pub_bytes) / NDTConstants.KILO)
- / (System.currentTimeMillis() - _dTime);
- }
- }, 100, _s2cspdUpdateTime);
+ Timer s2cspdUpdateTimer = new Timer();
+ s2cspdUpdateTimer.scheduleAtFixedRate(new TimerTask()
{
+ @Override
+ public void run() {
+ pub_s2cspd = ((NDTConstants.EIGHT *
pub_bytes) / NDTConstants.KILO)
+ /
(System.currentTimeMillis() - _dTime);
+ }
+ }, 100, _s2cspdUpdateTime);

// read data sent by server
try {
@@ -2113,8 +2111,8 @@
_sErrMsg = "Server Failed while reading socket
data\n";
return true;
} finally {
- s2cspdUpdateTimer.cancel();
- }
+ s2cspdUpdateTimer.cancel();
+ }

// get time duration during which bytes were received
_dTime = System.currentTimeMillis() - _dTime;
@@ -2154,38 +2152,38 @@
return true;
}
// get data from payload
- if (jsonSupport) {
- try {
- String tmpstr3 = new String(msg.getBody());
- _dSs2cspd = Double.parseDouble(JSONUtils.getValueFromJsonObj(tmpstr3, "ThroughputValue"))
- / NDTConstants.KILO;
- _iSsndqueue = Integer.parseInt(JSONUtils.getValueFromJsonObj(tmpstr3, "UnsentDataAmount"));
- _dSbytes = Double.parseDouble(JSONUtils.getValueFromJsonObj(tmpstr3, "TotalSentByte"));
- } catch (Exception e) {
- e.printStackTrace();
- _sErrMsg = _resBundDisplayMsgs.getString("inboundWrongMessage")
- + "\n";
- return true;
- }
- }
- else {
- try {
- String tmpstr3 = new String(msg.getBody());
- int k1 = tmpstr3.indexOf(" ");
- int k2 = tmpstr3.substring(k1 + 1).indexOf(" ");
- _dSs2cspd = Double.parseDouble(tmpstr3.substring(0, k1))
- / NDTConstants.KILO;
- _iSsndqueue = Integer.parseInt(tmpstr3.substring(k1 + 1)
- .substring(0, k2));
- _dSbytes = Double.parseDouble(tmpstr3.substring(k1 + 1)
- .substring(k2 + 1));
- } catch (Exception e) {
- e.printStackTrace();
- _sErrMsg = _resBundDisplayMsgs.getString("inboundWrongMessage")
- + "\n";
- return true;
- }
- }
+ if (jsonSupport) {
+ try {
+ String tmpstr3 = new
String(msg.getBody());
+ _dSs2cspd = Double.parseDouble(JSONUtils.getValueFromJsonObj(tmpstr3, "ThroughputValue"))
+ / NDTConstants.KILO;
+ _iSsndqueue = Integer.parseInt(JSONUtils.getValueFromJsonObj(tmpstr3, "UnsentDataAmount"));
+ _dSbytes = Double.parseDouble(JSONUtils.getValueFromJsonObj(tmpstr3, "TotalSentByte"));
+ } catch (Exception e) {
+ e.printStackTrace();
+ _sErrMsg =
_resBundDisplayMsgs.getString("inboundWrongMessage")
+ + "\n";
+ return true;
+ }
+ }
+ else {
+ try {
+ String tmpstr3 = new
String(msg.getBody());
+ int k1 = tmpstr3.indexOf(" ");
+ int k2 = tmpstr3.substring(k1 +
1).indexOf(" ");
+ _dSs2cspd =
Double.parseDouble(tmpstr3.substring(0, k1))
+ / NDTConstants.KILO;
+ _iSsndqueue =
Integer.parseInt(tmpstr3.substring(k1 + 1)
+ .substring(0, k2));
+ _dSbytes =
Double.parseDouble(tmpstr3.substring(k1 + 1)
+ .substring(k2 + 1));
+ } catch (Exception e) {
+ e.printStackTrace();
+ _sErrMsg =
_resBundDisplayMsgs.getString("inboundWrongMessage")
+ + "\n";
+ return true;
+ }
+ }

// Represent throughput using optimal units (kbps /
mbps)
if (_dS2cspd < 1.0) {
@@ -2256,11 +2254,11 @@
return true;
}
// Get all web100 variables as
name-value string pairs
- if (jsonSupport) {
- _sTestResults += JSONUtils.getSingleMessage(new String(msg.getBody()));
- } else {
- _sTestResults += new String(msg.getBody());
- }
+ if (jsonSupport) {
+ _sTestResults += JSONUtils.getSingleMessage(new String(msg.getBody()));
+ } else {
+ _sTestResults += new
String(msg.getBody());
+ }
i++;
} // end for
} catch (IOException ioExcep) {
@@ -2370,9 +2368,9 @@
(NDTConstants.META_CLIENT_KERNEL_VERSION +
":" + System

.getProperty("os.version")).getBytes());
paramProtoObj.send_json_msg(MessageType.TEST_MSG,
- (NDTConstants.META_CLIENT_VERSION + ":" + NDTConstants.VERSION).getBytes());
+ (NDTConstants.META_CLIENT_VERSION + ":" + NDTConstants.VERSION).getBytes());
paramProtoObj.send_json_msg(MessageType.TEST_MSG,
- (NDTConstants.META_CLIENT_APPLICATION + ":" + application) .getBytes());
+ (NDTConstants.META_CLIENT_APPLICATION + ":" + application) .getBytes());

// Client can send any number of such meta data in a
TEST_MSG
// format, and signal
@@ -2514,10 +2512,10 @@

// write our test suite request by sending a login message
// _yTests indicates the requested test-suite
- byte [] send = new byte[NDTConstants.VERSION.length()+1];
- send[0] = _yTests;
- System.arraycopy(NDTConstants.VERSION.getBytes(), 0, send, 1, NDTConstants.VERSION.length());
-
+ byte [] send = new byte[NDTConstants.VERSION.length()+1];
+ send[0] = _yTests;
+ System.arraycopy(NDTConstants.VERSION.getBytes(), 0, send, 1, NDTConstants.VERSION.length());
+
protocolObj.send_json_msg(MessageType.MSG_EXTENDED_LOGIN,
send);

// read the specially crafted data that kicks off the old
clients
@@ -2547,62 +2545,62 @@
// below.
// Any other type of message at this stage is
incorrect
if (msg.getType() != MessageType.SRV_QUEUE) {
- if (!retry && !new String(msg.getBody()).equals("Invalid login message.")) {
- jsonSupport = false;
- retry = true;
- try {
+ if (!retry && !new String(msg.getBody()).equals("Invalid login message.")) {
+ jsonSupport = false;
+ retry = true;
+ try {

- // RAC Debug message
- _resultsTxtPane.append(_resBundDisplayMsgs
- .getString("unsupportedMsgExtendedLogin")
- + "\n");
- // create socket to host specified by user and the default port
- ctlSocket = new Socket(hostAddress, ctlport);
- } catch (UnknownHostException e) {
- System.err.println("Don't know about host: " + sHostName);
- _sErrMsg = _resBundDisplayMsgs.getString("unknownServer") + "\n";
- _bFailed = true;
- return;
- } catch (IOException e) {
- System.err.println("Couldn't get the connection to: " + sHostName
- + " " + ctlport);
- _sErrMsg = _resBundDisplayMsgs.getString("serverNotRunning") + " ("
- + sHostName + ":" + ctlport + ")\n";
- _bFailed = true;
- return;
- }
+ // RAC Debug message
+
_resultsTxtPane.append(_resBundDisplayMsgs
+
.getString("unsupportedMsgExtendedLogin")
+ + "\n");
+ // create socket to host
specified by user and the default port
+ ctlSocket = new
Socket(hostAddress, ctlport);
+ } catch (UnknownHostException e) {
+ System.err.println("Don't know
about host: " + sHostName);
+ _sErrMsg =
_resBundDisplayMsgs.getString("unknownServer") + "\n";
+ _bFailed = true;
+ return;
+ } catch (IOException e) {
+ System.err.println("Couldn't get
the connection to: " + sHostName
+ + " " +
ctlport);
+ _sErrMsg =
_resBundDisplayMsgs.getString("serverNotRunning") + " ("
+ + sHostName + ":" +
ctlport + ")\n";
+ _bFailed = true;
+ return;
+ }

- protocolObj = new Protocol(ctlSocket);
- protocolObj.setJsonSupport(false);
- // The beginning of the protocol
+ protocolObj = new Protocol(ctlSocket);
+ protocolObj.setJsonSupport(false);
+ // The beginning of the protocol

- // Determine, and indicate to client about Inet6/4 address being used
- if (ctlSocket.getInetAddress() instanceof Inet6Address) {
- _resultsTxtPane.append(_resBundDisplayMsgs.getString("connected")
- + " " + sHostName
- + _resBundDisplayMsgs.getString("usingIpv6") + "\n");
- } else {
- _resultsTxtPane.append(_resBundDisplayMsgs.getString("connected")
- + " " + sHostName
- + _resBundDisplayMsgs.getString("usingIpv4") + "\n");
- }
+ // Determine, and indicate to client
about Inet6/4 address being used
+ if (ctlSocket.getInetAddress()
instanceof Inet6Address) {
+
_resultsTxtPane.append(_resBundDisplayMsgs.getString("connected")
+ + " " +
sHostName
+ +
_resBundDisplayMsgs.getString("usingIpv6") + "\n");
+ } else {
+
_resultsTxtPane.append(_resBundDisplayMsgs.getString("connected")
+ + " " +
sHostName
+ +
_resBundDisplayMsgs.getString("usingIpv4") + "\n");
+ }

- protocolObj.send_msg(MessageType.MSG_LOGIN, _yTests);
+
protocolObj.send_msg(MessageType.MSG_LOGIN, _yTests);


- if (protocolObj.readn(msg, 13) != 13) {
- _sErrMsg = _resBundDisplayMsgs.getString("unsupportedClient")
- + "\n";
- _bFailed = true;
- return;
- }
- continue;
- } else {
- _sErrMsg = _resBundDisplayMsgs.getString("loggingWrongMessage")
- + "\n";
- _bFailed = true;
- return;
- }
+ if (protocolObj.readn(msg, 13) != 13)
{
+ _sErrMsg =
_resBundDisplayMsgs.getString("unsupportedClient")
+ + "\n";
+ _bFailed = true;
+ return;
+ }
+ continue;
+ } else {
+ _sErrMsg =
_resBundDisplayMsgs.getString("loggingWrongMessage")
+ + "\n";
+ _bFailed = true;
+ return;
+ }
}

// Get wait flag value
@@ -2616,12 +2614,12 @@
break;
}

- if (wait == NDTConstants.SRV_QUEUE_SERVER_FAULT) {
- _sErrMsg = _resBundDisplayMsgs.getString("serverFault")
- + "\n";
- _bFailed = true;
- return;
- }
+ if (wait == NDTConstants.SRV_QUEUE_SERVER_FAULT) {
+ _sErrMsg =
_resBundDisplayMsgs.getString("serverFault")
+ + "\n";
+ _bFailed = true;
+ return;
+ }

if (wait == NDTConstants.SRV_QUEUE_SERVER_BUSY) {
if (iServerWaitFlag == 0) { // First message
from server,
@@ -2698,12 +2696,12 @@
}

// Version compatibility between server-client must be
verified
- String vVersion;
- if (jsonSupport) {
- vVersion = JSONUtils.getSingleMessage(new String(msg.getBody()));
- } else {
- vVersion = new String(msg.getBody());
- }
+ String vVersion;
+ if (jsonSupport) {
+ vVersion = JSONUtils.getSingleMessage(new
String(msg.getBody()));
+ } else {
+ vVersion = new String(msg.getBody());
+ }

if (!vVersion.startsWith("v")) {
_sErrMsg =
_resBundDisplayMsgs.getString("incompatibleVersion");
@@ -2712,18 +2710,18 @@
}
System.out.println("Server version: " +
vVersion.substring(1));

- if (vVersion.endsWith("Web10G") || vVersion.endsWith("Web100")) {
- if (!vVersion.substring(1, vVersion.lastIndexOf('-')).equals(NDTConstants.VERSION)) {
- _resultsTxtPane.append(_resBundDisplayMsgs
- .getString("diffrentVersion") + " (" + vVersion.substring(1, vVersion.lastIndexOf('-')) + ")\n");
- System.out.println("WARNING: NDT server has different version number (" + vVersion.substring(1) + ")");
- }
- }
- else if (!vVersion.substring(1).equals(NDTConstants.VERSION)) {
- _resultsTxtPane.append(_resBundDisplayMsgs
- .getString("diffrentVersion") + " (" + vVersion.substring(1) + ")\n");
- System.out.println("WARNING: NDT server has different version number (" + vVersion.substring(1) + ")");
- }
+ if (vVersion.endsWith("Web10G") ||
vVersion.endsWith("Web100")) {
+ if (!vVersion.substring(1, vVersion.lastIndexOf('-')).equals(NDTConstants.VERSION)) {
+ _resultsTxtPane.append(_resBundDisplayMsgs
+ .getString("diffrentVersion") + " (" + vVersion.substring(1, vVersion.lastIndexOf('-')) + ")\n");
+ System.out.println("WARNING: NDT server has different version number (" + vVersion.substring(1) + ")");
+ }
+ }
+ else if (!vVersion.substring(1).equals(NDTConstants.VERSION))
{
+ _resultsTxtPane.append(_resBundDisplayMsgs
+ .getString("diffrentVersion") + " (" +
vVersion.substring(1) + ")\n");
+ System.out.println("WARNING: NDT server has different version number (" + vVersion.substring(1) + ")");
+ }

// If we have connected to a Web10G server rebrand ourselves
as such
_sServerType = vVersion.endsWith("Web10G") ? "web10g" :
"web100";
@@ -2756,13 +2754,13 @@
}

// get ids of tests to be run now
- String tmpstr;
- if (jsonSupport) {
- tmpstr = JSONUtils.getSingleMessage(new String(msg.getBody()));
- } else {
- tmpstr = new String(msg.getBody());
- }
- StringTokenizer tokenizer = new StringTokenizer(tmpstr, " ");
+ String tmpstr;
+ if (jsonSupport) {
+ tmpstr = JSONUtils.getSingleMessage(new
String(msg.getBody()));
+ } else {
+ tmpstr = new String(msg.getBody());
+ }
+ StringTokenizer tokenizer = new StringTokenizer(tmpstr, " ");

// Run all tests requested, based on the ID. In each case, if
tests
// cannot be successfully run,
@@ -2870,11 +2868,11 @@
_bFailed = true;
return;
}
- if (jsonSupport) {
- _sTestResults += JSONUtils.getSingleMessage(new String(msg.getBody()));
- } else {
- _sTestResults += new String(msg.getBody());
- }
+ if (jsonSupport) {
+ _sTestResults += JSONUtils.getSingleMessage(new String(msg.getBody()));
+ } else {
+ _sTestResults += new
String(msg.getBody());
+ }
i++;
}
} catch (IOException e) {
@@ -2954,54 +2952,54 @@
String sSysvar, sStrval;
int iSysval, iZero = 0; // iBwdelay, iMinwin; // commented
out unused
// variables
- double dSysval2, j;
- long lSysval3;
- String sOsName, sOsArch, sOsVer, sJavaVer, sJavaVendor, sClient;
+ double dSysval2, j;
+ long lSysval3;
+ String sOsName, sOsArch, sOsVer, sJavaVer, sJavaVendor,
sClient;

- // extract key-value pair results
+ // extract key-value pair results

- tokens = new StringTokenizer(sTestResParam);
- sSysvar = null;
- sStrval = null;
- while (tokens.hasMoreTokens()) {
- if (++i % 2 == 1) {
- sSysvar = tokens.nextToken();
- } else {
- sStrval = tokens.nextToken();
- _txtDiagnosis.append(sSysvar + " " + sStrval + "\n");
- _sEmailText += sSysvar + " " + sStrval + "\n%0A";
+ tokens = new StringTokenizer(sTestResParam);
+ sSysvar = null;
+ sStrval = null;
+ while (tokens.hasMoreTokens()) {
+ if (++i % 2 == 1) {
+ sSysvar = tokens.nextToken();
+ } else {
+ sStrval = tokens.nextToken();
+ _txtDiagnosis.append(sSysvar + " " + sStrval +
"\n");
+ _sEmailText += sSysvar + " " + sStrval +
"\n%0A";

- //check if it's save anywhere after parse
- if (isValueSave(sSysvar)) {
- if (sSysvar.equals("DataBytesOut:")) {
- // long
- try{
- lSysval3 = Long.parseLong(sStrval);
- } catch (Exception e) {
- System.out.println("Exception occured reading a web100 var " + sSysvar + " - " + e);
- lSysval3 = -1;
- }
- // save value into a key value expected by us
- save_long_values(sSysvar, lSysval3);
- }
- else if (sStrval.indexOf(".") == -1) { // no decimal point, hence
- // integer
- try{
- iSysval = Integer.parseInt(sStrval);
- // If it fails as an int it's probably to big since the values are often unsigned
- } catch (Exception e) {
- System.out.println("Exception occured reading a web100 var " + sSysvar + " - " + e);
- iSysval = -1;
- }
- // save value into a key value expected by us
- save_int_values(sSysvar, iSysval);
- } else { // if not integer, save as double
- dSysval2 = Double.valueOf(sStrval).doubleValue();
- save_dbl_values(sSysvar, dSysval2);
- }
- }
- }
- }
+ //check if it's save anywhere after parse
+ if (isValueSave(sSysvar)) {
+ if (sSysvar.equals("DataBytesOut:")) {
+ // long
+ try{
+ lSysval3 =
Long.parseLong(sStrval);
+ } catch (Exception e) {
+ System.out.println("Exception occured reading a web100 var " + sSysvar + " - " + e);
+ lSysval3 = -1;
+ }
+ // save value into a key
value expected by us
+ save_long_values(sSysvar,
lSysval3);
+ }
+ else if (sStrval.indexOf(".") == -1)
{ // no decimal point, hence
+ // integer
+ try{
+ iSysval =
Integer.parseInt(sStrval);
+ // If it fails as an int it's probably to big since the values are often unsigned
+ } catch (Exception e) {
+ System.out.println("Exception occured reading a web100 var " + sSysvar + " - " + e);
+ iSysval = -1;
+ }
+ // save value into a key
value expected by us
+ save_int_values(sSysvar,
iSysval);
+ } else { // if not integer, save as
double
+ dSysval2 =
Double.valueOf(sStrval).doubleValue();
+ save_dbl_values(sSysvar,
dSysval2);
+ }
+ }
+ }
+ }

// Grab some client details from the Applet environment
sOsName = System.getProperty("os.name");
@@ -3216,8 +3214,8 @@

if (((2 * rwin) / rttsec) < mylink) { // multiply by 2 to counter round-trip

- // link speed is in Mbps. Convert it
back to kbps (*1000),
- // and bytes (/8)
+ // link speed is in Mbps. Convert it
back to kbps (*1000),
+ // and bytes (/8)
j = (float) ((mylink * avgrtt) *
NDTConstants.KILO)
/ NDTConstants.EIGHT
/ NDTConstants.KILO_BITS;
if (j > (float) _iMaxRwinRcvd) {
@@ -3579,7 +3577,7 @@
+ NDTUtils.prtdbl(sendtime *
NDTConstants.PERCENTAGE)
+
_resBundDisplayMsgs.getString("pctOfTime") + ".\n%0A";
if ((2 * (swin / rttsec)) < mylink) {
- // divide by 2 to counter round-trip
+ // divide by 2 to counter round-trip
_txtStatistics.append(" "
+
_resBundDisplayMsgs.getString("incrTxBuf") + " ("
+ NDTUtils.prtdbl(_iSndbuf / (2
* NDTConstants.KILO_BITS)) + " KB) "
@@ -3589,9 +3587,9 @@
}

// Is the connection network limited?
- // If the congestion window is limited more than 0.5%
- // of the time, NDT claims the connection is network
- // limited.
+ // If the congestion window is limited more than 0.5%
+ // of the time, NDT claims the connection is network
+ // limited.
if (cwndtime > .005) {
_txtStatistics.append(_resBundDisplayMsgs
.getString("thisConnIs")
@@ -3608,11 +3606,11 @@


// Is the loss excessive?
- // If the link speed is less than a T3, and loss
- // is greater than 1 percent, loss is determined
- // to be excessive.
+ // If the link speed is less than a T3, and loss
+ // is greater than 1 percent, loss is determined
+ // to be excessive.
if ((spd < 4) && (loss > .01)) {
-
_txtStatistics.append(_resBundDisplayMsgs.getString("excLoss")
+
_txtStatistics.append(_resBundDisplayMsgs.getString("excLoss")
+ "\n");
}

@@ -3653,11 +3651,11 @@

_txtStatistics.append("RFC 1323 Window Scaling: ");
if (_iMaxRwinRcvd <
NDTConstants.TCP_MAX_RECV_WIN_SIZE)
- _iWinScaleRcvd = 0; //Max rec window size
lesser than TCP's max value,
- // so, no scaling
requested
- // According to RFC1323, Section 2.3 the max valid value of _iWinScaleRcvd is 14.
- // Unclear why NDT uses 20 for this, but leaving for now in case this is a web100
- // error value of some kind. (Revisit after Methodology document written.)
+ _iWinScaleRcvd = 0; //Max rec window size
lesser than TCP's max value,
+ //
so, no scaling requested
+ // According to RFC1323, Section 2.3 the max valid value of _iWinScaleRcvd is 14.
+ // Unclear why NDT uses 20 for this, but leaving for now in case this is a web100
+ // error value of some kind. (Revisit after Methodology document written.)
if ((_iWinScaleRcvd == 0) || (_iWinScaleRcvd > 20))

_txtStatistics.append(_resBundDisplayMsgs.getString("off")
+ "\n");
@@ -3815,47 +3813,47 @@
*/

public void middleboxResults(String sMidBoxTestResParam) {
- String sServerIp;
- String sClientIp;
- int iMss;
- // changing order for issue 61
- int iWinsSent;
- int iWinsRecv; // unused, but retaining
- String sClientSideServerIp;
- String sClientSideClientIp;
+ String sServerIp;
+ String sClientIp;
+ int iMss;
+ // changing order for issue 61
+ int iWinsSent;
+ int iWinsRecv; // unused, but retaining
***The diff for this file has been truncated for email.***


  • [ndt-dev] [ndt] r1059 committed - added json-smart library to svn, added descriptions of new functions, ..., ndt, 05/27/2014

Archive powered by MHonArc 2.6.16.

Top of Page