This commit is contained in:
emigranteMuse 2017-03-08 21:26:06 +08:00
parent 40f771b724
commit a810429467
6 changed files with 57 additions and 41 deletions

View File

@ -261,7 +261,7 @@ public class NewMCOSORAMClient implements ORAM{
if (slots[c].size() >= MCloudCommInfo.evictConditionSize)
{
// System.out.println("evict c:"+c+" slot size:"+slots[c].size());
if (subORAMs[c].canWrite())
subORAMs[c].writeCloud(slots[c]);
}
}

View File

@ -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;

View File

@ -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) {
@ -27,11 +27,8 @@ public class NewMCOSReadAndWrite {
private static void testMultiWrite() {
//testWrite(5);
testWrite(10);
testWrite(25);
testWrite(50);
testWrite(75);
testWrite(100);
testWrite(150);
testWrite(1000);
}
@ -81,16 +78,11 @@ public class NewMCOSReadAndWrite {
Util.debug = false;
writeTheBlocks(oram, N);
accessWithRandomStatus(oram, 500);
accessWithRandomStatus(oram, 1000);
accessWithRandomStatus(oram, 5000);
accessWithRandomStatus(oram, 10000);
accessWithRandomStatus(oram, 50000);
accessWithRandomStatus(oram, 100000);
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 );

View File

@ -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 String[] ip={ "114.215.26.85", "114.215.26.85"};
//public static String[] ip={ "localhost", "localhost"};
// 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 int[] port={ 2121, 2122};
}

View File

@ -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; i<this.n_capacity; i++)
{
if (blockIDs[i]>0 && 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; i<this.n_capacity; i++)
{
if (blockIDs[i]>0)
if (blockIDs[i]>0 && readFlag[i]==false)
realDataNumber++;
}
if (realDataNumber > this.n_realBlocks_p)
realDataNumber=realDataNumber;
}
@ -632,7 +646,7 @@ public class NewMCOSPartition{
realDataNumber=0;
for (int i=levelBegin; i<this.n_capacity; i++)
{
if (blockIDs[i]>0)
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;
}
}

View File

@ -131,6 +131,17 @@ 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_partitions; i++)
{
realnumber += this.partitions[i].realDataNumber;
}
if (realnumber> ( (this.n_realBlocks_p * this.n_partitions * 11)/10 ) )
return false;
return true;
}
@Override