Search in sources :

Example 21 with Link

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;
}
Also used : Device(org.onosproject.net.Device) PortStatistics(org.onosproject.net.device.PortStatistics) Link(org.onosproject.net.Link)

Example 22 with Link

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);
}
Also used : Path(org.onosproject.net.Path) DeviceId(org.onosproject.net.DeviceId) Host(org.onosproject.net.Host) FlowRule(org.onosproject.net.flow.FlowRule) PortNumber(org.onosproject.net.PortNumber) Link(org.onosproject.net.Link)

Example 23 with Link

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);
}
Also used : DefaultTopology(org.onosproject.common.DefaultTopology) Device(org.onosproject.net.Device) DefaultGraphDescription(org.onosproject.net.topology.DefaultGraphDescription) Link(org.onosproject.net.Link)

Example 24 with Link

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;
}
Also used : ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) DefaultVirtualLink(org.onosproject.incubator.net.virtual.DefaultVirtualLink) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink) Link(org.onosproject.net.Link)

Example 25 with Link

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();
}
Also used : NetworkId(org.onosproject.incubator.net.virtual.NetworkId) DefaultVirtualLink(org.onosproject.incubator.net.virtual.DefaultVirtualLink) VirtualLink(org.onosproject.incubator.net.virtual.VirtualLink) Link(org.onosproject.net.Link)

Aggregations

Link (org.onosproject.net.Link)210 ConnectPoint (org.onosproject.net.ConnectPoint)92 Test (org.junit.Test)66 DeviceId (org.onosproject.net.DeviceId)62 DefaultLink (org.onosproject.net.DefaultLink)50 Intent (org.onosproject.net.intent.Intent)40 List (java.util.List)38 Set (java.util.Set)33 Collectors (java.util.stream.Collectors)30 Device (org.onosproject.net.Device)30 TrafficSelector (org.onosproject.net.flow.TrafficSelector)30 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)29 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)28 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)28 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)26 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)26 ArrayList (java.util.ArrayList)24 Collections (java.util.Collections)24 Path (org.onosproject.net.Path)24 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)24