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 sweeping victory of the clergy under the banner of Muttahida Majlis e Amal (MMA) in the last general polls in the NWFP and parts of Balochistan has rocked the wisdom of nationalist leaders who failed to comprehend the changing dynamics of Pashtun politics. . . . Read More

ضحاک تازي، د متي پښتنو نيکه ، ډاکټر چراغ حسېن شاه

ضحاک يا سهاک څوک وو؟ د کوم نسل نه وو؟ او ايراني او زردشتي روايات د ده په باره کښې څه ليکي؟ ضحاک د شام د ملک يو افسانوي شهزاده وو چا چه د جمشېد بادشاه د مړ کولو نه پس د ايران په تخت قبضه اوکړه۔ . . . نور



Old Kandahar is a large, impressive ruin field near Afghanistan's modern second city, bearing the same name. For years the site has been central to many arguments about the most ancient geography and history of the region. It has been identified with an Alexandria/ Alexandropolis, referring to the conquest of Alexander the Great.For the Islamic period the excavations on behalf of the Society for Afghan Studies have revealed some striking new evidence, particularly for the period of the Arab Conquest during the later 7th and early 8th century. . . . Read More

Aerial Firing - A Menace , Zafar Ali Usafzai

"Life is a narrow vale between the cold and barren peaks of two eternities. We strive in vain to look beyond the heights. We cry aloud-and the only answer is the echo of our wailing cry. From the voiceless lips of the unreplying dead there comes no word. But in the night of Death, Hope sees a star." --------- Robert Green Ingersoll (1833-1899) . . . Read More


Ghulam Ishaq Khan was born on January 20, 1915, in Ismail Khel, Bannu District. He did his graduation in Chemistry and Botany and joined the NWFP Civil Service in 1940. After the unification of West Pakistan into One Unit in 1955, Ishaq Khan was appointed Provincial Secretary of West Pakistan for Irrigation Development. . . . 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)