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


د جرمني په مرکز برلین ښار کې د نورو ګڼو ښوونیزو مرکزونو ترڅنګ دری لوی پوهنتونونه: د برلين تخنيکي پوهنتون، د برلين آزاد پوهنتون او د برلين آمبولټ پوهنتون فعالیت کوي. د برلین تخنیکي پوهنتون ډېری تخنیکي څانګې لري او د نړۍ له بېلابېلو هېوادونو محصلين په کې زده کړه کوي. زموږ ۲۴ کسیز ټیم چې د افغانستان له بېلابېلو اتو پوهنتونونو څخه راغلي یو، . . . نور


The ravages of the decade-long armed conflict in Afghanistan between the Soviets and anti-communist forces were not confined to Afghanistan. Rather, its ill effects spilled over to neighboring countries. One effected country of note was Pakistan, which was used as a base for war activities. Pakistan served as a home to arms depots and camps for training guerillas, and as a passageway for logistic supplies and other activities for the co-ordination of the war effort. . . . Read More


په افغانستان کې د سرو پوځونو په ضد عمومي پاڅون د يوې داسې سپېڅلې جذبې په تړاو راټوکېدلى و چې نه يې يواځې د افغان ځلمو مټو ته زور بښلى و بلکې د افغاني ليکوالو او شاعرانو ژبې او قلمونه يې هم د تورې په شان تېره کړي وه. همدا وجه وه چې کله به دوى څه ويل نو د افغانانو په جهادي جذبه به يې د ايمان د نور پخلي مېخونه ټک وهل او . . . نور

The State of Dir , Simon Gillett

Throughout the 19th century the Khans of Dir effectively controlled only upper Dir and their attempts to dominate lower Dir and even lower Swat were strongly resisted. A notable opponent was the famous Umra Khan of Jandool, a bitter enemy of British hegemony. . . . Read More


Located inside the compound of the Mission Hospital stands a most unique historical monument of Peshawar dating back to Mughal times. The dome shaped structure is thought to be the garden tomb of Nawab Sayid Khan, the Mughal governor . . . Read More


Muslim authors agree that the Khalaj are one of the earliest tribes to have crossed the Oxus. In addition to I. Khurdadhbih whom we have quoted above, Istakhri (circa AD 930) says: "The Khalaj are a class of Turks who in the days of the old (fi qadim al-ayyam) came to the country stretching between India and the districts of Sijistan, behind Ghur. . . . 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)