Ver Fonte

further eval

Simon há 2 anos atrás
pai
commit
a7ffc6dec0

+ 7 - 21
client/client.go

@@ -42,7 +42,7 @@ type tweet struct {
 const leader string = "127.0.0.1:4441"
 
 //needs to be changed at leader/follower/client at the same time
-const numClients = 5000
+const numClients = 500
 
 //mylimit=8000
 //sudo prlimit --nofile=$mylimit --pid $$; ulimit -n $mylimit
@@ -65,7 +65,7 @@ var timeBounds []float64
 //this translates to a simulated round length of ~2h
 var speedUp float64 = 7200 / ((maxTimePerRound.Seconds()) * 3)
 
-var maxTimePerRound time.Duration = 200 * time.Second
+var maxTimePerRound time.Duration = 1000 * time.Second
 var startTime int
 
 var archiveInterests = make([]int, 1)
@@ -117,7 +117,6 @@ func client(clientNumber int, f *os.File) {
 
 	leaderConn, err := tls.Dial("tcp", leader, conf)
 	if err != nil {
-		fmt.Println("clientNumber", clientNumber)
 		panic(err)
 	}
 	leaderConn.SetDeadline(time.Time{})
@@ -279,7 +278,6 @@ func client(clientNumber int, f *os.File) {
 
 			writeTo(leaderConn, wantsArchive)
 
-			//fmt.Println("list", archiveTopicList)
 			if wantsArchive[0] == 1 && len(archiveTopicList) > 0 {
 				encryptedQueryLeader, encryptedQueryFollower = createPIRQuery(-1, clientNumber)
 				sendQuerys(encryptedQueryLeader, encryptedQueryFollower, leaderConn, true)
@@ -453,8 +451,6 @@ func receiveTweets(sharedSecret [2][32]byte, leaderConn net.Conn, getArchive boo
 
 		tweets := readFrom(leaderConn, tweetsLength)
 
-		//fmt.Println(tweets[:10])
-
 		//expand sharedSecret so it is of right length
 		expandBy := len(tweets) / 32
 		expandedSharedSecrets := make([][]byte, 2)
@@ -470,8 +466,6 @@ func receiveTweets(sharedSecret [2][32]byte, leaderConn net.Conn, getArchive boo
 			lib.Xor(expandedSharedSecrets[i][:], tweets)
 		}
 
-		//fmt.Println("PubKey", clientPublicKey[clientNumber], "Bytes", tweets)
-
 		index := strings.Index(string(tweets), ";;")
 
 		if index != -1 {
@@ -479,8 +473,6 @@ func receiveTweets(sharedSecret [2][32]byte, leaderConn net.Conn, getArchive boo
 			textArr := strings.Split(string(tweets), ";;;")
 			text := textArr[:len(textArr)-1]
 
-			//fmt.Println("Round", round, text[0], "Length", len(tweets))
-
 			if text[1] != "" {
 				text[1] = text[1][1:]
 
@@ -488,8 +480,6 @@ func receiveTweets(sharedSecret [2][32]byte, leaderConn net.Conn, getArchive boo
 			ok := strings.Contains(text[0], text[1])
 			if !ok {
 				goodPadding++
-				//fmt.Println("Round", round, text[0], "Length", len(tweets))
-				//fmt.Println("padding", text[1])
 			}
 
 		} else if index == -1 && tweets[0] != 0 {
@@ -673,6 +663,11 @@ func getRealTweet(clientNumber int) []byte {
 
 	for scanner.Scan() {
 
+		//skips round 1, cause of 90% publisher rate
+		if round == 1 {
+			//break
+		}
+
 		lineArr := strings.Split(scanner.Text(), ", \"hashtags\"")
 		lineArr = strings.Split(lineArr[0], ": ")
 		lineArr = strings.Split(lineArr[1], " \"")
@@ -707,7 +702,6 @@ func getRealTweet(clientNumber int) []byte {
 
 			topics = topics[:len(topics)-1]
 
-			//fmt.Println(string(topics))
 			tweet = append(tweet, topics...)
 			tweet = append(tweet, []byte(";")[0])
 
@@ -717,7 +711,6 @@ func getRealTweet(clientNumber int) []byte {
 				num = 1
 			}
 			tweet = append(tweet, []byte(strconv.Itoa(num) + ";;")[:]...)
-			//fmt.Println("tweet", string(tweet))
 
 			//adds padding
 			length := dataLength - len(tweet)
@@ -771,7 +764,6 @@ func getRandomTweet(clientNumber int) []byte {
 	}
 
 	sort.Ints(topicNumbers)
-	//fmt.Println("topicNumbers", topicNumbers)
 	var topics []byte
 
 	topicIndex := 0
@@ -796,12 +788,6 @@ func getRandomTweet(clientNumber int) []byte {
 	tweet = append(tweet, text...)
 	tweet = append(tweet, []byte(";")[0])
 
-	//fmt.Println("writing", string(text))
-	//fmt.Println(topicNumbers)
-
-	if len(tweet) > 32 {
-		fmt.Println("lenlen", len(tweet))
-	}
 	//adds padding
 	length := dataLength - len(tweet)
 	padding := make([]byte, length)

+ 71 - 0
data/evalDataClient_90PercentPublishers

@@ -0,0 +1,71 @@
+2022/05/15 18:18:32 simulated Duration 2.4
+2022/05/15 18:21:33 Round 1
+2022/05/15 18:21:33 publisherAmount 1965
+2022/05/15 18:21:33 goodPadding 0
+2022/05/15 18:21:33 blocksReceived 0
+2022/05/15 18:21:33 goodPadding Percentage NaN
+2022/05/15 18:28:14 Round 2
+2022/05/15 18:28:14 publisherAmount 233
+2022/05/15 18:28:14 goodPadding 619
+2022/05/15 18:28:14 blocksReceived 10000
+2022/05/15 18:28:14 goodPadding Percentage 0.0619
+2022/05/15 18:34:16 Round 3
+2022/05/15 18:34:16 publisherAmount 219
+2022/05/15 18:34:16 goodPadding 1310
+2022/05/15 18:34:16 blocksReceived 19999
+2022/05/15 18:34:16 goodPadding Percentage 0.06550327516375819
+2022/05/15 18:40:53 Round 4
+2022/05/15 18:40:53 publisherAmount 187
+2022/05/15 18:40:53 goodPadding 2084
+2022/05/15 18:40:53 blocksReceived 29999
+2022/05/15 18:40:53 goodPadding Percentage 0.06946898229940998
+2022/05/15 18:46:55 Round 5
+2022/05/15 18:46:55 publisherAmount 181
+2022/05/15 18:46:55 goodPadding 2998
+2022/05/15 18:46:55 blocksReceived 39997
+2022/05/15 18:46:55 goodPadding Percentage 0.07495562167162537
+2022/05/15 18:53:05 Round 6
+2022/05/15 18:53:05 publisherAmount 222
+2022/05/15 18:53:05 goodPadding 3912
+2022/05/15 18:53:05 blocksReceived 49996
+2022/05/15 18:53:05 goodPadding Percentage 0.07824625970077606
+2022/05/15 18:59:09 Round 7
+2022/05/15 18:59:09 publisherAmount 243
+2022/05/15 18:59:09 goodPadding 4744
+2022/05/15 18:59:09 blocksReceived 59996
+2022/05/15 18:59:09 goodPadding Percentage 0.07907193812920861
+2022/05/15 19:05:42 Round 8
+2022/05/15 19:05:42 publisherAmount 202
+2022/05/15 19:05:42 goodPadding 5670
+2022/05/15 19:05:42 blocksReceived 69996
+2022/05/15 19:05:42 goodPadding Percentage 0.08100462883593348
+2022/05/15 19:12:12 Round 9
+2022/05/15 19:12:12 publisherAmount 194
+2022/05/15 19:12:12 goodPadding 6637
+2022/05/15 19:12:12 blocksReceived 79996
+2022/05/15 19:12:12 goodPadding Percentage 0.08296664833241663
+2022/05/15 19:19:03 Round 10
+2022/05/15 19:19:03 publisherAmount 241
+2022/05/15 19:19:03 goodPadding 7675
+2022/05/15 19:19:03 blocksReceived 89995
+2022/05/15 19:19:03 goodPadding Percentage 0.0852825156953164
+2022/05/15 19:25:50 Round 11
+2022/05/15 19:25:50 publisherAmount 221
+2022/05/15 19:25:50 goodPadding 8775
+2022/05/15 19:25:50 blocksReceived 99995
+2022/05/15 19:25:50 goodPadding Percentage 0.08775438771938597
+2022/05/15 19:32:53 Round 12
+2022/05/15 19:32:53 publisherAmount 252
+2022/05/15 19:32:53 goodPadding 9842
+2022/05/15 19:32:53 blocksReceived 109995
+2022/05/15 19:32:53 goodPadding Percentage 0.08947679439974544
+2022/05/15 19:39:57 Round 13
+2022/05/15 19:39:57 publisherAmount 256
+2022/05/15 19:39:57 goodPadding 10964
+2022/05/15 19:39:57 blocksReceived 119995
+2022/05/15 19:39:57 goodPadding Percentage 0.0913704737697404
+2022/05/15 19:48:29 Round 14
+2022/05/15 19:48:29 publisherAmount 241
+2022/05/15 19:48:29 goodPadding 12035
+2022/05/15 19:48:29 blocksReceived 129995
+2022/05/15 19:48:29 goodPadding Percentage 0.09258048386476403

+ 188 - 0
data/evalData_90PercentPublishers

@@ -0,0 +1,188 @@
+2022/05/15 18:18:30 roundsBeforeUpdate 2
+2022/05/15 18:18:30 neededSubscriptions 5
+2022/05/15 18:18:30 dataLength 256
+2022/05/15 18:18:30 maxTimePerRound~ 50m0s
+2022/05/15 18:18:30 extraPositions 2
+2022/05/15 18:18:30 numClients 2000
+2022/05/15 18:18:30 Archiving is done every 24h, no Clients wants Archive
+2022/05/15 18:18:30 
+2022/05/15 18:18:30 Phase 1 Round 1
+2022/05/15 18:18:30 
+2022/05/15 18:18:30 bytesSaved Percentage NaN
+2022/05/15 18:18:32 Auditing duration 0.067713898 numVirtualAddresses 39002
+2022/05/15 18:21:34 fullDurationPhase1 183.167897044
+2022/05/15 18:21:34 fullAuditingDuration~ 135.426874
+2022/05/15 18:21:34 auditingPercentage 0.7393589094276637
+2022/05/15 18:21:34 Collision percentage this round 0.0010512820512820513 dbWriteSize 39000
+2022/05/15 18:21:34 currentPublisherAmount 1954 publisher percentage 0.977
+2022/05/15 18:21:34 fullDurationPhase2 0.774628937
+2022/05/15 18:21:36 sending 48384 bytes of data
+2022/05/15 18:25:27 fullDurationPhase3 232.467226127
+2022/05/15 18:25:27 
+2022/05/15 18:25:27 Phase 1 Round 2
+2022/05/15 18:25:27 
+2022/05/15 18:25:27 bytesSaved Percentage NaN
+2022/05/15 18:25:27 Auditing duration 0.002329074 numVirtualAddresses 38105
+2022/05/15 18:28:15 fullDurationPhase1 168.216865518
+2022/05/15 18:28:15 fullAuditingDuration~ 4.657568
+2022/05/15 18:28:15 auditingPercentage 0.027687865844728272
+2022/05/15 18:28:16 Collision percentage this round 0 dbWriteSize 38103
+2022/05/15 18:28:16 currentPublisherAmount 233 publisher percentage 0.1165
+2022/05/15 18:28:16 fullDurationPhase2 0.664428121
+2022/05/15 18:28:17 sending 50688 bytes of data
+2022/05/15 18:32:39 fullDurationPhase3 263.765394971
+2022/05/15 18:32:39 
+2022/05/15 18:32:39 Phase 1 Round 3
+2022/05/15 18:32:39 
+2022/05/15 18:32:39 bytesSaved Percentage NaN
+2022/05/15 18:32:40 Auditing duration 0.001773248 numVirtualAddresses 21316
+2022/05/15 18:34:16 fullDurationPhase1 97.001270712
+2022/05/15 18:34:16 fullAuditingDuration~ 3.545874
+2022/05/15 18:34:16 auditingPercentage 0.03655488344717228
+2022/05/15 18:34:17 Collision percentage this round 4.69175190015952e-05 dbWriteSize 21314
+2022/05/15 18:34:17 currentPublisherAmount 217 publisher percentage 0.1085
+2022/05/15 18:34:17 fullDurationPhase2 0.39352158
+2022/05/15 18:34:19 sending 51456 bytes of data
+2022/05/15 18:39:41 fullDurationPhase3 324.087100743
+2022/05/15 18:39:41 
+2022/05/15 18:39:41 Phase 1 Round 4
+2022/05/15 18:39:41 
+2022/05/15 18:39:41 bytesSaved Percentage NaN
+2022/05/15 18:39:41 Auditing duration 0.001473904 numVirtualAddresses 15622
+2022/05/15 18:40:53 fullDurationPhase1 71.865871473
+2022/05/15 18:40:53 fullAuditingDuration~ 2.947346
+2022/05/15 18:40:53 auditingPercentage 0.04101171809263482
+2022/05/15 18:40:53 Collision percentage this round 6.402048655569782e-05 dbWriteSize 15620
+2022/05/15 18:40:53 currentPublisherAmount 187 publisher percentage 0.0935
+2022/05/15 18:40:53 fullDurationPhase2 0.294670745
+2022/05/15 18:40:55 sending 51456 bytes of data
+2022/05/15 18:46:00 fullDurationPhase3 307.10102751
+2022/05/15 18:46:00 
+2022/05/15 18:46:00 Phase 1 Round 5
+2022/05/15 18:46:00 
+2022/05/15 18:46:00 bytesSaved Percentage NaN
+2022/05/15 18:46:00 Auditing duration 0.001555945 numVirtualAddresses 12619
+2022/05/15 18:46:55 fullDurationPhase1 55.131403657
+2022/05/15 18:46:55 fullAuditingDuration~ 3.11145
+2022/05/15 18:46:55 auditingPercentage 0.056436897416647744
+2022/05/15 18:46:56 Collision percentage this round 7.925814377427281e-05 dbWriteSize 12617
+2022/05/15 18:46:56 currentPublisherAmount 181 publisher percentage 0.0905
+2022/05/15 18:46:56 fullDurationPhase2 0.221227719
+2022/05/15 18:46:58 sending 51456 bytes of data
+2022/05/15 18:52:18 fullDurationPhase3 322.783456375
+2022/05/15 18:52:18 
+2022/05/15 18:52:18 Phase 1 Round 6
+2022/05/15 18:52:18 
+2022/05/15 18:52:18 bytesSaved Percentage NaN
+2022/05/15 18:52:18 Auditing duration 0.001025711 numVirtualAddresses 10805
+2022/05/15 18:53:06 fullDurationPhase1 47.140249202
+2022/05/15 18:53:06 fullAuditingDuration~ 2.0509999999999997
+2022/05/15 18:53:06 auditingPercentage 0.04350837436084151
+2022/05/15 18:53:06 Collision percentage this round 0.0003702675182819587 dbWriteSize 10803
+2022/05/15 18:53:06 currentPublisherAmount 220 publisher percentage 0.11
+2022/05/15 18:53:06 fullDurationPhase2 0.203618064
+2022/05/15 18:53:08 sending 51712 bytes of data
+2022/05/15 18:58:27 fullDurationPhase3 321.332081816
+2022/05/15 18:58:27 
+2022/05/15 18:58:27 Phase 1 Round 7
+2022/05/15 18:58:27 
+2022/05/15 18:58:27 bytesSaved Percentage NaN
+2022/05/15 18:58:27 Auditing duration 0.000918147 numVirtualAddresses 9713
+2022/05/15 18:59:09 fullDurationPhase1 42.223827989
+2022/05/15 18:59:09 fullAuditingDuration~ 1.835794
+2022/05/15 18:59:09 auditingPercentage 0.04347759930324662
+2022/05/15 18:59:09 Collision percentage this round 0.0005148800329523221 dbWriteSize 9711
+2022/05/15 18:59:09 currentPublisherAmount 244 publisher percentage 0.122
+2022/05/15 18:59:09 fullDurationPhase2 0.191920825
+2022/05/15 18:59:12 sending 52224 bytes of data
+2022/05/15 19:05:02 fullDurationPhase3 352.834399518
+2022/05/15 19:05:02 
+2022/05/15 19:05:02 Phase 1 Round 8
+2022/05/15 19:05:02 
+2022/05/15 19:05:02 bytesSaved Percentage NaN
+2022/05/15 19:05:02 Auditing duration 0.000954475 numVirtualAddresses 9011
+2022/05/15 19:05:43 fullDurationPhase1 40.521688006
+2022/05/15 19:05:43 fullAuditingDuration~ 1.90851
+2022/05/15 19:05:43 auditingPercentage 0.047098390875876105
+2022/05/15 19:05:43 Collision percentage this round 0.000444000444000444 dbWriteSize 9009
+2022/05/15 19:05:43 currentPublisherAmount 201 publisher percentage 0.1005
+2022/05/15 19:05:43 fullDurationPhase2 0.165843158
+2022/05/15 19:05:45 sending 52736 bytes of data
+2022/05/15 19:11:36 fullDurationPhase3 352.864766597
+2022/05/15 19:11:36 
+2022/05/15 19:11:36 Phase 1 Round 9
+2022/05/15 19:11:36 
+2022/05/15 19:11:36 bytesSaved Percentage NaN
+2022/05/15 19:11:36 Auditing duration 0.00105745 numVirtualAddresses 8368
+2022/05/15 19:12:12 fullDurationPhase1 36.472335527
+2022/05/15 19:12:12 fullAuditingDuration~ 2.114098
+2022/05/15 19:12:12 auditingPercentage 0.05796430015011841
+2022/05/15 19:12:12 Collision percentage this round 0.00011953143676786995 dbWriteSize 8366
+2022/05/15 19:12:12 currentPublisherAmount 194 publisher percentage 0.097
+2022/05/15 19:12:12 fullDurationPhase2 0.145670576
+2022/05/15 19:12:15 sending 53248 bytes of data
+2022/05/15 19:18:28 fullDurationPhase3 375.798414971
+2022/05/15 19:18:28 
+2022/05/15 19:18:28 Phase 1 Round 10
+2022/05/15 19:18:28 
+2022/05/15 19:18:28 bytesSaved Percentage NaN
+2022/05/15 19:18:28 Auditing duration 0.000804206 numVirtualAddresses 7861
+2022/05/15 19:19:03 fullDurationPhase1 34.762811857
+2022/05/15 19:19:03 fullAuditingDuration~ 1.608092
+2022/05/15 19:19:03 auditingPercentage 0.0462588629436028
+2022/05/15 19:19:03 Collision percentage this round 0.0007634559104211731 dbWriteSize 7859
+2022/05/15 19:19:03 currentPublisherAmount 242 publisher percentage 0.121
+2022/05/15 19:19:03 fullDurationPhase2 0.13582535
+2022/05/15 19:19:05 sending 54528 bytes of data
+2022/05/15 19:25:18 fullDurationPhase3 375.03899141
+2022/05/15 19:25:18 
+2022/05/15 19:25:18 Phase 1 Round 11
+2022/05/15 19:25:18 
+2022/05/15 19:25:18 bytesSaved Percentage NaN
+2022/05/15 19:25:18 Auditing duration 0.000941686 numVirtualAddresses 7549
+2022/05/15 19:25:51 fullDurationPhase1 32.405076282
+2022/05/15 19:25:51 fullAuditingDuration~ 1.88269
+2022/05/15 19:25:51 auditingPercentage 0.0580984894713057
+2022/05/15 19:25:51 Collision percentage this round 0.00039750894395123893 dbWriteSize 7547
+2022/05/15 19:25:51 currentPublisherAmount 221 publisher percentage 0.1105
+2022/05/15 19:25:51 fullDurationPhase2 0.149425646
+2022/05/15 19:25:53 sending 54784 bytes of data
+2022/05/15 19:32:35 fullDurationPhase3 404.341026566
+2022/05/15 19:32:35 
+2022/05/15 19:32:35 Phase 1 Round 12
+2022/05/15 19:32:35 
+2022/05/15 19:32:35 bytesSaved Percentage NaN
+2022/05/15 19:32:35 Auditing duration 0.000939372 numVirtualAddresses 4175
+2022/05/15 19:32:54 fullDurationPhase1 18.462527662
+2022/05/15 19:32:54 fullAuditingDuration~ 1.878242
+2022/05/15 19:32:54 auditingPercentage 0.10173227393104675
+2022/05/15 19:32:54 Collision percentage this round 0.0014378145219266715 dbWriteSize 4173
+2022/05/15 19:32:54 currentPublisherAmount 251 publisher percentage 0.1255
+2022/05/15 19:32:54 fullDurationPhase2 0.08619278
+2022/05/15 19:32:56 sending 57344 bytes of data
+2022/05/15 19:39:38 fullDurationPhase3 404.596481174
+2022/05/15 19:39:38 
+2022/05/15 19:39:38 Phase 1 Round 13
+2022/05/15 19:39:38 
+2022/05/15 19:39:38 bytesSaved Percentage NaN
+2022/05/15 19:39:38 Auditing duration 0.000695349 numVirtualAddresses 4195
+2022/05/15 19:39:57 fullDurationPhase1 18.642478927
+2022/05/15 19:39:57 fullAuditingDuration~ 1.390338
+2022/05/15 19:39:57 auditingPercentage 0.07457874069276196
+2022/05/15 19:39:57 Collision percentage this round 0.0014309563558311473 dbWriteSize 4193
+2022/05/15 19:39:57 currentPublisherAmount 257 publisher percentage 0.1285
+2022/05/15 19:39:57 fullDurationPhase2 0.084603207
+2022/05/15 19:40:00 sending 62464 bytes of data
+2022/05/15 19:48:10 fullDurationPhase3 492.949868653
+2022/05/15 19:48:10 
+2022/05/15 19:48:10 Phase 1 Round 14
+2022/05/15 19:48:10 
+2022/05/15 19:48:10 bytesSaved Percentage NaN
+2022/05/15 19:48:10 Auditing duration 0.000858557 numVirtualAddresses 4273
+2022/05/15 19:48:29 fullDurationPhase1 18.630979493
+2022/05/15 19:48:29 fullAuditingDuration~ 1.716834
+2022/05/15 19:48:29 auditingPercentage 0.09214907241796061
+2022/05/15 19:48:29 Collision percentage this round 0.0007024116132053383 dbWriteSize 4271
+2022/05/15 19:48:29 currentPublisherAmount 240 publisher percentage 0.12
+2022/05/15 19:48:29 fullDurationPhase2 0.076480019
+2022/05/15 19:48:32 sending 65024 bytes of data

+ 6 - 13
follower/follower.go

@@ -52,7 +52,7 @@ const numThreads = 12
 //Maximum Transport Unit
 const mtu int = 1100
 
-var dbWriteSize int = 15000
+var dbWriteSize int
 var neededSubscriptions int
 
 var round int
@@ -68,8 +68,6 @@ func main() {
 	followerPrivateKey = generatedPrivateKey
 	followerPublicKey = generatedPublicKey
 
-	C.initializeServer(C.int(numThreads))
-
 	followerConnectionPrivateKey, err := rsa.GenerateKey(rand.Reader, 2048)
 	if err != nil {
 		panic(err)
@@ -138,8 +136,13 @@ func main() {
 	neededSubscriptionsBytes := readFrom(leaderConnection, 4)
 	neededSubscriptions = byteToInt(neededSubscriptionsBytes)
 
+	dbWriteSizeBytes := readFrom(leaderConnection, 4)
+	dbWriteSize = byteToInt(dbWriteSizeBytes)
+
 	leaderPublicKey = &tmpLeaderPubKey
 
+	C.initializeServer(C.int(numThreads))
+
 	//setup ends here
 
 	//locks access to DB
@@ -439,8 +442,6 @@ func phase2(leaderWorkerConnection net.Conn) {
 		}
 	}
 
-	//fmt.Println("tweets recovered: ", tweets)
-
 	//sort into read db
 	lib.NewEntries(tweets, 0)
 
@@ -563,10 +564,6 @@ func getSendTweets(clientKeys clientKeys, archiveQuerys [][]byte, leaderWorkerCo
 		//Xor's sharedSecret with all tweets
 		lib.Xor(expandedSharedSecret[:], tweets)
 
-		if archiveQuerys != nil {
-			//fmt.Println("length", len(tweets))
-		}
-
 		//sends tweets to leader
 		writeTo(leaderWorkerConnection, tweets)
 	}
@@ -658,10 +655,6 @@ func handlePirQuery(clientKeys clientKeys, leaderWorkerConnection net.Conn, subP
 		clientKeys.PirQuery = pirQuerys
 	}
 
-	if subPhase == -1 {
-		//fmt.Println("query", pirQuerys)
-	}
-
 	return clientKeys, pirQuerys, false
 }
 

+ 21 - 17
leader/leader.go

@@ -65,15 +65,19 @@ const neededSubscriptions = 5
 const numThreads = 12
 const dataLength = 256
 const minDBWriteSize = 1000
+const numClients = 500
 
-var dbWriteSize float64 = 15000
+var dbWriteSize float64 = numClients * 19.5
 
 //this is the number of positions for auditing
 var extraPositions int = 2
 var collisionCounter []float64
 var clientsConnected float64
 
-var maxTimePerRound time.Duration = 200 * time.Second
+var maxTimePerRound time.Duration = 1000 * time.Second
+
+//counts the number of rounds
+var round int
 
 var clientsServedPhase1 []int
 var clientsServedPhase3 []int
@@ -82,8 +86,10 @@ var startPhase1 time.Time
 var startPhase2 time.Time
 var startPhase3 time.Time
 
-//counts the number of rounds
-var round int
+//only prints auditing time for one client per round
+var firstAuditPrint bool
+var auditingStart time.Time
+var auditingEnd time.Time
 
 var startTime time.Time
 var startTimeRound time.Time
@@ -98,11 +104,6 @@ const publisherRounds int = 10
 var publisherAmount float64
 var publisherHistory [publisherRounds]int
 
-//only prints auditing time for one client per round
-var firstAuditPrint bool
-var auditingStart time.Time
-var auditingEnd time.Time
-
 var firstTweetSend bool
 
 func main() {
@@ -119,7 +120,7 @@ func main() {
 	log.Println("dataLength", dataLength)
 	log.Println("maxTimePerRound~", maxTimePerRound*3)
 	log.Println("extraPositions", extraPositions)
-	log.Println("numClients", 5000)
+	log.Println("numClients", numClients)
 	log.Println("Archiving is done every 24h, no Clients wants Archive")
 
 	//prevents race conditions for wrtiting
@@ -163,6 +164,8 @@ func main() {
 
 	writeTo(followerConnection, intToByte(neededSubscriptions))
 
+	writeTo(followerConnection, intToByte(int(dbWriteSize)))
+
 	//goroutine for accepting new clients
 	go func() {
 		leaderConnectionPrivateKey, err := rsa.GenerateKey(rand.Reader, 2048)
@@ -294,6 +297,7 @@ func main() {
 	for {
 		startPhase1 = time.Now()
 		startTimeRound = time.Now()
+		firstAuditPrint = true
 
 		phase[0] = 1
 
@@ -301,15 +305,12 @@ func main() {
 
 		fmt.Println("clientsServedPhase1", clientsServedPhase1[round-1])
 		fmt.Println("clientsServedPhase3", clientsServedPhase3[round-1])
-		//fmt.Println("dbWriteSize", dbWriteSize)
 
 		log.Println()
 		log.Println("Phase 1 Round", round)
 		log.Println()
 		bytesSaved := lib.GetBytesSaved()
-		//todo! doesnt work
 		log.Println("bytesSaved Percentage", bytesSaved)
-		firstAuditPrint = true
 
 		//creates a new write Db for this round
 		for i := 0; i < int(dbWriteSize); i++ {
@@ -347,7 +348,7 @@ func main() {
 
 		wg.Wait()
 
-		//log.Println("fullDurationPhase1", time.Since(startPhase1).Seconds())
+		log.Println("fullDurationPhase1", time.Since(startPhase1).Seconds())
 		log.Println("fullAuditingDuration~", auditingEnd.Sub(auditingStart).Seconds()*clientsConnected)
 		log.Println("auditingPercentage", (auditingEnd.Sub(auditingStart).Seconds()*clientsConnected)/(time.Since(startPhase1).Seconds()))
 
@@ -363,7 +364,7 @@ func main() {
 
 		phase2(followerConnection)
 
-		//log.Println("fullDurationPhase2", time.Since(startPhase2).Seconds())
+		log.Println("fullDurationPhase2", time.Since(startPhase2).Seconds())
 
 		//Phase 3
 
@@ -483,6 +484,7 @@ func phase1(id int, phase []byte, followerConnection net.Conn, wg *sync.WaitGrou
 		if id == 0 && firstAuditPrint {
 			auditingStart = time.Now()
 		}
+
 		m.RLock()
 		var clientKeys = clientData[clientConnection.RemoteAddr()]
 		m.RUnlock()
@@ -603,8 +605,9 @@ func phase1(id int, phase []byte, followerConnection net.Conn, wg *sync.WaitGrou
 		}
 
 		//loop that waits for new client or leaves phase1 if time is up
+		//todo! remove && len(phase1Channel) > 0
 		for {
-			if time.Since(startTimeRound) < maxTimePerRound {
+			if time.Since(startTimeRound) < maxTimePerRound && len(phase1Channel) > 0 {
 				//this worker handles the next client
 				if len(phase1Channel) > 0 {
 					break
@@ -982,8 +985,9 @@ func phase3(id int, phase []byte, followerConnection net.Conn, wg *sync.WaitGrou
 
 		phase1Channel <- clientConnection
 
+		//todo! remove && len(phase3Channel) > 0
 		for {
-			if time.Since(startTimeRound) < 2*maxTimePerRound {
+			if time.Since(startTimeRound) < 2*maxTimePerRound && len(phase3Channel) > 0 {
 				//this worker handles the next client
 				if len(phase3Channel) > 0 {
 					break

+ 2 - 1
lib/databaseRead.go

@@ -84,7 +84,8 @@ func GetTweets(pirQuery []byte, dataLength int, whereFrom int, pubKey [32]byte)
 	if whereFrom == 1 {
 		tmpdb = archive
 	}
-	minimumBlockSize = dataLength * maxTweetAmount(whereFrom)
+	//50 is an estimated nr that works, there probably is a smarter way to do this
+	minimumBlockSize = 50 * maxTweetAmount(whereFrom)
 
 	var wantedTopics = getNamesForTopics(pirQuery, whereFrom)
 	tweetsToReturn := make([][]Tweet, len(wantedTopics))