use of org.onosproject.net.ConnectPoint 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;
}
use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.
the class PacketLinkRealizedByOpticalTest method testCreateWithConnectivityIntent.
/**
* Checks the construction of OpticalConnectivityId object with OpticalConnectivityIntent.
*/
@Test
public void testCreateWithConnectivityIntent() {
ConnectPoint cp1 = new ConnectPoint(DeviceId.deviceId("of:0000000000000001"), PortNumber.portNumber(1L));
ConnectPoint cp2 = new ConnectPoint(DeviceId.deviceId("of:0000000000000002"), PortNumber.portNumber(2L));
OpticalConnectivityIntent connIntent = OpticalConnectivityIntent.builder().appId(appId).src(cp1).dst(cp2).bidirectional(true).key(Key.of(0, appId)).signalType(OduSignalType.ODU4).build();
PacketLinkRealizedByOptical plink = PacketLinkRealizedByOptical.create(cp1, cp2, connIntent);
assertNotNull(plink);
assertEquals(plink.src(), cp1);
assertEquals(plink.dst(), cp2);
assertEquals((long) plink.bandwidth().bps(), OduSignalType.ODU4.bitRate());
}
use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.
the class AddOpticalConnectivityCommand method doExecute.
@Override
protected void doExecute() {
OpticalPathService opticalPathService = get(OpticalPathService.class);
ConnectPoint ingress = readConnectPoint(ingressStr);
ConnectPoint egress = readConnectPoint(egressStr);
if (ingress == null || egress == null) {
print("Invalid connect points: %s, %s", ingressStr, egressStr);
return;
}
Bandwidth bandwidth = (bandwidthStr == null || bandwidthStr.isEmpty()) ? null : Bandwidth.bps(Long.valueOf(bandwidthStr));
print("Trying to setup connectivity between %s and %s.", ingress, egress);
OpticalConnectivityId id = opticalPathService.setupConnectivity(ingress, egress, bandwidth, null);
if (id == null) {
print("Failed. See ONOS log for more details.");
print(" log:set TRACE org.onosproject.newoptical.OpticalPathProvisioner");
return;
}
// FIXME This is the last chance to know the Optical path ID.
// there's no other way to know existing Optical Path ID
print("Optical path ID : %s", id.id());
log.info("Optical path ID {} for connectivity between {} and {}", id.id(), ingress, egress);
}
use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.
the class OpticalConnectivityTest method testLinkEstablishedByConnectivityIntent.
/**
* Checks that isAllRealizingLink(Not)Established works for OpticalConnectivityIntent.
*/
@Test
public void testLinkEstablishedByConnectivityIntent() {
// Mock 7-nodes linear topology
ConnectPoint cp12 = createConnectPoint(1, 2);
ConnectPoint cp21 = createConnectPoint(2, 1);
ConnectPoint cp22 = createConnectPoint(2, 2);
ConnectPoint cp31 = createConnectPoint(3, 1);
ConnectPoint cp32 = createConnectPoint(3, 2);
ConnectPoint cp41 = createConnectPoint(4, 1);
ConnectPoint cp42 = createConnectPoint(4, 2);
ConnectPoint cp51 = createConnectPoint(5, 1);
ConnectPoint cp52 = createConnectPoint(5, 2);
ConnectPoint cp61 = createConnectPoint(6, 1);
ConnectPoint cp62 = createConnectPoint(6, 2);
ConnectPoint cp71 = createConnectPoint(7, 1);
Link link1 = createLink(cp12, cp21);
Link link2 = createLink(cp22, cp31);
Link link3 = createLink(cp32, cp41);
Link link4 = createLink(cp42, cp51);
Link link5 = createLink(cp52, cp61);
Link link6 = createLink(cp62, cp71);
List<Link> links = Stream.of(link1, link2, link3, link4, link5, link6).collect(Collectors.toList());
// Mocks 2 intents to create OduCtl connectivity
OpticalConnectivityIntent connIntent1 = createConnectivityIntent(cp21, cp32);
PacketLinkRealizedByOptical oduLink1 = PacketLinkRealizedByOptical.create(cp12, cp41, connIntent1);
OpticalConnectivityIntent connIntent2 = createConnectivityIntent(cp51, cp62);
PacketLinkRealizedByOptical oduLink2 = PacketLinkRealizedByOptical.create(cp42, cp71, connIntent2);
Set<PacketLinkRealizedByOptical> plinks = ImmutableSet.of(oduLink1, oduLink2);
Bandwidth bandwidth = Bandwidth.bps(100);
Duration latency = Duration.ofMillis(10);
OpticalConnectivityId cid = OpticalConnectivityId.of(1L);
OpticalConnectivity oc1 = new OpticalConnectivity(cid, links, bandwidth, latency, plinks, Collections.emptySet());
assertTrue(oc1.isAllRealizingLinkNotEstablished());
assertFalse(oc1.isAllRealizingLinkEstablished());
// Sets link realized by connIntent1 to be established
OpticalConnectivity oc2 = oc1.setLinkEstablished(cp12, cp41, true);
assertFalse(oc2.isAllRealizingLinkNotEstablished());
assertFalse(oc2.isAllRealizingLinkEstablished());
// Sets link realized by connIntent2 to be established
OpticalConnectivity oc3 = oc2.setLinkEstablished(cp42, cp71, true);
assertFalse(oc3.isAllRealizingLinkNotEstablished());
assertTrue(oc3.isAllRealizingLinkEstablished());
}
use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.
the class OpticalConnectivityTest method testCreate.
/**
* Checks the construction of OpticalConnectivity object.
*/
@Test
public void testCreate() {
Bandwidth bandwidth = Bandwidth.bps(100);
Duration latency = Duration.ofMillis(10);
// Mock 3-nodes linear topology
ConnectPoint cp12 = createConnectPoint(1, 2);
ConnectPoint cp21 = createConnectPoint(2, 1);
ConnectPoint cp22 = createConnectPoint(2, 2);
ConnectPoint cp31 = createConnectPoint(3, 1);
Link link1 = createLink(cp12, cp21);
Link link2 = createLink(cp22, cp31);
List<Link> links = Stream.of(link1, link2).collect(Collectors.toList());
OpticalConnectivityId cid = OpticalConnectivityId.of(1L);
OpticalConnectivity oc = new OpticalConnectivity(cid, links, bandwidth, latency, Collections.emptySet(), Collections.emptySet());
assertNotNull(oc);
assertEquals(oc.id(), cid);
assertEquals(oc.links(), links);
assertEquals(oc.bandwidth(), bandwidth);
assertEquals(oc.latency(), latency);
}
Aggregations