marionnet.org — a virtual network laboratory

Scripting and AI

Marionnet can also be driven by a script: it then takes its commands from a program instead of the mouse. All it takes is to start it with the --control-socket option, which opens its control channel:

marionnet --control-socket /tmp/marionnet.sock

The file /tmp/marionnet.sock is where Marionnet and the program driving it meet (technically, a Unix domain socket). Without the option, the file does not exist, so you decide, each time you start Marionnet, whether it accepts commands from elsewhere. The commands are then sent from a terminal with mrnctl, installed along with Marionnet, which you point once to the same socket:

export MARIONNET_CONTROL_SOCKET=/tmp/marionnet.sock

mrnctl new /tmp/tp1.mar
mrnctl add machine m1
mrnctl start m1

Each line is a command. In this way you can create a project, add machines and switches to it, connect them with cables, give them addresses, start them, then read what happened inside the machines. Each command is carried out as if it came from the mouse, and the Marionnet window stays open throughout. You therefore watch the network being built, and you can even use the mouse while the program is at work.

Marionnet answers each command with one line of JSON, which says whether the command was accepted and, if not, why; mrnctl help lists every command. A script can thus build the network of a lab and check that it behaves as intended, and so can an AI agent, as long as it can run commands and read their output.

With an AI

Marionnet itself has no AI built in: you bring your own, a command-line coding assistant for instance. You then do not need to know the mrnctl commands. You tell the agent what you want, it writes the commands, and you follow along in the Marionnet window.

To help the agent, Marionnet ships a skill, a guide written for the agent. It is not meant for any assistant in particular and needs no plug-in. Its subject is driving Marionnet: it teaches the agent the command language that Marionnet now offers, so that the agent can act as a go-between for you and the software, which was not possible before. It explains how to build a lab with commands, how to run it, and then how to collect what the students’ sessions produced, exam mode included, and apply your correction key to it. Designing the lab, on the other hand, is not its subject: the agent can of course help you with that, as it would without the skill, but that is another matter. The Teaching tab presents the skill from the teacher’s point of view.

The guides