update admin dot to better handle missing nodes and to direct links towards parent, based on neilalexander's work

This commit is contained in:
Arceliar 2018-01-21 14:58:54 -06:00
parent 625b97c511
commit 87a4af7841
2 changed files with 73 additions and 13 deletions

View File

@ -377,6 +377,14 @@ func dumpDHTSize(store map[[32]byte]*Node) {
fmt.Printf("DHT min %d / avg %f / max %d\n", min, avg, max) fmt.Printf("DHT min %d / avg %f / max %d\n", min, avg, max)
} }
func (n *Node) startUDP(listen string) {
n.core.DEBUG_setupAndStartGlobalUDPInterface(listen)
}
func (n *Node) connectUDP(remoteAddr string) {
n.core.DEBUG_maybeSendUDPKeys(remoteAddr)
}
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
var cpuprofile = flag.String("cpuprofile", "", "write cpu profile `file`") var cpuprofile = flag.String("cpuprofile", "", "write cpu profile `file`")
@ -416,6 +424,22 @@ func main() {
} }
*/ */
startNetwork(kstore) startNetwork(kstore)
if true {
for _, node := range kstore {
node.startUDP("localhost:0")
node.connectUDP("localhost:12345")
break // just 1
}
for _, node := range kstore {
go func() {
// Just dump any packets sent to this node
for range node.recv {
}
}()
}
var block chan struct{}
<-block
}
//time.Sleep(10*time.Second) //time.Sleep(10*time.Second)
// Note that testPaths only works if pressure is turend off // Note that testPaths only works if pressure is turend off
// Otherwise congestion can lead to routing loops? // Otherwise congestion can lead to routing loops?

View File

@ -111,24 +111,60 @@ func (a *admin) handleRequest(conn net.Conn) {
} }
a.core.router.doAdmin(getSessions) a.core.router.doAdmin(getSessions)
// Now print it all out // Start building a tree from all known nodes
conn.Write([]byte(fmt.Sprintf("graph {\n"))) type nodeInfo struct {
for k := range m { name string
var mask [mDepth]switchPort key [mDepth]switchPort
copy(mask[:mDepth], k[:]) parent [mDepth]switchPort
for mk := range mask {
mask[len(mask)-1-mk] = 0
if len(m[k]) == 0 {
m[k] = fmt.Sprintf("%+v (missing)", k)
} }
if len(m[mask]) == 0 { infos := make(map[[mDepth]switchPort]nodeInfo)
m[mask] = fmt.Sprintf("%+v (missing)", mask) // First fill the tree with all known nodes, no parents
for k, n := range m {
infos[k] = nodeInfo{
name: n,
key: k,
} }
if len(m[mask]) > 0 && m[mask] != m[k] { }
conn.Write([]byte(fmt.Sprintf(" \"%+v\" -- \"%+v\";\n", m[k], m[mask]))) // Now go through and create placeholders for any missing nodes
for _, info := range infos {
for idx, port := range info.key {
if port == 0 {
break
}
var key [mDepth]switchPort
copy(key[:idx], info.key[:])
newInfo, isIn := infos[key]
if isIn {
continue
}
newInfo.name = "missing"
newInfo.key = key
infos[key] = newInfo
}
}
// Now go through and attach parents
for _, info := range infos {
info.parent = info.key
for idx := len(info.parent) - 1; idx >= 0; idx-- {
if info.parent[idx] != 0 {
info.parent[idx] = 0
break break
} }
} }
infos[info.key] = info
}
// Now print it all out
conn.Write([]byte(fmt.Sprintf("digraph {\n")))
// First set the labels
for _, info := range infos {
conn.Write([]byte(fmt.Sprintf("\"%v\" [ label = \"%v\" ];\n", info.key, info.name)))
}
// Then print the tree structure
for _, info := range infos {
if info.key == info.parent {
continue
} // happens for the root, skip it
conn.Write([]byte(fmt.Sprintf(" \"%+v\" -> \"%+v\";\n", info.key, info.parent)))
} }
conn.Write([]byte(fmt.Sprintf("}\n"))) conn.Write([]byte(fmt.Sprintf("}\n")))
break break