4
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2025-09-16 00:52:30 +00:00

remove TTL from traffic packets

This commit is contained in:
Arceliar
2018-06-07 20:29:22 -05:00
parent 84c13fac90
commit bced15b138
7 changed files with 13 additions and 38 deletions

View File

@@ -413,22 +413,19 @@ func (t *switchTable) updateTable() {
t.table.Store(newTable)
}
func (t *switchTable) lookup(dest []byte, ttl uint64) (switchPort, uint64) {
func (t *switchTable) lookup(dest []byte) switchPort {
t.updater.Load().(*sync.Once).Do(t.updateTable)
table := t.table.Load().(lookupTable)
myDist := table.self.dist(dest) //getDist(table.self.coords)
if !(uint64(myDist) < ttl) {
//return 0, 0
}
myDist := table.self.dist(dest)
if myDist == 0 {
return 0, 0
return 0
}
// cost is in units of (expected distance) + (expected queue size), where expected distance is used as an approximation of the minimum backpressure gradient needed for packets to flow
ports := t.core.peers.getPorts()
var best switchPort
bestCost := int64(^uint64(0) >> 1)
for _, info := range table.elems {
dist := info.locator.dist(dest) //getDist(info.locator.coords)
dist := info.locator.dist(dest)
if !(dist < myDist) {
continue
}
@@ -442,9 +439,8 @@ func (t *switchTable) lookup(dest []byte, ttl uint64) (switchPort, uint64) {
bestCost = cost
}
}
//t.core.log.Println("DEBUG: sending to", best, "bandwidth", getBandwidth(best))
//t.core.log.Println("DEBUG: sending to", best, "cost", bestCost)
return best, ttl //uint64(myDist)
return best
}
////////////////////////////////////////////////////////////////////////////////