Exemplo n.º 1
0
Arquivo: spi.go Projeto: cycps/addie
func dnsSubstrate() spi.Substrate {
	var s spi.Substrate
	s.Name = "dnslink"
	s.Capacity = spi.Capacity{float64(100.0) * 1000, spi.Kind{"max"}}
	s.Latency = spi.Latency{float64(4.0), spi.Kind{"max"}}

	return s
}
Exemplo n.º 2
0
Arquivo: spi.go Projeto: cycps/addie
func krySubstrate() spi.Substrate {

	var ks spi.Substrate
	ks.Name = "krynet"
	ks.Capacity = spi.Capacity{float64(1000.0) * 1000, spi.Kind{"max"}}
	ks.Latency = spi.Latency{float64(0.0), spi.Kind{"max"}}

	return ks

}
Exemplo n.º 3
0
Arquivo: spi.go Projeto: cycps/addie
func swSubstrate(sw *addie.Switch) spi.Substrate {

	var ss spi.Substrate
	ss.Name = sw.Name
	ss.Capacity = spi.Capacity{float64(sw.Capacity) * 1000, spi.Kind{"max"}}
	ss.Latency = spi.Latency{float64(sw.Latency), spi.Kind{"max"}}

	return ss

}
Exemplo n.º 4
0
Arquivo: spi.go Projeto: cycps/addie
func linkSubstrate(link *addie.Link, dsg *addie.Design,
	xp *spi.Experiment,
	cMap map[addie.Id]*spi.Computer,
	sMap map[addie.Id]*spi.Substrate) *spi.Substrate {

	var ss spi.Substrate
	ss.Name = link.Name
	ss.Capacity = spi.Capacity{float64(link.Capacity) * 1000, spi.Kind{"max"}}
	ss.Latency = spi.Latency{float64(link.Latency), spi.Kind{"max"}}

	a, ok := dsg.Elements[link.Endpoints[0].Id]
	if !ok {
		log.Printf("link '%s' references element '%v' but no such element exists",
			link.Name, link.Endpoints[0].Id)
		return nil
	}
	b, ok := dsg.Elements[link.Endpoints[1].Id]
	if !ok {
		log.Printf("link '%s' references element '%v' but no such element exists",
			link.Name, link.Endpoints[0].Id)
		return nil
	}

	ta := reflect.TypeOf(a).Name()
	tb := reflect.TypeOf(b).Name()

	taIsHost := ta == "Computer" || ta == "Router" || ta == "Sax"
	tbIsHost := tb == "Computer" || tb == "Router" || tb == "Sax"

	if taIsHost && tbIsHost {
		updateEndpoint(link.Name, link.Endpoints[0], dsg, xp, cMap)
		updateEndpoint(link.Name, link.Endpoints[1], dsg, xp, cMap)
		return &ss
	} else if taIsHost && !tbIsHost {
		sw := b.(addie.Switch)
		updateEndpoint(sw.Name, link.Endpoints[0], dsg, xp, cMap)
		return nil
	} else if !taIsHost && tbIsHost {
		sw := a.(addie.Switch)
		updateEndpoint(sw.Name, link.Endpoints[1], dsg, xp, cMap)
		return nil
	}

	return nil
}