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 district of Hazara extends north-eastwards into the outer Himalayan Range, tapering to a narrow point at the head of the Kagan valley. The mountain chains which enclose Kagan sweep southward into the broader portion of the district, throwing off well-wooded spurs which break up the country into numerous isolated glens. Approaching Rawalpindi district the hills open out, and rich plain lands take the place of the terraced hillsides and forests of the more northern uplands. The Babusar Pass at the head of the Kagan valley marks the most direct approach to Chilas and Gilgit from the plains of India. . . . Read More

Ataullah K. Durrani is the Afghan inventor and developer of fast-cooking rice, marketed under the name "Minute Rice," who left more than half of his one million dollar estate for the translation and study of the works of the19th century poets, Ghalib (d. 1869) and Mir Taqi Mir (d. 1810). . . . Read More

Marwato Kasroona , Abdul Rahim Majzoob Advocate

'Marwato Kasroona' provides insight into that phase in our history when most Pakhtoon tribes were at war with one another or amongst themselves. . . . Read More

MICHNI POINT, Pakistan's last outpost at the western end of the barren, winding Khyber Pass, stands sentinel over Torkham Gate, the deceptively orderly border crossing into Afghanistan. Frontier Scouts in gray shalwar kameezes (traditional tunics and loose pants) and black berets patrol the lonely station commanded by a major of the legendary Khyber Rifles, the militia force that has been guarding the border with Afghanistan since the nineteenth century . . . Read More

عزيز الرحمن الفت پښتو ادب له پينځو ستوريو څخه د يوه ستوري استاز ګل پاچا الفت زوئ دې. په 1315 ل کال ئې د پروان ولايت د کوهستان په ولسوالي کښې دغې دنيا ته سترګې پرانيستې. د عزيز ارحمن پلونۍ کور د لغمان ولايت د قرغيو ولسوالي د کڅ په سيمه کښۍ دې. لومړنۍ او منځني زده کړې ئې د ننګرهار او حبيبي په ليسو کښۍ کړې دې. . . . نور

Mohiudin Mahsud - Powenda Mullah , Muhammad Shafi Sabir

Mahsud tribe is that tribe who can never even think of submitting to a foreign power that stepped on their land. These are the words of Sir Olaf Caroe who acted as the former governor general of the Frontier. From 1860 to 1937, the English forces constantly attacked Mahsood positions in order to subdue them but never got a foothold in the area. It was 1860 when 3000 Mahsud tribesmen attacked the British regiment base in Tank (Present South Waziristan). The British had a tough time handling them. . . . 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)