5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-12-22 22:15:46 +00:00

don't use TTL

This commit is contained in:
Arceliar 2018-06-07 20:18:13 -05:00
parent fe12e1509a
commit 84c13fac90
3 changed files with 10 additions and 11 deletions

View File

@ -207,6 +207,10 @@ func testPaths(store map[[32]byte]*Node) bool {
// This is sufficient to check for routing loops or blackholes
//break
}
if here == next {
fmt.Println("Drop2:", source.index, here.index, dest.index, oldTTL)
return false
}
here = next
}
}

View File

@ -204,15 +204,14 @@ func (p *peer) handleTraffic(packet []byte, pTypeLen int) {
// Drop traffic until the peer manages to send us at least one good switchMsg
return
}
ttl, ttlLen := wire_decode_uint64(packet[pTypeLen:])
ttlBegin := pTypeLen
_, ttlLen := wire_decode_uint64(packet[pTypeLen:])
ttlEnd := pTypeLen + ttlLen
coords, coordLen := wire_decode_coords(packet[ttlEnd:])
coordEnd := ttlEnd + coordLen
if coordEnd == len(packet) {
return
} // No payload
toPort, newTTL := p.core.switchTable.lookup(coords, ttl)
toPort, _ := p.core.switchTable.lookup(coords, 0)
if toPort == p.port {
return
}
@ -220,13 +219,6 @@ func (p *peer) handleTraffic(packet []byte, pTypeLen int) {
if to == nil {
return
}
// This mutates the packet in-place if the length of the TTL changes!
ttlSlice := wire_encode_uint64(newTTL)
newTTLLen := len(ttlSlice)
shift := ttlLen - newTTLLen
copy(packet[shift:], packet[:pTypeLen])
copy(packet[ttlBegin+shift:], ttlSlice)
packet = packet[shift:]
to.sendPacket(packet)
}

View File

@ -418,6 +418,9 @@ func (t *switchTable) lookup(dest []byte, ttl uint64) (switchPort, uint64) {
table := t.table.Load().(lookupTable)
myDist := table.self.dist(dest) //getDist(table.self.coords)
if !(uint64(myDist) < ttl) {
//return 0, 0
}
if myDist == 0 {
return 0, 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
@ -441,7 +444,7 @@ func (t *switchTable) lookup(dest []byte, ttl uint64) (switchPort, uint64) {
}
//t.core.log.Println("DEBUG: sending to", best, "bandwidth", getBandwidth(best))
//t.core.log.Println("DEBUG: sending to", best, "cost", bestCost)
return best, uint64(myDist)
return best, ttl //uint64(myDist)
}
////////////////////////////////////////////////////////////////////////////////