moved linkconfig to CoreNetworkBase and made linkconfig defined the same across the board

This commit is contained in:
Blake Harnden 2020-05-22 23:44:10 -07:00
parent fe09b37819
commit dd13bc8379
7 changed files with 44 additions and 37 deletions

View file

@ -121,6 +121,7 @@ class EmaneCommEffectModel(emanemodel.EmaneModel):
duplicate: float = None,
jitter: float = None,
netif2: CoreInterface = None,
devname: str = None,
) -> None:
"""
Generate CommEffect events when a Link Message is received having

View file

@ -163,6 +163,7 @@ class EmaneModel(WirelessModel):
duplicate: float = None,
jitter: float = None,
netif2: CoreInterface = None,
devname: str = None,
) -> None:
"""
Invoked when a Link Message is received. Default is unimplemented.
@ -174,6 +175,7 @@ class EmaneModel(WirelessModel):
:param duplicate: duplicate percentage to set to
:param jitter: jitter to set to
:param netif2: interface two
:param devname: device name
:return: nothing
"""
logging.warning(

View file

@ -62,6 +62,7 @@ class EmaneNet(CoreNetworkBase):
duplicate: float = None,
jitter: float = None,
netif2: CoreInterface = None,
devname: str = None,
) -> None:
"""
The CommEffect model supports link configuration.
@ -69,13 +70,7 @@ class EmaneNet(CoreNetworkBase):
if not self.model:
return
self.model.linkconfig(
netif=netif,
bw=bw,
delay=delay,
loss=loss,
duplicate=duplicate,
jitter=jitter,
netif2=netif2,
netif, bw, delay, loss, duplicate, jitter, netif2, devname
)
def config(self, conf: str) -> None:

View file

@ -4,7 +4,6 @@ import netaddr
from core import utils
from core.api.grpc.core_pb2 import LinkOptions
from core.emane.nodes import EmaneNet
from core.emulator.enumerations import LinkTypes
from core.nodes.base import CoreNetworkBase, CoreNode
from core.nodes.interface import CoreInterface
@ -37,22 +36,16 @@ def link_config(
:param interface_two: other interface associated, default is None
:return: nothing
"""
config = {
"netif": interface,
"bw": link_options.bandwidth,
"delay": link_options.delay,
"loss": link_options.per,
"duplicate": link_options.dup,
"jitter": link_options.jitter,
"netif2": interface_two,
}
# hacky check here, because physical and emane nodes do not conform to the same
# linkconfig interface
if not isinstance(node, (EmaneNet, PhysicalNode)):
config["devname"] = devname
node.linkconfig(**config)
node.linkconfig(
interface,
link_options.bandwidth,
link_options.delay,
link_options.per,
link_options.dup,
link_options.jitter,
interface_two,
devname,
)
class NodeOptions:

View file

@ -335,12 +335,7 @@ class BasicRangeModel(WirelessModel):
with self._netifslock:
for netif in self._netifs:
self.wlan.linkconfig(
netif,
bw=self.bw,
delay=self.delay,
loss=self.loss,
duplicate=None,
jitter=self.jitter,
netif, self.bw, self.delay, self.loss, jitter=self.jitter
)
def get_position(self, netif: CoreInterface) -> Tuple[float, float, float]:

View file

@ -1165,6 +1165,32 @@ class CoreNetworkBase(NodeBase):
return all_links
def linkconfig(
self,
netif: CoreInterface,
bw: float = None,
delay: float = None,
loss: float = None,
duplicate: float = None,
jitter: float = None,
netif2: float = None,
devname: str = None,
) -> None:
"""
Configure link parameters by applying tc queuing disciplines on the interface.
:param netif: interface one
:param bw: bandwidth to set to
:param delay: packet delay to set to
:param loss: packet loss to set to
:param duplicate: duplicate percentage to set to
:param jitter: jitter to set to
:param netif2: interface two
:param devname: device name
:return: nothing
"""
raise NotImplementedError
class Position:
"""

View file

@ -151,6 +151,7 @@ class PhysicalNode(CoreNodeBase):
duplicate: float = None,
jitter: float = None,
netif2: CoreInterface = None,
devname: str = None,
) -> None:
"""
Apply tc queing disciplines using linkconfig.
@ -158,13 +159,7 @@ class PhysicalNode(CoreNodeBase):
linux_bridge = CoreNetwork(session=self.session, start=False)
linux_bridge.up = True
linux_bridge.linkconfig(
netif,
bw=bw,
delay=delay,
loss=loss,
duplicate=duplicate,
jitter=jitter,
netif2=netif2,
netif, bw, delay, loss, duplicate, jitter, netif2, devname
)
del linux_bridge