Merge pull request #469 from coreemu/cleanup/per-to-loss

converted usages of per to loss
This commit is contained in:
bharnden 2020-06-13 17:26:54 -07:00 committed by GitHub
commit b74395049a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 61 additions and 60 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

@ -885,20 +885,21 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
interface_one_id = request.interface_one_id
interface_two_id = request.interface_two_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
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(
node_one_id, node_two_id, interface_one_id, interface_two_id, link_options
node_one_id, node_two_id, interface_one_id, interface_two_id, options
)
return core_pb2.EditLinkResponse(result=True)

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

@ -334,9 +334,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)
@ -348,7 +348,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),
@ -776,7 +776,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
link_options.delay = message.get_tlv(LinkTlvs.DELAY.value)
link_options.bandwidth = message.get_tlv(LinkTlvs.BANDWIDTH.value)
link_options.session = message.get_tlv(LinkTlvs.SESSION.value)
link_options.per = message.get_tlv(LinkTlvs.PER.value)
link_options.loss = message.get_tlv(LinkTlvs.LOSS.value)
link_options.dup = message.get_tlv(LinkTlvs.DUP.value)
link_options.jitter = message.get_tlv(LinkTlvs.JITTER.value)
link_options.mer = message.get_tlv(LinkTlvs.MER.value)

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, "per", link_data.loss)
add_attribute(options, "dup", link_data.dup)
add_attribute(options, "jitter", link_data.jitter)
add_attribute(options, "mer", link_data.mer)
@ -957,7 +957,7 @@ class CoreXmlReader:
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.loss = 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")

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
node_one = session.add_node(CoreNode)
@ -90,13 +90,13 @@ class TestLinks:
interface_one = node_one.netif(interface_one_data.id)
assert interface_one.getparam("delay") != delay
assert interface_one.getparam("bw") != bandwidth
assert interface_one.getparam("loss") != per
assert interface_one.getparam("loss") != loss
assert interface_one.getparam("duplicate") != dup
assert interface_one.getparam("jitter") != jitter
# when
link_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(
node_one.id,
@ -108,7 +108,7 @@ class TestLinks:
# then
assert interface_one.getparam("delay") == delay
assert interface_one.getparam("bw") == bandwidth
assert interface_one.getparam("loss") == per
assert interface_one.getparam("loss") == loss
assert interface_one.getparam("duplicate") == dup
assert interface_one.getparam("jitter") == jitter
@ -116,7 +116,7 @@ class TestLinks:
# given
delay = 50
bandwidth = 5000000
per = 25
loss = 25
dup = 25
jitter = 10
node_one = session.add_node(SwitchNode)
@ -126,13 +126,13 @@ class TestLinks:
interface_two = node_two.netif(interface_two_data.id)
assert interface_two.getparam("delay") != delay
assert interface_two.getparam("bw") != bandwidth
assert interface_two.getparam("loss") != per
assert interface_two.getparam("loss") != loss
assert interface_two.getparam("duplicate") != dup
assert interface_two.getparam("jitter") != jitter
# when
link_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(
node_one.id,
@ -144,7 +144,7 @@ class TestLinks:
# then
assert interface_two.getparam("delay") == delay
assert interface_two.getparam("bw") == bandwidth
assert interface_two.getparam("loss") == per
assert interface_two.getparam("loss") == loss
assert interface_two.getparam("duplicate") == dup
assert interface_two.getparam("jitter") == jitter
@ -152,7 +152,7 @@ class TestLinks:
# given
delay = 50
bandwidth = 5000000
per = 25
loss = 25
dup = 25
jitter = 10
node_one = session.add_node(CoreNode)
@ -166,18 +166,18 @@ class TestLinks:
interface_two = node_two.netif(interface_two_data.id)
assert interface_one.getparam("delay") != delay
assert interface_one.getparam("bw") != bandwidth
assert interface_one.getparam("loss") != per
assert interface_one.getparam("loss") != loss
assert interface_one.getparam("duplicate") != dup
assert interface_one.getparam("jitter") != jitter
assert interface_two.getparam("delay") != delay
assert interface_two.getparam("bw") != bandwidth
assert interface_two.getparam("loss") != per
assert interface_two.getparam("loss") != loss
assert interface_two.getparam("duplicate") != dup
assert interface_two.getparam("jitter") != jitter
# when
link_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(
node_one.id,
@ -190,12 +190,12 @@ class TestLinks:
# then
assert interface_one.getparam("delay") == delay
assert interface_one.getparam("bw") == bandwidth
assert interface_one.getparam("loss") == per
assert interface_one.getparam("loss") == loss
assert interface_one.getparam("duplicate") == dup
assert interface_one.getparam("jitter") == jitter
assert interface_two.getparam("delay") == delay
assert interface_two.getparam("bw") == bandwidth
assert interface_two.getparam("loss") == per
assert interface_two.getparam("loss") == loss
assert interface_two.getparam("duplicate") == dup
assert interface_two.getparam("jitter") == jitter

View file

@ -304,7 +304,7 @@ class TestXml:
# create link
link_options = LinkOptions()
link_options.per = 10.5
link_options.loss = 10.5
link_options.bandwidth = 50000
link_options.jitter = 10
link_options.delay = 30
@ -347,7 +347,7 @@ class TestXml:
node = session.nodes[node_id]
links += node.all_link_data()
link = links[0]
assert link_options.per == link.per
assert link_options.loss == link.loss
assert link_options.bandwidth == link.bandwidth
assert link_options.jitter == link.jitter
assert link_options.delay == link.delay
@ -371,7 +371,7 @@ class TestXml:
# create link
link_options = LinkOptions()
link_options.per = 10.5
link_options.loss = 10.5
link_options.bandwidth = 50000
link_options.jitter = 10
link_options.delay = 30
@ -416,7 +416,7 @@ class TestXml:
node = session.nodes[node_id]
links += node.all_link_data()
link = links[0]
assert link_options.per == link.per
assert link_options.loss == link.loss
assert link_options.bandwidth == link.bandwidth
assert link_options.jitter == link.jitter
assert link_options.delay == link.delay
@ -443,7 +443,7 @@ class TestXml:
link_options_one.unidirectional = 1
link_options_one.bandwidth = 5000
link_options_one.delay = 10
link_options_one.per = 10.5
link_options_one.loss = 10.5
link_options_one.dup = 5
link_options_one.jitter = 5
session.add_link(
@ -453,7 +453,7 @@ class TestXml:
link_options_two.unidirectional = 1
link_options_two.bandwidth = 10000
link_options_two.delay = 20
link_options_two.per = 10
link_options_two.loss = 10
link_options_two.dup = 10
link_options_two.jitter = 10
session.update_link(
@ -504,11 +504,11 @@ class TestXml:
link_two = links[1]
assert link_options_one.bandwidth == link_one.bandwidth
assert link_options_one.delay == link_one.delay
assert link_options_one.per == link_one.per
assert link_options_one.loss == link_one.loss
assert link_options_one.dup == link_one.dup
assert link_options_one.jitter == link_one.jitter
assert link_options_two.bandwidth == link_two.bandwidth
assert link_options_two.delay == link_two.delay
assert link_options_two.per == link_two.per
assert link_options_two.loss == link_two.loss
assert link_options_two.dup == link_two.dup
assert link_options_two.jitter == link_two.jitter