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

Nek Muhammad Wazir , Muhammad Ilyas Khan

With his Byronic good looks and proud tribal mien, Nek Mohammad fearlessly cruises the rugged South Waziristan landscape in the company of his infamous guests as the hapless administration looks on. Just how does he do that? . . . Read More

فرض شناسي ، حميد الله زاهد

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


For an under-developed Third World country like Pakistan which is in the process of development, cement is an essential commodity. The number of cement plants and their production volume gives an indication of the stage of development in a country. . . . Read More

ماشومانو سره دا سلوک؟ ، عبدالهادي حيران

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

Folk Poetry in Iranian Languages , Philip G. Kreyenbroek

The term 'folk poetry' can be properly used for texts which have some characteristics marking them as poetry and belong to the tradition of the common people, as against the dominant 'polite' literary culture of the area. This article will focus on those modern traditions which have been most fully described, i.e., on Persian, Tajiki, Kurdish, Pashto, and Baluchi folk poetry, with some reference to Ossetic. . . . Read More


This is an American book, but an English edition is published by MacDonald and Janes. Ostensibly it deals with the North-West Frontier, but in truth it treats the Frontier in the context of Afghanistan; the country and the people, Pathans, of both the N.W.F.P. proper (the Settled Districts) and the Tribal Areas . . . 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)