moved linkconfig to CoreNetworkBase and made linkconfig defined the same across the board
This commit is contained in:
parent
fe09b37819
commit
dd13bc8379
7 changed files with 44 additions and 37 deletions
|
@ -121,6 +121,7 @@ class EmaneCommEffectModel(emanemodel.EmaneModel):
|
||||||
duplicate: float = None,
|
duplicate: float = None,
|
||||||
jitter: float = None,
|
jitter: float = None,
|
||||||
netif2: CoreInterface = None,
|
netif2: CoreInterface = None,
|
||||||
|
devname: str = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Generate CommEffect events when a Link Message is received having
|
Generate CommEffect events when a Link Message is received having
|
||||||
|
|
|
@ -163,6 +163,7 @@ class EmaneModel(WirelessModel):
|
||||||
duplicate: float = None,
|
duplicate: float = None,
|
||||||
jitter: float = None,
|
jitter: float = None,
|
||||||
netif2: CoreInterface = None,
|
netif2: CoreInterface = None,
|
||||||
|
devname: str = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Invoked when a Link Message is received. Default is unimplemented.
|
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 duplicate: duplicate percentage to set to
|
||||||
:param jitter: jitter to set to
|
:param jitter: jitter to set to
|
||||||
:param netif2: interface two
|
:param netif2: interface two
|
||||||
|
:param devname: device name
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
logging.warning(
|
logging.warning(
|
||||||
|
|
|
@ -62,6 +62,7 @@ class EmaneNet(CoreNetworkBase):
|
||||||
duplicate: float = None,
|
duplicate: float = None,
|
||||||
jitter: float = None,
|
jitter: float = None,
|
||||||
netif2: CoreInterface = None,
|
netif2: CoreInterface = None,
|
||||||
|
devname: str = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
The CommEffect model supports link configuration.
|
The CommEffect model supports link configuration.
|
||||||
|
@ -69,13 +70,7 @@ class EmaneNet(CoreNetworkBase):
|
||||||
if not self.model:
|
if not self.model:
|
||||||
return
|
return
|
||||||
self.model.linkconfig(
|
self.model.linkconfig(
|
||||||
netif=netif,
|
netif, bw, delay, loss, duplicate, jitter, netif2, devname
|
||||||
bw=bw,
|
|
||||||
delay=delay,
|
|
||||||
loss=loss,
|
|
||||||
duplicate=duplicate,
|
|
||||||
jitter=jitter,
|
|
||||||
netif2=netif2,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def config(self, conf: str) -> None:
|
def config(self, conf: str) -> None:
|
||||||
|
|
|
@ -4,7 +4,6 @@ import netaddr
|
||||||
|
|
||||||
from core import utils
|
from core import utils
|
||||||
from core.api.grpc.core_pb2 import LinkOptions
|
from core.api.grpc.core_pb2 import LinkOptions
|
||||||
from core.emane.nodes import EmaneNet
|
|
||||||
from core.emulator.enumerations import LinkTypes
|
from core.emulator.enumerations import LinkTypes
|
||||||
from core.nodes.base import CoreNetworkBase, CoreNode
|
from core.nodes.base import CoreNetworkBase, CoreNode
|
||||||
from core.nodes.interface import CoreInterface
|
from core.nodes.interface import CoreInterface
|
||||||
|
@ -37,22 +36,16 @@ def link_config(
|
||||||
:param interface_two: other interface associated, default is None
|
:param interface_two: other interface associated, default is None
|
||||||
:return: nothing
|
:return: nothing
|
||||||
"""
|
"""
|
||||||
config = {
|
node.linkconfig(
|
||||||
"netif": interface,
|
interface,
|
||||||
"bw": link_options.bandwidth,
|
link_options.bandwidth,
|
||||||
"delay": link_options.delay,
|
link_options.delay,
|
||||||
"loss": link_options.per,
|
link_options.per,
|
||||||
"duplicate": link_options.dup,
|
link_options.dup,
|
||||||
"jitter": link_options.jitter,
|
link_options.jitter,
|
||||||
"netif2": interface_two,
|
interface_two,
|
||||||
}
|
devname,
|
||||||
|
)
|
||||||
# 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)
|
|
||||||
|
|
||||||
|
|
||||||
class NodeOptions:
|
class NodeOptions:
|
||||||
|
|
|
@ -335,12 +335,7 @@ class BasicRangeModel(WirelessModel):
|
||||||
with self._netifslock:
|
with self._netifslock:
|
||||||
for netif in self._netifs:
|
for netif in self._netifs:
|
||||||
self.wlan.linkconfig(
|
self.wlan.linkconfig(
|
||||||
netif,
|
netif, self.bw, self.delay, self.loss, jitter=self.jitter
|
||||||
bw=self.bw,
|
|
||||||
delay=self.delay,
|
|
||||||
loss=self.loss,
|
|
||||||
duplicate=None,
|
|
||||||
jitter=self.jitter,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def get_position(self, netif: CoreInterface) -> Tuple[float, float, float]:
|
def get_position(self, netif: CoreInterface) -> Tuple[float, float, float]:
|
||||||
|
|
|
@ -1165,6 +1165,32 @@ class CoreNetworkBase(NodeBase):
|
||||||
|
|
||||||
return all_links
|
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:
|
class Position:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -151,6 +151,7 @@ class PhysicalNode(CoreNodeBase):
|
||||||
duplicate: float = None,
|
duplicate: float = None,
|
||||||
jitter: float = None,
|
jitter: float = None,
|
||||||
netif2: CoreInterface = None,
|
netif2: CoreInterface = None,
|
||||||
|
devname: str = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Apply tc queing disciplines using linkconfig.
|
Apply tc queing disciplines using linkconfig.
|
||||||
|
@ -158,13 +159,7 @@ class PhysicalNode(CoreNodeBase):
|
||||||
linux_bridge = CoreNetwork(session=self.session, start=False)
|
linux_bridge = CoreNetwork(session=self.session, start=False)
|
||||||
linux_bridge.up = True
|
linux_bridge.up = True
|
||||||
linux_bridge.linkconfig(
|
linux_bridge.linkconfig(
|
||||||
netif,
|
netif, bw, delay, loss, duplicate, jitter, netif2, devname
|
||||||
bw=bw,
|
|
||||||
delay=delay,
|
|
||||||
loss=loss,
|
|
||||||
duplicate=duplicate,
|
|
||||||
jitter=jitter,
|
|
||||||
netif2=netif2,
|
|
||||||
)
|
)
|
||||||
del linux_bridge
|
del linux_bridge
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue