Random Generation of bi-directional Graphs in Omnet :: Khyber.ORG

پښتو :: پښتانه :: پښتونخواه :: پښتونوالی

Random Generation of bi-directional Graphs in Omnet, Omar Usman
Published in Khyber.ORG on Wednesday, July 4 2012 (http://www.khyber.org)

New Additions

[an error occurred while processing this directive]

From Archives

Kaghan valley is one of the prime tourist attractions of Pakistan. Stretched over 160 km, it is abound with snow-clad mountains, flowery meadows, enchanting lakes, and dense forests. With so much to offer, it provides an exhilarating experience; seeked after by thousands of tourists who flock the valley each year. . . . Read More

Reminiscing some of the stars of the secular galaxy of Pakistan and especially Khyber-Pakhtunkhwa, is an obligation not just due to a family association or personal feel-good, nostalgic reasons. It is a must because the current generations - being fed a steady diet of religious extremism masquerading as non-denominational Islam - ought to get acquainted with the history of this land. . . . Read More

هسې خو دصنعت اوتجارت په حواله دلته په پښتونخوا کښې دپنجاب خلق د پخواراسې اباددى يعنى ماهرين اواستاذان پنجابيان دى او مزدور طبقه دلته په خپلې پښتونخوا کښې هم پښتانۀ دى اوپنجاب کښې هم . . . نور

کاکاجى صنوبر حسين مومند په ١٨٩٧ کښې پيښور سره نزدې په ((کږه وله)) نومې کلى کښې پيدا شو او هم دلته ئې ابتدائى تعليم حاصل کړو دميټرک نه پس په يو سکول کښې داستاد په حيث نوکر شو خو دخپل انقلابى فکر اوانګريزدشمنۍ په سبب ملازمت ئې پريښود. او په علاقه کښې ئې دکسانانو او مزدورانوتنظيم سازۍ سره سره دوطن دازادۍ جدوجهد ئې خپل مقصد وګرځولو عملى سياست ئې دخدائى خدمتګار او بيا دکانګرس دپليټ فارم نه شروع کړو خو دخپل تيز . . . نور

The life story of the great and the finest Pukhtoon Khan Abdul Ghaffar Baacha Khan is in fact, the history of Pukhtoons, replete with his life-long trials and sufferings his simple patience, resignation and deep concern for the good of humanity, at large. . . . Read More

Dr Sher Zaman Taizi is a known literary figure in the world of Pushto literature. With typical Pakhtoon features, he is a soft spoken and well-articulated man of letters. His contribution to Pushto literature is born from his love of the language and his commitment to a cause . . . Read More

Random Generation of bi-directional Graphs in Omnet

Omar Usman

Publishing Date: Wednesday, July 4 2012

The Omnet usman.html manual has code for generation of random topologies. The type of network generated can contain uni-directional, or bi-directional edges. Usually, people working with networks require generation of bi-directional graphs only. What you will see here is a small hack to the Omnet Engine, which can enable you to do that. (Note: I am not an expert on Omnet so most probably there is another simpler way of doing this. If you do, please leave a comment).

The files you need to modify are:

  1. src/sim/distrib.cc
  2. include/distrib.h
  3. src/sim/nedfunctions.cc

Modifications to distrib.cc

You need to create a new function (runiform). What this does is that it retains the random number generated from a previous call to uniform(). The random number is generated every 2-calls.

double runiform(int rng) {
static int r = 0;
static double l = 0;
if(r%2 == 0) l = uniform(0,1);
return l;

Modifications to distrib.h

Just one line to be modified here:

SIM_API double runiform(int rng=0);

Modifications to nedfunctions.cc

The current usman.html manual (July 4, 2012) shows a different way of doing this. The code in the manual is not consistent with what I found in the source (4.2.2). You need to add the following code to where the other continuous random variate generation code is present.

"quantity runiform(int rng?)",
"Retains the value generated from a previous call to uniform()",
int rng = argc==2 ? (int)argv[1] : 0;
return cNEDValue(runiform(rng), argv[0].getUnit());

Compilation and Usage

If you have already compiled omnet once, you can simply run make and compile the engine again. When complete, fire up your editor and open your .NED file. You can now generate bi-directional graphs using the following code from the manual (which is adopted to this hack):

module RandomGraph {
int count;
double connectedness; // 0.0 submodules:
node[count]: Node {
connections allowunconnected:
for i=0..count-1, for j=0..count-1 {
node[i].out[j] --> node[j].in[i]
if i<j && runiform() > connectedness;
node[j].out[i] --> node[i].in[j]
if i<j && runiform() > connectedness;

Comments powered by Disqus

Random Generation of bi-directional Graphs in Omnet, Omar Usman
Published in Khyber.ORG on Wednesday, July 4 2012 (http://www.khyber.org)