diff -r d1785ce489c5 examples/routing/nms-p2p-nix.cc --- a/examples/routing/nms-p2p-nix.cc Tue Oct 26 18:02:17 2010 +0100 +++ b/examples/routing/nms-p2p-nix.cc Wed Oct 27 12:48:29 2010 +1100 @@ -71,14 +71,63 @@ cout << "Number of CNs: " << nCN << ", LAN nodes: " << nLANClients << endl; - NodeContainer nodes_net0[nCN][3], nodes_net1[nCN][6], nodes_netLR[nCN], - nodes_net2[nCN][14], nodes_net2LAN[nCN][7][nLANClients], - nodes_net3[nCN][9], nodes_net3LAN[nCN][5][nLANClients]; + NodeContainer** nodes_net0 = new NodeContainer*[nCN]; //[nCN][3] + for (int i = 0; i < nCN; i++) + nodes_net0[i] = new NodeContainer[3]; + NodeContainer** nodes_net1 = new NodeContainer*[nCN]; //[nCN][6] + for (int i = 0; i < nCN; i++) + nodes_net1[i] = new NodeContainer[6]; + NodeContainer* nodes_netLR = new NodeContainer[nCN]; //[nCN] + NodeContainer** nodes_net2 = new NodeContainer*[nCN]; //[nCN][14] + for (int i = 0; i < nCN; i++) + nodes_net2[i] = new NodeContainer[14]; + NodeContainer*** nodes_net2LAN = new NodeContainer**[nCN]; //[nCN][7][nLANClients] + for (int i = 0; i < nCN; i++) + { + nodes_net2LAN[i] = new NodeContainer*[7]; + for (int j = 0; j < 7; j++) + nodes_net2LAN[i][j] = new NodeContainer[nLANClients]; + } + NodeContainer** nodes_net3 = new NodeContainer*[nCN]; //[nCN][9] + for (int i = 0; i < nCN; i++) + nodes_net3[i] = new NodeContainer[9]; + NodeContainer*** nodes_net3LAN = new NodeContainer**[nCN]; //[nCN][5][nLANClients] + for (int i = 0; i < nCN; i++) + { + nodes_net3LAN[i] = new NodeContainer*[5]; + for (int j = 0; j < 5; j++) + nodes_net3LAN[i][j] = new NodeContainer[nLANClients]; + } PointToPointHelper p2p_2gb200ms, p2p_1gb5ms, p2p_100mb1ms; InternetStackHelper stack; - Ipv4InterfaceContainer ifs, ifs0[nCN][3], ifs1[nCN][6], ifs2[nCN][14], - ifs3[nCN][9], ifs2LAN[nCN][7][nLANClients], - ifs3LAN[nCN][5][nLANClients]; + Ipv4InterfaceContainer ifs; + Ipv4InterfaceContainer** ifs0 = new Ipv4InterfaceContainer*[nCN]; //[nCN][3] + for (int i = 0; i < nCN; i++) + ifs0[i] = new Ipv4InterfaceContainer[3]; + Ipv4InterfaceContainer** ifs1 = new Ipv4InterfaceContainer*[nCN]; //[nCN][6] + for (int i = 0; i < nCN; i++) + ifs1[i] = new Ipv4InterfaceContainer[6]; + Ipv4InterfaceContainer** ifs2 = new Ipv4InterfaceContainer*[nCN]; //[nCN][[14] + for (int i = 0; i < nCN; i++) + ifs2[i] = new Ipv4InterfaceContainer[14]; + Ipv4InterfaceContainer** ifs3 = new Ipv4InterfaceContainer*[nCN]; //[nCN][9] + for (int i = 0; i < nCN; i++) + ifs3[i] = new Ipv4InterfaceContainer[9]; + Ipv4InterfaceContainer*** ifs2LAN = new Ipv4InterfaceContainer**[nCN]; //[nCN][7][nLANClients] + for (int i = 0; i < nCN; i++) + { + ifs2LAN[i] = new Ipv4InterfaceContainer*[7]; + for (int j = 0; j < 7; j++) + ifs2LAN[i][j] = new Ipv4InterfaceContainer[nLANClients]; + } + Ipv4InterfaceContainer*** ifs3LAN = new Ipv4InterfaceContainer**[nCN]; //[nCN][5][nLANClients] + for (int i = 0; i < nCN; i++) + { + ifs3LAN[i] = new Ipv4InterfaceContainer*[5]; + for (int j = 0; j < 5; j++) + ifs3LAN[i][j] = new Ipv4InterfaceContainer[nLANClients]; + } + Ipv4AddressHelper address; std::ostringstream oss; p2p_1gb5ms.SetDeviceAttribute ("DataRate", StringValue ("1Gbps")); @@ -177,7 +226,11 @@ { ndc2[i] = p2p_1gb5ms.Install (nodes_net2[z][i]); } - NetDeviceContainer ndc2LAN[7][nLANClients]; +/// NetDeviceContainer ndc2LAN[7][nLANClients]; + NetDeviceContainer** ndc2LAN = new NetDeviceContainer*[7]; + for (int i = 0; i < 7; i++) + ndc2LAN[i] = new NetDeviceContainer[nLANClients]; + for (int i = 0; i < 7; ++i) { oss.str (""); @@ -213,7 +266,11 @@ { ndc3[i] = p2p_1gb5ms.Install (nodes_net3[z][i]); } - NetDeviceContainer ndc3LAN[5][nLANClients]; +/// NetDeviceContainer ndc3LAN[5][nLANClients]; + NetDeviceContainer** ndc3LAN = new NetDeviceContainer*[5]; + for (int i = 0; i < 5; i++) + ndc3LAN[i] = new NetDeviceContainer[nLANClients]; + for (int i = 0; i < 5; ++i) { oss.str (""); @@ -317,12 +374,20 @@ address.SetBase (oss.str ().c_str (), "255.255.255.0"); ifs3[z][i] = address.Assign (ndc3[i]); } + + for (int i = 0; i < 5; i++) + delete[] ndc3LAN[i]; + delete[] ndc3LAN; + + for (int i = 0; i < 7; i++) + delete[] ndc2LAN[i]; + delete[] ndc2LAN; } // Create Ring Links if (nCN > 1) { cout << "Forming Ring Topology..." << endl; - NodeContainer nodes_ring[nCN]; + NodeContainer* const nodes_ring = new NodeContainer[nCN]; for (int z = 0; z < nCN-1; ++z) { nodes_ring[z].Add (nodes_net0[z][0].Get (0)); @@ -330,7 +395,7 @@ } nodes_ring[nCN-1].Add (nodes_net0[nCN-1][0].Get (0)); nodes_ring[nCN-1].Add (nodes_net0[0][0].Get (0)); - NetDeviceContainer ndc_ring[nCN]; + NetDeviceContainer* const ndc_ring = new NetDeviceContainer[nCN]; for (int z = 0; z < nCN; ++z) { ndc_ring[z] = p2p_2gb200ms.Install (nodes_ring[z]); @@ -339,6 +404,8 @@ address.SetBase (oss.str ().c_str (), "255.255.255.0"); ifs = address.Assign (ndc_ring[z]); } + delete[] ndc_ring; + delete[] nodes_ring; } // Create Traffic Flows @@ -445,5 +512,72 @@ cout << "Simulator init time: " << d1 << endl; cout << "Simulator run time: " << d2 << endl; cout << "Total elapsed time: " << d1+d2 << endl; + + for (int i = 0; i < nCN; i++) + { + for (int j = 0; j < 5; j++) + delete[] ifs3LAN[i][j]; + delete[] ifs3LAN[i]; + } + delete[] ifs3LAN; + + for (int i = 0; i < nCN; i++) + { + for (int j = 0; j < 7; j++) + delete[] ifs2LAN[i][j]; + delete[] ifs2LAN[i]; + } + delete[] ifs2LAN; + + for (int i = 0; i < nCN; i++) + delete[] ifs3[i]; + delete[] ifs3; + + for (int i = 0; i < nCN; i++) + delete[] ifs2[i]; + delete[] ifs2; + + for (int i = 0; i < nCN; i++) + delete[] ifs1[i]; + delete[] ifs1; + + for (int i = 0; i < nCN; i++) + delete[] ifs0[i]; + delete[] ifs0; + + for (int i = 0; i < nCN; i++) + { + for (int j = 0; j < 5; j++) + delete[] nodes_net3LAN[i][j]; + delete[] nodes_net3LAN[i]; + } + delete[] nodes_net3LAN; + + for (int i = 0; i < nCN; i++) + delete[] nodes_net3[i]; + delete[] nodes_net3; + + for (int i = 0; i < nCN; i++) + { + for (int j = 0; j < 7; j++) + delete[] nodes_net2LAN[i][j]; + delete[] nodes_net2LAN[i]; + } + delete[] nodes_net2LAN; + + for (int i = 0; i < nCN; i++) + delete[] nodes_net2[i]; + delete[] nodes_net2; + + delete[] nodes_netLR; + + for (int i = 0; i < nCN; i++) + delete[] nodes_net1[i]; + delete[] nodes_net1; + + for (int i = 0; i < nCN; i++) + delete[] nodes_net0[i]; + delete[] nodes_net0; + return 0; }