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

Ghilzai : Iranica , Muhammad Jamil Hanifi

Ghilzi or Ghilzi (Pashto plural of singular masculine Ghilzai and singuler feminine Ghilzayi) are one of three major Pashtun tribal confederations in Afghanistan. The other two are the Durrani, formerly the Abdali, in western Afghanistan and the Karlani, who straddle the border between . . . Read More

Sherani Folk Tales , Sir Lucas King

A collection of various stories such as Samandar & the Rajah's Daughter, the Thumbling & the Thieves, The Prince & the Goldsmith's Daughter, Sheikh Khwaja, and more . . . Read More

د بغداد نه بهر يوه کلي کي دوه وروڼه اوسيدل چي يو يي محمد او بل يي احمد نوميده .پلار و مور يي لاډيرپخوا له دنيا نه سترګي پټي کړي او دواړه زامن يي يتيمان او بي اسري پري ايښي وو .دواړه وروڼه چي کله د لويوالي منګ ته ورسيدل کړراور يي سره جلا کړل.٠. . . . نور

درنو لوستونکو! داسې ويل کېږي، چې غومبسې په ژمي کې چېرې په يوه تاوده ځای کې په سورويو کې د ژمي خوبونه کوي او بنډارونه يې تاوده وي، چې هوا بيا راتوده شي او د ګلانو موسوم شي، نو دوی هم په بوږنېدا شي او په يوه او يا بل ځای کې ځالې جوړې کړي، د ګلانو په نشتارو . . . نور

The Pathan Unarmed , Mukulika Banerjea

Pathans are commonly associated with the full gamut of violence, from the domestic variety through tribal feud to armed resistance to outsiders. Accordingly, a peculiar interest attaches itself to the Khudai Khidmatgars or Servants of God, often referred to as the Red Shirts, a Pathan organization which professed (and sometimes practised) non-violence in the North West Frontier province of British India during the 1930s and 1940s. . . . 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)