Veins

The open source vehicular network simulation framework.

sumo-launchd

The SUMO Traffic Control Interface (TraCI) modules for OMNeT++ come with a small daemon to make running coupled simulations easier:

This daemon, sumo-launchd, is designed to run in the background, listening for incoming requests. On each incoming connection, it receives the simulation setup in XML format, then launches a separate instance of SUMO and proxies requests between OMNeT++ and SUMO.

All network port management and tempfile management is done by the daemon. SUMO instances are created and destroyed as needed, greatly simplifying batch execution of simulation runs.

sumo-launchd is run as follows:

~/src/inet/etc/sumo-launchd.py -vv -c /c/Users/[...]/sumo.exe

The following command line parameters are understood (note that the --daemon switch only works on POSIX systems, not on Windows):

  -h, --help            show this help message and exit
  -c COMMAND, --command=COMMAND
                        run SUMO as COMMAND [default: sumo]
  -s, --shlex           treat command as shell string to execute, replace {}
                        with command line parameters [default: no]
  -p PORT, --port=PORT  listen for connections on PORT [default: 9999]
  -b ADDRESS, --bind=ADDRESS
                        bind to ADDRESS [default: 127.0.0.1]
  -L LOGFILE, --logfile=LOGFILE
                        log messages to LOGFILE [default: TMPDIR/sumo-
                        launchd.log]
  -v, --verbose         increase verbosity [default: don't log infos, debug]
  -q, --quiet           decrease verbosity [default: log warnings, errors]
  -d, --daemon          detach and run as daemon [default: no]
  -k, --kill            send SIGTERM to running daemon first [default: no]
  -P PIDFILE, --pidfile=PIDFILE
                        if running as a daemon, write pid to PIDFILE [default:
                        /tmp/sumo-launchd.pid]
  -t, --keep-temp       keep all temporary files [default: no]

An XML launch configuration looks like this:

<?xml version="1.0"?>
<launch>
	<copy file="demo.net.xml" />
	<copy file="demo.rou.xml" />
	<copy file="demo.sumo.cfg" type="config" />
</launch>

Because sumo-launchd has no way of telling how long it takes for SUMO to start, it will retry connecting to SUMO, leading to output comparable to the following. This is perfectly normal.

$ ./sumo-launchd.py -vv -c /c/Users/user/src/sumo/bin/sumo.exe
Logging to /c/Users/user/appdata/local/temp/sumo-launchd.log
Listening on port 9999
Connection from 127.0.0.1 on port 60569
Handling connection from 127.0.0.1 on port 60569
Got TraCI message of length 2
Got TraCI command of length 1
Got TraCI command 0x0
Got CMD_GETVERSION
Got TraCI message of length 297
Got TraCI command of length 292
Got TraCI command 0x75
Got CMD_FILE_SEND for "sumo-launchd.launch.xml"
Got CMD_FILE_SEND with data "<launch>
  <copy file="erlangen.net.xml"/>
  <copy file="erlangen.rou.xml"/>
  <copy file="erlangen.poly.xml"/>
  <copy file="erlangen.sumo.cfg" type="config"/>
  <basedir path="/c/Users/user/src/veins/examples/veins/"/>
  <seed value="0"/>
</launch>
"
Creating temporary directory...
Temporary dir is /c/Users/user/appdata/local/temp/sumo-launchd-tmp-9duiwg
Base dir is /c/Users/user/src/veins/examples/veins/
Seed is 0
Finding free port number...
Claiming lock on port
...found port 60570
Starting SUMO (/c/Users/user/src/sumo/bin/sumo.exe -c erlangen.sumo.cfg) on port 60570, seed 0
Connecting to SUMO (/c/Users/user/src/sumo/bin/sumo.exe -c erlangen.sumo.cfg) on port 60570 (try 1)
Error ([Errno 10061] No connection could be made because the target machine actively refused it)
Connecting to SUMO (/c/Users/user/src/sumo/bin/sumo.exe -c erlangen.sumo.cfg) on port 60570 (try 2)
Error ([Errno 10061] No connection could be made because the target machine actively refused it)
Connecting to SUMO (/c/Users/user/src/sumo/bin/sumo.exe -c erlangen.sumo.cfg) on port 60570 (try 3)
Releasing lock on port
Starting proxy mode

After SUMO terminates (successfully or unsuccessfully), a sumo-launchd run in verbose mode will display its exit code, exit status, as well as its output (stdout and stderr) in the following form (with XXX filled in by the respective values).

<?xml version="1.0"?>
<status>
        <exit-code>XXX</exit-code>
        <start>0</start>
        <end>1</end>
        <status>XXX</status>
        <stdout><![CDATA[XXX]]></stdout>
        <stderr><![CDATA[XXX]]></stderr>
</status>

Common examples are:

  • SUMO ran successfully
    • exit code: 0
    • status: Done.
  • SUMO could not be started (here: because a wrong path to the SUMO binary was given)
    • exit code: -1
    • status: Could not start SUMO (/tmp/sumo -c erlangen.sumo.cfg): [Error 2] The system cannot find the file specified
  • SUMO was started, but aborted unsuccessfully (here: trying to execute commands that only make sense for the GUI version)
    • exit code: 1
    • status: Exited with error code 1
    • stderr: Error: Requested command not implemented (0xcc): Command not implemented in sumo
  • SUMO was started, but aborted unsuccessfully (here: because the network file was damaged)
    • exit code: 1
    • status: Exited with error code 1
    • stderr: Error: expected end of tag 'net' In file 'my.net.xml' At line/column 10948/3. Quitting (on error).