updated grpc node x,y types, added new grpc session position type, grpc updated link options to use int, fixed corehandlers handling of dup, fixed corexml type handling for link options, updated mobility config types to correlate with link options
This commit is contained in:
parent
e2f2d9dca0
commit
191d392c46
10 changed files with 131 additions and 45 deletions
|
@ -246,7 +246,7 @@ class CoreGrpcClient(object):
|
|||
:rtype: core_pb2.SetSessionLocationResponse
|
||||
:raises grpc.RpcError: when session doesn't exist
|
||||
"""
|
||||
position = core_pb2.Position(x=x, y=y, z=z, lat=lat, lon=lon, alt=alt)
|
||||
position = core_pb2.SessionPosition(x=x, y=y, z=z, lat=lat, lon=lon, alt=alt)
|
||||
request = core_pb2.SetSessionLocationRequest(session_id=session_id, position=position, scale=scale)
|
||||
return self.stub.SetSessionLocation(request)
|
||||
|
||||
|
|
|
@ -195,7 +195,7 @@ class CoreGrpcServer(core_pb2_grpc.CoreApiServicer):
|
|||
session = self.get_session(request.session_id, context)
|
||||
x, y, z = session.location.refxyz
|
||||
lat, lon, alt = session.location.refgeo
|
||||
position = core_pb2.Position(x=x, y=y, z=z, lat=lat, lon=lon, alt=alt)
|
||||
position = core_pb2.SessionPosition(x=x, y=y, z=z, lat=lat, lon=lon, alt=alt)
|
||||
return core_pb2.GetSessionLocationResponse(position=position, scale=session.location.refscale)
|
||||
|
||||
def SetSessionLocation(self, request, context):
|
||||
|
|
|
@ -324,6 +324,9 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
|||
per = ""
|
||||
if link_data.per is not None:
|
||||
per = str(link_data.per)
|
||||
dup = ""
|
||||
if link_data.dup is not None:
|
||||
dup = str(link_data.dup)
|
||||
|
||||
tlv_data = structutils.pack_values(coreapi.CoreLinkTlv, [
|
||||
(LinkTlvs.N1_NUMBER, link_data.node1_id),
|
||||
|
@ -331,7 +334,7 @@ class CoreHandler(socketserver.BaseRequestHandler):
|
|||
(LinkTlvs.DELAY, link_data.delay),
|
||||
(LinkTlvs.BANDWIDTH, link_data.bandwidth),
|
||||
(LinkTlvs.PER, per),
|
||||
(LinkTlvs.DUP, link_data.dup),
|
||||
(LinkTlvs.DUP, dup),
|
||||
(LinkTlvs.JITTER, link_data.jitter),
|
||||
(LinkTlvs.MER, link_data.mer),
|
||||
(LinkTlvs.BURST, link_data.burst),
|
||||
|
|
|
@ -367,8 +367,7 @@ class Session(object):
|
|||
if node_two:
|
||||
node_two.lock.release()
|
||||
|
||||
def update_link(self, node_one_id, node_two_id, interface_one_id=None, interface_two_id=None,
|
||||
link_options=LinkOptions()):
|
||||
def update_link(self, node_one_id, node_two_id, interface_one_id=None, interface_two_id=None, link_options=None):
|
||||
"""
|
||||
Update link information between nodes.
|
||||
|
||||
|
@ -379,6 +378,9 @@ class Session(object):
|
|||
:param core.emulator.emudata.LinkOptions link_options: data to update link with
|
||||
:return: nothing
|
||||
"""
|
||||
if not link_options:
|
||||
link_options = LinkOptions()
|
||||
|
||||
# get node objects identified by link data
|
||||
node_one, node_two, net_one, net_two, _tunnel = self._link_nodes(node_one_id, node_two_id)
|
||||
|
||||
|
@ -441,7 +443,6 @@ class Session(object):
|
|||
link_config(net_one, interface_one, link_options, interface_two=interface_two)
|
||||
if not link_options.unidirectional:
|
||||
link_config(net_one, interface_two, link_options, interface_two=interface_one)
|
||||
|
||||
finally:
|
||||
if node_one:
|
||||
node_one.lock.release()
|
||||
|
|
|
@ -318,11 +318,11 @@ class BasicRangeModel(WirelessModel):
|
|||
name = "basic_range"
|
||||
options = [
|
||||
Configuration(_id="range", _type=ConfigDataTypes.UINT32, default="275", label="wireless range (pixels)"),
|
||||
Configuration(_id="bandwidth", _type=ConfigDataTypes.UINT32, default="54000000", label="bandwidth (bps)"),
|
||||
Configuration(_id="jitter", _type=ConfigDataTypes.FLOAT, default="0.0", label="transmission jitter (usec)"),
|
||||
Configuration(_id="delay", _type=ConfigDataTypes.FLOAT, default="5000.0",
|
||||
Configuration(_id="bandwidth", _type=ConfigDataTypes.UINT64, default="54000000", label="bandwidth (bps)"),
|
||||
Configuration(_id="jitter", _type=ConfigDataTypes.UINT64, default="0", label="transmission jitter (usec)"),
|
||||
Configuration(_id="delay", _type=ConfigDataTypes.UINT64, default="5000",
|
||||
label="transmission delay (usec)"),
|
||||
Configuration(_id="error", _type=ConfigDataTypes.FLOAT, default="0.0", label="error rate (%)")
|
||||
Configuration(_id="error", _type=ConfigDataTypes.STRING, default="0", label="error rate (%)")
|
||||
]
|
||||
|
||||
@classmethod
|
||||
|
@ -358,19 +358,19 @@ class BasicRangeModel(WirelessModel):
|
|||
:param dict config: values to convert
|
||||
:return: nothing
|
||||
"""
|
||||
self.range = float(config["range"])
|
||||
self.range = int(config["range"])
|
||||
logging.info("basic range model configured for WLAN %d using range %d", self.wlan.id, self.range)
|
||||
self.bw = int(config["bandwidth"])
|
||||
if self.bw == 0.0:
|
||||
if self.bw == 0:
|
||||
self.bw = None
|
||||
self.delay = float(config["delay"])
|
||||
if self.delay == 0.0:
|
||||
self.delay = int(config["delay"])
|
||||
if self.delay == 0:
|
||||
self.delay = None
|
||||
self.loss = float(config["error"])
|
||||
if self.loss == 0.0:
|
||||
self.loss = int(config["error"])
|
||||
if self.loss == 0:
|
||||
self.loss = None
|
||||
self.jitter = float(config["jitter"])
|
||||
if self.jitter == 0.0:
|
||||
self.jitter = int(config["jitter"])
|
||||
if self.jitter == 0:
|
||||
self.jitter = None
|
||||
|
||||
def setlinkparams(self):
|
||||
|
|
|
@ -459,10 +459,10 @@ class CoreNetwork(CoreNetworkBase):
|
|||
netem = ["netem"]
|
||||
changed = max(changed, netif.setparam("delay", delay))
|
||||
if loss is not None:
|
||||
loss = float(loss)
|
||||
loss = int(loss)
|
||||
changed = max(changed, netif.setparam("loss", loss))
|
||||
if duplicate is not None:
|
||||
duplicate = float(duplicate)
|
||||
duplicate = int(duplicate)
|
||||
changed = max(changed, netif.setparam("duplicate", duplicate))
|
||||
changed = max(changed, netif.setparam("jitter", jitter))
|
||||
if not changed:
|
||||
|
|
|
@ -225,11 +225,11 @@ class OvsNet(CoreNetworkBase):
|
|||
delay_changed = netif.setparam("delay", delay)
|
||||
|
||||
if loss is not None:
|
||||
loss = float(loss)
|
||||
loss = int(loss)
|
||||
loss_changed = netif.setparam("loss", loss)
|
||||
|
||||
if duplicate is not None:
|
||||
duplicate = float(duplicate)
|
||||
duplicate = int(duplicate)
|
||||
duplicate_changed = netif.setparam("duplicate", duplicate)
|
||||
jitter_changed = netif.setparam("jitter", jitter)
|
||||
|
||||
|
|
|
@ -755,9 +755,11 @@ class CoreXmlReader(object):
|
|||
if link_elements is None:
|
||||
return
|
||||
|
||||
node_sets = set()
|
||||
for link_element in link_elements.iterchildren():
|
||||
node_one = get_int(link_element, "node_one")
|
||||
node_two = get_int(link_element, "node_two")
|
||||
node_set = frozenset((node_one, node_two))
|
||||
|
||||
interface_one_element = link_element.find("interface_one")
|
||||
interface_one = None
|
||||
|
@ -772,15 +774,15 @@ class CoreXmlReader(object):
|
|||
options_element = link_element.find("options")
|
||||
link_options = LinkOptions()
|
||||
if options_element is not None:
|
||||
link_options.bandwidth = get_float(options_element, "bandwidth")
|
||||
link_options.burst = get_float(options_element, "burst")
|
||||
link_options.delay = get_float(options_element, "delay")
|
||||
link_options.dup = get_float(options_element, "dup")
|
||||
link_options.mer = get_float(options_element, "mer")
|
||||
link_options.mburst = get_float(options_element, "mburst")
|
||||
link_options.jitter = get_float(options_element, "jitter")
|
||||
link_options.key = get_float(options_element, "key")
|
||||
link_options.per = get_float(options_element, "per")
|
||||
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_int(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")
|
||||
|
@ -788,5 +790,11 @@ class CoreXmlReader(object):
|
|||
link_options.opaque = options_element.get("opaque")
|
||||
link_options.gui_attributes = options_element.get("gui_attributes")
|
||||
|
||||
logging.info("reading link node_one(%s) node_two(%s)", node_one, node_two)
|
||||
self.session.add_link(node_one, node_two, interface_one, interface_two, link_options)
|
||||
if link_options.unidirectional == 1 and node_set in node_sets:
|
||||
logging.info("updating link node_one(%s) node_two(%s): %s", node_one, node_two, link_options)
|
||||
self.session.update_link(node_one, node_two, interface_one, interface_two, link_options)
|
||||
else:
|
||||
logging.info("adding link node_one(%s) node_two(%s): %s", node_one, node_two, link_options)
|
||||
self.session.add_link(node_one, node_two, interface_one, interface_two, link_options)
|
||||
|
||||
node_sets.add(node_set)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue