From d43a904b5ebfcf1bbd8ef78b71a0eb601f6481bd Mon Sep 17 00:00:00 2001 From: Josh Pelkey Date: Thu, 11 Nov 2010 16:09:15 -0500 Subject: [PATCH] fix nms examples --- ...-udp-nix.cc => nms-p2p-nix-distributed.cc} | 24 ++++---- examples/mpi/wscript | 4 +- examples/routing/nms-p2p-nix.cc | 55 +++++++++++++------ 3 files changed, 51 insertions(+), 32 deletions(-) rename examples/mpi/{nms-udp-nix.cc => nms-p2p-nix-distributed.cc} (94%) diff --git a/examples/mpi/nms-udp-nix.cc b/examples/mpi/nms-p2p-nix-distributed.cc similarity index 94% rename from examples/mpi/nms-udp-nix.cc rename to examples/mpi/nms-p2p-nix-distributed.cc index 55ac5a0fd..afd24c5f0 100644 --- a/examples/mpi/nms-udp-nix.cc +++ b/examples/mpi/nms-p2p-nix-distributed.cc @@ -62,7 +62,7 @@ typedef struct timeval TIMER_TYPE; #define TIMER_SECONDS(_t) ((double)(_t).tv_sec + (_t).tv_usec * 1e-6) #define TIMER_DIFF(_t1, _t2) (TIMER_SECONDS (_t1) - TIMER_SECONDS (_t2)) -NS_LOG_COMPONENT_DEFINE ("CampusNetworkModel"); +NS_LOG_COMPONENT_DEFINE ("CampusNetworkModelDistributed"); int main (int argc, char *argv[]) @@ -468,7 +468,7 @@ main (int argc, char *argv[]) ApplicationContainer sinkApp = sinkHelper.Install (nodes_net2LAN[z][i][j].Get (0)); - sinkApp.Start (Seconds (100.0)); + sinkApp.Start (Seconds (0.0)); } else if (systemId == z % systemCount) { @@ -479,13 +479,13 @@ main (int argc, char *argv[]) ApplicationContainer sinkApp = sinkHelper.Install (nodes_net2LAN[z][i][j].Get (0)); - sinkApp.Start (Seconds (100.0)); + sinkApp.Start (Seconds (0.0)); } // Sources if (systemCount == 1) { r1 = 2 + (int)(4 * urng.GetValue ()); - r2 = 100 + (10 * urng.GetValue ()); + r2 = 10 * urng.GetValue (); OnOffHelper client ("ns3::UdpSocketFactory", Address ()); AddressValue remoteAddress @@ -499,7 +499,7 @@ main (int argc, char *argv[]) else if (systemId == x % systemCount) { r1 = 2 + (int)(4 * urng.GetValue ()); - r2 = 100 + (10 * urng.GetValue ()); + r2 = 10 * urng.GetValue (); OnOffHelper client ("ns3::UdpSocketFactory", Address ()); AddressValue remoteAddress @@ -528,7 +528,7 @@ main (int argc, char *argv[]) ApplicationContainer sinkApp = sinkHelper.Install (nodes_net3LAN[z][i][j].Get (0)); - sinkApp.Start (Seconds (100.0)); + sinkApp.Start (Seconds (0.0)); } else if (systemId == z % systemCount) { @@ -539,17 +539,17 @@ main (int argc, char *argv[]) ApplicationContainer sinkApp = sinkHelper.Install (nodes_net3LAN[z][i][j].Get (0)); - sinkApp.Start (Seconds (100.0)); + sinkApp.Start (Seconds (0.0)); } // Sources if (systemCount == 1) { r1 = 2 + (int)(4 * urng.GetValue ()); - r2 = 100 + (10 * urng.GetValue ()); + r2 = 10 * urng.GetValue (); OnOffHelper client ("ns3::UdpSocketFactory", Address ()); AddressValue remoteAddress - (InetSocketAddress (ifs2LAN[z][i][j].GetAddress (0), 9999)); + (InetSocketAddress (ifs3LAN[z][i][j].GetAddress (0), 9999)); client.SetAttribute ("Remote", remoteAddress); ApplicationContainer clientApp; @@ -559,11 +559,11 @@ main (int argc, char *argv[]) else if (systemId == x % systemCount) { r1 = 2 + (int)(4 * urng.GetValue ()); - r2 = 100 + (10 * urng.GetValue ()); + r2 = 10 * urng.GetValue (); OnOffHelper client ("ns3::UdpSocketFactory", Address ()); AddressValue remoteAddress - (InetSocketAddress (ifs2LAN[z][i][j].GetAddress (0), 9999)); + (InetSocketAddress (ifs3LAN[z][i][j].GetAddress (0), 9999)); client.SetAttribute ("Remote", remoteAddress); ApplicationContainer clientApp; @@ -597,7 +597,7 @@ main (int argc, char *argv[]) cout << "Running simulator..." << endl; TIMER_NOW (t1); - Simulator::Stop (Seconds (200.0)); + Simulator::Stop (Seconds (100.0)); Simulator::Run (); TIMER_NOW (t2); cout << "Simulator finished." << endl; diff --git a/examples/mpi/wscript b/examples/mpi/wscript index 6eadc0f4f..82b530b51 100644 --- a/examples/mpi/wscript +++ b/examples/mpi/wscript @@ -9,6 +9,6 @@ def build(bld): ['point-to-point', 'internet-stack']) obj.source = 'third-distributed.cc' - obj = bld.create_ns3_program('nms-udp-nix', + obj = bld.create_ns3_program('nms-p2p-nix-distributed', ['point-to-point', 'internet-stack']) - obj.source = 'nms-udp-nix.cc' + obj.source = 'nms-p2p-nix-distributed.cc' diff --git a/examples/routing/nms-p2p-nix.cc b/examples/routing/nms-p2p-nix.cc index dc5cf5386..961a5cbf2 100644 --- a/examples/routing/nms-p2p-nix.cc +++ b/examples/routing/nms-p2p-nix.cc @@ -1,13 +1,35 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -// DARPA NMS Campus Network Model -// -// - This topology replicates the original NMS Campus Network model -// with the exception of chord links (which were never utilized in the -// original model) -// - Link Bandwidths and Delays may not be the same as the original -// specifications -// -// (c)2009, GTech Systems, Inc. - Alfred Park +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation; + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * (c) 2009, GTech Systems, Inc. - Alfred Park + * + * DARPA NMS Campus Network Model + * + * This topology replicates the original NMS Campus Network model + * with the exception of chord links (which were never utilized in the + * original model) + * Link Bandwidths and Delays may not be the same as the original + * specifications + * + * The fundamental unit of the NMS model consists of a campus network. The + * campus network topology can been seen here: + * http://www.nsnam.org/~jpelkey3/nms.png + * The number of hosts (default 42) is variable. Finally, an arbitrary + * number of these campus networks can be connected together (default 2) + * to make very large simulations. + */ // for timing functions #include @@ -45,14 +67,11 @@ void Progress () int main (int argc, char *argv[]) { - //Config::SetDefault ("ns3::Simulator::SchedulerType", StringValue ("ns3::CalendarScheduler")); TIMER_TYPE t0, t1, t2; TIMER_NOW(t0); cout << " ==== DARPA NMS CAMPUS NETWORK SIMULATION ====" << endl; LogComponentEnable ("OnOffApplication", LOG_LEVEL_INFO); - //RandomVariable::UseGlobalSeed (1, 1, 2, 3, 5, 8); - int nCN = 2, nLANClients = 42; bool nix = true; @@ -371,10 +390,10 @@ main (int argc, char *argv[]) InetSocketAddress (Ipv4Address::GetAny (), 9999)); ApplicationContainer sinkApp = sinkHelper.Install ( nodes_net2LAN[z][i][j].Get (0)); - sinkApp.Start (Seconds (100.0)); + sinkApp.Start (Seconds (0.0)); // Sources r1 = 2 + (int)(4 * urng.GetValue ()); - r2 = 100 + (10 * urng.GetValue ());; + r2 = 10 * urng.GetValue (); OnOffHelper client ("ns3::TcpSocketFactory", Address ()); AddressValue remoteAddress(InetSocketAddress ( ifs2LAN[z][i][j].GetAddress (0), 9999)); @@ -395,13 +414,13 @@ main (int argc, char *argv[]) InetSocketAddress (Ipv4Address::GetAny (), 9999)); ApplicationContainer sinkApp = sinkHelper.Install ( nodes_net3LAN[z][i][j].Get (0)); - sinkApp.Start (Seconds (100.0)); + sinkApp.Start (Seconds (0.0)); // Sources r1 = 2 + (int)(4 * urng.GetValue ()); - r2 = 100 + (10 * urng.GetValue ());; + r2 = 10 * urng.GetValue (); OnOffHelper client ("ns3::TcpSocketFactory", Address ()); AddressValue remoteAddress (InetSocketAddress ( - ifs2LAN[z][i][j].GetAddress (0), 9999)); + ifs3LAN[z][i][j].GetAddress (0), 9999)); client.SetAttribute ("Remote", remoteAddress); ApplicationContainer clientApp; clientApp.Add (client.Install (nodes_net1[x][r1].Get (0))); @@ -434,7 +453,7 @@ main (int argc, char *argv[]) Simulator::ScheduleNow (Progress); cout << "Running simulator..." << endl; TIMER_NOW (t1); - Simulator::Stop (Seconds (200.0)); + Simulator::Stop (Seconds (100.0)); Simulator::Run (); TIMER_NOW (t2); cout << "Simulator finished." << endl;