2015-07-25 11:42:53 +00:00
|
|
|
package net.i2p.client.streaming;
|
2004-10-24 23:23:35 +00:00
|
|
|
|
2014-01-04 19:57:47 +00:00
|
|
|
import net.i2p.client.streaming.StreamSinkClient;
|
|
|
|
import net.i2p.client.streaming.StreamSinkSend;
|
|
|
|
import net.i2p.client.streaming.StreamSinkServer;
|
2004-10-24 23:23:35 +00:00
|
|
|
/**
|
2004-11-02 11:57:07 +00:00
|
|
|
* Usage: StreamSinkTest [(old|new) [#hops [#kb]]]
|
2004-10-24 23:23:35 +00:00
|
|
|
*/
|
2013-06-28 22:32:05 +00:00
|
|
|
public class StreamSinkTestStandalone {
|
2004-10-30 23:46:01 +00:00
|
|
|
/* private static String HOST1 = "dev.i2p.net";
|
|
|
|
private static String HOST2 = "dev.i2p.net";
|
|
|
|
private static String PORT1 = "4101";
|
|
|
|
private static String PORT2 = "4501";
|
2004-11-02 11:57:07 +00:00
|
|
|
/*
|
2004-10-30 23:46:01 +00:00
|
|
|
private static String HOST1 = "localhost";
|
|
|
|
private static String HOST2 = "localhost";
|
|
|
|
private static String PORT1 = "7654";
|
|
|
|
private static String PORT2 = "7654";
|
2004-11-02 11:57:07 +00:00
|
|
|
*/
|
2004-10-30 23:46:01 +00:00
|
|
|
private static String HOST1 = "localhost";
|
|
|
|
private static String HOST2 = "localhost";
|
|
|
|
private static String PORT1 = "10001";
|
|
|
|
private static String PORT2 = "11001";
|
2004-11-02 11:57:07 +00:00
|
|
|
/* */
|
2004-10-30 23:46:01 +00:00
|
|
|
|
2004-10-24 23:23:35 +00:00
|
|
|
public static void main(String args[]) {
|
2004-11-02 11:57:07 +00:00
|
|
|
int hops = 0;
|
|
|
|
int kb = 32*1024;
|
|
|
|
if (args.length > 0) {
|
|
|
|
try {
|
2015-07-25 11:42:53 +00:00
|
|
|
hops = Integer.parseInt(args[0]);
|
2004-11-02 11:57:07 +00:00
|
|
|
} catch (NumberFormatException nfe) {
|
|
|
|
hops = 0;
|
|
|
|
}
|
|
|
|
}
|
2015-07-25 11:42:53 +00:00
|
|
|
if (args.length > 1) {
|
2004-11-02 11:57:07 +00:00
|
|
|
try {
|
2015-07-25 11:42:53 +00:00
|
|
|
kb = Integer.parseInt(args[1]);
|
2004-11-02 11:57:07 +00:00
|
|
|
} catch (NumberFormatException nfe) {
|
|
|
|
kb = 32*1024;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
System.setProperty("tunnels.depthInbound", ""+hops);
|
2004-10-24 23:23:35 +00:00
|
|
|
|
|
|
|
new Thread(new Runnable() {
|
|
|
|
public void run() {
|
2004-10-30 23:46:01 +00:00
|
|
|
StreamSinkServer.main(new String[] { HOST1, PORT1, "streamSinkTestDir", "streamSinkTestServer.key" });
|
2004-10-24 23:23:35 +00:00
|
|
|
}
|
|
|
|
}, "server").start();
|
|
|
|
|
2004-10-30 23:46:01 +00:00
|
|
|
try { Thread.sleep(60*1000); } catch (Exception e) {}
|
2004-10-24 23:23:35 +00:00
|
|
|
|
2004-11-02 11:57:07 +00:00
|
|
|
//run(256, 1);
|
2004-10-24 23:23:35 +00:00
|
|
|
//run(256, 1000);
|
2004-11-02 11:57:07 +00:00
|
|
|
//run(4*1024, 10);
|
|
|
|
run(kb, 1);
|
2004-10-30 23:46:01 +00:00
|
|
|
//run(1*1024, 1);
|
2004-10-24 23:23:35 +00:00
|
|
|
//run("/home/jrandom/streamSinkTestDir/clientSink36766.dat", 1);
|
|
|
|
//run(512*1024, 1);
|
|
|
|
try { Thread.sleep(10*1000); } catch (InterruptedException e) {}
|
|
|
|
System.out.println("Shutting down");
|
|
|
|
System.exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void run(final int kb, final int msBetweenWrites) {
|
|
|
|
Thread t = new Thread(new Runnable() {
|
|
|
|
public void run() {
|
2004-10-30 23:46:01 +00:00
|
|
|
StreamSinkClient.main(new String[] { HOST2, PORT2, kb+"", msBetweenWrites+"", "streamSinkTestServer.key" });
|
2004-10-24 23:23:35 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
t.start();
|
|
|
|
|
|
|
|
System.out.println("client and server started: size = " + kb + "KB, delay = " + msBetweenWrites);
|
|
|
|
try {
|
|
|
|
t.join();
|
|
|
|
} catch (InterruptedException ie) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void run(final String filename, final int msBetweenWrites) {
|
|
|
|
Thread t = new Thread(new Runnable() {
|
|
|
|
public void run() {
|
|
|
|
StreamSinkSend.main(new String[] { filename, msBetweenWrites+"", "streamSinkTestServer.key" });
|
|
|
|
}
|
|
|
|
});
|
|
|
|
t.start();
|
|
|
|
|
|
|
|
System.out.println("client and server started: file " + filename + ", delay = " + msBetweenWrites);
|
|
|
|
try {
|
|
|
|
t.join();
|
|
|
|
} catch (InterruptedException ie) {}
|
|
|
|
}
|
|
|
|
}
|