def draw_link_options(self): options = self.link.options lines = [] bandwidth = options.bandwidth if bandwidth > 0: lines.append(bandwidth_text(bandwidth)) delay = options.delay jitter = options.jitter if delay > 0 and jitter > 0: lines.append(f"{delay} us (\u00B1{jitter} us)") elif jitter > 0: lines.append(f"0 us (\u00B1{jitter} us)") loss = options.loss if loss > 0: lines.append(f"loss={loss}%") dup = options.dup if dup > 0: lines.append(f"dup={dup}%") label = "\n".join(lines) self.middle_label_text(label)
def draw(self) -> None: self.columnconfigure(0, weight=1) link = self.edge.link options = link.options src_canvas_node = self.app.core.canvas_nodes[link.node1_id] src_node = src_canvas_node.core_node dst_canvas_node = self.app.core.canvas_nodes[link.node2_id] dst_node = dst_canvas_node.core_node frame = DetailsFrame(self) frame.grid(sticky="ew") frame.add_detail("Source", src_node.name) iface1 = link.iface1 if iface1: mac = iface1.mac if iface1.mac else "auto" frame.add_detail("MAC", mac) ip4 = f"{iface1.ip4}/{iface1.ip4_mask}" if iface1.ip4 else "" frame.add_detail("IP4", ip4) ip6 = f"{iface1.ip6}/{iface1.ip6_mask}" if iface1.ip6 else "" frame.add_detail("IP6", ip6) frame.add_separator() frame.add_detail("Destination", dst_node.name) iface2 = link.iface2 if iface2: mac = iface2.mac if iface2.mac else "auto" frame.add_detail("MAC", mac) ip4 = f"{iface2.ip4}/{iface2.ip4_mask}" if iface2.ip4 else "" frame.add_detail("IP4", ip4) ip6 = f"{iface2.ip6}/{iface2.ip6_mask}" if iface2.ip6 else "" frame.add_detail("IP6", ip6) if link.HasField("options"): frame.add_separator() bandwidth = bandwidth_text(options.bandwidth) frame.add_detail("Bandwidth", bandwidth) frame.add_detail("Delay", f"{options.delay} us") frame.add_detail("Jitter", f"\u00B1{options.jitter} us") frame.add_detail("Loss", f"{options.loss}%") frame.add_detail("Duplicate", f"{options.dup}%")
def draw_link_options(self): if not self.link.options: return options = self.link.options asym_options = None if self.asymmetric_link and self.asymmetric_link.options: asym_options = self.asymmetric_link.options lines = [] # bandwidth if options.bandwidth > 0: bandwidth_line = bandwidth_text(options.bandwidth) if asym_options and asym_options.bandwidth > 0: bandwidth_line += f" / {bandwidth_text(asym_options.bandwidth)}" lines.append(bandwidth_line) # delay/jitter dj_line = delay_jitter_text(options.delay, options.jitter) if dj_line and asym_options: asym_dj_line = delay_jitter_text(asym_options.delay, asym_options.jitter) if asym_dj_line: dj_line += f" / {asym_dj_line}" if dj_line: lines.append(dj_line) # loss if options.loss > 0: loss_line = f"loss={options.loss}%" if asym_options and asym_options.loss > 0: loss_line += f" / loss={asym_options.loss}%" lines.append(loss_line) # duplicate if options.dup > 0: dup_line = f"dup={options.dup}%" if asym_options and asym_options.dup > 0: dup_line += f" / dup={asym_options.dup}%" lines.append(dup_line) label = "\n".join(lines) self.middle_label_text(label)