Add support for unicast ethernet faces to utility and helper methods.
Refs #5321
Change-Id: I2e28d092853fc21f59109cfbc23b946d30626a8c
diff --git a/minindn/helpers/ndn_routing_helper.py b/minindn/helpers/ndn_routing_helper.py
index d614926..7ea0de9 100644
--- a/minindn/helpers/ndn_routing_helper.py
+++ b/minindn/helpers/ndn_routing_helper.py
@@ -38,6 +38,8 @@
from mininet.log import info, debug, error, warn
from minindn.helpers.nfdc import Nfdc as nfdc
+from minindn.util import MACToEther
+
UNKNOWN_DISTANCE = -1
HYPERBOLIC_COST_ADJUSTMENT_FACTOR = 1000
@@ -297,8 +299,13 @@
def globalRoutingHelperHandler(self):
info('Creating faces and adding routes to FIB\n')
+ if self.faceType == nfdc.PROTOCOL_ETHER:
+ add_route_method = self.addNodeRoutesEther
+ else:
+ add_route_method = self.addNodeRoutes
+
res = Parallel(n_jobs=-1, require='sharedmem',
- prefer="threads", verbose=1)(delayed(self.addNodeRoutes)(host) for host in self.net.hosts)
+ prefer="threads", verbose=1)(delayed(add_route_method)(host) for host in self.net.hosts)
info('Processed all the routes to NFD\n')
@@ -308,10 +315,20 @@
:param Node node: Node from net object
"""
- neighborIPs = self.getNeighbor(node)
+ neighborIPs = self.getNeighborIP(node)
neighborFaces = self.createFaces(node, neighborIPs)
self.routeAdd(node, neighborFaces)
+ def addNodeRoutesEther(self, node):
+ """
+ Create faces to neighbors and add all routes for one node
+
+ :param Node node: Node from net object
+ """
+ neighborAddrs = self.getNeighborEther(node)
+ neighborFaces = self.createEtherFaces(node, neighborAddrs)
+ self.routeAdd(node, neighborFaces)
+
def addOrigin(self, nodes, prefix):
"""
Add prefix/s as origin on node/s
@@ -355,6 +372,15 @@
neighborFaces[k] = faceID
return neighborFaces
+ def createEtherFaces(self, node, neighborLocations):
+ neighborFaces = {}
+ for k, intfLocTuple in neighborLocations.items():
+ localIntf, etherAddr = intfLocTuple
+ faceID = nfdc.createFace(node, etherAddr, self.faceType, self.permanentFaces, localIntf)
+ if not isinstance(faceID, str): raise ValueError(faceID)
+ neighborFaces[k] = faceID
+ return neighborFaces
+
def routeAdd(self, node, neighborFaces):
"""
@@ -373,8 +399,9 @@
for prefix in prefixes:
# Register routes to all the available destination name prefix/s
nfdc.registerRoute(node, prefix, neighborFaces[nextHop], cost=cost)
+
@staticmethod
- def getNeighbor(node):
+ def getNeighborIP(node):
# Nodes to IP mapping
neighborIPs = defaultdict()
for intf in node.intfList():
@@ -392,3 +419,21 @@
# Used later to create faces
neighborIPs[other.name] = ip
return neighborIPs
+
+ @staticmethod
+ def getNeighborEther(node):
+ # Nodes to IP mapping
+ neighborLocations = defaultdict()
+ for intf in node.intfList():
+ link = intf.link
+ if link:
+ node1, node2 = link.intf1.node, link.intf2.node
+ if node1 == node:
+ other = node2
+ intf_location = (link.intf1.name, MACToEther(link.intf2.MAC()))
+ else:
+ other = node1
+ intf_location = (link.intf2.name, MACToEther(link.intf1.MAC()))
+ # Used later to create faces
+ neighborLocations[other.name] = intf_location
+ return neighborLocations
\ No newline at end of file