The interactive REPL
opp_repl is an IPython shell with every opp_repl public function
imported into the top-level namespace, plus convenience variables
for every loaded project and a handful of REPL-specific ergonomics.
Upstream references:
- https://github.com/omnetpp/opp_repl/blob/main/doc/repl.md
- https://github.com/omnetpp/opp_repl/blob/main/doc/getting_started.md
Launching
opp_repl --load ~/workspace/omnetpp/omnetpp.opp \
--load ~/workspace/inet/inet.opp
Glob patterns are allowed and --load can be repeated:
opp_repl --load "~/workspace/omnetpp/samples/*/*.opp"
CLI flags
| Flag | Effect |
|---|---|
--load FILE_OR_GLOB |
Load .opp descriptor(s); repeatable. |
-p NAME |
Set default simulation project by name. |
--mcp-port PORT |
Start MCP server on TCP PORT (default 0 = OFF; TCP needs a token). |
--mcp-socket [PATH] |
Start MCP server on a Unix socket (no token; default per-user path). |
-l LEVEL |
Log level: ERROR, WARN, INFO, DEBUG. |
--external-command-log-level L |
Log level for simulation and build tool output. |
--no-handle-exception |
Show full Python tracebacks instead of short errors. |
Pre-loaded namespace
On startup every public symbol from opp_repl is imported at the
top level — call them without a prefix:
run_simulations(sim_time_limit="1s")
run_smoke_tests()
build_project()
compare_simulations(simulation_project_1=a, simulation_project_2=b)
Press TAB after any partial name to auto-complete function names, method names, and keyword arguments.
Convenience variables
Every loaded project is injected as {name}_project, with hyphens
and dots turned into underscores:
inet.opp-->inet_projectsimu5g.opp-->simu5g_projectomnetpp-6.3.0.opp-->omnetpp_6_3_0_project
List them: get_simulation_project_variable_names().
Defaults
If the current working directory is inside a loaded project's tree, that project is auto-set as default. Otherwise set explicitly:
set_default_simulation_project(aloha_project)
Or on the command line: -p aloha.
Autoreload
IPython's %autoreload 2 is enabled at startup. Editing Python
source files (your own helpers or opp_repl itself) picks up changes
before the next command — no restart required.
User module auto-import
At startup the REPL tries import <unix-login-name>, e.g.
import alice if $USER is alice. If the module exists, every
public name is injected into the namespace. This is the blessed
mechanism for per-user helpers, project defaults, and shortcuts —
no need to fork opp_repl.
Stopping execution cleanly
Inside a multi-line REPL script, call stop_execution() (or
stop_execution(value)) to abort the current cell without a
full traceback. Useful for early exits from sourced scripts.
Scripting non-interactively
opp_repl accepts stdin and runs each line as in an interactive
session. Pipe a heredoc for one-shot scripted runs:
opp_repl --mcp-port 0 --load aloha.opp <<'EOF'
r = run_simulations(config_filter="PureAloha1", sim_time_limit="0.3s")
print(r)
exit
EOF
For CI where IPython-specific features are not needed, prefer the
shell wrappers — see opp-repl-cli-tools.
Pitfalls
--mcp-portdefaults to0(the MCP server is OFF). Pass a port (e.g.9966) to enable TCP mode — which then needs--mcp-token-hashoutsideopp_sandbox— or use--mcp-socketfor the tokenless local transport. Leave both unset in CI / parallel test runs. Seeopp-repl-mcp-server.- The user-module auto-import is silent when the module is missing. If your helpers don't load, check your OS login name vs. module name.
- Running
opp_replwithout--loadand not inside a project tree gives you a bare REPL — the{name}_projectvariables only appear afterload_opp_file().
See also
opp-repl-installation— prerequisites.opp-repl-concepts— the object model.opp-repl-running-simulations—run_simulations()in detail.opp-repl-cli-tools— non-interactive shell equivalents.opp-repl-mcp-server— expose the REPL to AI agents.opp-repl-shared-terminal— let a human and an AI share this REPL.