Next: 4 The pbuf structure
Up: Simulation Environment Overview 15-441
Previous: 2.1 Network configuration file
User programs can be run on each simulated node. Each user program is run
as a separate user process as shown in Figure 1.
All user programs used with the simulator must be linked against the
user libraries we provide (see the template Makefile for more details).
There are two important issues regarding user programs:
- Use Main() instead of main(). The entry point of a user
program is actually in the simulator, not the code you write. After the
simulator is done with the necessary initializations, it invokes your
Main() function. The Main() function is exactly the same as
main(); that is, the usual argc and argv are still there.
- User programs must be run with ``-n i'' as the first
argument. This argument is to specify that this user program should
be run on node i.
Note that the Main() function will not get
this argument (i.e. the simulator will strip this argument
before passing the arguments to Main()).
- You should close all open sockets before returning from Main(). If you forget to close an open socket, the simulator will not
close it for you and future invocations of your program might fail.
Next: 4 The pbuf structure
Up: Simulation Environment Overview 15-441
Previous: 2.1 Network configuration file