From 84c13fac90df2018e449e05f6f6e514ff676b6af Mon Sep 17 00:00:00 2001 From: Arceliar Date: Thu, 7 Jun 2018 20:18:13 -0500 Subject: [PATCH] don't use TTL --- misc/sim/treesim.go | 4 ++++ src/yggdrasil/peer.go | 12 ++---------- src/yggdrasil/switch.go | 5 ++++- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/misc/sim/treesim.go b/misc/sim/treesim.go index d885926..91b8e0e 100644 --- a/misc/sim/treesim.go +++ b/misc/sim/treesim.go @@ -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 } } diff --git a/src/yggdrasil/peer.go b/src/yggdrasil/peer.go index 27be44b..ee25b07 100644 --- a/src/yggdrasil/peer.go +++ b/src/yggdrasil/peer.go @@ -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) } diff --git a/src/yggdrasil/switch.go b/src/yggdrasil/switch.go index de79f4a..be3027a 100644 --- a/src/yggdrasil/switch.go +++ b/src/yggdrasil/switch.go @@ -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) } ////////////////////////////////////////////////////////////////////////////////