mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-11-28 20:45:18 +00:00
don't use TTL
This commit is contained in:
parent
fe12e1509a
commit
84c13fac90
@ -207,6 +207,10 @@ func testPaths(store map[[32]byte]*Node) bool {
|
|||||||
// This is sufficient to check for routing loops or blackholes
|
// This is sufficient to check for routing loops or blackholes
|
||||||
//break
|
//break
|
||||||
}
|
}
|
||||||
|
if here == next {
|
||||||
|
fmt.Println("Drop2:", source.index, here.index, dest.index, oldTTL)
|
||||||
|
return false
|
||||||
|
}
|
||||||
here = next
|
here = next
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
// Drop traffic until the peer manages to send us at least one good switchMsg
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ttl, ttlLen := wire_decode_uint64(packet[pTypeLen:])
|
_, ttlLen := wire_decode_uint64(packet[pTypeLen:])
|
||||||
ttlBegin := pTypeLen
|
|
||||||
ttlEnd := pTypeLen + ttlLen
|
ttlEnd := pTypeLen + ttlLen
|
||||||
coords, coordLen := wire_decode_coords(packet[ttlEnd:])
|
coords, coordLen := wire_decode_coords(packet[ttlEnd:])
|
||||||
coordEnd := ttlEnd + coordLen
|
coordEnd := ttlEnd + coordLen
|
||||||
if coordEnd == len(packet) {
|
if coordEnd == len(packet) {
|
||||||
return
|
return
|
||||||
} // No payload
|
} // No payload
|
||||||
toPort, newTTL := p.core.switchTable.lookup(coords, ttl)
|
toPort, _ := p.core.switchTable.lookup(coords, 0)
|
||||||
if toPort == p.port {
|
if toPort == p.port {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -220,13 +219,6 @@ func (p *peer) handleTraffic(packet []byte, pTypeLen int) {
|
|||||||
if to == nil {
|
if to == nil {
|
||||||
return
|
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)
|
to.sendPacket(packet)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,6 +418,9 @@ func (t *switchTable) lookup(dest []byte, ttl uint64) (switchPort, uint64) {
|
|||||||
table := t.table.Load().(lookupTable)
|
table := t.table.Load().(lookupTable)
|
||||||
myDist := table.self.dist(dest) //getDist(table.self.coords)
|
myDist := table.self.dist(dest) //getDist(table.self.coords)
|
||||||
if !(uint64(myDist) < ttl) {
|
if !(uint64(myDist) < ttl) {
|
||||||
|
//return 0, 0
|
||||||
|
}
|
||||||
|
if myDist == 0 {
|
||||||
return 0, 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
|
// 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, "bandwidth", getBandwidth(best))
|
||||||
//t.core.log.Println("DEBUG: sending to", best, "cost", bestCost)
|
//t.core.log.Println("DEBUG: sending to", best, "cost", bestCost)
|
||||||
return best, uint64(myDist)
|
return best, ttl //uint64(myDist)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
Reference in New Issue
Block a user