From a81042946747f4f029bf04ff0b52cf0446f3c41d Mon Sep 17 00:00:00 2001 From: emigranteMuse Date: Wed, 8 Mar 2017 21:26:06 +0800 Subject: [PATCH] 3.8 --- src/nankai/oram/client/NewMCOSORAMClient.java | 4 +-- .../Test/TestReadWrite/NewMCOSInitOram.java | 2 +- .../TestReadWrite/NewMCOSReadAndWrite.java | 33 +++++++------------ .../oram/client/mCloud/MCloudCommInfo.java | 20 +++++------ .../oram/client/mCloud/NewMCOSPartition.java | 24 +++++++++++--- .../oram/client/mCloud/SubCloudNewORAM.java | 15 +++++++-- 6 files changed, 57 insertions(+), 41 deletions(-) diff --git a/src/nankai/oram/client/NewMCOSORAMClient.java b/src/nankai/oram/client/NewMCOSORAMClient.java index 303d920..0fce2c6 100644 --- a/src/nankai/oram/client/NewMCOSORAMClient.java +++ b/src/nankai/oram/client/NewMCOSORAMClient.java @@ -261,8 +261,8 @@ public class NewMCOSORAMClient implements ORAM{ if (slots[c].size() >= MCloudCommInfo.evictConditionSize) { -// System.out.println("evict c:"+c+" slot size:"+slots[c].size()); - subORAMs[c].writeCloud(slots[c]); + if (subORAMs[c].canWrite()) + subORAMs[c].writeCloud(slots[c]); } } diff --git a/src/nankai/oram/client/Test/TestReadWrite/NewMCOSInitOram.java b/src/nankai/oram/client/Test/TestReadWrite/NewMCOSInitOram.java index 39851f6..ff8a1b3 100644 --- a/src/nankai/oram/client/Test/TestReadWrite/NewMCOSInitOram.java +++ b/src/nankai/oram/client/Test/TestReadWrite/NewMCOSInitOram.java @@ -18,7 +18,7 @@ public class NewMCOSInitOram { NewMCOSORAMClient oram=new NewMCOSORAMClient(); //initialize the client - oram.init(102400); + oram.init(40000); oram.openConnection(); long testTime = -1; diff --git a/src/nankai/oram/client/Test/TestReadWrite/NewMCOSReadAndWrite.java b/src/nankai/oram/client/Test/TestReadWrite/NewMCOSReadAndWrite.java index 1a02d00..c66808a 100644 --- a/src/nankai/oram/client/Test/TestReadWrite/NewMCOSReadAndWrite.java +++ b/src/nankai/oram/client/Test/TestReadWrite/NewMCOSReadAndWrite.java @@ -10,7 +10,7 @@ import nankai.oram.common.Util; public class NewMCOSReadAndWrite { - public static int N = 102400; + public static int N = 40000; public static void main(String[] args) { @@ -26,12 +26,9 @@ public class NewMCOSReadAndWrite { private static void testMultiWrite() { //testWrite(5); - testWrite(10); - testWrite(25); - testWrite(50); - testWrite(75); - testWrite(100); - testWrite(150); + testWrite(10); + testWrite(50); + testWrite(100); testWrite(1000); } @@ -80,17 +77,12 @@ public class NewMCOSReadAndWrite { oram.openORAM(); Util.debug = false; - - - writeTheBlocks(oram, N); - - - accessWithRandomStatus(oram, 500); - accessWithRandomStatus(oram, 1000); - accessWithRandomStatus(oram, 5000); - accessWithRandomStatus(oram, 10000); - accessWithRandomStatus(oram, 50000); - accessWithRandomStatus(oram, 100000); + + writeTheBlocks(oram, N); + + accessWithRandomStatus(oram, 50); + accessWithRandomStatus(oram, 100); + accessWithRandomStatus(oram, 500); accessWithRandomStatus(oram, 1000); // oram.closeConnection(); @@ -122,8 +114,7 @@ public class NewMCOSReadAndWrite { accessWithSameStatus(oram, 1000); //accessWithSameStatus(oram, 2500); accessWithSameStatus(oram, 5000); -// accessWithSameStatus(oram, 7500); - accessWithSameStatus(oram, 10000); +// accessWithSameStatus(oram, 7500); accessWithSameStatus(oram, 10000); // writeTheBlocks(oram, 10000); // @@ -187,7 +178,7 @@ public class NewMCOSReadAndWrite { System.out.println("totalElapsedTime:"+totalElapsedTime); // System.out.println("-----Shuffle numeber-----!"+Util.writeNumber+" Util.cloudtocloud:"+ Util.cloudtocloud); // System.out.println("-----ORAM CACHE-----!"+ oram.getCacheSlotSize()); - System.out.println("-----writeNumber ---- "+Util.writeNumber ); + System.out.println("-----writeNumb r ---- "+Util.writeNumber ); System.out.println("-----cloudtocloud ---- "+Util.cloudtocloud ); System.out.println("-----readNumber ---- "+Util.readNumber ); System.out.println("-----bandwidth ---- "+ Util.bandwidth ); diff --git a/src/nankai/oram/client/mCloud/MCloudCommInfo.java b/src/nankai/oram/client/mCloud/MCloudCommInfo.java index 65032a5..6cd803e 100644 --- a/src/nankai/oram/client/mCloud/MCloudCommInfo.java +++ b/src/nankai/oram/client/mCloud/MCloudCommInfo.java @@ -13,17 +13,17 @@ public interface MCloudCommInfo { // public static int evictConditionSize = 16;//1+2+4=6 // public static int cloudNumber = 2; //the cloud number -// public static int severBeginLevel = 2;//the default level of each partition in the server -// public static int clientEndLevel =1;//the default level of each partition in the client cache -// public static int evictConditionSize = 3;//1+2+4=6 -// public static int cloudNumber = 2; //the cloud number - - public static int severBeginLevel = 5;//the default level of each partition in the server - public static int clientEndLevel = 4;//the default level of each partition in the client cache - public static int evictConditionSize = 32;//1+2+4+8=15 + public static int severBeginLevel = 2;//the default level of each partition in the server + public static int clientEndLevel =1;//the default level of each partition in the client cache + public static int evictConditionSize = 4;//1+2+4=6 public static int cloudNumber = 2; //the cloud number + +// public static int severBeginLevel = 5;//the default level of each partition in the server +// public static int clientEndLevel = 4;//the default level of each partition in the client cache +// public static int evictConditionSize = 32;//1+2+4+8=15 +// public static int cloudNumber = 2; //the cloud number - public static String[] ip={ "114.215.26.85", "114.215.26.85"}; - //public static String[] ip={ "localhost", "localhost"}; + //public static String[] ip={ "114.215.26.85", "114.215.26.85"}; + public static String[] ip={ "localhost", "localhost"}; public static int[] port={ 2121, 2122}; } diff --git a/src/nankai/oram/client/mCloud/NewMCOSPartition.java b/src/nankai/oram/client/mCloud/NewMCOSPartition.java index cc1dba3..bd6d63d 100644 --- a/src/nankai/oram/client/mCloud/NewMCOSPartition.java +++ b/src/nankai/oram/client/mCloud/NewMCOSPartition.java @@ -199,6 +199,16 @@ public class NewMCOSPartition{ // Second, onion decrypt by the user key subOram.decryptData(data); } + + + //update all the real numbers + realDataNumber=0; + int levelBegin = (1 << (MCloudCommInfo.severBeginLevel + 1)) - 2; + for (int i=levelBegin; i0 && readFlag[i]==false) + realDataNumber++; + } return data ; } @@ -353,7 +363,7 @@ public class NewMCOSPartition{ int rndLength = filledLevelLength - dataNumber - 2*evictSize; if (rndLength<0){ - System.out.println(" rndLength "+ rndLength +" filledLevelLength "+filledLevelLength+" dataNumber "+dataNumber+" evictSize "+evictSize ); + //System.out.println(" rndLength "+ rndLength +" filledLevelLength "+filledLevelLength+" dataNumber "+dataNumber+" evictSize "+evictSize ); return; } @@ -541,9 +551,13 @@ public class NewMCOSPartition{ realDataNumber=0; for (int i=levelBegin; i0) + if (blockIDs[i]>0 && readFlag[i]==false) realDataNumber++; } + + + if (realDataNumber > this.n_realBlocks_p) + realDataNumber=realDataNumber; } @@ -632,9 +646,9 @@ public class NewMCOSPartition{ realDataNumber=0; for (int i=levelBegin; i0) + if (blockIDs[i]>0 && readFlag[i]==false) realDataNumber++; - } + } } @@ -696,7 +710,7 @@ public class NewMCOSPartition{ } //Notice that, there is no dummy blocks - //System.out.println("No dummy !!!!!! return 0!!!!!p:"+this.partition+" !!!type:"+type+" level:"+level+" nextDummy[level]"+nextDummy[level]); +// System.out.println("No dummy !!!!!! return 0!!!!!p:"+this.partition+" !!!type:"+type+" level:"+level+" nextDummy[level]"+nextDummy[level]); return -1; } } diff --git a/src/nankai/oram/client/mCloud/SubCloudNewORAM.java b/src/nankai/oram/client/mCloud/SubCloudNewORAM.java index 4633449..1535da4 100644 --- a/src/nankai/oram/client/mCloud/SubCloudNewORAM.java +++ b/src/nankai/oram/client/mCloud/SubCloudNewORAM.java @@ -115,7 +115,7 @@ public class SubCloudNewORAM implements MultiCloudORAM { int p = 1;//rnd.nextInt(n_partitions); if (Util.debug == false){ p = rnd.nextInt(n_partitions); - //not write to the partition with more than the pre-defined real blocks + //not write to the partition with more than the pre-defined real blocks while ( partitions[p].realDataNumber >= (partitions[p].top_level_len - 2*MCloudCommInfo.evictConditionSize) ) p = rnd.nextInt(n_partitions); } @@ -130,7 +130,18 @@ public class SubCloudNewORAM implements MultiCloudORAM { partitions[p].writePartition(slot, cli[cloud], otherCloud, cli[otherCloud], userKey, cloud); } - + + public boolean canWrite() + { + int realnumber = 0; + for (int i=0;i ( (this.n_realBlocks_p * this.n_partitions * 11)/10 ) ) + return false; + return true; + } @Override