2017-04-25 16:45:34 +01:00
|
|
|
"""
|
2013-08-29 15:21:13 +01:00
|
|
|
rfpipe.py: EMANE RF-PIPE model for CORE
|
2017-04-25 16:45:34 +01:00
|
|
|
"""
|
|
|
|
|
|
|
|
from core.emane.emanemodel import EmaneModel
|
|
|
|
from core.emane.universal import EmaneUniversalModel
|
|
|
|
from core.enumerations import ConfigDataTypes
|
2013-08-29 15:21:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
class EmaneRfPipeModel(EmaneModel):
|
|
|
|
# model name
|
2017-04-25 16:45:34 +01:00
|
|
|
name = "emane_rfpipe"
|
2018-03-19 23:33:36 +00:00
|
|
|
xml_path = "/usr/share/emane/xml/models/mac/rfpipe"
|
2013-08-29 15:21:13 +01:00
|
|
|
|
|
|
|
# configuration parameters are
|
2017-08-04 22:34:44 +01:00
|
|
|
# ( "name", "type", "default", "possible-value-list", "caption")
|
2013-08-29 15:21:13 +01:00
|
|
|
# MAC parameters
|
2018-03-22 16:58:23 +00:00
|
|
|
_confmatrix_mac = [
|
|
|
|
("datarate", ConfigDataTypes.UINT64.value, "1M", "", "data rate (bps)"),
|
|
|
|
("delay", ConfigDataTypes.FLOAT.value, "0.0", "", "transmission delay (sec)"),
|
2018-03-19 23:33:36 +00:00
|
|
|
("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"),
|
|
|
|
("jitter", ConfigDataTypes.FLOAT.value, "0.0", "", "transmission jitter (sec)"),
|
2018-03-22 16:58:23 +00:00
|
|
|
("neighbormetricdeletetime", ConfigDataTypes.FLOAT.value, "60.0", "",
|
|
|
|
"R2RI neighbor table inactivity time (sec)"),
|
|
|
|
("pcrcurveuri", ConfigDataTypes.STRING.value, "%s/rfpipepcr.xml" % xml_path, "", "SINR/PCR curve file"),
|
2018-03-19 23:33:36 +00:00
|
|
|
("radiometricenable", ConfigDataTypes.BOOL.value, "0", "On,Off", "report radio metrics via R2RI"),
|
|
|
|
("radiometricreportinterval", ConfigDataTypes.FLOAT.value, "1.0", "",
|
|
|
|
"R2RI radio metric report interval (sec)"),
|
2014-10-02 16:00:19 +01:00
|
|
|
]
|
2014-09-17 23:00:11 +01:00
|
|
|
|
2013-08-29 15:21:13 +01:00
|
|
|
# PHY parameters from Universal PHY
|
2017-04-25 16:45:34 +01:00
|
|
|
_confmatrix_phy = EmaneUniversalModel.config_matrix
|
2013-08-29 15:21:13 +01:00
|
|
|
|
2017-04-25 16:45:34 +01:00
|
|
|
config_matrix = _confmatrix_mac + _confmatrix_phy
|
2013-08-29 15:21:13 +01:00
|
|
|
|
|
|
|
# value groupings
|
2017-04-25 16:45:34 +01:00
|
|
|
config_groups = "RF-PIPE MAC Parameters:1-%d|Universal PHY Parameters:%d-%d" % (
|
|
|
|
len(_confmatrix_mac), len(_confmatrix_mac) + 1, len(config_matrix))
|
2013-08-29 15:21:13 +01:00
|
|
|
|
2018-03-19 23:33:36 +00:00
|
|
|
def __init__(self, session, object_id=None):
|
|
|
|
EmaneModel.__init__(self, session, object_id)
|
|
|
|
|
2013-08-29 15:21:13 +01:00
|
|
|
def buildnemxmlfiles(self, e, ifc):
|
2017-04-25 16:45:34 +01:00
|
|
|
"""
|
|
|
|
Build the necessary nem, mac, and phy XMLs in the given path.
|
|
|
|
If an individual NEM has a nonstandard config, we need to build
|
|
|
|
that file also. Otherwise the WLAN-wide nXXemane_rfpipenem.xml,
|
|
|
|
nXXemane_rfpipemac.xml, nXXemane_rfpipephy.xml are used.
|
|
|
|
"""
|
2018-03-19 23:33:36 +00:00
|
|
|
values = e.getifcconfig(self.object_id, self.name, self.getdefaultvalues(), ifc)
|
2013-08-29 15:21:13 +01:00
|
|
|
if values is None:
|
|
|
|
return
|
2018-03-19 23:33:36 +00:00
|
|
|
|
2013-08-29 15:21:13 +01:00
|
|
|
nemdoc = e.xmldoc("nem")
|
|
|
|
nem = nemdoc.getElementsByTagName("nem").pop()
|
|
|
|
nem.setAttribute("name", "RF-PIPE NEM")
|
2017-04-25 16:45:34 +01:00
|
|
|
e.appendtransporttonem(nemdoc, nem, self.object_id, ifc)
|
2013-08-29 15:21:13 +01:00
|
|
|
mactag = nemdoc.createElement("mac")
|
|
|
|
mactag.setAttribute("definition", self.macxmlname(ifc))
|
|
|
|
nem.appendChild(mactag)
|
|
|
|
phytag = nemdoc.createElement("phy")
|
|
|
|
phytag.setAttribute("definition", self.phyxmlname(ifc))
|
|
|
|
nem.appendChild(phytag)
|
|
|
|
e.xmlwrite(nemdoc, self.nemxmlname(ifc))
|
|
|
|
|
|
|
|
names = list(self.getnames())
|
|
|
|
macnames = names[:len(self._confmatrix_mac)]
|
|
|
|
phynames = names[len(self._confmatrix_mac):]
|
|
|
|
|
|
|
|
macdoc = e.xmldoc("mac")
|
|
|
|
mac = macdoc.getElementsByTagName("mac").pop()
|
|
|
|
mac.setAttribute("name", "RF-PIPE MAC")
|
|
|
|
mac.setAttribute("library", "rfpipemaclayer")
|
2018-03-19 23:33:36 +00:00
|
|
|
|
2013-08-29 15:21:13 +01:00
|
|
|
# append MAC options to macdoc
|
2017-04-25 16:45:34 +01:00
|
|
|
map(lambda n: mac.appendChild(e.xmlparam(macdoc, n, self.valueof(n, values))), macnames)
|
2013-08-29 15:21:13 +01:00
|
|
|
e.xmlwrite(macdoc, self.macxmlname(ifc))
|
|
|
|
|
|
|
|
phydoc = EmaneUniversalModel.getphydoc(e, self, values, phynames)
|
|
|
|
e.xmlwrite(phydoc, self.phyxmlname(ifc))
|