wsn-ping.cc example

100 views
Skip to first unread message

Jaspal Singh

unread,
May 31, 2016, 6:05:02 AM5/31/16
to ns-3-users

Greetings!

I am new to NS, just downloaded NS2.35. I wish to use NS3 for simulating WSN. On browsing through the examples I came across example wsn-ping6.cc. Need help on few queries regarding the same:

I tried creating network with 100 nodes and allotted random positions to those (this was a minor change as listed below):

  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
 
   Ptr <UniformRandomVariable> x= CreateObject <UniformRandomVariable>();
   Ptr<ListPositionAllocator> nodesPositionAlloc = CreateObject<ListPositionAllocator> ();
   int nodeCount, xPos, yPos;
   for (nodeCount=1; nodeCount<=100; nodeCount++)
   {
       xPos=((int)(x->GetValue()*1000))%100+1; yPos=((int)(x->GetValue()*1000))%100+1;
       std::cout << "Adding node at position (" << xPos << ", " << yPos << ")" << std::endl;
       nodesPositionAlloc->Add (Vector (xPos, yPos, 0.0));
   }
   mobility.SetPositionAllocator (nodesPositionAlloc);
   mobility.Install (nodes);
 

Now I wish to simulate Direct communication between nodes and the sink and I don't know how to proceed.

I understand this would require:
1. Creating a sink
2. Making the nodes send data packets to the sink after fixed time intervals
3. I also need to compute remaining energy after each communication.

Regards,
Jaspal Singh.

Tommaso Pecorella

unread,
May 31, 2016, 9:01:48 AM5/31/16
to ns-3-users
Hi,

I'd suggest to start with the tutorial. It explains about all these things.

Cheers,

T.

Jaspal Singh

unread,
May 31, 2016, 9:11:15 AM5/31/16
to ns-3-users

Thanks,

Tried searching ns3 tutorials for WSN, lr-wpan, but got no  results.

https://www.nsnam.org/docs/tutorial/html/search.html?q=lr-wpan
https://www.nsnam.org/docs/tutorial/html/search.html?q=wsn

Sorry, but could you suggest some links.

Regards,

Jaspal Singh

unread,
May 31, 2016, 9:50:24 AM5/31/16
to ns-3-users

All right,

On browsing through the tutorial, I see that these are  step by step explanation of the example scripts. I'll go through these before posting my next question.

Thanks.
Reply all
Reply to author
Forward
0 new messages