Ver código fonte

add Retrieve time and bandwidth output printing

Boyoung- 6 anos atrás
pai
commit
7a283ab70e

+ 6 - 3
src/protocols/Eviction.java

@@ -22,18 +22,21 @@ import subprotocols.PermuteIndex;
 import subprotocols.PermuteTarget;
 import subprotocols.SSXOT;
 import util.M;
+import util.P;
 import util.Util;
 
 // TODO: set bucket on path
 
 public class Eviction extends Protocol {
 
+	int pid = P.EVI;
+
 	public Eviction(Communication con1, Communication con2) {
 		super(con1, con2);
 
-		online_band = all.Eviction_on;
-		offline_band = all.Eviction_off;
-		timer = all.Eviction;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	private int[] prepareEviction(int[] target, int[] ti, int W) {

+ 6 - 3
src/protocols/FlipFlag.java

@@ -9,16 +9,19 @@ import struct.OutFF;
 import struct.Party;
 import subprotocols.Shift;
 import util.M;
+import util.P;
 import util.Util;
 
 public class FlipFlag extends Protocol {
 
+	int pid = P.FF;
+
 	public FlipFlag(Communication con1, Communication con2) {
 		super(con1, con2);
 
-		online_band = all.FlipFlag_on;
-		offline_band = all.FlipFlag_off;
-		timer = all.FlipFlag;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	// TODO: remove loop around setXor: use Util.setXor(byte[][], byte[][])

+ 6 - 3
src/protocols/PIRAccess.java

@@ -22,16 +22,19 @@ import subprotocols.PIRCOT;
 import subprotocols.ThreeShiftPIR;
 import subprotocols.ThreeShiftXorPIR;
 import util.M;
+import util.P;
 import util.Util;
 
 public class PIRAccess extends Protocol {
 
+	int pid = P.ACC;
+
 	public PIRAccess(Communication con1, Communication con2) {
 		super(con1, con2);
 
-		online_band = all.Access_on;
-		offline_band = all.Access_off;
-		timer = all.Access;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public OutPIRAccess runE(Metadata md, Tree tree_DE, Tree tree_CE, byte[] Li, TwoThreeXorByte L, TwoThreeXorByte N,

+ 38 - 17
src/protocols/PIRRetrieve.java

@@ -19,8 +19,8 @@ import struct.TwoThreeXorByte;
 import struct.TwoThreeXorInt;
 import util.Bandwidth;
 import util.M;
+import util.P;
 import util.StopWatch;
-import util.Timer;
 import util.Util;
 
 // TODO: really FlipFlag on path, and update path in Eviction
@@ -31,12 +31,14 @@ public class PIRRetrieve extends Protocol {
 	Communication[] cons1;
 	Communication[] cons2;
 
+	int pid = P.RTV;
+
 	public PIRRetrieve(Communication con1, Communication con2) {
 		super(con1, con2);
 
-		online_band = new Bandwidth();
-		offline_band = new Bandwidth();
-		timer = new Timer();
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public void setCons(Communication[] a, Communication[] b) {
@@ -281,13 +283,13 @@ public class PIRRetrieve extends Protocol {
 		Tree tree_DE = null;
 		Tree tree_CE = null;
 
-		int iterations = 100;
-		int reset = 20;
+		int iterations = 10;
+		int reset = 2;
 
 		for (int test = 0; test < iterations; test++) {
 
 			if (test == reset) {
-				timer.reset();
+				all.resetTime();
 				ete.reset();
 			}
 			if (test == 1) {
@@ -373,22 +375,41 @@ public class PIRRetrieve extends Protocol {
 
 		}
 
-		// Bandwidth total = new Bandwidth("Total Online");
-		// for (int i = 0; i < P.size; i++) {
-		// for (int j = 0; j < cons1.length; j++)
-		// total.add(cons1[j].bandwidth[i].add(cons2[j].bandwidth[i]).bandwidth);
-		// }
-		// System.out.println(total.toString());
+		System.out.println();
+
+		Bandwidth band_on = new Bandwidth("Total Online Band");
+		Bandwidth band_off = new Bandwidth("Total Offline Band");
+		for (int i = 0; i < P.size; i++) {
+			System.out.println(all.offline_band[i].noPreToString());
+			System.out.println(all.online_band[i].noPreToString());
+			band_on.add(all.online_band[i]);
+			band_off.add(all.offline_band[i]);
+		}
+		System.out.println(band_off.noPreToString());
+		System.out.println(band_on.noPreToString());
+
+		System.out.println();
+
+		StopWatch time_on = new StopWatch("Total Online Time");
+		StopWatch time_off = new StopWatch("Total Offline Time");
+		for (int i = 0; i < P.size; i++) {
+			for (int j = 0; j < 3; j++)
+				time_on.add(all.timer[i].watches[j]);
+			for (int j = 3; j < M.size; j++)
+				time_off.add(all.timer[i].watches[j]);
+			all.timer[i].noPrePrint();
+		}
+		System.out.println(time_off.noPreToMS());
+		System.out.println(time_on.noPreToMS());
 
-		// timer.divideBy(iterations - reset);
-		// timer.print();
+		System.out.println();
+		System.out.println(ete.noPreToMS());
 
-		System.out.println(ete.toMS());
+		System.out.println();
 
 		sanityCheck();
 	}
 
-	// for testing correctness
 	@Override
 	public void run(Party party, Metadata md, Forest forest) {
 	}

+ 1 - 1
src/protocols/Protocol.java

@@ -7,8 +7,8 @@ import oram.Forest;
 import oram.Global;
 import oram.Metadata;
 import struct.Party;
-import struct.TimeAndBandwidth;
 import util.Bandwidth;
+import util.TimeAndBandwidth;
 import util.Timer;
 
 public abstract class Protocol {

+ 9 - 6
src/protocols/ULiT.java

@@ -15,6 +15,7 @@ import struct.TwoThreeXorByte;
 import struct.TwoThreeXorInt;
 import subprotocols.InsLbl;
 import util.M;
+import util.P;
 import util.Util;
 
 public class ULiT extends Protocol {
@@ -22,12 +23,14 @@ public class ULiT extends Protocol {
 	SecureRandom sr1;
 	SecureRandom sr2;
 
+	int pid = P.ULIT;
+
 	public ULiT(Communication con1, Communication con2) {
 		super(con1, con2);
 
-		online_band = all.ULiT_on;
-		offline_band = all.ULiT_off;
-		timer = all.ULiT;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public ULiT(Communication con1, Communication con2, SecureRandom sr1, SecureRandom sr2) {
@@ -35,9 +38,9 @@ public class ULiT extends Protocol {
 		this.sr1 = sr1;
 		this.sr2 = sr2;
 
-		online_band = all.ULiT_on;
-		offline_band = all.ULiT_off;
-		timer = all.ULiT;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public void reinit(Communication con1, Communication con2, SecureRandom sr1, SecureRandom sr2) {

+ 6 - 3
src/protocols/UpdateRoot.java

@@ -21,16 +21,19 @@ import oram.Tuple;
 import struct.Party;
 import subprotocols.SSXOT;
 import util.M;
+import util.P;
 import util.Util;
 
 public class UpdateRoot extends Protocol {
 
+	int pid = P.UR;
+
 	public UpdateRoot(Communication con1, Communication con2) {
 		super(con1, con2);
 
-		online_band = all.UpdateRoot_on;
-		offline_band = all.UpdateRoot_off;
-		timer = all.UpdateRoot;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public Tuple[] runE(boolean firstTree, int sw, int lBits, int[] tupleParam, byte[] Li, Tuple[] R, Tuple Ti) {

+ 0 - 121
src/struct/TimeAndBandwidth.java

@@ -1,121 +0,0 @@
-package struct;
-
-import util.Bandwidth;
-import util.Timer;
-
-public class TimeAndBandwidth {
-	public Bandwidth KSearch_on;
-	public Bandwidth KSearch_off;
-
-	public Bandwidth SSPIR_on;
-	public Bandwidth SSPIR_off;
-	public Bandwidth ShiftPIR_on;
-	public Bandwidth ShiftPIR_off;
-	public Bandwidth ThreeShiftPIR_on;
-	public Bandwidth ThreeShiftPIR_off;
-	public Bandwidth ShiftXorPIR_on;
-	public Bandwidth ShiftXorPIR_off;
-	public Bandwidth ThreeShiftXorPIR_on;
-	public Bandwidth ThreeShiftXorPIR_off;
-
-	public Bandwidth InsLbl_on;
-	public Bandwidth InsLbl_off;
-	public Bandwidth ULiT_on;
-	public Bandwidth ULiT_off;
-
-	public Bandwidth Shift_on;
-	public Bandwidth Shift_off;
-	public Bandwidth FlipFlag_on;
-	public Bandwidth FlipFlag_off;
-
-	public Bandwidth SSXOT_on;
-	public Bandwidth SSXOT_off;
-	public Bandwidth UpdateRoot_on;
-	public Bandwidth UpdateRoot_off;
-	public Bandwidth PermBucket_on;
-	public Bandwidth PermBucket_off;
-	public Bandwidth PermTuple_on;
-	public Bandwidth PermTuple_off;
-
-	public Bandwidth Access_on;
-	public Bandwidth Access_off;
-
-	public Bandwidth PostProcess_on;
-	public Bandwidth PostProcess_off;
-
-	public Bandwidth Eviction_on;
-	public Bandwidth Eviction_off;
-
-	public Timer KSearch;
-	public Timer SSPIR;
-	public Timer ShiftPIR;
-	public Timer ThreeShiftPIR;
-	public Timer ShiftXorPIR;
-	public Timer ThreeShiftXorPIR;
-	public Timer InsLbl;
-	public Timer ULiT;
-	public Timer Shift;
-	public Timer FlipFlag;
-	public Timer SSXOT;
-	public Timer UpdateRoot;
-	public Timer PermBucket;
-	public Timer PermTuple;
-	public Timer Access;
-	public Timer PostProcess;
-	public Timer Eviction;
-
-	public TimeAndBandwidth() {
-		KSearch_on = new Bandwidth();
-		KSearch_off = new Bandwidth();
-		SSPIR_on = new Bandwidth();
-		SSPIR_off = new Bandwidth();
-		ShiftPIR_on = new Bandwidth();
-		ShiftPIR_off = new Bandwidth();
-		ThreeShiftPIR_on = new Bandwidth();
-		ThreeShiftPIR_off = new Bandwidth();
-		ShiftXorPIR_on = new Bandwidth();
-		ShiftXorPIR_off = new Bandwidth();
-		ThreeShiftXorPIR_on = new Bandwidth();
-		ThreeShiftXorPIR_off = new Bandwidth();
-		InsLbl_on = new Bandwidth();
-		InsLbl_off = new Bandwidth();
-		ULiT_on = new Bandwidth();
-		ULiT_off = new Bandwidth();
-		Shift_on = new Bandwidth();
-		Shift_off = new Bandwidth();
-		FlipFlag_on = new Bandwidth();
-		FlipFlag_off = new Bandwidth();
-		SSXOT_on = new Bandwidth();
-		SSXOT_off = new Bandwidth();
-		UpdateRoot_on = new Bandwidth();
-		UpdateRoot_off = new Bandwidth();
-		PermBucket_on = new Bandwidth();
-		PermBucket_off = new Bandwidth();
-		PermTuple_on = new Bandwidth();
-		PermTuple_off = new Bandwidth();
-		Access_on = new Bandwidth();
-		Access_off = new Bandwidth();
-		PostProcess_on = new Bandwidth();
-		PostProcess_off = new Bandwidth();
-		Eviction_on = new Bandwidth();
-		Eviction_off = new Bandwidth();
-
-		KSearch = new Timer();
-		SSPIR = new Timer();
-		ShiftPIR = new Timer();
-		ThreeShiftPIR = new Timer();
-		ShiftXorPIR = new Timer();
-		ThreeShiftXorPIR = new Timer();
-		InsLbl = new Timer();
-		ULiT = new Timer();
-		Shift = new Timer();
-		FlipFlag = new Timer();
-		SSXOT = new Timer();
-		UpdateRoot = new Timer();
-		PermBucket = new Timer();
-		PermTuple = new Timer();
-		Access = new Timer();
-		PostProcess = new Timer();
-		Eviction = new Timer();
-	}
-}

+ 9 - 6
src/subprotocols/InsLbl.java

@@ -11,6 +11,7 @@ import oram.Metadata;
 import protocols.Protocol;
 import struct.Party;
 import util.M;
+import util.P;
 import util.Util;
 
 public class InsLbl extends Protocol {
@@ -18,12 +19,14 @@ public class InsLbl extends Protocol {
 	SecureRandom sr1;
 	SecureRandom sr2;
 
+	int pid = P.IL;
+
 	public InsLbl(Communication con1, Communication con2) {
 		super(con1, con2);
 
-		online_band = all.InsLbl_on;
-		offline_band = all.InsLbl_off;
-		timer = all.InsLbl;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public InsLbl(Communication con1, Communication con2, SecureRandom sr1, SecureRandom sr2) {
@@ -31,9 +34,9 @@ public class InsLbl extends Protocol {
 		this.sr1 = sr1;
 		this.sr2 = sr2;
 
-		online_band = all.InsLbl_on;
-		offline_band = all.InsLbl_off;
-		timer = all.InsLbl;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public void reinit(Communication con1, Communication con2, SecureRandom sr1, SecureRandom sr2) {

+ 6 - 3
src/subprotocols/PIRCOT.java

@@ -11,17 +11,20 @@ import protocols.Protocol;
 import struct.OutPIRCOT;
 import struct.Party;
 import util.M;
+import util.P;
 import util.Util;
 
 // KSearch
 public class PIRCOT extends Protocol {
 
+	int pid = P.KSER;
+
 	public PIRCOT(Communication con1, Communication con2) {
 		super(con1, con2);
 
-		online_band = all.KSearch_on;
-		offline_band = all.KSearch_off;
-		timer = all.KSearch;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public OutPIRCOT runE(byte[][] u, byte[] v) {

+ 6 - 3
src/subprotocols/PermuteIndex.java

@@ -10,16 +10,19 @@ import oram.Metadata;
 import protocols.Protocol;
 import struct.Party;
 import util.M;
+import util.P;
 import util.Util;
 
 public class PermuteIndex extends Protocol {
 
+	int pid = P.PT;
+
 	public PermuteIndex(Communication con1, Communication con2) {
 		super(con1, con2);
 
-		online_band = all.PermTuple_on;
-		offline_band = all.PermTuple_off;
-		timer = all.PermTuple;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public void runE(int w, int[] evict_pi) {

+ 6 - 3
src/subprotocols/PermuteTarget.java

@@ -13,16 +13,19 @@ import oram.Metadata;
 import protocols.Protocol;
 import struct.Party;
 import util.M;
+import util.P;
 import util.Util;
 
 public class PermuteTarget extends Protocol {
 
+	int pid = P.PB;
+
 	public PermuteTarget(Communication con1, Communication con2) {
 		super(con1, con2);
 
-		online_band = all.PermBucket_on;
-		offline_band = all.PermBucket_off;
-		timer = all.PermBucket;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public void runE(int d, int[] evict_pi, GCSignal[][][] evict_targetOutKeyPairs) {

+ 9 - 6
src/subprotocols/SSPIR.java

@@ -10,6 +10,7 @@ import oram.Metadata;
 import protocols.Protocol;
 import struct.Party;
 import util.M;
+import util.P;
 import util.Util;
 
 public class SSPIR extends Protocol {
@@ -17,12 +18,14 @@ public class SSPIR extends Protocol {
 	SecureRandom sr1;
 	SecureRandom sr2;
 
+	int pid = P.PIR;
+
 	public SSPIR(Communication con1, Communication con2) {
 		super(con1, con2);
 
-		online_band = all.SSPIR_on;
-		offline_band = all.SSPIR_off;
-		timer = all.SSPIR;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public SSPIR(Communication con1, Communication con2, SecureRandom sr1, SecureRandom sr2) {
@@ -30,9 +33,9 @@ public class SSPIR extends Protocol {
 		this.sr1 = sr1;
 		this.sr2 = sr2;
 
-		online_band = all.SSPIR_on;
-		offline_band = all.SSPIR_off;
-		timer = all.SSPIR;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public void reinit(Communication con1, Communication con2, SecureRandom sr1, SecureRandom sr2) {

+ 6 - 3
src/subprotocols/SSXOT.java

@@ -11,18 +11,21 @@ import oram.Tuple;
 import protocols.Protocol;
 import struct.Party;
 import util.M;
+import util.P;
 import util.Util;
 
 // TODO: change XOT to do 2 rounds and 2|path| bndw
 
 public class SSXOT extends Protocol {
 
+	int pid = P.XOT;
+
 	public SSXOT(Communication con1, Communication con2) {
 		super(con1, con2);
 
-		online_band = all.SSXOT_on;
-		offline_band = all.SSXOT_off;
-		timer = all.SSXOT;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public Tuple[] runE(Tuple[] m, int[] tupleParam) {

+ 6 - 3
src/subprotocols/Shift.java

@@ -8,16 +8,19 @@ import oram.Metadata;
 import protocols.Protocol;
 import struct.Party;
 import util.M;
+import util.P;
 import util.Util;
 
 public class Shift extends Protocol {
 
+	int pid = P.SFT;
+
 	public Shift(Communication con1, Communication con2) {
 		super(con1, con2);
 
-		online_band = all.Shift_on;
-		offline_band = all.Shift_off;
-		timer = all.Shift;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public byte[][] runE(byte[][] x, int s) {

+ 9 - 6
src/subprotocols/ShiftPIR.java

@@ -10,6 +10,7 @@ import oram.Metadata;
 import protocols.Protocol;
 import struct.Party;
 import util.M;
+import util.P;
 import util.Util;
 
 public class ShiftPIR extends Protocol {
@@ -17,12 +18,14 @@ public class ShiftPIR extends Protocol {
 	SecureRandom sr1;
 	SecureRandom sr2;
 
+	int pid = P.SPIR;
+
 	public ShiftPIR(Communication con1, Communication con2) {
 		super(con1, con2);
 
-		online_band = all.ShiftPIR_on;
-		offline_band = all.ShiftPIR_off;
-		timer = all.ShiftPIR;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public ShiftPIR(Communication con1, Communication con2, SecureRandom sr1, SecureRandom sr2) {
@@ -30,9 +33,9 @@ public class ShiftPIR extends Protocol {
 		this.sr1 = sr1;
 		this.sr2 = sr2;
 
-		online_band = all.ShiftPIR_on;
-		offline_band = all.ShiftPIR_off;
-		timer = all.ShiftPIR;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public void reinit(Communication con1, Communication con2, SecureRandom sr1, SecureRandom sr2) {

+ 9 - 6
src/subprotocols/ShiftXorPIR.java

@@ -11,6 +11,7 @@ import oram.Metadata;
 import protocols.Protocol;
 import struct.Party;
 import util.M;
+import util.P;
 import util.Util;
 
 public class ShiftXorPIR extends Protocol {
@@ -18,12 +19,14 @@ public class ShiftXorPIR extends Protocol {
 	SecureRandom sr1;
 	SecureRandom sr2;
 
+	int pid = P.SXPIR;
+
 	public ShiftXorPIR(Communication con1, Communication con2) {
 		super(con1, con2);
 
-		online_band = all.ShiftXorPIR_on;
-		offline_band = all.ShiftXorPIR_off;
-		timer = all.ShiftXorPIR;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public ShiftXorPIR(Communication con1, Communication con2, SecureRandom sr1, SecureRandom sr2) {
@@ -31,9 +34,9 @@ public class ShiftXorPIR extends Protocol {
 		this.sr1 = sr1;
 		this.sr2 = sr2;
 
-		online_band = all.ShiftXorPIR_on;
-		offline_band = all.ShiftXorPIR_off;
-		timer = all.ShiftXorPIR;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public void reinit(Communication con1, Communication con2, SecureRandom sr1, SecureRandom sr2) {

+ 9 - 6
src/subprotocols/ThreeShiftPIR.java

@@ -12,6 +12,7 @@ import struct.OutPIRCOT;
 import struct.Party;
 import struct.TwoThreeXorByte;
 import util.M;
+import util.P;
 import util.Util;
 
 public class ThreeShiftPIR extends Protocol {
@@ -19,12 +20,14 @@ public class ThreeShiftPIR extends Protocol {
 	SecureRandom sr1;
 	SecureRandom sr2;
 
+	int pid = P.TSPIR;
+
 	public ThreeShiftPIR(Communication con1, Communication con2) {
 		super(con1, con2);
 
-		online_band = all.ThreeShiftPIR_on;
-		offline_band = all.ThreeShiftPIR_off;
-		timer = all.ThreeShiftPIR;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public ThreeShiftPIR(Communication con1, Communication con2, SecureRandom sr1, SecureRandom sr2) {
@@ -32,9 +35,9 @@ public class ThreeShiftPIR extends Protocol {
 		this.sr1 = sr1;
 		this.sr2 = sr2;
 
-		online_band = all.ThreeShiftPIR_on;
-		offline_band = all.ThreeShiftPIR_off;
-		timer = all.ThreeShiftPIR;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public void reinit(Communication con1, Communication con2, SecureRandom sr1, SecureRandom sr2) {

+ 9 - 6
src/subprotocols/ThreeShiftXorPIR.java

@@ -14,6 +14,7 @@ import struct.Party;
 import struct.TwoOneXor;
 import struct.TwoThreeXorByte;
 import util.M;
+import util.P;
 import util.Util;
 
 public class ThreeShiftXorPIR extends Protocol {
@@ -21,12 +22,14 @@ public class ThreeShiftXorPIR extends Protocol {
 	SecureRandom sr1;
 	SecureRandom sr2;
 
+	int pid = P.TSXPIR;
+
 	public ThreeShiftXorPIR(Communication con1, Communication con2) {
 		super(con1, con2);
 
-		online_band = all.ThreeShiftXorPIR_on;
-		offline_band = all.ThreeShiftXorPIR_off;
-		timer = all.ThreeShiftXorPIR;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public ThreeShiftXorPIR(Communication con1, Communication con2, SecureRandom sr1, SecureRandom sr2) {
@@ -34,9 +37,9 @@ public class ThreeShiftXorPIR extends Protocol {
 		this.sr1 = sr1;
 		this.sr2 = sr2;
 
-		online_band = all.ThreeShiftXorPIR_on;
-		offline_band = all.ThreeShiftXorPIR_off;
-		timer = all.ThreeShiftXorPIR;
+		online_band = all.online_band[pid];
+		offline_band = all.offline_band[pid];
+		timer = all.timer[pid];
 	}
 
 	public void reinit(Communication con1, Communication con2, SecureRandom sr1, SecureRandom sr2) {

+ 2 - 2
src/util/Bandwidth.java

@@ -39,8 +39,8 @@ public class Bandwidth {
 	}
 
 	public void add(Bandwidth b) {
-		if (!task.equals(b.task))
-			throw new BandwidthException("Task: " + task + " != " + b.task);
+		// if (!task.equals(b.task))
+		// throw new BandwidthException("Task: " + task + " != " + b.task);
 		bandwidth += b.bandwidth;
 	}
 

+ 27 - 0
src/util/P.java

@@ -0,0 +1,27 @@
+package util;
+
+public class P {
+
+	public static final int KSER = 0;
+	public static final int PIR = 1;
+	public static final int SPIR = 2;
+	public static final int TSPIR = 3;
+	public static final int SXPIR = 4;
+	public static final int TSXPIR = 5;
+	public static final int IL = 6;
+	public static final int ULIT = 7;
+	public static final int SFT = 8;
+	public static final int FF = 9;
+	public static final int XOT = 10;
+	public static final int UR = 11;
+	public static final int PB = 12;
+	public static final int PT = 13;
+	public static final int ACC = 14;
+	public static final int EVI = 15;
+	public static final int RTV = 16;
+
+	public static final String[] names = { "KSearch", "SSPIR", "ShiftPIR", "3ShiftPIR", "ShiftXorPIR", "3ShiftXorPIR",
+			"InsLbl", "ULiT", "Shift", "FlipFlag", "SSXOT", "UpdateRoot", "PermBucket", "PermTuple", "Access",
+			"Eviction", "Retrieve" };
+	public static final int size = names.length;
+}

+ 23 - 9
src/util/StopWatch.java

@@ -90,10 +90,11 @@ public class StopWatch {
 	}
 
 	public String noPreToMS() {
-		return "\n" + (elapsedWC / 1000000) + "\n" + (elapsedCPU / 1000000);
+		// return "\n" + (elapsedWC / 1000000) + "\n" + (elapsedCPU / 1000000);
+		return "" + (elapsedWC / 1000000) + "\n" + (elapsedCPU / 1000000);
 	}
 
-	public StopWatch divideBy(int n) {
+	public StopWatch divideByAndReturn(int n) {
 		if (isOn) {
 			try {
 				throw new StopWatchException("StopWatch is still running");
@@ -108,6 +109,19 @@ public class StopWatch {
 		return sw;
 	}
 
+	public void divideBy(int n) {
+		if (isOn) {
+			try {
+				throw new StopWatchException("StopWatch is still running");
+			} catch (StopWatchException e) {
+				e.printStackTrace();
+			}
+		}
+
+		elapsedWC /= n;
+		elapsedCPU /= n;
+	}
+
 	public StopWatch addAndReturn(StopWatch s) {
 		if (isOn || s.isOn) {
 			try {
@@ -140,13 +154,13 @@ public class StopWatch {
 			}
 		}
 
-		if (!task.equals(s.task)) {
-			try {
-				throw new StopWatchException("Tasks don't match: " + task + " != " + s.task);
-			} catch (StopWatchException e) {
-				e.printStackTrace();
-			}
-		}
+		// if (!task.equals(s.task)) {
+		// try {
+		// throw new StopWatchException("Tasks don't match: " + task + " != " + s.task);
+		// } catch (StopWatchException e) {
+		// e.printStackTrace();
+		// }
+		// }
 
 		elapsedWC += s.elapsedWC;
 		elapsedCPU += s.elapsedCPU;

+ 24 - 0
src/util/TimeAndBandwidth.java

@@ -0,0 +1,24 @@
+package util;
+
+public class TimeAndBandwidth {
+
+	public Bandwidth[] offline_band;
+	public Bandwidth[] online_band;
+	public Timer[] timer;
+
+	public TimeAndBandwidth() {
+		offline_band = new Bandwidth[P.size];
+		online_band = new Bandwidth[P.size];
+		timer = new Timer[P.size];
+		for (int i = 0; i < P.size; i++) {
+			offline_band[i] = new Bandwidth(P.names[i] + "_off");
+			online_band[i] = new Bandwidth(P.names[i] + "_on");
+			timer[i] = new Timer(P.names[i]);
+		}
+	}
+
+	public void resetTime() {
+		for (Timer t : timer)
+			t.reset();
+	}
+}

+ 15 - 5
src/util/Timer.java

@@ -5,7 +5,7 @@ import java.util.Stack;
 import exceptions.TimerException;
 
 public class Timer {
-	StopWatch[] watches;
+	public StopWatch[] watches;
 	static Stack<StopWatch> stack;
 
 	static {
@@ -18,6 +18,12 @@ public class Timer {
 			watches[j] = new StopWatch(M.names[j]);
 	}
 
+	public Timer(String task) {
+		watches = new StopWatch[M.size];
+		for (int j = 0; j < M.size; j++)
+			watches[j] = new StopWatch(task + "_" + M.names[j]);
+	}
+
 	public Timer(StopWatch[] sws) {
 		watches = sws;
 	}
@@ -52,23 +58,27 @@ public class Timer {
 	public void print() {
 		if (!stack.empty())
 			throw new TimerException("Stack not empty");
-		for (int i = 0; i < watches.length; i++)
+		for (int i = 3; i < watches.length; i++)
+			System.out.println(watches[i].toMS());
+		for (int i = 0; i < 3; i++)
 			System.out.println(watches[i].toMS());
 	}
 
 	public void noPrePrint() {
 		if (!stack.empty())
 			throw new TimerException("Stack not empty");
-		for (int i = 0; i < watches.length; i++)
+		for (int i = 3; i < watches.length; i++)
+			System.out.println(watches[i].noPreToMS());
+		for (int i = 0; i < 3; i++)
 			System.out.println(watches[i].noPreToMS());
 	}
 
-	public Timer divideBy(int n) {
+	public Timer divideByAndReturn(int n) {
 		if (!stack.empty())
 			throw new TimerException("Stack not empty");
 		StopWatch[] sws = new StopWatch[M.size];
 		for (int i = 0; i < watches.length; i++)
-			sws[i] = watches[i].divideBy(n);
+			sws[i] = watches[i].divideByAndReturn(n);
 		return new Timer(sws);
 	}