Search in sources :

Example 1 with Link

use of org.onosproject.net.Link in project onos by opennetworkinglab.

the class LinkPropsTopovMessageHandler method sendByteData.

private void sendByteData() {
    if (elementOfNote != null && elementOfNote instanceof Device) {
        DeviceId devId = (DeviceId) elementOfNote.id();
        Set<Link> links = linkService.getDeviceEgressLinks(devId);
        Highlights highlights = getTotalBytes(links, devId);
        sendHighlights(highlights);
    }
}
Also used : Highlights(org.onosproject.ui.topo.Highlights) Device(org.onosproject.net.Device) DeviceId(org.onosproject.net.DeviceId) Link(org.onosproject.net.Link)

Example 2 with Link

use of org.onosproject.net.Link in project onos by opennetworkinglab.

the class DefaultCheckLoop method processOneOutputInstruction.

/**
 * Process one output instruction.
 *
 * Params are passed from processOneInstruction directly,
 * and obey the same rules.
 *
 * @param instOne the instruction to be processed
 * @param currentDeviceId id of the device we are now in
 * @param initPkt the packet before being copied
 * @param matchedPkt the packet which matched the flow entry,
 *                   to which this instruction belongs
 * @param isFindLoop indicate if it is invoked by findLoop method
 * @param firstEntry the flow entry from which the packet is generated
 * @return true, if a loop is discovered;
 *         false, 1. invoked by matchDeviceFlows method, and detected no loop;
 *                2. invoked by findLoop method
 */
private boolean processOneOutputInstruction(Instruction instOne, DeviceId currentDeviceId, TsLoopPacket initPkt, TsLoopPacket matchedPkt, boolean isFindLoop, FlowEntry firstEntry) {
    OutputInstruction instOutput = (OutputInstruction) instOne;
    PortNumber instPort = instOutput.port();
    if (!instPort.isLogical()) {
        // single OUTPUT - NIC or normal port
        Set<Link> dstLink = tsGetEgressLinks(new ConnectPoint(currentDeviceId, instPort));
        if (!dstLink.isEmpty()) {
            // TODO - now, just deal with the first destination.
            // will there be more destinations?
            Link dstThisLink = dstLink.iterator().next();
            ConnectPoint dstPoint = dstThisLink.dst();
            // check output to devices only (output to a host is normal)
            if (isDevice(dstPoint)) {
                PortCriterion oldInPort = updatePktInportPerHop(matchedPkt, dstPoint);
                matchedPkt.pushPathLink(dstThisLink);
                TsLoopPacket newNewPkt = matchedPkt.copyPacketMatch();
                boolean loopFound = matchDeviceFlows(dstPoint.deviceId(), newNewPkt);
                if (isFindLoop) {
                    if (loopFound) {
                        loops.add(newNewPkt);
                        updateExcludeDeviceSet(newNewPkt);
                    }
                    matchedPkt.resetLinkFlow(firstEntry);
                } else {
                    if (loopFound) {
                        initPkt.handInLoopMatch(newNewPkt);
                        return true;
                    }
                    matchedPkt.popPathLink();
                }
                restorePktInportPerHop(matchedPkt, oldInPort);
            }
        } else {
            if (!isFindLoop) {
                // TODO - NEED
                log.warn("no link connecting at device {}, port {}", currentDeviceId, instPort);
            }
        }
    } else if (instPort.equals(PortNumber.IN_PORT)) {
        // TODO - in the future,
        // we may need to resolve this condition 1
        log.warn("can not handle {} port now.", PortNumber.IN_PORT);
    } else if (instPort.equals(PortNumber.NORMAL) || instPort.equals(PortNumber.FLOOD) || instPort.equals(PortNumber.ALL)) {
        // TODO - in the future,
        // we may need to resolve this condition 2
        log.warn("can not handle {}/{}/{} now.", PortNumber.NORMAL, PortNumber.FLOOD, PortNumber.ALL);
    }
    return false;
}
Also used : OutputInstruction(org.onosproject.net.flow.instructions.Instructions.OutputInstruction) PortCriterion(org.onosproject.net.flow.criteria.PortCriterion) PortNumber(org.onosproject.net.PortNumber) ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link) TsLoopPacket(org.onosproject.fnl.base.TsLoopPacket)

Example 3 with Link

use of org.onosproject.net.Link in project onos by opennetworkinglab.

the class DefaultCheckLoop method tsGetEgressLinks.

private Set<Link> tsGetEgressLinks(ConnectPoint point) {
    Set<Link> portEgressLink = new HashSet<>();
    DeviceId deviceId = point.deviceId();
    portEgressLink.addAll(// all egress links
    egressLinkInfo.get(deviceId).stream().filter(l -> l.src().equals(point)).collect(Collectors.toList()));
    return portEgressLink;
}
Also used : DeviceId(org.onosproject.net.DeviceId) Link(org.onosproject.net.Link) HashSet(java.util.HashSet)

Example 4 with Link

use of org.onosproject.net.Link in project onos by opennetworkinglab.

the class OpticalPathProvisioner method activate.

@Activate
protected void activate(ComponentContext context) {
    deviceService = opticalView(deviceService);
    appId = coreService.registerApplication("org.onosproject.newoptical");
    idCounter = storageService.getAtomicCounter(OPTICAL_CONNECTIVITY_ID_COUNTER);
    linkPathMap = storageService.<PacketLinkRealizedByOptical, OpticalConnectivity>consistentMapBuilder().withSerializer(Serializer.using(LINKPATH_SERIALIZER.build())).withName(LINKPATH_MAP_NAME).withApplicationId(appId).build();
    connectivityMap = storageService.<OpticalConnectivityId, OpticalConnectivity>consistentMapBuilder().withSerializer(Serializer.using(CONNECTIVITY_SERIALIZER.build())).withName(CONNECTIVITY_MAP_NAME).withApplicationId(appId).build();
    usedCrossConnectLinkSet = storageService.<Link>setBuilder().withSerializer(Serializer.using(CROSSCONNECTLINKS_SERIALIZER.build())).withName(CROSSCONNECTLINK_SET_NAME).withApplicationId(appId).build().asDistributedSet();
    eventDispatcher.addSink(OpticalPathEvent.class, listenerRegistry);
    listeners = new ListenerTracker();
    listeners.addListener(linkService, new InternalLinkListener()).addListener(intentService, new InternalIntentListener());
    linkPathMap.addListener(storeListener);
    readComponentConfiguration(context);
    log.info("Started");
}
Also used : ListenerTracker(org.onosproject.event.ListenerTracker) Link(org.onosproject.net.Link) Activate(org.osgi.service.component.annotations.Activate)

Example 5 with Link

use of org.onosproject.net.Link in project onos by opennetworkinglab.

the class OpticalPathProvisioner method setupPath.

/*
     * Given a multi-layer path,
     * compute a set of segments which requires
     * OpticalConnectivity(~=OpticalConnectivityIntent or OpticalCircuitPath)
     * to provide packet-layer connectivity.
     */
@Override
public OpticalConnectivityId setupPath(Path path, Bandwidth bandwidth, Duration latency) {
    checkNotNull(path);
    log.debug("setupPath({}, {}, {})", path, bandwidth, latency);
    // map of cross connect points (optical port -> packet port)
    Map<ConnectPoint, ConnectPoint> crossConnectPointMap = new HashMap<>();
    // list of (src, dst) pair of optical ports between which optical path should be installed
    List<Pair<ConnectPoint, ConnectPoint>> crossConnectPoints = new ArrayList<>();
    // Scan path to find pairs of connect points between which optical intent is installed
    // opticalSrcPort works as a flag parameter to show scanning status
    ConnectPoint opticalSrcPort = null;
    for (Link link : path.links()) {
        if (!isCrossConnectLink(link)) {
            continue;
        }
        if (opticalSrcPort != null) {
            // opticalSrcPort!=null means src port was already found
            // in this case link.src() is optical layer, and link.dst() is packet layer
            // Check if types of src port and dst port matches
            Device srcDevice = checkNotNull(deviceService.getDevice(opticalSrcPort.deviceId()), "Unknown device ID");
            Device dstDevice = checkNotNull(deviceService.getDevice(link.src().deviceId()), "Unknown device ID");
            if (srcDevice.type() != dstDevice.type()) {
                log.error("Unsupported mix of cross connect points : {}, {}", srcDevice.type(), dstDevice.type());
                return null;
            }
            // Update cross connect points map
            crossConnectPointMap.put(link.src(), link.dst());
            // Add optical ports pair to list
            crossConnectPoints.add(Pair.of(opticalSrcPort, link.src()));
            // Reset flag parameter
            opticalSrcPort = null;
        } else {
            // opticalSrcPort==null means src port was not found yet
            // in this case link.src() is packet layer, and link.dst() is optical layer
            // Update cross connect points map
            crossConnectPointMap.put(link.dst(), link.src());
            // Set opticalSrcPort to src of link (optical port)
            opticalSrcPort = link.dst();
        }
    }
    // create intents from cross connect points
    List<Intent> intents = createIntents(crossConnectPoints);
    if (intents.isEmpty()) {
        log.error("No intents produced from {}", crossConnectPoints);
        return null;
    }
    // create set of PacketLinkRealizedByOptical
    Set<PacketLinkRealizedByOptical> packetLinks = createPacketLinkSet(crossConnectPoints, intents, crossConnectPointMap);
    // create OpticalConnectivity object and store information to distributed store
    OpticalConnectivity connectivity = createConnectivity(path, bandwidth, latency, packetLinks);
    // store cross connect port usage
    path.links().stream().filter(this::isCrossConnectLink).forEach(usedCrossConnectLinkSet::add);
    // Submit the intents
    for (Intent i : intents) {
        intentService.submit(i);
        log.debug("Submitted an intent: {}", i);
    }
    return connectivity.id();
}
Also used : HashMap(java.util.HashMap) Device(org.onosproject.net.Device) ArrayList(java.util.ArrayList) OpticalCircuitIntent(org.onosproject.net.intent.OpticalCircuitIntent) Intent(org.onosproject.net.intent.Intent) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) ConnectPoint(org.onosproject.net.ConnectPoint) Link(org.onosproject.net.Link) Pair(org.apache.commons.lang3.tuple.Pair)

Aggregations

Link (org.onosproject.net.Link)172 ConnectPoint (org.onosproject.net.ConnectPoint)75 Test (org.junit.Test)66 DefaultLink (org.onosproject.net.DefaultLink)44 Intent (org.onosproject.net.intent.Intent)40 DeviceId (org.onosproject.net.DeviceId)39 TrafficSelector (org.onosproject.net.flow.TrafficSelector)27 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)26 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)26 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)26 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)26 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)26 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)24 List (java.util.List)23 LinkKey (org.onosproject.net.LinkKey)23 Set (java.util.Set)22 DefaultPath (org.onosproject.net.DefaultPath)20 FlowRule (org.onosproject.net.flow.FlowRule)20 Collectors (java.util.stream.Collectors)19 PathIntent (org.onosproject.net.intent.PathIntent)18