Simulating Mesh Topology

668 views
Skip to first unread message

Michael Ibrahim

unread,
Aug 23, 2010, 11:04:28 AM8/23/10
to ns-3-users
Hello Everyone,
I am doing some simulations on mesh networks,
I am comparing the performance of AODV, OLSR, and HWMP
I am using a "RandomDiscPositionAllocator",
I run the same configuration 10 times using random seeds, so that I
can get more accurate results,
the problem is that:
in HWMP the results are identical regardless of the seed ???
while in the AODV simulation as the seed changes the performance
changes slightly.
I had this problem with ns 3.8 and 3.9 .

Thanks a lot for your help,
Regards
Michael Ibrahim

Kirill And

unread,
Aug 25, 2010, 12:36:03 AM8/25/10
to ns-3-...@googlegroups.com
Hi!

2010/8/23 Michael Ibrahim <michae...@gmail.com>:


> Hello Everyone,
> I am doing some simulations on mesh networks,
> I am comparing the performance of AODV, OLSR, and HWMP
> I am using a "RandomDiscPositionAllocator",
> I run the same configuration 10 times using random seeds, so that I
> can get more accurate results,
> the problem is that:
> in HWMP the results are identical regardless of the seed ???

Well, random variables used in HWMP do not differ from random
variables used in AODV, so, it looks very strange. Could you send me
you scenario?


> while in the AODV simulation as the seed changes the performance
> changes slightly.
> I had this problem with ns 3.8 and 3.9 .
>
> Thanks a lot for your help,
> Regards
> Michael Ibrahim
>

> --
> You received this message because you are subscribed to the Google Groups "ns-3-users" group.
> To post to this group, send email to ns-3-...@googlegroups.com.
> To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/ns-3-users?hl=en.
>
>

--
Regards, Kirill Andreev
Wireless Software R&D Group,
IITP RAS

Michael Ibrahim

unread,
Sep 1, 2010, 1:58:31 PM9/1/10
to ns-3-users
Thanks a lot for your reply,
here is the code I am using

// Mesh Network Simulation Ver 0.3
// Using UniformDiscPositionAllocator
// Based on Code provided with ns3 - code build by Kirill Andreev
<and...@iitp.ru>


#include "ns3/core-module.h"
#include "ns3/simulator-module.h"
#include "ns3/node-module.h"
#include "ns3/helper-module.h"
#include "ns3/global-routing-module.h"
#include "ns3/wifi-module.h"
#include "ns3/mesh-module.h"
#include "ns3/mobility-module.h"
#include "ns3/mesh-helper.h"
#include "ns3/flow-monitor-module.h"
#include "ns3/random-variable.h"

#include <iostream>
#include <sstream>
#include <fstream>
#include <stdio.h>
#include <time.h>
#include <cmath>

using namespace ns3;

NS_LOG_COMPONENT_DEFINE ("TestMeshScript");

int main (int argc, char *argv[])
{
char myfilename [100];
char datarate[10];
ofstream myofile;
int m_rho(100);
int m_number_of_nodes(10);
// double m_step;
double m_randomStart(0.1);
double m_totalTime(10);
double m_packetInterval(0.032); //), //0.032 ==>
250kbps 0.1 ==> // 80 Kbps = 10 packets per sec * 1024 byte
per packet (1 Kbyte) * 8 bits per byte
float pi(3.14159265);
uint16_t m_packetSize(1024);
uint32_t m_nIfaces(1);
bool m_chan(true);
bool m_pcap(true);
bool m_verbose(true);
std::string m_stack("ns3::Dot11sStack");
std::string m_root("00:00:00:00:00:01"); //
("ff:ff:ff:ff:ff:ff");//
// List of network nodes
NodeContainer nodes;
NodeContainer root_node;
// List of all mesh point devices
NetDeviceContainer meshDevices;
NetDeviceContainer root_meshDevice;
//Addresses of interfaces:
Ipv4InterfaceContainer interfaces;
Ipv4InterfaceContainer root_interface;
// MeshHelper. Report is not static methods
MeshHelper mesh;
// Flow Monitor
FlowMonitorHelper flowmon;
Ptr<FlowMonitor> monitor;

std::sprintf (myfilename, "mesh_network_ver_0.3.tr");
std::sprintf (datarate,"250Kbps");

CommandLine cmd;
cmd.AddValue ("rho", "Radius of the Disc", m_rho);
cmd.AddValue ("number-of-nodes", "Number of nodes [10]",
m_number_of_nodes);
/*
* As soon as starting node means that it sends a beacon,
* simultaneous start is not good.
*/
cmd.AddValue ("start", "Maximum random start delay, seconds. [0.1
s]", m_randomStart);
cmd.AddValue ("time", "Simulation time, seconds [100 s]",
m_totalTime);
cmd.AddValue ("packet-interval", "Interval between packets in UDP
ping, seconds [0.1 s]", m_packetInterval);
cmd.AddValue ("packet-size", "Size of packets in UDP ping",
m_packetSize);
cmd.AddValue ("interfaces", "Number of radio interfaces used by each
mesh point. [1]", m_nIfaces);
cmd.AddValue ("channels", "Use different frequency channels for
different interfaces. [true]", m_chan);
cmd.AddValue ("pcap", "Enable PCAP traces on interfaces. [true]",
m_pcap);
cmd.AddValue ("verbose", "Enable UDP Applications to log
[true]",m_verbose);
cmd.AddValue ("stack", "Type of protocol stack. ns3::Dot11sStack by
default", m_stack);
cmd.AddValue ("root", "Mac address of root mesh point in HWMP",
m_root);
cmd.AddValue ("myfilename", "Output File Name: ", myfilename);
cmd.AddValue ("datarate", "On-Off Source Data Rate", datarate);

cmd.Parse (argc, argv);
/* NS_LOG_DEBUG ("Simulation Time");*/
NS_LOG_DEBUG ("Simulation time: " << m_totalTime << " s");


nodes.Create (m_number_of_nodes);
root_node.Add (nodes.Get(0));

// Configure YansWifiChannel
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default
();
wifiPhy.SetChannel (wifiChannel.Create ());

/*
* Create mesh helper and set stack installer to it
* Stack installer creates all needed protocols and install them to
* mesh point device
*/
mesh = MeshHelper::Default ();
// m_root =
if (!Mac48Address (m_root.c_str ()).IsBroadcast ())
{
mesh.SetStackInstaller (m_stack, "Root", Mac48AddressValue
(Mac48Address (m_root.c_str ())));
}
else
{
//If root is not set, we do not use "Root" attribute, because it
//is specified only for 11s
mesh.SetStackInstaller (m_stack);
}
if (m_chan)
{
mesh.SetSpreadInterfaceChannels (MeshHelper::SPREAD_CHANNELS);
}
else
{
mesh.SetSpreadInterfaceChannels (MeshHelper::ZERO_CHANNEL);
}
mesh.SetMacType ("RandomStart", TimeValue (Seconds(m_randomStart)));
// Set number of interfaces - default is single-interface mesh point
mesh.SetNumberOfInterfaces (m_nIfaces);


// Install protocols and return container if MeshPointDevices
meshDevices = mesh.Install (wifiPhy, nodes);

// cout << meshDevices.Get(0)->GetAddress()<<endl;
// root_meshDevice = mesh.Install (wifiPhy, root_node);
// Setup mobility - static grid topology
MobilityHelper mobility;

// seed0={65487979,54654879,4564689,54649879,56468797,56612133};
//
seed1={39937816,98795323,8796364546,654689898,98795656,987567687};

/* initialize random seed: */
// srand ( time(NULL) );

// RandomVariable::UseDevRandom();
// RngStream::SetPackageSeed(rand());
srand (time(NULL));
SeedManager::SetSeed (rand());
cout << rand() << endl;
SeedManager::SetRun (1);
UniformVariable rv_rho (0, m_rho);
// rv_rho::RngStream.SetPackageSeed([548798, 65489, 65648489,
321315, 654898, 12354654]);
// RngStream::SetPackageSeed(rand());
/* srand (time(NULL));
SeedManager::SetSeed (rand());
cout << rand() << endl;
SeedManager::SetRun (5);*/
UniformVariable rv_theta (0, 2*pi);
// rv_theta::RngStream.SetPackageSeed([548798, 65489, 65648489,
321315, 654898, 12354654]);


ObjectFactory position;
position.SetTypeId ("ns3::RandomDiscPositionAllocator");
position.Set ("X", DoubleValue(0.0)); // Center
of the Disc X-coordinate
position.Set ("Y", DoubleValue(0.0)); // Center
of the Disc Y-coordinate
position.Set ("Rho", RandomVariableValue(rv_rho));
position.Set ("Theta", RandomVariableValue(rv_theta));

Ptr<RandomDiscPositionAllocator> allocator = position.Create()->
GetObject<RandomDiscPositionAllocator> ();
// allocator->SetN(m_xSize);

mobility.SetPositionAllocator (allocator);
// cout << allocator-> GetNext() << endl;
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (nodes);



ObjectFactory root_position;
root_position.SetTypeId ("ns3::UniformDiscPositionAllocator");
root_position.Set ("X", DoubleValue(0.0)); //
Center of the Disc X-coordinate
root_position.Set ("Y", DoubleValue(0.0)); //
Center of the Disc Y-coordinate
root_position.Set ("rho", DoubleValue(0.1));

Ptr<UniformDiscPositionAllocator> root_allocator =
root_position.Create()-> GetObject<UniformDiscPositionAllocator> ();
// allocator->SetN(m_xSize);

// cout << root_allocator-> GetNext() << endl;
mobility.SetPositionAllocator (root_allocator);

mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");

mobility.Install (root_node);



if (m_verbose)
{
LogComponentEnable ("UdpClientApplication",LOG_LEVEL_INFO);
LogComponentEnable ("UdpServerApplication",LOG_LEVEL_INFO);
}

// if (m_pcap)
// {
// wifiPhy.EnablePcapAll (std::string ("mp-"),false);
// AsciiTraceHelper ascii;
// wifiPhy.EnableAsciiAll(ascii.CreateFileStream ("mesh.tr"));
// }

InternetStackHelper internetStack;
internetStack.Install (nodes);
// internetStack.Install (root_node);
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
interfaces = address.Assign (meshDevices);



// interfaces = address.Assign (meshDevices);
// address.SetBase ("10.1.2.0", "255.255.255.0");
// root_interface = address.Assign
(meshDevices.Get(m_number_of_nodes-1));

// UdpServerHelper udpServer (9);
// ApplicationContainer serverApps = udpServer.Install
(root_node.Get(0));//(nodes.Get (m_number_of_nodes-1));
// serverApps.Start (Seconds (0.0));
// serverApps.Stop (Seconds (m_totalTime));
//
// UdpClientHelper udpClient (interfaces.GetAddress
(m_number_of_nodes-1), 9);
// udpClient.SetAttribute ("MaxPackets", UintegerValue ((uint32_t)
(m_totalTime*(1/m_packetInterval))));//UniformVariable x(0,10);
// udpClient.SetAttribute ("Interval", TimeValue (Seconds
(m_packetInterval)));
// udpClient.SetAttribute ("PacketSize", UintegerValue
(m_packetSize));
// ApplicationContainer clientApps = udpClient.Install (nodes.Get
(0));
// clientApps.Start (Seconds (0.0));
// clientApps.Stop (Seconds (m_totalTime));


OnOffHelper onoffHelper ("ns3::UdpSocketFactory", InetSocketAddress
(interfaces.GetAddress (0), 9));
onoffHelper.SetAttribute ("DataRate", StringValue (datarate));
onoffHelper.SetAttribute ("PacketSize", UintegerValue
(m_packetSize));

ExponentialVariable ontime(0.5);
ExponentialVariable offtime(0.5);
RandomVariableValue onontime = RandomVariableValue (ontime);
RandomVariableValue offofftime = RandomVariableValue (offtime);
onoffHelper.SetAttribute ("OnTime", onontime);
onoffHelper.SetAttribute ("OffTime", offofftime);

ApplicationContainer apps;

// UniformVariable on_sources (1,m_number_of_nodes-1);
// int temp = on_sources.GetInteger(1,m_number_of_nodes-1);
// apps.Add (onoffHelper.Install (nodes.Get (temp)));
//
// temp = on_sources.GetInteger(1,m_number_of_nodes-1);
// apps.Add (onoffHelper.Install (nodes.Get (temp)));
//
// temp = on_sources.GetInteger(1,m_number_of_nodes-1);
// apps.Add (onoffHelper.Install (nodes.Get (temp)));
//
// temp = on_sources.GetInteger(1,m_number_of_nodes-1);
// apps.Add (onoffHelper.Install (nodes.Get (temp)));

for (int ii=1; ii<=(m_number_of_nodes/2); ii++)
{
apps.Add (onoffHelper.Install (nodes.Get (ii)));
}

monitor = flowmon.InstallAll();



// void
// MeshTest::Report ()
// {
// unsigned n (0);
// for (NetDeviceContainer::Iterator i = meshDevices.Begin (); i !=
meshDevices.End (); ++i, ++n)
// {
// std::ostringstream os;
// os << "mp-report-" << n << ".xml";
// // std::cerr << "Printing mesh point device #" << n << "
diagnostics to " << os.str () << "\n";
// std::ofstream of;
// of.open (os.str().c_str());
// if (! of.is_open ())
// {
// std::cerr << "Error: Can't open file " << os.str() << "\n";
// return;
// }
// mesh.Report (*i, of);
// of.close ();
// }
//
// }

Simulator::Stop (Seconds (m_totalTime));
Simulator::Run ();

myofile.open (myfilename,ios::app);

monitor->CheckForLostPackets(Seconds(m_totalTime));
Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier>
(flowmon.GetClassifier());
std::map<FlowId, FlowMonitor::FlowStats> stats = monitor-
>GetFlowStats();
std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i;
for (i=stats.begin();i != stats.end(); i++)
{
Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow(i->first);
// std::cout << "Flow " << i->first << " ( " << t.sourceAddress <<
" --> " << t.destinationAddress << " ) " << endl;
// std::cout << "delaySum : " << i->second.delaySum << endl;
// std::cout << "lastDelay : " << i->second.lastDelay << endl;
// std::cout << "jitterSum : " << i->second.jitterSum << endl;
// std::cout << "Tx Packets : " << i->second.txPackets << endl;
// std::cout << "Rx Packets : " << i->second.rxPackets << endl;
// std::cout << "Lost Packets : " << i->second.lostPackets <<
endl;
// std::cout << "Throughput : " << i->second.rxPackets *
m_packetSize * 8 /(1024 * 1024 * m_totalTime ) << " Mbps"<< endl;
// monitor->CheckForLostPackets(Seconds(m_totalTime));
myofile << m_number_of_nodes << ",\t\t"<<i->first << ",\t\t" << i-
>second.delaySum << ",\t\t" << i->second.txPackets << ", \t\t\t" << i-
>second.rxPackets <<",\t\t\t" << i->second.txPackets - i-
>second.rxPackets <<",\t\t\t" << i->second.rxPackets * m_packetSize *
8 /(1024 * 1024 * m_totalTime ) << endl; //i->second.txPackets - i-
>second.rxPackets

}
myofile.close();
Simulator::Destroy ();
return 0;
}

Regards
Michael Ibrahim


On Aug 25, 12:36 am, Kirill And <and.kir...@gmail.com> wrote:
> Hi!
>
> 2010/8/23MichaelIbrahim<michael.na...@gmail.com>:
>
> > Hello Everyone,
> > I am doing some simulations on mesh networks,
> > I am comparing the performance of AODV, OLSR, and HWMP
> > I am using a "RandomDiscPositionAllocator",
> > I run the same configuration 10 times using random seeds, so that I
> > can get more accurate results,
> > the problem is that:
> > in HWMP the results are identical regardless of the seed ???
>
> Well, random variables used in HWMP do not differ from random
> variables used in AODV, so, it looks very strange. Could you send me
> you scenario?
>
> > while in the AODV simulation as the seed changes the performance
> > changes slightly.
> > I had this problem with ns 3.8 and 3.9 .
>
> > Thanks a lot for your help,
> > Regards
> >MichaelIbrahim
>
> > --
> > You received this message because you are subscribed to the Google Groups "ns-3-users" group.
> > To post to this group, send email to ns-3-...@googlegroups.com.
> > To unsubscribe from this group, send email to ns-3-users+...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/ns-3-users?hl=en.

Kirill And

unread,
Sep 3, 2010, 8:01:47 AM9/3/10
to ns-3-...@googlegroups.com
Hi!

Did you try to change run number (run a script with
--RngRun=something) instead of
> SeedManager::SetRun (1);
?
When you initiate any random variable, setting other Run (after
initiation) number will NOT change anything
try ./waf --run "mesh --RngRun=1"

Reply all
Reply to author
Forward
0 new messages