From 62ec5315ec74b6b51363f546eaf015341dd3cb62 Mon Sep 17 00:00:00 2001 From: Anton Johansson Date: Tue, 30 Oct 2007 20:47:38 +0100 Subject: [PATCH] prrroff --- Makefile | 20 ++++++++++---------- Node.java | 6 +++--- NodeInterface.java | 4 ++-- TCPNode.java | 4 ++-- UDPNode.java | 6 +++--- rapport/rapport.tex | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index c691738..70e94b1 100644 --- a/Makefile +++ b/Makefile @@ -33,18 +33,18 @@ runTCP : java $(CFLAGS) TCPNode 9809 localhost 9800 & runTCPtry : - java $(CFLAGS) TCPNode 9800 fyrkant 9801 L & - ssh fyrkant "java $(CFLAGS) TCPNode 9801 $(HOST) 9802" & - java $(CFLAGS) TCPNode 9802 kub 9803 & - ssh kub "java $(CFLAGS) TCPNode 9803 $(HOST) 9804" & - java $(CFLAGS) TCPNode 9804 localhost 9800 & + java $(CFLAGS) TCPNode 9800 fyrkant 9801 L & + ssh fyrkant "java $(CFLAGS) TCPNode 9801 $(HOST) 9802" & + java $(CFLAGS) TCPNode 9802 kub 9803 & + ssh kub "java $(CFLAGS) TCPNode 9803 $(HOST) 9804" & + java $(CFLAGS) TCPNode 9804 localhost 9800 & runUDPtry : - java $(CFLAGS) UDPNode 9800 fyrkant 9801 L & - ssh fyrkant "java $(CFLAGS) UDPNode 9801 $(HOST) 9802" & - java $(CFLAGS) UDPNode 9802 kub 9803 & - ssh kub "java $(CFLAGS) UDPNode 9803 $(HOST) 9804" & - java $(CFLAGS) UDPNode 9804 localhost 9800 & + java $(CFLAGS) UDPNode 9800 fyrkant 9801 L & + ssh fyrkant "java $(CFLAGS) UDPNode 9801 $(HOST) 9802" & + java $(CFLAGS) UDPNode 9802 kub 9803 & + ssh kub "java $(CFLAGS) UDPNode 9803 $(HOST) 9804" & + java $(CFLAGS) UDPNode 9804 localhost 9800 & api : javadoc *.java -d $HOME/public_html -charset UTF-8 diff --git a/Node.java b/Node.java index 7d57086..1e0e4ac 100644 --- a/Node.java +++ b/Node.java @@ -1,6 +1,6 @@ /* * @(#)Node.java - * Time-stamp: "2007-10-30 20:00:19 spoof" + * Time-stamp: "2007-10-30 20:36:14 anton" */ import java.util.Random; @@ -145,12 +145,12 @@ public abstract class Node implements NodeInterface { * @return boolean true if writing to the log file * was successful, false if not. */ - public boolean writeToLog() { + public boolean writeToLog(String id) { try { out.write("Average time so far: " + (System.nanoTime() - startTime)/(double)sentPackets + - " ns\n"); + " ns, ID = " + id + "\n"); } catch (IOException e) { System.out.println(e); diff --git a/NodeInterface.java b/NodeInterface.java index d7a7f0e..8b6a1f0 100644 --- a/NodeInterface.java +++ b/NodeInterface.java @@ -1,6 +1,6 @@ /* * @(#)NodeInterface.java - * Time-stamp: "2007-10-18 01:50:57 spoof" + * Time-stamp: "2007-10-30 20:39:29 anton" */ import java.net.DatagramPacket; @@ -15,6 +15,6 @@ public interface NodeInterface { public abstract boolean sendPacket(DatagramPacket sendPacket); public abstract boolean receivePacket(DatagramPacket receivePacket); public abstract DatagramPacket constructPacket(int messageType, String message); - public abstract boolean writeToLog(); + public abstract boolean writeToLog(String id); public abstract boolean closeLogFile(); } diff --git a/TCPNode.java b/TCPNode.java index 9761e78..e2f7b98 100644 --- a/TCPNode.java +++ b/TCPNode.java @@ -1,6 +1,6 @@ /* * @(#)TCPNode.java - * Time-stamp: "2007-10-30 17:33:34 spoof" + * Time-stamp: "2007-10-30 20:39:05 anton" */ // import necessary input/output classes @@ -242,7 +242,7 @@ public class TCPNode extends Node { // if this node is a logging node, if (isLogger) { // write the current average lap time of the data - writeToLog(); + writeToLog(new String(receivedData).substring(2, receivedData[1] + 2)); } // send data to the next node diff --git a/UDPNode.java b/UDPNode.java index 6bdb822..62d7ec1 100644 --- a/UDPNode.java +++ b/UDPNode.java @@ -1,6 +1,6 @@ /* * @(#)UDPNode.java - * Time-stamp: "2007-10-30 16:22:02 spoof" + * Time-stamp: "2007-10-30 20:40:28 anton" */ import java.io.FileWriter; @@ -141,7 +141,7 @@ public class UDPNode extends Node { // if this node is a logger: if (isLogger) { // write to file - writeToLog(); + writeToLog(new String(receivedData).substring(2, receivedData[1] + 2)); } // if this is the master node and // we've sent as many packets as we were to (and the @@ -166,7 +166,7 @@ public class UDPNode extends Node { // if this node is a logger, log one final time before // stopping the whole shebang and close the file if (isLogger) { - writeToLog(); + writeToLog(new String(receivedData).substring(2, receivedData[1] + 2)); System.out.println("Closing file..."); closeLogFile(); System.out.println("Finished."); diff --git a/rapport/rapport.tex b/rapport/rapport.tex index a30dfd1..decac5c 100644 --- a/rapport/rapport.tex +++ b/rapport/rapport.tex @@ -94,7 +94,7 @@ till anslutande nod i fas ett. När noder tar emot meddelande i denna fas så jämförs nodens egna nummer med det som kommer i meddelandet. Om ankommande nummer är större än nodens egna så skickas detta nummer vidare istället för nodens egna genererade nummer. När en nod får -tillbaka sitt egna nummer så är ringen sluten. Nu inleds fas två. +tillbaka sitt egna nummer så är ringen sluten. Då inleds fas två. I fas två, börjar en utvald nod att skicka ett meddelande, sedan skickas detta meddelande runt i ringen ett specificerat antal -- 2.11.4.GIT