initial pass to remove support for legacy emane code and focus on newer releases

This commit is contained in:
Blake J. Harnden 2018-03-19 16:33:36 -07:00
parent bc1ef88f82
commit 2142586112
12 changed files with 451 additions and 880 deletions

View file

@ -1,49 +0,0 @@
from core import CoreCommandError
from core import logger
from core.misc import utils
EMANEUNK = 0
EMANE074 = 7
EMANE081 = 8
EMANE091 = 91
EMANE092 = 92
EMANE093 = 93
EMANE101 = 101
VERSION = None
VERSIONSTR = None
def emane_version():
"""
Return the locally installed EMANE version identifier and string.
"""
global VERSION
global VERSIONSTR
args = ["emane", "--version"]
VERSION = EMANEUNK
try:
output = utils.check_cmd(args)
if output.startswith("0.7.4"):
VERSION = EMANE074
elif output.startswith("0.8.1"):
VERSION = EMANE081
elif output.startswith("0.9.1"):
VERSION = EMANE091
elif output.startswith("0.9.2"):
VERSION = EMANE092
elif output.startswith("0.9.3"):
VERSION = EMANE093
elif output.startswith("1.0.1"):
VERSION = EMANE101
except CoreCommandError:
logger.exception("error checking emane version")
output = ""
VERSIONSTR = output.strip()
# set version variables for the Emane class
emane_version()

View file

@ -7,9 +7,6 @@ from core.enumerations import ConfigDataTypes
class EmaneBypassModel(EmaneModel):
def __init__(self, session, object_id=None):
EmaneModel.__init__(self, session, object_id)
name = "emane_bypass"
config_matrix = [
("none", ConfigDataTypes.BOOL.value, "0",
@ -19,6 +16,9 @@ class EmaneBypassModel(EmaneModel):
# value groupings
config_groups = "Bypass Parameters:1-1"
def __init__(self, session, object_id=None):
EmaneModel.__init__(self, session, object_id)
def buildnemxmlfiles(self, e, ifc):
"""
Build the necessary nem, mac, and phy XMLs in the given path.

View file

@ -2,22 +2,32 @@
commeffect.py: EMANE CommEffect model for CORE
"""
from core import emane
from core import logger
from core.emane.emanemodel import EmaneModel
from core.enumerations import ConfigDataTypes
try:
import emaneeventservice
import emaneeventcommeffect
from emanesh.events.commeffectevent import CommEffectEvent
except ImportError:
logger.info("emane < 0.9.1 not found")
try:
from emane.events.commeffectevent import CommEffectEvent
except ImportError:
logger.info("emane 0.9.1+ not found")
def convert_none(x):
"""
Helper to use 0 for None values.
"""
if type(x) is str:
x = float(x)
if x is None:
return 0
else:
return int(x)
class EmaneCommEffectModel(EmaneModel):
def __init__(self, session, object_id=None):
EmaneModel.__init__(self, session, object_id)
# model name
name = "emane_commeffect"
# CommEffect parameters
@ -31,25 +41,19 @@ class EmaneCommEffectModel(EmaneModel):
("receivebufferperiod", ConfigDataTypes.FLOAT.value, "1.0",
"", "receivebufferperiod"),
]
_confmatrix_shim_081 = [
("defaultconnectivity", ConfigDataTypes.BOOL.value, "0",
"On,Off", "defaultconnectivity"),
("enabletighttimingmode", ConfigDataTypes.BOOL.value, "0",
"On,Off", "enable tight timing mode"),
]
_confmatrix_shim_091 = [
("defaultconnectivitymode", ConfigDataTypes.BOOL.value, "0",
"On,Off", "defaultconnectivity"),
]
if emane.VERSION >= emane.EMANE091:
_confmatrix_shim = _confmatrix_shim_base + _confmatrix_shim_091
else:
_confmatrix_shim = _confmatrix_shim_base + _confmatrix_shim_081
_confmatrix_shim = _confmatrix_shim_base + _confmatrix_shim_091
config_matrix = _confmatrix_shim
# value groupings
config_groups = "CommEffect SHIM Parameters:1-%d" % len(_confmatrix_shim)
def __init__(self, session, object_id=None):
EmaneModel.__init__(self, session, object_id)
def buildnemxmlfiles(self, e, ifc):
"""
Build the necessary nem and commeffect XMLs in the given path.
@ -85,45 +89,35 @@ class EmaneCommEffectModel(EmaneModel):
nem.appendChild(e.xmlshimdefinition(nemdoc, self.shimxmlname(ifc)))
e.xmlwrite(nemdoc, self.nemxmlname(ifc))
def linkconfig(self, netif, bw=None, delay=None,
loss=None, duplicate=None, jitter=None, netif2=None):
def linkconfig(self, netif, bw=None, delay=None, loss=None, duplicate=None, jitter=None, netif2=None):
"""
Generate CommEffect events when a Link Message is received having
link parameters.
"""
if emane.VERSION >= emane.EMANE091:
raise NotImplementedError("CommEffect linkconfig() not implemented for EMANE 0.9.1+")
def z(x):
"""
Helper to use 0 for None values.
"""
if type(x) is str:
x = float(x)
if x is None:
return 0
else:
return int(x)
service = self.session.emane.service
if service is None:
logger.warn("%s: EMANE event service unavailable" % self.name)
logger.warn("%s: EMANE event service unavailable", self.name)
return
if netif is None or netif2 is None:
logger.warn("%s: missing NEM information" % self.name)
logger.warn("%s: missing NEM information", self.name)
return
# TODO: batch these into multiple events per transmission
# TODO: may want to split out seconds portion of delay and jitter
event = emaneeventcommeffect.EventCommEffect(1)
index = 0
e = self.session.get_object(self.object_id)
nemid = e.getnemid(netif)
nemid2 = e.getnemid(netif2)
event = CommEffectEvent()
emane_node = self.session.get_object(self.object_id)
nemid = emane_node.getnemid(netif)
nemid2 = emane_node.getnemid(netif2)
mbw = bw
event.set(index, nemid, 0, z(delay), 0, z(jitter), z(loss),
z(duplicate), long(z(bw)), long(z(mbw)))
service.publish(emaneeventcommeffect.EVENT_ID,
emaneeventservice.PLATFORMID_ANY,
nemid2, emaneeventservice.COMPONENTID_ANY,
event.export())
event.append(
nemid,
latency=convert_none(delay),
jitter=convert_none(jitter),
loss=convert_none(loss),
duplicate=convert_none(duplicate),
unicast=long(convert_none(bw)),
broadcast=long(convert_none(mbw))
)
service.publish(nemid2, event)

File diff suppressed because it is too large Load diff

View file

@ -2,7 +2,6 @@
Defines Emane Models used within CORE.
"""
from core import emane
from core import logger
from core.misc import utils
from core.mobility import WirelessModel
@ -47,23 +46,6 @@ class EmaneModel(WirelessModel):
"""
return cls.configure(session.emane, config_data)
@classmethod
def emane074_fixup(cls, value, div=1.0):
"""
Helper for converting 0.8.1 and newer values to EMANE 0.7.4
compatible values.
NOTE: This should be removed when support for 0.7.4 has been
deprecated.
"""
if div == 0:
return "0"
if type(value) is not str:
return str(value / div)
if value.endswith(tuple(cls._prefix.keys())):
suffix = value[-1]
value = float(value[:-1]) * cls._prefix[suffix]
return str(int(value / div))
def buildnemxmlfiles(self, e, ifc):
"""
Build the necessary nem, mac, and phy XMLs in the given path.
@ -98,22 +80,21 @@ class EmaneModel(WirelessModel):
"""
ttype = ifc.transport_type
if not ttype:
logger.info("warning: %s interface type unsupported!" % ifc.name)
logger.info("warning: %s interface type unsupported!", ifc.name)
ttype = "raw"
trans = doc.createElement("transport")
trans.setAttribute("definition", n.transportxmlname(ttype))
if emane.VERSION < emane.EMANE092:
trans.setAttribute("group", "1")
param = doc.createElement("param")
param.setAttribute("name", "device")
if ttype == "raw":
# raw RJ45 name e.g. "eth0"
param.setAttribute("value", ifc.name)
else:
# virtual TAP name e.g. "n3.0.17"
param.setAttribute("value", ifc.localname)
if emane.VERSION > emane.EMANE091:
param.setAttribute("value", ifc.name)
param.setAttribute("value", ifc.name)
trans.appendChild(param)
return trans
@ -126,12 +107,14 @@ class EmaneModel(WirelessModel):
"""
emane = self.session.emane
name = "n%s" % self.object_id
if interface is not None:
nodenum = interface.node.objid
# Adamson change - use getifcconfig() to get proper result
# if emane.getconfig(nodenum, self._name, None)[1] is not None:
if emane.getifcconfig(nodenum, self.name, None, interface) is not None:
name = interface.localname.replace(".", "_")
return "%s%s" % (name, self.name)
def nemxmlname(self, interface=None):
@ -139,9 +122,8 @@ class EmaneModel(WirelessModel):
Return the string name for the NEM XML file, e.g. "n3rfpipenem.xml"
"""
append = ""
if emane.VERSION > emane.EMANE091:
if interface and interface.transport_type == "raw":
append = "_raw"
if interface and interface.transport_type == "raw":
append = "_raw"
return "%snem%s.xml" % (self.basename(interface), append)
def shimxmlname(self, ifc=None):

View file

@ -2,80 +2,54 @@
ieee80211abg.py: EMANE IEEE 802.11abg model for CORE
"""
from core import emane
from core.emane.emanemodel import EmaneModel
from core.emane.universal import EmaneUniversalModel
from core.enumerations import ConfigDataTypes
class EmaneIeee80211abgModel(EmaneModel):
def __init__(self, session, object_id=None):
EmaneModel.__init__(self, session, object_id)
# model name
name = "emane_ieee80211abg"
_80211rates = "1 1 Mbps,2 2 Mbps,3 5.5 Mbps,4 11 Mbps,5 6 Mbps," + \
"6 9 Mbps,7 12 Mbps,8 18 Mbps,9 24 Mbps,10 36 Mbps,11 48 Mbps," + \
"12 54 Mbps"
if emane.VERSION >= emane.EMANE091:
xml_path = "/usr/share/emane/xml/models/mac/ieee80211abg"
else:
xml_path = "/usr/share/emane/models/ieee80211abg/xml"
xml_path = "/usr/share/emane/xml/models/mac/ieee80211abg"
# MAC parameters
_confmatrix_mac_base = [
("mode", ConfigDataTypes.UINT8.value, "0",
"0 802.11b (DSSS only),1 802.11b (DSSS only)," +
("mode", ConfigDataTypes.UINT8.value, "0", "0 802.11b (DSSS only),1 802.11b (DSSS only)," +
"2 802.11a or g (OFDM),3 802.11b/g (DSSS and OFDM)", "mode"),
("enablepromiscuousmode", ConfigDataTypes.BOOL.value, "0",
"On,Off", "enable promiscuous mode"),
("distance", ConfigDataTypes.UINT32.value, "1000",
"", "max distance (m)"),
("unicastrate", ConfigDataTypes.UINT8.value, "4", _80211rates,
"unicast rate (Mbps)"),
("multicastrate", ConfigDataTypes.UINT8.value, "1", _80211rates,
"multicast rate (Mbps)"),
("rtsthreshold", ConfigDataTypes.UINT16.value, "0",
"", "RTS threshold (bytes)"),
("pcrcurveuri", ConfigDataTypes.STRING.value,
"%s/ieee80211pcr.xml" % xml_path,
"", "SINR/PCR curve file"),
("flowcontrolenable", ConfigDataTypes.BOOL.value, "0",
"On,Off", "enable traffic flow control"),
("flowcontroltokens", ConfigDataTypes.UINT16.value, "10",
"", "number of flow control tokens"),
("enablepromiscuousmode", ConfigDataTypes.BOOL.value, "0", "On,Off", "enable promiscuous mode"),
("distance", ConfigDataTypes.UINT32.value, "1000", "", "max distance (m)"),
("unicastrate", ConfigDataTypes.UINT8.value, "4", _80211rates, "unicast rate (Mbps)"),
("multicastrate", ConfigDataTypes.UINT8.value, "1", _80211rates, "multicast rate (Mbps)"),
("rtsthreshold", ConfigDataTypes.UINT16.value, "0", "", "RTS threshold (bytes)"),
("pcrcurveuri", ConfigDataTypes.STRING.value, "%s/ieee80211pcr.xml" % xml_path, "", "SINR/PCR curve file"),
("flowcontrolenable", ConfigDataTypes.BOOL.value, "0", "On,Off", "enable traffic flow control"),
("flowcontroltokens", ConfigDataTypes.UINT16.value, "10", "", "number of flow control tokens"),
]
# mac parameters introduced in EMANE 0.8.1
# Note: The entry format for category queue parameters (queuesize, aifs, etc) were changed in
# EMANE 9.x, but are being preserved for the time being due to space constraints in the
# CORE GUI. A conversion function (get9xmacparamequivalent) has been defined to support this.
_confmatrix_mac_extended = [
("wmmenable", ConfigDataTypes.BOOL.value, "0",
"On,Off", "WiFi Multimedia (WMM)"),
("queuesize", ConfigDataTypes.STRING.value, "0:255 1:255 2:255 3:255",
"", "queue size (0-4:size)"),
("cwmin", ConfigDataTypes.STRING.value, "0:32 1:32 2:16 3:8",
"", "min contention window (0-4:minw)"),
("cwmax", ConfigDataTypes.STRING.value, "0:1024 1:1024 2:64 3:16",
"", "max contention window (0-4:maxw)"),
("aifs", ConfigDataTypes.STRING.value, "0:2 1:2 2:2 3:1",
"", "arbitration inter frame space (0-4:aifs)"),
("txop", ConfigDataTypes.STRING.value, "0:0 1:0 2:0 3:0",
"", "txop (0-4:usec)"),
("retrylimit", ConfigDataTypes.STRING.value, "0:3 1:3 2:3 3:3",
"", "retry limit (0-4:numretries)"),
("wmmenable", ConfigDataTypes.BOOL.value, "0", "On,Off", "WiFi Multimedia (WMM)"),
("queuesize", ConfigDataTypes.STRING.value, "0:255 1:255 2:255 3:255", "", "queue size (0-4:size)"),
("cwmin", ConfigDataTypes.STRING.value, "0:32 1:32 2:16 3:8", "", "min contention window (0-4:minw)"),
("cwmax", ConfigDataTypes.STRING.value, "0:1024 1:1024 2:64 3:16", "", "max contention window (0-4:maxw)"),
("aifs", ConfigDataTypes.STRING.value, "0:2 1:2 2:2 3:1", "", "arbitration inter frame space (0-4:aifs)"),
("txop", ConfigDataTypes.STRING.value, "0:0 1:0 2:0 3:0", "", "txop (0-4:usec)"),
("retrylimit", ConfigDataTypes.STRING.value, "0:3 1:3 2:3 3:3", "", "retry limit (0-4:numretries)"),
]
_confmatrix_mac_091 = [
("radiometricenable", ConfigDataTypes.BOOL.value, "0",
"On,Off", "report radio metrics via R2RI"),
("radiometricreportinterval", ConfigDataTypes.FLOAT.value, "1.0",
"", "R2RI radio metric report interval (sec)"),
("neighbormetricdeletetime", ConfigDataTypes.FLOAT.value, "60.0",
"", "R2RI neighbor table inactivity time (sec)"),
("radiometricenable", ConfigDataTypes.BOOL.value, "0", "On,Off", "report radio metrics via R2RI"),
("radiometricreportinterval", ConfigDataTypes.FLOAT.value, "1.0", "",
"R2RI radio metric report interval (sec)"),
("neighbormetricdeletetime", ConfigDataTypes.FLOAT.value, "60.0", "",
"R2RI neighbor table inactivity time (sec)"),
]
_confmatrix_mac = _confmatrix_mac_base + _confmatrix_mac_extended
if emane.VERSION >= emane.EMANE091:
_confmatrix_mac += _confmatrix_mac_091
_confmatrix_mac = _confmatrix_mac_base + _confmatrix_mac_extended + _confmatrix_mac_091
# PHY parameters from Universal PHY
_confmatrix_phy = EmaneUniversalModel.config_matrix
@ -85,6 +59,9 @@ class EmaneIeee80211abgModel(EmaneModel):
config_groups = "802.11 MAC Parameters:1-%d|Universal PHY Parameters:%d-%d" % (
len(_confmatrix_mac), len(_confmatrix_mac) + 1, len(config_matrix))
def __init__(self, session, object_id=None):
EmaneModel.__init__(self, session, object_id)
def buildnemxmlfiles(self, e, ifc):
"""
Build the necessary nem, mac, and phy XMLs in the given path.
@ -118,13 +95,10 @@ class EmaneIeee80211abgModel(EmaneModel):
phynames = names[len(self._confmatrix_mac):]
# append all MAC options to macdoc
if emane.VERSION >= emane.EMANE091:
for macname in macnames:
mac9xnvpairlist = self.get9xmacparamequivalent(macname, values)
for nvpair in mac9xnvpairlist:
mac.appendChild(e.xmlparam(macdoc, nvpair[0], nvpair[1]))
else:
map(lambda n: mac.appendChild(e.xmlparam(macdoc, n, self.valueof(n, values))), macnames)
for macname in macnames:
mac9xnvpairlist = self.get9xmacparamequivalent(macname, values)
for nvpair in mac9xnvpairlist:
mac.appendChild(e.xmlparam(macdoc, nvpair[0], nvpair[1]))
e.xmlwrite(macdoc, self.macxmlname(ifc))
@ -145,6 +119,7 @@ class EmaneIeee80211abgModel(EmaneModel):
"""
nvpairlist = []
macparmval = self.valueof(macname, values)
if macname in ["queuesize", "aifs", "cwmin", "cwmax", "txop", "retrylimit"]:
for catval in macparmval.split():
idx_and_val = catval.split(":")
@ -157,4 +132,5 @@ class EmaneIeee80211abgModel(EmaneModel):
nvpairlist.append([name9x, val])
else:
nvpairlist.append([macname, macparmval])
return nvpairlist

View file

@ -4,9 +4,8 @@ control of an EMANE emulation. An EmaneNode has several attached NEMs that
share the same MAC+PHY model.
"""
from os import path
import os
from core import emane
from core import logger
from core.coreobj import PyCoreNet
from core.enumerations import LinkTypes
@ -21,12 +20,6 @@ except ImportError:
except ImportError:
logger.info("emane 0.9.1+ not found")
try:
import emaneeventservice
import emaneeventlocation
except ImportError:
logger.info("emane < 0.9.1 not found")
class EmaneNet(PyCoreNet):
"""
@ -125,8 +118,9 @@ class EmaneNode(EmaneNet):
"""
ret = {}
if self.model is None:
logger.info("warning: EmaneNode %s has no associated model" % self.name)
logger.info("warning: EmaneNode %s has no associated model", self.name)
return ret
for netif in self.netifs():
# <nem name="NODE-001" definition="rfpipenem.xml">
nementry = self.model.buildplatformxmlnementry(doc, self, netif)
@ -145,13 +139,16 @@ class EmaneNode(EmaneNet):
"""
if self.model is None:
return
# build XML for overall network (EmaneNode) configs
self.model.buildnemxmlfiles(emane, ifc=None)
# build XML for specific interface (NEM) configs
need_virtual = False
need_raw = False
vtype = "virtual"
rtype = "raw"
for netif in self.netifs():
self.model.buildnemxmlfiles(emane, netif)
if "virtual" in netif.transport_type:
@ -160,39 +157,42 @@ class EmaneNode(EmaneNet):
else:
need_raw = True
rtype = netif.transport_type
# build transport XML files depending on type of interfaces involved
if need_virtual:
self.buildtransportxml(emane, vtype)
if need_raw:
self.buildtransportxml(emane, rtype)
def buildtransportxml(self, emane, type):
def buildtransportxml(self, emane, transport_type):
"""
Write a transport XML file for the Virtual or Raw Transport.
"""
transdoc = emane.xmldoc("transport")
trans = transdoc.getElementsByTagName("transport").pop()
trans.setAttribute("name", "%s Transport" % type.capitalize())
trans.setAttribute("library", "trans%s" % type.lower())
trans.setAttribute("name", "%s Transport" % transport_type.capitalize())
trans.setAttribute("library", "trans%s" % transport_type.lower())
trans.appendChild(emane.xmlparam(transdoc, "bitrate", "0"))
flowcontrol = False
names = self.model.getnames()
values = emane.getconfig(self.objid, self.model.name,
self.model.getdefaultvalues())[1]
values = emane.getconfig(self.objid, self.model.name, self.model.getdefaultvalues())[1]
if "flowcontrolenable" in names and values:
i = names.index("flowcontrolenable")
if self.model.booltooffon(values[i]) == "on":
flowcontrol = True
if "virtual" in type.lower():
if path.exists("/dev/net/tun_flowctl"):
if "virtual" in transport_type.lower():
if os.path.exists("/dev/net/tun_flowctl"):
trans.appendChild(emane.xmlparam(transdoc, "devicepath", "/dev/net/tun_flowctl"))
else:
trans.appendChild(emane.xmlparam(transdoc, "devicepath", "/dev/net/tun"))
if flowcontrol:
trans.appendChild(emane.xmlparam(transdoc, "flowcontrolenable", "on"))
emane.xmlwrite(transdoc, self.transportxmlname(type.lower()))
emane.xmlwrite(transdoc, self.transportxmlname(transport_type.lower()))
def transportxmlname(self, type):
"""
@ -247,29 +247,15 @@ class EmaneNode(EmaneNet):
if nemid is None:
logger.info("nemid for %s is unknown" % ifname)
return
(lat, long, alt) = self.session.location.getgeo(x, y, z)
logger.info("setnemposition %s (%s) x,y,z=(%d,%d,%s)"
"(%.6f,%.6f,%.6f)" % \
(ifname, nemid, x, y, z, lat, long, alt))
if emane.VERSION >= emane.EMANE091:
event = LocationEvent()
else:
event = emaneeventlocation.EventLocation(1)
lat, long, alt = self.session.location.getgeo(x, y, z)
logger.info("setnemposition %s (%s) x,y,z=(%d,%d,%s)(%.6f,%.6f,%.6f)", ifname, nemid, x, y, z, lat, long, alt)
event = LocationEvent()
# altitude must be an integer or warning is printed
# unused: yaw, pitch, roll, azimuth, elevation, velocity
alt = int(round(alt))
if emane.VERSION >= emane.EMANE091:
event.append(nemid, latitude=lat, longitude=long, altitude=alt)
self.session.emane.service.publish(0, event)
else:
event.set(0, nemid, lat, long, alt)
self.session.emane.service.publish(
emaneeventlocation.EVENT_ID,
emaneeventservice.PLATFORMID_ANY,
emaneeventservice.NEMID_ANY,
emaneeventservice.COMPONENTID_ANY,
event.export()
)
event.append(nemid, latitude=lat, longitude=long, altitude=alt)
self.session.emane.service.publish(0, event)
def setnempositions(self, moved_netifs):
"""
@ -279,14 +265,12 @@ class EmaneNode(EmaneNet):
"""
if len(moved_netifs) == 0:
return
if self.session.emane.service is None:
logger.info("position service not available")
return
if emane.VERSION >= emane.EMANE091:
event = LocationEvent()
else:
event = emaneeventlocation.EventLocation(len(moved_netifs))
event = LocationEvent()
i = 0
for netif in moved_netifs:
nemid = self.getnemid(netif)
@ -294,26 +278,13 @@ class EmaneNode(EmaneNet):
if nemid is None:
logger.info("nemid for %s is unknown" % ifname)
continue
(x, y, z) = netif.node.getposition()
(lat, long, alt) = self.session.location.getgeo(x, y, z)
logger.info("setnempositions %d %s (%s) x,y,z=(%d,%d,%s)"
"(%.6f,%.6f,%.6f)" %
(i, ifname, nemid, x, y, z, lat, long, alt))
x, y, z = netif.node.getposition()
lat, long, alt = self.session.location.getgeo(x, y, z)
logger.info("setnempositions %d %s (%s) x,y,z=(%d,%d,%s)(%.6f,%.6f,%.6f)",
i, ifname, nemid, x, y, z, lat, long, alt)
# altitude must be an integer or warning is printed
alt = int(round(alt))
if emane.VERSION >= emane.EMANE091:
event.append(nemid, latitude=lat, longitude=long, altitude=alt)
else:
event.set(i, nemid, lat, long, alt)
event.append(nemid, latitude=lat, longitude=long, altitude=alt)
i += 1
if emane.VERSION >= emane.EMANE091:
self.session.emane.service.publish(0, event)
else:
self.session.emane.service.publish(
emaneeventlocation.EVENT_ID,
emaneeventservice.PLATFORMID_ANY,
emaneeventservice.NEMID_ANY,
emaneeventservice.COMPONENTID_ANY,
event.export()
)
self.session.emane.service.publish(0, event)

View file

@ -2,65 +2,36 @@
rfpipe.py: EMANE RF-PIPE model for CORE
"""
from core import emane
from core.emane.emanemodel import EmaneModel
from core.emane.universal import EmaneUniversalModel
from core.enumerations import ConfigDataTypes
class EmaneRfPipeModel(EmaneModel):
def __init__(self, session, object_id=None):
EmaneModel.__init__(self, session, object_id)
# model name
name = "emane_rfpipe"
if emane.VERSION >= emane.EMANE091:
xml_path = "/usr/share/emane/xml/models/mac/rfpipe"
else:
xml_path = "/usr/share/emane/models/rfpipe/xml"
xml_path = "/usr/share/emane/xml/models/mac/rfpipe"
# configuration parameters are
# ( "name", "type", "default", "possible-value-list", "caption")
# MAC parameters
_confmatrix_mac_base = [
("enablepromiscuousmode", ConfigDataTypes.BOOL.value, "0",
"True,False", "enable promiscuous mode"),
("datarate", ConfigDataTypes.UINT32.value, "1M",
"", "data rate (bps)"),
("flowcontrolenable", ConfigDataTypes.BOOL.value, "0",
"On,Off", "enable traffic flow control"),
("flowcontroltokens", ConfigDataTypes.UINT16.value, "10",
"", "number of flow control tokens"),
("pcrcurveuri", ConfigDataTypes.STRING.value,
"%s/rfpipepcr.xml" % xml_path,
"", "SINR/PCR curve file"),
]
_confmatrix_mac_081 = [
("jitter", ConfigDataTypes.FLOAT.value, "0.0",
"", "transmission jitter (usec)"),
("delay", ConfigDataTypes.FLOAT.value, "0.0",
"", "transmission delay (usec)"),
("transmissioncontrolmap", ConfigDataTypes.STRING.value, "",
"", "tx control map (nem:rate:freq:tx_dBm)"),
("enabletighttiming", ConfigDataTypes.BOOL.value, "0",
"On,Off", "enable tight timing for pkt delay"),
("enablepromiscuousmode", ConfigDataTypes.BOOL.value, "0", "True,False", "enable promiscuous mode"),
("datarate", ConfigDataTypes.UINT32.value, "1M", "", "data rate (bps)"),
("flowcontrolenable", ConfigDataTypes.BOOL.value, "0", "On,Off", "enable traffic flow control"),
("flowcontroltokens", ConfigDataTypes.UINT16.value, "10", "", "number of flow control tokens"),
("pcrcurveuri", ConfigDataTypes.STRING.value, "%s/rfpipepcr.xml" % xml_path, "", "SINR/PCR curve file"),
]
_confmatrix_mac_091 = [
("jitter", ConfigDataTypes.FLOAT.value, "0.0",
"", "transmission jitter (sec)"),
("delay", ConfigDataTypes.FLOAT.value, "0.0",
"", "transmission delay (sec)"),
("radiometricenable", ConfigDataTypes.BOOL.value, "0",
"On,Off", "report radio metrics via R2RI"),
("radiometricreportinterval", ConfigDataTypes.FLOAT.value, "1.0",
"", "R2RI radio metric report interval (sec)"),
("neighbormetricdeletetime", ConfigDataTypes.FLOAT.value, "60.0",
"", "R2RI neighbor table inactivity time (sec)"),
("jitter", ConfigDataTypes.FLOAT.value, "0.0", "", "transmission jitter (sec)"),
("delay", ConfigDataTypes.FLOAT.value, "0.0", "", "transmission delay (sec)"),
("radiometricenable", ConfigDataTypes.BOOL.value, "0", "On,Off", "report radio metrics via R2RI"),
("radiometricreportinterval", ConfigDataTypes.FLOAT.value, "1.0", "",
"R2RI radio metric report interval (sec)"),
("neighbormetricdeletetime", ConfigDataTypes.FLOAT.value, "60.0", "",
"R2RI neighbor table inactivity time (sec)"),
]
if emane.VERSION >= emane.EMANE091:
_confmatrix_mac = _confmatrix_mac_base + _confmatrix_mac_091
else:
_confmatrix_mac = _confmatrix_mac_base + _confmatrix_mac_081
_confmatrix_mac = _confmatrix_mac_base + _confmatrix_mac_091
# PHY parameters from Universal PHY
_confmatrix_phy = EmaneUniversalModel.config_matrix
@ -71,6 +42,9 @@ class EmaneRfPipeModel(EmaneModel):
config_groups = "RF-PIPE MAC Parameters:1-%d|Universal PHY Parameters:%d-%d" % (
len(_confmatrix_mac), len(_confmatrix_mac) + 1, len(config_matrix))
def __init__(self, session, object_id=None):
EmaneModel.__init__(self, session, object_id)
def buildnemxmlfiles(self, e, ifc):
"""
Build the necessary nem, mac, and phy XMLs in the given path.
@ -78,10 +52,10 @@ class EmaneRfPipeModel(EmaneModel):
that file also. Otherwise the WLAN-wide nXXemane_rfpipenem.xml,
nXXemane_rfpipemac.xml, nXXemane_rfpipephy.xml are used.
"""
values = e.getifcconfig(self.object_id, self.name,
self.getdefaultvalues(), ifc)
values = e.getifcconfig(self.object_id, self.name, self.getdefaultvalues(), ifc)
if values is None:
return
nemdoc = e.xmldoc("nem")
nem = nemdoc.getElementsByTagName("nem").pop()
nem.setAttribute("name", "RF-PIPE NEM")
@ -102,15 +76,9 @@ class EmaneRfPipeModel(EmaneModel):
mac = macdoc.getElementsByTagName("mac").pop()
mac.setAttribute("name", "RF-PIPE MAC")
mac.setAttribute("library", "rfpipemaclayer")
if emane.VERSION < emane.EMANE091 and \
self.valueof("transmissioncontrolmap", values) is "":
if self.valueof("transmissioncontrolmap", values) is "":
macnames.remove("transmissioncontrolmap")
# EMANE 0.7.4 support
if emane.VERSION == emane.EMANE074:
# convert datarate from bps to kbps
i = names.index("datarate")
values = list(values)
values[i] = self.emane074_fixup(values[i], 1000)
# append MAC options to macdoc
map(lambda n: mac.appendChild(e.xmlparam(macdoc, n, self.valueof(n, values))), macnames)
e.xmlwrite(macdoc, self.macxmlname(ifc))

View file

@ -2,8 +2,6 @@
tdma.py: EMANE TDMA model bindings for CORE
"""
from core import emane
from core import logger
from core.emane.emanemodel import EmaneModel
from core.emane.universal import EmaneUniversalModel
from core.enumerations import ConfigDataTypes
@ -16,37 +14,30 @@ class EmaneTdmaModel(EmaneModel):
# model name
name = "emane_tdma"
xml_path = "/usr/share/emane/xml/models/mac/tdmaeventscheduler"
if emane.VERSION < emane.EMANE101:
logger.error("EMANE TDMA requires EMANE 1.0.1 or greater")
# MAC parameters
_confmatrix_mac = [
("enablepromiscuousmode", ConfigDataTypes.BOOL.value, "0",
"True,False", "enable promiscuous mode"),
("flowcontrolenable", ConfigDataTypes.BOOL.value, "0",
"On,Off", "enable traffic flow control"),
("flowcontroltokens", ConfigDataTypes.UINT16.value, "10",
"", "number of flow control tokens"),
("fragmentcheckthreshold", ConfigDataTypes.UINT16.value, "2",
"", "rate in seconds for check if fragment reassembly efforts should be abandoned"),
("fragmenttimeoutthreshold", ConfigDataTypes.UINT16.value, "5",
"", "threshold in seconds to wait for another packet fragment for reassembly"),
("neighbormetricdeletetime", ConfigDataTypes.FLOAT.value, "60.0",
"", "neighbor RF reception timeout for removal from neighbor table (sec)"),
("neighbormetricupdateinterval", ConfigDataTypes.FLOAT.value, "1.0",
"", "neighbor table update interval (sec)"),
("pcrcurveuri", ConfigDataTypes.STRING.value, "%s/tdmabasemodelpcr.xml" % xml_path,
"", "SINR/PCR curve file"),
("queue.aggregationenable", ConfigDataTypes.BOOL.value, "1",
"On,Off", "enable transmit packet aggregation"),
("queue.aggregationslotthreshold", ConfigDataTypes.FLOAT.value, "90.0",
"", "percentage of a slot that must be filled in order to conclude aggregation"),
("queue.depth", ConfigDataTypes.UINT16.value, "256",
"", "size of the per service class downstream packet queues (packets)"),
("queue.fragmentationenable", ConfigDataTypes.BOOL.value, "1",
"On,Off", "enable packet fragmentation (over multiple slots)"),
("queue.strictdequeueenable", ConfigDataTypes.BOOL.value, "0",
"On,Off", "enable strict dequeueing to specified queues only"),
("enablepromiscuousmode", ConfigDataTypes.BOOL.value, "0", "True,False", "enable promiscuous mode"),
("flowcontrolenable", ConfigDataTypes.BOOL.value, "0", "On,Off", "enable traffic flow control"),
("flowcontroltokens", ConfigDataTypes.UINT16.value, "10", "", "number of flow control tokens"),
("fragmentcheckthreshold", ConfigDataTypes.UINT16.value, "2", "",
"rate in seconds for check if fragment reassembly efforts should be abandoned"),
("fragmenttimeoutthreshold", ConfigDataTypes.UINT16.value, "5", "",
"threshold in seconds to wait for another packet fragment for reassembly"),
("neighbormetricdeletetime", ConfigDataTypes.FLOAT.value, "60.0", "",
"neighbor RF reception timeout for removal from neighbor table (sec)"),
("neighbormetricupdateinterval", ConfigDataTypes.FLOAT.value, "1.0", "",
"neighbor table update interval (sec)"),
("pcrcurveuri", ConfigDataTypes.STRING.value, "%s/tdmabasemodelpcr.xml" % xml_path, "", "SINR/PCR curve file"),
("queue.aggregationenable", ConfigDataTypes.BOOL.value, "1", "On,Off", "enable transmit packet aggregation"),
("queue.aggregationslotthreshold", ConfigDataTypes.FLOAT.value, "90.0", "",
"percentage of a slot that must be filled in order to conclude aggregation"),
("queue.depth", ConfigDataTypes.UINT16.value, "256", "",
"size of the per service class downstream packet queues (packets)"),
("queue.fragmentationenable", ConfigDataTypes.BOOL.value, "1", "On,Off",
"enable packet fragmentation (over multiple slots)"),
("queue.strictdequeueenable", ConfigDataTypes.BOOL.value, "0", "On,Off",
"enable strict dequeueing to specified queues only"),
]
# PHY parameters from Universal PHY
@ -68,6 +59,7 @@ class EmaneTdmaModel(EmaneModel):
values = e.getifcconfig(self.object_id, self.name, self.getdefaultvalues(), ifc)
if values is None:
return
nemdoc = e.xmldoc("nem")
nem = nemdoc.getElementsByTagName("nem").pop()
nem.setAttribute("name", "TDMA NEM")

View file

@ -3,7 +3,6 @@ universal.py: EMANE Universal PHY model for CORE. Enumerates configuration items
used for the Universal PHY.
"""
from core import emane
from core.emane.emanemodel import EmaneModel
from core.enumerations import ConfigDataTypes
@ -36,28 +35,6 @@ class EmaneUniversalModel(EmaneModel):
("txpower", ConfigDataTypes.FLOAT.value, "0.0",
"", "transmit power (dBm)"),
]
_confmatrix_081 = [
("antennagain", ConfigDataTypes.FLOAT.value, "0.0",
"", "antenna gain (dBi)"),
("antennaazimuth", ConfigDataTypes.FLOAT.value, "0.0",
"", "antenna azimuth (deg)"),
("antennaelevation", ConfigDataTypes.FLOAT.value, "0.0",
"", "antenna elevation (deg)"),
("antennaprofileid", ConfigDataTypes.STRING.value, "1",
"", "antenna profile ID"),
("antennaprofilemanifesturi", ConfigDataTypes.STRING.value, "",
"", "antenna profile manifest URI"),
("antennaprofileenable", ConfigDataTypes.BOOL.value, "0",
"On,Off", "antenna profile mode"),
("defaultconnectivitymode", ConfigDataTypes.BOOL.value, "1",
"On,Off", "default connectivity"),
("frequencyofinterestfilterenable", ConfigDataTypes.BOOL.value, "1",
"On,Off", "frequency of interest filter enable"),
("noiseprocessingmode", ConfigDataTypes.BOOL.value, "0",
"On,Off", "enable noise processing"),
("pathlossmode", ConfigDataTypes.STRING.value, "2ray",
"pathloss,2ray,freespace", "path loss mode"),
]
_confmatrix_091 = [
("fixedantennagain", ConfigDataTypes.FLOAT.value, "0.0",
"", "antenna gain (dBi)"),
@ -70,63 +47,24 @@ class EmaneUniversalModel(EmaneModel):
("propagationmodel", ConfigDataTypes.STRING.value, "2ray",
"precomputed,2ray,freespace", "path loss mode"),
]
if emane.VERSION >= emane.EMANE091:
config_matrix = _confmatrix_base + _confmatrix_091
else:
config_matrix = _confmatrix_base + _confmatrix_081
# old parameters
_confmatrix_ver074 = [
("antennaazimuthbeamwidth", ConfigDataTypes.FLOAT.value, "360.0",
"", "azimith beam width (deg)"),
("antennaelevationbeamwidth", ConfigDataTypes.FLOAT.value, "180.0",
"", "elevation beam width (deg)"),
("antennatype", ConfigDataTypes.STRING.value, "omnidirectional",
"omnidirectional,unidirectional", "antenna type"),
]
# parameters that require unit conversion for 0.7.4
_update_ver074 = ("bandwidth", "frequency", "frequencyofinterest")
# parameters that should be removed for 0.7.4
_remove_ver074 = ("antennaprofileenable", "antennaprofileid",
"antennaprofilemanifesturi",
"frequencyofinterestfilterenable")
config_matrix = _confmatrix_base + _confmatrix_091
@classmethod
def getphydoc(cls, e, mac, values, phynames):
phydoc = e.xmldoc("phy")
phy = phydoc.getElementsByTagName("phy").pop()
phy.setAttribute("name", cls._xmlname)
if emane.VERSION < emane.EMANE091:
phy.setAttribute("library", cls._xmllibrary)
# EMANE 0.7.4 suppport - to be removed when 0.7.4 support is deprecated
if emane.VERSION == emane.EMANE074:
names = mac.getnames()
values = list(values)
phynames = list(phynames)
# update units for some parameters
for p in cls._update_ver074:
i = names.index(p)
# these all happen to be KHz, so 1000 is used
values[i] = cls.emane074_fixup(values[i], 1000)
# remove new incompatible options
for p in cls._remove_ver074:
phynames.remove(p)
# insert old options with their default values
for old in cls._confmatrix_ver074:
phy.appendChild(e.xmlparam(phydoc, old[0], old[2]))
frequencies = None
if emane.VERSION >= emane.EMANE091:
name = "frequencyofinterest"
value = mac.valueof(name, values)
frequencies = cls.valuestrtoparamlist(phydoc, name, value)
if frequencies:
phynames = list(phynames)
phynames.remove("frequencyofinterest")
name = "frequencyofinterest"
value = mac.valueof(name, values)
frequencies = cls.valuestrtoparamlist(phydoc, name, value)
if frequencies:
phynames = list(phynames)
phynames.remove("frequencyofinterest")
# append all PHY options to phydoc
map(lambda n: phy.appendChild(e.xmlparam(phydoc, n, mac.valueof(n, values))), phynames)
if frequencies:
phy.appendChild(frequencies)
return phydoc

View file

@ -2,11 +2,11 @@ import os
import socket
from core import constants
from core import emane
from core import logger
from core.enumerations import NodeTypes
from core.misc import ipaddress, utils
from core.misc import ipaddress
from core.misc import nodeutils
from core.misc import utils
from core.netns import nodes
from core.xml import xmlutils
@ -17,9 +17,6 @@ class CoreDeploymentWriter(object):
self.root = root
self.session = session
self.hostname = socket.gethostname()
if emane.VERSION < emane.EMANE092:
self.transport = None
self.platform = None
@staticmethod
def get_ipv4_addresses(hostname):
@ -185,18 +182,8 @@ class CoreDeploymentWriter(object):
def add_emane_interface(self, physical_host, virtual_host, netif, platform_name='p1', transport_name='t1'):
nemid = netif.net.nemidmap[netif]
if emane.VERSION < emane.EMANE092:
if self.platform is None:
self.platform = \
self.add_platform(physical_host, name=platform_name)
platform = self.platform
if self.transport is None:
self.transport = \
self.add_transport(physical_host, name=transport_name)
transport = self.transport
else:
platform = self.add_platform(virtual_host, name=platform_name)
transport = self.add_transport(virtual_host, name=transport_name)
platform = self.add_platform(virtual_host, name=platform_name)
transport = self.add_transport(virtual_host, name=transport_name)
nem_name = 'nem%s' % nemid
nem = self.add_nem(platform, nem_name)
self.add_parameter(nem, 'nemid', str(nemid))

View file

@ -636,7 +636,7 @@ class Experiment(object):
self.info("%s initial test ping (max 1 second)..." % \
self.firstnode.name)
(status, result) = self.firstnode.cmd_output(["ping", "-q", "-c", "1",
"-w", "1", self.lastaddr])
"-w", "1", self.lastaddr])
if status != 0:
self.warn("initial ping from %s to %s failed! result:\n%s" % \
(self.firstnode.name, self.lastaddr, result))
@ -706,11 +706,6 @@ def main():
exp = Experiment(opt=opt, start=starttime)
exp.info("Starting wlanemanetests.py tests %s" % starttime.ctime())
# system sanity checks here
emanever, emaneverstr = emane.VERSION, emane.VERSIONSTR
if opt.verbose:
exp.info("Detected EMANE version %s" % (emaneverstr,))
# bridged
exp.info("setting up bridged tests 1/2 no link effects")
exp.info("creating topology: numnodes = %s" % (opt.numnodes,))