initial EMANE 0.9.1 support

does not support event monitor or generating CommEffect events
This commit is contained in:
ahrenholz 2014-05-25 20:08:41 +00:00
parent 1ab6be9625
commit 9ba3d29768
6 changed files with 205 additions and 67 deletions

View file

@ -1,6 +1,6 @@
#
# CORE
# Copyright (c)2010-2013 the Boeing Company.
# Copyright (c)2010-2014 the Boeing Company.
# See the LICENSE file included in this distribution.
#
# authors: Jeff Ahrenholz <jeffrey.m.ahrenholz@boeing.com>
@ -12,8 +12,11 @@ commeffect.py: EMANE CommEffect model for CORE
import sys
import string
try:
from emanesh.events import EventService
except:
pass
from core.api import coreapi
from core.constants import *
from emane import EmaneModel
@ -30,20 +33,30 @@ class EmaneCommEffectModel(EmaneModel):
# model name
_name = "emane_commeffect"
# CommEffect parameters
_confmatrix_shim = [
("defaultconnectivity", coreapi.CONF_DATA_TYPE_BOOL, '0',
'On,Off', 'defaultconnectivity'),
_confmatrix_shim_base = [
("filterfile", coreapi.CONF_DATA_TYPE_STRING, '',
'', 'filter file'),
("groupid", coreapi.CONF_DATA_TYPE_UINT32, '0',
'', 'NEM Group ID'),
("enablepromiscuousmode", coreapi.CONF_DATA_TYPE_BOOL, '0',
'On,Off', 'enable promiscuous mode'),
("enabletighttimingmode", coreapi.CONF_DATA_TYPE_BOOL, '0',
'On,Off', 'enable tight timing mode'),
("receivebufferperiod", coreapi.CONF_DATA_TYPE_FLOAT, '1.0',
'', 'receivebufferperiod'),
]
_confmatrix_shim_081 = [
("defaultconnectivity", coreapi.CONF_DATA_TYPE_BOOL, '0',
'On,Off', 'defaultconnectivity'),
("enabletighttimingmode", coreapi.CONF_DATA_TYPE_BOOL, '0',
'On,Off', 'enable tight timing mode'),
]
_confmatrix_shim_091 = [
("defaultconnectivitymode", coreapi.CONF_DATA_TYPE_BOOL, '0',
'On,Off', 'defaultconnectivity'),
]
if 'EventService' in globals():
_confmatrix_shim = _confmatrix_shim_base + _confmatrix_shim_091
else:
_confmatrix_shim = _confmatrix_shim_base + _confmatrix_shim_081
_confmatrix = _confmatrix_shim
# value groupings
@ -90,6 +103,9 @@ class EmaneCommEffectModel(EmaneModel):
''' Generate CommEffect events when a Link Message is received having
link parameters.
'''
if self.session.emane.version == self.session.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:

View file

@ -1,6 +1,6 @@
#
# CORE
# Copyright (c)2010-2013 the Boeing Company.
# Copyright (c)2010-2014 the Boeing Company.
# See the LICENSE file included in this distribution.
#
# author: Jeff Ahrenholz <jeffrey.m.ahrenholz@boeing.com>
@ -19,11 +19,19 @@ from core.misc.xmlutils import addtextelementsfromtuples
from core.conf import ConfigurableManager, Configurable
from core.mobility import WirelessModel
from core.emane.nodes import EmaneNode
# EMANE 0.7.4/0.8.1
try:
import emaneeventservice
import emaneeventlocation
except Exception, e:
pass
# EMANE 0.9.1+
try:
from emanesh.events import EventService
from emanesh.events import LocationEvent
except Exception, e:
pass
class Emane(ConfigurableManager):
''' EMANE controller object. Lives in a Session instance and is used for
@ -35,6 +43,8 @@ class Emane(ConfigurableManager):
_hwaddr_prefix = "02:02"
(SUCCESS, NOT_NEEDED, NOT_READY) = (0, 1, 2)
EVENTCFGVAR = 'LIBEMANEEVENTSERVICECONFIG'
# possible self.version values
(EMANE074, EMANE081, EMANE091) = (7, 8, 9)
def __init__(self, session):
ConfigurableManager.__init__(self, session)
@ -49,24 +59,28 @@ class Emane(ConfigurableManager):
8100)
self.transformport = self.session.getcfgitemint('emane_transform_port',
8200)
self.doeventloop = False
self.eventmonthread = None
# detect between EMANE versions 0.7.4, 0.8.1, and 0.9.1+
# to be removed as support for older EMANEs is deprecated
self.version = self.EMANE081
try:
tmp = emaneeventlocation.EventLocation(1)
# check if yaw parameter is supported by Location Events
# if so, we have EMANE 0.8.1; if not, we have EMANE 0.7.4/earlier
tmp.set(0, 1, 2, 2, 2, 3)
except TypeError:
self.version = self.EMANE074
except Exception:
# e.g. no Python bindings installed
pass
if 'EventService' in globals():
self.version = self.EMANE091
# model for global EMANE configuration options
self.emane_config = EmaneGlobalModel(session, None, self.verbose)
session.broker.handlers += (self.handledistributed, )
self.loadmodels()
self.initeventservice()
self.doeventloop = False
self.eventmonthread = None
# EMANE 0.7.4 support -- to be removed when 0.7.4 support is deprecated
self.emane074 = False
try:
tmp = emaneeventlocation.EventLocation(1)
# check if yaw parameter is supported by Location Events
# if so, we have EMANE 0.8.1+; if not, we have EMANE 0.7.4/earlier
tmp.set(0, 1, 2, 2, 2, 3)
except TypeError:
self.emane074 = True
except Exception:
pass
def initeventservice(self, filename=None):
''' (Re-)initialize the EMANE Event service. The multicast group and/or
@ -76,6 +90,24 @@ class Emane(ConfigurableManager):
if hasattr(self, 'service'):
del self.service
self.service = None
# EMANE 0.9.1+ does not require event service XML config
if self.version == self.EMANE091:
values = self.getconfig(None, "emane",
self.emane_config.getdefaultvalues())[1]
group, port = self.emane_config.valueof('eventservicegroup',
values).split(':')
dev = self.emane_config.valueof('eventservicedevice', values)
otachannel = None
ota_enable = self.emane_config.valueof('otamanagerchannelenable',
values)
if self.emane_config.offontobool(ota_enable):
ogroup, oport = self.emane_config.valueof('otamanagergroup',
values).split(':')
odev = self.emane_config.valueof('otamanagerdevice', values)
otachannel = (ogroup, int(oport), odev)
self.service = EventService(eventchannel=(group, int(port), dev),
otachannel=otachannel)
return True
if filename is not None:
tmp = os.getenv(self.EVENTCFGVAR)
os.environ.update( {self.EVENTCFGVAR: filename} )
@ -427,8 +459,9 @@ class Emane(ConfigurableManager):
doc = self.xmldoc("platform")
plat = doc.getElementsByTagName("platform").pop()
platformid = self.emane_config.valueof("platform_id_start", values)
plat.setAttribute("name", "Platform %s" % platformid)
plat.setAttribute("id", platformid)
if self.version != self.EMANE091:
plat.setAttribute("name", "Platform %s" % platformid)
plat.setAttribute("id", platformid)
names = list(self.emane_config.getnames())
platform_names = names[:len(self.emane_config._confmatrix_platform)]
@ -667,6 +700,9 @@ class Emane(ConfigurableManager):
'''
if self.service is None:
return
if self.version == self.EMANE091:
raise NotImplementedError, \
"EMANE eventmonitorloop() not implemented for EMANE 0.9"
self.info("subscribing to EMANE location events")
#self.service.subscribe(emaneeventlocation.EVENT_ID,
# self.handlelocationevent)
@ -884,7 +920,7 @@ class EmaneGlobalModel(EmaneModel):
EmaneModel.__init__(self, session, objid, verbose)
_name = "emane"
_confmatrix_platform = [
_confmatrix_platform_base = [
("otamanagerchannelenable", coreapi.CONF_DATA_TYPE_BOOL, '0',
'on,off', 'enable OTA Manager channel'),
("otamanagergroup", coreapi.CONF_DATA_TYPE_STRING, '224.1.2.8:45702',
@ -897,11 +933,17 @@ class EmaneGlobalModel(EmaneModel):
'', 'Event Service device'),
("platform_id_start", coreapi.CONF_DATA_TYPE_INT32, '1',
'', 'starting Platform ID'),
]
_confmatrix_platform_081 = [
("debugportenable", coreapi.CONF_DATA_TYPE_BOOL, '0',
'on,off', 'enable debug port'),
("debugport", coreapi.CONF_DATA_TYPE_UINT16, '47000',
'', 'debug port number'),
]
_confmatrix_platform_091 = [
("controlportendpoint", coreapi.CONF_DATA_TYPE_STRING, '0.0.0.0:47000',
'', 'Control port address'),
]
_confmatrix_nem = [
("transportendpoint", coreapi.CONF_DATA_TYPE_STRING, 'localhost',
'', 'Transport endpoint address (port is automatic)'),
@ -910,6 +952,12 @@ class EmaneGlobalModel(EmaneModel):
("nem_id_start", coreapi.CONF_DATA_TYPE_INT32, '1',
'', 'starting NEM ID'),
]
if 'EventService' in globals():
_confmatrix_platform = _confmatrix_platform_base + \
_confmatrix_platform_091
else:
_confmatrix_platform = _confmatrix_platform_base + \
_confmatrix_platform_081
_confmatrix = _confmatrix_platform + _confmatrix_nem
_confgroups = "Platform Attributes:1-%d|NEM Parameters:%d-%d" % \
(len(_confmatrix_platform), len(_confmatrix_platform) + 1,

View file

@ -1,6 +1,6 @@
#
# CORE
# Copyright (c)2010-2013 the Boeing Company.
# Copyright (c)2010-2014 the Boeing Company.
# See the LICENSE file included in this distribution.
#
# author: Jeff Ahrenholz <jeffrey.m.ahrenholz@boeing.com>
@ -11,8 +11,11 @@ ieee80211abg.py: EMANE IEEE 802.11abg model for CORE
import sys
import string
try:
from emanesh.events import EventService
except:
pass
from core.api import coreapi
from core.constants import *
from emane import EmaneModel
from universal import EmaneUniversalModel
@ -26,8 +29,13 @@ class EmaneIeee80211abgModel(EmaneModel):
_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 'EventService' in globals():
xml_path = '/usr/share/emane/xml/models/mac/ieee80211abg'
else:
xml_path = "/usr/share/emane/models/ieee80211abg/xml"
# MAC parameters
_confmatrix_mac = [
_confmatrix_mac_base = [
("mode", coreapi.CONF_DATA_TYPE_UINT8, '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'),
@ -41,15 +49,17 @@ class EmaneIeee80211abgModel(EmaneModel):
'multicast rate (Mbps)'),
("rtsthreshold", coreapi.CONF_DATA_TYPE_UINT16, '0',
'', 'RTS threshold (bytes)'),
("wmmenable", coreapi.CONF_DATA_TYPE_BOOL, '0',
'On,Off', 'WiFi Multimedia (WMM)'),
("pcrcurveuri", coreapi.CONF_DATA_TYPE_STRING,
'/usr/share/emane/models/ieee80211abg/xml/ieee80211pcr.xml',
'%s/ieee80211pcr.xml' % xml_path,
'', 'SINR/PCR curve file'),
("flowcontrolenable", coreapi.CONF_DATA_TYPE_BOOL, '0',
'On,Off', 'enable traffic flow control'),
("flowcontroltokens", coreapi.CONF_DATA_TYPE_UINT16, '10',
'', 'number of flow control tokens'),
]
_confmatrix_mac_081 = [
("wmmenable", coreapi.CONF_DATA_TYPE_BOOL, '0',
'On,Off', 'WiFi Multimedia (WMM)'),
("queuesize", coreapi.CONF_DATA_TYPE_STRING, '0:255 1:255 2:255 3:255',
'', 'queue size (0-4:size)'),
("cwmin", coreapi.CONF_DATA_TYPE_STRING, '0:32 1:32 2:16 3:8',
@ -63,6 +73,11 @@ class EmaneIeee80211abgModel(EmaneModel):
("retrylimit", coreapi.CONF_DATA_TYPE_STRING, '0:3 1:3 2:3 3:3',
'', 'retry limit (0-4:numretries)'),
]
_confmatrix_mac_091 = []
if 'EventService' in globals():
_confmatrix_mac = _confmatrix_mac_base + _confmatrix_mac_091
else:
_confmatrix_mac = _confmatrix_mac_base + _confmatrix_mac_081
# PHY parameters from Universal PHY
_confmatrix_phy = EmaneUniversalModel._confmatrix

View file

@ -1,6 +1,6 @@
#
# CORE
# Copyright (c)2010-2013 the Boeing Company.
# Copyright (c)2010-2014 the Boeing Company.
# See the LICENSE file included in this distribution.
#
# author: Jeff Ahrenholz <jeffrey.m.ahrenholz@boeing.com>
@ -15,6 +15,12 @@ import sys
from core.api import coreapi
from core.coreobj import PyCoreNet
try:
from emanesh.events import EventService
from emanesh.events import LocationEvent
except Exception, e:
pass
try:
import emaneeventservice
import emaneeventlocation
@ -243,12 +249,19 @@ class EmaneNode(EmaneNet):
self.info("setnemposition %s (%s) x,y,z=(%d,%d,%s)"
"(%.6f,%.6f,%.6f)" % \
(ifname, nemid, x, y, z, lat, long, alt))
event = emaneeventlocation.EventLocation(1)
if self.session.emane.version == self.session.emane.EMANE091:
event = LocationEvent()
else:
event = emaneeventlocation.EventLocation(1)
# altitude must be an integer or warning is printed
# unused: yaw, pitch, roll, azimuth, elevation, velocity
alt = int(round(alt))
event.set(0, nemid, lat, long, alt)
self.session.emane.service.publish(emaneeventlocation.EVENT_ID,
if self.session.emane.version == self.session.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,
@ -266,7 +279,10 @@ class EmaneNode(EmaneNet):
self.info("position service not available")
return
event = emaneeventlocation.EventLocation(len(moved_netifs))
if self.session.emane.version == self.session.emane.EMANE091:
event = LocationEvent()
else:
event = emaneeventlocation.EventLocation(len(moved_netifs))
i = 0
for netif in moved_netifs:
nemid = self.getnemid(netif)
@ -282,10 +298,16 @@ class EmaneNode(EmaneNet):
(i, ifname, nemid, x, y, z, lat, long, alt))
# altitude must be an integer or warning is printed
alt = int(round(alt))
event.set(i, nemid, lat, long, alt)
if self.session.emane.version == self.session.emane.EMANE091:
event.append(nemid, latitude=lat, longitude=long, altitude=alt)
else:
event.set(i, nemid, lat, long, alt)
i += 1
self.session.emane.service.publish(emaneeventlocation.EVENT_ID,
if self.session.emane.version == self.session.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,

View file

@ -1,10 +1,10 @@
#
# CORE
# Copyright (c)2010-2013 the Boeing Company.
# Copyright (c)2010-2014 the Boeing Company.
# See the LICENSE file included in this distribution.
#
# author: Jeff Ahrenholz <jeffrey.m.ahrenholz@boeing.com>
# author: Harry Bullen <hbullen@i-a-i.com>
# authors: Jeff Ahrenholz <jeffrey.m.ahrenholz@boeing.com>
# Harry Bullen <hbullen@i-a-i.com>
#
'''
rfpipe.py: EMANE RF-PIPE model for CORE
@ -12,8 +12,11 @@ rfpipe.py: EMANE RF-PIPE model for CORE
import sys
import string
try:
from emanesh.events import EventService
except:
pass
from core.api import coreapi
from core.constants import *
from emane import EmaneModel
from universal import EmaneUniversalModel
@ -24,11 +27,15 @@ class EmaneRfPipeModel(EmaneModel):
# model name
_name = "emane_rfpipe"
if 'EventService' in globals():
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')
# MAC parameters
_confmatrix_mac = [
_confmatrix_mac_base = [
("enablepromiscuousmode", coreapi.CONF_DATA_TYPE_BOOL, '0',
'True,False', 'enable promiscuous mode'),
("datarate", coreapi.CONF_DATA_TYPE_UINT32, '1M',
@ -41,14 +48,21 @@ class EmaneRfPipeModel(EmaneModel):
'On,Off', 'enable traffic flow control'),
("flowcontroltokens", coreapi.CONF_DATA_TYPE_UINT16, '10',
'', 'number of flow control tokens'),
("enabletighttiming", coreapi.CONF_DATA_TYPE_BOOL, '0',
'On,Off', 'enable tight timing for pkt delay'),
("pcrcurveuri", coreapi.CONF_DATA_TYPE_STRING,
'/usr/share/emane/models/rfpipe/xml/rfpipepcr.xml',
'%s/rfpipepcr.xml' % xml_path,
'', 'SINR/PCR curve file'),
]
_confmatrix_mac_081 = [
("transmissioncontrolmap", coreapi.CONF_DATA_TYPE_STRING, '',
'', 'tx control map (nem:rate:freq:tx_dBm)'),
("enabletighttiming", coreapi.CONF_DATA_TYPE_BOOL, '0',
'On,Off', 'enable tight timing for pkt delay'),
]
_confmatrix_mac_091 = []
if 'EventService' in globals():
_confmatrix_mac = _confmatrix_mac_base + _confmatrix_mac_091
else:
_confmatrix_mac = _confmatrix_mac_base + _confmatrix_mac_081
# PHY parameters from Universal PHY
_confmatrix_phy = EmaneUniversalModel._confmatrix
@ -88,10 +102,11 @@ class EmaneRfPipeModel(EmaneModel):
mac = macdoc.getElementsByTagName("mac").pop()
mac.setAttribute("name", "RF-PIPE MAC")
mac.setAttribute("library", "rfpipemaclayer")
if self.valueof("transmissioncontrolmap", values) is "":
if e.version != e.EMANE091 and \
self.valueof("transmissioncontrolmap", values) is "":
macnames.remove("transmissioncontrolmap")
# EMANE 0.7.4 support
if e.emane074:
if e.version == e.EMANE074:
# convert datarate from bps to kbps
i = names.index('datarate')
values = list(values)

View file

@ -1,6 +1,6 @@
#
# CORE
# Copyright (c)2010-2013 the Boeing Company.
# Copyright (c)2010-2014 the Boeing Company.
# See the LICENSE file included in this distribution.
#
# author: Jeff Ahrenholz <jeffrey.m.ahrenholz@boeing.com>
@ -12,8 +12,11 @@ used for the Universal PHY.
import sys
import string
try:
from emanesh.events import EventService
except:
pass
from core.api import coreapi
from core.constants import *
from emane import EmaneModel
@ -29,7 +32,21 @@ class EmaneUniversalModel(EmaneModel):
_xmllibrary = "universalphylayer"
# universal PHY parameters
_confmatrix = [
_confmatrix_base = [
("bandwidth", coreapi.CONF_DATA_TYPE_UINT64, '1M',
'', 'rf bandwidth (hz)'),
("frequency", coreapi.CONF_DATA_TYPE_UINT64, '2.347G',
'','frequency (Hz)'),
("frequencyofinterest", coreapi.CONF_DATA_TYPE_UINT64, '2.347G',
'','frequency of interest (Hz)'),
("subid", coreapi.CONF_DATA_TYPE_UINT16, '1',
'','subid'),
("systemnoisefigure", coreapi.CONF_DATA_TYPE_FLOAT, '4.0',
'','system noise figure (dB)'),
("txpower", coreapi.CONF_DATA_TYPE_FLOAT, '0.0',
'','transmit power (dBm)'),
]
_confmatrix_081 = [
("antennagain", coreapi.CONF_DATA_TYPE_FLOAT, '0.0',
'','antenna gain (dBi)'),
("antennaazimuth", coreapi.CONF_DATA_TYPE_FLOAT, '0.0',
@ -42,27 +59,31 @@ class EmaneUniversalModel(EmaneModel):
'','antenna profile manifest URI'),
("antennaprofileenable", coreapi.CONF_DATA_TYPE_BOOL, '0',
'On,Off','antenna profile mode'),
("bandwidth", coreapi.CONF_DATA_TYPE_UINT64, '1M',
'', 'rf bandwidth (hz)'),
("defaultconnectivitymode", coreapi.CONF_DATA_TYPE_BOOL, '1',
'On,Off','default connectivity'),
("frequency", coreapi.CONF_DATA_TYPE_UINT64, '2.347G',
'','frequency (Hz)'),
("frequencyofinterest", coreapi.CONF_DATA_TYPE_UINT64, '2.347G',
'','frequency of interest (Hz)'),
("frequencyofinterestfilterenable", coreapi.CONF_DATA_TYPE_BOOL, '1',
'On,Off','frequency of interest filter enable'),
("noiseprocessingmode", coreapi.CONF_DATA_TYPE_BOOL, '0',
'On,Off','enable noise processing'),
("pathlossmode", coreapi.CONF_DATA_TYPE_STRING, '2ray',
'pathloss,2ray,freespace','path loss mode'),
("subid", coreapi.CONF_DATA_TYPE_UINT16, '1',
'','subid'),
("systemnoisefigure", coreapi.CONF_DATA_TYPE_FLOAT, '4.0',
'','system noise figure (dB)'),
("txpower", coreapi.CONF_DATA_TYPE_FLOAT, '0.0',
'','transmit power (dBm)'),
]
]
_confmatrix_091 = [
("fixedantennagain", coreapi.CONF_DATA_TYPE_FLOAT, '0.0',
'','antenna gain (dBi)'),
("fixedantennagainenable", coreapi.CONF_DATA_TYPE_BOOL, '1',
'On,Off','enable fixed antenna gain'),
("noisemode", coreapi.CONF_DATA_TYPE_STRING, 'none',
'none,all,outofband','noise processing mode'),
("noisebinsize", coreapi.CONF_DATA_TYPE_UINT64, '20',
'','noise bin size in microseconds'),
("propagationmodel", coreapi.CONF_DATA_TYPE_STRING, '2ray',
'precomputed,2ray,freespace','path loss mode'),
]
if 'EventService' in globals():
_confmatrix = _confmatrix_base + _confmatrix_091
else:
_confmatrix = _confmatrix_base + _confmatrix_081
# old parameters
_confmatrix_ver074 = [
@ -87,9 +108,10 @@ class EmaneUniversalModel(EmaneModel):
phydoc = e.xmldoc("phy")
phy = phydoc.getElementsByTagName("phy").pop()
phy.setAttribute("name", cls._xmlname)
phy.setAttribute("library", cls._xmllibrary)
if e.version != e.EMANE091:
phy.setAttribute("library", cls._xmllibrary)
# EMANE 0.7.4 suppport - to be removed when 0.7.4 support is deprecated
if e.emane074:
if e.version == e.EMANE074:
names = mac.getnames()
values = list(values)
phynames = list(phynames)