[Udt-java-commits] SF.net SVN: udt-java:[35] udt-java/trunk
Status: Alpha
Brought to you by:
bschuller
|
From: <bsc...@us...> - 2010-05-01 20:49:58
|
Revision: 35
http://udt-java.svn.sourceforge.net/udt-java/?rev=35&view=rev
Author: bschuller
Date: 2010-05-01 20:49:52 +0000 (Sat, 01 May 2010)
Log Message:
-----------
nicer stats; stats switchable
Modified Paths:
--------------
udt-java/trunk/README
udt-java/trunk/src/main/java/udt/UDTReceiver.java
udt-java/trunk/src/main/java/udt/UDTSender.java
udt-java/trunk/src/main/java/udt/UDTSocket.java
udt-java/trunk/src/main/java/udt/util/MeanValue.java
udt-java/trunk/src/main/java/udt/util/SendFile.java
udt-java/trunk/src/main/java/udt/util/StatisticsHistoryEntry.java
udt-java/trunk/src/main/java/udt/util/UDTStatistics.java
udt-java/trunk/src/main/scripts/fufex-recv
udt-java/trunk/src/main/scripts/fufex-send
udt-java/trunk/src/main/scripts/receive-file
udt-java/trunk/src/main/scripts/send-file
udt-java/trunk/src/test/java/udt/performance/TestUDTLargeData.java
Added Paths:
-----------
udt-java/trunk/src/main/java/udt/util/MeanThroughput.java
Modified: udt-java/trunk/README
===================================================================
--- udt-java/trunk/README 2010-04-30 21:31:25 UTC (rev 34)
+++ udt-java/trunk/README 2010-05-01 20:49:52 UTC (rev 35)
@@ -3,13 +3,24 @@
#
This is a native Java implementation of the UDT protocol.
+The UDT protocol has been developed by Yunhong Gu and
+Robert Grossmann from the University of Illinois, and provides
+high-speed data transfer with configurable congestion control.
+#
+# Using UDT-Java
+#
+UDT-Java can be used as a library for developing your own
+applications, and it can be used as-is as a commandline tool for
+file transfer.
+
#
-# Sample applications
+# File transfer applications
#
-We provide "send-file" and "receive-file" scripts that work analogously to their C++ counterparts.
+We provide "send-file" and "receive-file" scripts that work analogously
+to their C++ counterparts.
To start a file "server",
@@ -19,17 +30,24 @@
bin/receive-file <server_host> <server_port> <remote_filename> <local_filename>
+where the <server_host> can be a server name or a numerical IP address.
#
# Setting up a development environment using Eclipse
#
+If you want to work with the UDT-Java source code, you need to first
+checkout the sourcecode from Sourceforge using Subversion:
+
+ svn checkout http://udt-java.sourceforge.net/svnroot/udt-java/udt-java/trunk udt-java
+
You will need Apache Maven from http://maven.apache.org
To generate Eclipse project files,
+ cd udt-java
mvn eclipse:eclipse
-Then, import the project into your workspace.
+Then, open Eclipse and import the project into your workspace, using
+"Import/Existing projects into workspace...".
-
\ No newline at end of file
Modified: udt-java/trunk/src/main/java/udt/UDTReceiver.java
===================================================================
--- udt-java/trunk/src/main/java/udt/UDTReceiver.java 2010-04-30 21:31:25 UTC (rev 34)
+++ udt-java/trunk/src/main/java/udt/UDTReceiver.java 2010-05-01 20:49:52 UTC (rev 35)
@@ -152,6 +152,8 @@
*/
public static boolean connectionExpiryDisabled=false;
+ private final boolean storeStatistics;
+
/**
* create a receiver with a valid {@link UDTSession}
* @param session
@@ -169,6 +171,7 @@
largestReceivedSeqNumber=session.getInitialSequenceNumber()-1;
bufferSize=session.getReceiveBufferSize();
handoffQueue=new ArrayBlockingQueue<UDTPacket>(4*session.getFlowWindowSize());
+ storeStatistics=Boolean.getBoolean("udt.receiver.storeStatistics");
initMetrics();
start();
}
@@ -178,6 +181,7 @@
private MeanValue processTime;
private MeanValue dataProcessTime;
private void initMetrics(){
+ if(!storeStatistics)return;
dgReceiveInterval=new MeanValue("UDT receive interval");
statistics.addMetric(dgReceiveInterval);
dataPacketInterval=new MeanValue("Data packet interval");
@@ -216,9 +220,9 @@
* packets are written by the endpoint
*/
protected void receive(UDTPacket p)throws IOException{
- dgReceiveInterval.end();
+ if(storeStatistics)dgReceiveInterval.end();
handoffQueue.offer(p);
- dgReceiveInterval.begin();
+ if(storeStatistics)dgReceiveInterval.begin();
}
/**
@@ -261,9 +265,11 @@
if(needEXPReset){
nextEXP=Util.getCurrentTime()+expTimerInterval;
}
- processTime.begin();
+ if(storeStatistics)processTime.begin();
+
processUDTPacket(packet);
- processTime.end();
+
+ if(storeStatistics)processTime.end();
}
Thread.yield();
@@ -348,11 +354,15 @@
if(!p.isControlPacket()){
DataPacket dp=(DataPacket)p;
- dataPacketInterval.end();
- dataProcessTime.begin();
+ if(storeStatistics){
+ dataPacketInterval.end();
+ dataProcessTime.begin();
+ }
onDataPacketReceived(dp);
- dataProcessTime.end();
- dataPacketInterval.begin();
+ if(storeStatistics){
+ dataProcessTime.end();
+ dataPacketInterval.begin();
+ }
}
else if (p.getControlPacketType()==ControlPacketType.ACK2.ordinal()){
Modified: udt-java/trunk/src/main/java/udt/UDTSender.java
===================================================================
--- udt-java/trunk/src/main/java/udt/UDTSender.java 2010-04-30 21:31:25 UTC (rev 34)
+++ udt-java/trunk/src/main/java/udt/UDTSender.java 2010-05-01 20:49:52 UTC (rev 35)
@@ -50,6 +50,7 @@
import udt.packets.KeepAlive;
import udt.packets.NegativeAcknowledgement;
import udt.sender.SenderLossList;
+import udt.util.MeanThroughput;
import udt.util.MeanValue;
import udt.util.UDTStatistics;
import udt.util.UDTThreadFactory;
@@ -114,6 +115,8 @@
//used by the sender to wait for an ACK of a certain sequence number
private final AtomicReference<CountDownLatch> waitForSeqAckLatch=new AtomicReference<CountDownLatch>();
+ private final boolean storeStatistics;
+
public UDTSender(UDTSession session,UDPEndPoint endpoint){
if(!session.isReady())throw new IllegalStateException("UDTSession is not ready.");
this.endpoint= endpoint;
@@ -125,17 +128,22 @@
lastAckSequenceNumber=session.getInitialSequenceNumber();
waitForAckLatch.set(new CountDownLatch(1));
waitForSeqAckLatch.set(new CountDownLatch(1));
+ storeStatistics=Boolean.getBoolean("udt.sender.storeStatistics");
initMetrics();
doStart();
}
private MeanValue dgSendTime;
private MeanValue dgSendInterval;
+ private MeanThroughput throughput;
private void initMetrics(){
+ if(!storeStatistics)return;
dgSendTime=new MeanValue("Datagram send time");
statistics.addMetric(dgSendTime);
dgSendInterval=new MeanValue("Datagram send interval");
statistics.addMetric(dgSendInterval);
+ throughput=new MeanThroughput("Throughput", session.getDatagramSize());
+ statistics.addMetric(throughput);
}
/**
@@ -182,11 +190,17 @@
*/
private void send(DataPacket p)throws IOException{
synchronized(sendLock){
- dgSendInterval.end();
- dgSendTime.begin();
+ if(storeStatistics){
+ dgSendInterval.end();
+ dgSendTime.begin();
+ }
endpoint.doSend(p);
- dgSendTime.end();
- dgSendInterval.begin();
+ if(storeStatistics){
+ dgSendTime.end();
+ dgSendInterval.begin();
+ throughput.end();
+ throughput.begin();
+ }
sendBuffer.put(p.getPacketSequenceNumber(), p);
unacknowledged.incrementAndGet();
}
@@ -261,7 +275,7 @@
//send ACK2 packet to the receiver
sendAck2(ackNumber);
statistics.incNumberOfACKReceived();
- statistics.storeParameters();
+ if(storeStatistics)statistics.storeParameters();
}
/**
@@ -275,8 +289,7 @@
session.getCongestionControl().onLoss(nak.getDecodedLossInfo());
session.getSocket().getReceiver().resetEXPTimer();
statistics.incNumberOfNAKReceived();
- statistics.storeParameters();
-
+
if(logger.isLoggable(Level.FINER)){
logger.finer("NAK for "+nak.getDecodedLossInfo().size()+" packets lost, "
+"set send period to "+session.getCongestionControl().getSendInterval());
@@ -303,9 +316,7 @@
/**
* sender algorithm
*/
- MeanValue v=new MeanValue("Wait for Ack time: ");
public void senderAlgorithm()throws InterruptedException, IOException{
- statistics.addMetric(v);
while(!paused){
long iterationStart=Util.getCurrentTime(); //last packet send time?
@@ -338,9 +349,7 @@
if(unAcknowledged>=session.getCongestionControl().getCongestionWindowSize()){
statistics.incNumberOfCCWindowExceededEvents();
}
- v.begin();
waitForAck();
- v.end();
}
}
@@ -356,6 +365,7 @@
x++;
}
passed=Util.getCurrentTime()-iterationStart;
+ if(stopped)return;
}
}
}
Modified: udt-java/trunk/src/main/java/udt/UDTSocket.java
===================================================================
--- udt-java/trunk/src/main/java/udt/UDTSocket.java 2010-04-30 21:31:25 UTC (rev 34)
+++ udt-java/trunk/src/main/java/udt/UDTSocket.java 2010-05-01 20:49:52 UTC (rev 35)
@@ -204,6 +204,7 @@
sender.waitForAck(seqNo);
}
}
+ sender.pause();
}
//writes and wait for ack
Added: udt-java/trunk/src/main/java/udt/util/MeanThroughput.java
===================================================================
--- udt-java/trunk/src/main/java/udt/util/MeanThroughput.java (rev 0)
+++ udt-java/trunk/src/main/java/udt/util/MeanThroughput.java 2010-05-01 20:49:52 UTC (rev 35)
@@ -0,0 +1,30 @@
+package udt.util;
+
+
+/**
+ * holds a floating mean value
+ */
+public class MeanThroughput extends MeanValue{
+
+ private final double packetSize;
+
+ public MeanThroughput(String name, int packetSize){
+ this(name, false, 64, packetSize);
+ }
+
+ public MeanThroughput(String name, boolean verbose, int packetSize){
+ this(name, verbose, 64, packetSize);
+ }
+
+ public MeanThroughput(String name, boolean verbose, int nValue, int packetSize){
+ super(name,verbose,nValue);
+ this.packetSize=packetSize;
+ }
+
+ @Override
+ public double getMean() {
+ return packetSize/super.getMean();
+ }
+
+
+}
Property changes on: udt-java/trunk/src/main/java/udt/util/MeanThroughput.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Modified: udt-java/trunk/src/main/java/udt/util/MeanValue.java
===================================================================
--- udt-java/trunk/src/main/java/udt/util/MeanValue.java 2010-04-30 21:31:25 UTC (rev 34)
+++ udt-java/trunk/src/main/java/udt/util/MeanValue.java 2010-05-01 20:49:52 UTC (rev 35)
@@ -1,6 +1,7 @@
package udt.util;
import java.text.NumberFormat;
+import java.util.Locale;
/**
* holds a floating mean value
@@ -31,20 +32,20 @@
}
public MeanValue(String name, boolean verbose, int nValue){
- format=NumberFormat.getNumberInstance();
+ format=NumberFormat.getNumberInstance(Locale.ENGLISH);
format.setMaximumFractionDigits(2);
+ format.setGroupingUsed(false);
this.verbose=verbose;
this.nValue=nValue;
this.name=name;
- begin();
}
public void addValue(double value){
mean=(mean*n+value)/(n+1);
n++;
if(verbose && n % nValue == 0){
- if(msg!=null)System.out.print(msg+" ");
- System.out.println(getFormattedMean());
+ if(msg!=null)System.out.println(msg+" "+getFormattedMean());
+ else System.out.println(getFormattedMean());
}
}
@@ -53,7 +54,7 @@
}
public String getFormattedMean(){
- return format.format(mean);
+ return format.format(getMean());
}
public void clear(){
@@ -66,7 +67,7 @@
}
public void end(){
- addValue(Util.getCurrentTime()-start);
+ if(start>0)addValue(Util.getCurrentTime()-start);
}
public void end(String msg){
this.msg=msg;
@@ -76,4 +77,8 @@
public String getName(){
return name;
}
+
+ public String toString(){
+ return name;
+ }
}
Modified: udt-java/trunk/src/main/java/udt/util/SendFile.java
===================================================================
--- udt-java/trunk/src/main/java/udt/util/SendFile.java 2010-04-30 21:31:25 UTC (rev 34)
+++ udt-java/trunk/src/main/java/udt/util/SendFile.java 2010-05-01 20:49:52 UTC (rev 35)
@@ -157,8 +157,11 @@
System.out.println(socket.getSession().getStatistics().toString());
double rate=1000.0*size/1024/1024/(end-start);
System.out.println("[SendFile] Rate: "+format.format(rate)+" MBytes/sec. "+format.format(8*rate)+" MBit/sec.");
- socket.getSession().getStatistics().writeParameterHistory(new File("udtstats-"+System.currentTimeMillis()+".csv"));
+ if(Boolean.getBoolean("udt.sender.storeStatistics")){
+ socket.getSession().getStatistics().writeParameterHistory(new File("udtstats-"+System.currentTimeMillis()+".csv"));
+ }
}finally{
+ socket.getSender().stop();
fis.close();
}
logger.info("Finished request from "+socket.getSession().getDestination());
Modified: udt-java/trunk/src/main/java/udt/util/StatisticsHistoryEntry.java
===================================================================
--- udt-java/trunk/src/main/java/udt/util/StatisticsHistoryEntry.java 2010-04-30 21:31:25 UTC (rev 34)
+++ udt-java/trunk/src/main/java/udt/util/StatisticsHistoryEntry.java 2010-05-01 20:49:52 UTC (rev 35)
@@ -1,5 +1,7 @@
package udt.util;
+import java.util.List;
+
public class StatisticsHistoryEntry {
private final Object[] values;
@@ -14,6 +16,26 @@
this.timestamp=time;
}
+ public StatisticsHistoryEntry(boolean heading, long time, List<MeanValue>metrics){
+ this.isHeading=heading;
+ this.timestamp=time;
+ int length=metrics.size();
+ if(isHeading)length++;
+ Object[]metricValues=new Object[length];
+ if(isHeading){
+ metricValues[0]="time";
+ for(int i=0;i<metrics.size();i++){
+ metricValues[i+1]=metrics.get(i).getName();
+ }
+ }
+ else{
+ for(int i=0;i<metricValues.length;i++){
+ metricValues[i]=metrics.get(i).getFormattedMean();
+ }
+ }
+ this.values=metricValues;
+ }
+
public StatisticsHistoryEntry(Object ...values){
this(false,System.currentTimeMillis(),values);
}
@@ -26,12 +48,12 @@
if(!isHeading){
sb.append(timestamp);
for(Object val: values){
- sb.append(",").append(String.valueOf(val));
+ sb.append(" , ").append(String.valueOf(val));
}
}
else{
for(int i=0;i<values.length;i++){
- if(i>0)sb.append(",");
+ if(i>0)sb.append(" , ");
sb.append(String.valueOf(values[i]));
}
}
Modified: udt-java/trunk/src/main/java/udt/util/UDTStatistics.java
===================================================================
--- udt-java/trunk/src/main/java/udt/util/UDTStatistics.java 2010-04-30 21:31:25 UTC (rev 34)
+++ udt-java/trunk/src/main/java/udt/util/UDTStatistics.java 2010-05-01 20:49:52 UTC (rev 35)
@@ -42,7 +42,6 @@
/**
* This class is used to keep some statistics about a UDT connection.
- * It also allows to compute a MD5 hash over the received data
*/
public class UDTStatistics {
@@ -226,10 +225,10 @@
synchronized (statsHistory) {
if(first){
first=false;
- statsHistory.add(new StatisticsHistoryEntry(true,0,"time","packetRate","sendPeriod"));
+ statsHistory.add(new StatisticsHistoryEntry(true,0,metrics));
initialTime=System.currentTimeMillis();
}
- statsHistory.add(new StatisticsHistoryEntry(false,System.currentTimeMillis()-initialTime,packetArrivalRate,sendPeriod));
+ statsHistory.add(new StatisticsHistoryEntry(false,System.currentTimeMillis()-initialTime,metrics));
}
}
Modified: udt-java/trunk/src/main/scripts/fufex-recv
===================================================================
--- udt-java/trunk/src/main/scripts/fufex-recv 2010-04-30 21:31:25 UTC (rev 34)
+++ udt-java/trunk/src/main/scripts/fufex-recv 2010-05-01 20:49:52 UTC (rev 35)
@@ -36,5 +36,5 @@
#memory for the VM
MEM=-Xmx128m
-$JAVA $MEM -cp $CP udt.unicore.FufexReceive $*
+$JAVA $MEM $OPTS -cp $CP udt.unicore.FufexReceive $*
Modified: udt-java/trunk/src/main/scripts/fufex-send
===================================================================
--- udt-java/trunk/src/main/scripts/fufex-send 2010-04-30 21:31:25 UTC (rev 34)
+++ udt-java/trunk/src/main/scripts/fufex-send 2010-05-01 20:49:52 UTC (rev 35)
@@ -37,5 +37,5 @@
#memory for the VM
MEM=-Xmx128m
-$JAVA $MEM -cp $CP udt.unicore.FufexSend $*
+$JAVA $MEM $OPTS -cp $CP udt.unicore.FufexSend $*
Modified: udt-java/trunk/src/main/scripts/receive-file
===================================================================
--- udt-java/trunk/src/main/scripts/receive-file 2010-04-30 21:31:25 UTC (rev 34)
+++ udt-java/trunk/src/main/scripts/receive-file 2010-05-01 20:49:52 UTC (rev 35)
@@ -1,6 +1,15 @@
#!/bin/sh
#
+# Start script for the UDT-Java send-file application
+# Usage: receive-file <server-address> <server-port> <remote-file> <local-file>
+# [--localIP=<local ip>]
+# [--localPort=<local port>]
+# [--verbose]
+#
+#
+
+#
#Installation Directory
#
dir=`dirname $0`
@@ -24,6 +33,12 @@
#
#INST=
+#
+# Alternative CC class
+#
+#OPTS=$OPTS" -Dudt.congestioncontrol.class=udt.cc.SimpleTCP"
+
+#Java command to use
JAVA=java
#location of udt.jar
@@ -32,5 +47,5 @@
#memory for the VM
MEM=-Xmx128m
-$JAVA $MEM -cp $CP udt.util.ReceiveFile $*
+$JAVA $MEM $OPTS -cp $CP udt.util.ReceiveFile $*
Modified: udt-java/trunk/src/main/scripts/send-file
===================================================================
--- udt-java/trunk/src/main/scripts/send-file 2010-04-30 21:31:25 UTC (rev 34)
+++ udt-java/trunk/src/main/scripts/send-file 2010-05-01 20:49:52 UTC (rev 35)
@@ -1,6 +1,13 @@
#!/bin/sh
#
+# Start script for the UDT-Java send-file application
+# Usage: send-file <server-port>
+# [--localIP=<local ip>]
+# [--verbose]
+#
+
+#
#Installation Directory
#
dir=`dirname $0`
@@ -24,6 +31,19 @@
#
#INST=
+#
+# Alternative CC class
+#
+#OPTS=$OPTS" -Dudt.congestioncontrol.class=udt.cc.SimpleTCP"
+
+#
+# Collect and store some performance data (e.g. throughput)
+# (data will be collected in memory and stored after send finishes
+# to a udtstats-<NNNN>.csv file)
+#OPTS=$OPTS" -Dudt.sender.storeStatistics=true"
+
+
+#which Java command to use
JAVA=java
#location of udt.jar
@@ -32,5 +52,5 @@
#memory for the VM
MEM=-Xmx128m
-$JAVA $MEM -cp $CP udt.util.SendFile $*
+$JAVA $MEM $OPTS -cp $CP udt.util.SendFile $*
Modified: udt-java/trunk/src/test/java/udt/performance/TestUDTLargeData.java
===================================================================
--- udt-java/trunk/src/test/java/udt/performance/TestUDTLargeData.java 2010-04-30 21:31:25 UTC (rev 34)
+++ udt-java/trunk/src/test/java/udt/performance/TestUDTLargeData.java 2010-05-01 20:49:52 UTC (rev 35)
@@ -21,7 +21,7 @@
boolean running=false;
//how many
- int num_packets=500;
+ int num_packets=50;
//how large is a single packet
int size=1*1024*1024;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|