diff --git a/src/main/java/net/utp4j/channels/impl/alg/UtpAlgorithm.java b/src/main/java/net/utp4j/channels/impl/alg/UtpAlgorithm.java index e6f3f71..af507fe 100644 --- a/src/main/java/net/utp4j/channels/impl/alg/UtpAlgorithm.java +++ b/src/main/java/net/utp4j/channels/impl/alg/UtpAlgorithm.java @@ -76,7 +76,7 @@ public class UtpAlgorithm { private long timeStampNow; private long lastAckRecieved; - private int resendedPackets = 0; + private int resentPackets = 0; private int totalPackets = 0; private long lastMaxedOutWindow; @@ -193,7 +193,7 @@ private void updateWindow(UtpPacket utpPacket, long timestamp, int packetSizeJus statisticLogger.microSecTimeStamp(timeStampNow); currentWindow = buffer.getBytesOnfly(); - if (isWondowFull()) { + if (isWindowFull()) { lastMaxedOutWindow = timeStampNow; } @@ -240,7 +240,7 @@ private void updateWindow(UtpPacket utpPacket, long timestamp, int packetSizeJus if (maxWindow == 0) { lastZeroWindow = timeStampNow; } - // get bytes successfully transmitted: + // get bytes successfuly transmitted: // this is the position of the bytebuffer (comes from programmer) // substracted by the amount of bytes on fly (these are not yet acked) int bytesSend = bBuffer.position() - buffer.getBytesOnfly(); @@ -302,7 +302,7 @@ public Queue getPacketsToResend() throws SocketException { utpTimestampedPacketDTO.setReduceWindow(false); } } - resendedPackets += queue.size(); + resentPackets += queue.size(); return queue; } @@ -341,7 +341,7 @@ public boolean canSendNextPacket() { log.debug("setting window to one packet size. current window is:" + currentWindow); maxWindow = MAX_PACKET_SIZE; } - boolean windowNotFull = !isWondowFull(); + boolean windowNotFull = !isWindowFull(); boolean burstFull = false; if (windowNotFull) { @@ -363,7 +363,7 @@ private boolean isBurstFull() { } - private boolean isWondowFull() { + private boolean isWindowFull() { int maximumWindow = (advertisedWindowSize < maxWindow && advertisedWindowSizeSet) ? advertisedWindowSize : maxWindow; return currentWindow >= maximumWindow; @@ -512,17 +512,17 @@ public long getWaitingTimeMicroSeconds() { long nextTimeOut = oldestTimeStamp + getTimeOutMicros(); timeStampNow = timeStamper.timeStamp(); long timeOutInMicroSeconds = nextTimeOut - timeStampNow; - if (continueImmidiately(timeOutInMicroSeconds, oldestTimeStamp)) { + if (continueImmediately(timeOutInMicroSeconds, oldestTimeStamp)) { return 0L; } - if (!isWondowFull() || maxWindow == 0) { + if (!isWindowFull() || maxWindow == 0) { return MICROSECOND_WAIT_BETWEEN_BURSTS; } return timeOutInMicroSeconds; } - private boolean continueImmidiately( + private boolean continueImmediately( long timeOutInMicroSeconds, long oldestTimeStamp) { return timeOutInMicroSeconds < 0 && (oldestTimeStamp != 0); } @@ -530,12 +530,12 @@ private boolean continueImmidiately( /** * terminates. * @param bytesSend - * @param successfull + * @param successful */ - public void end(int bytesSend, boolean successfull) { - if (successfull) { + public void end(int bytesSend, boolean successful) { + if (successful) { statisticLogger.end(bytesSend); - log.debug("Total packets send: " + totalPackets + ", Total Packets Resend: " + resendedPackets); + log.debug("Total packets send: " + totalPackets + ", Total Packets Resend: " + resentPackets); } } diff --git a/src/main/java/net/utp4j/examples/configtest/ConfigTestWrite.java b/src/main/java/net/utp4j/examples/configtest/ConfigTestWrite.java index 5c2c3d0..0f5d345 100644 --- a/src/main/java/net/utp4j/examples/configtest/ConfigTestWrite.java +++ b/src/main/java/net/utp4j/examples/configtest/ConfigTestWrite.java @@ -49,10 +49,19 @@ public class ConfigTestWrite { * @throws InterruptedException */ public static void main(String[] args) throws IOException, InterruptedException { - - String testPlan = "testPlan/testplan2.csv"; - String testDataFile = "testData/sc S01E01.avi"; - boolean waitOnManualInput = true; + if (args.length < 2) { + System.out.println("Error - usage: configwritetest [server ip:port]"); + return; + } + + + String testPlan = args[0]; + String testDataFile = args[1]; + String ip = "localhost"; + if (args.length > 2) { + ip = args[2]; + } + boolean waitOnManualInput = false; MicroSecondsTimeStamp timeStamper = new MicroSecondsTimeStamp(); @@ -86,7 +95,7 @@ public static void main(String[] args) throws IOException, InterruptedException } // UtpConnectFuture cFuture = chanel.connect(new InetSocketAddress("192.168.1.40", 13344)); - UtpConnectFuture cFuture = chanel.connect(new InetSocketAddress("localhost", 13344)); + UtpConnectFuture cFuture = chanel.connect(new InetSocketAddress(ip, 13344)); // UtpConnectFuture cFuture = chanel.connect(new InetSocketAddress("192.168.1.44", 13344)); cFuture.block(); @@ -113,7 +122,7 @@ public static void main(String[] args) throws IOException, InterruptedException chanel.close(); buffer.clear(); cpuLoad.reset(); - Thread.sleep(15000); + Thread.sleep(1000); } closeLog(); @@ -160,13 +169,10 @@ private static void openLog() throws IOException { /* Transmission Rate calculus */ private static String calculateRate(int bytesToSend, long start, long end) { - long seconds = (end - start)/1000000; - long sendRate = 0; - if (seconds != 0) { - sendRate = (bytesToSend/1024)/seconds; - } - return sendRate + "kB/sec"; + double seconds = (double)(end - start)/1000000d; + double sendRate = ((double)bytesToSend/1024d)/seconds; + return Math.round(sendRate) + "kB/sec"; } -} +} \ No newline at end of file