merged latest from develop

This commit is contained in:
Blake Harnden 2020-06-13 18:07:21 -07:00
commit 83f66d33f7
16 changed files with 81 additions and 83 deletions

View file

@ -94,7 +94,7 @@ def add_link_data(
if options_data:
options.delay = options_data.delay
options.bandwidth = options_data.bandwidth
options.per = options_data.per
options.loss = options_data.loss
options.dup = options_data.dup
options.jitter = options_data.jitter
options.mer = options_data.mer
@ -343,7 +343,7 @@ def convert_link(link_data: LinkData) -> core_pb2.Link:
key=link_data.key,
mburst=link_data.mburst,
mer=link_data.mer,
per=link_data.per,
loss=link_data.loss,
bandwidth=link_data.bandwidth,
burst=link_data.burst,
delay=link_data.delay,

View file

@ -881,21 +881,20 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
interface1_id = request.interface1_id
interface2_id = request.interface2_id
options_data = request.options
link_options = LinkOptions()
link_options.delay = options_data.delay
link_options.bandwidth = options_data.bandwidth
link_options.per = options_data.per
link_options.dup = options_data.dup
link_options.jitter = options_data.jitter
link_options.mer = options_data.mer
link_options.burst = options_data.burst
link_options.mburst = options_data.mburst
link_options.unidirectional = options_data.unidirectional
link_options.key = options_data.key
link_options.opaque = options_data.opaque
session.update_link(
node1_id, node2_id, interface1_id, interface2_id, link_options
options = LinkOptions(
delay=options_data.delay,
bandwidth=options_data.bandwidth,
loss=options_data.loss,
dup=options_data.dup,
jitter=options_data.jitter,
mer=options_data.mer,
burst=options_data.burst,
mburst=options_data.mburst,
unidirectional=options_data.unidirectional,
key=options_data.key,
opaque=options_data.opaque,
)
session.update_link(node1_id, node2_id, interface1_id, interface2_id, options)
return core_pb2.EditLinkResponse(result=True)
def DeleteLink(

View file

@ -495,7 +495,7 @@ class CoreLinkTlv(CoreTlv):
LinkTlvs.N2_NUMBER.value: CoreTlvDataUint32,
LinkTlvs.DELAY.value: CoreTlvDataUint64,
LinkTlvs.BANDWIDTH.value: CoreTlvDataUint64,
LinkTlvs.PER.value: CoreTlvDataString,
LinkTlvs.LOSS.value: CoreTlvDataString,
LinkTlvs.DUP.value: CoreTlvDataString,
LinkTlvs.JITTER.value: CoreTlvDataUint64,
LinkTlvs.MER.value: CoreTlvDataUint16,

View file

@ -336,9 +336,9 @@ class CoreHandler(socketserver.BaseRequestHandler):
:return: nothing
"""
logging.debug("handling broadcast link: %s", link_data)
per = ""
if link_data.per is not None:
per = str(link_data.per)
loss = ""
if link_data.loss is not None:
loss = str(link_data.loss)
dup = ""
if link_data.dup is not None:
dup = str(link_data.dup)
@ -350,7 +350,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
(LinkTlvs.N2_NUMBER, link_data.node2_id),
(LinkTlvs.DELAY, link_data.delay),
(LinkTlvs.BANDWIDTH, link_data.bandwidth),
(LinkTlvs.PER, per),
(LinkTlvs.LOSS, loss),
(LinkTlvs.DUP, dup),
(LinkTlvs.JITTER, link_data.jitter),
(LinkTlvs.MER, link_data.mer),
@ -775,7 +775,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
options.delay = message.get_tlv(LinkTlvs.DELAY.value)
options.bandwidth = message.get_tlv(LinkTlvs.BANDWIDTH.value)
options.session = message.get_tlv(LinkTlvs.SESSION.value)
options.per = message.get_tlv(LinkTlvs.PER.value)
options.loss = message.get_tlv(LinkTlvs.LOSS.value)
options.dup = message.get_tlv(LinkTlvs.DUP.value)
options.jitter = message.get_tlv(LinkTlvs.JITTER.value)
options.mer = message.get_tlv(LinkTlvs.MER.value)
@ -787,6 +787,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
options.network_id = message.get_tlv(LinkTlvs.NETWORK_ID.value)
options.key = message.get_tlv(LinkTlvs.KEY.value)
options.opaque = message.get_tlv(LinkTlvs.OPAQUE.value)
if message.flags & MessageFlags.ADD.value:
self.session.add_link(
node1_id, node2_id, interface1_data, interface2_data, options

View file

@ -59,7 +59,7 @@ class LinkTlvs(Enum):
N2_NUMBER = 0x02
DELAY = 0x03
BANDWIDTH = 0x04
PER = 0x05
LOSS = 0x05
DUP = 0x06
JITTER = 0x07
MER = 0x08

View file

@ -141,7 +141,7 @@ class EmaneCommEffectModel(emanemodel.EmaneModel):
nemid,
latency=convert_none(options.delay),
jitter=convert_none(options.jitter),
loss=convert_none(options.per),
loss=convert_none(options.loss),
duplicate=convert_none(options.dup),
unicast=int(convert_none(options.bandwidth)),
broadcast=int(convert_none(options.bandwidth)),

View file

@ -101,7 +101,7 @@ class LinkData:
node2_id: int = None
delay: float = None
bandwidth: float = None
per: float = None
loss: float = None
dup: float = None
jitter: float = None
mer: float = None

View file

@ -68,7 +68,7 @@ class LinkOptions:
session: int = None
delay: int = None
bandwidth: int = None
per: float = None
loss: float = None
dup: int = None
jitter: int = None
mer: int = None

View file

@ -223,7 +223,7 @@ class LinkConfigurationDialog(Dialog):
duplicate = get_int(self.duplicate)
loss = get_float(self.loss)
options = core_pb2.LinkOptions(
bandwidth=bandwidth, jitter=jitter, delay=delay, dup=duplicate, per=loss
bandwidth=bandwidth, jitter=jitter, delay=delay, dup=duplicate, loss=loss
)
link.options.CopyFrom(options)
@ -252,7 +252,7 @@ class LinkConfigurationDialog(Dialog):
jitter=down_jitter,
delay=down_delay,
dup=down_duplicate,
per=down_loss,
loss=down_loss,
unidirectional=True,
)
self.edge.asymmetric_link = core_pb2.Link(
@ -317,12 +317,12 @@ class LinkConfigurationDialog(Dialog):
self.bandwidth.set(str(link.options.bandwidth))
self.jitter.set(str(link.options.jitter))
self.duplicate.set(str(link.options.dup))
self.loss.set(str(link.options.per))
self.loss.set(str(link.options.loss))
self.delay.set(str(link.options.delay))
if not self.is_symmetric:
asym_link = self.edge.asymmetric_link
self.down_bandwidth.set(str(asym_link.options.bandwidth))
self.down_jitter.set(str(asym_link.options.jitter))
self.down_duplicate.set(str(asym_link.options.dup))
self.down_loss.set(str(asym_link.options.per))
self.down_loss.set(str(asym_link.options.loss))
self.down_delay.set(str(asym_link.options.delay))

View file

@ -338,7 +338,7 @@ class BasicRangeModel(WirelessModel):
options = LinkOptions(
bandwidth=self.bw,
delay=self.delay,
per=self.loss,
loss=self.loss,
jitter=self.jitter,
)
self.wlan.linkconfig(netif, options)

View file

@ -1134,7 +1134,7 @@ class CoreNetworkBase(NodeBase):
bandwidth=netif.getparam("bw"),
dup=netif.getparam("duplicate"),
jitter=netif.getparam("jitter"),
per=netif.getparam("loss"),
loss=netif.getparam("loss"),
)
all_links.append(link_data)
@ -1153,7 +1153,7 @@ class CoreNetworkBase(NodeBase):
bandwidth=netif.getparam("bw"),
dup=netif.getparam("duplicate"),
jitter=netif.getparam("jitter"),
per=netif.getparam("loss"),
loss=netif.getparam("loss"),
)
netif.swapparams("_params_up")

View file

@ -482,7 +482,7 @@ class CoreNetwork(CoreNetworkBase):
netem = "netem"
delay = options.delay
changed = max(changed, netif.setparam("delay", delay))
loss = options.per
loss = options.loss
if loss is not None:
loss = float(loss)
changed = max(changed, netif.setparam("loss", loss))
@ -939,7 +939,7 @@ class PtpNet(CoreNetwork):
unidirectional=unidirectional,
delay=if1.getparam("delay"),
bandwidth=if1.getparam("bw"),
per=if1.getparam("loss"),
loss=if1.getparam("loss"),
dup=if1.getparam("duplicate"),
jitter=if1.getparam("jitter"),
interface1_id=if1.node.getifindex(if1),
@ -970,7 +970,7 @@ class PtpNet(CoreNetwork):
node2_id=if1.node.id,
delay=if2.getparam("delay"),
bandwidth=if2.getparam("bw"),
per=if2.getparam("loss"),
loss=if2.getparam("loss"),
dup=if2.getparam("duplicate"),
jitter=if2.getparam("jitter"),
unidirectional=1,

View file

@ -569,7 +569,7 @@ class CoreXmlWriter:
options = etree.Element("options")
add_attribute(options, "delay", link_data.delay)
add_attribute(options, "bandwidth", link_data.bandwidth)
add_attribute(options, "per", link_data.per)
add_attribute(options, "loss", link_data.loss)
add_attribute(options, "dup", link_data.dup)
add_attribute(options, "jitter", link_data.jitter)
add_attribute(options, "mer", link_data.mer)
@ -947,37 +947,35 @@ class CoreXmlReader:
interface2_data = create_interface_data(interface2_element)
options_element = link_element.find("options")
link_options = LinkOptions()
options = LinkOptions()
if options_element is not None:
link_options.bandwidth = get_int(options_element, "bandwidth")
link_options.burst = get_int(options_element, "burst")
link_options.delay = get_int(options_element, "delay")
link_options.dup = get_int(options_element, "dup")
link_options.mer = get_int(options_element, "mer")
link_options.mburst = get_int(options_element, "mburst")
link_options.jitter = get_int(options_element, "jitter")
link_options.key = get_int(options_element, "key")
link_options.per = get_float(options_element, "per")
link_options.unidirectional = get_int(options_element, "unidirectional")
link_options.session = options_element.get("session")
link_options.emulation_id = get_int(options_element, "emulation_id")
link_options.network_id = get_int(options_element, "network_id")
link_options.opaque = options_element.get("opaque")
link_options.gui_attributes = options_element.get("gui_attributes")
options.bandwidth = get_int(options_element, "bandwidth")
options.burst = get_int(options_element, "burst")
options.delay = get_int(options_element, "delay")
options.dup = get_int(options_element, "dup")
options.mer = get_int(options_element, "mer")
options.mburst = get_int(options_element, "mburst")
options.jitter = get_int(options_element, "jitter")
options.key = get_int(options_element, "key")
options.loss = get_float(options_element, "loss")
if options.loss is None:
options.loss = get_float(options_element, "per")
options.unidirectional = get_int(options_element, "unidirectional")
options.session = options_element.get("session")
options.emulation_id = get_int(options_element, "emulation_id")
options.network_id = get_int(options_element, "network_id")
options.opaque = options_element.get("opaque")
options.gui_attributes = options_element.get("gui_attributes")
if link_options.unidirectional == 1 and node_set in node_sets:
if options.unidirectional == 1 and node_set in node_sets:
logging.info("updating link node1(%s) node2(%s)", node1_id, node2_id)
self.session.update_link(
node1_id,
node2_id,
interface1_data.id,
interface2_data.id,
link_options,
node1_id, node2_id, interface1_data.id, interface2_data.id, options
)
else:
logging.info("adding link node1(%s) node2(%s)", node1_id, node2_id)
self.session.add_link(
node1_id, node2_id, interface1_data, interface2_data, link_options
node1_id, node2_id, interface1_data, interface2_data, options
)
node_sets.add(node_set)

View file

@ -719,7 +719,7 @@ message LinkOptions {
int32 key = 3;
int32 mburst = 4;
int32 mer = 5;
float per = 6;
float loss = 6;
int64 bandwidth = 7;
int32 burst = 8;
int64 delay = 9;

View file

@ -80,7 +80,7 @@ class TestLinks:
# given
delay = 50
bandwidth = 5000000
per = 25
loss = 25
dup = 25
jitter = 10
node1 = session.add_node(CoreNode)
@ -90,13 +90,13 @@ class TestLinks:
interface1 = node1.netif(interface1_data.id)
assert interface1.getparam("delay") != delay
assert interface1.getparam("bw") != bandwidth
assert interface1.getparam("loss") != per
assert interface1.getparam("loss") != loss
assert interface1.getparam("duplicate") != dup
assert interface1.getparam("jitter") != jitter
# when
options = LinkOptions(
delay=delay, bandwidth=bandwidth, per=per, dup=dup, jitter=jitter
delay=delay, bandwidth=bandwidth, loss=loss, dup=dup, jitter=jitter
)
session.update_link(
node1.id, node2.id, interface1_id=interface1_data.id, options=options
@ -105,7 +105,7 @@ class TestLinks:
# then
assert interface1.getparam("delay") == delay
assert interface1.getparam("bw") == bandwidth
assert interface1.getparam("loss") == per
assert interface1.getparam("loss") == loss
assert interface1.getparam("duplicate") == dup
assert interface1.getparam("jitter") == jitter
@ -113,7 +113,7 @@ class TestLinks:
# given
delay = 50
bandwidth = 5000000
per = 25
loss = 25
dup = 25
jitter = 10
node1 = session.add_node(SwitchNode)
@ -123,13 +123,13 @@ class TestLinks:
interface2 = node2.netif(interface2_data.id)
assert interface2.getparam("delay") != delay
assert interface2.getparam("bw") != bandwidth
assert interface2.getparam("loss") != per
assert interface2.getparam("loss") != loss
assert interface2.getparam("duplicate") != dup
assert interface2.getparam("jitter") != jitter
# when
options = LinkOptions(
delay=delay, bandwidth=bandwidth, per=per, dup=dup, jitter=jitter
delay=delay, bandwidth=bandwidth, loss=loss, dup=dup, jitter=jitter
)
session.update_link(
node1.id, node2.id, interface2_id=interface2_data.id, options=options
@ -138,7 +138,7 @@ class TestLinks:
# then
assert interface2.getparam("delay") == delay
assert interface2.getparam("bw") == bandwidth
assert interface2.getparam("loss") == per
assert interface2.getparam("loss") == loss
assert interface2.getparam("duplicate") == dup
assert interface2.getparam("jitter") == jitter
@ -146,7 +146,7 @@ class TestLinks:
# given
delay = 50
bandwidth = 5000000
per = 25
loss = 25
dup = 25
jitter = 10
node1 = session.add_node(CoreNode)
@ -158,18 +158,18 @@ class TestLinks:
interface2 = node2.netif(interface2_data.id)
assert interface1.getparam("delay") != delay
assert interface1.getparam("bw") != bandwidth
assert interface1.getparam("loss") != per
assert interface1.getparam("loss") != loss
assert interface1.getparam("duplicate") != dup
assert interface1.getparam("jitter") != jitter
assert interface2.getparam("delay") != delay
assert interface2.getparam("bw") != bandwidth
assert interface2.getparam("loss") != per
assert interface2.getparam("loss") != loss
assert interface2.getparam("duplicate") != dup
assert interface2.getparam("jitter") != jitter
# when
options = LinkOptions(
delay=delay, bandwidth=bandwidth, per=per, dup=dup, jitter=jitter
delay=delay, bandwidth=bandwidth, loss=loss, dup=dup, jitter=jitter
)
session.update_link(
node1.id, node2.id, interface1_data.id, interface2_data.id, options
@ -178,12 +178,12 @@ class TestLinks:
# then
assert interface1.getparam("delay") == delay
assert interface1.getparam("bw") == bandwidth
assert interface1.getparam("loss") == per
assert interface1.getparam("loss") == loss
assert interface1.getparam("duplicate") == dup
assert interface1.getparam("jitter") == jitter
assert interface2.getparam("delay") == delay
assert interface2.getparam("bw") == bandwidth
assert interface2.getparam("loss") == per
assert interface2.getparam("loss") == loss
assert interface2.getparam("duplicate") == dup
assert interface2.getparam("jitter") == jitter

View file

@ -304,7 +304,7 @@ class TestXml:
# create link
options = LinkOptions()
options.per = 10.5
options.loss = 10.5
options.bandwidth = 50000
options.jitter = 10
options.delay = 30
@ -347,7 +347,7 @@ class TestXml:
node = session.nodes[node_id]
links += node.all_link_data()
link = links[0]
assert options.per == link.per
assert options.loss == link.loss
assert options.bandwidth == link.bandwidth
assert options.jitter == link.jitter
assert options.delay == link.delay
@ -371,7 +371,7 @@ class TestXml:
# create link
options = LinkOptions()
options.per = 10.5
options.loss = 10.5
options.bandwidth = 50000
options.jitter = 10
options.delay = 30
@ -414,7 +414,7 @@ class TestXml:
node = session.nodes[node_id]
links += node.all_link_data()
link = links[0]
assert options.per == link.per
assert options.loss == link.loss
assert options.bandwidth == link.bandwidth
assert options.jitter == link.jitter
assert options.delay == link.delay
@ -441,7 +441,7 @@ class TestXml:
options1.unidirectional = 1
options1.bandwidth = 5000
options1.delay = 10
options1.per = 10.5
options1.loss = 10.5
options1.dup = 5
options1.jitter = 5
session.add_link(node1.id, node2.id, interface1_data, interface2_data, options1)
@ -449,7 +449,7 @@ class TestXml:
options2.unidirectional = 1
options2.bandwidth = 10000
options2.delay = 20
options2.per = 10
options2.loss = 10
options2.dup = 10
options2.jitter = 10
session.update_link(
@ -496,11 +496,11 @@ class TestXml:
link2 = links[1]
assert options1.bandwidth == link1.bandwidth
assert options1.delay == link1.delay
assert options1.per == link1.per
assert options1.loss == link1.loss
assert options1.dup == link1.dup
assert options1.jitter == link1.jitter
assert options2.bandwidth == link2.bandwidth
assert options2.delay == link2.delay
assert options2.per == link2.per
assert options2.loss == link2.loss
assert options2.dup == link2.dup
assert options2.jitter == link2.jitter