making usage of double quotes standard for emane files

This commit is contained in:
Blake J. Harnden 2017-08-04 14:34:44 -07:00
parent 850cc599c8
commit 2281051edf
8 changed files with 278 additions and 277 deletions

View file

@ -12,8 +12,8 @@ class EmaneBypassModel(EmaneModel):
name = "emane_bypass"
config_matrix = [
("none", ConfigDataTypes.BOOL.value, '0',
'True,False', 'There are no parameters for the bypass model.'),
("none", ConfigDataTypes.BOOL.value, "0",
"True,False", "There are no parameters for the bypass model."),
]
# value groupings

View file

@ -24,24 +24,24 @@ class EmaneCommEffectModel(EmaneModel):
name = "emane_commeffect"
# CommEffect parameters
_confmatrix_shim_base = [
("filterfile", ConfigDataTypes.STRING.value, '',
'', 'filter file'),
("groupid", ConfigDataTypes.UINT32.value, '0',
'', 'NEM Group ID'),
("enablepromiscuousmode", ConfigDataTypes.BOOL.value, '0',
'On,Off', 'enable promiscuous mode'),
("receivebufferperiod", ConfigDataTypes.FLOAT.value, '1.0',
'', 'receivebufferperiod'),
("filterfile", ConfigDataTypes.STRING.value, "",
"", "filter file"),
("groupid", ConfigDataTypes.UINT32.value, "0",
"", "NEM Group ID"),
("enablepromiscuousmode", ConfigDataTypes.BOOL.value, "0",
"On,Off", "enable promiscuous mode"),
("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'),
("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'),
("defaultconnectivitymode", ConfigDataTypes.BOOL.value, "0",
"On,Off", "defaultconnectivity"),
]
if emane.VERSION >= emane.EMANE091:
_confmatrix_shim = _confmatrix_shim_base + _confmatrix_shim_091
@ -75,7 +75,7 @@ class EmaneCommEffectModel(EmaneModel):
map(lambda n: shim.appendChild(e.xmlparam(shimdoc, n, self.valueof(n, values))), shimnames)
# empty filterfile is not allowed
ff = self.valueof("filterfile", values)
if ff.strip() != '':
if ff.strip() != "":
shim.appendChild(e.xmlparam(shimdoc, "filterfile", ff))
e.xmlwrite(shimdoc, self.shimxmlname(ifc))

View file

@ -64,7 +64,7 @@ class EmaneManager(ConfigurableManager):
config_type = RegisterTlvs.EMULATION_SERVER.value
_hwaddr_prefix = "02:02"
(SUCCESS, NOT_NEEDED, NOT_READY) = (0, 1, 2)
EVENTCFGVAR = 'LIBEMANEEVENTSERVICECONFIG'
EVENTCFGVAR = "LIBEMANEEVENTSERVICECONFIG"
DEFAULT_LOG_LEVEL = 3
def __init__(self, session):
@ -81,8 +81,8 @@ class EmaneManager(ConfigurableManager):
self._ifccounts = {}
self._ifccountslock = threading.Lock()
# Port numbers are allocated from these counters
self.platformport = self.session.get_config_item_int('emane_platform_port', 8100)
self.transformport = self.session.get_config_item_int('emane_transform_port', 8200)
self.platformport = self.session.get_config_item_int("emane_platform_port", 8100)
self.transformport = self.session.get_config_item_int("emane_transform_port", 8200)
self.doeventloop = False
self.eventmonthread = None
self.logversion()
@ -102,7 +102,7 @@ class EmaneManager(ConfigurableManager):
logger.info("using EMANE version: %s", emane.VERSIONSTR)
def deleteeventservice(self):
if hasattr(self, 'service'):
if hasattr(self, "service"):
if self.service:
for fd in self.service._readFd, self.service._writeFd:
if fd >= 0:
@ -132,8 +132,8 @@ class EmaneManager(ConfigurableManager):
return
# Get the control network to be used for events
values = self.getconfig(None, "emane", self.emane_config.getdefaultvalues())[1]
group, port = self.emane_config.valueof('eventservicegroup', values).split(':')
eventdev = self.emane_config.valueof('eventservicedevice', values)
group, port = self.emane_config.valueof("eventservicegroup", values).split(":")
eventdev = self.emane_config.valueof("eventservicedevice", values)
eventnetidx = self.session.get_control_net_index(eventdev)
if emane.VERSION > emane.EMANE091:
if eventnetidx < 0:
@ -240,14 +240,14 @@ class EmaneManager(ConfigurableManager):
if ifc is None:
return self.getconfig(nodenum, conftype, defaultvalues)[1]
else:
# don't use default values when interface config is the same as net
# don"t use default values when interface config is the same as net
# note here that using ifc.node.objid as key allows for only one type
# of each model per node; TODO: use both node and interface as key
# Adamson change: first check for iface config keyed by "node:ifc.name"
# (so that nodes w/ multiple interfaces of same conftype can have
# different configs for each separate interface)
key = 1000*ifc.node.objid
key = 1000 * ifc.node.objid
if ifc.netindex is not None:
key += ifc.netindex
values = self.getconfig(key, conftype, None)[1]
@ -274,14 +274,14 @@ class EmaneManager(ConfigurableManager):
if len(self._objs) == 0:
return EmaneManager.NOT_NEEDED
if emane.VERSION == emane.EMANEUNK:
raise ValueError, 'EMANE version not properly detected'
raise ValueError, "EMANE version not properly detected"
# control network bridge required for EMANE 0.9.2
# - needs to be configured before checkdistributed() for distributed
# - needs to exist when eventservice binds to it (initeventservice)
if emane.VERSION > emane.EMANE091 and self.session.master:
values = self.getconfig(None, "emane",
self.emane_config.getdefaultvalues())[1]
otadev = self.emane_config.valueof('otamanagerdevice', values)
otadev = self.emane_config.valueof("otamanagerdevice", values)
netidx = self.session.get_control_net_index(otadev)
if netidx < 0:
msg = "EMANE cannot be started. " \
@ -291,7 +291,7 @@ class EmaneManager(ConfigurableManager):
ctrlnet = self.session.add_remove_control_net(net_index=netidx, remove=False, conf_required=False)
self.distributedctrlnet(ctrlnet)
eventdev = self.emane_config.valueof('eventservicedevice', values)
eventdev = self.emane_config.valueof("eventservicedevice", values)
if eventdev != otadev:
netidx = self.session.get_control_net_index(eventdev)
if netidx < 0:
@ -304,10 +304,10 @@ class EmaneManager(ConfigurableManager):
self.distributedctrlnet(ctrlnet)
if self.checkdistributed():
# we are slave, but haven't received a platformid yet
# we are slave, but haven"t received a platformid yet
cfgval = self.getconfig(None, self.emane_config.name,
self.emane_config.getdefaultvalues())[1]
i = self.emane_config.getnames().index('platform_id_start')
i = self.emane_config.getnames().index("platform_id_start")
if cfgval[i] == self.emane_config.getdefaultvalues()[i]:
return EmaneManager.NOT_READY
self.setnodemodels()
@ -348,13 +348,13 @@ class EmaneManager(ConfigurableManager):
e.getnemid(netif)))
if nems:
emane_nems_filename = os.path.join(self.session.session_dir,
'emane_nems')
"emane_nems")
try:
with open(emane_nems_filename, 'w') as f:
with open(emane_nems_filename, "w") as f:
for nodename, ifname, nemid in nems:
f.write('%s %s %s\n' % (nodename, ifname, nemid))
f.write("%s %s %s\n" % (nodename, ifname, nemid))
except IOError:
logger.exception('Error writing EMANE NEMs file: %s')
logger.exception("Error writing EMANE NEMs file: %s")
return EmaneManager.SUCCESS
@ -378,9 +378,9 @@ class EmaneManager(ConfigurableManager):
"""
with self._objslock:
self._objs.clear()
# don't clear self._ifccounts here; NEM counts are needed for buildxml
self.platformport = self.session.get_config_item_int('emane_platform_port', 8100)
self.transformport = self.session.get_config_item_int('emane_transform_port', 8200)
# don"t clear self._ifccounts here; NEM counts are needed for buildxml
self.platformport = self.session.get_config_item_int("emane_platform_port", 8100)
self.transformport = self.session.get_config_item_int("emane_transform_port", 8200)
def shutdown(self):
"""
@ -522,8 +522,8 @@ class EmaneManager(ConfigurableManager):
# not distributed
if len(servers) < 2:
return
prefix = session.config.get('controlnet')
prefix = getattr(session.options, 'controlnet', prefix)
prefix = session.config.get("controlnet")
prefix = getattr(session.options, "controlnet", prefix)
prefixes = prefix.split()
# normal Config messaging will distribute controlnets
if len(prefixes) >= len(servers):
@ -531,7 +531,7 @@ class EmaneManager(ConfigurableManager):
# this generates a config message having controlnet prefix assignments
logger.info("Setting up default controlnet prefixes for distributed (%d configured)" % len(prefixes))
prefixes = ctrlnet.DEFAULT_PREFIX_LIST[0]
vals = "controlnet='%s'" % prefixes
vals = 'controlnet="%s"' % prefixes
tlvdata = ""
tlvdata += coreapi.CoreConfigTlv.pack(ConfigTlvs.OBJECT.value, "session")
tlvdata += coreapi.CoreConfigTlv.pack(ConfigTlvs.TYPE.value, 0)
@ -647,7 +647,7 @@ class EmaneManager(ConfigurableManager):
names = list(self.emane_config.getnames())
platform_names = names[:len(self.emane_config._confmatrix_platform)]
platform_names.remove('platform_id_start')
platform_names.remove("platform_id_start")
# append all platform options (except starting id) to doc
map(lambda n: plat.appendChild(self.xmlparam(doc, n, self.emane_config.valueof(n, values))), platform_names)
@ -697,13 +697,13 @@ class EmaneManager(ConfigurableManager):
plat = doc.getElementsByTagName("platform").pop()
names = list(self.emane_config.getnames())
platform_names = names[:len(self.emane_config._confmatrix_platform)]
platform_names.remove('platform_id_start')
platform_names.remove("platform_id_start")
platform_values = list(values)
if otadev:
i = platform_names.index('otamanagerdevice')
i = platform_names.index("otamanagerdevice")
platform_values[i] = otadev
if eventdev:
i = platform_names.index('eventservicedevice')
i = platform_names.index("eventservicedevice")
platform_values[i] = eventdev
# append all platform options (except starting id) to doc
map(lambda n: plat.appendChild(self.xmlparam(doc, n, self.emane_config.valueof(n, platform_values))),
@ -727,7 +727,7 @@ class EmaneManager(ConfigurableManager):
nementry.setAttribute("id", "%d" % nemid)
k = netif.node.objid
if netif.transport_type == "raw":
k = 'host'
k = "host"
otadev = ctrlnet.brname
eventdev = ctrlnet.brname
else:
@ -745,8 +745,8 @@ class EmaneManager(ConfigurableManager):
netif.sethwaddr(MacAddress.from_string(macstr))
nemid += 1
for k in sorted(platformxmls.keys()):
if k == 'host':
self.xmlwrite(platformxmls['host'], "platform.xml")
if k == "host":
self.xmlwrite(platformxmls["host"], "platform.xml")
continue
self.xmlwrite(platformxmls[k], "platform%d.xml" % k)
@ -763,7 +763,7 @@ class EmaneManager(ConfigurableManager):
"""
Given a nem XML node and EMANE WLAN node number, append
a <transport/> tag to the NEM definition, required for using
EMANE's internal transport.
EMANE"s internal transport.
"""
if emane.VERSION < emane.EMANE092:
return
@ -793,7 +793,7 @@ class EmaneManager(ConfigurableManager):
defaults = self.emane_config.getdefaultvalues()
values = self.getconfig(None, "emane", self.emane_config.getdefaultvalues())[1]
need_xml = False
keys = ('eventservicegroup', 'eventservicedevice')
keys = ("eventservicegroup", "eventservicedevice")
for k in keys:
a = self.emane_config.valueof(k, defaults)
b = self.emane_config.valueof(k, values)
@ -806,17 +806,17 @@ class EmaneManager(ConfigurableManager):
return
try:
group, port = self.emane_config.valueof('eventservicegroup', values).split(':')
group, port = self.emane_config.valueof("eventservicegroup", values).split(":")
except ValueError:
logger.exception("invalid eventservicegroup in EMANE config")
return
dev = self.emane_config.valueof('eventservicedevice', values)
dev = self.emane_config.valueof("eventservicedevice", values)
doc = self.xmldoc("emaneeventmsgsvc")
es = doc.getElementsByTagName("emaneeventmsgsvc").pop()
kvs = (('group', group), ('port', port), ('device', dev), ('mcloop', '1'), ('ttl', '32'))
kvs = (("group", group), ("port", port), ("device", dev), ("mcloop", "1"), ("ttl", "32"))
xmlutils.add_text_elements_from_tuples(doc, es, kvs)
filename = 'libemaneeventservice.xml'
filename = "libemaneeventservice.xml"
self.xmlwrite(doc, filename)
pathname = os.path.join(self.session.session_dir, filename)
self.initeventservice(filename=pathname)
@ -875,17 +875,17 @@ class EmaneManager(ConfigurableManager):
emanecmd += "-r",
values = self.getconfig(None, "emane", self.emane_config.getdefaultvalues())[1]
otagroup, otaport = self.emane_config.valueof('otamanagergroup', values).split(':')
otadev = self.emane_config.valueof('otamanagerdevice', values)
otagroup, otaport = self.emane_config.valueof("otamanagergroup", values).split(":")
otadev = self.emane_config.valueof("otamanagerdevice", values)
otanetidx = self.session.get_control_net_index(otadev)
eventgroup, eventport = self.emane_config.valueof('eventservicegroup', values).split(':')
eventdev = self.emane_config.valueof('eventservicedevice', values)
eventgroup, eventport = self.emane_config.valueof("eventservicegroup", values).split(":")
eventdev = self.emane_config.valueof("eventservicedevice", values)
eventservicenetidx = self.session.get_control_net_index(eventdev)
run_emane_on_host = False
for node in self.getnodes():
if hasattr(node, 'transport_type') and node.transport_type == "raw":
if hasattr(node, "transport_type") and node.transport_type == "raw":
run_emane_on_host = True
continue
path = self.session.session_dir
@ -937,12 +937,12 @@ class EmaneManager(ConfigurableManager):
Kill the appropriate EMANE daemons.
"""
# TODO: we may want to improve this if we had the PIDs from the
# specific EMANE daemons that we've started
# specific EMANE daemons that we"ve started
cmd = ["killall", "-q", "emane"]
stop_emane_on_host = False
if emane.VERSION > emane.EMANE091:
for node in self.getnodes():
if hasattr(node, 'transport_type') and \
if hasattr(node, "transport_type") and \
node.transport_type == "raw":
stop_emane_on_host = True
continue
@ -997,7 +997,7 @@ class EmaneManager(ConfigurableManager):
"""
# this support must be explicitly turned on; by default, CORE will
# generate the EMANE events when nodes are moved
return self.session.get_config_item_bool('emane_event_monitor', False)
return self.session.get_config_item_bool("emane_event_monitor", False)
def genlocationevents(self):
"""
@ -1005,7 +1005,7 @@ class EmaneManager(ConfigurableManager):
"""
# By default, CORE generates EMANE location events when nodes
# are moved; this can be explicitly disabled in core.conf
tmp = self.session.get_config_item_bool('emane_event_generate')
tmp = self.session.get_config_item_bool("emane_event_generate")
if tmp is None:
tmp = not self.doeventmonitor()
return tmp
@ -1036,7 +1036,7 @@ class EmaneManager(ConfigurableManager):
self.doeventloop = False
if self.service is not None:
self.service.breakloop()
# reset the service, otherwise nextEvent won't work
# reset the service, otherwise nextEvent won"t work
self.initeventservice(shutdown=True)
if self.eventmonthread is not None:
if emane.VERSION >= emane.EMANE091:
@ -1086,14 +1086,14 @@ class EmaneManager(ConfigurableManager):
events.restore(data)
for event in events:
(txnemid, attrs) = event
if 'latitude' not in attrs or 'longitude' not in attrs or \
'altitude' not in attrs:
if "latitude" not in attrs or "longitude" not in attrs or \
"altitude" not in attrs:
logger.warn("dropped invalid location event")
continue
# yaw,pitch,roll,azimuth,elevation,velocity are unhandled
lat = attrs['latitude']
long = attrs['longitude']
alt = attrs['altitude']
lat = attrs["latitude"]
long = attrs["longitude"]
alt = attrs["altitude"]
self.handlelocationeventtoxyz(txnemid, lat, long, alt)
def handlelocationeventtoxyz(self, nemid, lat, long, alt):
@ -1133,7 +1133,7 @@ class EmaneManager(ConfigurableManager):
except KeyError:
logger.exception("location event NEM %s has no corresponding node %s" % (nemid, n))
return False
# don't use node.setposition(x,y,z) which generates an event
# don"t use node.setposition(x,y,z) which generates an event
node.position.set(x, y, z)
node_data = node.data(message_type=0)
@ -1150,7 +1150,7 @@ class EmaneManager(ConfigurableManager):
is running, False otherwise.
"""
status = -1
cmd = ['pkill', '-0', '-x', 'emane']
cmd = ["pkill", "-0", "-x", "emane"]
try:
if emane.VERSION < emane.EMANE092:
@ -1172,50 +1172,50 @@ class EmaneGlobalModel(EmaneModel):
EmaneModel.__init__(self, session, object_id)
# Over-The-Air channel required for EMANE 0.9.2
_DEFAULT_OTA = '0'
_DEFAULT_DEV = 'lo'
_DEFAULT_OTA = "0"
_DEFAULT_DEV = "lo"
if emane.VERSION >= emane.EMANE092:
_DEFAULT_OTA = '1'
_DEFAULT_DEV = 'ctrl0'
_DEFAULT_OTA = "1"
_DEFAULT_DEV = "ctrl0"
name = "emane"
_confmatrix_platform_base = [
("otamanagerchannelenable", ConfigDataTypes.BOOL.value, _DEFAULT_OTA,
'on,off', 'enable OTA Manager channel'),
("otamanagergroup", ConfigDataTypes.STRING.value, '224.1.2.8:45702',
'', 'OTA Manager group'),
"on,off", "enable OTA Manager channel"),
("otamanagergroup", ConfigDataTypes.STRING.value, "224.1.2.8:45702",
"", "OTA Manager group"),
("otamanagerdevice", ConfigDataTypes.STRING.value, _DEFAULT_DEV,
'', 'OTA Manager device'),
("eventservicegroup", ConfigDataTypes.STRING.value, '224.1.2.8:45703',
'', 'Event Service group'),
"", "OTA Manager device"),
("eventservicegroup", ConfigDataTypes.STRING.value, "224.1.2.8:45703",
"", "Event Service group"),
("eventservicedevice", ConfigDataTypes.STRING.value, _DEFAULT_DEV,
'', 'Event Service device'),
("platform_id_start", ConfigDataTypes.INT32.value, '1',
'', 'starting Platform ID'),
"", "Event Service device"),
("platform_id_start", ConfigDataTypes.INT32.value, "1",
"", "starting Platform ID"),
]
_confmatrix_platform_081 = [
("debugportenable", ConfigDataTypes.BOOL.value, '0',
'on,off', 'enable debug port'),
("debugport", ConfigDataTypes.UINT16.value, '47000',
'', 'debug port number'),
("debugportenable", ConfigDataTypes.BOOL.value, "0",
"on,off", "enable debug port"),
("debugport", ConfigDataTypes.UINT16.value, "47000",
"", "debug port number"),
]
_confmatrix_platform_091 = [
("controlportendpoint", ConfigDataTypes.STRING.value, '0.0.0.0:47000',
'', 'Control port address'),
("antennaprofilemanifesturi", ConfigDataTypes.STRING.value, '',
'', 'antenna profile manifest URI'),
("controlportendpoint", ConfigDataTypes.STRING.value, "0.0.0.0:47000",
"", "Control port address"),
("antennaprofilemanifesturi", ConfigDataTypes.STRING.value, "",
"", "antenna profile manifest URI"),
]
_confmatrix_nem = [
("transportendpoint", ConfigDataTypes.STRING.value, 'localhost',
'', 'Transport endpoint address (port is automatic)'),
("platformendpoint", ConfigDataTypes.STRING.value, 'localhost',
'', 'Platform endpoint address (port is automatic)'),
("nem_id_start", ConfigDataTypes.INT32.value, '1',
'', 'starting NEM ID'),
("transportendpoint", ConfigDataTypes.STRING.value, "localhost",
"", "Transport endpoint address (port is automatic)"),
("platformendpoint", ConfigDataTypes.STRING.value, "localhost",
"", "Platform endpoint address (port is automatic)"),
("nem_id_start", ConfigDataTypes.INT32.value, "1",
"", "starting NEM ID"),
]
_confmatrix_nem_092 = [
("nem_id_start", ConfigDataTypes.INT32.value, '1',
'', 'starting NEM ID'),
("nem_id_start", ConfigDataTypes.INT32.value, "1",
"", "starting NEM ID"),
]
if emane.VERSION >= emane.EMANE091:

View file

@ -17,24 +17,25 @@ class EmaneModel(WirelessModel):
handling configuration messages based on the _confmatrix list of
configurable parameters. Helper functions also live here.
"""
_prefix = {'y': 1e-24, # yocto
'z': 1e-21, # zepto
'a': 1e-18, # atto
'f': 1e-15, # femto
'p': 1e-12, # pico
'n': 1e-9, # nano
'u': 1e-6, # micro
'm': 1e-3, # mili
'c': 1e-2, # centi
'd': 1e-1, # deci
'k': 1e3, # kilo
'M': 1e6, # mega
'G': 1e9, # giga
'T': 1e12, # tera
'P': 1e15, # peta
'E': 1e18, # exa
'Z': 1e21, # zetta
'Y': 1e24, # yotta
_prefix = {
"y": 1e-24, # yocto
"z": 1e-21, # zepto
"a": 1e-18, # atto
"f": 1e-15, # femto
"p": 1e-12, # pico
"n": 1e-9, # nano
"u": 1e-6, # micro
"m": 1e-3, # mili
"c": 1e-2, # centi
"d": 1e-1, # deci
"k": 1e3, # kilo
"M": 1e6, # mega
"G": 1e9, # giga
"T": 1e12, # tera
"P": 1e15, # peta
"E": 1e18, # exa
"Z": 1e21, # zetta
"Y": 1e24, # yotta
}
@classmethod
@ -106,10 +107,10 @@ class EmaneModel(WirelessModel):
param = doc.createElement("param")
param.setAttribute("name", "device")
if ttype == "raw":
# raw RJ45 name e.g. 'eth0'
# raw RJ45 name e.g. "eth0"
param.setAttribute("value", ifc.name)
else:
# virtual TAP name e.g. 'n3.0.17'
# virtual TAP name e.g. "n3.0.17"
param.setAttribute("value", ifc.localname)
if emane.VERSION > emane.EMANE091:
param.setAttribute("value", ifc.name)
@ -120,7 +121,7 @@ class EmaneModel(WirelessModel):
def basename(self, interface=None):
"""
Return the string that other names are based on.
If a specific config is stored for a node's interface, a unique
If a specific config is stored for a node"s interface, a unique
filename is needed; otherwise the name of the EmaneNode is used.
"""
emane = self.session.emane
@ -130,12 +131,12 @@ class EmaneModel(WirelessModel):
# 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('.', '_')
name = interface.localname.replace(".", "_")
return "%s%s" % (name, self.name)
def nemxmlname(self, interface=None):
"""
Return the string name for the NEM XML file, e.g. 'n3rfpipenem.xml'
Return the string name for the NEM XML file, e.g. "n3rfpipenem.xml"
"""
append = ""
if emane.VERSION > emane.EMANE091:
@ -145,19 +146,19 @@ class EmaneModel(WirelessModel):
def shimxmlname(self, ifc=None):
"""
Return the string name for the SHIM XML file, e.g. 'commeffectshim.xml'
Return the string name for the SHIM XML file, e.g. "commeffectshim.xml"
"""
return "%sshim.xml" % self.basename(ifc)
def macxmlname(self, ifc=None):
"""
Return the string name for the MAC XML file, e.g. 'n3rfpipemac.xml'
Return the string name for the MAC XML file, e.g. "n3rfpipemac.xml"
"""
return "%smac.xml" % self.basename(ifc)
def phyxmlname(self, ifc=None):
"""
Return the string name for the PHY XML file, e.g. 'n3rfpipephy.xml'
Return the string name for the PHY XML file, e.g. "n3rfpipephy.xml"
"""
return "%sphy.xml" % self.basename(ifc)
@ -194,7 +195,7 @@ class EmaneModel(WirelessModel):
logger.exception("error in value string to param list")
return None
if not hasattr(values, '__iter__'):
if not hasattr(values, "__iter__"):
return None
if len(values) < 2:

View file

@ -17,64 +17,64 @@ class EmaneIeee80211abgModel(EmaneModel):
# 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'
_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'
xml_path = "/usr/share/emane/xml/models/mac/ieee80211abg"
else:
xml_path = "/usr/share/emane/models/ieee80211abg/xml"
# MAC parameters
_confmatrix_mac_base = [
("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)'),
("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'),
"%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:
@ -136,7 +136,7 @@ class EmaneIeee80211abgModel(EmaneModel):
#
# TEMP HACK: Account for parameter convention change in EMANE 9.x
# This allows CORE to preserve the entry layout for the mac 'category' parameters
# This allows CORE to preserve the entry layout for the mac "category" parameters
# and work with EMANE 9.x onwards.
#
def get9xmacparamequivalent(self, macname, values):

View file

@ -18,47 +18,47 @@ class EmaneRfPipeModel(EmaneModel):
# model name
name = "emane_rfpipe"
if emane.VERSION >= emane.EMANE091:
xml_path = '/usr/share/emane/xml/models/mac/rfpipe'
xml_path = "/usr/share/emane/xml/models/mac/rfpipe"
else:
xml_path = "/usr/share/emane/models/rfpipe/xml"
# configuration parameters are
# ( 'name', 'type', 'default', 'possible-value-list', 'caption')
# ( "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'),
("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'),
"%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'),
("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"),
]
_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
@ -111,7 +111,7 @@ class EmaneRfPipeModel(EmaneModel):
# EMANE 0.7.4 support
if emane.VERSION == emane.EMANE074:
# convert datarate from bps to kbps
i = names.index('datarate')
i = names.index("datarate")
values = list(values)
values[i] = self.emane074_fixup(values[i], 1000)
# append MAC options to macdoc

View file

@ -18,38 +18,38 @@ class EmaneTdmaModel(EmaneModel):
# model name
name = "emane_tdma"
if emane.VERSION >= emane.EMANE101:
xml_path = '/usr/share/emane/xml/models/mac/tdmaeventscheduler'
xml_path = "/usr/share/emane/xml/models/mac/tdmaeventscheduler"
else:
raise Exception("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

View file

@ -26,52 +26,52 @@ class EmaneUniversalModel(EmaneModel):
# universal PHY parameters
_confmatrix_base = [
("bandwidth", ConfigDataTypes.UINT64.value, '1M',
'', 'rf bandwidth (hz)'),
("frequency", ConfigDataTypes.UINT64.value, '2.347G',
'', 'frequency (Hz)'),
("frequencyofinterest", ConfigDataTypes.UINT64.value, '2.347G',
'', 'frequency of interest (Hz)'),
("subid", ConfigDataTypes.UINT16.value, '1',
'', 'subid'),
("systemnoisefigure", ConfigDataTypes.FLOAT.value, '4.0',
'', 'system noise figure (dB)'),
("txpower", ConfigDataTypes.FLOAT.value, '0.0',
'', 'transmit power (dBm)'),
("bandwidth", ConfigDataTypes.UINT64.value, "1M",
"", "rf bandwidth (hz)"),
("frequency", ConfigDataTypes.UINT64.value, "2.347G",
"", "frequency (Hz)"),
("frequencyofinterest", ConfigDataTypes.UINT64.value, "2.347G",
"", "frequency of interest (Hz)"),
("subid", ConfigDataTypes.UINT16.value, "1",
"", "subid"),
("systemnoisefigure", ConfigDataTypes.FLOAT.value, "4.0",
"", "system noise figure (dB)"),
("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'),
("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)'),
("fixedantennagainenable", ConfigDataTypes.BOOL.value, '1',
'On,Off', 'enable fixed antenna gain'),
("noisemode", ConfigDataTypes.STRING.value, 'none',
'none,all,outofband', 'noise processing mode'),
("noisebinsize", ConfigDataTypes.UINT64.value, '20',
'', 'noise bin size in microseconds'),
("propagationmodel", ConfigDataTypes.STRING.value, '2ray',
'precomputed,2ray,freespace', 'path loss mode'),
("fixedantennagain", ConfigDataTypes.FLOAT.value, "0.0",
"", "antenna gain (dBi)"),
("fixedantennagainenable", ConfigDataTypes.BOOL.value, "1",
"On,Off", "enable fixed antenna gain"),
("noisemode", ConfigDataTypes.STRING.value, "none",
"none,all,outofband", "noise processing mode"),
("noisebinsize", ConfigDataTypes.UINT64.value, "20",
"", "noise bin size in microseconds"),
("propagationmodel", ConfigDataTypes.STRING.value, "2ray",
"precomputed,2ray,freespace", "path loss mode"),
]
if emane.VERSION >= emane.EMANE091:
config_matrix = _confmatrix_base + _confmatrix_091
@ -80,12 +80,12 @@ class EmaneUniversalModel(EmaneModel):
# 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'),
("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