Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.29 KB | None | 0 0
  1.     // Later, we add IP addresses.
  2.     NS_LOG_INFO ("Assignings IP Addresses.");
  3.     Ipv4AddressHelper ipv4_n;
  4.     //ipv4_n.SetBase ("10.1.0.0", "255.255.0.0");
  5.  
  6.     NS_LOG_INFO ("Create Links Between Nodes");
  7.     uint32_t linkCount = 0;
  8.  
  9.     Ipv4InterfaceContainer n_ic[nodes.GetN()][nodes.GetN()];
  10.  
  11.     for (size_t i = 0; i < nodes.GetN(); i++)
  12.     {
  13.         for (size_t j = 0; j < nodes.GetN(); j++)
  14.         {
  15.             if (NICM[i][j][2] != -1)
  16.             {
  17.                 NodeContainer n_links = NodeContainer (nodes.Get (i), nodes.Get (j));
  18.                 NetDeviceContainer n_devs = p2phelper.Install (n_links);
  19.                     char * cstr;
  20.                     std::stringstream ss;
  21.                     ss << "10.1." << 1+j << ".0";
  22.                     cstr = new char [ss.str().size()+1];
  23.                     strcpy(cstr, ss.str().c_str());
  24.                     ipv4_n.SetBase(cstr, "255.255.255.0");
  25.                 n_ic[i][j] = ipv4_n.Assign (n_devs);
  26.                 ipv4_n.NewNetwork ();
  27.                 linkCount++;
  28.                 NS_LOG_INFO ("matrix element [" << i << "][" << j << "] is " << NICM[i][j][2]);
  29.             }
  30.             else
  31.             {
  32.             NS_LOG_INFO ("matrix element [" << i << "][" << j << "] is -1");
  33.             }
  34.         }
  35.  
  36.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement