The v3 project format: projects written as text
Translated from the French version, which is authoritative.
This note is for teachers who keep a collection of .mar projects, such as the starting networks
of their lab sessions. Since 2026, Marionnet saves its projects in a new format, the v3 format,
written as text. Nothing changes in the way you use the software, and old projects open as before.
However, an old project saved by the new version can no longer be opened by an earlier version of
Marionnet. If one of your lab rooms, or one of your colleagues, still uses such a version, keep a
copy of each project before saving it (see § 3).
1. What changes
A Marionnet project, that is, a .mar file, is a compressed archive that holds two things: the
description of the virtual network (its components, cables, addresses and drawing), and the disks
of the machines, or more precisely what has changed on each of them since the original image.
Until now, the description was written in OCaml’s internal binary format (OCaml being the
language Marionnet is written in), in other words a raw copy of the program’s data structures. It
could not be read outside Marionnet, nor compared from one version to the next. It was also
fragile: a change in the program could make an old project unreadable, without any warning.
In the v3 format, the description is written as text: JSON for the files that describe the
network, and plain scripts for the startup scripts of the components. The disks, for their part,
remain binary images, which is what they are by nature. Two useful properties follow:
- once the archive is unpacked (
tar xzf lab.mar), a project can be read, compared (diff) and kept under a version control system such asgit: two versions of a lab that differ by one address differ by one line; - a project opened and then saved without any change is rewritten identically. Until now, the
order of the components was reversed at every save, which made any comparison useless. One file
is the exception,
states/ifconfig-counters.json, which holds an obsolete field drawn at random at every save:difftherefore reports it every time, and you can ignore it.
2. Old projects still open
Marionnet reads every format it has written since its beginnings (v0, v1 and v2). When it
opens an old project, it adapts whatever needs adapting, for instance by replacing a kernel that is
no longer shipped with an available one, exactly as it already did. The file is still an ordinary
.mar archive, which you can copy, send by email or archive as usual.
3. Before saving an old project
Opening an old project changes nothing on disk; saving it does. The project is then written in
the v3 format, and an earlier version of Marionnet will no longer be able to open it. Marionnet
says so when it opens such a project, with the warning it has always shown when a project is about
to change format:
Project in old file format — This project will be automatically converted in a format not compatible with previous versions of this software. If you want to preserve compatibility, don’t save it or save it with another name.
What happens next has been checked, not assumed. Faced with a v3 project, an earlier version of
Marionnet refuses to open it and says so (Failed loading the project). It does not crash, shows
no half-loaded network, and above all leaves the file intact: a refusal never damages a
project. The failure therefore does the file no harm, but the project cannot be used on that
workstation, and there is no way back: a v3 project cannot be converted back to an old format.
So if some workstations still run an earlier version of Marionnet (a lab room not yet updated, a colleague, or a virtual machine you keep for a course), keep a copy of each project before saving it with the new version:
cp lab.mar lab-v2.mar
Telling which format a project is in
The format is written in a small file, version, inside the archive:
$ tar xzf lab.mar -O --wildcards '*/version'; echo
v2
The file holds only the name of the format, without even a newline, hence the final echo. The
formats v0, v1 and v2 are the old binary formats, and v3 is the text format: the same
command, run on a project saved by the new version, therefore answers v3.
4. Converting a whole collection of projects
Converting is not necessary, since Marionnet opens old projects; it is only useful if you want to
compare your projects, or keep them under git, right away.
Marionnet provides no separate conversion tool, and this is deliberate: the only program allowed to
write a Marionnet project is Marionnet itself. Converting a project therefore means opening it and
then saving it, which a script can do without anyone clicking, thanks to
driving by script. The script is run in your graphical session, since
Marionnet opens its window there as usual, and mrnctl, the client of driving by script, is
installed with Marionnet:
# mrnctl reads the path of the socket from this variable:
export MARIONNET_CONTROL_SOCKET=/tmp/marionnet.sock
marionnet --control-socket "$MARIONNET_CONTROL_SOCKET" &
until mrnctl status > /dev/null 2>&1; do sleep 0.5; done
mkdir -p ~/labs-v2
for f in ~/labs/*.mar; do
# The copy first, in a directory of its own (see § 3):
cp "$f" ~/labs-v2/
mrnctl open "$f" --timeout=120 &&
mrnctl close --save --timeout=120 || break
done
mrnctl quit
Three remarks about this loop. First, opening an old project may adapt it (by replacing a
kernel, for instance): mrnctl open lists these adaptations in its answer, and they are part of
what will be saved. Second, the --timeout=120 option is not decoration. A command that does not
carry one is limited to five seconds, and saving a large project, or saving on a busy machine, can
take longer: the script would then report as failed an operation that was merely slow. Finally, if
opening or saving really fails, mrnctl returns an error code and the loop stops (|| break)
instead of moving on to the next project; when saving fails, close --save does not close the
project, so that nothing is lost. The copies, for their part, keep their .mar name, so an earlier
version of Marionnet opens them as they are.
What a .mar archive contains
| In the archive | Contents |
|---|---|
version |
the name of the format (v3) |
netmodel/network.json |
the network itself: machines, routers, switches, cables |
netmodel/dotoptions.json |
the drawing of the network (layout, zoom, flipped cables) |
states/ifconfig.json |
the addresses, one row per network card |
states/ifconfig-counters.json |
the counters used to assign the next address |
states/defects.json |
the simulated defects (loss, delay, duplication) |
states/states-forest.json |
the states of the machines’ disks |
states/texts.json |
the documents attached to the project |
states/rc_config.* |
the startup scripts, one file per component that has one |
The startup scripts are files of their own rather than a field of the network description, so that each of them can be opened in an editor, like any other file.
5. Further reading
- Driving Marionnet from a script or an AI, the guide to driving by script.
- The design of the format and the reasons behind its choices, for developers:
docs/migration-marshal-to-text.md, in Marionnet’s sources on Launchpad (in French).
