Home | nevrax.com |
|
The NeL Net Message Recorder
OverviewWhen creating client-server applications, it is generally hard to debug one program, because you need one or more external processes to run it. Moreover, these other external programs should work perfectly in order to debug the first program, but to test them you need the first program to work perfectly too ! Eventually, when several processes run in parallel and interact with each other, a bug behaviour is difficult to reproduce. The Message Recorder allows to record every message and network event (connection, disconnection...) that is managed by the Nel network engine. Then, it is easy to replay the sequence later, even if the peers (clients or servers) are not running, and to trace it with a debugger. If your program is a service based on the NeL service framework (see NLNET::IService), all you have to do is to add the following line in the config file of the service (this is also where you type the address of the Naming Service): Rec = "Record"; Rec = "Replay"; Note that in the first case, you lauch the service in the same way as usual, launching other services such as the Naming Service before, but in the second case, the service process is the only one required. To disable recording/replaying, remove or comment out the line in the config file, or set it to: Rec = "Off"; Besides, if your service creates some client connections using layer 3, creating CCallbackClient or CCallbackServer objects, you need to change the code. For example:
MyConnection = new CCallbackClient( "OneService" ); MyConnection = new CCallbackClient( "OneService", IService::recordingState(), "one_service.nmr" ); If your service uses layer 4 to create additionnal connections, using CNetManager::addClient() or CNetManager::addServer(), you don't need to change the code. If your program is not based on the service framework, there is no standard config file. Consequently, you need to change the code. For example, using layer 3:
MyConnection = new CCallbackClient( "OneService" ); MyConnection = new CCallbackClient( "OneService", CCallbackNetBase::Record, "one_service.nmr" ); The type of the second argument is CCallbackNetBase::TRecordingState and can take one of these values: Off, Record, Replay. Using layer 4, all you have to do is to pass the recording state to CNetManager::init().
In the examples above, we set the output/input file to "one_service.nmr". When using layer 4 or the service framework, each client connection or server gets a short service name, such as NS for Naming Service. The output/input filenames are built upon this short service name and the extension ".nmr". NMR stands for NeL Message Record. Consequently, do not run several programs located in the same directory in record or replay mode at the same time. The filenames would conflict. The messages and events are stored in plain text, so that anyone can read them.
|