Skip to Content.
Sympa Menu

ndt-dev - [ndt] r346 committed - adding the 'SamKnows' patch to Tcpbw100.java to the repo. We will be ...

Subject: NDT-DEV email list created

List archive

[ndt] r346 committed - adding the 'SamKnows' patch to Tcpbw100.java to the repo. We will be ...


Chronological Thread 
  • From:
  • To:
  • Subject: [ndt] r346 committed - adding the 'SamKnows' patch to Tcpbw100.java to the repo. We will be ...
  • Date: Wed, 14 Apr 2010 15:15:37 +0000

Revision: 346
Author: jwzurawski
Date: Wed Apr 14 08:15:20 2010
Log: adding the 'SamKnows' patch to Tcpbw100.java to the repo. We will be
sorting out how to apply this at a later date.

-jason


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

Added:
/trunk/contrib/samknows.patch

=======================================
--- /dev/null
+++ /trunk/contrib/samknows.patch Wed Apr 14 08:15:20 2010
@@ -0,0 +1,4860 @@
+--- Tcpbw100.java 2010-03-01 22:51:48.000000000 +0000
++++ /tmp/Tcpbw100.java 2010-04-14 13:11:05.000000000 +0100
+@@ -59,2365 +59,2567 @@
+ The Software was developed at least in part by the University of Chicago,
+ as Operator of Argonne National Laboratory (http://miranda.ctd.anl.gov:7123/).
+ */
+-import java.io.*;
+-import java.net.*;
+-import java.net.Socket;
++
++import skin.Interface;
++import skin.control.MyTextPane;
++import skin.control.SkinPanel;
++
++import javax.swing.*;
++import javax.swing.text.BadLocationException;
+ import java.awt.*;
++import java.awt.datatransfer.Clipboard;
++import java.awt.datatransfer.StringSelection;
+ import java.awt.event.*;
+-import java.awt.event.ActionListener;
+-import java.awt.event.ActionEvent;
+-import java.awt.datatransfer.*;
+-import java.applet.*;
+-import java.util.*;
+-import java.text.*;
+-import java.lang.*;
+-import javax.swing.JLabel;
+-import javax.swing.JApplet;
+-import javax.swing.JFrame;
+-import javax.swing.JTextArea;
+-import javax.swing.JButton;
+-import javax.swing.JCheckBox;
+-import javax.swing.JPanel;
+-import javax.swing.JScrollPane;
+-import javax.swing.BorderFactory;
+-import javax.swing.JTextPane;
+-import javax.swing.text.StyledDocument;
+-import javax.swing.text.DefaultStyledDocument;
+-import javax.swing.text.BadLocationException;
+-import javax.swing.JOptionPane;
+-import javax.swing.BoxLayout;
+-import javax.swing.JSpinner;
+-import javax.swing.SpinnerNumberModel;
+-import javax.swing.JComboBox;
+-import javax.swing.JProgressBar;
+-
+-public class Tcpbw100 extends JApplet implements ActionListener
+-{
+- private static final String VERSION = "3.6.1";
+- private static final byte TEST_MID = (1 << 0);
+- private static final byte TEST_C2S = (1 << 1);
+- private static final byte TEST_S2C = (1 << 2);
+- private static final byte TEST_SFW = (1 << 3);
+- private static final byte TEST_STATUS = (1 << 4);
+-
+- /* we really should do some clean-up in this java code... maybe later ;) */
+- private static final byte COMM_FAILURE = 0;
+- private static final byte SRV_QUEUE = 1;
+- private static final byte MSG_LOGIN = 2;
+- private static final byte TEST_PREPARE = 3;
+- private static final byte TEST_START = 4;
+- private static final byte TEST_MSG = 5;
+- private static final byte TEST_FINALIZE = 6;
+- private static final byte MSG_ERROR = 7;
+- private static final byte MSG_RESULTS = 8;
+- private static final byte MSG_LOGOUT = 9;
+- private static final byte MSG_WAITING = 10;
+-
+- private static final int SFW_NOTTESTED = 0;
+- private static final int SFW_NOFIREWALL = 1;
+- private static final int SFW_UNKNOWN = 2;
+- private static final int SFW_POSSIBLE = 3;
+-
+- private static final double VIEW_DIFF = 0.1;
+-
+- JTextArea diagnosis, statistics;
+- MyTextPane results;
+- String inresult, outresult, errmsg;
+- JButton startTest;
+- JButton disMiss, disMiss2;
+- JButton copy, copy2;
+- JButton deTails;
+- JButton sTatistics;
+- JButton mailTo;
+- JButton options;
+- JCheckBox defaultTest = new JCheckBox("Default tests"),
++import java.io.*;
++import java.net.*;
++import java.util.Random;
++import java.util.StringTokenizer;
++
++public class Tcpbw100 extends JApplet implements ActionListener {
++ private static final String VERSION = "3.6.1";
++ private static final byte TEST_MID = (1 << 0);
++ private static final byte TEST_C2S = (1 << 1);
++ private static final byte TEST_S2C = (1 << 2);
++ private static final byte TEST_SFW = (1 << 3);
++ private static final byte TEST_STATUS = (1 << 4);
++
++ /* we really should do some clean-up in this java code... maybe later ;) */
++ private static final byte COMM_FAILURE = 0;
++ private static final byte SRV_QUEUE = 1;
++ private static final byte MSG_LOGIN = 2;
++ private static final byte TEST_PREPARE = 3;
++ private static final byte TEST_START = 4;
++ private static final byte TEST_MSG = 5;
++ private static final byte TEST_FINALIZE = 6;
++ private static final byte MSG_ERROR = 7;
++ private static final byte MSG_RESULTS = 8;
++ private static final byte MSG_LOGOUT = 9;
++ private static final byte MSG_WAITING = 10;
++
++ private static final int SFW_NOTTESTED = 0;
++ private static final int SFW_NOFIREWALL = 1;
++ private static final int SFW_UNKNOWN = 2;
++ private static final int SFW_POSSIBLE = 3;
++
++ private static final double VIEW_DIFF = 0.1;
++
++ JTextArea diagnosis, statistics;
++ MyTextPane results;
++ String inresult, outresult, errmsg;
++ JButton startTest;
++
++ // BEGIN by prv
++ JButton stopTest;
++ // END by prv
++
++ JButton disMiss, disMiss2;
++ JButton copy, copy2;
++ JButton deTails;
++ JButton sTatistics;
++ JButton mailTo;
++ JButton options;
++ JCheckBox defaultTest = new JCheckBox("Default tests"),
+ preferIPv6 = new JCheckBox("prefer IPv6");
+- JSpinner numOfTests = new JSpinner();
+- String[] delays = { "immediate", "1 min", "5 mins", "10 mins", "30 mins", "2 hours", "12 hours", "1 day" };
+- JComboBox delay = new JComboBox(delays);
+-
+- boolean Randomize, failed, cancopy;
+- URL location;
+- clsFrame f, ff, optionsFrame;
+- String s;
+- double t;
+- int ECNEnabled, NagleEnabled, MSSSent, MSSRcvd;
+- int SACKEnabled, TimestampsEnabled, WinScaleRcvd, WinScaleSent;
+- int FastRetran, AckPktsOut, SmoothedRTT, CurrentCwnd, MaxCwnd;
+- int SndLimTimeRwin, SndLimTimeCwnd, SndLimTimeSender;
+- int SndLimTransRwin, SndLimTransCwnd, SndLimTransSender, MaxSsthresh;
+- int SumRTT, CountRTT, CurrentMSS, Timeouts, PktsRetrans;
+- int SACKsRcvd, DupAcksIn, MaxRwinRcvd, MaxRwinSent;
+- int DataPktsOut, Rcvbuf, Sndbuf, AckPktsIn, DataBytesOut;
+- int PktsOut, CongestionSignals, RcvWinScale;
+- int pkts, lth=8192, CurrentRTO;
+- int c2sData, c2sAck, s2cData, s2cAck;
+- // added for mailto url
+- protected URL targetURL;
+- private String TARGET1 = "U";
+- private String TARGET2 = "H";
+- String emailText;
+- double s2cspd, c2sspd, sc2sspd, ss2cspd;
+- int ssndqueue;
+- double sbytes;
+-
+- /*************************************************************************
+- * Added by Seth Peery
+- * Adds public variables to store upstream and downstream speeds in kbps
+- */
+- public String downstream = "No data";
+- public String upstream = "No data";
+- /************************************************************************/
+-
+-
+- int half_duplex, congestion, bad_cable, mismatch;
+- double mylink;
+- double loss, estimate, avgrtt, spd, waitsec, timesec, rttsec;
+- double order, rwintime, sendtime, cwndtime, rwin, swin, cwin;
+- double aspd;
+-
+- boolean isApplication = false;
+- boolean testInProgress = false;
+- String host = null;
+- String tmpstr, tmpstr2;
+- byte tests = TEST_MID | TEST_C2S | TEST_S2C | TEST_SFW | TEST_STATUS;
+- int c2sResult = SFW_NOTTESTED;
+- int s2cResult = SFW_NOTTESTED;
+-
+- public void showStatus(String msg)
+- {
+- if (!isApplication) {
+- super.showStatus(msg);
+- }
+- }
++ JSpinner numOfTests = new JSpinner();
++ String[] delays = {"immediate", "1 min", "5 mins", "10 mins", "30 mins", "2 hours", "12 hours", "1 day"};
++ JComboBox delay = new JComboBox(delays);
++
++ boolean Randomize, failed, cancopy;
++ URL location;
++ clsFrame f, ff, optionsFrame;
++ String s;
++ double t;
++ int ECNEnabled, NagleEnabled, MSSSent, MSSRcvd;
++ int SACKEnabled, TimestampsEnabled, WinScaleRcvd, WinScaleSent;
++ int FastRetran, AckPktsOut, SmoothedRTT, CurrentCwnd, MaxCwnd;
++ int SndLimTimeRwin, SndLimTimeCwnd, SndLimTimeSender;
++ int SndLimTransRwin, SndLimTransCwnd, SndLimTransSender, MaxSsthresh;
++ int SumRTT, CountRTT, CurrentMSS, Timeouts, PktsRetrans;
++ int SACKsRcvd, DupAcksIn, MaxRwinRcvd, MaxRwinSent;
++ int DataPktsOut, Rcvbuf, Sndbuf, AckPktsIn, DataBytesOut;
++ int PktsOut, CongestionSignals, RcvWinScale;
++ int pkts, lth = 8192, CurrentRTO;
++ int c2sData, c2sAck, s2cData, s2cAck;
++ // added for mailto url
++ protected URL targetURL;
++ private String TARGET1 = "U";
++ private String TARGET2 = "H";
++ String emailText;
++ double s2cspd, c2sspd, sc2sspd, ss2cspd;
++ int ssndqueue;
++ double sbytes;
++
++ // BEGIN by prv
++ private boolean _stop;
++ // END by prv
++ /**
++ * **********************************************************************
++ * Added by Seth Peery
++ * Adds public variables to store upstream and downstream speeds in kbps
++ */
++ public String downstream = "No data";
++ public String upstream = "No data";
++ /**
++ * ********************************************************************
++ */
++
++
++ int half_duplex, congestion, bad_cable, mismatch;
++ double mylink;
++ double loss, estimate, avgrtt, spd, waitsec, timesec, rttsec;
++ double order, rwintime, sendtime, cwndtime, rwin, swin, cwin;
++ double aspd;
++
++ boolean isApplication = false;
++ boolean testInProgress = false;
++ String host = null;
++ String tmpstr, tmpstr2;
++ byte tests = TEST_MID | TEST_C2S | TEST_S2C | TEST_SFW | TEST_STATUS;
++ int c2sResult = SFW_NOTTESTED;
++ int s2cResult = SFW_NOTTESTED;
++
++ // BEGIN by prv
++ private SkinPanel skinPanel;
++ // END by prv
++
++ public void showStatus(String msg) {
++ if (!isApplication) {
++ super.showStatus(msg);
++ skinPanel.getStatusLabel().setText(msg);
++ }
++ }
++
++ public String getParameter(String name) {
++ if (!isApplication) {
++ return super.getParameter(name);
++ }
++ return null;
++ }
++
++ public boolean wantToStop() {
++ return _stop;
++ }
++
++ public void init() {
++ /* BEGIN by prv
++ getContentPane().setLayout(new BorderLayout());
++ showStatus("Tcpbw100 ready");
++ END by prv */
++ failed = false;
++ Randomize = false;
++ cancopy = false;
++
++ // BEGIN by prv
++ Interface skin = Interface.getInstance();
++
++ skinPanel = new SkinPanel(skin);
++ Insets insets = skinPanel.getInsets();
++ // END by prv
++
++ results = new MyTextPane(/* BEGIN by prv */skin.getTextPane(), insets/* END by prv */);
++
++ startTest = skinPanel.getStartButton();
++ startTest.addActionListener(this);
++ stopTest = skinPanel.getStopButton();
++ stopTest.setEnabled(false);
++
++ stopTest.addActionListener(new ActionListener() {
++
++ public void actionPerformed(ActionEvent e) {
++ if (!_stop && JOptionPane.showConfirmDialog(null, "Are you sure?", "Stop test", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
++ stopTest.setEnabled(false);
++ _stop = true;
++ }
+
+- public String getParameter(String name)
+- {
+- if (!isApplication) {
+- return super.getParameter(name);
+- }
+- return null;
+- }
++ }
+
+- public void init() {
+- getContentPane().setLayout(new BorderLayout());
+- showStatus("Tcpbw100 ready");
+- failed = false ;
+- Randomize = false;
+- cancopy = false;
+- results = new MyTextPane();
+- results.append("TCP/Web100 Network Diagnostic Tool v" + VERSION + "\n");
+- results.setEditable(false);
+- getContentPane().add(new JScrollPane(results));
+- results.append("click START to begin\n");
+- Panel mPanel = new Panel();
+- startTest = new JButton("START");
+- startTest.addActionListener(this);
+- mPanel.add(startTest);
+- sTatistics = new JButton("Statistics");
+- sTatistics.addActionListener(this);
+- if (getParameter("disableStatistics") == null) {
+- mPanel.add(sTatistics);
+- }
+- sTatistics.setEnabled(false);
+- deTails = new JButton("More Details...");
+- deTails.addActionListener(this);
+- if (getParameter("disableDetails") == null) {
+- mPanel.add(deTails);
+- }
+- deTails.setEnabled(false);
+- mailTo = new JButton("Report Problem");
+- mailTo.addActionListener(this);
+- if (getParameter("disableMailto") == null) {
+- mPanel.add(mailTo);
+- }
+- mailTo.setEnabled(false);
+- options = new JButton("Options");
+- options.addActionListener(new ActionListener() {
+-
+- public void actionPerformed(ActionEvent e) {
+- options.setEnabled(false);
+- showOptions();
+- options.setEnabled(true);
+- }
+-
+- });
+- if (getParameter("disableOptions") == null) {
+- mPanel.add(options);
+- }
+- getContentPane().add(BorderLayout.SOUTH, mPanel);
+- preferIPv6.setSelected(true);
+- defaultTest.setSelected(true);
+- defaultTest.setEnabled(false);
+- SpinnerNumberModel model = new SpinnerNumberModel();
+- model.setMinimum(new Integer(0));
+- model.setValue(new Integer(1));
+- numOfTests.setModel(model);
+- numOfTests.setPreferredSize(new Dimension(60, 20));
+- delay.setSelectedIndex(0);
+- }
+-
+- class MyTextPane extends JTextPane
+- {
+- public void append(String text)
+- {
+- try {
+- getStyledDocument().insertString(getStyledDocument().getLength(), text, null);
+- }
+- catch (BadLocationException e) {
+- System.out.println("WARNING: failed to append text to the text pane! [" + text + "]");
+- }
+- }
++ });
+
+- public void insertComponent(Component c)
+- {
+- setSelectionStart(results.getStyledDocument().getLength());
+- setSelectionEnd(results.getStyledDocument().getLength());
+- super.insertComponent(c);
+- }
+- }
+
+- class StatusPanel extends JPanel
+- {
+- private int _testNo;
+- private int _testsNum;
+- private boolean _stop = false;
+-
+- private JLabel testNoLabel = new JLabel();
+- private JButton stopButton= new JButton("STOP");
+- private JProgressBar progressBar = new JProgressBar();
+-
+- StatusPanel(int testsNum) {
+- this._testNo = 1;
+- this._testsNum = testsNum;
+-
+- setTestNoLabelText();
+- if (getParameter("enableMultipleTests") != null) {
+- add(testNoLabel);
+- }
+- progressBar.setMinimum(0);
+- progressBar.setMaximum(_testsNum);
+- progressBar.setValue(0);
+- progressBar.setStringPainted(true);
+- if (_testsNum == 0) {
+- progressBar.setString("");
+- progressBar.setIndeterminate(true);
+- }
+- else {
+- progressBar.setString("initialization...");
+- }
+- add(progressBar);
+- stopButton.addActionListener(new ActionListener() {
+-
+- public void actionPerformed(ActionEvent e) {
+- _stop = true;
+- stopButton.setEnabled(false);
+- StatusPanel.this.setText("Stopping...");
+- }
+-
+- });
+- if (getParameter("enableMultipleTests") != null) {
+- add(stopButton);
+- }
+- }
+-
+- private void setTestNoLabelText() {
+- testNoLabel.setText("Test " + _testNo + " of " + _testsNum);
+- }
+-
+- public boolean wantToStop() {
+- return _stop;
+- }
+-
+- public void endTest() {
+- progressBar.setValue(_testNo);
+- _testNo++;
+- setTestNoLabelText();
+- }
+-
+- public void setText(String text) {
+- if (!progressBar.isIndeterminate()) {
+- progressBar.setString(text);
+- }
+- }
+- }
+-
+- class TestWorker implements Runnable
+- {
+- public void run()
+- {
+- if (!testInProgress) {
+- int testNo = 1;
+- int testsNum = ((Integer)numOfTests.getValue()).intValue();
+- testInProgress = true;
+- diagnose();
+- statistics();
+- startTest.setEnabled(false);
++ options = skinPanel.getAdvancedButton();
++ options.addActionListener(new ActionListener() {
++
++ public void actionPerformed(ActionEvent e) {
++ options.setEnabled(false);
++ showAdvancedPanel();
++
++ }
++
++ });
++
++ setContentPane(skinPanel);
++
++ results.append("TCP/Web100 Network Diagnostic Tool v" + VERSION + "\n");
++ results.append("click START to begin\n");
++
++// results = new MyTextPane();
++// results.append("TCP/Web100 Network Diagnostic Tool v" + VERSION + "\n");
++// results.setEditable(false);
++// getContentPane().add(new JScrollPane(results));
++// results.append("click START to begin\n");
++
++// Panel mPanel = new Panel();
++// startTest = new JButton("START");
++// startTest.addActionListener(this);
++// mPanel.add(startTest);
++ sTatistics = new JButton("Statistics");
++// sTatistics.addActionListener(this);
++// if (getParameter("disableStatistics") == null) {
++// mPanel.add(sTatistics);
++// }
++// sTatistics.setEnabled(false);
++ deTails = new JButton("More Details...");
++ deTails.addActionListener(this);
++// if (getParameter("disableDetails") == null) {
++// mPanel.add(deTails);
++// }
+ deTails.setEnabled(false);
+- sTatistics.setEnabled(false);
+- mailTo.setEnabled(false);
+- options.setEnabled(false);
+- numOfTests.setEnabled(false);
+- StatusPanel sPanel = new StatusPanel(testsNum);
+- getContentPane().add(BorderLayout.NORTH, sPanel);
+- getContentPane().validate();
+- getContentPane().repaint();
++ mailTo = new JButton("Report Problem");
++// mailTo.addActionListener(this);
++// if (getParameter("disableMailto") == null) {
++// mPanel.add(mailTo);
++// }
++// mailTo.setEnabled(false);
++// options = new JButton("Options");
++// options.addActionListener(new ActionListener() {
++
++// public void actionPerformed(ActionEvent e) {
++// options.setEnabled(false);
++// showOptions();
++// options.setEnabled(true);
++// }
++
++// });
++// if (getParameter("disableOptions") == null) {
++// mPanel.add(options);
++// }
++// getContentPane().add(BorderLayout.SOUTH, mPanel);
++ preferIPv6.setSelected(true);
++ defaultTest.setSelected(true);
++ defaultTest.setEnabled(false);
++ SpinnerNumberModel model = new SpinnerNumberModel();
++ model.setMinimum(new Integer(0));
++ model.setValue(new Integer(1));
++ numOfTests.setModel(model);
++ numOfTests.setPreferredSize(new Dimension(60, 20));
++ delay.setSelectedIndex(0);
++ }
++
++// public void init() {
++// getContentPane().setLayout(new BorderLayout());
++// showStatus("Tcpbw100 ready");
++// failed = false;
++// Randomize = false;
++// cancopy = false;
++// results = new MyTextPane();
++// results.append("TCP/Web100 Network Diagnostic Tool v" + VERSION + "\n");
++// results.setEditable(false);
++// getContentPane().add(new JScrollPane(results));
++// results.append("click START to begin\n");
++// Panel mPanel = new Panel();
++// startTest = new JButton("START");
++// startTest.addActionListener(this);
++// mPanel.add(startTest);
++// sTatistics = new JButton("Statistics");
++// sTatistics.addActionListener(this);
++// if (getParameter("disableStatistics") == null) {
++// mPanel.add(sTatistics);
++// }
++// sTatistics.setEnabled(false);
++// deTails = new JButton("More Details...");
++// deTails.addActionListener(this);
++// if (getParameter("disableDetails") == null) {
++// mPanel.add(deTails);
++// }
++// deTails.setEnabled(false);
++// mailTo = new JButton("Report Problem");
++// mailTo.addActionListener(this);
++// if (getParameter("disableMailto") == null) {
++// mPanel.add(mailTo);
++// }
++// mailTo.setEnabled(false);
++// options = new JButton("Options");
++// options.addActionListener(new ActionListener() {
++//
++// public void actionPerformed(ActionEvent e) {
++// options.setEnabled(false);
++// showOptions();
++// options.setEnabled(true);
++// }
++//
++// });
++// if (getParameter("disableOptions") == null) {
++// mPanel.add(options);
++// }
++// getContentPane().add(BorderLayout.SOUTH, mPanel);
++// preferIPv6.setSelected(true);
++// defaultTest.setSelected(true);
++// defaultTest.setEnabled(false);
++// SpinnerNumberModel model = new SpinnerNumberModel();
++// model.setMinimum(new Integer(0));
++// model.setValue(new Integer(1));
++// numOfTests.setModel(model);
++// numOfTests.setPreferredSize(snew Dimension(60, 20));
++// delay.setSelectedIndex(0);
++// }
++//
++// class MyTextPane extends JTextPane {
++// public void append(String text) {
++// try {
++// getStyledDocument().insertString(getStyledDocument().getLength(), text, null);
++// }
++// catch (BadLocationException e) {
++// System.out.println("WARNING: failed to append text to the text pane! [" + text + "]");
++// }
++// }
++//
++// public void insertComponent(Component c) {
++// setSelectionStart(results.getStyledDocument().getLength());
++// setSelectionEnd(results.getStyledDocument().getLength());
++// super.insertComponent(c);
++// }
++// }
++
++ private void showAdvancedPanel() {
++ final JDialog dialog = new JDialog();
++ dialog.setTitle("Advanced");
++ JPanel panel = new JPanel(new BorderLayout());
++ panel.add(BorderLayout.CENTER, new JScrollPane(results));
++ JPanel buttonsPanel = new JPanel();
++
++ final JButton optionsButton = new JButton("Options");
++ optionsButton.addActionListener(new ActionListener() {
++ public void actionPerformed(ActionEvent e) {
++ showOptions();
++ }
++ });
++ buttonsPanel.add(optionsButton);
+
+- try {
+- while (true) {
+- if (sPanel.wantToStop()) {
+- break;
+- }
+- if (testsNum == 0) {
+- results.append("\n** Starting test " + testNo + " **\n");
+- }
+- else {
+- results.append("\n** Starting test " + testNo + " of " + testsNum + " **\n");
++ buttonsPanel.add(deTails);
++
++ JButton btn = new JButton("Close");
++ btn.addActionListener(new ActionListener() {
++ public void actionPerformed(ActionEvent e) {
++ dialog.dispose();
++ }
++ });
++ buttonsPanel.add(btn);
++ panel.add(BorderLayout.SOUTH, buttonsPanel);
++ dialog.addWindowListener(new WindowAdapter() {
++ @Override
++ public void windowClosed(WindowEvent e) {
++ options.setEnabled(true);
++ }
++ });
++ dialog.setContentPane(panel);
++ dialog.setSize(new Dimension(600, 400));
++ dialog.setLocationRelativeTo(null);
++ dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
++ dialog.setVisible(true);
++ }
++
++ class StatusPanel extends JPanel {
++ private int _testNo;
++ private int _testsNum;
++ private boolean _stop = false;
++
++ private JLabel testNoLabel = new JLabel();
++ private JButton stopButton = new JButton("STOP");
++ private JProgressBar progressBar = new JProgressBar();
++
++ StatusPanel(int testsNum) {
++ this._testNo = 1;
++ this._testsNum = testsNum;
++
++ setTestNoLabelText();
++ if (getParameter("enableMultipleTests") != null) {
++ add(testNoLabel);
++ }
++ progressBar.setMinimum(0);
++ progressBar.setMaximum(_testsNum);
++ progressBar.setValue(0);
++ progressBar.setStringPainted(true);
++ if (_testsNum == 0) {
++ progressBar.setString("");
++ progressBar.setIndeterminate(true);
++ } else {
++ progressBar.setString("initialization...");
++ }
++ add(progressBar);
++ stopButton.addActionListener(new ActionListener() {
++
++ public void actionPerformed(ActionEvent e) {
++ _stop = true;
++ stopButton.setEnabled(false);
++ StatusPanel.this.setText("Stopping...");
+ }
+- dottcp(sPanel);
+- if (testNo == testsNum) {
+- break;
++
++ });
++ if (getParameter("enableMultipleTests") != null) {
++ add(stopButton);
++ }
++ }
++
++ private void setTestNoLabelText() {
++ testNoLabel.setText("Test " + _testNo + " of " + _testsNum);
++ }
++
++ public boolean wantToStop() {
++ return _stop;
++ }
++
++ public void endTest() {
++ progressBar.setValue(_testNo);
++ _testNo++;
++ setTestNoLabelText();
++ }
++
++ public void setText(String text) {
++ if (!progressBar.isIndeterminate()) {
++ progressBar.setString(text);
++ }
++ }
++ }
++
++ class TestWorker implements Runnable {
++ public void run() {
++ if (!testInProgress) {
++ int testNo = 1;
++ int testsNum = ((Integer) numOfTests.getValue()).intValue();
++ testInProgress = true;
++ diagnose();
++ statistics();
++
++ startTest.setEnabled(false);
++ // BEGIN by prv
++ stopTest.setEnabled(true);
++ _stop = false;
++ // END by prv
++
++ deTails.setEnabled(false);
++ sTatistics.setEnabled(false);
++ mailTo.setEnabled(false);
++
++ // BEGIN by prv
++ //options.setEnabled(false);
++ // END by prv
++
++ numOfTests.setEnabled(false);
++ StatusPanel sPanel = new StatusPanel(testsNum);
++ getContentPane().add(BorderLayout.NORTH, sPanel);
++ getContentPane().validate();
++ getContentPane().repaint();
++
++ try {
++ while (true) {
++ if (sPanel.wantToStop()/* BEGIN by prv */ || wantToStop() /* END by prv */) {
++ break;
++ }
++ if (testsNum == 0) {
++ results.append("\n** Starting test " + testNo + " **\n");
++ } else {
++ results.append("\n** Starting test " + testNo + " of " + testsNum + " **\n");
++ }
++ dottcp(sPanel);
++ if (testNo == testsNum) {
++ break;
++ }
++ if (sPanel.wantToStop()/* BEGIN by prv */ || wantToStop() /* END by prv */) {
++ break;
++ }
++ sPanel.setText("");
++ sPanel.endTest();
++ testNo += 1;
++ deTails.setEnabled(true);
++ sTatistics.setEnabled(true);
++ mailTo.setEnabled(true);
++
++ // BEGIN by prv
++ //options.setEnabled(true);
++ // END by prv
++
++ statistics.append("\n** Test " + testNo + " **\n");
++ diagnosis.append("\n** Test " + testNo + " **\n");
++ try {
++ switch (delay.getSelectedIndex()) {
++ case 1:
++ results.append("\n** Sleeping for 1 min... **\n");
++ Thread.sleep(1000 * 60);
++ break;
++ case 2:
++ results.append("\n** Sleeping for 5 mins... **\n");
++ Thread.sleep(1000 * 60 * 5);
++ break;
++ case 3:
++ results.append("\n** Sleeping for 10 mins... **\n");
++ Thread.sleep(1000 * 60 * 10);
++ break;
++ case 4:
++ results.append("\n** Sleeping for 30 mins... **\n");
++ Thread.sleep(1000 * 60 * 30);
++ break;
++ case 5:
++ results.append("\n** Sleeping for 2 hours... **\n");
++ Thread.sleep(1000 * 60 * 120);
++ break;
++ case 6:
++ results.append("\n** Sleeping for 12 hours... **\n");
++ Thread.sleep(1000 * 60 * 720);
++ break;
++ case 7:
++ results.append("\n** Sleeping for 1 day... **\n");
++ Thread.sleep(1000 * 60 * 1440);
++ break;
++ }
++ }
++ catch (InterruptedException e) {
++ // do nothing.
++ }
++ }
++ } catch (IOException e) {
++ e.printStackTrace();
++ failed = true;
++ errmsg = "Server busy: Please wait 30 seconds for previous test to finish\n";
+ }
+- if (sPanel.wantToStop()) {
+- break;
++
++ if (failed) {
++ results.append(errmsg);
++ // BEGIN by prv
++ showStatus(Interface.getInstance().getStopString());
++ // END by prv
++ }/* BEGIN by prv */ else {
++ showStatus(Interface.getInstance().getCompleteTestString());
+ }
+- sPanel.setText("");
+- sPanel.endTest();
+- testNo += 1;
++ // END by prv
++
+ deTails.setEnabled(true);
+ sTatistics.setEnabled(true);
+ mailTo.setEnabled(true);
+- options.setEnabled(true);
+- statistics.append("\n** Test " + testNo + " **\n");
+- diagnosis.append("\n** Test " + testNo + " **\n");
+- try {
+- switch (delay.getSelectedIndex()) {
+- case 1:
+- results.append("\n** Sleeping for 1 min... **\n");
+- Thread.sleep(1000 * 60);
+- break;
+- case 2:
+- results.append("\n** Sleeping for 5 mins... **\n");
+- Thread.sleep(1000 * 60 * 5);
+- break;
+- case 3:
+- results.append("\n** Sleeping for 10 mins... **\n");
+- Thread.sleep(1000 * 60 * 10);
+- break;
+- case 4:
+- results.append("\n** Sleeping for 30 mins... **\n");
+- Thread.sleep(1000 * 60 * 30);
+- break;
+- case 5:
+- results.append("\n** Sleeping for 2 hours... **\n");
+- Thread.sleep(1000 * 60 * 120);
+- break;
+- case 6:
+- results.append("\n** Sleeping for 12 hours... **\n");
+- Thread.sleep(1000 * 60 * 720);
+- break;
+- case 7:
+- results.append("\n** Sleeping for 1 day... **\n");
+- Thread.sleep(1000 * 60 * 1440);
+- break;
+- }
+- }
+- catch (InterruptedException e) {
+- // do nothing.
+- }
++
++ // BEGIN by prv
++ skinPanel.setValue1_(0);
++ skinPanel.setValue2_(0);
++ // options.setEnabled(true);
++ // END by prv
++
++ numOfTests.setEnabled(true);
++ results.append("\nclick START to re-test\n");
++ startTest.setEnabled(true);
++ // BEGIN by prv
++ stopTest.setEnabled(false);
++ // END by prv
++ testInProgress = false;
++ getContentPane().remove(sPanel);
++ getContentPane().validate();
++ getContentPane().repaint();
+ }
+- } catch(IOException e) {
+- e.printStackTrace();
+- failed=true;
+- errmsg = "Server busy: Please wait 30 seconds for previous test to finish\n";
+- }
+-
+- if (failed) {
+- results.append(errmsg);
+- }
+-
+- deTails.setEnabled(true);
+- sTatistics.setEnabled(true);
+- mailTo.setEnabled(true);
+- options.setEnabled(true);
+- numOfTests.setEnabled(true);
+- showStatus("Tcpbw100 done");
+- results.append("\nclick START to re-test\n");
+- startTest.setEnabled(true);
+- testInProgress = false;
+- getContentPane().remove(sPanel);
+- getContentPane().validate();
+- getContentPane().repaint();
+- }
++ }
+ }
+- }
+
+- synchronized public void runtest() {
+- new Thread(new TestWorker()).start();
+- }
+-
+- class Message {
+- byte type;
+- byte[] body;
+- }
+-
+- class Protocol {
+- private InputStream _ctlin;
+- private OutputStream _ctlout;
+-
+- public Protocol(Socket ctlSocket) throws IOException
+- {
+- _ctlin = ctlSocket.getInputStream();
+- _ctlout = ctlSocket.getOutputStream();
+- }
+-
+- public void send_msg(byte type, byte toSend) throws IOException
+- {
+- byte[] tab = new byte[] { toSend };
+- send_msg(type, tab);
++ synchronized public void runtest() {
++ new Thread(new TestWorker()).start();
+ }
+
+- public void send_msg(byte type, byte[] tab) throws IOException
+- {
+- byte[] header = new byte[3];
+- header[0] = type;
+- header[1] = (byte) (tab.length >> 8);
+- header[2] = (byte) tab.length;
+-
+- _ctlout.write(header);
+- _ctlout.write(tab);
++ class Message {
++ byte type;
++ byte[] body;
+ }
+
+- public int readn(Message msg, int amount) throws IOException
+- {
+- int read = 0;
+- int tmp;
+- msg.body = new byte[amount];
+- while (read != amount) {
+- tmp = _ctlin.read(msg.body, read, amount - read);
+- if (tmp <= 0) {
+- return read;
+- }
+- read += tmp;
+- }
+- return read;
+- }
+-
+- public int recv_msg(Message msg) throws IOException
+- {
+- int length;
+- if (readn(msg, 3) != 3) {
***The diff for this file has been truncated for email.***


  • [ndt] r346 committed - adding the 'SamKnows' patch to Tcpbw100.java to the repo. We will be ..., ndt, 04/14/2010

Archive powered by MHonArc 2.6.16.

Top of Page