use of org.onosproject.net.Link in project ddosdn by ssulca.
the class Monitoring method getStatisticsEdgePortsTotal.
/**
* Retorna Conjunto de los PortStatistics de los puertos conectados a los edges
* @param devId DeviceId del disposivo del cual se quiere obtener las estadisticas Totales
* @return a Set con todos los PortStatics
*/
default Set<PortStatistics> getStatisticsEdgePortsTotal(DeviceService deviceService, LinkService linkService, DeviceId devId, Logger log) {
Device dev;
Set<PortStatistics> portSet;
portSet = new HashSet<>();
// se obtienen todos los links conectado al dispostivo
Set<Link> ingressLinks = linkService.getDeviceIngressLinks(devId);
// busqueda en los enlaces, buscado conexiones con los edges
for (Link link : ingressLinks) {
dev = deviceService.getDevice(link.src().deviceId());
try {
if (dev.annotations().value(ANNT).equals(EDGE)) {
/* True: se agrega la estadistica del puerto. */
// log.info("dev/port: {}/{}",devId,link.dst().port()); //cometar
portSet.add(deviceService.getStatisticsForPort(devId, link.dst().port()));
}
} catch (NullPointerException e) {
log.error("No se encuentran las anotaciones :dev{}", dev.id().toString());
}
}
return portSet;
}
use of org.onosproject.net.Link in project TFG by mattinelorza.
the class Ipv6SimpleRoutingComponent method setUpPath.
private void setUpPath(HostId srcId, HostId dstId) {
Host src = hostService.getHost(srcId);
Host dst = hostService.getHost(dstId);
// Check if hosts are located at the same switch
log.info("Src switch id={} and Dst switch id={}", src.location().deviceId(), dst.location().deviceId());
if (src.location().deviceId().toString().equals(dst.location().deviceId().toString())) {
PortNumber outPort = dst.location().port();
DeviceId devId = dst.location().deviceId();
FlowRule nextHopRule = createL2NextHopRule(devId, dst.mac(), outPort);
flowRuleService.applyFlowRules(nextHopRule);
log.info("Hosts in the same switch");
return;
}
// Get all the available paths between two given hosts
// A path is a collection of links
Set<Path> paths = topologyService.getPaths(topologyService.currentTopology(), src.location().deviceId(), dst.location().deviceId());
if (paths.isEmpty()) {
// If there are no paths, display a warn and exit
log.warn("No path found");
return;
}
// Pick a path that does not lead back to where we
// came from; if no such path,display a warn and exit
Path path = pickForwardPathIfPossible(paths, src.location().port());
if (path == null) {
log.warn("Don't know where to go from here {} for {} -> {}", src.location(), srcId, dstId);
return;
}
// Install rules in the path
List<Link> pathLinks = path.links();
for (Link l : pathLinks) {
PortNumber outPort = l.src().port();
DeviceId devId = l.src().deviceId();
FlowRule nextHopRule = createL2NextHopRule(devId, dst.mac(), outPort);
flowRuleService.applyFlowRules(nextHopRule);
}
// Install rule in the last device (where dst is located)
PortNumber outPort = dst.location().port();
DeviceId devId = dst.location().deviceId();
FlowRule nextHopRule = createL2NextHopRule(devId, dst.mac(), outPort);
flowRuleService.applyFlowRules(nextHopRule);
}
use of org.onosproject.net.Link in project onos by opennetworkinglab.
the class VirtualNetworkTopologyManager method currentTopology.
@Override
public Topology currentTopology() {
Iterable<Device> devices = manager.getVirtualDevices(networkId()).stream().collect(Collectors.toSet());
Iterable<Link> links = manager.getVirtualLinks(networkId()).stream().collect(Collectors.toSet());
DefaultGraphDescription graph = new DefaultGraphDescription(System.nanoTime(), System.currentTimeMillis(), devices, links);
return new DefaultTopology(PID, graph);
}
use of org.onosproject.net.Link in project onos by opennetworkinglab.
the class VirtualLinkCodec method encode.
@Override
public ObjectNode encode(VirtualLink vLink, CodecContext context) {
checkNotNull(vLink, NULL_OBJECT_MSG);
ObjectNode result = context.mapper().createObjectNode().put(NETWORK_ID, vLink.networkId().toString());
JsonCodec<Link> codec = context.codec(Link.class);
ObjectNode linkResult = codec.encode(vLink, context);
result.setAll(linkResult);
return result;
}
use of org.onosproject.net.Link in project onos by opennetworkinglab.
the class VirtualLinkCodec method decode.
@Override
public VirtualLink decode(ObjectNode json, CodecContext context) {
if (json == null || !json.isObject()) {
return null;
}
JsonCodec<Link> codec = context.codec(Link.class);
Link link = codec.decode(json, context);
NetworkId nId = NetworkId.networkId(Long.parseLong(extractMember(NETWORK_ID, json)));
return DefaultVirtualLink.builder().networkId(nId).src(link.src()).dst(link.dst()).build();
}
Aggregations