[ns] how to create log file

Angelo Alifano alifangelo at gmail.com
Thu Apr 23 03:45:15 PDT 2009


Hi all,
I want to create a log file to see when a C++ function has called. I want to stamp in log file the simulation time too, how I can do that ?
I'm modifing file mac/mac-802_11.cc like this

...
void Mac_802_11::function (void) {
// code of function
...
// here I want log
 ofstream file;
 string nome="log.txt";
 file.open(nome.c_str(), ios_base::app); 
 if (!file)
     cout << "Error\n";
 else {
     file << "Function called at time ..." << endl;
 } file.close();
}
...

There is a function that return the simulation time that I can use ?

Thx in advance
Angelo


More information about the Ns-users mailing list