ndt-dev - [ndt-dev] [ndt] r517 committed - Fill in more of detailed results, re-factor to better de-compose.
Subject: NDT-DEV email list created
List archive
[ndt-dev] [ndt] r517 committed - Fill in more of detailed results, re-factor to better de-compose.
Chronological Thread
- From:
- To:
- Subject: [ndt-dev] [ndt] r517 committed - Fill in more of detailed results, re-factor to better de-compose.
- Date: Tue, 23 Aug 2011 20:37:57 +0000
Revision: 517
Author:
Date: Tue Aug 23 13:36:59 2011
Log: Fill in more of detailed results, re-factor to better de-compose.
http://code.google.com/p/ndt/source/detail?r=517
Modified:
/branches/android/Android/AndroidManifest.xml
/branches/android/Android/res/layout/results.xml
/branches/android/Android/res/values/strings.xml
/branches/android/Android/src/net/measurementlab/ndt/AndroidNdt.java
/branches/android/Android/src/net/measurementlab/ndt/Constants.java
/branches/android/Android/src/net/measurementlab/ndt/InitialActivity.java
/branches/android/Android/src/net/measurementlab/ndt/NdtService.java
/branches/android/Android/src/net/measurementlab/ndt/ResultsActivity.java
/branches/android/Android/src/net/measurementlab/ndt/Statistics.java
/branches/android/Android/src/net/measurementlab/ndt/TestsActivity.java
/branches/android/java/net/measurementlab/ndt/NdtTests.java
=======================================
--- /branches/android/Android/AndroidManifest.xml Tue Aug 16 09:53:54
2011
+++ /branches/android/Android/AndroidManifest.xml Tue Aug 23 13:36:59
2011
@@ -11,8 +11,6 @@
</activity>
<activity android:name=".TestsActivity" android:label="@string/app_name" android:theme="@style/NdtTheme" />
<activity android:name=".ResultsActivity" android:label="@string/app_name" android:theme="@style/NdtTheme.Blue" />
- <!-- SelectServer.java: Options Activity for selecting the test server -->
- <activity android:name=".SelectServer" android:label="@string/choice_server_title" />
<service android:name=".NdtService" />
</application>
<uses-sdk android:minSdkVersion="8" />
=======================================
--- /branches/android/Android/res/layout/results.xml Tue Aug 23 08:23:47 2011
+++ /branches/android/Android/res/layout/results.xml Tue Aug 23 13:36:59 2011
@@ -10,7 +10,8 @@
<RelativeLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<HorizontalScrollView android:orientation="horizontal"
- android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_alignParentTop="true">
+ android:layout_width="fill_parent"
android:layout_height="fill_parent"
+ android:layout_alignParentTop="true">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<!-- summary results -->
@@ -81,19 +82,31 @@
</LinearLayout>
</LinearLayout>
<!-- detailed results -->
- <LinearLayout android:orientation="vertical"
+ <ScrollView android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
- <TextView
android:layout_width="fill_parent"
- android:layout_height="wrap_content"
android:paddingTop="15sp"
- android:text="Details" style="@style/NdtHeader" android:id="@+id/DetailedResultsHeader" />
- </LinearLayout>
+ <LinearLayout
android:orientation="vertical"
+ android:layout_width="fill_parent" android:layout_height="fill_parent">
+ <TextView
android:layout_width="fill_parent"
+
android:layout_height="wrap_content" android:paddingTop="15sp"
+ android:text="Details" style="@style/NdtHeader" android:id="@+id/DetailedResultsHeader" />
+ <TextView
android:layout_width="fill_parent"
+
android:layout_height="wrap_content" android:paddingTop="15sp"
+ style="@style/NdtTestsDetail.Info" android:id="@+id/DetailedResultsInfo" />
+ </LinearLayout>
+ </ScrollView>
<!-- advanced results -->
- <LinearLayout android:orientation="vertical"
+ <ScrollView android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
- <TextView
android:layout_width="fill_parent"
- android:layout_height="wrap_content"
android:paddingTop="15sp"
- android:text="Advanced" style="@style/NdtHeader" android:id="@+id/AdvancedResultsHeader" />
- </LinearLayout>
+ <LinearLayout
android:orientation="vertical"
+ android:layout_width="fill_parent" android:layout_height="fill_parent">
+ <TextView
android:layout_width="fill_parent"
+
android:layout_height="wrap_content" android:paddingTop="15sp"
+ android:text="Advanced" style="@style/NdtHeader" android:id="@+id/AdvancedResultsHeader" />
+ <TextView
android:layout_width="fill_parent"
+
android:layout_height="wrap_content" android:paddingTop="15sp"
+ style="@style/NdtTestsDetail.Info" android:id="@+id/AdvancedResultsInfo" />
+ </LinearLayout>
+ </ScrollView>
</LinearLayout>
</HorizontalScrollView>
<RelativeLayout android:orientation="horizontal"
=======================================
--- /branches/android/Android/res/values/strings.xml Tue Aug 23 08:23:47 2011
+++ /branches/android/Android/res/values/strings.xml Tue Aug 23 13:36:59 2011
@@ -1,24 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
- <string name="hello">NDT Mobile Client for Android Ready.</string>
<string name="app_name">NDT Mobile Client</string>
- <string name="choice_server_title">Choose Testing Server</string>
- <string name="exit">Exit</string>
<string name="about">About</string>
<string name="start">Start</string>
- <string name="options">Options</string>
- <string name="statistics">Statistics</string>
<string name="label_about_description">Copyright 2009 Google Inc.\n\nThis software is based in part on NDT: Copyright (c) 2003 University of Chicago.</string>
<string name="label_about_title">About NDT Mobile Client for Android</string>
- <string name="close">Close</string>
- <string name="save">Save</string>
- <string name="email">E-Mail</string>
- <string name="cancel">Cancel</string>
- <string name="warning">Warning</string>
- <string name="contents_warning">Server list error. Shutting down NDT Mobile Client.</string>
- <string name="fail_tip">Test failed.</string>
<string name="serverlist_corrupted_tip">Server list corrupted, please contact the publisher.</string>
- <string name="test_begins_at">Testing started at %1$s</string>
<string name="from_header">From:</string>
<string name="to_header">To:</string>
<string name="server_indicator">Server: %1$s</string>
@@ -29,11 +16,7 @@
<string name="default_server_indicator">Default server: %1$s</string>
<string name="network_type_indicator">NetworkType: %1$s</string>
<string name="changed_server">Changed testing server to: %1$s</string>
- <string name="os_line">OS: Name = %1$s, Architecture = %2$s, Version = %3$s</string>
- <string name="java_line">Java: Version = %1$s, Vendor = %2$s</string>
<string name="email_title">NDT Mobile Client for Android Result on %1$s</string>
- <string name="intent_error">Intent Error.</string>
- <string name="test_again">Press Start to test again.</string>
<string name="mlab">M-Lab</string>
<string name="mlabdesc">Network Diagnostic Tool (NDT) provides a sophisticated speed and diagnostic test. An NDT test reports more than just the upload and download speeds — it also attempts to determine what, if any, problems limited these speeds, differentiating between computer configuration and network infrastructure problems. While the diagnostic messages are most useful for expert users, they can also help novice users by allowing them to provide detailed trouble reports to their network administrator.</string>
@@ -45,13 +28,25 @@
<string name="tests_test_server">TEST SERVER</string>
<string name="tests_your_computer">YOUR COMPUTER</string>
<string name="results_header">YOUR TEST RESULTS</string>
+ <string name="results_swipe_hint">Swipe to view detailed and advanced results.</string>
<string name="results_upload_speed_header">UPLOAD SPEED</string>
<string name="results_download_speed_header">DOWNLOAD SPEED</string>
<string name="results_mpbs">mb/s</string>
<string name="results_latency_label">Network latency:</string>
- <string name="results_latency">{0} msec round trip time</string>
+ <string name="results_latency">%d msec round trip time</string>
<string name="results_jitter_label">Jitter:</string>
- <string name="results_jitter">{0} msec</string>
+ <string name="results_jitter">%d msec</string>
+ <string name="results_summary">Summary Results</string>
+ <string name="results_detailed">Detailed Results</string>
+ <string name="results_detailed_system">Your system: %1$s version %2$s \nJava version: %3$s (%4$s)</string>
+ <string name="results_detailed_tcp">TCP receive window: %1$d current,\n\t%2$d maximum</string>
+ <string name="results_detailed_packet_loss">%f packets lost during test</string>
+ <string name="results_detailed_rtt">Round trip time: %1$d msec (minimum),\n\t%2$d msec (maximum),\n\t%3$f msec (average)</string>
+ <string name="results_detailed_jitter">Jitter: %d msec</string>
+ <string name="results_detailed_timeout">%1$d seconds spend waiting following a timeout\nTCP time-out counter: %2$d</string>
+ <string name="results_detailed_ack">%d selective acknowledgement packets received</string>
+ <string name="results_advanced">Advanced Results</string>
+ <string name="results_advanced_web100">WEB100 Kernel Variables:\n%s</string>
<string name="results_more_about">More information about M-Lab</string>
<string name="results_test_again">Test Again</string>
</resources>
=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/AndroidNdt.java Fri Jun 10 12:49:15 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/AndroidNdt.java Tue Aug 23 13:36:59 2011
@@ -3,182 +3,32 @@
package net.measurementlab.ndt;
import android.app.Activity;
-import android.app.AlertDialog;
import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.net.ConnectivityManager;
-import android.net.NetworkInfo;
import android.os.Bundle;
-import android.os.Handler;
-import android.os.Looper;
-import android.os.Message;
import android.os.PowerManager;
-import android.text.method.ScrollingMovementMethod;
import android.util.Log;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.Button;
-import android.widget.ProgressBar;
-import android.widget.TextView;
import android.widget.Toast;
-import java.util.Date;
-
-import net.measurementlab.ndt.NdtTests;
-import net.measurementlab.ndt.UiServices;
-
/**
* UI Thread and Entry Point of NDT mobile client.
*/
public class AndroidNdt extends Activity {
- private int serverNumber;
- private int progress;
- private String serverName;
- private String serverHost;
- private String mobileInfo;
- private String statistics;
- private Button buttonStart;
- private Button buttonAbout;
- private Button buttonStatistics;
- private Button buttonOption;
- private ProgressBar progressBar;
- private TextView textViewMain;
- private UiHandler uiHandler;
private PowerManager powerManager;
private PowerManager.WakeLock wakeLock;
- private NetworkInfo networkInfo;
- private UiServices uiServices;
private NdtLocation ndtLocation;
- private class StartButtonListener implements OnClickListener {
- public void onClick(View view) {
- statistics = "";
- Date date = new Date();
- StringBuilder stringBuilder = new StringBuilder()
- .append("\n")
- .append(getString(R.string.test_begins_at, date.toString()))
- .append("\n");
- uiServices.appendString(stringBuilder.toString(), UiServices.MAIN_VIEW);
- uiServices.appendString(stringBuilder.toString(), UiServices.STAT_VIEW);
- stringBuilder = new StringBuilder()
- .append("\n")
- .append(getString(R.string.from_header))
- .append(getSystemProperty())
- .append("\n")
- .append(mobileInfo)
- .append("\n\n")
- .append(getString(R.string.to_header))
- .append("\n")
- .append(getString(R.string.server_indicator, serverName))
- .append("\n")
- .append(getString(R.string.host_indicator, serverHost))
- .append("\n");
- uiServices.appendString(stringBuilder.toString(), UiServices.STAT_VIEW);
- Thread netWorker = new Thread(new NdtTests(serverHost, uiServices, getNetworkType()));
- netWorker.start();
- }
- }
-
- private class StatisticsButtonListener implements OnClickListener {
- public void onClick(View view) {
- StringBuilder locationBuilder = new StringBuilder();
- if (ndtLocation.location != null) {
- locationBuilder
- .append(getString(R.string.latitude_result, ndtLocation.location.getLatitude()))
- .append("\n")
- .append(getString(R.string.longitude_result, ndtLocation.location.getLongitude()));
- }
- Intent intent = new Intent(AndroidNdt.this, Statistics.class);
- intent.putExtra(Constants.INTENT_STATISTICS, statistics);
- intent.putExtra(Constants.INTENT_NETWORK, getNetworkType());
- intent.putExtra(Constants.INTENT_LOCATION, locationBuilder.toString());
- startActivityForResult(intent, Constants.ACTIVITY_STATISTICS);
- }
- }
-
- private class AboutButtonListener implements OnClickListener {
- Context contextActivity;
-
- AboutButtonListener(Context context) {
- contextActivity = context;
- }
-
- public void onClick(View view) {
- AlertDialog.Builder builderAbout = new AlertDialog.Builder(contextActivity);
- builderAbout.setTitle(R.string.label_about_title);
- builderAbout.setPositiveButton(R.string.close, new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int which) {
- setResult(RESULT_OK);
- }
- });
- builderAbout.setMessage(R.string.label_about_description);
- builderAbout.create();
- builderAbout.show();
- }
- }
-
- private class OptionButtonListener implements OnClickListener {
- public void onClick(View view) {
- Intent intent = new Intent(AndroidNdt.this, SelectServer.class);
- intent.putExtra(Constants.INTENT_SERVER_NO, serverNumber);
- startActivityForResult(intent, Constants.ACTIVITY_OPTION);
- }
- }
-
/**
* Initializes the activity.
*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
checkServerListValid();
// Set the default server
- serverNumber = Constants.DEFAULT_SERVER;
ndtLocation = new NdtLocation(this);
ndtLocation.startListen();
powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
- ConnectivityManager connectivityManager =
- (ConnectivityManager) getSystemService(CONNECTIVITY_SERVICE);
- networkInfo = connectivityManager.getActiveNetworkInfo();
wakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "Network Testing");
- serverName = Constants.SERVER_NAME[serverNumber];
- serverHost = Constants.SERVER_HOST[serverNumber];
- uiHandler = new UiHandler(Looper.myLooper());
- try {
- uiServices = new AndroidUiServices(this, uiHandler);
-
- textViewMain = (TextView) findViewById(R.id.TextViewMain);
-
textViewMain.setMovementMethod(ScrollingMovementMethod.getInstance());
- textViewMain.setClickable(false);
- textViewMain.setLongClickable(false);
- textViewMain.append("\n" + getString(R.string.version_indicator, NdtTests.VERSION));
- textViewMain.append("\n" + getString(R.string.default_server_indicator, serverName));
- textViewMain.append("\n");
- mobileInfo = getMobileProperty();
- textViewMain.append(mobileInfo);
- textViewMain.append("\n");
- initComponents();
- } catch (Exception e) {
- Log.i("ndt", "Error in create.", e);
- }
- }
-
- /**
- *
{@inheritDoc}
- */
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- if (resultCode == RESULT_OK || requestCode == Constants.ACTIVITY_OPTION) {
- if (data != null) {
- serverNumber = data.getExtras().getInt(Constants.INTENT_SERVER_NO);
- textViewMain.append("\n"
- + getString(R.string.changed_server, Constants.SERVER_NAME[serverNumber]) + "\n");
- serverName = Constants.SERVER_NAME[serverNumber];
- serverHost = Constants.SERVER_HOST[serverNumber];
- }
- }
}
/**
@@ -230,138 +80,4 @@
finish();
}
}
-
- /**
- * Gets the system related properties.
- *
- * @return a string describing the OS and Java environment
- */
- private String getSystemProperty() {
- String osName, osArch, osVer, javaVer, javaVendor;
- osName = System.getProperty("os.name");
- osArch = System.getProperty("os.arch");
- osVer = System.getProperty("os.version");
- javaVer = System.getProperty("java.version");
- javaVendor = System.getProperty("java.vendor");
- StringBuilder sb = new StringBuilder()
- .append("\n")
- .append(getString(R.string.os_line, osName, osArch, osVer))
- .append("\n")
- .append(getString(R.string.java_line, javaVer, javaVendor));
- return sb.toString();
- }
-
- /**
- * Gets the mobile device related properties.
- *
- * @return a string about location, network type (MOBILE or WIFI)
- */
- private String getMobileProperty() {
- StringBuilder sb = new StringBuilder();
- if (ndtLocation.location != null) {
- Log.v(Constants.LOG_TAG, ndtLocation.location.toString());
- sb.append(getString(R.string.latitude_result, ndtLocation.location.getLatitude()))
- .append("\n")
- .append(getString(R.string.longitude_result, ndtLocation.location.getLongitude()));
- }
- if (networkInfo != null) {
- Log.v(Constants.LOG_TAG, networkInfo.toString());
- sb.append("\n")
- .append(getString(R.string.network_type_indicator, networkInfo.getTypeName()));
- }
- return sb.toString();
- }
-
- /**
- * Initializes the components on main view.
- */
- private void initComponents() {
- buttonStart = (Button) findViewById(R.id.ButtonStart);
- buttonStart.setOnClickListener(new StartButtonListener());
- buttonAbout = (Button) findViewById(R.id.ButtonAbout);
- buttonAbout.setOnClickListener(new AboutButtonListener(this));
- buttonOption = (Button) findViewById(R.id.ButtonOption);
- buttonOption.setOnClickListener(new OptionButtonListener());
- buttonStatistics = (Button) findViewById(R.id.ButtonStatistics);
- buttonStatistics.setOnClickListener(new StatisticsButtonListener());
- buttonStatistics.setEnabled(false);
- progressBar = (ProgressBar) findViewById(R.id.ProgressBar);
- progressBar.setVisibility(View.INVISIBLE);
- progressBar.setIndeterminate(false);
- }
-
- /**
- * Gets the type of the active network, networkInfo should be initialized before called this function.
- *
- * @return a string to describe user's network
- * @see NdtTests#NETWORK_WIFI
- * @see NdtTests#NETWORK_MOBILE
- * @see NdtTests#NETWORK_WIRED
- * @see NdtTests#NETWORK_UNKNOWN
- */
- private String getNetworkType() {
- if (networkInfo != null) {
- int networkType = networkInfo.getType();
- switch (networkType) {
- case ConnectivityManager.TYPE_MOBILE:
- return NdtTests.NETWORK_MOBILE;
- case ConnectivityManager.TYPE_WIFI:
- return NdtTests.NETWORK_WIFI;
- default:
- return NdtTests.NETWORK_UNKNOWN;
- }
- } else {
- return NdtTests.NETWORK_UNKNOWN;
- }
- }
-
- public class UiHandler extends Handler {
- public UiHandler(Looper looper) {
- super(looper);
- }
-
- @Override
- public void handleMessage(Message message) {
- switch (message.what) {
- case Constants.THREAD_MAIN_APPEND:
- textViewMain.append(message.obj.toString());
- break;
- case Constants.THREAD_STAT_APPEND:
- statistics += message.obj.toString();
- break;
- case Constants.THREAD_BEGIN_TEST:
- Log.v(Constants.LOG_TAG, "Begin the test");
- progress = 0;
- buttonStart.setEnabled(false);
- buttonAbout.setEnabled(false);
- buttonStatistics.setEnabled(false);
- buttonOption.setEnabled(false);
- progressBar.setVisibility(View.VISIBLE);
- progressBar.setProgress(progress);
- progressBar.setMax(UiServices.TEST_STEPS);
- if (wakeLock.isHeld() == false) {
- wakeLock.acquire();
- Log.v(Constants.LOG_TAG, "wakeLock acquired");
- }
- break;
- case Constants.THREAD_END_TEST:
- Log.v(Constants.LOG_TAG, "End the test");
- textViewMain.append("\n" + getString(R.string.test_again) + "\n");
- statistics += "\n";
- buttonStart.setEnabled(true);
- buttonAbout.setEnabled(true);
- buttonStatistics.setEnabled(true);
- buttonOption.setEnabled(true);
- progressBar.setVisibility(View.INVISIBLE);
- if (wakeLock.isHeld()) {
- wakeLock.release();
- Log.v(Constants.LOG_TAG, "wakeLock released");
- }
- break;
- case Constants.THREAD_ADD_PROGRESS:
- progressBar.setProgress(progressBar.getProgress() + 1);
- break;
- }
- }
- }
-}
+}
=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/Constants.java Fri Jun 24 10:53:15 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/Constants.java Tue Aug 23 13:36:59 2011
@@ -3,63 +3,48 @@
package net.measurementlab.ndt;
/**
- * Definition for constant values used in ndt mobile.
+ * Definition for constant values used in NDT mobile.
*/
-public class Constants {
- /**
- * Maximum test steps for ProgressBar setting.
- */
- public static final int TEST_STEPS = 7;
-
- /**
- * TAG constant for logging.
- */
- public static final String LOG_TAG = "NDT";
-
- // Messages submitted from working thread to UI
- public static final int THREAD_MAIN_APPEND = 0;
- public static final int THREAD_STAT_APPEND = 1;
- public static final int THREAD_BEGIN_TEST = 2;
- public static final int THREAD_END_TEST = 3;
- public static final int THREAD_ADD_PROGRESS = 4;
-
- // ID of Activities
- public static final int ACTIVITY_OPTION = 0;
- public static final int ACTIVITY_STATISTICS = 1;
-
- // Intents ID
- public static final String SERVER_LOCATION = "net.measurementlab.ndt.ServerLocation";
- public static final String INTENT_SERVER_NO = "serverno";
- public static final String INTENT_STATISTICS = "statistics";
- public static final String INTENT_LOCATION = "location";
- public static final String INTENT_NETWORK = "network";
-
- // Options
- // See newest server list here: http://www.measurementlab.net/measurement-lab-tools#ndt
- // All the data here should be kept sync with the published list
- // In future server list should be downloaded from some list servers dynamically.
- public static final int DEFAULT_SERVER = 0;
- public static final String SERVER_NAME[] =
- {"Closest Server (DONAR)", "Mountain View, California", "Los Angeles, California", "Seattle, Washington",
- "Dallas, Texas", "Chicago, Illinois", "Atlanta, Georgia", "Miami, Florida",
- "New York City, New York #1", "New York City, New York #2", "London, United Kingdom",
- "Paris, France", "Amsterdam, The Netherlands #1", "Athens, Greece", "Sydney, Australia"};
- public static final String SERVER_HOST[] =
- {"ndt.iupui.donar.measurement-lab.org",
- "ndt.iupui.nuq01.measurement-lab.org",
"ndt.iupui.lax01.measurement-lab.org",
- "ndt.iupui.sea01.measurement-lab.org",
"ndt.iupui.dfw01.measurement-lab.org",
- "ndt.iupui.ord01.measurement-lab.org",
"ndt.iupui.atl01.measurement-lab.org",
- "ndt.iupui.mia01.measurement-lab.org",
"ndt.iupui.lga01.measurement-lab.org",
- "ndt.iupui.lga02.measurement-lab.org",
"ndt.iupui.lhr01.measurement-lab.org",
- "ndt.iupui.par01.measurement-lab.org",
"ndt.iupui.ams01.measurement-lab.org",
- "ndt.iupui.ath01.measurement-lab.org",
"ndt.iupui.syd01.measurement-lab.org"};
-
- /**
- * Number of servers. All the arrays should have the same length.
- */
- public static final int NUMBER_OF_SERVERS = SERVER_NAME.length;
-
- private Constants() {
- // private constructor to make sure it can't be instantiated
- }
-}
+interface Constants {
+
+ /**
+ * TAG constant for logging.
+ */
+ static final String LOG_TAG = "NDT";
+
+ // Options
+ // See newest server list here:
+ // http://www.measurementlab.net/measurement-lab-tools#ndt
+ // All the data here should be kept sync with the published list
+ // In future server list should be downloaded from some list servers
+ // dynamically.
+ public static final int DEFAULT_SERVER = 0;
+ public static final String SERVER_NAME[] = { "Closest Server (DONAR)",
+ "Mountain View, California", "Los Angeles,
California",
+ "Seattle, Washington", "Dallas, Texas", "Chicago,
Illinois",
+ "Atlanta, Georgia", "Miami, Florida", "New York City, New
York #1",
+ "New York City, New York #2", "London, United
Kingdom",
+ "Paris, France", "Amsterdam, The Netherlands #1", "Athens,
Greece",
+ "Sydney, Australia" };
+ public static final String SERVER_HOST[] = {
+ "ndt.iupui.donar.measurement-lab.org",
+ "ndt.iupui.nuq01.measurement-lab.org",
+ "ndt.iupui.lax01.measurement-lab.org",
+ "ndt.iupui.sea01.measurement-lab.org",
+ "ndt.iupui.dfw01.measurement-lab.org",
+ "ndt.iupui.ord01.measurement-lab.org",
+ "ndt.iupui.atl01.measurement-lab.org",
+ "ndt.iupui.mia01.measurement-lab.org",
+ "ndt.iupui.lga01.measurement-lab.org",
+ "ndt.iupui.lga02.measurement-lab.org",
+ "ndt.iupui.lhr01.measurement-lab.org",
+ "ndt.iupui.par01.measurement-lab.org",
+ "ndt.iupui.ams01.measurement-lab.org",
+ "ndt.iupui.ath01.measurement-lab.org",
+ "ndt.iupui.syd01.measurement-lab.org" };
+
+ /**
+ * Number of servers. All the arrays should have the same length.
+ */
+ public static final int NUMBER_OF_SERVERS = SERVER_NAME.length;
+}
=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/InitialActivity.java Tue Aug 23 08:23:47 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/InitialActivity.java Tue Aug 23 13:36:59 2011
@@ -4,14 +4,12 @@
import android.app.Activity;
import android.content.Intent;
-import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
-import android.widget.TextView;
/**
* UI Thread and Entry Point of NDT mobile client.
@@ -26,10 +24,7 @@
super.onCreate(savedInstanceState);
setContentView(R.layout.initial);
Log.i("ndt", "Loaded!");
- Typeface typeFace = Typeface.createFromAsset(getAssets(),
- "fonts/League_Gothic.otf");
- TextView textView = (TextView) findViewById(R.id.MLabDesc);
- textView.setTypeface(typeFace);
+ NdtSupport.applyFont(this, "fonts/League_Gothic.otf",
R.id.MLabDesc);
Button startButton = (Button) findViewById(R.id.ButtonStart);
startButton.setOnClickListener(new OnClickListener() {
=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/NdtService.java Tue Aug 16 11:38:31 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/NdtService.java Tue Aug 23 13:36:59 2011
@@ -14,26 +14,81 @@
import android.os.IBinder;
import android.util.Log;
+/**
+ * Background service that drives the NDT test protocol and broadcasts updates
+ * to indicated when the @see {@link TestsActivity} should change to reflect
+ * progress to the next user visible test.
+ *
+ * @author
+ *
+ */
public class NdtService extends Service {
+ // log tag so logcat can be filtered to just the variable
+ // written out by the core NDT Java code, useful for understanding
+ // what is available for display in the test results
private static final String VARS_TAG = "variables";
-
- static final int PREPARING = 0;
- static final int UPLOADING = 1;
- static final int DOWNLOADING = 2;
- static final int COMPLETE = 3;
-
+
+ // user visible test phases, more coarse than actual tests
+ /**
+ * Includes middle box and SFW testing.
+ */
+ static final int STATUS_PREPARING = 0;
+ /**
+ * Client to server test.
+ */
+ static final int STATUS_UPLOADING = 1;
+ /**
+ * Server to client and meta test.
+ */
+ static final int STATUS_DOWNLOADING = 2;
+ /**
+ * Indicates tests are concluded.
+ */
+ static final int STATUS_COMPLETE = 3;
+ /**
+ * Indicates the service encountered an error.
+ */
+ static final int STATUS_ERROR = 4;
+
+ /**
+ * Intent for sending updates from this service to trigger display
changes
+ * in @link
{@link
TestsActivity}.
+ */
static final String INTENT_UPDATE_STATUS = "net.measurementlab.ndt.UpdateStatus";
+ /**
+ * Intent for @link {@link TestsActivity} to request that this service stop
+ * testing.
+ */
static final String INTENT_STOP_TESTS = "net.measurementlab.ndt.StopTests";
-
+
+ /**
+ * Label for extra data in
{@link
Intent} sent for test status updates.
+ */
static final String EXTRA_STATUS = "status";
+
+ /**
+ * Label for extra data about network type in
{@link
Intent} sent from
+ *
{@link
InitialActivity}.
+ */
+ static final String EXTRA_NETWORK_TYPE = "networkType";
+
+ /**
+ * Status line used for the advanced display.
+ */
+ static final String EXTRA_DIAG_STATUS = "diagnosticStatus";
+
+ /**
+ * Label for variables captured during testing and used in
presentation of
+ * results in
{@link
ResultsActivity}.
+ */
static final String EXTRA_VARS = VARS_TAG;
-
+
private Intent intent;
-
+
private String networkType;
-
+
private CaptiveUiServices uiServices;
-
+
private BroadcastReceiver stopReceiver;
@Override
@@ -52,15 +107,24 @@
public void onStart(Intent intent, int startId) {
Log.i(LOG_TAG, "Starting NDT service.");
super.onStart(intent, startId);
+
+ // this means the service is already started
if (uiServices != null) {
return;
}
+
if (null != intent) {
- networkType = intent.getStringExtra("networkType");
- }
+ networkType =
intent.getStringExtra(EXTRA_NETWORK_TYPE);
+ }
+
+ // listen to a broadcast from TestActivity requesting that
+ // tests be stopped
stopReceiver = createReceiver();
registerReceiver(stopReceiver, new IntentFilter(
NdtService.INTENT_STOP_TESTS));
+
+ // this interface is how the service is able to observe the
+ // tests as run by the core Java client code
uiServices = new CaptiveUiServices();
try {
new Thread(new NdtTests(
@@ -68,13 +132,15 @@
uiServices, networkType)).start();
} catch (Throwable tr) {
Log.e(LOG_TAG, "Problem running tests.", tr);
+ intent.putExtra(EXTRA_STATUS, STATUS_ERROR);
}
}
-
+
@Override
public void onDestroy() {
super.onDestroy();
- if (COMPLETE != uiServices.status) {
+ if (STATUS_COMPLETE != uiServices.status
+ && STATUS_ERROR != uiServices.status) {
uiServices.requestStop();
}
uiServices = null;
@@ -97,77 +163,132 @@
}
private class CaptiveUiServices implements UiServices {
+ private final Map<Integer, StringBuilder> statusBuffers = new HashMap<Integer, StringBuilder>();
+
+ // sub-string that identifies the message marking start of
upload
+ // testing
+ private static final String S2C_MSG_FRAGMENT =
"server-to-client";
+
+ // sub-string that identifies the message marking start of
download
+ // testing
+ private static final String C2S_MSG_FRAGMENT =
"client-to-server";
+
private boolean wantToStop = false;
-
- int status = PREPARING;
-
+
+ int status = STATUS_PREPARING;
+
private Map<String, Object> variables = new HashMap<String,
Object>();
-
+
+ CaptiveUiServices() {
+ // not needed now but may be useful in the future
+// statusBuffers.put(UiServices.MAIN_VIEW, new
StringBuilder());
+// statusBuffers.put(UiServices.STAT_VIEW, new
StringBuilder());
+ statusBuffers.put(UiServices.DIAG_VIEW, new
StringBuilder());
+ }
+
+ /**
+ *
{@inheritDoc}
+ */
@Override
- public void appendString(String str, int viewId) {
- Log.d(LOG_TAG, String.format("Appended: (%1$d)
%2$s.", viewId, str
- .trim()));
-
- if (str.contains("client-to-server") && 0 == viewId) {
+ public void appendString(String message, int viewId) {
+ Log.d(LOG_TAG, String.format("Appended: (%1$d)
%2$s.", viewId,
+ message.trim()));
+
+ if (statusBuffers.containsKey(viewId)) {
+
statusBuffers.get(viewId).append(message).append('\n');
+ }
+
+ if (message.contains(C2S_MSG_FRAGMENT)
+ && UiServices.MAIN_VIEW == viewId) {
Log.i(LOG_TAG, "Starting upload test.");
- intent.putExtra(EXTRA_STATUS, UPLOADING);
+ intent.putExtra(EXTRA_STATUS,
STATUS_UPLOADING);
sendBroadcast(intent);
- status = UPLOADING;
+ status = STATUS_UPLOADING;
Log.i(LOG_TAG, "Broadcast status change.");
}
- if (str.contains("server-to-client") && 0 == viewId) {
+ if (message.contains(S2C_MSG_FRAGMENT)
+ && UiServices.MAIN_VIEW == viewId) {
Log.i(LOG_TAG, "Starting download test.");
- intent.putExtra(EXTRA_STATUS, DOWNLOADING);
+ intent.putExtra(EXTRA_STATUS,
STATUS_DOWNLOADING);
sendBroadcast(intent);
- status = DOWNLOADING;
+ status = STATUS_DOWNLOADING;
Log.i(LOG_TAG, "Broadcast status change.");
}
}
+ /**
+ *
{@inheritDoc}
+ */
@Override
public void incrementProgress() {
Log.d(LOG_TAG, "Incremented progress.");
}
+ /**
+ *
{@inheritDoc}
+ */
@Override
public void logError(String str) {
Log.e(LOG_TAG, String.format("Error: %1$s.",
str.trim()));
}
+ /**
+ *
{@inheritDoc}
+ */
@Override
public void onBeginTest() {
Log.d(LOG_TAG, "Test begun.");
wantToStop = false;
}
+ /**
+ *
{@inheritDoc}
+ */
@Override
public void onEndTest() {
Log.d(LOG_TAG, "Test ended.");
- intent.putExtra(EXTRA_STATUS, COMPLETE);
+ intent.putExtra(EXTRA_STATUS, STATUS_COMPLETE);
+ intent.putExtra(EXTRA_DIAG_STATUS, statusBuffers.get(
+ UiServices.DIAG_VIEW).toString());
intent.putExtra(EXTRA_VARS, (Serializable) variables);
sendBroadcast(intent);
+ status = STATUS_COMPLETE;
wantToStop = false;
- status = COMPLETE;
Log.i(LOG_TAG, "Broadcast status change.");
}
+ /**
+ *
{@inheritDoc}
+ */
@Override
public void onFailure(String errorMessage) {
Log.d(LOG_TAG, String.format("Failed: %1$s.",
errorMessage));
+ intent.putExtra(EXTRA_STATUS, STATUS_ERROR);
+ sendBroadcast(intent);
+ status = STATUS_ERROR;
wantToStop = false;
}
+ /**
+ *
{@inheritDoc}
+ */
@Override
public void onLoginSent() {
Log.d(LOG_TAG, "Login sent.");
}
+ /**
+ *
{@inheritDoc}
+ */
@Override
public void onPacketQueuingDetected() {
Log.d(LOG_TAG, "Packet queuing detected.");
}
+ /**
+ *
{@inheritDoc}
+ */
@Override
public void setVariable(String name, int value) {
Log.d(VARS_TAG, String.format(
@@ -175,6 +296,9 @@
variables.put(name, value);
}
+ /**
+ *
{@inheritDoc}
+ */
@Override
public void setVariable(String name, double value) {
Log.d(VARS_TAG, String.format(
@@ -182,6 +306,9 @@
variables.put(name, value);
}
+ /**
+ *
{@inheritDoc}
+ */
@Override
public void setVariable(String name, Object value) {
Log.d(VARS_TAG, String.format(
@@ -190,21 +317,35 @@
variables.put(name, value);
}
+ /**
+ *
{@inheritDoc}
+ */
@Override
public void updateStatus(String status) {
Log.d(LOG_TAG, String.format("Updating status:
%1$s.", status));
}
+ /**
+ *
{@inheritDoc}
+ */
@Override
public void updateStatusPanel(String status) {
- Log.d(LOG_TAG, String.format("Updating status panel:
%1$s.", status));
+ Log.d(LOG_TAG, String
+ .format("Updating status panel:
%1$s.", status));
}
+ /**
+ *
{@inheritDoc}
+ */
@Override
public boolean wantToStop() {
return wantToStop;
}
+ /**
+ * Allows the containing service instance to request the
blackbox from
+ * the core NDT Java code stop testing.
+ */
void requestStop() {
wantToStop = true;
}
=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/ResultsActivity.java Tue Aug 23 08:23:47 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/ResultsActivity.java Tue Aug 23 13:36:59 2011
@@ -1,66 +1,65 @@
package net.measurementlab.ndt;
import java.text.DecimalFormat;
-import java.text.MessageFormat;
+import java.util.LinkedList;
+import java.util.List;
import java.util.Map;
import android.app.Activity;
import android.content.Intent;
-import android.graphics.Typeface;
import android.net.Uri;
import android.os.Bundle;
+import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
-
+import android.widget.Toast;
+
+/**
+ * Activity to display the results of the testing, including summary, detailed
+ * and expert views.
+ *
+ * @author
+ *
+ */
public class ResultsActivity extends Activity {
+ /**
+ *
{@inheritDoc}
+ */
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.results);
- Typeface typeFace = Typeface.createFromAsset(getAssets(), "fonts/League_Gothic.otf");
- TextView textView = (TextView)
findViewById(R.id.ResultsHeader);
- textView.setTypeface(typeFace);
-
- textView = (TextView) findViewById(R.id.UploadSpeedHeader);
- textView.setTypeface(typeFace);
- textView = (TextView) findViewById(R.id.UploadSpeed);
- textView.setTypeface(typeFace);
- textView = (TextView) findViewById(R.id.UploadSpeedMbps);
- textView.setTypeface(typeFace);
-
- textView = (TextView) findViewById(R.id.DownloadSpeedHeader);
- textView.setTypeface(typeFace);
- textView = (TextView) findViewById(R.id.DownloadSpeed);
- textView.setTypeface(typeFace);
- textView = (TextView) findViewById(R.id.DownloadSpeedMbps);
- textView.setTypeface(typeFace);
-
- textView = (TextView)
findViewById(R.id.DetailedResultsHeader);
- textView.setTypeface(typeFace);
-
- textView = (TextView)
findViewById(R.id.AdvancedResultsHeader);
- textView.setTypeface(typeFace);
-
- textView = (TextView) findViewById(R.id.MoreInfo);
- textView.setTypeface(typeFace);
+ // surprising that typeface cannot be set in styles.xml or
+ // even in the respective layout .xml file
+ NdtSupport.applyFont(this, R.id.ResultsHeader);
+ NdtSupport.applyFont(this, R.id.UploadSpeedHeader,
R.id.UploadSpeed,
+ R.id.UploadSpeedMbps);
+ NdtSupport.applyFont(this, R.id.DownloadSpeedHeader,
+ R.id.DownloadSpeed, R.id.DownloadSpeedMbps);
+ NdtSupport.applyFont(this, R.id.DetailedResultsHeader,
+ R.id.DetailedResultsInfo);
+ NdtSupport.applyFont(this, R.id.AdvancedResultsHeader,
+ R.id.AdvancedResultsInfo);
+ NdtSupport.applyFont(this, R.id.MoreInfo);
OnClickListener aboutListener = new OnClickListener() {
@Override
public void onClick(View v) {
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://measurementlab.net"));
+ Intent intent = new
Intent(Intent.ACTION_VIEW, Uri
+
.parse("http://measurementlab.net"));
startActivity(intent);
}
};
+
View aboutView = findViewById(R.id.MoreInfo);
aboutView.setOnClickListener(aboutListener);
aboutView = findViewById(R.id.MLabLogo);
aboutView.setOnClickListener(aboutListener);
-
Button startButton = (Button) findViewById(R.id.ButtonStart);
startButton.setOnClickListener(new OnClickListener() {
@@ -73,13 +72,26 @@
}
});
}
-
+
+ /**
+ *
{@inheritDoc}
+ */
@SuppressWarnings("unchecked")
@Override
protected void onResume() {
super.onResume();
- Map<String,Object> variables = (Map<String,Object>) getIntent().getSerializableExtra(NdtService.EXTRA_VARS);
-
+ Map<String, Object> variables = (Map<String, Object>)
getIntent()
+ .getSerializableExtra(NdtService.EXTRA_VARS);
+ formatSummaryResults(variables);
+ formatDetailedResults(variables);
+ formatAdvancedResults(getIntent().getStringExtra(
+ NdtService.EXTRA_DIAG_STATUS));
+
+ Toast resultsHint = Toast.makeText(getApplicationContext(), getString(R.string.results_swipe_hint), 10);
+ resultsHint.show();
+ }
+
+ private void formatSummaryResults(Map<String, Object> variables) {
DecimalFormat format = (DecimalFormat)
DecimalFormat.getInstance();
format.setMaximumFractionDigits(2);
@@ -90,21 +102,68 @@
Double downloadSpeed = (Double) variables.get("pub_s2cspd");
textView = (TextView) findViewById(R.id.DownloadSpeed);
textView.setText(format.format(downloadSpeed));
-
+
Integer maxRtt = (Integer) variables.get("pub_MaxRTT");
Integer minRtt = (Integer) variables.get("pub_MinRTT");
Double avgRtt = (Double) variables.get("pub_avgrtt");
-
- String latency =
getResources().getString(R.string.results_latency);
- latency = MessageFormat.format(latency, (int)(double)avgRtt);
-
+ variables.put("pub_jitter", maxRtt - minRtt);
+
+ String latency = getString(R.string.results_latency,
Math.round(avgRtt));
textView = (TextView) findViewById(R.id.Latency);
textView.setText(latency);
-
- String jitter =
getResources().getString(R.string.results_jitter);
- jitter = MessageFormat.format(jitter, maxRtt - minRtt);
-
+
+ String jitter = getString(R.string.results_jitter, maxRtt -
minRtt);
textView = (TextView) findViewById(R.id.Jitter);
textView.setText(jitter);
}
-}
+
+ private void formatDetailedResults(Map<String, Object> variables) {
+ StringBuilder results = new StringBuilder();
+
results.append(formatDetailedLine(R.string.results_detailed_system,
+ variables, "pub_osName", "pub_osVer",
"pub_javaVer",
+ "pub_osArch"));
+ results.append('\n');
+
+
results.append(formatDetailedLine(R.string.results_detailed_tcp,
+ variables, "pub_CurRwinRcvd",
"pub_MaxRwinRcvd"));
+ results.append(formatDetailedLine(
+ R.string.results_detailed_packet_loss, variables,
"pub_loss"));
+
results.append(formatDetailedLine(R.string.results_detailed_rtt,
+ variables, "pub_MinRTT", "pub_MaxRTT",
"pub_avgrtt"));
+
results.append(formatDetailedLine(R.string.results_detailed_jitter,
+ variables, "pub_jitter"));
+ Integer curRTO = (Integer) variables.get("pub_CurRTO");
+ Integer timeouts = (Integer) variables.get("pub_Timeouts");
+ if (null == timeouts) {
+ timeouts = 0;
+ }
+ Integer waitSec = (curRTO * timeouts)/1000;
+ variables.put("pub_WaitSec", waitSec);
+
results.append(formatDetailedLine(R.string.results_detailed_timeout,
+ variables, "pub_WaitSec", "pub_CurRTO"));
+
results.append(formatDetailedLine(R.string.results_detailed_ack,
+ variables, "pub_SACKsRcvd"));
+
+ TextView textView = (TextView)
findViewById(R.id.DetailedResultsInfo);
+ textView.setText(results);
+ }
+
+ private void formatAdvancedResults(String diagnosticStatus) {
+ String advanced = getString(R.string.results_advanced_web100,
+ diagnosticStatus);
+ Log.i(Constants.LOG_TAG, diagnosticStatus);
+ TextView textView = (TextView)
findViewById(R.id.AdvancedResultsInfo);
+ textView.setText(advanced);
+ }
+
+ private String formatDetailedLine(int templateId,
+ Map<String, Object> variables, String... paramKeys) {
+ List<Object> params = new LinkedList<Object>();
+ for (String paramKey : paramKeys) {
+ params.add(variables.get(paramKey));
+ }
+ String message = getString(templateId, params.toArray(new
Object[params
+ .size()]));
+ return message.concat("\n");
+ }
+}
=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/Statistics.java Wed Jun 9 15:23:05 2010
+++ /branches/android/Android/src/net/measurementlab/ndt/Statistics.java Tue Aug 23 13:36:59 2011
@@ -11,7 +11,6 @@
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
-import android.widget.Toast;
/**
* Shows the testing report to the user, email application also could be called here.
@@ -30,22 +29,10 @@
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
- setContentView(R.layout.stats);
- Bundle statsInfo = getIntent().getExtras();
date = new Date();
- buttonEmail = (Button) findViewById(R.id.ButtonEmail);
+ buttonEmail = null;
buttonEmail.setOnClickListener(this);
- if (statsInfo != null) {
- statistics = statsInfo.getString(Constants.INTENT_STATISTICS);
- location = statsInfo.getString(Constants.INTENT_LOCATION);
- network = statsInfo.getString(Constants.INTENT_NETWORK);
- } else {
- Toast toast =
- Toast.makeText(getApplicationContext(), R.string.intent_error, Toast.LENGTH_SHORT);
- toast.show();
- finish();
- }
- textViewStatistics = (TextView) findViewById(R.id.TextViewStatistics);
+ textViewStatistics = null;
textViewStatistics.setText(statistics);
}
=======================================
--- /branches/android/Android/src/net/measurementlab/ndt/TestsActivity.java Tue Aug 16 13:12:16 2011
+++ /branches/android/Android/src/net/measurementlab/ndt/TestsActivity.java Tue Aug 23 13:36:59 2011
@@ -142,18 +142,18 @@
@Override
public void onReceive(Context context, Intent intent)
{
Log.i(LOG_TAG, "Status change received.");
- int status = intent.getIntExtra(NdtService.EXTRA_STATUS, NdtService.PREPARING);
+ int status = intent.getIntExtra(NdtService.EXTRA_STATUS, NdtService.STATUS_PREPARING);
switch (status) {
- case NdtService.PREPARING:
+ case NdtService.STATUS_PREPARING:
preparing();
break;
- case NdtService.UPLOADING:
+ case NdtService.STATUS_UPLOADING:
uploading();
break;
- case NdtService.DOWNLOADING:
+ case NdtService.STATUS_DOWNLOADING:
downloading();
break;
- case NdtService.COMPLETE:
+ case NdtService.STATUS_COMPLETE:
complete(intent);
break;
default:
=======================================
--- /branches/android/java/net/measurementlab/ndt/NdtTests.java Fri Jun 10 09:17:33 2011
+++ /branches/android/java/net/measurementlab/ndt/NdtTests.java Tue Aug 23 13:36:59 2011
@@ -67,7 +67,7 @@
import java.util.*;
public class NdtTests implements Runnable {
- public static final String VERSION = "3.6.3";
+ public static final String VERSION = "3.6.4";
// Network (physical layer) types
public static final String NETWORK_WIFI = "WIFI";
- [ndt-dev] [ndt] r517 committed - Fill in more of detailed results, re-factor to better de-compose., ndt, 08/23/2011
Archive powered by MHonArc 2.6.16.