Cleanup nms script
authorJosh Pelkey <jpelkey@gatech.edu>
Mon Nov 09 13:31:27 2009 -0500 (3 months ago)
changeset 5521b303a7d65a95
parent 5520 8cd6033d3886
child 5522 b4da067ee22b
Cleanup nms script
examples/mpi/nms-udp-nix.cc
     1.1 --- a/examples/mpi/nms-udp-nix.cc	Mon Nov 02 11:57:20 2009 -0500
     1.2 +++ b/examples/mpi/nms-udp-nix.cc	Mon Nov 09 13:31:27 2009 -0500
     1.3 @@ -1,13 +1,38 @@
     1.4 -// DARPA NMS Campus Network Model
     1.5 -// - This topology replicates the original NMS Campus Network model
     1.6 -// with the exception of chord links (which were never utilized in the
     1.7 -// original model)
     1.8 -// - Link Bandwidths and Delays may not be the same as the original
     1.9 -// specifications 
    1.10 -//
    1.11 -// (c)2009, GTech Systems, Inc. - Alfred Park <park@gtech-systems.com>
    1.12 -//
    1.13 -// Modified for distributed simulation by Josh Pelkey <jpelkey@gatech.edu>
    1.14 +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
    1.15 +/*
    1.16 + * This program is free software; you can redistribute it and/or modify
    1.17 + * it under the terms of the GNU General Public License version 2 as
    1.18 + * published by the Free Software Foundation;
    1.19 + *
    1.20 + * This program is distributed in the hope that it will be useful,
    1.21 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.22 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.23 + * GNU General Public License for more details.
    1.24 + *
    1.25 + * You should have received a copy of the GNU General Public License
    1.26 + * along with this program; if not, write to the Free Software
    1.27 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.28 + * 
    1.29 + * DARPA NMS Campus Network Model
    1.30 + *
    1.31 + * This topology replicates the original NMS Campus Network model
    1.32 + * with the exception of chord links (which were never utilized in the
    1.33 + * original model)
    1.34 + * Link Bandwidths and Delays may not be the same as the original
    1.35 + * specifications 
    1.36 + *
    1.37 + * 
    1.38 + * (c) 2009, GTech Systems, Inc. - Alfred Park <park@gtech-systems.com>
    1.39 + *
    1.40 + * Modified for distributed simulation by Josh Pelkey <jpelkey@gatech.edu>
    1.41 + *
    1.42 + * The fundamental unit of the NMS model consists of a campus network. The 
    1.43 + * campus network topology can been seen here: 
    1.44 + * http://www.nsnam.org/~jpelkey3/nms.png
    1.45 + * The number of hosts (default 42) is variable.  Finally, an arbitrary 
    1.46 + * number of these campus networks can be connected together (default 2) 
    1.47 + * to make very large simulations.
    1.48 + */
    1.49  
    1.50  // for timing functions
    1.51  #include <cstdlib>
    1.52 @@ -42,43 +67,42 @@
    1.53  {
    1.54  #ifdef NS3_MPI
    1.55    // Enable MPI with the command line arguments
    1.56 -  MPIInterface::Enable(&argc, &argv);
    1.57 +  MPIInterface::Enable (&argc, &argv);
    1.58  
    1.59    TIMER_TYPE t0, t1, t2;
    1.60    TIMER_NOW(t0);
    1.61    cout << " ==== DARPA NMS CAMPUS NETWORK SIMULATION ====" << endl;
    1.62  
    1.63 -  //RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8);
    1.64 -  
    1.65 -  GlobalValue::Bind("SimulatorImplementationType",
    1.66 -                        StringValue("ns3::DistributedSimulatorImpl"));
    1.67 +  GlobalValue::Bind ("SimulatorImplementationType",
    1.68 +                        StringValue ("ns3::DistributedSimulatorImpl"));
    1.69  
    1.70 -  uint32_t rank = MPIInterface::Rank();;
    1.71 +  uint32_t rank = MPIInterface::Rank ();
    1.72    uint32_t systemCount = MPIInterface::Size ();
    1.73  
    1.74    uint32_t nCN = 2, nLANClients = 42;
    1.75 -  int single = 0; // non zero if use a single flow only
    1.76    int nBytes = 500000; // Bytes for each on/off app
    1.77    bool nix = true;
    1.78  
    1.79    CommandLine cmd;
    1.80 -  cmd.AddValue("CN", "Number of total CNs [2]", nCN);
    1.81 -  cmd.AddValue("LAN", "Number of nodes per LAN [42]", nLANClients);
    1.82 -  cmd.AddValue("single", "1 if use single flow", single);
    1.83 -  cmd.AddValue("nBytes", "Number of bytes for each on/off app", nBytes);
    1.84 -  cmd.AddValue("NIX", "Toggle the use of nix-vector or global routing", nix);
    1.85 -  cmd.Parse(argc,argv);
    1.86 +  cmd.AddValue ("CN", "Number of total CNs [2]", nCN);
    1.87 +  cmd.AddValue ("LAN", "Number of nodes per LAN [42]", nLANClients);
    1.88 +  cmd.AddValue ("nBytes", "Number of bytes for each on/off app", nBytes);
    1.89 +  cmd.AddValue ("NIX", "Toggle the use of nix-vector or global routing", nix);
    1.90 +  cmd.Parse (argc,argv);
    1.91  
    1.92 -  if (nCN < 2) {
    1.93 -    cout << "Number of total CNs (" << nCN << ") lower than minimum of 2"
    1.94 -      << endl;
    1.95 -    return 1;
    1.96 -  }
    1.97 -  if (systemCount > nCN) {
    1.98 -    cout << "Number of total CNs (" << nCN << ") should be >= systemCount (" 
    1.99 -         << systemCount << ")." << endl;
   1.100 -    return 1;
   1.101 -  }
   1.102 +  if (nCN < 2) 
   1.103 +    {
   1.104 +      cout << "Number of total CNs (" << nCN << ") lower than minimum of 2" 
   1.105 +           << endl;
   1.106 +      return 1;
   1.107 +    }
   1.108 +  if (systemCount > nCN) 
   1.109 +    {
   1.110 +      cout << "Number of total CNs (" << nCN << ") should be >= systemCount (" 
   1.111 +           << systemCount << ")." << endl;
   1.112 +      return 1;
   1.113 +    }
   1.114 +
   1.115    cout << "Number of CNs: " << nCN << ", LAN nodes: " << nLANClients << endl;
   1.116  
   1.117    NodeContainer nodes_net0[nCN][3], nodes_net1[nCN][6], nodes_netLR[nCN],
   1.118 @@ -91,12 +115,12 @@
   1.119                           ifs3LAN[nCN][5][nLANClients];
   1.120    Ipv4AddressHelper address;
   1.121    std::ostringstream oss;
   1.122 -  p2p_1gb5ms.SetDeviceAttribute("DataRate", StringValue("1Gbps"));
   1.123 -  p2p_1gb5ms.SetChannelAttribute("Delay", StringValue("5ms"));
   1.124 -  p2p_2gb200ms.SetDeviceAttribute("DataRate", StringValue("2Gbps"));
   1.125 -  p2p_2gb200ms.SetChannelAttribute("Delay", StringValue("200ms"));
   1.126 -  p2p_100mb1ms.SetDeviceAttribute("DataRate", StringValue("100Mbps"));
   1.127 -  p2p_100mb1ms.SetChannelAttribute("Delay", StringValue("1ms"));
   1.128 +  p2p_1gb5ms.SetDeviceAttribute ("DataRate", StringValue ("1Gbps"));
   1.129 +  p2p_1gb5ms.SetChannelAttribute ("Delay", StringValue ("5ms"));
   1.130 +  p2p_2gb200ms.SetDeviceAttribute ("DataRate", StringValue ("2Gbps"));
   1.131 +  p2p_2gb200ms.SetChannelAttribute ("Delay", StringValue ("200ms"));
   1.132 +  p2p_100mb1ms.SetDeviceAttribute ("DataRate", StringValue ("100Mbps"));
   1.133 +  p2p_100mb1ms.SetChannelAttribute ("Delay", StringValue ("1ms"));
   1.134  
   1.135    Ipv4NixVectorHelper nixRouting;
   1.136    Ipv4StaticRoutingHelper staticRouting;
   1.137 @@ -111,374 +135,393 @@
   1.138      }
   1.139  
   1.140    // Create Campus Networks
   1.141 -  for (uint32_t z = 0; z < nCN; ++z) {
   1.142 -    cout << "Creating Campus Network " << z << ":" << endl;
   1.143 -    // Create Net0
   1.144 -    cout << "  SubNet [ 0";
   1.145 -    for (int i = 0; i < 3; ++i) {
   1.146 -      Ptr<Node> node = CreateObject<Node> (z%systemCount);
   1.147 -      nodes_net0[z][i].Add (node);
   1.148 -      stack.Install(nodes_net0[z][i]);
   1.149 +  for (uint32_t z = 0; z < nCN; ++z) 
   1.150 +    {
   1.151 +      cout << "Creating Campus Network " << z << ":" << endl;
   1.152 +      // Create Net0
   1.153 +      cout << "  SubNet [ 0";
   1.154 +      for (int i = 0; i < 3; ++i) 
   1.155 +        {
   1.156 +          Ptr<Node> node = CreateObject<Node> (z%systemCount);
   1.157 +          nodes_net0[z][i].Add (node);
   1.158 +          stack.Install (nodes_net0[z][i]);
   1.159 +        }
   1.160 +      nodes_net0[z][0].Add (nodes_net0[z][1].Get (0));
   1.161 +      nodes_net0[z][1].Add (nodes_net0[z][2].Get (0));
   1.162 +      nodes_net0[z][2].Add (nodes_net0[z][0].Get (0));
   1.163 +      NetDeviceContainer ndc0[3];
   1.164 +      for (int i = 0; i < 3; ++i) 
   1.165 +        {
   1.166 +          ndc0[i] = p2p_1gb5ms.Install (nodes_net0[z][i]);
   1.167 +        }
   1.168 +      // Create Net1
   1.169 +      cout << " 1";
   1.170 +      for (int i = 0; i < 6; ++i) 
   1.171 +        {
   1.172 +          Ptr<Node> node = CreateObject<Node> (z%systemCount);
   1.173 +          nodes_net1[z][i].Add (node);
   1.174 +          stack.Install (nodes_net1[z][i]);
   1.175 +        }
   1.176 +      nodes_net1[z][0].Add (nodes_net1[z][1].Get (0));
   1.177 +      nodes_net1[z][2].Add (nodes_net1[z][0].Get (0));
   1.178 +      nodes_net1[z][3].Add (nodes_net1[z][0].Get (0));
   1.179 +      nodes_net1[z][4].Add (nodes_net1[z][1].Get (0));
   1.180 +      nodes_net1[z][5].Add (nodes_net1[z][1].Get (0));
   1.181 +      NetDeviceContainer ndc1[6];
   1.182 +      for (int i = 0; i < 6; ++i) 
   1.183 +        {
   1.184 +          if (i == 1) continue;
   1.185 +          ndc1[i] = p2p_1gb5ms.Install (nodes_net1[z][i]);
   1.186 +        }
   1.187 +      // Connect Net0 <-> Net1
   1.188 +      NodeContainer net0_1;
   1.189 +      net0_1.Add (nodes_net0[z][2].Get (0));
   1.190 +      net0_1.Add (nodes_net1[z][0].Get (0));
   1.191 +      NetDeviceContainer ndc0_1;
   1.192 +      ndc0_1 = p2p_1gb5ms.Install (net0_1);
   1.193 +      oss.str ("");
   1.194 +      oss << 10 + z << ".1.252.0";
   1.195 +      address.SetBase (oss.str ().c_str (), "255.255.255.0");
   1.196 +      ifs = address.Assign (ndc0_1);
   1.197 +      // Create Net2
   1.198 +      cout << " 2";
   1.199 +      for (int i = 0; i < 14; ++i) 
   1.200 +        {
   1.201 +          Ptr<Node> node = CreateObject<Node> (z%systemCount);
   1.202 +          nodes_net2[z][i].Add (node);
   1.203 +          stack.Install (nodes_net2[z][i]);
   1.204 +        }
   1.205 +      nodes_net2[z][0].Add (nodes_net2[z][1].Get (0));
   1.206 +      nodes_net2[z][2].Add (nodes_net2[z][0].Get (0));
   1.207 +      nodes_net2[z][1].Add (nodes_net2[z][3].Get (0));
   1.208 +      nodes_net2[z][3].Add (nodes_net2[z][2].Get (0));
   1.209 +      nodes_net2[z][4].Add (nodes_net2[z][2].Get (0));
   1.210 +      nodes_net2[z][5].Add (nodes_net2[z][3].Get (0));
   1.211 +      nodes_net2[z][6].Add (nodes_net2[z][5].Get (0));
   1.212 +      nodes_net2[z][7].Add (nodes_net2[z][2].Get (0));
   1.213 +      nodes_net2[z][8].Add (nodes_net2[z][3].Get (0));
   1.214 +      nodes_net2[z][9].Add (nodes_net2[z][4].Get (0));
   1.215 +      nodes_net2[z][10].Add (nodes_net2[z][5].Get (0));
   1.216 +      nodes_net2[z][11].Add (nodes_net2[z][6].Get (0));
   1.217 +      nodes_net2[z][12].Add (nodes_net2[z][6].Get (0));
   1.218 +      nodes_net2[z][13].Add (nodes_net2[z][6].Get (0));
   1.219 +      NetDeviceContainer ndc2[14];
   1.220 +      for (int i = 0; i < 14; ++i) 
   1.221 +        {
   1.222 +          ndc2[i] = p2p_1gb5ms.Install (nodes_net2[z][i]);
   1.223 +        }
   1.224 +      NetDeviceContainer ndc2LAN[7][nLANClients];
   1.225 +      for (int i = 0; i < 7; ++i) 
   1.226 +        {
   1.227 +          oss.str ("");
   1.228 +          oss << 10 + z << ".4." << 15 + i << ".0";
   1.229 +          address.SetBase (oss.str ().c_str (), "255.255.255.0");
   1.230 +          for (uint32_t j = 0; j < nLANClients; ++j) 
   1.231 +            {
   1.232 +              Ptr<Node> node = CreateObject<Node> (z%systemCount);
   1.233 +              nodes_net2LAN[z][i][j].Add (node);
   1.234 +              stack.Install (nodes_net2LAN[z][i][j]);
   1.235 +              nodes_net2LAN[z][i][j].Add (nodes_net2[z][i+7].Get (0));
   1.236 +              ndc2LAN[i][j] = p2p_100mb1ms.Install (nodes_net2LAN[z][i][j]);
   1.237 +              ifs2LAN[z][i][j] = address.Assign (ndc2LAN[i][j]);
   1.238 +            }
   1.239 +        }
   1.240 +      // Create Net3
   1.241 +      cout << " 3 ]" << endl;
   1.242 +      for (int i = 0; i < 9; ++i) 
   1.243 +        {
   1.244 +          Ptr<Node> node = CreateObject<Node> (z%systemCount);
   1.245 +          nodes_net3[z][i].Add (node);
   1.246 +          stack.Install (nodes_net3[z][i]);
   1.247 +        }
   1.248 +      nodes_net3[z][0].Add (nodes_net3[z][1].Get (0));
   1.249 +      nodes_net3[z][1].Add (nodes_net3[z][2].Get (0));
   1.250 +      nodes_net3[z][2].Add (nodes_net3[z][3].Get (0));
   1.251 +      nodes_net3[z][3].Add (nodes_net3[z][1].Get (0));
   1.252 +      nodes_net3[z][4].Add (nodes_net3[z][0].Get (0));
   1.253 +      nodes_net3[z][5].Add (nodes_net3[z][0].Get (0));
   1.254 +      nodes_net3[z][6].Add (nodes_net3[z][2].Get (0));
   1.255 +      nodes_net3[z][7].Add (nodes_net3[z][3].Get (0));
   1.256 +      nodes_net3[z][8].Add (nodes_net3[z][3].Get (0));
   1.257 +      NetDeviceContainer ndc3[9];
   1.258 +      for (int i = 0; i < 9; ++i) 
   1.259 +        {
   1.260 +          ndc3[i] = p2p_1gb5ms.Install (nodes_net3[z][i]);
   1.261 +        }
   1.262 +      NetDeviceContainer ndc3LAN[5][nLANClients];
   1.263 +      for (int i = 0; i < 5; ++i) 
   1.264 +        {
   1.265 +          oss.str ("");
   1.266 +          oss << 10 + z << ".5." << 10 + i << ".0";
   1.267 +          address.SetBase (oss.str ().c_str (), "255.255.255.255");
   1.268 +          for (uint32_t j = 0; j < nLANClients; ++j) 
   1.269 +            {
   1.270 +              Ptr<Node> node = CreateObject<Node> (z%systemCount);
   1.271 +              nodes_net3LAN[z][i][j].Add (node);
   1.272 +              stack.Install (nodes_net3LAN[z][i][j]);
   1.273 +              nodes_net3LAN[z][i][j].Add (nodes_net3[z][i+4].Get (0));
   1.274 +              ndc3LAN[i][j] = p2p_100mb1ms.Install (nodes_net3LAN[z][i][j]);
   1.275 +              ifs3LAN[z][i][j] = address.Assign (ndc3LAN[i][j]);
   1.276 +            }
   1.277 +        }
   1.278 +      cout << "  Connecting Subnets..." << endl;
   1.279 +      // Create Lone Routers (Node 4 & 5) 
   1.280 +      Ptr<Node> node1 = CreateObject<Node> (z%systemCount);
   1.281 +      Ptr<Node> node2 = CreateObject<Node> (z%systemCount);
   1.282 +      nodes_netLR[z].Add (node1);
   1.283 +      nodes_netLR[z].Add (node2);
   1.284 +      stack.Install (nodes_netLR[z]);
   1.285 +      NetDeviceContainer ndcLR;
   1.286 +      ndcLR = p2p_1gb5ms.Install (nodes_netLR[z]);
   1.287 +      // Connect Net2/Net3 through Lone Routers to Net0
   1.288 +      NodeContainer net0_4, net0_5, net2_4a, net2_4b, net3_5a, net3_5b;
   1.289 +      net0_4.Add (nodes_netLR[z].Get (0));
   1.290 +      net0_4.Add (nodes_net0[z][0].Get (0));
   1.291 +      net0_5.Add (nodes_netLR[z].Get (1));
   1.292 +      net0_5.Add (nodes_net0[z][1].Get (0));
   1.293 +      net2_4a.Add (nodes_netLR[z].Get (0));
   1.294 +      net2_4a.Add (nodes_net2[z][0].Get (0));
   1.295 +      net2_4b.Add (nodes_netLR[z].Get (1));
   1.296 +      net2_4b.Add (nodes_net2[z][1].Get (0));
   1.297 +      net3_5a.Add (nodes_netLR[z].Get (1));
   1.298 +      net3_5a.Add (nodes_net3[z][0].Get (0));
   1.299 +      net3_5b.Add (nodes_netLR[z].Get (1));
   1.300 +      net3_5b.Add (nodes_net3[z][1].Get (0));
   1.301 +      NetDeviceContainer ndc0_4, ndc0_5, ndc2_4a, ndc2_4b, ndc3_5a, ndc3_5b;
   1.302 +      ndc0_4 = p2p_1gb5ms.Install (net0_4);
   1.303 +      oss.str ("");
   1.304 +      oss << 10 + z << ".1.253.0";
   1.305 +      address.SetBase (oss.str ().c_str (), "255.255.255.0");
   1.306 +      ifs = address.Assign (ndc0_4);
   1.307 +      ndc0_5 = p2p_1gb5ms.Install (net0_5);
   1.308 +      oss.str ("");
   1.309 +      oss << 10 + z << ".1.254.0";
   1.310 +      address.SetBase (oss.str ().c_str (), "255.255.255.0");
   1.311 +      ifs = address.Assign (ndc0_5);
   1.312 +      ndc2_4a = p2p_1gb5ms.Install (net2_4a);
   1.313 +      oss.str ("");
   1.314 +      oss << 10 + z << ".4.253.0";
   1.315 +      address.SetBase (oss.str ().c_str (), "255.255.255.0");
   1.316 +      ifs = address.Assign (ndc2_4a);
   1.317 +      ndc2_4b = p2p_1gb5ms.Install (net2_4b);
   1.318 +      oss.str ("");
   1.319 +      oss << 10 + z << ".4.254.0";
   1.320 +      address.SetBase (oss.str ().c_str (), "255.255.255.0");
   1.321 +      ifs = address.Assign (ndc2_4b);
   1.322 +      ndc3_5a = p2p_1gb5ms.Install (net3_5a);
   1.323 +      oss.str ("");
   1.324 +      oss << 10 + z << ".5.253.0";
   1.325 +      address.SetBase (oss.str ().c_str (), "255.255.255.0");
   1.326 +      ifs = address.Assign (ndc3_5a);
   1.327 +      ndc3_5b = p2p_1gb5ms.Install (net3_5b);
   1.328 +      oss.str ("");
   1.329 +      oss << 10 + z << ".5.254.0";
   1.330 +      address.SetBase (oss.str ().c_str (), "255.255.255.0");
   1.331 +      ifs = address.Assign (ndc3_5b);
   1.332 +      // Assign IP addresses
   1.333 +      cout << "  Assigning IP addresses..." << endl;
   1.334 +      for (int i = 0; i < 3; ++i) 
   1.335 +        {
   1.336 +          oss.str ("");
   1.337 +          oss << 10 + z << ".1." << 1 + i << ".0";
   1.338 +          address.SetBase (oss.str ().c_str (), "255.255.255.0");
   1.339 +          ifs0[z][i] = address.Assign (ndc0[i]);
   1.340 +        }
   1.341 +      for (int i = 0; i < 6; ++i) 
   1.342 +        {
   1.343 +          if (i == 1) continue;
   1.344 +          oss.str ("");
   1.345 +          oss << 10 + z << ".2." << 1 + i << ".0";
   1.346 +          address.SetBase (oss.str ().c_str (), "255.255.255.0");
   1.347 +          ifs1[z][i] = address.Assign (ndc1[i]);
   1.348 +        }
   1.349 +      oss.str ("");
   1.350 +      oss << 10 + z << ".3.1.0";
   1.351 +      address.SetBase (oss.str ().c_str (), "255.255.255.0");
   1.352 +      ifs = address.Assign (ndcLR);
   1.353 +      for (int i = 0; i < 14; ++i) 
   1.354 +        {
   1.355 +          oss.str ("");
   1.356 +          oss << 10 + z << ".4." << 1 + i << ".0";
   1.357 +          address.SetBase (oss.str ().c_str (), "255.255.255.0");
   1.358 +          ifs2[z][i] = address.Assign (ndc2[i]);
   1.359 +        }
   1.360 +      for (int i = 0; i < 9; ++i) 
   1.361 +        {
   1.362 +          oss.str ("");
   1.363 +          oss << 10 + z << ".5." << 1 + i << ".0";
   1.364 +          address.SetBase (oss.str ().c_str (), "255.255.255.0");
   1.365 +          ifs3[z][i] = address.Assign (ndc3[i]);
   1.366 +        }
   1.367      }
   1.368 -    nodes_net0[z][0].Add(nodes_net0[z][1].Get(0));
   1.369 -    nodes_net0[z][1].Add(nodes_net0[z][2].Get(0));
   1.370 -    nodes_net0[z][2].Add(nodes_net0[z][0].Get(0));
   1.371 -    NetDeviceContainer ndc0[3];
   1.372 -    for (int i = 0; i < 3; ++i) {
   1.373 -      ndc0[i] = p2p_1gb5ms.Install(nodes_net0[z][i]);
   1.374 -    }
   1.375 -    // Create Net1
   1.376 -    cout << " 1";
   1.377 -    for (int i = 0; i < 6; ++i) {
   1.378 -      Ptr<Node> node = CreateObject<Node> (z%systemCount);
   1.379 -      nodes_net1[z][i].Add (node);
   1.380 -      stack.Install(nodes_net1[z][i]);
   1.381 -    }
   1.382 -    nodes_net1[z][0].Add(nodes_net1[z][1].Get(0));
   1.383 -    nodes_net1[z][2].Add(nodes_net1[z][0].Get(0));
   1.384 -    nodes_net1[z][3].Add(nodes_net1[z][0].Get(0));
   1.385 -    nodes_net1[z][4].Add(nodes_net1[z][1].Get(0));
   1.386 -    nodes_net1[z][5].Add(nodes_net1[z][1].Get(0));
   1.387 -    NetDeviceContainer ndc1[6];
   1.388 -    for (int i = 0; i < 6; ++i) {
   1.389 -      if (i == 1) continue;
   1.390 -      ndc1[i] = p2p_1gb5ms.Install(nodes_net1[z][i]);
   1.391 -    }
   1.392 -    // Connect Net0 <-> Net1
   1.393 -    NodeContainer net0_1;
   1.394 -    net0_1.Add(nodes_net0[z][2].Get(0));
   1.395 -    net0_1.Add(nodes_net1[z][0].Get(0));
   1.396 -    NetDeviceContainer ndc0_1;
   1.397 -    ndc0_1 = p2p_1gb5ms.Install(net0_1);
   1.398 -    oss.str("");
   1.399 -    oss << 10 + z << ".1.252.0";
   1.400 -    address.SetBase(oss.str().c_str(), "255.255.255.0");
   1.401 -    ifs = address.Assign(ndc0_1);
   1.402 -    // Create Net2
   1.403 -    cout << " 2";
   1.404 -    for (int i = 0; i < 14; ++i) {
   1.405 -      Ptr<Node> node = CreateObject<Node> (z%systemCount);
   1.406 -      nodes_net2[z][i].Add (node);
   1.407 -      stack.Install(nodes_net2[z][i]);
   1.408 -    }
   1.409 -    nodes_net2[z][0].Add(nodes_net2[z][1].Get(0));
   1.410 -    nodes_net2[z][2].Add(nodes_net2[z][0].Get(0));
   1.411 -    nodes_net2[z][1].Add(nodes_net2[z][3].Get(0));
   1.412 -    nodes_net2[z][3].Add(nodes_net2[z][2].Get(0));
   1.413 -    nodes_net2[z][4].Add(nodes_net2[z][2].Get(0));
   1.414 -    nodes_net2[z][5].Add(nodes_net2[z][3].Get(0));
   1.415 -    nodes_net2[z][6].Add(nodes_net2[z][5].Get(0));
   1.416 -    nodes_net2[z][7].Add(nodes_net2[z][2].Get(0));
   1.417 -    nodes_net2[z][8].Add(nodes_net2[z][3].Get(0));
   1.418 -    nodes_net2[z][9].Add(nodes_net2[z][4].Get(0));
   1.419 -    nodes_net2[z][10].Add(nodes_net2[z][5].Get(0));
   1.420 -    nodes_net2[z][11].Add(nodes_net2[z][6].Get(0));
   1.421 -    nodes_net2[z][12].Add(nodes_net2[z][6].Get(0));
   1.422 -    nodes_net2[z][13].Add(nodes_net2[z][6].Get(0));
   1.423 -    NetDeviceContainer ndc2[14];
   1.424 -    for (int i = 0; i < 14; ++i) {
   1.425 -      ndc2[i] = p2p_1gb5ms.Install(nodes_net2[z][i]);
   1.426 -    }
   1.427 -    NetDeviceContainer ndc2LAN[7][nLANClients];
   1.428 -    for (int i = 0; i < 7; ++i) {
   1.429 -      oss.str("");
   1.430 -      oss << 10 + z << ".4." << 15 + i << ".0";
   1.431 -      address.SetBase(oss.str().c_str(), "255.255.255.0");
   1.432 -      for (uint32_t j = 0; j < nLANClients; ++j) {
   1.433 -        Ptr<Node> node = CreateObject<Node> (z%systemCount);
   1.434 -        nodes_net2LAN[z][i][j].Add (node);
   1.435 -        stack.Install(nodes_net2LAN[z][i][j]);
   1.436 -        nodes_net2LAN[z][i][j].Add(nodes_net2[z][i+7].Get(0));
   1.437 -        ndc2LAN[i][j] = p2p_100mb1ms.Install(nodes_net2LAN[z][i][j]);
   1.438 -        ifs2LAN[z][i][j] = address.Assign(ndc2LAN[i][j]);
   1.439 +    // Create Ring Links
   1.440 +    if (nCN > 1) 
   1.441 +      {
   1.442 +        cout << "Forming Ring Topology..." << endl;
   1.443 +        NodeContainer nodes_ring[nCN];
   1.444 +        for (uint32_t z = 0; z < nCN-1; ++z) 
   1.445 +          {
   1.446 +            nodes_ring[z].Add (nodes_net0[z][0].Get (0));
   1.447 +            nodes_ring[z].Add (nodes_net0[z+1][0].Get (0));
   1.448 +          }
   1.449 +        nodes_ring[nCN-1].Add (nodes_net0[nCN-1][0].Get (0));
   1.450 +        nodes_ring[nCN-1].Add (nodes_net0[0][0].Get (0));
   1.451 +        NetDeviceContainer ndc_ring[nCN];
   1.452 +        for (uint32_t z = 0; z < nCN; ++z) 
   1.453 +          {
   1.454 +            ndc_ring[z] = p2p_2gb200ms.Install (nodes_ring[z]);
   1.455 +            oss.str ("");
   1.456 +            oss << "254.1." << z + 1 << ".0";
   1.457 +            address.SetBase (oss.str ().c_str (), "255.255.255.0");
   1.458 +            ifs = address.Assign (ndc_ring[z]);
   1.459 +          }
   1.460        }
   1.461 -    }
   1.462 -    // Create Net3
   1.463 -    cout << " 3 ]" << endl;
   1.464 -    for (int i = 0; i < 9; ++i) {
   1.465 -      Ptr<Node> node = CreateObject<Node> (z%systemCount);
   1.466 -      nodes_net3[z][i].Add (node);
   1.467 -      stack.Install(nodes_net3[z][i]);
   1.468 -    }
   1.469 -    nodes_net3[z][0].Add(nodes_net3[z][1].Get(0));
   1.470 -    nodes_net3[z][1].Add(nodes_net3[z][2].Get(0));
   1.471 -    nodes_net3[z][2].Add(nodes_net3[z][3].Get(0));
   1.472 -    nodes_net3[z][3].Add(nodes_net3[z][1].Get(0));
   1.473 -    nodes_net3[z][4].Add(nodes_net3[z][0].Get(0));
   1.474 -    nodes_net3[z][5].Add(nodes_net3[z][0].Get(0));
   1.475 -    nodes_net3[z][6].Add(nodes_net3[z][2].Get(0));
   1.476 -    nodes_net3[z][7].Add(nodes_net3[z][3].Get(0));
   1.477 -    nodes_net3[z][8].Add(nodes_net3[z][3].Get(0));
   1.478 -    NetDeviceContainer ndc3[9];
   1.479 -    for (int i = 0; i < 9; ++i) {
   1.480 -      ndc3[i] = p2p_1gb5ms.Install(nodes_net3[z][i]);
   1.481 -    }
   1.482 -    NetDeviceContainer ndc3LAN[5][nLANClients];
   1.483 -    for (int i = 0; i < 5; ++i) {
   1.484 -      oss.str("");
   1.485 -      oss << 10 + z << ".5." << 10 + i << ".0";
   1.486 -      address.SetBase(oss.str().c_str(), "255.255.255.255");
   1.487 -      for (uint32_t j = 0; j < nLANClients; ++j) {
   1.488 -        Ptr<Node> node = CreateObject<Node> (z%systemCount);
   1.489 -        nodes_net3LAN[z][i][j].Add (node);
   1.490 -        stack.Install(nodes_net3LAN[z][i][j]);
   1.491 -        nodes_net3LAN[z][i][j].Add(nodes_net3[z][i+4].Get(0));
   1.492 -        ndc3LAN[i][j] = p2p_100mb1ms.Install(nodes_net3LAN[z][i][j]);
   1.493 -        ifs3LAN[z][i][j] = address.Assign(ndc3LAN[i][j]);
   1.494 -      }
   1.495 -    }
   1.496 -    cout << "  Connecting Subnets..." << endl;
   1.497 -    // Create Lone Routers (Node 4 & 5) 
   1.498 -    Ptr<Node> node1 = CreateObject<Node> (z%systemCount);
   1.499 -    Ptr<Node> node2 = CreateObject<Node> (z%systemCount);
   1.500 -    nodes_netLR[z].Add (node1);
   1.501 -    nodes_netLR[z].Add (node2);
   1.502 -    stack.Install(nodes_netLR[z]);
   1.503 -    NetDeviceContainer ndcLR;
   1.504 -    ndcLR = p2p_1gb5ms.Install(nodes_netLR[z]);
   1.505 -    // Connect Net2/Net3 through Lone Routers to Net0
   1.506 -    NodeContainer net0_4, net0_5, net2_4a, net2_4b, net3_5a, net3_5b;
   1.507 -    net0_4.Add(nodes_netLR[z].Get(0));
   1.508 -    net0_4.Add(nodes_net0[z][0].Get(0));
   1.509 -    net0_5.Add(nodes_netLR[z].Get(1));
   1.510 -    net0_5.Add(nodes_net0[z][1].Get(0));
   1.511 -    net2_4a.Add(nodes_netLR[z].Get(0));
   1.512 -    net2_4a.Add(nodes_net2[z][0].Get(0));
   1.513 -    net2_4b.Add(nodes_netLR[z].Get(1));
   1.514 -    net2_4b.Add(nodes_net2[z][1].Get(0));
   1.515 -    net3_5a.Add(nodes_netLR[z].Get(1));
   1.516 -    net3_5a.Add(nodes_net3[z][0].Get(0));
   1.517 -    net3_5b.Add(nodes_netLR[z].Get(1));
   1.518 -    net3_5b.Add(nodes_net3[z][1].Get(0));
   1.519 -    NetDeviceContainer ndc0_4, ndc0_5, ndc2_4a, ndc2_4b, ndc3_5a, ndc3_5b;
   1.520 -    ndc0_4 = p2p_1gb5ms.Install(net0_4);
   1.521 -    oss.str("");
   1.522 -    oss << 10 + z << ".1.253.0";
   1.523 -    address.SetBase(oss.str().c_str(), "255.255.255.0");
   1.524 -    ifs = address.Assign(ndc0_4);
   1.525 -    ndc0_5 = p2p_1gb5ms.Install(net0_5);
   1.526 -    oss.str("");
   1.527 -    oss << 10 + z << ".1.254.0";
   1.528 -    address.SetBase(oss.str().c_str(), "255.255.255.0");
   1.529 -    ifs = address.Assign(ndc0_5);
   1.530 -    ndc2_4a = p2p_1gb5ms.Install(net2_4a);
   1.531 -    oss.str("");
   1.532 -    oss << 10 + z << ".4.253.0";
   1.533 -    address.SetBase(oss.str().c_str(), "255.255.255.0");
   1.534 -    ifs = address.Assign(ndc2_4a);
   1.535 -    ndc2_4b = p2p_1gb5ms.Install(net2_4b);
   1.536 -    oss.str("");
   1.537 -    oss << 10 + z << ".4.254.0";
   1.538 -    address.SetBase(oss.str().c_str(), "255.255.255.0");
   1.539 -    ifs = address.Assign(ndc2_4b);
   1.540 -    ndc3_5a = p2p_1gb5ms.Install(net3_5a);
   1.541 -    oss.str("");
   1.542 -    oss << 10 + z << ".5.253.0";
   1.543 -    address.SetBase(oss.str().c_str(), "255.255.255.0");
   1.544 -    ifs = address.Assign(ndc3_5a);
   1.545 -    ndc3_5b = p2p_1gb5ms.Install(net3_5b);
   1.546 -    oss.str("");
   1.547 -    oss << 10 + z << ".5.254.0";
   1.548 -    address.SetBase(oss.str().c_str(), "255.255.255.0");
   1.549 -    ifs = address.Assign(ndc3_5b);
   1.550 -    // Assign IP addresses
   1.551 -    cout << "  Assigning IP addresses..." << endl;
   1.552 -    for (int i = 0; i < 3; ++i) {
   1.553 -      oss.str("");
   1.554 -      oss << 10 + z << ".1." << 1 + i << ".0";
   1.555 -      address.SetBase(oss.str().c_str(), "255.255.255.0");
   1.556 -      ifs0[z][i] = address.Assign(ndc0[i]);
   1.557 -    }
   1.558 -    for (int i = 0; i < 6; ++i) {
   1.559 -      if (i == 1) continue;
   1.560 -      oss.str("");
   1.561 -      oss << 10 + z << ".2." << 1 + i << ".0";
   1.562 -      address.SetBase(oss.str().c_str(), "255.255.255.0");
   1.563 -      ifs1[z][i] = address.Assign(ndc1[i]);
   1.564 -    }
   1.565 -    oss.str("");
   1.566 -    oss << 10 + z << ".3.1.0";
   1.567 -    address.SetBase(oss.str().c_str(), "255.255.255.0");
   1.568 -    ifs = address.Assign(ndcLR);
   1.569 -    for (int i = 0; i < 14; ++i) {
   1.570 -      oss.str("");
   1.571 -      oss << 10 + z << ".4." << 1 + i << ".0";
   1.572 -      address.SetBase(oss.str().c_str(), "255.255.255.0");
   1.573 -      ifs2[z][i] = address.Assign(ndc2[i]);
   1.574 -    }
   1.575 -    for (int i = 0; i < 9; ++i) {
   1.576 -      oss.str("");
   1.577 -      oss << 10 + z << ".5." << 1 + i << ".0";
   1.578 -      address.SetBase(oss.str().c_str(), "255.255.255.0");
   1.579 -      ifs3[z][i] = address.Assign(ndc3[i]);
   1.580 -    }
   1.581 -  }
   1.582 -  // Create Ring Links
   1.583 -  if (nCN > 1) {
   1.584 -    cout << "Forming Ring Topology..." << endl;
   1.585 -    NodeContainer nodes_ring[nCN];
   1.586 -    for (uint32_t z = 0; z < nCN-1; ++z) {
   1.587 -      nodes_ring[z].Add(nodes_net0[z][0].Get(0));
   1.588 -      nodes_ring[z].Add(nodes_net0[z+1][0].Get(0));
   1.589 -    }
   1.590 -    nodes_ring[nCN-1].Add(nodes_net0[nCN-1][0].Get(0));
   1.591 -    nodes_ring[nCN-1].Add(nodes_net0[0][0].Get(0));
   1.592 -    NetDeviceContainer ndc_ring[nCN];
   1.593 -    for (uint32_t z = 0; z < nCN; ++z) {
   1.594 -      ndc_ring[z] = p2p_2gb200ms.Install(nodes_ring[z]);
   1.595 -      oss.str("");
   1.596 -      oss << "254.1." << z + 1 << ".0";
   1.597 -      address.SetBase(oss.str().c_str(), "255.255.255.0");
   1.598 -      ifs = address.Assign(ndc_ring[z]);
   1.599 -    }
   1.600 -  }
   1.601  
   1.602    // Create Traffic Flows
   1.603 -  cout << "Creating TCP Traffic Flows:" << endl;
   1.604 -  Config::SetDefault("ns3::OnOffApplication::MaxBytes", UintegerValue(nBytes));
   1.605 -  Config::SetDefault("ns3::OnOffApplication::OnTime",
   1.606 -      RandomVariableValue(ConstantVariable(1)));
   1.607 -  Config::SetDefault("ns3::OnOffApplication::OffTime",
   1.608 -      RandomVariableValue(ConstantVariable(0)));
   1.609 -  Config::SetDefault ("ns3::TcpSocket::SegmentSize", UintegerValue (512));
   1.610 +  cout << "Creating UDP Traffic Flows:" << endl;
   1.611 +  Config::SetDefault ("ns3::OnOffApplication::MaxBytes", 
   1.612 +                      UintegerValue (nBytes));
   1.613 +  Config::SetDefault ("ns3::OnOffApplication::OnTime", 
   1.614 +                      RandomVariableValue (ConstantVariable (1)));
   1.615 +  Config::SetDefault ("ns3::OnOffApplication::OffTime", 
   1.616 +                      RandomVariableValue (ConstantVariable (0)));
   1.617  
   1.618  
   1.619 -  if (single)
   1.620 +  UniformVariable urng;
   1.621 +  int r1;
   1.622 +  double r2;
   1.623 +  for (uint32_t z = 0; z < nCN; ++z) 
   1.624      {
   1.625 -      cout << "Using single flow." << endl;
   1.626 -
   1.627 -      if (rank == 0)
   1.628 -      {
   1.629 -        PacketSinkHelper sinkHelper("ns3::TcpSocketFactory",
   1.630 -                                  InetSocketAddress(Ipv4Address::GetAny(),
   1.631 -                                                    9999));
   1.632 -        ApplicationContainer sinkApp = sinkHelper.Install(
   1.633 -                                                        nodes_net1[0][2].Get(0));
   1.634 -        sinkApp.Start(Seconds(100.0));
   1.635 -        
   1.636 -        OnOffHelper client("ns3::TcpSocketFactory", Address());
   1.637 -        AddressValue remoteAddress(InetSocketAddress(
   1.638 -                                                   ifs1[0][2].GetAddress(0), 9999));
   1.639 -        cout << "Remote Address is " << ifs1[0][2].GetAddress(0) << endl;
   1.640 -        client.SetAttribute("Remote", remoteAddress);
   1.641 -
   1.642 -        ApplicationContainer clientApp;
   1.643 -        clientApp.Add(client.Install(nodes_net2LAN[0][0][0].Get(0)));
   1.644 -        clientApp.Start(Seconds(100));
   1.645 -      }
   1.646 -    }
   1.647 -  else
   1.648 -    {
   1.649 -      UniformVariable urng;
   1.650 -      int r1;
   1.651 -      double r2;
   1.652 -      for (uint32_t z = 0; z < nCN; ++z) {
   1.653 -        uint32_t x = z + 1;
   1.654 -        if (z == nCN - 1) {
   1.655 +      uint32_t x = z + 1;
   1.656 +      if (z == nCN - 1) 
   1.657 +        {
   1.658            x = 0;
   1.659          }
   1.660 -        // Subnet 2 LANs
   1.661 -        cout << "  Campus Network " << z << " Flows [ Net2 ";
   1.662 -        for (int i = 0; i < 7; ++i) {
   1.663 -          for (uint32_t j = 0; j < nLANClients; ++j) {
   1.664 -            // Sinks
   1.665 -            if (systemCount == 1)
   1.666 +      // Subnet 2 LANs
   1.667 +      cout << "  Campus Network " << z << " Flows [ Net2 ";
   1.668 +      for (int i = 0; i < 7; ++i) 
   1.669 +        {
   1.670 +          for (uint32_t j = 0; j < nLANClients; ++j) 
   1.671              {
   1.672 -              PacketSinkHelper sinkHelper("ns3::TcpSocketFactory",
   1.673 -                                        InetSocketAddress(Ipv4Address::GetAny(), 9999));
   1.674 -              ApplicationContainer sinkApp = sinkHelper.Install(
   1.675 -                                                              nodes_net2LAN[z][i][j].Get(0));
   1.676 -              sinkApp.Start(Seconds(100.0));
   1.677 +              // Sinks
   1.678 +              if (systemCount == 1)
   1.679 +                {
   1.680 +                  PacketSinkHelper sinkHelper 
   1.681 +                    ("ns3::UdpSocketFactory", 
   1.682 +                    InetSocketAddress (Ipv4Address::GetAny (), 9999));
   1.683 +
   1.684 +                  ApplicationContainer sinkApp = 
   1.685 +                    sinkHelper.Install (nodes_net2LAN[z][i][j].Get (0));
   1.686 +
   1.687 +                  sinkApp.Start(Seconds (100.0));
   1.688 +                }
   1.689 +              else if (rank == z%systemCount)
   1.690 +                {
   1.691 +                  PacketSinkHelper sinkHelper 
   1.692 +                    ("ns3::UdpSocketFactory", 
   1.693 +                    InetSocketAddress (Ipv4Address::GetAny (), 9999));
   1.694 +
   1.695 +                  ApplicationContainer sinkApp = 
   1.696 +                    sinkHelper.Install (nodes_net2LAN[z][i][j].Get (0));
   1.697 +
   1.698 +                  sinkApp.Start (Seconds (100.0));
   1.699 +                }
   1.700 +              // Sources
   1.701 +              if (systemCount == 1)
   1.702 +                {
   1.703 +                  r1 = 2 + (int)(4 * urng.GetValue ());
   1.704 +                  r2 = 100 + (10 * urng.GetValue ());
   1.705 +                  OnOffHelper client ("ns3::UdpSocketFactory", Address ());
   1.706 +
   1.707 +                  AddressValue remoteAddress 
   1.708 +                   (InetSocketAddress (ifs2LAN[z][i][j].GetAddress (0), 9999));
   1.709 +
   1.710 +                  client.SetAttribute ("Remote", remoteAddress);
   1.711 +                  ApplicationContainer clientApp;
   1.712 +                  clientApp.Add (client.Install (nodes_net1[x][r1].Get (0)));
   1.713 +                  clientApp.Start (Seconds (r2));
   1.714 +                }
   1.715 +              else if (rank == x%systemCount)
   1.716 +                {
   1.717 +                  r1 = 2 + (int)(4 * urng.GetValue ());
   1.718 +                  r2 = 100 + (10 * urng.GetValue ());
   1.719 +                  OnOffHelper client ("ns3::UdpSocketFactory", Address ());
   1.720 +
   1.721 +                  AddressValue remoteAddress 
   1.722 +                   (InetSocketAddress (ifs2LAN[z][i][j].GetAddress (0), 9999));
   1.723 +
   1.724 +                  client.SetAttribute ("Remote", remoteAddress);
   1.725 +                  ApplicationContainer clientApp;
   1.726 +                  clientApp.Add (client.Install (nodes_net1[x][r1].Get (0)));
   1.727 +                  clientApp.Start (Seconds (r2));
   1.728 +                }
   1.729              }
   1.730 -            else if (rank == z%systemCount)
   1.731 +        }
   1.732 +      // Subnet 3 LANs
   1.733 +      cout << "Net3 ]" << endl;
   1.734 +      for (int i = 0; i < 5; ++i) 
   1.735 +        {
   1.736 +          for (uint32_t j = 0; j < nLANClients; ++j) 
   1.737              {
   1.738 -              PacketSinkHelper sinkHelper("ns3::TcpSocketFactory",
   1.739 -                                        InetSocketAddress(Ipv4Address::GetAny(), 9999));
   1.740 -              ApplicationContainer sinkApp = sinkHelper.Install(
   1.741 -                                                              nodes_net2LAN[z][i][j].Get(0));
   1.742 -              sinkApp.Start(Seconds(100.0));
   1.743 +              // Sinks
   1.744 +              if (systemCount == 1)
   1.745 +                {
   1.746 +                  PacketSinkHelper sinkHelper 
   1.747 +                    ("ns3::UdpSocketFactory", 
   1.748 +                    InetSocketAddress(Ipv4Address::GetAny (), 9999));
   1.749 +
   1.750 +                  ApplicationContainer sinkApp = 
   1.751 +                    sinkHelper.Install (nodes_net3LAN[z][i][j].Get (0));
   1.752 +
   1.753 +                  sinkApp.Start (Seconds (100.0));
   1.754 +                }
   1.755 +              else if (rank == z%systemCount)
   1.756 +                {
   1.757 +                  PacketSinkHelper sinkHelper 
   1.758 +                    ("ns3::UdpSocketFactory", 
   1.759 +                    InetSocketAddress (Ipv4Address::GetAny (), 9999));
   1.760 +
   1.761 +                  ApplicationContainer sinkApp = 
   1.762 +                    sinkHelper.Install (nodes_net3LAN[z][i][j].Get (0));
   1.763 +
   1.764 +                  sinkApp.Start (Seconds (100.0));
   1.765 +                }
   1.766 +              // Sources
   1.767 +              if (systemCount == 1)
   1.768 +                {
   1.769 +                  r1 = 2 + (int)(4 * urng.GetValue ());
   1.770 +                  r2 = 100 + (10 * urng.GetValue ());
   1.771 +                  OnOffHelper client ("ns3::UdpSocketFactory", Address ());
   1.772 +
   1.773 +                  AddressValue remoteAddress 
   1.774 +                    (InetSocketAddress (ifs2LAN[z][i][j].GetAddress (0), 9999));
   1.775 +
   1.776 +                  client.SetAttribute ("Remote", remoteAddress);
   1.777 +                  ApplicationContainer clientApp;
   1.778 +                  clientApp.Add (client.Install (nodes_net1[x][r1].Get (0)));
   1.779 +                  clientApp.Start (Seconds (r2));
   1.780 +                }
   1.781 +              else if (rank == x%systemCount)
   1.782 +                {
   1.783 +                  r1 = 2 + (int)(4 * urng.GetValue ());
   1.784 +                  r2 = 100 + (10 * urng.GetValue ());
   1.785 +                  OnOffHelper client ("ns3::UdpSocketFactory", Address ());
   1.786 +
   1.787 +                  AddressValue remoteAddress 
   1.788 +                    (InetSocketAddress (ifs2LAN[z][i][j].GetAddress (0), 9999));
   1.789 +
   1.790 +                  client.SetAttribute ("Remote", remoteAddress);
   1.791 +                  ApplicationContainer clientApp;
   1.792 +                  clientApp.Add (client.Install (nodes_net1[x][r1].Get (0)));
   1.793 +                  clientApp.Start (Seconds (r2));
   1.794 +                }
   1.795              }
   1.796 -            // Sources
   1.797 -            if (systemCount == 1)
   1.798 -            {
   1.799 -              r1 = 2 + (int)(4 * urng.GetValue());
   1.800 -              r2 = 100 + (10 * urng.GetValue());;
   1.801 -              OnOffHelper client("ns3::TcpSocketFactory", Address());
   1.802 -              AddressValue remoteAddress(InetSocketAddress(
   1.803 -                                                         ifs2LAN[z][i][j].GetAddress(0), 9999));
   1.804 -              client.SetAttribute("Remote", remoteAddress);
   1.805 -              ApplicationContainer clientApp;
   1.806 -              clientApp.Add(client.Install(nodes_net1[x][r1].Get(0)));
   1.807 -              clientApp.Start(Seconds(r2));
   1.808 -            }
   1.809 -            else if (rank == x%systemCount)
   1.810 -            {
   1.811 -              r1 = 2 + (int)(4 * urng.GetValue());
   1.812 -              r2 = 100 + (10 * urng.GetValue());;
   1.813 -              OnOffHelper client("ns3::TcpSocketFactory", Address());
   1.814 -              AddressValue remoteAddress(InetSocketAddress(
   1.815 -                                                         ifs2LAN[z][i][j].GetAddress(0), 9999));
   1.816 -              client.SetAttribute("Remote", remoteAddress);
   1.817 -              ApplicationContainer clientApp;
   1.818 -              clientApp.Add(client.Install(nodes_net1[x][r1].Get(0)));
   1.819 -              clientApp.Start(Seconds(r2));
   1.820 -            }
   1.821 -          }
   1.822          }
   1.823 -        // Subnet 3 LANs
   1.824 -        cout << "Net3 ]" << endl;
   1.825 -        for (int i = 0; i < 5; ++i) {
   1.826 -          for (uint32_t j = 0; j < nLANClients; ++j) {
   1.827 -            // Sinks
   1.828 -            if (systemCount == 1)
   1.829 -            {
   1.830 -              PacketSinkHelper sinkHelper("ns3::TcpSocketFactory",
   1.831 -                                        InetSocketAddress(Ipv4Address::GetAny(), 9999));
   1.832 -              ApplicationContainer sinkApp = sinkHelper.Install(
   1.833 -                                                              nodes_net3LAN[z][i][j].Get(0));
   1.834 -              sinkApp.Start(Seconds(100.0));
   1.835 -            }
   1.836 -            else if (rank == z%systemCount)
   1.837 -            {
   1.838 -              PacketSinkHelper sinkHelper("ns3::TcpSocketFactory",
   1.839 -                                        InetSocketAddress(Ipv4Address::GetAny(), 9999));
   1.840 -              ApplicationContainer sinkApp = sinkHelper.Install(
   1.841 -                                                              nodes_net3LAN[z][i][j].Get(0));
   1.842 -              sinkApp.Start(Seconds(100.0));
   1.843 -            }
   1.844 -            // Sources
   1.845 -            if (systemCount == 1)
   1.846 -            {
   1.847 -              r1 = 2 + (int)(4 * urng.GetValue());
   1.848 -              r2 = 100 + (10 * urng.GetValue());;
   1.849 -              OnOffHelper client("ns3::TcpSocketFactory", Address());
   1.850 -              AddressValue remoteAddress(InetSocketAddress(
   1.851 -                                                         ifs2LAN[z][i][j].GetAddress(0), 9999));
   1.852 -              client.SetAttribute("Remote", remoteAddress);
   1.853 -              ApplicationContainer clientApp;
   1.854 -              clientApp.Add(client.Install(nodes_net1[x][r1].Get(0)));
   1.855 -              clientApp.Start(Seconds(r2));
   1.856 -            }
   1.857 -            else if (rank == x%systemCount)
   1.858 -            {
   1.859 -              r1 = 2 + (int)(4 * urng.GetValue());
   1.860 -              r2 = 100 + (10 * urng.GetValue());;
   1.861 -              OnOffHelper client("ns3::TcpSocketFactory", Address());
   1.862 -              AddressValue remoteAddress(InetSocketAddress(
   1.863 -                                                         ifs2LAN[z][i][j].GetAddress(0), 9999));
   1.864 -              client.SetAttribute("Remote", remoteAddress);
   1.865 -              ApplicationContainer clientApp;
   1.866 -              clientApp.Add(client.Install(nodes_net1[x][r1].Get(0)));
   1.867 -              clientApp.Start(Seconds(r2));
   1.868 -            }
   1.869 -          }
   1.870 -        }
   1.871 -      }
   1.872      }
   1.873    
   1.874 -  cout << "Created " << NodeList::GetNNodes() << " nodes." << endl;
   1.875 +  cout << "Created " << NodeList::GetNNodes () << " nodes." << endl;
   1.876    TIMER_TYPE routingStart;
   1.877 -  TIMER_NOW(routingStart);
   1.878 +  TIMER_NOW (routingStart);
   1.879  
   1.880    if (nix)
   1.881      {
   1.882 @@ -492,10 +535,10 @@
   1.883      }
   1.884  
   1.885    TIMER_TYPE routingEnd;
   1.886 -  TIMER_NOW(routingEnd);
   1.887 +  TIMER_NOW (routingEnd);
   1.888    cout << "Routing tables population took " 
   1.889 -       << TIMER_DIFF(routingEnd, routingStart) << endl;
   1.890 -#if 1
   1.891 +       << TIMER_DIFF (routingEnd, routingStart) << endl;
   1.892 +#if 0
   1.893    oss.str("");
   1.894    oss << "nms_udp_nix_rank" << rank << ".tr";
   1.895    std::ofstream ascii;
   1.896 @@ -504,27 +547,22 @@
   1.897    CsmaHelper::EnableAsciiAll(ascii);
   1.898  #endif
   1.899  
   1.900 -#if 0
   1.901 -  PointToPointHelper::EnablePcapAll("nms_p2p");
   1.902 -  CsmaHelper::EnablePcapAll("nms_csma");
   1.903 -#endif
   1.904 +  cout << "Running simulator..." << endl;
   1.905 +  TIMER_NOW (t1);
   1.906 +  Simulator::Stop (Seconds(200.0));
   1.907 +  Simulator::Run ();
   1.908 +  TIMER_NOW (t2);
   1.909 +  cout << "Simulator finished." << endl;
   1.910 +  Simulator::Destroy ();
   1.911  
   1.912 -  cout << "Running simulator..." << endl;
   1.913 -  TIMER_NOW(t1);
   1.914 -  Simulator::Stop(Seconds(102.0));
   1.915 -  Simulator::Run();
   1.916 -  TIMER_NOW(t2);
   1.917 -  cout << "Simulator finished." << endl;
   1.918 -  Simulator::Destroy();
   1.919 -
   1.920 -  double d1 = TIMER_DIFF(t1, t0), d2 = TIMER_DIFF(t2, t1);
   1.921 +  double d1 = TIMER_DIFF (t1, t0), d2 = TIMER_DIFF (t2, t1);
   1.922    cout << "-----" << endl << "Runtime Stats:" << endl;
   1.923    cout << "Simulator init time: " << d1 << endl;
   1.924    cout << "Simulator run time: " << d2 << endl;
   1.925    cout << "Total elapsed time: " << d1+d2 << endl;
   1.926    return 0;
   1.927  #else
   1.928 -    NS_FATAL_ERROR ("Can't use distributed simulator without MPI compiled in");
   1.929 +  NS_FATAL_ERROR ("Can't use distributed simulator without MPI compiled in");
   1.930  #endif
   1.931  }
   1.932