本文整理汇总了Java中net.floodlightcontroller.routing.Link.getSrc方法的典型用法代码示例。如果您正苦于以下问题:Java Link.getSrc方法的具体用法?Java Link.getSrc怎么用?Java Link.getSrc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.floodlightcontroller.routing.Link
的用法示例。
在下文中一共展示了Link.getSrc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addLinkToStructure
import net.floodlightcontroller.routing.Link; //导入方法依赖的package包/类
/**
* Add the given link to the data structure. Returns true if a link was
* added.
* @param s
* @param l
* @return
*/
private boolean addLinkToStructure(Map<NodePortTuple,
Set<Link>> s, Link l) {
boolean result1 = false, result2 = false;
NodePortTuple n1 = new NodePortTuple(l.getSrc(), l.getSrcPort());
NodePortTuple n2 = new NodePortTuple(l.getDst(), l.getDstPort());
if (s.get(n1) == null) {
s.put(n1, new HashSet<Link>());
}
if (s.get(n2) == null) {
s.put(n2, new HashSet<Link>());
}
result1 = s.get(n1).add(l);
result2 = s.get(n2).add(l);
return (result1 || result2);
}
示例2: removeLinkFromStructure
import net.floodlightcontroller.routing.Link; //导入方法依赖的package包/类
/**
* Delete the given link from the data strucure. Returns true if the
* link was deleted.
* @param s
* @param l
* @return
*/
private boolean removeLinkFromStructure(Map<NodePortTuple,
Set<Link>> s, Link l) {
boolean result1 = false, result2 = false;
NodePortTuple n1 = new NodePortTuple(l.getSrc(), l.getSrcPort());
NodePortTuple n2 = new NodePortTuple(l.getDst(), l.getDstPort());
if (s.get(n1) != null) {
result1 = s.get(n1).remove(l);
if (s.get(n1).isEmpty()) s.remove(n1);
}
if (s.get(n2) != null) {
result2 = s.get(n2).remove(l);
if (s.get(n2).isEmpty()) s.remove(n2);
}
return result1 || result2;
}
示例3: addLinkToStructure
import net.floodlightcontroller.routing.Link; //导入方法依赖的package包/类
/**
* Add the given link to the data structure.
* @param s
* @param l
*/
private void addLinkToStructure(Map<NodePortTuple, Set<Link>> s, Link l) {
NodePortTuple n1 = new NodePortTuple(l.getSrc(), l.getSrcPort());
NodePortTuple n2 = new NodePortTuple(l.getDst(), l.getDstPort());
if (s.get(n1) == null) {
s.put(n1, new HashSet<Link>());
}
if (s.get(n2) == null) {
s.put(n2, new HashSet<Link>());
}
/*
* Since we don't include latency in .equals(), we need
* to explicitly remove the existing link (if present).
* Otherwise, new latency values for existing links will
* never be accepted.
*/
s.get(n1).remove(l);
s.get(n2).remove(l);
s.get(n1).add(l);
s.get(n2).add(l);
}
示例4: LinkWithType
import net.floodlightcontroller.routing.Link; //导入方法依赖的package包/类
public LinkWithType(Link link,
LinkType type,
LinkDirection direction) {
this.srcSwDpid = link.getSrc();
this.srcPort = link.getSrcPort();
this.dstSwDpid = link.getDst();
this.dstPort = link.getDstPort();
this.type = type;
this.direction = direction;
}
示例5: removeLink
import net.floodlightcontroller.routing.Link; //导入方法依赖的package包/类
public void removeLink(Link link) {
linksUpdated = true;
dtLinksUpdated = removeLinkFromStructure(directLinks, link);
removeLinkFromStructure(portBroadcastDomainLinks, link);
removeLinkFromStructure(switchPortLinks, link);
NodePortTuple srcNpt =
new NodePortTuple(link.getSrc(), link.getSrcPort());
NodePortTuple dstNpt =
new NodePortTuple(link.getDst(), link.getDstPort());
// Remove switch ports if there are no links through those switch ports
if (switchPortLinks.get(srcNpt) == null) {
if (switchPorts.get(srcNpt.getNodeId()) != null)
switchPorts.get(srcNpt.getNodeId()).remove(srcNpt.getPortId());
}
if (switchPortLinks.get(dstNpt) == null) {
if (switchPorts.get(dstNpt.getNodeId()) != null)
switchPorts.get(dstNpt.getNodeId()).remove(dstNpt.getPortId());
}
// Remove the node if no ports are present
if (switchPorts.get(srcNpt.getNodeId())!=null &&
switchPorts.get(srcNpt.getNodeId()).isEmpty()) {
switchPorts.remove(srcNpt.getNodeId());
}
if (switchPorts.get(dstNpt.getNodeId())!=null &&
switchPorts.get(dstNpt.getNodeId()).isEmpty()) {
switchPorts.remove(dstNpt.getNodeId());
}
}
示例6: calculateAllBroadcastNodePorts
import net.floodlightcontroller.routing.Link; //导入方法依赖的package包/类
protected void calculateAllBroadcastNodePorts() {
if (this.destinationRootedFullTrees.size() > 0) {
this.finiteBroadcastTree = destinationRootedFullTrees.values().iterator().next();
Map<DatapathId, Link> links = finiteBroadcastTree.getLinks();
if (links == null) return;
for (DatapathId nodeId : links.keySet()) {
Link l = links.get(nodeId);
if (l == null) continue;
NodePortTuple npt1 = new NodePortTuple(l.getSrc(), l.getSrcPort());
NodePortTuple npt2 = new NodePortTuple(l.getDst(), l.getDstPort());
this.broadcastNodePorts.add(npt1);
this.broadcastNodePorts.add(npt2);
}
}
}
示例7: packetFromHost
import net.floodlightcontroller.routing.Link; //导入方法依赖的package包/类
/**
* checks if the packet arrived at a host-facing port
* @param sw
* @param pi
* @param cntx
* @return
*/
private boolean packetFromHost(IOFSwitch sw, OFPacketIn pi, FloodlightContext cntx) {
for (Link link : linkDiscoveryService.getSwitchLinks().get(sw.getId())) {
if ((link.getSrc() == sw.getId()) && (link.getSrcPort() == pi.getMatch().get(MatchField.IN_PORT))) { // link where the packet arrived
if (switchService.getActiveSwitch(link.getDst()) != null) // endpoint of link is another switch -> not a host
return false;
}
}
return true;
}
示例8: floodArpRequest
import net.floodlightcontroller.routing.Link; //导入方法依赖的package包/类
private void floodArpRequest(IOFSwitch sw, IPv4Address requestedAddress) {
IPacket arpRequest = new Ethernet()
.setSourceMACAddress("00:00:00:00:00:01")
.setDestinationMACAddress("ff:ff:ff:ff:ff:ff")
.setEtherType(EthType.ARP)
.setVlanID((short) 0)
.setPriorityCode((byte) 0)
.setPayload(
new ARP()
.setHardwareType(ARP.HW_TYPE_ETHERNET)
.setProtocolType(ARP.PROTO_TYPE_IP)
.setHardwareAddressLength((byte) 6)
.setProtocolAddressLength((byte) 4)
.setOpCode(ARP.OP_REQUEST)
.setSenderHardwareAddress(HexString.fromHexString("00:00:00:00:00:01"))
.setSenderProtocolAddress(IPv4.toIPv4AddressBytes("10.0.0.111"))
.setTargetHardwareAddress(HexString.fromHexString("00:00:00:00:00:00"))
.setTargetProtocolAddress(requestedAddress.getBytes()));
Set<OFPort> portsConnectedToSwitches = new HashSet<OFPort>();
for (Link link : linkDiscoveryService.getSwitchLinks().get(sw.getId())) {
if (link.getSrc() == sw.getId())
portsConnectedToSwitches.add(link.getSrcPort());
}
for (OFPortDesc port : sw.getPorts()) {
if (!portsConnectedToSwitches.contains(port.getPortNo())) {
pushPacket(arpRequest, sw, OFBufferId.NO_BUFFER, OFPort.ANY, port.getPortNo());
}
}
}
示例9: retrieve
import net.floodlightcontroller.routing.Link; //导入方法依赖的package包/类
@Get("json")
public Set<LinkWithType> retrieve() {
ILinkDiscoveryService ld = (ILinkDiscoveryService)getContext().getAttributes().
get(ILinkDiscoveryService.class.getCanonicalName());
Map<Link, LinkInfo> links = new HashMap<Link, LinkInfo>();
Set<LinkWithType> returnLinkSet = new HashSet<LinkWithType>();
if (ld != null) {
links.putAll(ld.getLinks());
for (Link link: links.keySet()) {
LinkInfo info = links.get(link);
LinkType type = ld.getLinkType(link, info);
if (type == LinkType.DIRECT_LINK || type == LinkType.TUNNEL) {
LinkWithType lwt;
DatapathId src = link.getSrc();
DatapathId dst = link.getDst();
OFPort srcPort = link.getSrcPort();
OFPort dstPort = link.getDstPort();
Link otherLink = new Link(dst, dstPort, src, srcPort, U64.ZERO /* not important in lookup */);
LinkInfo otherInfo = links.get(otherLink);
LinkType otherType = null;
if (otherInfo != null)
otherType = ld.getLinkType(otherLink, otherInfo);
if (otherType == LinkType.DIRECT_LINK ||
otherType == LinkType.TUNNEL) {
// This is a bi-direcitonal link.
// It is sufficient to add only one side of it.
if ((src.getLong() < dst.getLong()) || (src.getLong() == dst.getLong()
&& srcPort.getPortNumber() < dstPort.getPortNumber())) {
lwt = new LinkWithType(link,
type,
LinkDirection.BIDIRECTIONAL);
returnLinkSet.add(lwt);
}
} else {
// This is a unidirectional link.
lwt = new LinkWithType(link,
type,
LinkDirection.UNIDIRECTIONAL);
returnLinkSet.add(lwt);
}
}
}
}
return returnLinkSet;
}
示例10: retrieve
import net.floodlightcontroller.routing.Link; //导入方法依赖的package包/类
@Get("json")
public Set<LinkWithType> retrieve() {
ILinkDiscoveryService ld = (ILinkDiscoveryService)getContext().getAttributes().
get(ILinkDiscoveryService.class.getCanonicalName());
Map<Link, LinkInfo> links = new HashMap<Link, LinkInfo>();
Set<LinkWithType> returnLinkSet = new HashSet<LinkWithType>();
if (ld != null) {
links.putAll(ld.getLinks());
for (Link link: links.keySet()) {
LinkInfo info = links.get(link);
LinkType type = ld.getLinkType(link, info);
if (type == LinkType.MULTIHOP_LINK) {
LinkWithType lwt;
DatapathId src = link.getSrc();
DatapathId dst = link.getDst();
OFPort srcPort = link.getSrcPort();
OFPort dstPort = link.getDstPort();
Link otherLink = new Link(dst, dstPort, src, srcPort, U64.ZERO /* not important in lookup */);
LinkInfo otherInfo = links.get(otherLink);
LinkType otherType = null;
if (otherInfo != null)
otherType = ld.getLinkType(otherLink, otherInfo);
if (otherType == LinkType.MULTIHOP_LINK) {
// This is a bi-direcitonal link.
// It is sufficient to add only one side of it.
if ((src.getLong() < dst.getLong()) || (src.getLong() == dst.getLong()
&& srcPort.getPortNumber() < dstPort.getPortNumber())) {
lwt = new LinkWithType(link,
type,
LinkDirection.BIDIRECTIONAL);
returnLinkSet.add(lwt);
}
} else {
// This is a unidirectional link.
lwt = new LinkWithType(link,
type,
LinkDirection.UNIDIRECTIONAL);
returnLinkSet.add(lwt);
}
}
}
}
return returnLinkSet;
}
示例11: isBlockedLink
import net.floodlightcontroller.routing.Link; //导入方法依赖的package包/类
/** Returns true if a link has either one of its switch ports
* blocked.
* @param l
* @return
*/
protected boolean isBlockedLink(Link l) {
NodePortTuple n1 = new NodePortTuple(l.getSrc(), l.getSrcPort());
NodePortTuple n2 = new NodePortTuple(l.getDst(), l.getDstPort());
return (isBlockedPort(n1) || isBlockedPort(n2));
}
示例12: dijkstra
import net.floodlightcontroller.routing.Link; //导入方法依赖的package包/类
protected BroadcastTree dijkstra(Map<DatapathId, Set<Link>> links, DatapathId root,
Map<Link, Integer> linkCost,
boolean isDstRooted) {
HashMap<DatapathId, Link> nexthoplinks = new HashMap<DatapathId, Link>();
HashMap<DatapathId, Integer> cost = new HashMap<DatapathId, Integer>();
int w;
for (DatapathId node : links.keySet()) {
nexthoplinks.put(node, null);
cost.put(node, MAX_PATH_WEIGHT);
}
HashMap<DatapathId, Boolean> seen = new HashMap<DatapathId, Boolean>();
PriorityQueue<NodeDist> nodeq = new PriorityQueue<NodeDist>();
nodeq.add(new NodeDist(root, 0));
cost.put(root, 0);
while (nodeq.peek() != null) {
NodeDist n = nodeq.poll();
DatapathId cnode = n.getNode();
int cdist = n.getDist();
if (cdist >= MAX_PATH_WEIGHT) break;
if (seen.containsKey(cnode)) continue;
seen.put(cnode, true);
for (Link link : links.get(cnode)) {
DatapathId neighbor;
if (isDstRooted == true) {
neighbor = link.getSrc();
} else {
neighbor = link.getDst();
}
// links directed toward cnode will result in this condition
if (neighbor.equals(cnode)) continue;
if (seen.containsKey(neighbor)) continue;
if (linkCost == null || linkCost.get(link) == null) {
w = 1;
} else {
w = linkCost.get(link);
}
int ndist = cdist + w; // the weight of the link, always 1 in current version of floodlight.
if (ndist < cost.get(neighbor)) {
cost.put(neighbor, ndist);
nexthoplinks.put(neighbor, link);
NodeDist ndTemp = new NodeDist(neighbor, ndist);
// Remove an object that's already in there.
// Note that the comparison is based on only the node id,
// and not node id and distance.
nodeq.remove(ndTemp);
// add the current object to the queue.
nodeq.add(ndTemp);
}
}
}
BroadcastTree ret = new BroadcastTree(nexthoplinks, cost);
return ret;
}
示例13: isBroadcastDomainLink
import net.floodlightcontroller.routing.Link; //导入方法依赖的package包/类
public boolean isBroadcastDomainLink(Link l) {
NodePortTuple n1 = new NodePortTuple(l.getSrc(), l.getSrcPort());
NodePortTuple n2 = new NodePortTuple(l.getDst(), l.getDstPort());
return (isBroadcastDomainPort(n1) || isBroadcastDomainPort(n2));
}
示例14: dijkstra
import net.floodlightcontroller.routing.Link; //导入方法依赖的package包/类
protected BroadcastTree dijkstra(Cluster c, DatapathId root,
Map<Link, Integer> linkCost,
boolean isDstRooted) {
HashMap<DatapathId, Link> nexthoplinks = new HashMap<DatapathId, Link>();
//HashMap<Long, Long> nexthopnodes = new HashMap<Long, Long>();
HashMap<DatapathId, Integer> cost = new HashMap<DatapathId, Integer>();
int w;
for (DatapathId node: c.links.keySet()) {
nexthoplinks.put(node, null);
//nexthopnodes.put(node, null);
cost.put(node, MAX_PATH_WEIGHT);
}
HashMap<DatapathId, Boolean> seen = new HashMap<DatapathId, Boolean>();
PriorityQueue<NodeDist> nodeq = new PriorityQueue<NodeDist>();
nodeq.add(new NodeDist(root, 0));
cost.put(root, 0);
while (nodeq.peek() != null) {
NodeDist n = nodeq.poll();
DatapathId cnode = n.getNode();
int cdist = n.getDist();
if (cdist >= MAX_PATH_WEIGHT) break;
if (seen.containsKey(cnode)) continue;
seen.put(cnode, true);
for (Link link: c.links.get(cnode)) {
DatapathId neighbor;
if (isDstRooted == true) neighbor = link.getSrc();
else neighbor = link.getDst();
// links directed toward cnode will result in this condition
if (neighbor.equals(cnode)) continue;
if (seen.containsKey(neighbor)) continue;
if (linkCost == null || linkCost.get(link)==null) w = 1;
else w = linkCost.get(link);
int ndist = cdist + w; // the weight of the link, always 1 in current version of floodlight.
if (ndist < cost.get(neighbor)) {
cost.put(neighbor, ndist);
nexthoplinks.put(neighbor, link);
//nexthopnodes.put(neighbor, cnode);
NodeDist ndTemp = new NodeDist(neighbor, ndist);
// Remove an object that's already in there.
// Note that the comparison is based on only the node id,
// and not node id and distance.
nodeq.remove(ndTemp);
// add the current object to the queue.
nodeq.add(ndTemp);
}
}
}
BroadcastTree ret = new BroadcastTree(nexthoplinks, cost);
return ret;
}
示例15: retrieve
import net.floodlightcontroller.routing.Link; //导入方法依赖的package包/类
@Get("json")
public Set<LinkWithType> retrieve() {
ILinkDiscoveryService ld = (ILinkDiscoveryService)getContext().getAttributes().
get(ILinkDiscoveryService.class.getCanonicalName());
Map<Link, LinkInfo> links = new HashMap<Link, LinkInfo>();
Set<LinkWithType> returnLinkSet = new HashSet<LinkWithType>();
if (ld != null) {
links.putAll(ld.getLinks());
for (Link link: links.keySet()) {
LinkInfo info = links.get(link);
LinkType type = ld.getLinkType(link, info);
if (type == LinkType.DIRECT_LINK || type == LinkType.TUNNEL) {
LinkWithType lwt;
DatapathId src = link.getSrc();
DatapathId dst = link.getDst();
OFPort srcPort = link.getSrcPort();
OFPort dstPort = link.getDstPort();
Link otherLink = new Link(dst, dstPort, src, srcPort);
LinkInfo otherInfo = links.get(otherLink);
LinkType otherType = null;
if (otherInfo != null)
otherType = ld.getLinkType(otherLink, otherInfo);
if (otherType == LinkType.DIRECT_LINK ||
otherType == LinkType.TUNNEL) {
// This is a bi-direcitonal link.
// It is sufficient to add only one side of it.
if ((src.getLong() < dst.getLong()) || (src.getLong() == dst.getLong()
&& srcPort.getPortNumber() < dstPort.getPortNumber())) {
lwt = new LinkWithType(link,
type,
LinkDirection.BIDIRECTIONAL);
returnLinkSet.add(lwt);
}
} else {
// This is a unidirectional link.
lwt = new LinkWithType(link,
type,
LinkDirection.UNIDIRECTIONAL);
returnLinkSet.add(lwt);
}
}
}
}
return returnLinkSet;
}