updates to leverage htb as the means for managing loss between more nodes, added in updates to rate configurations and delay/jitter settings
This commit is contained in:
parent
be3041c2ee
commit
914cca589a
2 changed files with 53 additions and 41 deletions
|
@ -1493,11 +1493,6 @@ class Session:
|
||||||
# initialize distributed tunnels
|
# initialize distributed tunnels
|
||||||
self.distributed.start()
|
self.distributed.start()
|
||||||
|
|
||||||
# initialize wlan loss
|
|
||||||
for node in self.nodes.values():
|
|
||||||
if isinstance(node, WlanNode):
|
|
||||||
node.initialize_loss()
|
|
||||||
|
|
||||||
# instantiate will be invoked again upon emane configure
|
# instantiate will be invoked again upon emane configure
|
||||||
if self.emane.startup() == self.emane.NOT_READY:
|
if self.emane.startup() == self.emane.NOT_READY:
|
||||||
return []
|
return []
|
||||||
|
|
|
@ -1037,6 +1037,7 @@ class WlanNode(CoreNetwork):
|
||||||
"""
|
"""
|
||||||
super().__init__(session, _id, name, start, server, policy)
|
super().__init__(session, _id, name, start, server, policy)
|
||||||
# wireless and mobility models (BasicRangeModel, Ns2WaypointMobility)
|
# wireless and mobility models (BasicRangeModel, Ns2WaypointMobility)
|
||||||
|
self.initialized = False
|
||||||
self.model = None
|
self.model = None
|
||||||
self.mobility = None
|
self.mobility = None
|
||||||
self.loss_maps = {}
|
self.loss_maps = {}
|
||||||
|
@ -1051,14 +1052,12 @@ class WlanNode(CoreNetwork):
|
||||||
super().startup()
|
super().startup()
|
||||||
self.net_client.disable_mac_learning(self.brname)
|
self.net_client.disable_mac_learning(self.brname)
|
||||||
|
|
||||||
def initialize_loss(self) -> None:
|
def _initialize_tc(self) -> None:
|
||||||
logging.info("initializing loss")
|
logging.info("setting wlan configuration: %s", self.model.bw)
|
||||||
|
|
||||||
# get band count, must be at least 3
|
# initial settings
|
||||||
self.bands = len(self.netifs())
|
self.bands = len(self.netifs())
|
||||||
if self.bands < 3:
|
self.loss_maps.clear()
|
||||||
self.bands = 3
|
|
||||||
logging.info("wlan qdisc prio with bands: %s", self.bands)
|
|
||||||
|
|
||||||
# initialize loss rules
|
# initialize loss rules
|
||||||
for netif in self.netifs():
|
for netif in self.netifs():
|
||||||
|
@ -1068,58 +1067,71 @@ class WlanNode(CoreNetwork):
|
||||||
|
|
||||||
# setup root handler for wlan interface
|
# setup root handler for wlan interface
|
||||||
self.host_cmd(
|
self.host_cmd(
|
||||||
f"tc qdisc add dev {name} root handle 1: " f"prio bands {self.bands}"
|
f"tc qdisc add dev {name} root handle 1: htb default {self.bands}"
|
||||||
)
|
)
|
||||||
|
|
||||||
# setup filter rules and qdisc for each other node
|
# setup filter rules and qdisc for each other node
|
||||||
index = 1
|
index = 2
|
||||||
for other_netif in self.netifs():
|
for other_netif in self.netifs():
|
||||||
if netif == other_netif:
|
if netif == other_netif:
|
||||||
continue
|
continue
|
||||||
other_name = other_netif.localname
|
other_name = other_netif.localname
|
||||||
logging.info("setup rules from %s to %s", name, other_name)
|
|
||||||
|
|
||||||
# initialize filter rules for all other nodes and catch all
|
|
||||||
mac = other_netif.hwaddr
|
mac = other_netif.hwaddr
|
||||||
qdisc_index = self._qdisc_index(index)
|
|
||||||
logging.info(
|
logging.info(
|
||||||
"setup filter to %s for src mac(%s) index(%s) qdisc(%s)",
|
"tc filter from(%s) to(%s) for src mac(%s) index(%s)",
|
||||||
other_name,
|
node.name,
|
||||||
|
other_netif.node.name,
|
||||||
mac,
|
mac,
|
||||||
index,
|
index,
|
||||||
qdisc_index,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# save loss map
|
# save loss map
|
||||||
loss_map = self.loss_maps.setdefault(name, {})
|
loss_map = self.loss_maps.setdefault(name, {})
|
||||||
loss_map[other_name] = index
|
loss_map[other_name] = index
|
||||||
self.host_cmd(
|
self._tc_filter(name, index, mac)
|
||||||
f"tc filter add dev {name} protocol all parent 1: "
|
|
||||||
f"prio 1 u32 match eth src {mac} flowid 1:{index}"
|
|
||||||
)
|
|
||||||
self.host_cmd(
|
|
||||||
f"tc qdisc add dev {name} parent 1:{index} "
|
|
||||||
f"handle {qdisc_index}: netem loss 0.1%"
|
|
||||||
)
|
|
||||||
index += 1
|
index += 1
|
||||||
|
|
||||||
# setup catch all
|
# setup catch all
|
||||||
self.host_cmd(
|
loss_map = self.loss_maps.setdefault(name, {})
|
||||||
f"tc filter add dev {name} protocol all parent 1: "
|
loss_map["catch"] = index
|
||||||
f"prio 0 u32 match u32 0 0 flowid 1:{index}"
|
self._tc_catch_all(name, index)
|
||||||
)
|
|
||||||
qdisc_index = self._qdisc_index(index)
|
|
||||||
self.host_cmd(
|
|
||||||
f"tc qdisc add dev {name} parent 1:{index} handle {qdisc_index}: sfq"
|
|
||||||
)
|
|
||||||
|
|
||||||
import pprint
|
import pprint
|
||||||
|
|
||||||
pretty_map = pprint.pformat(self.loss_maps, indent=4, compact=False)
|
pretty_map = pprint.pformat(self.loss_maps, indent=4, compact=False)
|
||||||
logging.info("wlan loss map:\n%s", pretty_map)
|
logging.info("wlan loss map:\n%s", pretty_map)
|
||||||
|
|
||||||
def _qdisc_index(self, index: int) -> int:
|
def _tc_update_rate(self):
|
||||||
return self.bands + index
|
for name, loss_map in self.loss_maps.items():
|
||||||
|
for index in loss_map.values():
|
||||||
|
self.host_cmd(
|
||||||
|
f"tc class change dev {name} parent 1: classid 1:{index} "
|
||||||
|
f"htb rate {self.model.bw}"
|
||||||
|
)
|
||||||
|
|
||||||
|
def _tc_catch_all(self, name: str, index: int) -> None:
|
||||||
|
self.host_cmd(
|
||||||
|
f"tc class add dev {name} parent 1: classid 1:{index} "
|
||||||
|
f"htb rate {self.model.bw}"
|
||||||
|
)
|
||||||
|
self.host_cmd(
|
||||||
|
f"tc filter add dev {name} protocol all parent 1: "
|
||||||
|
f"prio 0 u32 match u32 0 0 flowid 1:{index}"
|
||||||
|
)
|
||||||
|
self.host_cmd(f"tc qdisc add dev {name} parent 1:{index} handle {index}: sfq")
|
||||||
|
|
||||||
|
def _tc_filter(self, name: str, index: int, mac: str) -> None:
|
||||||
|
self.host_cmd(
|
||||||
|
f"tc class add dev {name} parent 1: classid 1:{index} "
|
||||||
|
f"htb rate {self.model.bw}"
|
||||||
|
)
|
||||||
|
self.host_cmd(
|
||||||
|
f"tc filter add dev {name} protocol all parent 1: "
|
||||||
|
f"prio 1 u32 match eth src {mac} flowid 1:{index}"
|
||||||
|
)
|
||||||
|
self.host_cmd(
|
||||||
|
f"tc qdisc add dev {name} parent 1:{index} "
|
||||||
|
f"handle {index}: netem loss 0.01%"
|
||||||
|
)
|
||||||
|
|
||||||
def change_loss(
|
def change_loss(
|
||||||
self, netif: CoreInterface, netif2: CoreInterface, loss: float
|
self, netif: CoreInterface, netif2: CoreInterface, loss: float
|
||||||
|
@ -1127,10 +1139,10 @@ class WlanNode(CoreNetwork):
|
||||||
name = netif.localname
|
name = netif.localname
|
||||||
other_name = netif2.localname
|
other_name = netif2.localname
|
||||||
index = self.loss_maps[name][other_name]
|
index = self.loss_maps[name][other_name]
|
||||||
qdisc_index = self._qdisc_index(index)
|
|
||||||
self.host_cmd(
|
self.host_cmd(
|
||||||
f"tc qdisc change dev {name} parent 1:{index}"
|
f"tc qdisc change dev {name} parent 1:{index}"
|
||||||
f" handle {qdisc_index}: netem loss {loss}%"
|
f" handle {index}: netem loss {loss}%"
|
||||||
|
f" delay {self.model.delay}us {self.model.jitter}us 25%"
|
||||||
)
|
)
|
||||||
|
|
||||||
def attach(self, netif: CoreInterface) -> None:
|
def attach(self, netif: CoreInterface) -> None:
|
||||||
|
@ -1176,6 +1188,11 @@ class WlanNode(CoreNetwork):
|
||||||
"node(%s) updating model(%s): %s", self.id, self.model.name, config
|
"node(%s) updating model(%s): %s", self.id, self.model.name, config
|
||||||
)
|
)
|
||||||
self.model.update_config(config)
|
self.model.update_config(config)
|
||||||
|
if not self.initialized:
|
||||||
|
self.initialized = True
|
||||||
|
self._initialize_tc()
|
||||||
|
else:
|
||||||
|
self._tc_update_rate()
|
||||||
for netif in self.netifs():
|
for netif in self.netifs():
|
||||||
netif.setposition()
|
netif.setposition()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue