|
@ -79,7 +79,7 @@ func (p *Peer) sendEventData(event EventData) bool { |
|
|
if (minRecvTime-desiredRecvTime)/partTxMS > sendQueueCapacity { |
|
|
if (minRecvTime-desiredRecvTime)/partTxMS > sendQueueCapacity { |
|
|
return false |
|
|
return false |
|
|
} else { |
|
|
} else { |
|
|
event.SetRecvTime(minRecvTime) // Adjust recvTime
|
|
|
|
|
|
|
|
|
event.time = minRecvTime // Adjust recvTime
|
|
|
p.node.sendEvent(event) |
|
|
p.node.sendEvent(event) |
|
|
p.sent += partTxMS |
|
|
p.sent += partTxMS |
|
|
return true |
|
|
return true |
|
@ -210,7 +210,6 @@ func (n *Node) String() string { |
|
|
|
|
|
|
|
|
type Event interface { |
|
|
type Event interface { |
|
|
RecvTime() int32 |
|
|
RecvTime() int32 |
|
|
SetRecvTime(int32) |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
type EventData struct { |
|
|
type EventData struct { |
|
@ -223,10 +222,6 @@ func (e EventData) RecvTime() int32 { |
|
|
return e.time |
|
|
return e.time |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (e EventData) SetRecvTime(time int32) { |
|
|
|
|
|
e.time = time |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (e EventData) String() string { |
|
|
func (e EventData) String() string { |
|
|
return fmt.Sprintf("[%d:%d:%d]", e.time, e.src, e.part) |
|
|
return fmt.Sprintf("[%d:%d:%d]", e.time, e.src, e.part) |
|
|
} |
|
|
} |
|
@ -242,10 +237,6 @@ func (e EventDataResponse) RecvTime() int32 { |
|
|
return e.time |
|
|
return e.time |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (e EventDataResponse) SetRecvTime(time int32) { |
|
|
|
|
|
e.time = time |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func (e EventDataResponse) String() string { |
|
|
func (e EventDataResponse) String() string { |
|
|
return fmt.Sprintf("[%d:%d:%d:%d]", e.time, e.src, e.part, e.rank) |
|
|
return fmt.Sprintf("[%d:%d:%d:%d]", e.time, e.src, e.part, e.rank) |
|
|
} |
|
|
} |
|
@ -285,16 +276,6 @@ func createNetwork() []*Node { |
|
|
return nodes |
|
|
return nodes |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func printNodes(nodes []*Node) { |
|
|
|
|
|
for _, node := range nodes { |
|
|
|
|
|
peerStr := "" |
|
|
|
|
|
for _, peer := range node.peers { |
|
|
|
|
|
peerStr += fmt.Sprintf(" %v", peer.node.index) |
|
|
|
|
|
} |
|
|
|
|
|
fmt.Printf("[%v] peers: %v\n", node.index, peerStr) |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func countFull(nodes []*Node) (fullCount int) { |
|
|
func countFull(nodes []*Node) (fullCount int) { |
|
|
for _, node := range nodes { |
|
|
for _, node := range nodes { |
|
|
if node.isFull() { |
|
|
if node.isFull() { |
|
@ -320,7 +301,6 @@ func main() { |
|
|
// Global vars
|
|
|
// Global vars
|
|
|
nodes := createNetwork() |
|
|
nodes := createNetwork() |
|
|
runStats := []runStat{} |
|
|
runStats := []runStat{} |
|
|
//printNodes(nodes[:])
|
|
|
|
|
|
|
|
|
|
|
|
// Keep iterating and improving .wanted
|
|
|
// Keep iterating and improving .wanted
|
|
|
for { |
|
|
for { |
|
@ -401,7 +381,7 @@ func main() { |
|
|
rank: rank, |
|
|
rank: rank, |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
logWrite(fmt.Sprintf("[%v] t:%v s:%v -> n:%v p:%v r:%v\n", len(runStats), event.time, srcPeer.node.index, node.index, event.part, rank)) |
|
|
|
|
|
|
|
|
//logWrite(fmt.Sprintf("[%v] t:%v s:%v -> n:%v p:%v r:%v\n", len(runStats), event.time, srcPeer.node.index, node.index, event.part, rank))
|
|
|
|
|
|
|
|
|
if rank > 1 { |
|
|
if rank > 1 { |
|
|
// Already has this part, ignore this event.
|
|
|
// Already has this part, ignore this event.
|
|
@ -423,11 +403,11 @@ func main() { |
|
|
part: event.part, |
|
|
part: event.part, |
|
|
}) |
|
|
}) |
|
|
if sent { |
|
|
if sent { |
|
|
logWrite(fmt.Sprintf("p:%v WS\n", peer.node.index)) |
|
|
|
|
|
|
|
|
//logWrite(fmt.Sprintf("[%v] t:%v S:%v n:%v -> p:%v %v WS\n", len(runStats), event.time, srcPeer.node.index, node.index, peer.node.index, event.part))
|
|
|
peer.setGiven(event.part) |
|
|
peer.setGiven(event.part) |
|
|
numSendSuccess++ |
|
|
numSendSuccess++ |
|
|
} else { |
|
|
} else { |
|
|
logWrite(fmt.Sprintf("p:%v WF\n", peer.node.index)) |
|
|
|
|
|
|
|
|
//logWrite(fmt.Sprintf("[%v] t:%v S:%v n:%v -> p:%v %v WF\n", len(runStats), event.time, srcPeer.node.index, node.index, peer.node.index, event.part))
|
|
|
numSendFailure++ |
|
|
numSendFailure++ |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
@ -440,11 +420,11 @@ func main() { |
|
|
part: event.part, |
|
|
part: event.part, |
|
|
}) |
|
|
}) |
|
|
if sent { |
|
|
if sent { |
|
|
logWrite(fmt.Sprintf("p:%v TS\n", peer.node.index)) |
|
|
|
|
|
|
|
|
//logWrite(fmt.Sprintf("[%v] t:%v S:%v n:%v -> p:%v %v TS\n", len(runStats), event.time, srcPeer.node.index, node.index, peer.node.index, event.part))
|
|
|
peer.setGiven(event.part) |
|
|
peer.setGiven(event.part) |
|
|
// numSendSuccess++
|
|
|
// numSendSuccess++
|
|
|
} else { |
|
|
} else { |
|
|
logWrite(fmt.Sprintf("p:%v TF\n", peer.node.index)) |
|
|
|
|
|
|
|
|
//logWrite(fmt.Sprintf("[%v] t:%v S:%v n:%v -> p:%v %v TF\n", len(runStats), event.time, srcPeer.node.index, node.index, peer.node.index, event.part))
|
|
|
// numSendFailure++
|
|
|
// numSendFailure++
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|