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

دا نننۍ خبره نۀ ده، بلکې له هغه وخت څخه چې په افغانستان کښې نوے سياسي نظام منځته راغلے دے، نۀ يواځې حکومت په بيا بيا طالبانو اؤ نورو دولت مخالفو ډلو ته عفوه اعلان کړې اؤ د هېواد په سياسي اؤ جمهوري نظام کښې د ګډون بلنه يې ورکړې بلکې ځينيو نورو خلکو هم دا غوښتنه کړې چې طالبان اؤ نورې دولت مخالف ډلې دې د هېواد په سياسي اؤ . . . نور

ګدړی او ليوو کيسه ، ذبیح لله شریفي

وای یوه ورځ په یوه وچ زنګله کی یو لیوو او یوه ګډړه سره مخ شول ګدړی له لیوو نه پښتنه وکړه چی ولی داسی سرګردانه ګرځی راګرځی څه چل درباندی شوی چی . . . نور

In the 1840s, tribal swat started to get organized with the rise of a sufi ascetic and anti british reformer named abdul ghafoor, who later became known as the akhund of swat. Akhund means theologian or religious teacher. When the british moved into Peshawar in 1849 he rallied the clans but his state collapsed after a few years. . . . Read More

Syed Muhammad Hubaan , Muhammad Shafi Sabir

The Tehreek e Mujahideen is rightly considered a very important, popular, and successful movement. A well renowned historian of modern times, Toin B. states that the Tehreek e Mujahideen was the first such movement meant for freeing the Muslims of the sub continent from the hands of the British and their cronies; the Sikhs and Hindus. . . . 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)