|
@@ -42,12 +42,11 @@ 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 = 1
|
|
|
|
|
|
+const numClients = 500
|
|
|
|
|
|
//mylimit=8000
|
|
//mylimit=8000
|
|
//sudo prlimit --nofile=$mylimit --pid $$; ulimit -n $mylimit
|
|
//sudo prlimit --nofile=$mylimit --pid $$; ulimit -n $mylimit
|
|
const dataLength int = 256
|
|
const dataLength int = 256
|
|
-const numThreads int = 12
|
|
|
|
|
|
|
|
//Maximum Transport Unit
|
|
//Maximum Transport Unit
|
|
const mtu int = 1100
|
|
const mtu int = 1100
|
|
@@ -59,9 +58,9 @@ var archiveTopicList []string
|
|
var neededSubscriptions int
|
|
var neededSubscriptions int
|
|
var publisherAmount int
|
|
var publisherAmount int
|
|
var timeBounds []int
|
|
var timeBounds []int
|
|
-var speedUp int = 50
|
|
|
|
|
|
+var speedUp int = 500
|
|
|
|
|
|
-var maxTimePerRound time.Duration = 5 * time.Second
|
|
|
|
|
|
+var maxTimePerRound time.Duration = 10 * time.Second
|
|
var startTime int
|
|
var startTime int
|
|
|
|
|
|
//todo! expand this for multiple clients
|
|
//todo! expand this for multiple clients
|
|
@@ -170,7 +169,7 @@ func client(clientNumber int) {
|
|
sendQuerys(encryptedQueryLeader, encryptedQueryFollower, leaderConn, false)
|
|
sendQuerys(encryptedQueryLeader, encryptedQueryFollower, leaderConn, false)
|
|
pos := receiveVirtualAddress(sharedSecret[clientNumber], leaderConn)
|
|
pos := receiveVirtualAddress(sharedSecret[clientNumber], leaderConn)
|
|
|
|
|
|
- tweet := getRandomTweet(clientNumber)
|
|
|
|
|
|
+ tweet := getRealTweet(clientNumber)
|
|
if clientNumber == numClients-1 {
|
|
if clientNumber == numClients-1 {
|
|
fmt.Println("publisherAmount", publisherAmount)
|
|
fmt.Println("publisherAmount", publisherAmount)
|
|
}
|
|
}
|
|
@@ -280,11 +279,8 @@ func client(clientNumber int) {
|
|
//creates and sends the pirQuerys for each server
|
|
//creates and sends the pirQuerys for each server
|
|
func createPIRQuery(subPhase int, clientNumber int) ([]byte, []byte) {
|
|
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, 10)
|
|
|
|
- topicsOFInterest[0] = 0
|
|
|
|
- topicsOFInterest[1] = 1
|
|
|
|
- topicsOFInterest[9] = 1
|
|
|
|
- archiveInterests[0] = 1
|
|
|
|
|
|
+ topicsOfInterest := make([]int, 1)
|
|
|
|
+ topicsOfInterest[0] = mr.Intn(10)
|
|
|
|
|
|
//todo! repeat for archive
|
|
//todo! repeat for archive
|
|
tmpNeededSubscriptions := neededSubscriptions
|
|
tmpNeededSubscriptions := neededSubscriptions
|
|
@@ -292,8 +288,8 @@ func createPIRQuery(subPhase int, clientNumber int) ([]byte, []byte) {
|
|
tmpNeededSubscriptions = len(topicList)
|
|
tmpNeededSubscriptions = len(topicList)
|
|
}
|
|
}
|
|
|
|
|
|
- tmptopicsOfInterest := make([]int, len(topicList))
|
|
|
|
- copy(tmptopicsOfInterest, topicsOFInterest)
|
|
|
|
|
|
+ tmptopicsOfInterest := make([]int, len(topicsOfInterest))
|
|
|
|
+ copy(tmptopicsOfInterest, topicsOfInterest)
|
|
|
|
|
|
tmpTopicList := make([]string, len(topicList))
|
|
tmpTopicList := make([]string, len(topicList))
|
|
copy(tmpTopicList, topicList)
|
|
copy(tmpTopicList, topicList)
|
|
@@ -311,7 +307,7 @@ func createPIRQuery(subPhase int, clientNumber int) ([]byte, []byte) {
|
|
tmptopicsOfInterest = addFakeInterests(len(tmpTopicList), tmptopicsOfInterest, false)
|
|
tmptopicsOfInterest = addFakeInterests(len(tmpTopicList), tmptopicsOfInterest, false)
|
|
}
|
|
}
|
|
|
|
|
|
- //pirQuery [topicsofinterest][serverAmount][topicAmount]byte
|
|
|
|
|
|
+ //pirQuery [topicsOfInterest][serverAmount][topicAmount]byte
|
|
pirQuerys := make([][][]byte, len(tmptopicsOfInterest))
|
|
pirQuerys := make([][][]byte, len(tmptopicsOfInterest))
|
|
for i := range pirQuerys {
|
|
for i := range pirQuerys {
|
|
pirQuerys[i] = make([][]byte, 2)
|
|
pirQuerys[i] = make([][]byte, 2)
|
|
@@ -332,29 +328,28 @@ func createPIRQuery(subPhase int, clientNumber int) ([]byte, []byte) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- tmptopicsOfInterestBytes := make([]byte, tmpNeededSubscriptions)
|
|
|
|
- for index := range tmptopicsOfInterestBytes {
|
|
|
|
|
|
+ tmptopicsOfInterestBytes := make([]byte, len(tmpTopicList))
|
|
|
|
+ for index := range tmptopicsOfInterest {
|
|
if tmptopicsOfInterest[index] == 1 {
|
|
if tmptopicsOfInterest[index] == 1 {
|
|
tmptopicsOfInterestBytes[index] = 1
|
|
tmptopicsOfInterestBytes[index] = 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- for topic := range tmptopicsOfInterest {
|
|
|
|
|
|
+ for topicIndex, topic := range tmptopicsOfInterest {
|
|
for index := range tmpTopicList {
|
|
for index := range tmpTopicList {
|
|
if topic == index {
|
|
if topic == index {
|
|
- if pirQuerys[topic][0][index] == 1 {
|
|
|
|
- pirQuerys[topic][1][index] = 0
|
|
|
|
|
|
+ if pirQuerys[topicIndex][0][index] == 1 {
|
|
|
|
+ pirQuerys[topicIndex][1][index] = 0
|
|
} else {
|
|
} else {
|
|
- pirQuerys[topic][1][index] = 1
|
|
|
|
|
|
+ pirQuerys[topicIndex][1][index] = 1
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- if pirQuerys[topic][0][index] == 0 {
|
|
|
|
- pirQuerys[topic][1][index] = 0
|
|
|
|
|
|
+ if pirQuerys[topicIndex][0][index] == 0 {
|
|
|
|
+ pirQuerys[topicIndex][1][index] = 0
|
|
} else {
|
|
} else {
|
|
- pirQuerys[topic][1][index] = 1
|
|
|
|
|
|
+ pirQuerys[topicIndex][1][index] = 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -458,15 +453,28 @@ func receiveTweets(sharedSecret [2][32]byte, leaderConn net.Conn, getArchive boo
|
|
|
|
|
|
index := strings.Index(string(tweets), ";;")
|
|
index := strings.Index(string(tweets), ";;")
|
|
if index != -1 && clientNumber == 0 {
|
|
if index != -1 && clientNumber == 0 {
|
|
|
|
+ //fmt.Println("Correct")
|
|
|
|
+
|
|
|
|
+ textArr := strings.Split(string(tweets), ";;;")
|
|
|
|
+ text := textArr[:len(textArr)-1]
|
|
|
|
+
|
|
|
|
+ fmt.Println("Round", round, text[0], "Length", len(tweets))
|
|
|
|
+ fmt.Println("padding", text[1])
|
|
|
|
|
|
- fmt.Println("Correct")
|
|
|
|
- //textArr := strings.Split(string(tweets), ";;;;;;;;")
|
|
|
|
- //text := string(tweets)[:len(textArr)-1]
|
|
|
|
- fmt.Println("Round", round, "Text", string(tweets), "Length", len(tweets))
|
|
|
|
|
|
+ /* 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])
|
|
|
|
+ }
|
|
|
|
+ */
|
|
|
|
|
|
} else if index == -1 {
|
|
} else if index == -1 {
|
|
fmt.Println("error")
|
|
fmt.Println("error")
|
|
- fmt.Println("round", round, "text:", string(tweets), "length", len(tweets))
|
|
|
|
|
|
+ fmt.Println("round", round, string(tweets), "length", len(tweets))
|
|
return
|
|
return
|
|
//panic("received text not of correct format")
|
|
//panic("received text not of correct format")
|
|
}
|
|
}
|
|
@@ -542,15 +550,15 @@ func addFakeInterests(max int, topicsOfInterest []int, doAuditing bool) []int {
|
|
tmpNeededSubscriptions = len(topicList)
|
|
tmpNeededSubscriptions = len(topicList)
|
|
}
|
|
}
|
|
|
|
|
|
- fakeTopicsOfInterest := make([]int, tmpNeededSubscriptions)
|
|
|
|
|
|
+ faketopicsOfInterest := make([]int, tmpNeededSubscriptions)
|
|
maxInt := max
|
|
maxInt := max
|
|
|
|
|
|
//fills the array with unique random ascending values ranging from 0 to max
|
|
//fills the array with unique random ascending values ranging from 0 to max
|
|
for i := 0; i < tmpNeededSubscriptions; i++ {
|
|
for i := 0; i < tmpNeededSubscriptions; i++ {
|
|
- fakeTopicsOfInterest[i] = mr.Intn(maxInt)
|
|
|
|
|
|
+ faketopicsOfInterest[i] = mr.Intn(maxInt)
|
|
|
|
|
|
for j := 0; j < i; j++ {
|
|
for j := 0; j < i; j++ {
|
|
- if fakeTopicsOfInterest[i] == fakeTopicsOfInterest[j] {
|
|
|
|
|
|
+ if faketopicsOfInterest[i] == faketopicsOfInterest[j] {
|
|
i--
|
|
i--
|
|
break
|
|
break
|
|
}
|
|
}
|
|
@@ -558,12 +566,12 @@ func addFakeInterests(max int, topicsOfInterest []int, doAuditing bool) []int {
|
|
}
|
|
}
|
|
|
|
|
|
if doAuditing {
|
|
if doAuditing {
|
|
- sort.Ints(fakeTopicsOfInterest)
|
|
|
|
- return fakeTopicsOfInterest
|
|
|
|
|
|
+ sort.Ints(faketopicsOfInterest)
|
|
|
|
+ return faketopicsOfInterest
|
|
}
|
|
}
|
|
|
|
|
|
//adds unique and new random numbers to topicOfInterests until length is satisfied
|
|
//adds unique and new random numbers to topicOfInterests until length is satisfied
|
|
- for _, number := range fakeTopicsOfInterest {
|
|
|
|
|
|
+ for _, number := range faketopicsOfInterest {
|
|
if !inList(number, topicsOfInterest) {
|
|
if !inList(number, topicsOfInterest) {
|
|
topicsOfInterest = append(topicsOfInterest, number)
|
|
topicsOfInterest = append(topicsOfInterest, number)
|
|
}
|
|
}
|
|
@@ -728,7 +736,7 @@ func getRandomTweet(clientNumber int) []byte {
|
|
if maxTopics == 0 {
|
|
if maxTopics == 0 {
|
|
maxTopics = 1
|
|
maxTopics = 1
|
|
}
|
|
}
|
|
- maxInt := 3
|
|
|
|
|
|
+ maxInt := 100
|
|
topicNumbers := make([]int, maxTopics)
|
|
topicNumbers := make([]int, maxTopics)
|
|
//fills the array with unique random ascending values ranging from 0 to maxInt
|
|
//fills the array with unique random ascending values ranging from 0 to maxInt
|
|
for i := 0; i < maxTopics; i++ {
|
|
for i := 0; i < maxTopics; i++ {
|