2. cQueue is a container class that acts as a queue.
The basic cQueue member functions:
insert(obj), inserts an object into the queue head.
pop(), returns and removes object from the front.
remove(obj), removes that object from the queue.
length(), returns the number of items in the queue.
empty(), tells whether there is anything in the queue.
insertBefore(obj_where, obj_what)
insertAfter(obj_where, obj_what)
front(), returns pointer to the object at the front.
back() , returns pointer to the object at the back.
4. cArray is a container class that holds objects derived from cObject.
cArray works as an array, but it grows automatically when it becomes
full.
The basic usage:
cArray array("array"); // Creating an array
int index = array.add( obj ); // Adding an object
int index = array.find(obj);// Finding an object
array.remove (obj)// Remove an object
Iteration
for (int i=0; i<array.size(); i++)
{
if (array[i]) // is this position used?
{
}
}
5. There are two main types of outputs: vectors and
scalars.
output vectors are to record time series data and
output scalars are supposed to record a single value per
simulation run.
Let’s record the node power after every transmission
operation. To do that add the following:
1. cOutVector TxEnergy;// in Node.h
2. TxEnergy.setName("NodePower");// in Node.cc (initialize())
3. TxEnergy.record(energy);// after updating node energy
Save, build, and run.
6. A folder called “results” will be generated.
Click one of VEC files to generate an analysis file (.anf).
Select “result” as parent folder -> name it-> click finish.
7. Click Wildcard to add all other VEC files in single ANF
file.
Browse data to get the following results
8. You may want to record the distribution as a histogram
(not as a time series).
Syntax: cHistogram hData;
hData.collect(value);// to insert a new value.
Other functions can be used to get the statics, for
example:
hData.getCount(), hData.getMin(),
hData.getMax(), hData.getMean(),
hData.getStddev(), hData.getVariance(),
hData.getSum(), hData.getSqrSum().
9. Let’s record node life time, which is the time that a
node takes before it dies:
1. At Node.h
2. At Node.cc
10. Save, Build and run
Play with the properties to get:
11. An eventlog file contains a log of messages sent during
the simulation and the details of events that prompted
their sending or reception.
The Sequence Chart displays eventlog files in a
graphical form.
Add: record-eventlog = true # In omnetpp.ini
Save and run.
12. ELOG files will be generated.
Double-Click one of them to watch the sequence chart.