spongebob-cli 0.3.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- spongebob/__init__.py +1 -0
- spongebob/__main__.py +375 -0
- spongebob/analyzer/__init__.py +9 -0
- spongebob/analyzer/__main__.py +39 -0
- spongebob/analyzer/analyzer.py +234 -0
- spongebob/bus/__init__.py +6 -0
- spongebob/bus/bus.py +38 -0
- spongebob/diagnose/__init__.py +29 -0
- spongebob/diagnose/__main__.py +111 -0
- spongebob/diagnose/adapter.py +82 -0
- spongebob/diagnose/models.py +79 -0
- spongebob/diagnose/probes.py +129 -0
- spongebob/engine/__init__.py +26 -0
- spongebob/engine/__main__.py +25 -0
- spongebob/engine/models.py +161 -0
- spongebob/engine/simulator.py +196 -0
- spongebob/export/__init__.py +25 -0
- spongebob/export/exporter.py +354 -0
- spongebob/meter/__init__.py +7 -0
- spongebob/meter/__main__.py +50 -0
- spongebob/meter/meter.py +140 -0
- spongebob/narrator/__init__.py +25 -0
- spongebob/narrator/narrator.py +352 -0
- spongebob/plugins/__init__.py +28 -0
- spongebob/plugins/loader.py +308 -0
- spongebob/plugins/models.py +47 -0
- spongebob/scenarios/__init__.py +25 -0
- spongebob/scenarios/builtin/__init__.py +1 -0
- spongebob/scenarios/builtin/control-line.toml +33 -0
- spongebob/scenarios/builtin/crowded-wifi.toml +33 -0
- spongebob/scenarios/builtin/flaky-last-mile.toml +33 -0
- spongebob/scenarios/builtin/long-haul-orbit.toml +33 -0
- spongebob/scenarios/builtin/overloaded-uplink.toml +35 -0
- spongebob/scenarios/builtin/tunnel-burst.toml +38 -0
- spongebob/scenarios/loader.py +205 -0
- spongebob/scenarios/models.py +55 -0
- spongebob/scenarios/runner.py +24 -0
- spongebob/ui/__init__.py +23 -0
- spongebob/ui/__main__.py +11 -0
- spongebob/ui/app.py +88 -0
- spongebob/ui/canvas.py +147 -0
- spongebob/ui/diagnose_screen.py +525 -0
- spongebob/ui/export_modal.py +158 -0
- spongebob/ui/menu_screen.py +159 -0
- spongebob/ui/replay.py +209 -0
- spongebob/ui/settings_screen.py +101 -0
- spongebob/ui/simulate_screen.py +566 -0
- spongebob/ui/theme.py +364 -0
- spongebob/ui/visualize_screen.py +411 -0
- spongebob_cli-0.3.2.dist-info/METADATA +78 -0
- spongebob_cli-0.3.2.dist-info/RECORD +54 -0
- spongebob_cli-0.3.2.dist-info/WHEEL +5 -0
- spongebob_cli-0.3.2.dist-info/entry_points.txt +2 -0
- spongebob_cli-0.3.2.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,411 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import Sequence
|
|
4
|
+
|
|
5
|
+
from rich.style import Style
|
|
6
|
+
from rich.text import Text
|
|
7
|
+
from textual.app import ComposeResult
|
|
8
|
+
from textual.binding import Binding
|
|
9
|
+
from textual.containers import Horizontal, Vertical
|
|
10
|
+
from textual.screen import Screen
|
|
11
|
+
from textual.timer import Timer
|
|
12
|
+
from textual.widgets import Footer, Static
|
|
13
|
+
|
|
14
|
+
from spongebob.analyzer import Finding, LatencyKind
|
|
15
|
+
from spongebob.bus import EventBus
|
|
16
|
+
from spongebob.engine.models import Event, Hop
|
|
17
|
+
from spongebob.narrator import MASCOT_NAME, Line
|
|
18
|
+
from spongebob.ui import theme
|
|
19
|
+
from spongebob.ui.canvas import BrailleCanvas, detect_truecolor
|
|
20
|
+
from spongebob.ui.replay import compute_replay_state, select_pulse_target
|
|
21
|
+
|
|
22
|
+
MIN_WIDTH = 50
|
|
23
|
+
MIN_HEIGHT = 16
|
|
24
|
+
SPEED_STEPS = (0.25, 0.5, 1.0, 2.0, 4.0, 8.0)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class VisualizeScreen(Screen[None]):
|
|
28
|
+
"""Full-terminal living-pipe visualizer replaying events via EventBus."""
|
|
29
|
+
|
|
30
|
+
BINDINGS = [
|
|
31
|
+
Binding("escape", "go_back", "Back"),
|
|
32
|
+
Binding("space", "toggle_pause", "Pause/Resume"),
|
|
33
|
+
Binding("plus", "speed_up", "Speed +"),
|
|
34
|
+
Binding("equal", "speed_up", "Speed +", show=False),
|
|
35
|
+
Binding("minus", "speed_down", "Speed -"),
|
|
36
|
+
Binding("r", "restart", "Restart"),
|
|
37
|
+
Binding("p", "trigger_pulse", "Pulse"),
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
CSS = f"""
|
|
41
|
+
VisualizeScreen {{
|
|
42
|
+
layout: vertical;
|
|
43
|
+
background: {theme.BG};
|
|
44
|
+
color: {theme.CREAM};
|
|
45
|
+
}}
|
|
46
|
+
#viz-main {{
|
|
47
|
+
height: 1fr;
|
|
48
|
+
}}
|
|
49
|
+
#pipe-pane {{
|
|
50
|
+
width: 1fr;
|
|
51
|
+
height: 1fr;
|
|
52
|
+
padding: 0 1;
|
|
53
|
+
background: {theme.BG};
|
|
54
|
+
border: solid {theme.SIGNAL_GREEN};
|
|
55
|
+
}}
|
|
56
|
+
#side-readout {{
|
|
57
|
+
width: 32;
|
|
58
|
+
height: 1fr;
|
|
59
|
+
padding: 0 1;
|
|
60
|
+
border: solid {theme.SIGNAL_GREEN};
|
|
61
|
+
background: {theme.BG};
|
|
62
|
+
margin-left: 1;
|
|
63
|
+
}}
|
|
64
|
+
#readout-title {{
|
|
65
|
+
color: {theme.SIGNAL_GREEN};
|
|
66
|
+
text-style: bold;
|
|
67
|
+
}}
|
|
68
|
+
#readout-text {{
|
|
69
|
+
color: {theme.CREAM};
|
|
70
|
+
}}
|
|
71
|
+
#too-small {{
|
|
72
|
+
width: 100%;
|
|
73
|
+
height: 1fr;
|
|
74
|
+
content-align: center middle;
|
|
75
|
+
color: {theme.WARN_AMBER};
|
|
76
|
+
text-style: bold;
|
|
77
|
+
display: none;
|
|
78
|
+
}}
|
|
79
|
+
"""
|
|
80
|
+
|
|
81
|
+
def __init__(
|
|
82
|
+
self,
|
|
83
|
+
path: Sequence[Hop],
|
|
84
|
+
events: Sequence[Event],
|
|
85
|
+
findings: Sequence[Finding],
|
|
86
|
+
narrator_lines: Sequence[Line] = (),
|
|
87
|
+
narrator_enabled: bool = True,
|
|
88
|
+
latency_kind: LatencyKind = "one_way",
|
|
89
|
+
) -> None:
|
|
90
|
+
super().__init__()
|
|
91
|
+
self._path = list(path)
|
|
92
|
+
self._hop_names = [h.name for h in self._path]
|
|
93
|
+
self._events = list(events)
|
|
94
|
+
self._findings = list(findings)
|
|
95
|
+
self._narrator_lines = list(narrator_lines)
|
|
96
|
+
self._narrator_enabled = narrator_enabled
|
|
97
|
+
self._latency_kind: LatencyKind = latency_kind
|
|
98
|
+
self._max_time_ms = max((e.time_ms for e in self._events), default=0.0)
|
|
99
|
+
self._pulse_target = select_pulse_target(self._findings, self._hop_names)
|
|
100
|
+
self._truecolor = detect_truecolor()
|
|
101
|
+
|
|
102
|
+
self._bus = EventBus()
|
|
103
|
+
self._replayed_events: list[Event] = []
|
|
104
|
+
self._next_event_idx = 0
|
|
105
|
+
|
|
106
|
+
self._t_ms = 0.0
|
|
107
|
+
self._paused = False
|
|
108
|
+
self._speed_idx = 2 # 1.0x
|
|
109
|
+
self._pulse_active = False
|
|
110
|
+
self._pulse_x = 0.0
|
|
111
|
+
self._pulse_ticks = 0
|
|
112
|
+
self._canvas: BrailleCanvas | None = None
|
|
113
|
+
self._timer: Timer | None = None
|
|
114
|
+
|
|
115
|
+
def compose(self) -> ComposeResult:
|
|
116
|
+
yield theme.make_top_title("VISUALIZE")
|
|
117
|
+
yield theme.RedTopRule(id="viz-red-rule", classes="red-rule")
|
|
118
|
+
banner_label = (
|
|
119
|
+
"VISUALIZE — LIVE RTT PIPE"
|
|
120
|
+
if self._latency_kind == "rtt"
|
|
121
|
+
else "VISUALIZE — LIVE SIMULATION PIPE"
|
|
122
|
+
)
|
|
123
|
+
yield Static(banner_label, classes="screen-banner")
|
|
124
|
+
yield Static("Enlarge terminal (minimum 50x16 required).", id="too-small")
|
|
125
|
+
with Horizontal(id="viz-main"):
|
|
126
|
+
yield Static("", id="pipe-pane")
|
|
127
|
+
with Vertical(id="side-readout"):
|
|
128
|
+
yield Static("LIVE TELEMETRY", id="readout-title")
|
|
129
|
+
yield Static("", id="readout-text")
|
|
130
|
+
yield Static(theme.format_status_line("REPLAY READY", 0.0), id="viz-status", classes="status-bar")
|
|
131
|
+
yield Footer()
|
|
132
|
+
|
|
133
|
+
def on_mount(self) -> None:
|
|
134
|
+
self._reset_bus()
|
|
135
|
+
self._timer = self.set_interval(1.0 / 30.0, self._on_tick)
|
|
136
|
+
self._check_size_and_render()
|
|
137
|
+
|
|
138
|
+
def on_resize(self) -> None:
|
|
139
|
+
self._canvas = None
|
|
140
|
+
self._check_size_and_render()
|
|
141
|
+
|
|
142
|
+
def _reset_bus(self) -> None:
|
|
143
|
+
self._bus = EventBus()
|
|
144
|
+
self._replayed_events = []
|
|
145
|
+
self._next_event_idx = 0
|
|
146
|
+
self._bus.subscribe("*", lambda ev: self._replayed_events.append(ev))
|
|
147
|
+
|
|
148
|
+
def _advance_bus_to(self, t_ms: float) -> None:
|
|
149
|
+
while (
|
|
150
|
+
self._next_event_idx < len(self._events)
|
|
151
|
+
and self._events[self._next_event_idx].time_ms <= t_ms
|
|
152
|
+
):
|
|
153
|
+
self._bus.publish(self._events[self._next_event_idx])
|
|
154
|
+
self._next_event_idx += 1
|
|
155
|
+
|
|
156
|
+
def _on_tick(self) -> None:
|
|
157
|
+
if not self._paused:
|
|
158
|
+
speed = SPEED_STEPS[self._speed_idx]
|
|
159
|
+
dt_ms = (1000.0 / 30.0) * speed
|
|
160
|
+
if self._t_ms < self._max_time_ms:
|
|
161
|
+
self._t_ms = min(self._max_time_ms, self._t_ms + dt_ms)
|
|
162
|
+
self._advance_bus_to(self._t_ms)
|
|
163
|
+
if self._t_ms >= self._max_time_ms:
|
|
164
|
+
self._pulse_active = True
|
|
165
|
+
self._pulse_x = 0.0
|
|
166
|
+
self._pulse_ticks = 0
|
|
167
|
+
elif self._pulse_active:
|
|
168
|
+
self._pulse_ticks += 1
|
|
169
|
+
target_x = (
|
|
170
|
+
(self._pulse_target.hop_index + 0.5) / max(1, len(self._hop_names))
|
|
171
|
+
if self._pulse_target.hop_index is not None
|
|
172
|
+
else 1.0
|
|
173
|
+
)
|
|
174
|
+
if self._pulse_x < target_x:
|
|
175
|
+
self._pulse_x = min(target_x, self._pulse_x + 0.03)
|
|
176
|
+
self._check_size_and_render()
|
|
177
|
+
|
|
178
|
+
def _check_size_and_render(self) -> None:
|
|
179
|
+
w, h = self.size.width, self.size.height
|
|
180
|
+
too_small = self.query_one("#too-small", Static)
|
|
181
|
+
viz_main = self.query_one("#viz-main", Horizontal)
|
|
182
|
+
if w < MIN_WIDTH or h < MIN_HEIGHT:
|
|
183
|
+
too_small.styles.display = "block"
|
|
184
|
+
viz_main.styles.display = "none"
|
|
185
|
+
return
|
|
186
|
+
too_small.styles.display = "none"
|
|
187
|
+
viz_main.styles.display = "block"
|
|
188
|
+
self._render_frame()
|
|
189
|
+
|
|
190
|
+
def _update_red_rule(self) -> None:
|
|
191
|
+
rule_widget = self.query_one("#viz-red-rule", theme.RedTopRule)
|
|
192
|
+
w = max(20, rule_widget.size.width or 80)
|
|
193
|
+
if self._pulse_active:
|
|
194
|
+
marker_pos = max(0, min(w - 1, int(self._pulse_x * (w - 1))))
|
|
195
|
+
chars = ["━"] * w
|
|
196
|
+
chars[marker_pos] = "▼"
|
|
197
|
+
rule_widget.update("".join(chars))
|
|
198
|
+
else:
|
|
199
|
+
rule_widget.update("━" * w)
|
|
200
|
+
|
|
201
|
+
def _render_frame(self) -> None:
|
|
202
|
+
self._update_red_rule()
|
|
203
|
+
pipe_pane = self.query_one("#pipe-pane", Static)
|
|
204
|
+
cols = max(16, pipe_pane.size.width - 4)
|
|
205
|
+
rows = max(8, pipe_pane.size.height - 5)
|
|
206
|
+
if cols < 16 or rows < 8:
|
|
207
|
+
return
|
|
208
|
+
|
|
209
|
+
if self._canvas is None or self._canvas.cols != cols or self._canvas.rows != rows:
|
|
210
|
+
self._canvas = BrailleCanvas(cols, rows)
|
|
211
|
+
|
|
212
|
+
canvas = self._canvas
|
|
213
|
+
canvas.fade(0.72)
|
|
214
|
+
|
|
215
|
+
pw = canvas.pixel_width
|
|
216
|
+
ph = canvas.pixel_height
|
|
217
|
+
mid_y = ph // 2
|
|
218
|
+
pipe_half = max(4, ph // 5)
|
|
219
|
+
num_hops = max(1, len(self._path))
|
|
220
|
+
|
|
221
|
+
state = compute_replay_state(self._replayed_events, self._hop_names, self._t_ms)
|
|
222
|
+
is_rtt = self._latency_kind == "rtt"
|
|
223
|
+
|
|
224
|
+
# Deterministic signal-band stripe field inside the pipe
|
|
225
|
+
band_rows = theme.generate_signal_bands(max(1, pw - 4), 5, seed=42)
|
|
226
|
+
for b_idx, b_row in enumerate(band_rows):
|
|
227
|
+
by = mid_y - 2 + b_idx
|
|
228
|
+
if 1 <= by < ph - 1:
|
|
229
|
+
for x_off, (ch, rgb) in enumerate(b_row):
|
|
230
|
+
if ch != " " and x_off % 3 == 0:
|
|
231
|
+
dim_rgb = (rgb[0] // 3, rgb[1] // 3, rgb[2] // 3)
|
|
232
|
+
canvas.set_pixel(2 + x_off, by, dim_rgb)
|
|
233
|
+
|
|
234
|
+
# Draw living pipe walls (narrowing at bandwidth-capped hops in simulation mode)
|
|
235
|
+
for x in range(2, pw - 2):
|
|
236
|
+
x_norm = x / max(1, pw - 1)
|
|
237
|
+
hop_idx = min(num_hops - 1, int(x_norm * num_hops))
|
|
238
|
+
hop = self._path[hop_idx]
|
|
239
|
+
show_bw = (not is_rtt) and (hop.bandwidth_kbps is not None)
|
|
240
|
+
half_h = max(2, pipe_half // 2) if show_bw else pipe_half
|
|
241
|
+
wall_color = theme.WARN_AMBER_RGB if show_bw else theme.SIGNAL_GREEN_RGB
|
|
242
|
+
canvas.set_pixel(x, mid_y - half_h, wall_color)
|
|
243
|
+
canvas.set_pixel(x, mid_y + half_h, wall_color)
|
|
244
|
+
|
|
245
|
+
# Draw hop nodes and queued packet stacks
|
|
246
|
+
for i, hop in enumerate(self._path):
|
|
247
|
+
hx = int(((i + 0.5) / num_hops) * (pw - 6)) + 3
|
|
248
|
+
node_color = theme.TEAL_LIGHT_RGB
|
|
249
|
+
if (
|
|
250
|
+
self._pulse_active
|
|
251
|
+
and not self._pulse_target.all_clear
|
|
252
|
+
and self._pulse_target.hop_index == i
|
|
253
|
+
and self._pulse_ticks % 6 < 3
|
|
254
|
+
):
|
|
255
|
+
node_color = theme.CRIT_RED_RGB
|
|
256
|
+
canvas.draw_circle(hx, mid_y, 2, node_color)
|
|
257
|
+
|
|
258
|
+
if not is_rtt:
|
|
259
|
+
q_depth = state.queue_depths.get(hop.name, 0)
|
|
260
|
+
for q in range(min(q_depth, 8)):
|
|
261
|
+
qx = max(2, hx - 4 - (q * 2))
|
|
262
|
+
qy = mid_y - pipe_half - 2 - (q % 3)
|
|
263
|
+
canvas.set_pixel(qx, qy, theme.WARN_AMBER_RGB)
|
|
264
|
+
|
|
265
|
+
# Draw moving packet particles
|
|
266
|
+
for p in state.particles:
|
|
267
|
+
px = int(p.x_norm * (pw - 6)) + 3
|
|
268
|
+
py = int(mid_y + p.jitter_offset * 4)
|
|
269
|
+
canvas.draw_circle(px, py, 1, theme.CREAM_RGB)
|
|
270
|
+
canvas.set_pixel(px - 2, py, theme.TEAL_MID_RGB)
|
|
271
|
+
|
|
272
|
+
# Draw drop effects distinct by reason
|
|
273
|
+
for d in state.drops:
|
|
274
|
+
hx = int(((d.hop_index + 0.5) / num_hops) * (pw - 6)) + 3
|
|
275
|
+
spread = int((d.age_ms / 220.0) * 6) + 1
|
|
276
|
+
if d.reason == "timeout":
|
|
277
|
+
# Silent fade-out with no shatter: reads as "never came back"
|
|
278
|
+
fade = max(0.0, 1.0 - (d.age_ms / 220.0))
|
|
279
|
+
color = (
|
|
280
|
+
int(theme.TEAL_MID_RGB[0] * fade + theme.BG_RGB[0]),
|
|
281
|
+
int(theme.TEAL_MID_RGB[1] * fade + theme.BG_RGB[1]),
|
|
282
|
+
int(theme.TEAL_MID_RGB[2] * fade + theme.BG_RGB[2]),
|
|
283
|
+
)
|
|
284
|
+
canvas.set_pixel(hx, mid_y, color)
|
|
285
|
+
canvas.set_pixel(hx + 1, mid_y, color)
|
|
286
|
+
elif d.reason == "queue_full":
|
|
287
|
+
color = theme.CRIT_RED_RGB
|
|
288
|
+
for s in range(1, spread + 1):
|
|
289
|
+
canvas.set_pixel(hx - s, mid_y - s, color)
|
|
290
|
+
canvas.set_pixel(hx + s, mid_y - s, color)
|
|
291
|
+
elif d.reason == "burst":
|
|
292
|
+
color = theme.RED_RULE_RGB
|
|
293
|
+
for s in range(-spread, spread + 1):
|
|
294
|
+
canvas.set_pixel(hx, mid_y + s, color)
|
|
295
|
+
else:
|
|
296
|
+
color = theme.WARN_AMBER_RGB
|
|
297
|
+
canvas.set_pixel(hx - spread, mid_y - spread, color)
|
|
298
|
+
canvas.set_pixel(hx + spread, mid_y + spread, color)
|
|
299
|
+
canvas.set_pixel(hx - spread, mid_y + spread, color)
|
|
300
|
+
canvas.set_pixel(hx + spread, mid_y - spread, color)
|
|
301
|
+
|
|
302
|
+
# Draw diagnostic pulse wave
|
|
303
|
+
if self._pulse_active:
|
|
304
|
+
pulse_px = int(self._pulse_x * (pw - 6)) + 3
|
|
305
|
+
pulse_color = theme.TEAL_LIGHT_RGB if self._pulse_target.all_clear else theme.RED_RULE_RGB
|
|
306
|
+
canvas.draw_line(pulse_px, 1, pulse_px, ph - 2, pulse_color)
|
|
307
|
+
|
|
308
|
+
rich_text = Text()
|
|
309
|
+
# Hop name labels aligned along the pipe
|
|
310
|
+
label_row = [" "] * cols
|
|
311
|
+
for i, name in enumerate(self._hop_names):
|
|
312
|
+
cx = int(((i + 0.5) / num_hops) * cols)
|
|
313
|
+
tag = name.upper()[: max(3, cols // max(1, num_hops) - 1)]
|
|
314
|
+
start_c = max(0, min(cols - len(tag), cx - len(tag) // 2))
|
|
315
|
+
for idx_c, ch in enumerate(tag):
|
|
316
|
+
label_row[start_c + idx_c] = ch
|
|
317
|
+
rich_text.append("".join(label_row) + "\n", style=Style(bold=True, color=theme.SIGNAL_GREEN))
|
|
318
|
+
|
|
319
|
+
for r_idx, row in enumerate(canvas.iter_rows()):
|
|
320
|
+
for ch, rgb in row:
|
|
321
|
+
if rgb is None:
|
|
322
|
+
rich_text.append(ch)
|
|
323
|
+
else:
|
|
324
|
+
rich_text.append(ch, style=theme.color_style(rgb, truecolor=self._truecolor))
|
|
325
|
+
if r_idx < canvas.rows - 1:
|
|
326
|
+
rich_text.append("\n")
|
|
327
|
+
|
|
328
|
+
callout = self._callout_text()
|
|
329
|
+
if callout:
|
|
330
|
+
rich_text.append(f"\n{callout}", style=Style(bold=True, color=theme.CREAM))
|
|
331
|
+
pipe_pane.update(rich_text)
|
|
332
|
+
|
|
333
|
+
# Update outlined telemetry readout
|
|
334
|
+
lat_str = f"{state.latency_avg_ms:.1f} ms" if state.latency_avg_ms is not None else "N/A"
|
|
335
|
+
jit_str = f"{state.jitter_ms:.1f} ms" if state.jitter_ms is not None else "N/A"
|
|
336
|
+
lat_label = "RTT: " if is_rtt else "Latency: "
|
|
337
|
+
readout = (
|
|
338
|
+
f"Time: {state.time_ms:>5.0f}/{self._max_time_ms:<5.0f}ms\n"
|
|
339
|
+
f"Speed: {SPEED_STEPS[self._speed_idx]}x"
|
|
340
|
+
f"{' [PAUSED]' if self._paused else ''}\n\n"
|
|
341
|
+
f"Sent: {state.sent:>5}\n"
|
|
342
|
+
f"Delivered:{state.delivered:>5}\n"
|
|
343
|
+
f"Lost: {state.lost:>5} ({state.loss_pct:.1f}%)\n"
|
|
344
|
+
f"{lat_label}{lat_str}\n"
|
|
345
|
+
f"Jitter: {jit_str}\n"
|
|
346
|
+
)
|
|
347
|
+
if not is_rtt:
|
|
348
|
+
q_lines = "\n".join(
|
|
349
|
+
f" {name:<8} {state.queue_depths.get(name, 0):>3}" for name in self._hop_names
|
|
350
|
+
)
|
|
351
|
+
readout += f"Reordered:{state.reordered:>5}\n\nQueue Depth:\n{q_lines}"
|
|
352
|
+
self.query_one("#readout-text", Static).update(readout)
|
|
353
|
+
|
|
354
|
+
frac = (self._t_ms / self._max_time_ms) if self._max_time_ms > 0 else 1.0
|
|
355
|
+
status_label = "PULSE STALLED" if (self._pulse_active and not self._pulse_target.all_clear) else "REPLAYING"
|
|
356
|
+
self.query_one("#viz-status", Static).update(
|
|
357
|
+
theme.format_status_line(status_label, frac)
|
|
358
|
+
)
|
|
359
|
+
|
|
360
|
+
def _callout_text(self) -> str:
|
|
361
|
+
hops_bar = " -> ".join(self._hop_names)
|
|
362
|
+
if not self._pulse_active:
|
|
363
|
+
return f"Path: {hops_bar}"
|
|
364
|
+
mascot_line = ""
|
|
365
|
+
if self._narrator_enabled and self._narrator_lines:
|
|
366
|
+
if self._pulse_target.hop_name is not None:
|
|
367
|
+
matched = next(
|
|
368
|
+
(l.text for l in self._narrator_lines if l.hop == self._pulse_target.hop_name),
|
|
369
|
+
self._narrator_lines[0].text,
|
|
370
|
+
)
|
|
371
|
+
else:
|
|
372
|
+
matched = self._narrator_lines[0].text
|
|
373
|
+
mascot_line = f"\n{MASCOT_NAME}: {matched}"
|
|
374
|
+
if self._pulse_target.all_clear:
|
|
375
|
+
return f"PULSE ALL CLEAR | Path: {hops_bar}{mascot_line}"
|
|
376
|
+
f = self._pulse_target.finding
|
|
377
|
+
if f is None:
|
|
378
|
+
return f"Path: {hops_bar}{mascot_line}"
|
|
379
|
+
loc = self._pulse_target.hop_name or "path"
|
|
380
|
+
return f"PULSE STALLED @ {loc}: [{f.severity.upper()}] {f.code} = {f.value:.2f}{mascot_line}"
|
|
381
|
+
|
|
382
|
+
def action_toggle_pause(self) -> None:
|
|
383
|
+
self._paused = not self._paused
|
|
384
|
+
|
|
385
|
+
def action_speed_up(self) -> None:
|
|
386
|
+
if self._speed_idx < len(SPEED_STEPS) - 1:
|
|
387
|
+
self._speed_idx += 1
|
|
388
|
+
|
|
389
|
+
def action_speed_down(self) -> None:
|
|
390
|
+
if self._speed_idx > 0:
|
|
391
|
+
self._speed_idx -= 1
|
|
392
|
+
|
|
393
|
+
def action_restart(self) -> None:
|
|
394
|
+
self._t_ms = 0.0
|
|
395
|
+
self._paused = False
|
|
396
|
+
self._pulse_active = False
|
|
397
|
+
self._pulse_x = 0.0
|
|
398
|
+
self._pulse_ticks = 0
|
|
399
|
+
self._reset_bus()
|
|
400
|
+
if self._canvas is not None:
|
|
401
|
+
self._canvas.clear()
|
|
402
|
+
|
|
403
|
+
def action_trigger_pulse(self) -> None:
|
|
404
|
+
self._pulse_active = True
|
|
405
|
+
self._pulse_x = 0.0
|
|
406
|
+
self._pulse_ticks = 0
|
|
407
|
+
|
|
408
|
+
def action_go_back(self) -> None:
|
|
409
|
+
if self._timer is not None:
|
|
410
|
+
self._timer.stop()
|
|
411
|
+
self.app.pop_screen()
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: spongebob-cli
|
|
3
|
+
Version: 0.3.2
|
|
4
|
+
Summary: Spongebob — Terminal Network Impairment Simulator for delay, jitter, and packet loss.
|
|
5
|
+
Author: Vinay Bandla
|
|
6
|
+
Project-URL: Homepage, https://github.com/venkataramavinaybandla-crypto/Spongebob
|
|
7
|
+
Project-URL: Repository, https://github.com/venkataramavinaybandla-crypto/Spongebob
|
|
8
|
+
Project-URL: Issues, https://github.com/venkataramavinaybandla-crypto/Spongebob/issues
|
|
9
|
+
Keywords: network,simulator,delay,jitter,packet-loss,terminal,tui
|
|
10
|
+
Classifier: Environment :: Console
|
|
11
|
+
Classifier: Topic :: System :: Networking
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Requires-Python: >=3.11
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
Requires-Dist: textual==8.2.8
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: pytest>=9.0; extra == "dev"
|
|
18
|
+
Requires-Dist: pytest-asyncio<2,>=1.5.0; extra == "dev"
|
|
19
|
+
Provides-Extra: test
|
|
20
|
+
Requires-Dist: pytest>=9.0; extra == "test"
|
|
21
|
+
Requires-Dist: pytest-asyncio<2,>=1.5.0; extra == "test"
|
|
22
|
+
|
|
23
|
+
# Spongebob
|
|
24
|
+
|
|
25
|
+
Spongebob is an open-source, terminal-based **Network Impairment Simulator** focused on **Delay**, **Jitter**, and **Packet Loss**. Configure a multi-hop network path, inject controlled impairments into a simulated packet flow on a deterministic virtual clock, measure the resulting network metrics, and inspect rule-based findings and live terminal animations.
|
|
26
|
+
|
|
27
|
+
- **Delay:** Each packet waits a set time at a hop before moving on.
|
|
28
|
+
- **Jitter:** Wait times vary randomly per packet (uniform or normal), which can cause packets to arrive out of order.
|
|
29
|
+
- **Packet Loss:** Packets are dropped at a hop via random percentage, Gilbert-Elliott bursty loss, or queue-full tail drops under a bandwidth cap.
|
|
30
|
+
|
|
31
|
+
## Install
|
|
32
|
+
|
|
33
|
+
Requires **Python 3.11+**.
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pipx install spongebob-cli
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Or with pip:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install spongebob-cli
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Run
|
|
46
|
+
|
|
47
|
+
Launch the terminal UI:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
spongebob
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Headless CLI commands:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
spongebob --version
|
|
57
|
+
spongebob scenarios
|
|
58
|
+
spongebob run <scenario-or-file.toml>
|
|
59
|
+
spongebob diagnose <host>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Diagnose Mode Limits
|
|
63
|
+
|
|
64
|
+
Diagnose mode probes a single user-supplied target using bounded TCP connect timing (and optional system DNS resolution) and feeds samples into the meter, analyzer, narrator, and visualizer:
|
|
65
|
+
|
|
66
|
+
- Measures **round-trip time (RTT)**, not one-way delay.
|
|
67
|
+
- TCP connect timeouts **approximate packet loss**; they are not exact packet loss.
|
|
68
|
+
- Throughput is reported as `n/a`, and bandwidth choke or reordering findings are skipped.
|
|
69
|
+
- Enforces single target, single port (`1-65535`), max `200` probes, minimum `100 ms` interval, and `100-5000 ms` timeout.
|
|
70
|
+
|
|
71
|
+
## Privacy
|
|
72
|
+
|
|
73
|
+
- **Zero network calls in Simulate mode:** All simulation, measurement, and analysis run purely in-memory.
|
|
74
|
+
- **User-confirmed Diagnose targets only:** Contacts only the single host and port you enter, after explicit confirmation.
|
|
75
|
+
- **No telemetry or history:** Nothing is collected or saved automatically; exports write only to the exact path you confirm.
|
|
76
|
+
- **Data-only plugins:** Plugins are parsed as TOML data only and are never imported or executed as code.
|
|
77
|
+
|
|
78
|
+
Source code and full documentation: https://github.com/venkataramavinaybandla-crypto/Spongebob
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
spongebob/__init__.py,sha256=vNiWJ14r_cw5t_7UDqDQIVZvladKFGyHH2avsLpN7Vg,22
|
|
2
|
+
spongebob/__main__.py,sha256=V-dGqY3n6Tx5lB-0SfiOQzfnw8ROuGdm2ZHLBFeVNiw,13495
|
|
3
|
+
spongebob/analyzer/__init__.py,sha256=PkuciVNPI7rnMQwRFa7vRBlxKNc9CZ-fAOHjYEVq884,172
|
|
4
|
+
spongebob/analyzer/__main__.py,sha256=0-oo7ltSpnfw4LG3fKqYIZ-mBXyFlR64S5CdNz6Hdwk,1153
|
|
5
|
+
spongebob/analyzer/analyzer.py,sha256=-s0spUJDA0wBUe9Ual5AO8ZXU74fLuuv2739osr8-2A,7983
|
|
6
|
+
spongebob/bus/__init__.py,sha256=XJvMZoT4CIkiuJb0V9MQWJCJilzlhRkrmtD0hnT2wks,79
|
|
7
|
+
spongebob/bus/bus.py,sha256=hE9PMdq7PTKQdXXwOJrjNg-QOemc2biKCYhKFUOA6a8,1459
|
|
8
|
+
spongebob/diagnose/__init__.py,sha256=eB_UarUm9Nfw8ldikCCKpizE_ZUQn92OQoKfMZy65xY,580
|
|
9
|
+
spongebob/diagnose/__main__.py,sha256=ZUQHqgQaKKaMn-7AIFf-mqLjHyrJ2ve1sbjvxiXP52c,3452
|
|
10
|
+
spongebob/diagnose/adapter.py,sha256=1okAoFvewo9jUknc_wsmu15CcX9aIuVMqv2pKWAugLQ,2644
|
|
11
|
+
spongebob/diagnose/models.py,sha256=QFiVxcvuKAKi5ZbnilcP2XxqiGcj-vCG6vNpgvZl6lY,2859
|
|
12
|
+
spongebob/diagnose/probes.py,sha256=cfzESlmML6gY-3078QGHpcsWggxbOwnu30nzG259Z-4,3908
|
|
13
|
+
spongebob/engine/__init__.py,sha256=4J5twuoAFu7CJUhH_kGGtldZLV3gvszRoojdBDTPoa0,379
|
|
14
|
+
spongebob/engine/__main__.py,sha256=5dTiU0gtibgeb-CUnddraReIhNKH9eh6jCoXfqk8bCc,873
|
|
15
|
+
spongebob/engine/models.py,sha256=Oh9yS0Aarsz2H84txEQ6SdwVx6xm_8x1Z3ozOOAi0QI,5732
|
|
16
|
+
spongebob/engine/simulator.py,sha256=65MSQXMWHRMFeIoyvsWJbvZYCrlqcrVk_HR80JpbUJ8,7880
|
|
17
|
+
spongebob/export/__init__.py,sha256=xhM8llDo1HkcV5wcD6Z0HLxvsXsxqzOIuTFsSdD0YRY,465
|
|
18
|
+
spongebob/export/exporter.py,sha256=pv2ERG4lnWZMaHk8fIk3aOHGYTjsk8j-V4ISsGRPI1s,12493
|
|
19
|
+
spongebob/meter/__init__.py,sha256=UDwfa5uK8F142i4JJ0h1XFRD8UXyqKCF4MANjCyjnOw,115
|
|
20
|
+
spongebob/meter/__main__.py,sha256=fL_nJS4p0EApcy75r-lgERRgTkMx4mqkNkbFpRyJPIk,2060
|
|
21
|
+
spongebob/meter/meter.py,sha256=NSE3kri9YMkgRiU3n48RStX76mJagNiNeZg6ew3YnSA,4311
|
|
22
|
+
spongebob/narrator/__init__.py,sha256=muXo0yC164ebLqEpdLI616ZyX6BL1KNDhEQJZzsaGLk,415
|
|
23
|
+
spongebob/narrator/narrator.py,sha256=UdvBCMcyW5qWWKZPgpCQhgNmx-FH5Ed9s9QX0W9svv4,17743
|
|
24
|
+
spongebob/plugins/__init__.py,sha256=FZoFw3DIvvf2zOKPWaBSKaE85lvAN9TauEughACHfvc,582
|
|
25
|
+
spongebob/plugins/loader.py,sha256=tcsI8WxPXIO56zFgx686g8TqRTj9_L9BnhtP1r_L0uM,12195
|
|
26
|
+
spongebob/plugins/models.py,sha256=K-PC2wpijttSmDxnQlnm9dOm9HumAUW1oYcZsvpUIgM,1396
|
|
27
|
+
spongebob/scenarios/__init__.py,sha256=9AUQAdT4ACk66YnkPaEjlQ58lyPTje3kGPe1_pbPZ3Y,557
|
|
28
|
+
spongebob/scenarios/loader.py,sha256=n0F078N1Jt76fhIyGmtaYPDoafmfUcz-tBInGiLAbJM,6904
|
|
29
|
+
spongebob/scenarios/models.py,sha256=9xdqY-aslVqZ0sI_GpnEEJ1uq-7O-6uoXq70Cq04yNE,1971
|
|
30
|
+
spongebob/scenarios/runner.py,sha256=YxHhW5K1k07PSCAjRTZqKzE4SLAi3UF9hn0wJGYYAwQ,917
|
|
31
|
+
spongebob/scenarios/builtin/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
|
|
32
|
+
spongebob/scenarios/builtin/control-line.toml,sha256=7D-dXSSGshXPvY12-EJmL4P_9GgDJUFvgwMm3FiTqvM,479
|
|
33
|
+
spongebob/scenarios/builtin/crowded-wifi.toml,sha256=00RF9hCRqVkzdhZd9_IwRBC7h1FScept-EN90a-CgQU,491
|
|
34
|
+
spongebob/scenarios/builtin/flaky-last-mile.toml,sha256=_nPCq9pXticp5rghOVzrfs5O3kpcHED4qnlwNr3BvlA,489
|
|
35
|
+
spongebob/scenarios/builtin/long-haul-orbit.toml,sha256=f42GyMW4sF3NbM9FM-lAPglioU0iEqMbTlnmHmhoYLk,483
|
|
36
|
+
spongebob/scenarios/builtin/overloaded-uplink.toml,sha256=f7sq55DDM__yrxyUcc4vmF47n-DGZuJVoWeQH1OafOg,530
|
|
37
|
+
spongebob/scenarios/builtin/tunnel-burst.toml,sha256=W45vmHOhuqip0shrSfnNtAWboXBJVx6XmNLkdhnWjTA,571
|
|
38
|
+
spongebob/ui/__init__.py,sha256=QbMOXAol-4siW71Cx4_h52yHp_p2wKn7Or-f7M3Oo0Y,476
|
|
39
|
+
spongebob/ui/__main__.py,sha256=a4fPgspYXQk5yBDpKzJ7_N3c-kKZFSRVjvyvHjxMipU,165
|
|
40
|
+
spongebob/ui/app.py,sha256=4lGmWko6xJfh5P_C5b1q2TEmdaMky6wm7eeKwI2K59Y,3351
|
|
41
|
+
spongebob/ui/canvas.py,sha256=DF0ZuKXA3Mgeo4qSMjucaqyRCXN896f8t6Yo438e_9k,5299
|
|
42
|
+
spongebob/ui/diagnose_screen.py,sha256=JOhJmH-9aqsiSbYa_nrHq3Ea2npAQMbyGyTvgLAg3ZI,19594
|
|
43
|
+
spongebob/ui/export_modal.py,sha256=kSC4HwzjKk6PN3Xhr-_U-OSxd4OTNBMXCipQWAPKmik,4838
|
|
44
|
+
spongebob/ui/menu_screen.py,sha256=GLr_T3ZIKcWiD1pYLIgwrSJO3ZhvZ0RThHP_wVjVt80,5602
|
|
45
|
+
spongebob/ui/replay.py,sha256=8-yWoUdMdlF43KCrv13JsG7LqEs6AVo_lTyLw9psqsQ,6780
|
|
46
|
+
spongebob/ui/settings_screen.py,sha256=h5X7yMuq22RDH3r6KYb3tQuxdi_HQIPWqyqIIKn5928,3549
|
|
47
|
+
spongebob/ui/simulate_screen.py,sha256=D8s1q7d-Wyg-HyBjrcg15LZd7gaKudCLn5G-C79fEWk,23652
|
|
48
|
+
spongebob/ui/theme.py,sha256=sI7Ew4iODFzjMEB2UVTyLThT5sDTfnoIXoYWkEEzkNU,9089
|
|
49
|
+
spongebob/ui/visualize_screen.py,sha256=csVaqwwzrenpg1ybSTEmIkfEZ34p-QQDbqZOOTnf4Ns,16136
|
|
50
|
+
spongebob_cli-0.3.2.dist-info/METADATA,sha256=qIFRB8tDJ5WfNCz7L2pLM7ueTSumADJ-h6dthiSt3DY,3141
|
|
51
|
+
spongebob_cli-0.3.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
52
|
+
spongebob_cli-0.3.2.dist-info/entry_points.txt,sha256=zswHszPYFqWbHtGZO1Qv8kI3ly5uTGHrFEa7zx6tsoo,54
|
|
53
|
+
spongebob_cli-0.3.2.dist-info/top_level.txt,sha256=i0TJ5BfHN86mBXtDpDFQF2mz-FxaTnUuXvg9v8j8jio,10
|
|
54
|
+
spongebob_cli-0.3.2.dist-info/RECORD,,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
spongebob
|