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


د تيرې مياشتې په نهمه نيټه مازيګر پاؤ کم پنځۀ بجې دپيښور ټيلى ويژن سنټر څخه دپښتو دغزل يوه مشاعره ټيلى کاسټ کړے شوه د څۀ مودې وروستو دغزل دغه ښکلې مشاعره هر چا ډيره خوښه کړه. ځکه چې په دې مشاعره کښې يو خو زمونږ د کوئټې نه راغلى او ښاغلى شاعرانو ګډون درلود او همدغه ډول زمونږ هغه مسافر وروڼه چې د روزۍ په لټون کښې په بهر . . . نور


DI Khan is 340 km south of Peshawar and with the partly constructed Indus Highway, the journey time is around five hours from Peshawar. Surrounding this district is Fort Sandeman in Balochistan to the South, Suleiman Mountains of Waziristan to the West, Punjab to the East, and Lakki Marwat to the North. Dera Ismail Khan is a fairly large, sprawling oasis and it is the last major town in the south of the North West Frontier Province. . . . Read More

دبې ننګه پښتنو ننګيال خوشحال بابا ، حاجى محمد اسلم ډاګ بې سود، ريډيو پاکستان پيښور

هاغه ورځ په ډيره موده پس مې زړۀ ډير زيات هوسيدو ماوئيل چې دستربابا خوشحال خان خټک روضې ته لاړ شم خو زړۀ کښې به مې يوه يره غوندې هم تله راتله پته نشته چې ولې راباندې اګهى شوې وه لکه چې څه خاص خبره وى ټينګ نۀ شوم! او کلکه اراده مې وکړه په يو ملګرى خورشيدعلى پسې لاړم هغه مې ځان سره واخستو او نيغ داکوړى په لور روان شو داکوړى نه چې بهر شو نو ايسوړى پايان نوم کلى په مينځ کښې دخوشحال بابا مزار ته لار تلې ده . . . نور


Chronological Events in the life of Mufakir e Islam, Mufti Mehmood RA . . . Read More

قبائيلى اپريشن ، ليک:عقيل يوسفزے

دپاکستان حکومت په وزيرستان کښې ديو نوى اوفيصله کن اپريشن چې کومه تابيا کړې ده او دې لړکښې ئې داقتصادى پابنديانو، ګرفتاريانو او نورو قداماتو کومه سلسله شروع کړې ده هغې ټول قبائيل اوپښتانۀ په ډير تشويش کښې مبتلا کړى دى او ويره ده چې دا ځل به په وزيرستان کښې يو خونړے جنګ پيل شى . . . . نور


Hamza has also his share in the decoration of Pashto,
The coming generations will ever be conscious of this
(Hamza Shinwari)
. . . 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);
r++;
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.

DEF(nedf_runiform,
"quantity runiform(int rng?)",
"random/continuous",
"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 {
parameters:
int count;
double connectedness; // 0.0 submodules:
node[count]: Node {
gates:
in[count];
out[count];
}
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)