support for EMANE 0.9.2 by running emane process in each container

use control network for data and events
use internal transport instead of emanetransportd for 0.9.2
(Boeing r1881)
This commit is contained in:
ahrenholz 2014-09-23 16:26:22 +00:00
parent 24263d77bd
commit e825b94e13
8 changed files with 296 additions and 122 deletions

View file

@ -20,6 +20,7 @@ from core.coreobj import PyCoreNode
class CtrlNet(LxBrNet):
policy = "ACCEPT"
CTRLIF_IDX_BASE = 99 # base control interface index
DEFAULT_PREFIX = "172.16.0.0/24"
def __init__(self, session, objid = "ctrlnet", name = None,
verbose = False, netid = 1, prefix = None,
@ -168,7 +169,7 @@ class HubNode(LxBrNet):
apitype = coreapi.CORE_NODE_HUB
policy = "ACCEPT"
type = "hub"
def __init__(self, session, objid = None, name = None, verbose = False,
start = True):
''' the Hub node forwards packets to all bridge ports by turning off
@ -184,7 +185,7 @@ class WlanNode(LxBrNet):
linktype = coreapi.CORE_LINK_WIRELESS
policy = "DROP"
type = "wlan"
def __init__(self, session, objid = None, name = None, verbose = False,
start = True, policy = None):
LxBrNet.__init__(self, session, objid, name, verbose, start, policy)
@ -192,7 +193,7 @@ class WlanNode(LxBrNet):
self.model = None
# mobility model such as scripted
self.mobility = None
def attach(self, netif):
LxBrNet.attach(self, netif)
if self.model:
@ -203,7 +204,7 @@ class WlanNode(LxBrNet):
# invokes any netif.poshook
netif.setposition(x, y, z)
#self.model.setlinkparams()
def setmodel(self, model, config):
''' Mobility and wireless model.
'''
@ -222,7 +223,7 @@ class WlanNode(LxBrNet):
elif model._type == coreapi.CORE_TLV_REG_MOBILITY:
self.mobility = model(session=self.session, objid=self.objid,
verbose=self.verbose, values=config)
def updatemodel(self, model_name, values):
''' Allow for model updates during runtime (similar to setmodel().)
'''
@ -241,7 +242,7 @@ class WlanNode(LxBrNet):
(x,y,z) = netif.node.position.get()
netif.poshook(netif, x, y, z)
self.model.setlinkparams()
def tolinkmsgs(self, flags):
msgs = LxBrNet.tolinkmsgs(self, flags)
if self.model:
@ -255,7 +256,7 @@ class RJ45Node(PyCoreNode, PyCoreNetIf):
'''
apitype = coreapi.CORE_NODE_RJ45
type = "rj45"
def __init__(self, session, objid = None, name = None, mtu = 1500,
verbose = False, start = True):
PyCoreNode.__init__(self, session, objid, name, verbose=verbose,
@ -283,7 +284,7 @@ class RJ45Node(PyCoreNode, PyCoreNetIf):
(IP_BIN, self.localname))
return
self.up = True
def shutdown(self):
''' Bring the interface down. Remove any addresses and queuing
disciplines.
@ -295,16 +296,16 @@ class RJ45Node(PyCoreNode, PyCoreNetIf):
mutecall([TC_BIN, "qdisc", "del", "dev", self.localname, "root"])
self.up = False
self.restorestate()
def attachnet(self, net):
PyCoreNetIf.attachnet(self, net)
def detachnet(self):
PyCoreNetIf.detachnet(self)
def newnetif(self, net = None, addrlist = [], hwaddr = None,
ifindex = None, ifname = None):
''' This is called when linking with another node. Since this node
ifindex = None, ifname = None):
''' This is called when linking with another node. Since this node
represents an interface, we do not create another object here,
but attach ourselves to the given network.
'''
@ -325,7 +326,7 @@ class RJ45Node(PyCoreNode, PyCoreNetIf):
return ifindex
finally:
self.lock.release()
def delnetif(self, ifindex):
if ifindex is None:
ifindex = 0
@ -349,12 +350,12 @@ class RJ45Node(PyCoreNode, PyCoreNetIf):
if ifindex == self.ifindex:
return self
return None
def getifindex(self, netif):
if netif != self:
return None
return self.ifindex
def addaddr(self, addr):
if self.up:
check_call([IP_BIN, "addr", "add", str(addr), "dev", self.name])
@ -364,7 +365,7 @@ class RJ45Node(PyCoreNode, PyCoreNetIf):
if self.up:
check_call([IP_BIN, "addr", "del", str(addr), "dev", self.name])
PyCoreNetIf.deladdr(self, addr)
def savestate(self):
''' Save the addresses and other interface state before using the
interface for emulation purposes. TODO: save/restore the PROMISC flag
@ -395,7 +396,7 @@ class RJ45Node(PyCoreNode, PyCoreNetIf):
if items[1][:4] == "fe80":
continue
self.old_addrs.append((items[1], None))
def restorestate(self):
''' Restore the addresses and other interface state after using it.
'''
@ -404,19 +405,19 @@ class RJ45Node(PyCoreNode, PyCoreNetIf):
check_call([IP_BIN, "addr", "add", addr[0], "dev",
self.localname])
else:
check_call([IP_BIN, "addr", "add", addr[0], "brd", addr[1],
check_call([IP_BIN, "addr", "add", addr[0], "brd", addr[1],
"dev", self.localname])
if self.old_up:
check_call([IP_BIN, "link", "set", self.localname, "up"])
def setposition(self, x=None, y=None, z=None):
''' Use setposition() from both parent classes.
'''
PyCoreObj.setposition(self, x, y, z)
# invoke any poshook
PyCoreNetIf.setposition(self, x, y, z)