gentree

package
v0.0.0-...-fa7aae8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2020 License: AGPL-3.0 Imports: 15 Imported by: 0

README

gentree

This folder contains the code to generate the ARAs for Crux, and the corresponding Onet trees. It was inspired from paper_nyle.

Documentation

Index

Constants

View Source
const MIN_BUNCH_SIZE = 12
View Source
const NR_LEVELS = 3
View Source
const OPTIMIZED = false
View Source
const OPTTYPE = 1
View Source
const RND_LVLS = RND_NODES
View Source
const RND_NODES = false

Variables

This section is empty.

Functions

func AproximateDistanceOracle

func AproximateDistanceOracle(all LocalityNodes) map[*LocalityNode]map[*LocalityNode]float64

func CreateARAs

func CreateARAs(all LocalityNodes, rootName string,
	dist2 map[*LocalityNode]map[*LocalityNode]float64) (
	[][]*LocalityNode, []float64)

CreateARAs create ARAs

func CreateAndSetChildren

func CreateAndSetChildren(Rings bool, AllowedNodes map[string]bool,
	file *os.File, all LocalityNodes, treeNode *onet.TreeNode,
	NodeList map[string]*onet.TreeNode,
	parents map[*onet.TreeNode][]*onet.TreeNode) map[*onet.
	TreeNode][]*onet.TreeNode

CreateAndSetChildren Called on a node, It will add all the coresponding children depending on the optimisation stated previously AllowedNodes are the nodes that remain in the tree after the optimisation and the filter by radius (Rings) treeNode is the node that we are about to set the parents/childrens of

func CreateLocalityGraph

func CreateLocalityGraph(all LocalityNodes, randomCoords, randomLevels bool,
	levels int, pingDist map[string]map[string]float64)

CreateLocalityGraph creates a locality graph First argument is all the nodes Second argument is if the coordinates are random Third arguments is if the levels are random Fourth argument is how many levels there should be if they are random Second and Third arguments should always be the same

func CreateOnetLPTree

func CreateOnetLPTree(all LocalityNodes, rootName string, BunchLowerBound int) (
	[]*onet.Tree, [][]*onet.TreeNode, []map[*onet.TreeNode][]*onet.TreeNode,
	map[*LocalityNode]map[*LocalityNode]float64)

CreateOnetLPTree TODO add documentation Will Build The Tree calling different functions for different purposes It's the main function, all functions created are called directly or indirectly through this one

func CreateOnetRings

func CreateOnetRings(all LocalityNodes, rootName string,
	dist2 map[*LocalityNode]map[*LocalityNode]float64) ([]*onet.Tree,
	[][]*onet.TreeNode, []map[*onet.TreeNode][]*onet.TreeNode, []float64)

CreateOnetRings create Onet rings

func GenerateRadius

func GenerateRadius(maxDist float64) []float64

GenerateRadius GenerateRadius

func GetBridges

func GetBridges(all LocalityNodes, Root *LocalityNode) map[*LocalityNode]map[*LocalityNode]bool

Returns all the bridges of the current Graph

func GetChildren

func GetChildren(all LocalityNodes, A *LocalityNode) map[*LocalityNode]bool

Returns the Union of the Bunch and The Cluster with no duplicates

func MapLen2

func MapLen2(Map map[string]bool) int

Does the same as MapLen but with maps that have the type String as keys The Length will be the amount of keys that have the value "true"

func NodeNameToInt

func NodeNameToInt(nodeName string) int

NodeNameToInt Converts a Node to it's index

func OptimizeGraph

func OptimizeGraph(all LocalityNodes, rootName string, Optimization int,
	OptType int)

OptimizeGraph function Root is the root of the graph Optimization is the upperBound set on the bunch of each node of the graph

func RemoveLink(A *LocalityNode, B *LocalityNode, LinkList *map[*LocalityNode]map[*LocalityNode]bool)

Removes a link from The LinkLlist

func RemoveLinks(all LocalityNodes, Root *LocalityNode, max int, OptType int)

Removes Links from the Graph According to some omtimisation conditions

func UpdateDistance

func UpdateDistance(all LocalityNodes, startNode *LocalityNode)

Types

type ByServerIdentityAlphabetical

type ByServerIdentityAlphabetical []*network.ServerIdentity

ByServerIdentityAlphabetical ByServerIdentityAlphabetical

func (ByServerIdentityAlphabetical) Len

func (ByServerIdentityAlphabetical) Less

func (a ByServerIdentityAlphabetical) Less(i, j int) bool

func (ByServerIdentityAlphabetical) Swap

func (a ByServerIdentityAlphabetical) Swap(i, j int)

type GraphTree

type GraphTree struct {
	Tree        *onet.Tree
	ListOfNodes []*onet.TreeNode
	Parents     map[*onet.TreeNode][]*onet.TreeNode
	Radius      float64
}

GraphTree Represents the actual graph that will be linked to the Binary Tree of the Protocol

type LocalityNode

type LocalityNode struct {
	Name string
	IP   map[string]bool
	/*
		X              float64
		Y              float64
	*/
	Level          int
	ADist          []float64 // ADist[l] - minimum distance to level l
	PDist          []string  // pDist[l] - the node at level l whose distance from the crt Node isADist[l]
	Cluster        map[string]bool
	Bunch          map[string]bool
	OptimalCluster map[string]bool
	OptimalBunch   map[string]bool
	Rings          []string
	NrOwnRings     int
	ServerIdentity *network.ServerIdentity
}

LocalityNode represents a locality preserving node.

func CreateNode

func CreateNode(Name string, level int) *LocalityNode

CreateNode with the given parameters

func Filter

func Filter(all LocalityNodes, root *LocalityNode, radius float64,
	distances map[*LocalityNode]map[*LocalityNode]float64) []*LocalityNode

Filter Nodes depending on their distance to the root given as an argument distances is the distance between two nodes in the current graph

func NodesInARA

func NodesInARA(all LocalityNodes, root *LocalityNode, radius float64,
	distances map[*LocalityNode]map[*LocalityNode]float64) []*LocalityNode

NodesInARA NodesInARA

type LocalityNodes

type LocalityNodes struct {
	All                   []*LocalityNode
	ServerIdentityToName  map[network.ServerIdentityID]string
	ClusterBunchDistances map[*LocalityNode]map[*LocalityNode]float64
	Links                 map[*LocalityNode]map[*LocalityNode]map[*LocalityNode]bool
}

LocalityNodes is a list of LocalityNode

func GenARAs

func GenARAs(Nodes LocalityNodes, rootNodeName string,
	PingDistances map[string]map[string]float64, NrLevels int) (
	AuxNodes LocalityNodes, dist2 map[*LocalityNode]map[*LocalityNode]float64,
	ARATreeStruct map[string][]GraphTree,
	ARAOnetTrees map[string][]*onet.Tree)

GenARAs : Runs the compact routing algorithm to generate ARAs. It returns "AuxNodes", a LocalityNodes structure with all compact routing relevant fields filled in (bunch, cluster etc), as well as all fields that "Nodes" has; the caller can use it to replace the initial "Nodes" structure "dist2" the compact distance matrix relevant for the node "rootNodeName", "ARATreeStruct" a map with a graphTree slice for every node in "Nodes"; each slice contains a graphTree for each ARA created by that node, and "ARAOnetTrees", a map with a onet tree slice for every node in "Nodes"; each slice contains an onet tree for each ARA created by that node, that the caller can use to run protocols on.

func (LocalityNodes) GetByIP

func (ns LocalityNodes) GetByIP(ip string) *LocalityNode

GetByIP gets the node by IP.

func (LocalityNodes) GetByName

func (ns LocalityNodes) GetByName(name string) *LocalityNode

GetByName gets the node by name.

func (LocalityNodes) GetByServerIdentityIP

func (ns LocalityNodes) GetByServerIdentityIP(ip string) *LocalityNode

GetByServerIdentityIP GetByServerIdentityIP

func (LocalityNodes) GetServerIdentityToName

func (ns LocalityNodes) GetServerIdentityToName(
	sid *network.ServerIdentity) string

GetServerIdentityToName gets the name by server identity.

func (LocalityNodes) NameToServerIdentity

func (ns LocalityNodes) NameToServerIdentity(name string) *network.
	ServerIdentity

NameToServerIdentity gets the server identity by name.

type TreeConverter

type TreeConverter struct {
	BinaryTree    *onet.Tree
	RecursiveTree *onet.Tree
}

TreeConverter is a structure for converting between a recursive tree (graph) and a binary tree.

func (*TreeConverter) ToBinaryTreeNode

func (t *TreeConverter) ToBinaryTreeNode(target *onet.TreeNode) (
	*onet.TreeNode, error)

ToBinaryTreeNode finds the equivalent tree node in the binary tree.

func (*TreeConverter) ToRecursiveTreeNode

func (t *TreeConverter) ToRecursiveTreeNode(target *onet.TreeNode) (
	*onet.TreeNode, error)

ToRecursiveTreeNode finds the equivalent tree node in the recursive tree.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL