

file name: evalsys.cpp
classification: evaluation
contents: dummy evaluation systems
use: provide an evaluation system to test the simulation in
Linux
Note: the evaluation must be started before the simulation because
it creates the server socket to which the simulation modules connect.
Note: If you have adapted SimUTC to your needs and want to modify
the evaluation accordingly, here is where you might want to make changes:
-
evalcfg: if you have made any changes or additions
to parameters, then you will want to add them to the configuration data.
-
evalconv: If you have added or modified message
structures that are used in communication between EvalSys and SimUTC, you
should add a conversion function for the structure (or modify the existing
one).
-
evalfunc: If you have made changes or additions
to the events, then you should also edit PrintCSAEvents() and/or
PrintNetworkEvents(), which process events from the evaluation.
-
evalsys: If you have added new configuration data, then you will
have to adapt ConfigureNodes() and/or ConfigureNetworks()
so that SimUTC is sent the new data.
When sending your own messages, you should take care of two things:
-
Before you send the message, always call Convert()
to convert it to the byte order of the receiver.
-
Always set all data members of a message, even if the previous message
has used the same structure and has already set some of the data you need
in your own message. You have to do this because Convert()
may invert the byte order, and then your message will contain old data
that is already in the byte order of the receiver and new data that is
in the local byte order. Pay particular attention to this, it makes for
a nasty bug because the problem manifests itself only if the byte order
of SimUTC happens to be different from the local order. So the bug may
go unnoticed for quite a while.
Note: if you have defined the macro PLOT_DATA,
then the evaluation prints various data collected during the simulation
run into several files it creates in the directory PLOT_DIR.
The SimUTC archive assumes that the data files are created in the directory
SimUTC/Sources/Evalsys/gnuplot. There, you can find a file README that
contains instructions on how to further process the files.
global items provided:
EBool g_byteOrderReversed:
Is set to True if the byte order of communication peer is different from
the local order. The variable is needed for calls to Convert().
int main
(): The main function of the program. It executes the following steps:
-
It checks if the server socket already exists. If it does, then the program
reports this and exits.
-
The error handler is installed, so now error reports are printed to the
terminal.
-
The server socket is created.
-
If PLOT_DATA is defined, the gnuplot files are
created.
-
The evaluation system listens on the server socket until the simulation
Controller connects. If it encounters a timeout, this error is reported
and the program exists.
-
The byte order of SimUTC is checked and g_byteOrderReversed is
set accordingly.
-
The evaluation waits for the initial messages that the Controller is supposed
to send (module and enum sizes).
-
The Controller is configured according to the configuration data set in
evalcfg.cpp.
-
ConfigureNetworks() is called to configure the networks, if any
exist.
-
ConfigureNodes() is called to set up the nodes and to configure
them, if any exist.
-
The snapshot supervisor is set up to trigger snapshots.
-
The simulation is resumed. From now on, it sends events to the evaluation.
-
Events are received, processed, and printed until either the given number
of maximum messages has been received or if the specified number of rounds
has been encountered.
-
The simulation is killed. This causes SimUTC to exit.
-
The sockets that were created during the initialization of SimUTC are deleted.
The server socket is deleted as well.
-
The configuration data (number of nodes, node parameters, transmission
delay characteristics, etc.) and the precision summary (maximum, minimum
and average precision) are printed to the terminal.
-
If PLOT_DATA is defined, the gnuplot files are
closed.
-
The program returns successfully.
INT32 round:
The current round. The variable is set by PrintEvent().
INT32 supsid[ControllerIndex+1]:
All socket IDs. First come the supervisor socket IDs, the last entry is
the controller ID. The array is needed by SelectSocket().
local items used:
CUnixAddress
addr (SOCKNAME): The address of the server socket in UNIX domain.
Alternatively, you can use CInternetAddress addr (EvalsysPort)
if you want to use INET domain sockets.
void ConfigureNetworks():
Creates and configures numberOfNetworks networks.
int ConfigureNodes():
Creates and configures numberOfNodes nodes.
const INT32
ControllerIndex: The index of the controller in all arrays that
contain both supervisor and controller data. The supervisor indices are
the same as their internal nodeIDs and start with 0 and go up to numberOfNodes-1,
the controller is the last entry.
CStreamInterface
*ctrl: Socket for the controller.
enum EErrorNumbers:
All possible return values of the program.
SINT32 networkID[numberOfNetworks]:
IDs of the networks. The array is set by ConfigureNetworks() and
read by ConfigureNodes().
#define SOCKNAME:
The name of the UNIX socket.
CStreamInterface
*supsock[numberOfNodes]: Array of supervisor sockets.
last modified: Fri Feb 5 18:56:17 1999