|
@@ -10,7 +10,6 @@ package main
|
|
*/
|
|
*/
|
|
import "C"
|
|
import "C"
|
|
|
|
|
|
-//sssssssssssss
|
|
|
|
import (
|
|
import (
|
|
"2PPS/lib"
|
|
"2PPS/lib"
|
|
"bufio"
|
|
"bufio"
|
|
@@ -42,7 +41,7 @@ type tweet struct {
|
|
const leader string = "127.0.0.1:4441"
|
|
const leader string = "127.0.0.1:4441"
|
|
|
|
|
|
//needs to be changed at leader/follower/client at the same time
|
|
//needs to be changed at leader/follower/client at the same time
|
|
-const numClients = 5
|
|
|
|
|
|
+const numClients = 500
|
|
|
|
|
|
//mylimit=8000
|
|
//mylimit=8000
|
|
//sudo prlimit --nofile=$mylimit --pid $$; ulimit -n $mylimit
|
|
//sudo prlimit --nofile=$mylimit --pid $$; ulimit -n $mylimit
|
|
@@ -58,13 +57,13 @@ var topicList []string
|
|
var archiveTopicList []string
|
|
var archiveTopicList []string
|
|
var neededSubscriptions int
|
|
var neededSubscriptions int
|
|
var publisherAmount int
|
|
var publisherAmount int
|
|
|
|
+var goodPadding int
|
|
var timeBounds []int
|
|
var timeBounds []int
|
|
-var speedUp int = 500
|
|
|
|
|
|
+var speedUp int = 1000
|
|
|
|
|
|
-var maxTimePerRound time.Duration = 3 * time.Second
|
|
|
|
|
|
+var maxTimePerRound time.Duration = 10 * time.Second
|
|
var startTime int
|
|
var startTime int
|
|
|
|
|
|
-//todo! expand this for multiple clients
|
|
|
|
var archiveInterests = make([]int, 1)
|
|
var archiveInterests = make([]int, 1)
|
|
var sharedSecret [numClients][2][32]byte = createSharedSecret()
|
|
var sharedSecret [numClients][2][32]byte = createSharedSecret()
|
|
|
|
|
|
@@ -151,7 +150,6 @@ func client(clientNumber int) {
|
|
dbWriteSizeBytes := readFrom(leaderConn, 4)
|
|
dbWriteSizeBytes := readFrom(leaderConn, 4)
|
|
dbWriteSize = byteToInt(dbWriteSizeBytes)
|
|
dbWriteSize = byteToInt(dbWriteSizeBytes)
|
|
|
|
|
|
- //todo! put into tweet creation
|
|
|
|
//roundAsBytes := readFrom(leaderConn, 4)
|
|
//roundAsBytes := readFrom(leaderConn, 4)
|
|
roundAsBytes := make([]byte, 4)
|
|
roundAsBytes := make([]byte, 4)
|
|
_, err = leaderConn.Read(roundAsBytes)
|
|
_, err = leaderConn.Read(roundAsBytes)
|
|
@@ -173,6 +171,8 @@ func client(clientNumber int) {
|
|
tweet := getRealTweet(clientNumber)
|
|
tweet := getRealTweet(clientNumber)
|
|
if clientNumber == numClients-1 {
|
|
if clientNumber == numClients-1 {
|
|
fmt.Println("publisherAmount", publisherAmount)
|
|
fmt.Println("publisherAmount", publisherAmount)
|
|
|
|
+ fmt.Println("goodPadding", goodPadding)
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
//prep the query
|
|
//prep the query
|
|
@@ -257,13 +257,14 @@ func client(clientNumber int) {
|
|
receiveTweets(sharedSecret[clientNumber], leaderConn, false, clientNumber)
|
|
receiveTweets(sharedSecret[clientNumber], leaderConn, false, clientNumber)
|
|
|
|
|
|
if len(archiveTopicList) > 0 {
|
|
if len(archiveTopicList) > 0 {
|
|
- wantsArchive[0] = 1 //archive test
|
|
|
|
|
|
+ wantsArchive[0] = 1
|
|
} else {
|
|
} else {
|
|
wantsArchive[0] = 0
|
|
wantsArchive[0] = 0
|
|
}
|
|
}
|
|
|
|
|
|
writeTo(leaderConn, wantsArchive)
|
|
writeTo(leaderConn, wantsArchive)
|
|
|
|
|
|
|
|
+ //fmt.Println("list", archiveTopicList)
|
|
if wantsArchive[0] == 1 && len(archiveTopicList) > 0 {
|
|
if wantsArchive[0] == 1 && len(archiveTopicList) > 0 {
|
|
encryptedQueryLeader, encryptedQueryFollower = createPIRQuery(-1, clientNumber)
|
|
encryptedQueryLeader, encryptedQueryFollower = createPIRQuery(-1, clientNumber)
|
|
sendQuerys(encryptedQueryLeader, encryptedQueryFollower, leaderConn, true)
|
|
sendQuerys(encryptedQueryLeader, encryptedQueryFollower, leaderConn, true)
|
|
@@ -282,8 +283,8 @@ func createPIRQuery(subPhase int, clientNumber int) ([]byte, []byte) {
|
|
//later this will be taken from gui, this is only for testing
|
|
//later this will be taken from gui, this is only for testing
|
|
topicsOfInterest := make([]int, 1)
|
|
topicsOfInterest := make([]int, 1)
|
|
topicsOfInterest[0] = mr.Intn(10)
|
|
topicsOfInterest[0] = mr.Intn(10)
|
|
|
|
+ archiveInterests[0] = mr.Intn(10)
|
|
|
|
|
|
- //todo! repeat for archive
|
|
|
|
tmpNeededSubscriptions := neededSubscriptions
|
|
tmpNeededSubscriptions := neededSubscriptions
|
|
if tmpNeededSubscriptions > len(topicList) {
|
|
if tmpNeededSubscriptions > len(topicList) {
|
|
tmpNeededSubscriptions = len(topicList)
|
|
tmpNeededSubscriptions = len(topicList)
|
|
@@ -299,8 +300,8 @@ func createPIRQuery(subPhase int, clientNumber int) ([]byte, []byte) {
|
|
if tmpNeededSubscriptions > len(archiveTopicList) {
|
|
if tmpNeededSubscriptions > len(archiveTopicList) {
|
|
tmpNeededSubscriptions = len(archiveTopicList)
|
|
tmpNeededSubscriptions = len(archiveTopicList)
|
|
}
|
|
}
|
|
- copy(tmptopicsOfInterest, archiveInterests) //archiveInterests from gui
|
|
|
|
- copy(tmpTopicList, archiveTopicList)
|
|
|
|
|
|
+ tmptopicsOfInterest = archiveInterests //!todo take archiveInterests from gui
|
|
|
|
+ tmpTopicList = archiveTopicList
|
|
}
|
|
}
|
|
|
|
|
|
//creates fake topicsOfInterest if client is boooring
|
|
//creates fake topicsOfInterest if client is boooring
|
|
@@ -426,6 +427,7 @@ func receiveTweets(sharedSecret [2][32]byte, leaderConn net.Conn, getArchive boo
|
|
tmpNeededSubscriptions = len(archiveTopicList)
|
|
tmpNeededSubscriptions = len(archiveTopicList)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
for i := 0; i < tmpNeededSubscriptions; i++ {
|
|
for i := 0; i < tmpNeededSubscriptions; i++ {
|
|
//client receives tweets
|
|
//client receives tweets
|
|
tweetsLengthBytes := readFrom(leaderConn, 4)
|
|
tweetsLengthBytes := readFrom(leaderConn, 4)
|
|
@@ -453,28 +455,24 @@ func receiveTweets(sharedSecret [2][32]byte, leaderConn net.Conn, getArchive boo
|
|
//fmt.Println("PubKey", clientPublicKey[clientNumber], "Bytes", tweets)
|
|
//fmt.Println("PubKey", clientPublicKey[clientNumber], "Bytes", tweets)
|
|
|
|
|
|
index := strings.Index(string(tweets), ";;")
|
|
index := strings.Index(string(tweets), ";;")
|
|
- if getArchive {
|
|
|
|
- fmt.Println("gettingArchive")
|
|
|
|
- }
|
|
|
|
- if index != -1 && clientNumber == 0 {
|
|
|
|
- //fmt.Println("Correct")
|
|
|
|
|
|
+
|
|
|
|
+ if index != -1 {
|
|
|
|
|
|
textArr := strings.Split(string(tweets), ";;;")
|
|
textArr := strings.Split(string(tweets), ";;;")
|
|
text := textArr[:len(textArr)-1]
|
|
text := textArr[:len(textArr)-1]
|
|
|
|
|
|
- fmt.Println("Round", round, text[0], "Length", len(tweets))
|
|
|
|
- fmt.Println("padding", text[1])
|
|
|
|
|
|
+ //fmt.Println("Round", round, text[0], "Length", len(tweets))
|
|
|
|
+
|
|
|
|
+ if text[1] != "" {
|
|
|
|
+ text[1] = text[1][1:]
|
|
|
|
|
|
- /* doesnt work
|
|
|
|
- goodPadding := strings.Index(text[0], text[1])
|
|
|
|
- if text[0] == text[1] || text[1] == "" {
|
|
|
|
- goodPadding = -1
|
|
|
|
}
|
|
}
|
|
- if goodPadding != -1 {
|
|
|
|
- fmt.Println("Round", round, text[0], "Length", len(tweets))
|
|
|
|
- fmt.Println("padding", text[1])
|
|
|
|
|
|
+ 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 {
|
|
} else if index == -1 && tweets[0] != 0 {
|
|
fmt.Println("error")
|
|
fmt.Println("error")
|