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

طور علي د لکي مروت سره خواه کښې سلطان خېل کېچئ کمبر کلي اوسېدونکې دې۔ مخکښې دوئي په ورکوټوالي کښې ماشوم او۔ بيا چه کله ستر شو نو د پير والي ضلعې کښې D.I.G جوړ شو۔ پوليس ډيوټي کښې ئې د لکي مروت ډېر خلق په محکمه کښې بهرتي کړل۔ . . . نور

Kaghan valley is one of the prime tourist attractions of Pakistan. Stretched over 160 km, it is abound with snow-clad mountains, flowery meadows, enchanting lakes, and dense forests. With so much to offer, it provides an exhilarating experience; seeked after by thousands of tourists who flock the valley each year. . . . Read More

According to Tribal Laws and Tradition, the plantation of Wild Hemp or Cannabis (known as Bhang) & Opium (known as Afeem) is considered perfectly legal. However, the Taleban Government in Afghanistan had its effects felt in Tirah because under their influence, the local Ulema also banned its plantation in certain areas. . . . Read More

German Activities in NWFP (1914-45) , Dr. Syed Waqar Ali Shah

The region designated by the British Colonial rulers as the North-West Frontier Province of India has always played a significant role in the making of Indian history owing to its crucial geopolitical location. Once a passage of invaders . . . Read More

Aftab Ahmad Khan Sherpao , Muhammad Riaz

The rise of the Sherpao family to political eminence has come within a short span of time. This is remarkable given the fact that its home province, the NWFP, has traditionally been dominated by veterans like late Khan Abdul Ghaffar Khan, . . . Read More

Professor Feroze Shah , Prof Dr Muhammad Hafizullah

Though the weather has taken a turn for cooler nights, the days are still hot. The funeral of one of the pioneers of surgery in NWFP, Khyber Teaching hospital and Khyber Medical College and a very revered doctor and colleague was organised for 11 am. . . . 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)