tutorial 6 queues & arrays & results recording

12
By Mohammed Amer Al- Batati 2012 OMNet++ Step by Step Part - 6

Upload: mohd-batati

Post on 13-Jan-2017

7.236 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Tutorial 6   queues & arrays & results recording

ByMohammed Amer Al-

Batati

2012

OMNet++

Step by Step

Part - 6

Page 2: Tutorial 6   queues & arrays & results recording

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.

Queues

Page 3: Tutorial 6   queues & arrays & results recording

cQueue Example:

Iterators

Queues – cont.

Page 4: Tutorial 6   queues & arrays & results recording

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?{

}}

Expandable Array

Page 5: Tutorial 6   queues & arrays & results recording

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.h2. TxEnergy.setName("NodePower");// in Node.cc (initialize())3. TxEnergy.record(energy);// after updating node energy

Save, build, and run.

Result Recording and Analysis

Page 6: Tutorial 6   queues & arrays & results recording

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.

Output Vectors

Page 7: Tutorial 6   queues & arrays & results recording

Click Wildcard to add all other VEC files in single ANF file.

Browse data to get the following results

Output Vectors – cont.

Page 8: Tutorial 6   queues & arrays & results recording

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().

Histograms

Page 9: Tutorial 6   queues & arrays & results recording

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

Output Scalars

Page 10: Tutorial 6   queues & arrays & results recording

Save, Build and run

Play with the properties to get:

Output Scalars – cont.

Page 11: Tutorial 6   queues & arrays & results recording

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.

Eventlog and Sequence Chart

Page 12: Tutorial 6   queues & arrays & results recording

ELOG files will be generated.

Double-Click one of them to watch the sequence chart.

Sequence Chart