daemon: added link option to configure buffer, added support in pygui to allow configuring buffer

This commit is contained in:
Blake Harnden 2020-11-30 16:49:44 -08:00
parent d95c2ec05f
commit a35e91aeba
8 changed files with 68 additions and 5 deletions

View file

@ -49,12 +49,14 @@ class LinkConfigurationDialog(Dialog):
self.jitter: tk.StringVar = tk.StringVar()
self.loss: tk.StringVar = tk.StringVar()
self.duplicate: tk.StringVar = tk.StringVar()
self.buffer: tk.StringVar = tk.StringVar()
self.down_bandwidth: tk.StringVar = tk.StringVar()
self.down_delay: tk.StringVar = tk.StringVar()
self.down_jitter: tk.StringVar = tk.StringVar()
self.down_loss: tk.StringVar = tk.StringVar()
self.down_duplicate: tk.StringVar = tk.StringVar()
self.down_buffer: tk.StringVar = tk.StringVar()
self.color: tk.StringVar = tk.StringVar(value=self.edge.color)
self.color_button: Optional[tk.Button] = None
@ -187,6 +189,19 @@ class LinkConfigurationDialog(Dialog):
entry.grid(row=row, column=2, sticky=tk.EW, pady=PADY)
row = row + 1
label = ttk.Label(frame, text="Buffer (Packets)")
label.grid(row=row, column=0, sticky=tk.EW)
entry = validation.PositiveIntEntry(
frame, empty_enabled=False, textvariable=self.buffer
)
entry.grid(row=row, column=1, sticky=tk.EW, pady=PADY)
if not self.is_symmetric:
entry = validation.PositiveIntEntry(
frame, empty_enabled=False, textvariable=self.down_buffer
)
entry.grid(row=row, column=2, sticky=tk.EW, pady=PADY)
row = row + 1
label = ttk.Label(frame, text="Color")
label.grid(row=row, column=0, sticky=tk.EW)
self.color_button = tk.Button(
@ -224,9 +239,15 @@ class LinkConfigurationDialog(Dialog):
jitter = get_int(self.jitter)
delay = get_int(self.delay)
duplicate = get_int(self.duplicate)
buffer = get_int(self.buffer)
loss = get_float(self.loss)
options = LinkOptions(
bandwidth=bandwidth, jitter=jitter, delay=delay, dup=duplicate, loss=loss
bandwidth=bandwidth,
jitter=jitter,
delay=delay,
dup=duplicate,
loss=loss,
buffer=buffer,
)
link.options = options
iface1_id = link.iface1.id if link.iface1 else None
@ -243,6 +264,7 @@ class LinkConfigurationDialog(Dialog):
down_jitter = get_int(self.down_jitter)
down_delay = get_int(self.down_delay)
down_duplicate = get_int(self.down_duplicate)
down_buffer = get_int(self.down_buffer)
down_loss = get_float(self.down_loss)
options = LinkOptions(
bandwidth=down_bandwidth,
@ -250,6 +272,7 @@ class LinkConfigurationDialog(Dialog):
delay=down_delay,
dup=down_duplicate,
loss=down_loss,
buffer=down_buffer,
unidirectional=True,
)
self.edge.asymmetric_link = Link(
@ -304,6 +327,7 @@ class LinkConfigurationDialog(Dialog):
self.duplicate.set(str(link.options.dup))
self.loss.set(str(link.options.loss))
self.delay.set(str(link.options.delay))
self.buffer.set(str(link.options.buffer))
if not self.is_symmetric:
asym_link = self.edge.asymmetric_link
self.down_bandwidth.set(str(asym_link.options.bandwidth))
@ -311,3 +335,4 @@ class LinkConfigurationDialog(Dialog):
self.down_duplicate.set(str(asym_link.options.dup))
self.down_loss.set(str(asym_link.options.loss))
self.down_delay.set(str(asym_link.options.delay))
self.down_buffer.set(str(asym_link.options.buffer))