[ndnSIM] change consumer and producer randomly

Zeinab Rezaiefar z.rezaiefar at yahoo.com
Fri Apr 29 23:16:26 PDT 2016


hello,thank you so much Spyridon for nice explanation . I have defined random consumers and providers scenario for four nodes as below: NodeContainer nodes;
  nodes.Create (5);  // Connecting nodes using two links
  PointToPointHelper p2p;
  p2p.Install (nodes.Get (0), nodes.Get (4));
  p2p.Install (nodes.Get (4), nodes.Get (2));
p2p.Install (nodes.Get (3), nodes.Get (4));
  p2p.Install (nodes.Get (1), nodes.Get (4));
  // Install NDN stack on all nodes
  ndn::StackHelper ndnHelper;
ndnHelper.SetPit ("ns3::ndn::pit::Lru","PitEntryPruningTimout","20");
  ndnHelper.SetDefaultRoutes (true);
ndnHelper.SetContentStore("ns3::ndn::cs::Lru", "MaxSize", "1000000000");
  //ndnHelper.InstallAll ();
ndnHelper.Install(nodes.Get (4));
ndnHelper.SetContentStore("ns3::ndn::cs::Nocache");
ndnHelper.Install(nodes.Get (0));
ndnHelper.Install(nodes.Get (1));
ndnHelper.Install(nodes.Get (2));
ndnHelper.Install(nodes.Get (3));
//*****************4/27
Ptr<UniformRandomVariable> x = CreateObject<UniformRandomVariable> ();
 ndn::AppHelper consumerHelper ("ns3::ndn::ConsumerCbr");
 ndn::AppHelper producerHelper ("ns3::ndn::Producer");
consumerHelper.SetPrefix ("/prefix");
  consumerHelper.SetAttribute ("Frequency", StringValue ("5")); // 5 interests a second
 ApplicationContainer consumer[4][20];
producerHelper.SetPrefix ("/prefix");
  producerHelper.SetAttribute ("PayloadSize", StringValue("1024"));
ApplicationContainer producer[4][21];for ( int i=0;i <10;i++)
{
int provider=x->GetInteger (0,3);
int user=x->GetInteger (0,3);
while( (provider)==(user)){
user=x->GetInteger (0,3);
}

consumer[user][i]=consumerHelper.Install (nodes.Get (user)); 
consumer[user][i].Start(Seconds(2*i));
consumer[user][i].Stop(Seconds(2*i+1));
producer[provider][i]=producerHelper.Install (nodes.Get (provider));
producer[provider][i].Start(Seconds(2*i));
producer[provider][i].Stop(Seconds(2*i+2));
std::cout <<"provideris :"<<provider<<"user is "<<user<< std::endl; // the integer random value in the range of  [0,3] 
}
It works. however, if you think something is strange from time perspective ( start and stop time duration) or any other perspective, I will become so happy and thankful to let me know.thanks in advancebest regards 

    On Friday, April 29, 2016 6:26 AM, Spyridon (Spyros) Mastorakis <mastorakis at cs.ucla.edu> wrote:
 

 Hi,
in your simulation scenario, every time that you call the install method for an application, this call returns a container of the applications installed. In this way, you can collect all the application instances and then generate a random number and decide which application instance to start first using the StartApplication method and a specified time point.
You can schedule any actions that you would like your application to take as NS3 events in the code of your application.
Hope that this helps.
Spyridon (Spyros) Mastorakis
Personal Website: http://cs.ucla.edu/~mastorakis/
Internet Research Laboratory
Computer Science Department
UCLA


On Apr 27, 2016, at 7:49 PM, Zeinab Rezaiefar <z.rezaiefar at yahoo.com> wrote:
 Hello every one,I would like to know how I can change consumer and producer randomly during simulation time. let consider we have 5 nodes and node 1 to node 4 all connect to the node 5  and then select two nodes among node 1 to node 4  as consumer and producer. I would like to know how I should schedule them that after every 1 second, the producer and consumer change while all of the users request the same content. moreover, for example user 1 sends request for the specific packet at second one and later at second 8 again this user may send request for this packet. any help will be appreciatethanks in advanceregardsZeinab  



  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.lists.cs.ucla.edu/pipermail/ndnsim/attachments/20160430/4b26d775/attachment.html>


More information about the ndnSIM mailing list