Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
6.4k views
in Java FTP by (1k points)
Hi,

we implemented a java method to calculate ftp upload transfer speed of Files.but when we compared our product with other ftp clients we found our ftp upload speed is not calculated accurately.

we need a reliable and accurate method to calculate speed upload of files.

if we can do this with edtftpj free edition ,can you point me how i can approach this ?

if not; will your developer's team be able to implement this feature for us ? & how much will you charge for it ?

thanks.

5 Answers

0 votes
by (162k points)
How did you try to calculate it?

What statistics do you need? Is it average transfer speed over the transfer, or do you need a constantly updated transfer speed?
0 votes
by (1k points)
How did you try to calculate it?

What statistics do you need? Is it average transfer speed over the transfer, or do you need a constantly updated transfer speed?


i used a constantly updated transfer speed .

here is the method i used (counter is the number of bytes transfered at each given time 'end' ):

/**
    * estimates file transfer speed
    * 
    * @param counter
    * @param startTime
    * @return
    */
   public String speed(long counter) {
      long end = System.currentTimeMillis();
      long timeTaken = end - startTime;
      long kb = 0;
      timeTaken = (timeTaken / 1000);
      if (timeTaken != 0)
         kb = counter / timeTaken;

      else
         kb = ((counter));
      return fileSize((kb)) + "/s";

   }


thanks.
0 votes
by (162k points)
Have you looked at the FTPProgressMonitor that can be used to be notified of bytes transferred?
0 votes
by (1k points)
hi ,
we are still having problems to calculate transfer speed accurately.

beside the speed(long) method i posted above ,here is the method i use in ProgressMonitor:

public void bytesTransferred(long bytes) {
         util.Trace.log(bytes + " transferred");

         long b = r.numBytes + bytes;
         
         double done = ((double) b / r.tSize);
         done *= 100D;
         main.setProgressBar((int) done);
         
         long end = System.currentTimeMillis();
         long timeTaken = end - r.startTime;
         //timeTaken = (timeTaken / 1000);
         long kb = 0;

         if (timeTaken != 0)
            kb = ((b) / timeTaken);
         else
            kb = ((b));
         String speed = r.speed(b);
         String timeRemaining = r.remainingTime(r.tSize, b, kb);
         String currSize = util.UploadSystem.fileSize(b);
         String message = "Status: " + currSize + " of "
               + util.UploadSystem.fileSize(r.tSize) + ", " +

               timeRemaining + ", " + speed;
         main.setStatusLabel(message);

      }


i would appreciate you help me make the transfer rate calculation correctly .

thanks
0 votes
by (162k points)
what exactly is wrong with your calculations? In what way are they inaccurate do you think?

In the bytesTransferred method you are getting passed the total number of bytes transferred at each time it is invoked, and it is an accurate count.

Categories

...