To import CLOG.H packages in omnet++ tool we give detailed explanation so if you require assistance to carry on project then omnet-manual.com will be your best guide. cLog Header is a handy tool for logging messages, events, and other important info while running a simulation. It’s built to help developers keep an eye on how their simulation models are performing, follow the sequence of events, and troubleshoot problems by giving detailed output to the console, log files, or other output channels. It supports different levels of messages like debug, info, warnings, and errors, making it easier to sort the output by how critical the events are. Plus, cLog can manage formatted strings, so developers can log messages that include variable data like timestamps, module names, or specific parameter values.
Steps that are required for the installation of cLog.h.
PRE-REQUISITES:
Screenshot:
2.OMNET++ Installation:
Screenshot:
HEADER FILE VERIFICATION:
Screenshot:
2.OMNeT++ Building Process:
Next, we need to build the Aloha folder to make Aloha Example to work in the OMNET++ 6.0.2 IDE. Right Click the Aloha folder and Click the Build Project Option to build the Aloha Folder.
Screenshot:
Here, we shown the Aloha Building Process.
Screenshot:
Screenshot:
Screenshot:
Here We successfully built and imported the Aloha Example in the OMNET++ IDE.
3.Importing cLog.h:
Here we imported the cLog.h header file in this example program by clicking the Server.cc, you can see the header imported.
Screenshot:
So here we need to copy this code and paste in the existing code of Aloha Example for cLog header.
Code:
void Server::handleMessage(cMessage *msg)
{
if (msg == endRxEvent) {
EV_INFO << “reception finished\n”;
channelBusy = false;
emit(channelStateSignal, IDLE);
simtime_t dt = simTime() – recvStartTime;
if (currentCollisionNumFrames == 0) {
cTimestampedValue tmp(recvStartTime, (intval_t)1);
emit(receiveSignal, &tmp);
emit(receiveSignal, 0);
}
else {
cTimestampedValue tmp(recvStartTime, currentCollisionNumFrames);
emit(collisionSignal, &tmp);
emit(collisionLengthSignal, dt);
}
currentCollisionNumFrames = 0;
receiveCounter = 0;
emit(receiveBeginSignal, receiveCounter);
}
else {
cPacket *pkt = check_and_cast<cPacket *>(msg);
ASSERT(pkt->isReceptionStart());
simtime_t endReceptionTime = simTime() + pkt->getDuration();
emit(receiveBeginSignal, ++receiveCounter);
if (!channelBusy) {
EV << “started receiving\n”;
recvStartTime = simTime();
channelBusy = true;
emit(channelStateSignal, TRANSMISSION);
scheduleAt(endReceptionTime, endRxEvent);
}
else {
EV << “another frame arrived while receiving — collision!\n”;
emit(channelStateSignal, COLLISION);
if (currentCollisionNumFrames == 0)
currentCollisionNumFrames = 2;
else
currentCollisionNumFrames++;
if (endReceptionTime > endRxEvent->getArrivalTime()) {
cancelEvent(endRxEvent);
scheduleAt(endReceptionTime, endRxEvent);
}
if (hasGUI()) {
char buf[32];
sprintf(buf, “Collision! (%” PRId64 ” frames)”, currentCollisionNumFrames);
bubble(buf);
getParentModule()->getCanvas()->holdSimulationFor(par(“animationHoldTimeOnCollision”));
}
}
channelBusy = true;
delete pkt;
}
}
So here we highlighted the code line that uses the cLog header.
Screenshot:
Press Control key and click the cLog.h to open the header file.
Screenshot:
Here we will show the cLog.h header file to show the highlighted line imported from the cLog.h in the example code in function handleMessage().
Screenshot:
4.Executing the Example Program Using cLog header file:
Then we need to run the Example program Using cLog header file to view output of the program. Firstly, we need to locate to the “/Aloha/” to find the example program in the Aloha Folder.
Screenshot:
Next click the “omnetpp.ini” file and Configuration of the Aloha Program.
Screenshot:
Next, Right Click the omnetpp.ini file, click the Run As and then Click the OMNeT++ Simulation.
Screenshot:
If you got any prompt, then Click the OK button to build and Simulate the Example program.
Screenshot:
Click the Any Configuration in the Omnet++ Ide to select the Configuration for the Example Program Simulation.
Screenshot:
Click the Run Button in the Omnet++ Ide to simulate the Example Program.
Screenshot:
Screenshot:
Screenshot:
Simulation Completed Successfully by the Aloha Example Using cLog header.