So far we had to generate our graph every time we changed something in our code or restarted the simulation for any other reason.
We also already learned there’s a start parameter to change the timeout interval.
Actually there are more start parameters we’ll now have a closer look at.
All this parameters may be set by starting the simulation after the program name. On Windows they all can be set by starting the simulation from the command line or in the launcher window.
Prepared graph file
To not need to generate a graph every start you can store it to a file. To do so, generate it once and press Store Graph in the graph generation area.
You can edit such a file with an ordinary text editor.
It contains three areas:
At first there are several options set.
Second the nodes are created with node type, name, synchronous model and initial coordinates in the visualization.
The synchronous model and the coordinates are optional, but coordinates can only be set if the synchronous model is also given.
The last area contains the edges in the graph. They’ll be created using the entry() method.
To load such a file you may use the parameter -f, e.g.
netsimlan myProgram -f myGraph.txt.
Turn visualization or main window off
If you want to run a simulation without the visualization or a demo without the main window, you may turn off one or both of these.
The parameter to turn of the visualization is -v off, to turn of the main window you can use -g off.
Please note, that you can only turn off the main window when using a graph file, because otherwise you don’t have any node and can’t create any.
A combination of this options may looks as follows:
netsimlan myProgram -f myGraph.txt -g off -v on
If your program is made in a way it works without user interaction e.g. a self stabilizing network from a stored graph you can run a simulation that way.
Store log in a log file
NetSimLan shows the log in the main window and the terminal if started from there. You can also store it in a file using the -l parameter.
Combining that parameter with own generated log messages using the print method, you can store your networks behavior in a file.
Using that file you can create a script to get a deeper look in your algorithms behavior for example.
A call using that parameter may look like follows:
netsimlan myProgram -l run.log
When you want to run the simulation for a specific time, e.g. 30 seconds, you can use the parameter -t 30.
Note the simulation is finished after every node had a timeout after the specific time, so it might run a little longer than the parameter says.
After the termination of the simulation NetSimLan writes some statistics for every node to the log containing its id, name, average and maximal input buffer size, number of calls and values of variables.
Note the graphical interface doesn’t close after the termination. So to run a completely automated simulation you may combine the parameters before, e.g.
netsimlan myProgram -f myGraph.txt -g off -v off -l run.log -t 30.
Also that statistics are great for being processed by a script to learn more about your algorithms.
The timeout interval is 100 ms by default. You may change that using the -i parameter. Have a closer look to the previous chapter for details.
API for complex automated simulations
There’s a API to control a complex simulation from a script.
You open that API using the
-a <TCP Port> parameter.
Details about the API will follow in a later chapter.