• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java DatapathId类的典型用法和代码示例

java 8次浏览

本文整理汇总了Java中org.projectfloodlight.openflow.types.DatapathId的典型用法代码示例。如果您正苦于以下问题:Java DatapathId类的具体用法?Java DatapathId怎么用?Java DatapathId使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

DatapathId类属于org.projectfloodlight.openflow.types包,在下文中一共展示了DatapathId类的38个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testDeleteLinkToSelf

点赞 3

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Test
public void testDeleteLinkToSelf() throws Exception {
    LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager();

    Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(1L), OFPort.of(3), U64.ZERO);
    NodePortTuple srcNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(2));
    NodePortTuple dstNpt = new NodePortTuple(DatapathId.of(2L), OFPort.of(3));

    LinkInfo info = new LinkInfo(new Date(),
    		new Date(), null);
    linkDiscovery.addOrUpdateLink(lt, info);
    linkDiscovery.deleteLinks(Collections.singletonList(lt), "Test to self");

    // check invariants hold
    assertNull(linkDiscovery.switchLinks.get(lt.getSrc()));
    assertNull(linkDiscovery.switchLinks.get(lt.getDst()));
    assertNull(linkDiscovery.portLinks.get(srcNpt));
    assertNull(linkDiscovery.portLinks.get(dstNpt));
    assertTrue(linkDiscovery.links.isEmpty());
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:21,
代码来源:LinkDiscoveryManagerTest.java

示例2: removeSwitch

点赞 3

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
public void removeSwitch(DatapathId sid) {
	// Delete all the links in the switch, switch and all
	// associated data should be deleted.
	if (switchPorts.containsKey(sid) == false) return;

	// Check if any tunnel ports need to be removed.
	for(NodePortTuple npt: tunnelPorts) {
		if (npt.getNodeId() == sid) {
			removeTunnelPort(npt.getNodeId(), npt.getPortId());
		}
	}

	Set<Link> linksToRemove = new HashSet<Link>();
	for(OFPort p: switchPorts.get(sid)) {
		NodePortTuple n1 = new NodePortTuple(sid, p);
		linksToRemove.addAll(switchPortLinks.get(n1));
	}

	if (linksToRemove.isEmpty()) return;

	for(Link link: linksToRemove) {
		removeLink(link);
	}
}
 

开发者ID:nsg-ethz,
项目名称:iTAP-controller,
代码行数:25,
代码来源:TopologyManager.java

示例3: SwitchUpdate

点赞 3

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
public SwitchUpdate(DatapathId swId,
		SwitchUpdateType switchUpdateType,
		OFPortDesc port,
		PortChangeType changeType) {
	if (switchUpdateType == SwitchUpdateType.PORTCHANGED) {
		if (port == null) {
			throw new NullPointerException("Port must not be null " +
					"for PORTCHANGED updates");
		}
		if (changeType == null) {
			throw new NullPointerException("ChangeType must not be " +
					"null for PORTCHANGED updates");
		}
	} else {
		if (port != null || changeType != null) {
			throw new IllegalArgumentException("port and changeType " +
					"must be null for " + switchUpdateType +
					" updates");
		}
	}
	this.swId = swId;
	this.switchUpdateType = switchUpdateType;
	this.port = port;
	this.changeType = changeType;
}
 

开发者ID:nsg-ethz,
项目名称:iTAP-controller,
代码行数:26,
代码来源:OFSwitchManager.java

示例4: init

点赞 3

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Override
public void init(FloodlightModuleContext context)
		throws FloodlightModuleException {
	linkDiscoveryService = context.getServiceImpl(ILinkDiscoveryService.class);
	threadPoolService = context.getServiceImpl(IThreadPoolService.class);
	floodlightProviderService = context.getServiceImpl(IFloodlightProviderService.class);
	switchService = context.getServiceImpl(IOFSwitchService.class);
	restApiService = context.getServiceImpl(IRestApiService.class);
	debugCounterService = context.getServiceImpl(IDebugCounterService.class);
	debugEventService = context.getServiceImpl(IDebugEventService.class);

	switchPorts = new HashMap<DatapathId, Set<OFPort>>();
	switchPortLinks = new HashMap<NodePortTuple, Set<Link>>();
	directLinks = new HashMap<NodePortTuple, Set<Link>>();
	portBroadcastDomainLinks = new HashMap<NodePortTuple, Set<Link>>();
	tunnelPorts = new HashSet<NodePortTuple>();
	topologyAware = new ArrayList<ITopologyListener>();
	ldUpdates = new LinkedBlockingQueue<LDUpdate>();
	haListener = new HAListenerDelegate();
	registerTopologyDebugCounters();
	registerTopologyDebugEvents();
}
 

开发者ID:nsg-ethz,
项目名称:iTAP-controller,
代码行数:23,
代码来源:TopologyManager.java

示例5: testAddOrUpdateLink

点赞 3

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Test
public void testAddOrUpdateLink() throws Exception {
    LinkDiscoveryManager linkDiscovery = getLinkDiscoveryManager();
    U64 latency = U64.of(100);
    Link lt = new Link(DatapathId.of(1L), OFPort.of(2), DatapathId.of(2L), OFPort.of(1), latency);
    LinkInfo info = new LinkInfo(new Date(),
                                 new Date(), null);
    linkDiscovery.addOrUpdateLink(lt, info);

    NodePortTuple srcNpt = new NodePortTuple(DatapathId.of(1L), OFPort.of(2));
    NodePortTuple dstNpt = new NodePortTuple(DatapathId.of(2L), OFPort.of(1));

    // check invariants hold
    assertNotNull(linkDiscovery.switchLinks.get(lt.getSrc()));
    assertTrue(linkDiscovery.switchLinks.get(lt.getSrc()).contains(lt));
    assertNotNull(linkDiscovery.getPortLinks().get(srcNpt));
    assertTrue(linkDiscovery.getPortLinks().get(srcNpt).contains(lt));
    assertNotNull(linkDiscovery.portLinks.get(dstNpt));
    assertTrue(linkDiscovery.portLinks.get(dstNpt).contains(lt));
    assertTrue(linkDiscovery.links.containsKey(lt));
    assertTrue(linkDiscovery.switchLinks.get(lt.getSrc()).iterator().next().getLatency().equals(latency));
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:23,
代码来源:LinkDiscoveryManagerTest.java

示例6: installVerificationRule

点赞 3

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
/**
 * Installs the verification rule
 *
 * @param dpid        datapathId of switch
 * @param isBroadcast if broadcast then set a generic match; else specific to switch Id
 * @return true if the command is accepted to be sent to switch, false otherwise - switch is disconnected or in
 * SLAVE mode
 */
private boolean installVerificationRule(final DatapathId dpid, final boolean isBroadcast) {
    IOFSwitch sw = ofSwitchService.getSwitch(dpid);

    Match match = matchVerification(sw, isBroadcast);
    ArrayList<OFAction> actionList = new ArrayList<>(2);
    actionList.add(actionSendToController(sw));
    actionList.add(actionSetDstMac(sw, dpidToMac(sw)));
    OFInstructionApplyActions instructionApplyActions = sw.getOFFactory().instructions()
            .applyActions(actionList).createBuilder().build();
    final long cookie = isBroadcast ? 0x8000000000000002L : 0x8000000000000003L;
    OFFlowMod flowMod = buildFlowMod(sw, match, null, instructionApplyActions,
            cookie, FlowModUtils.PRIORITY_VERY_HIGH);
    String flowname = (isBroadcast) ? "Broadcast" : "Unicast";
    flowname += "--VerificationFlow--" + dpid.toString();
    return pushFlow(flowname, dpid, flowMod);
}
 

开发者ID:telstra,
项目名称:open-kilda,
代码行数:25,
代码来源:SwitchManager.java

示例7: switchActivated

点赞 3

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void switchActivated(final DatapathId switchId) {
    final IOFSwitch sw = switchService.getSwitch(switchId);

    Message message = buildSwitchMessage(sw, SwitchState.ACTIVATED);
    kafkaProducer.postMessage(TOPO_EVENT_TOPIC, message);

    ImmutablePair<Long, Boolean> metersDeleted;
    metersDeleted = switchManager.deleteMeter(switchId, ALL_VAL);
    if (!metersDeleted.getRight()) {
        logger.error("Could not delete meters from switch={} xid={}", switchId, metersDeleted.getLeft());
    }

    boolean defaultRulesInstalled = switchManager.installDefaultRules(switchId);
    if (!defaultRulesInstalled) {
        logger.error("Could not install default rules on switch={}", switchId);
    }

    if (sw.getEnabledPortNumbers() != null) {
        for (OFPort p : sw.getEnabledPortNumbers()) {
            kafkaProducer.postMessage(TOPO_EVENT_TOPIC, buildPortMessage(sw.getId(), p, PortChangeType.UP));
        }
    }
}
 

开发者ID:telstra,
项目名称:open-kilda,
代码行数:28,
代码来源:SwitchEventCollector.java

示例8: isAttachmentPointPort

点赞 3

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Override
public boolean isAttachmentPointPort(DatapathId switchid, OFPort port, boolean tunnelEnabled) {

	// If the switch port is 'tun-bsn' port, it is not
	// an attachment point port, irrespective of whether
	// a link is found through it or not.
	if (linkDiscoveryService.isTunnelPort(switchid, port))
		return false;

	TopologyInstance ti = getCurrentInstance(tunnelEnabled);

	// if the port is not attachment point port according to
	// topology instance, then return false
	if (ti.isAttachmentPointPort(switchid, port) == false)
		return false;

	// Check whether the port is a physical port. We should not learn
	// attachment points on "special" ports.
	if ((port.getShortPortNumber() & 0xff00) == 0xff00 && port.getShortPortNumber() != (short)0xfffe) return false;

	// Make sure that the port is enabled.
	IOFSwitch sw = switchService.getActiveSwitch(switchid);
	if (sw == null) return false;
	return (sw.portEnabled(port));
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:26,
代码来源:TopologyManager.java

示例9: getEntityKeys

点赞 3

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
private EnumSet<DeviceField> getEntityKeys(MacAddress macAddress,
	 VlanVid vlan,
	 IPv4Address ipv4Address,
	 DatapathId switchDPID,
	 OFPort switchPort) {
 // FIXME: vlan==null is a valid search. Need to handle this
 // case correctly. Note that the code will still work correctly.
 // But we might do a full device search instead of using an index.
 EnumSet<DeviceField> keys = EnumSet.noneOf(DeviceField.class);
 if (macAddress != null) keys.add(DeviceField.MAC);
 if (vlan != null) keys.add(DeviceField.VLAN);
 if (ipv4Address != null) keys.add(DeviceField.IPV4);
 if (switchDPID != null) keys.add(DeviceField.SWITCH);
 if (switchPort != null) keys.add(DeviceField.PORT);
 return keys;
}
 

开发者ID:nsg-ethz,
项目名称:iTAP-controller,
代码行数:17,
代码来源:DeviceManagerImpl.java

示例10: calculateBroadcastPortMap

点赞 3

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
protected void calculateBroadcastPortMap(){
this.broadcastPortMap.clear();

for (DatapathId sw : this.switches) {
	for (OFPort p : this.allPorts.get(sw)){
		NodePortTuple npt = new NodePortTuple(sw, p);
		if (isEdge(sw, p) || broadcastNodePorts.contains(npt)) { 
			if (broadcastPortMap.containsKey(sw)) {
              		broadcastPortMap.get(sw).add(p);
              	} else {
              		broadcastPortMap.put(sw, new HashSet<OFPort>(Arrays.asList(p)));
              	}
		}      		
	}
}
  }
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:17,
代码来源:TopologyInstance.java

示例11: getSourceEntityFromPacket

点赞 3

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
/**
 * Parse an entity from an {@link Ethernet} packet.
 * @param eth the packet to parse
 * @param sw the switch on which the packet arrived
 * @param pi the original packetin
 * @return the entity from the packet
 */
protected Entity getSourceEntityFromPacket(Ethernet eth, DatapathId swdpid, OFPort port) {
	MacAddress dlAddr = eth.getSourceMACAddress();

	// Ignore broadcast/multicast source
	if (dlAddr.isBroadcast() || dlAddr.isMulticast())
		return null;
	// Ignore 0 source mac
	if (dlAddr.getLong() == 0)
		return null;

	VlanVid vlan = VlanVid.ofVlan(eth.getVlanID());
	IPv4Address ipv4Src = getSrcIPv4AddrFromARP(eth, dlAddr);
	IPv6Address ipv6Src = ipv4Src.equals(IPv4Address.NONE) ? getSrcIPv6Addr(eth) : IPv6Address.NONE;
	return new Entity(dlAddr,
			vlan,
			ipv4Src,
			ipv6Src,
			swdpid,
			port,
			new Date());
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:29,
代码来源:DeviceManagerImpl.java

示例12: mockTopologyForPacketInTests

点赞 3

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
private static void
mockTopologyForPacketInTests(ITopologyService mockTopology) {
	expect(mockTopology.isAttachmentPointPort(DatapathId.of(anyLong()),
			OFPort.of(anyShort()))).
			andReturn(true).
			anyTimes();
	expect(mockTopology.isConsistent(DatapathId.of(EasyMock.anyLong()),
			OFPort.of(EasyMock.anyShort()),
			DatapathId.of(EasyMock.anyLong()),
			OFPort.of(EasyMock.anyShort()))).andReturn(false).
			anyTimes();
	expect(mockTopology.isBroadcastDomainPort(DatapathId.of(EasyMock.anyLong()),
			OFPort.of(EasyMock.anyShort())))
			.andReturn(false)
			.anyTimes();
	expect(mockTopology.getL2DomainId(DatapathId.of(anyLong()))).andReturn(DatapathId.of(1L)).anyTimes();
	expect(mockTopology.isInSameBroadcastDomain(DatapathId.of(anyLong()),
			OFPort.of(anyShort()),
			DatapathId.of(anyLong()),
			OFPort.of(anyShort())))
			.andReturn(false).anyTimes();

}
 

开发者ID:nsg-ethz,
项目名称:iTAP-controller,
代码行数:24,
代码来源:DeviceManagerImplTest.java

示例13: writeFlowModToSwitch

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
/**
 * Writes an OFFlowMod to a switch. It checks to make sure the switch
 * exists before it sends
 * @param dpid The data  to write the flow mod to
 * @param flowMod The OFFlowMod to write
 */
private void writeFlowModToSwitch(DatapathId dpid, OFFlowMod flowMod) {
	IOFSwitch ofSwitch = switchService.getSwitch(dpid);
	if (ofSwitch == null) {
		if (log.isDebugEnabled()) {
			log.debug("Not deleting key {} :: switch {} not connected", dpid.toString());
		}
		return;
	}
	writeFlowModToSwitch(ofSwitch, flowMod);
}
 

开发者ID:nsg-ethz,
项目名称:iTAP-controller,
代码行数:17,
代码来源:StaticFlowEntryPusher.java

示例14: writeOFMessagesToSwitch

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
/**
 * Writes a list of OFMessages to a switch
 * @param dpid The datapath ID of the switch to write to
 * @param messages The list of OFMessages to write.
 */
private void writeOFMessagesToSwitch(DatapathId dpid, List<OFMessage> messages) {
	IOFSwitch ofswitch = switchService.getSwitch(dpid);
	if (ofswitch != null) {  // is the switch connected
		if (log.isDebugEnabled()) {
			log.debug("Sending {} new entries to {}", messages.size(), dpid);
		}
		ofswitch.write(messages);
	}
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:15,
代码来源:StaticFlowEntryPusher.java

示例15: RemoveFromSuppressLLDPs

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
/**
 * Remove a switch port from the suppressed LLDP list. Discover links on
 * that switchport.
 */
@Override
public void RemoveFromSuppressLLDPs(DatapathId sw, OFPort port) {
	NodePortTuple npt = new NodePortTuple(sw, port);
	this.suppressLinkDiscovery.remove(npt);
	discover(npt);
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:11,
代码来源:LinkDiscoveryManager.java

示例16: addFlow

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Override
public void addFlow(String name, OFFlowMod fm, DatapathId swDpid) {
	try {
		Map<String, Object> fmMap = StaticFlowEntries.flowModToStorageEntry(fm, swDpid.toString(), name);
		storageSourceService.insertRowAsync(TABLE_NAME, fmMap);
	} catch (Exception e) {
		log.error("Error! Check the fields specified for the flow.Make sure IPv4 fields are not mixed with IPv6 fields or all "
				+ "mandatory fields are specified. ");
	}
}
 

开发者ID:nsg-ethz,
项目名称:iTAP-controller,
代码行数:11,
代码来源:StaticFlowEntryPusher.java

示例17: findDevice

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Override
public IDevice findDevice(@Nonnull MacAddress macAddress, VlanVid vlan,
		@Nonnull IPv4Address ipv4Address, @Nonnull IPv6Address ipv6Address,
		@Nonnull DatapathId switchDPID, @Nonnull OFPort switchPort)
				throws IllegalArgumentException {
	if (macAddress == null) {
   		throw new IllegalArgumentException("MAC address cannot be null. Try MacAddress.NONE if intention is 'no MAC'");
   	}
   	if (ipv4Address == null) {
   		throw new IllegalArgumentException("IPv4 address cannot be null. Try IPv4Address.NONE if intention is 'no IPv4'");
   	}
   	if (ipv6Address == null) {
   		throw new IllegalArgumentException("IPv6 address cannot be null. Try IPv6Address.NONE if intention is 'no IPv6'");
   	}
   	if (vlan == null) {
   		throw new IllegalArgumentException("VLAN cannot be null. Try VlanVid.ZERO if intention is 'no VLAN / untagged'");
   	}
   	if (switchDPID == null) {
   		throw new IllegalArgumentException("Switch DPID cannot be null. Try DatapathId.NONE if intention is 'no DPID'");
   	}
   	if (switchPort == null) {
   		throw new IllegalArgumentException("Switch port cannot be null. Try OFPort.ZERO if intention is 'no port'");
   	}
	
	Entity e = new Entity(macAddress, vlan, 
			ipv4Address, ipv6Address, 
			switchDPID, switchPort, Entity.NO_DATE);
	
	/*
	 * allKeyFieldsPresent() will check if the entity key fields (e.g. MAC and VLAN)
	 * have non-"zero" values i.e. are not set to e.g. MacAddress.NONE and VlanVid.ZERO
	 */
	if (!allKeyFieldsPresent(e, entityClassifier.getKeyFields())) {
		throw new IllegalArgumentException("Not all key fields specified."
				+ " Required fields: " + entityClassifier.getKeyFields());
	}
	return findDeviceByEntity(e);
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:39,
代码来源:DeviceManagerImpl.java

示例18: switchAdded

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Override
public void switchAdded(DatapathId dpid) {
	/* Insert static flows on all ports of the switch to redirect
	 * DHCP client --> DHCP DHCPServer traffic to the controller.
	 * DHCP client's operate on UDP port 67
	 */
	IOFSwitch sw = switchService.getSwitch(dpid);
	
	//fix concurrency flaw
	if (sw == null){
		return;
	}
	
	OFFlowAdd.Builder flow = sw.getOFFactory().buildFlowAdd();
	Match.Builder match = sw.getOFFactory().buildMatch();
	ArrayList<OFAction> actionList = new ArrayList<OFAction>();
	OFActionOutput.Builder action = sw.getOFFactory().actions().buildOutput();
	for (OFPortDesc port : sw.getPorts()) {
		match.setExact(MatchField.IN_PORT, port.getPortNo());
		match.setExact(MatchField.ETH_TYPE, EthType.IPv4);
		match.setExact(MatchField.IP_PROTO, IpProtocol.UDP);
		match.setExact(MatchField.UDP_SRC, UDP.DHCP_CLIENT_PORT);
		action.setMaxLen(0xffFFffFF);
		action.setPort(OFPort.CONTROLLER);
		actionList.add(action.build());
		
		flow.setBufferId(OFBufferId.NO_BUFFER);
		flow.setHardTimeout(0);
		flow.setIdleTimeout(0);
		flow.setOutPort(OFPort.CONTROLLER);
		flow.setActions(actionList);
		flow.setMatch(match.build());
		flow.setPriority(32767);
		sfp.addFlow("dhcp-port---" + port.getPortNo().getPortNumber() + "---(" + port.getName() + ")", flow.build(), sw.getId());
	}		
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:37,
代码来源:DHCPSwitchFlowSetter.java

示例19: AddToSuppressLLDPs

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
/**
 * Add a switch port to the suppressed LLDP list. Remove any known links on
 * the switch port.
 */
@Override
public void AddToSuppressLLDPs(DatapathId sw, OFPort port) {
	NodePortTuple npt = new NodePortTuple(sw, port);
	this.suppressLinkDiscovery.add(npt);
	deleteLinksOnPort(npt, "LLDP suppressed.");
}
 

开发者ID:nsg-ethz,
项目名称:iTAP-controller,
代码行数:11,
代码来源:LinkDiscoveryManager.java

示例20: verifyClusters

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
protected void verifyClusters(int[][] clusters, boolean tunnelsEnabled) {
    List<DatapathId> verifiedSwitches = new ArrayList<DatapathId>();

    // Make sure the expected cluster arrays are sorted so we can
    // use binarySearch to test for membership
    for (int i = 0; i < clusters.length; i++)
        Arrays.sort(clusters[i]);

    TopologyInstance ti = 
            topologyManager.getCurrentInstance(tunnelsEnabled);
    Set<DatapathId> switches = ti.getSwitches();

    for (DatapathId sw: switches) {
        if (!verifiedSwitches.contains(sw)) {

            int[] expectedCluster = null;

            for (int j = 0; j < clusters.length; j++) {
                if (Arrays.binarySearch(clusters[j], (int)sw.getLong()) >= 0) {
                    expectedCluster = clusters[j];
                    break;
                }
            }
            if (expectedCluster != null) {
                Set<DatapathId> cluster = ti.getSwitchesInOpenflowDomain(sw);
                assertEquals(expectedCluster.length, cluster.size());
                for (DatapathId sw2: cluster) {
                    assertTrue(Arrays.binarySearch(expectedCluster, (int)sw2.getLong()) >= 0);
                    verifiedSwitches.add(sw2);
                }
            }
        }
    }
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:35,
代码来源:TopologyInstanceTest.java

示例21: testForwardNoPath

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Test
public void testForwardNoPath() throws Exception {
	learnDevices(DestDeviceToLearn.NONE);

	// Set no destination attachment point or route
	// expect no Flow-mod but expect the packet to be flooded

	Capture<OFMessage> wc1 = new Capture<OFMessage>(CaptureType.ALL);
	
	Set<OFPort> bcastPorts = new HashSet<OFPort>();
	bcastPorts.add(OFPort.of(10));

	// Reset mocks, trigger the packet in, and validate results
	reset(topology);
	expect(topology.getSwitchBroadcastPorts(DatapathId.of(1L))).andReturn(bcastPorts).once();
	expect(topology.isAttachmentPointPort(DatapathId.of(anyLong()),
			OFPort.of(anyShort())))
			.andReturn(true)
			.anyTimes();
	expect(sw1.hasAttribute(IOFSwitch.PROP_SUPPORTS_OFPP_FLOOD)).andReturn(true).anyTimes();
	expect(sw1.write(capture(wc1))).andReturn(true).once();
	replay(sw1, sw2, routingEngine, topology);
	forwarding.receive(sw1, this.packetIn, cntx);
	verify(sw1, sw2, routingEngine);

	assertTrue(wc1.hasCaptured());
	assertTrue(OFMessageUtils.equalsIgnoreXid(wc1.getValue(), packetOutFlooded));
	
	removeDeviceFromContext();
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:31,
代码来源:ForwardingTest.java

示例22: isConsistent

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Override
public boolean isConsistent(DatapathId oldSw, OFPort oldPort,
		DatapathId newSw, OFPort newPort,
		boolean tunnelEnabled) {
	TopologyInstance ti = getCurrentInstance(tunnelEnabled);
	return ti.isConsistent(oldSw, oldPort, newSw, newPort);
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:8,
代码来源:TopologyManager.java

示例23: getIncomingSwitchPort

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Override
public NodePortTuple getIncomingSwitchPort(DatapathId src, OFPort srcPort,
		DatapathId dst, OFPort dstPort,
		boolean tunnelEnabled) {
	TopologyInstance ti = getCurrentInstance(tunnelEnabled);
	return ti.getIncomingSwitchPort(src, srcPort,
			dst, dstPort);
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:9,
代码来源:TopologyManager.java

示例24: doDiscoverIslCommand

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
private void doDiscoverIslCommand(CommandData data) {
    DiscoverIslCommandData command = (DiscoverIslCommandData) data;
    logger.debug("sending discover ISL to {}", command);

    String switchId = command.getSwitchId();
    boolean result = pathVerificationService.sendDiscoveryMessage(
            DatapathId.of(switchId), OFPort.of(command.getPortNo()));

    if (result) {
        logger.debug("packet_out was sent to {}", switchId);
    } else {
        logger.warn("packet_out was not sent to {}", switchId);
    }
}
 

开发者ID:telstra,
项目名称:open-kilda,
代码行数:15,
代码来源:KafkaMessageCollector.java

示例25: setUp

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Before
public void setUp() throws FloodlightModuleException {
    ofSwitchService = createMock(IOFSwitchService.class);
    restApiService = createMock(IRestApiService.class);
    iofSwitch = createMock(IOFSwitch.class);
    switchDescription = createMock(SwitchDescription.class);
    dpid = createMock(DatapathId.class);

    context.addService(IRestApiService.class, restApiService);
    context.addService(IOFSwitchService.class, ofSwitchService);

    switchManager = new SwitchManager();
    switchManager.init(context);
}
 

开发者ID:telstra,
项目名称:open-kilda,
代码行数:15,
代码来源:SwitchManagerTest.java

示例26: switchAdded

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Override
public synchronized void switchAdded(IOFSwitchBackend sw) {
	DatapathId dpid = sw.getId();
	IOFSwitchBackend oldSw = this.switches.put(dpid, sw);
	// Update event history
	evSwitch.newEventWithFlush(new SwitchEvent(dpid, "connected"));

	if (oldSw == sw)  {
		// Note == for object equality, not .equals for value
		counters.errorActivatedSwitchNotPresent.increment();
		log.error("Switch {} added twice?", sw);
		return;
	} else if (oldSw != null) {
		// This happens either when we have switches with duplicate
		// DPIDs or when a switch reconnects before we saw the
		// disconnect
		counters.switchWithSameDpidActivated.increment();
		log.warn("New switch added {} for already-added switch {}", sw, oldSw);
		// We need to disconnect and remove the old switch
		// TODO: we notify switch listeners that the switch has been
		// removed and then we notify them that the new one has been
		// added. One could argue that a switchChanged notification
		// might be more appropriate in this case....
		oldSw.cancelAllPendingRequests();
		addUpdateToQueue(new SwitchUpdate(dpid, SwitchUpdateType.REMOVED));
		oldSw.disconnect();
	}

}
 

开发者ID:nsg-ethz,
项目名称:iTAP-controller,
代码行数:30,
代码来源:OFSwitchManager.java

示例27: classifyEntity

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Override
public IEntityClass classifyEntity(Entity entity) {
    if (entity.getSwitchDPID() == null) {
        throw new IllegalArgumentException("Not all key fields specified."
                + " Required fields: " + getKeyFields());
    } else if (entity.getSwitchDPID().equals(DatapathId.of(1))) {
        return testECMac1;
    } else if (entity.getSwitchDPID().equals(DatapathId.of(2))) {
        return testECMac2;
    } else if (entity.getSwitchDPID().equals(DatapathId.of(-1))) {
        return null;
    }
    return DefaultEntityClassifier.entityClass;
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:15,
代码来源:MockEntityClassifierMac.java

示例28: getAllowedIncomingBroadcastPort

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Override
public NodePortTuple
getAllowedIncomingBroadcastPort(DatapathId src, OFPort srcPort,
		boolean tunnelEnabled) {
	TopologyInstance ti = getCurrentInstance(tunnelEnabled);
	return ti.getAllowedIncomingBroadcastPort(src,srcPort);
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:8,
代码来源:TopologyManager.java

示例29: getFlowAlias

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
private FlowAlias getFlowAlias(DatapathId dpid, long key){
	HashMap<Long, FlowAlias> faList = cMap.get(dpid);
	
	if (faList != null){
		return faList.get(key);
	}
	return null;
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:9,
代码来源:SecurityKernel.java

示例30: testDefaultGateway

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Test
public void testDefaultGateway() {
    testAddHost();
    IOFMessageListener listener = getVirtualNetworkListener();
    cntx = new FloodlightContext();
    IFloodlightProviderService.bcStore.put(cntx,
                       IFloodlightProviderService.CONTEXT_PI_PAYLOAD,
                           (Ethernet)mac1ToGwPacketIntestPacket);
    deviceService.learnEntity(((Ethernet)mac1ToGwPacketIntestPacket).getDestinationMACAddress(),
    		VlanVid.ZERO, IPv4Address.of(gw1), IPv6Address.NONE, DatapathId.NONE, OFPort.ZERO);
    Command ret = listener.receive(sw1, mac1ToGwPacketIn, cntx);
    assertTrue(ret == Command.CONTINUE);
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:14,
代码来源:VirtualNetworkFilterTest.java

示例31: handlePortDown

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
private void handlePortDown(DatapathId switchId, OFPort portNumber) {
	NodePortTuple npt = new NodePortTuple(switchId, portNumber);
	deleteLinksOnPort(npt, "Port Status Changed");
	LDUpdate update = new LDUpdate(switchId, portNumber,
			UpdateOperation.PORT_DOWN);
	updates.add(update);
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:8,
代码来源:LinkDiscoveryManager.java

示例32: isIncomingDiscoveryAllowed

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
/**
 * Check if incoming discovery messages are enabled or not.
 * @param sw
 * @param port
 * @param isStandard
 * @return
 */
protected boolean isIncomingDiscoveryAllowed(DatapathId sw, OFPort port,
		boolean isStandard) {

	if (isLinkDiscoverySuppressed(sw, port)) {
		/* Do not process LLDPs from this port as suppressLLDP is set */
		return false;
	}

	IOFSwitch iofSwitch = switchService.getSwitch(sw);
	if (iofSwitch == null) {
		return false;
	}

	if (port == OFPort.LOCAL) return false;

	OFPortDesc ofpPort = iofSwitch.getPort(port);
	if (ofpPort == null) {
		if (log.isTraceEnabled()) {
			log.trace("Null physical port. sw={}, port={}",
					sw.toString(), port.getPortNumber());
		}
		return false;
	}

	return true;
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:34,
代码来源:LinkDiscoveryManager.java

示例33: addSwitchEvent

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Override
public void addSwitchEvent(DatapathId dpid, String reason, boolean flushNow) {
	if (flushNow)
		evSwitch.newEventWithFlush(new SwitchEvent(dpid, reason));
	else
		evSwitch.newEventNoFlush(new SwitchEvent(dpid, reason));
}
 

开发者ID:nsg-ethz,
项目名称:iTAP-controller,
代码行数:8,
代码来源:OFSwitchManager.java

示例34: setUp

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    factory = OFFactories.getFactory(OFVersion.OF_13);
    switchId = DatapathId.of(1);
    timer = new HashedWheelTimer();
    channel = EasyMock.createMock(Channel.class);        
    IDebugCounterService debugCounterService = new DebugCounterServiceImpl();
    debugCounterService.registerModule(OFConnectionCounters.COUNTER_MODULE);
    conn = new OFConnection(switchId, factory, channel, OFAuxId.MAIN,
                            debugCounterService, timer);
    eventLoop = new TestEventLoop();
    
    expect(channel.eventLoop()).andReturn(eventLoop).anyTimes();
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:15,
代码来源:OFConnectionTest.java

示例35: getSwitchRepresentations

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Override
public List<SwitchRepresentation> getSwitchRepresentations() {
    List<SwitchRepresentation> representations = new ArrayList<SwitchRepresentation>();

    for(DatapathId dpid : this.switches.keySet()) {
        SwitchRepresentation representation = getSwitchRepresentation(dpid);
        if(representation != null) {
            representations.add(representation);
        }
    }
    return representations;
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:13,
代码来源:MockSwitchManager.java

示例36: isIncomingBroadcastAllowed

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Override
public boolean isIncomingBroadcastAllowed(DatapathId sw, OFPort portId) {
	return isIncomingBroadcastAllowed(sw, portId, true);
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:5,
代码来源:TopologyManager.java

示例37: BroadcastTree

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
public BroadcastTree(HashMap<DatapathId, Link> links, HashMap<DatapathId, Integer> costs) {
    this.links = links;
    this.costs = costs;
}
 

开发者ID:nsg-ethz,
项目名称:iTAP-controller,
代码行数:5,
代码来源:BroadcastTree.java

示例38: getSwitch

点赞 2

import org.projectfloodlight.openflow.types.DatapathId; //导入依赖的package包/类
@Override
public IOFSwitch getSwitch(DatapathId dpid) {
	return this.switches.get(dpid);
}
 

开发者ID:xuraylei,
项目名称:fresco_floodlight,
代码行数:5,
代码来源:OFSwitchManager.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)