64 |
64 |
65 int |
65 int |
66 main (int argc, char *argv[]) |
66 main (int argc, char *argv[]) |
67 { |
67 { |
68 #ifdef NS3_MPI |
68 #ifdef NS3_MPI |
69 // Distributed simulation setup |
69 |
|
70 bool nix = true; |
|
71 bool nullmsg = false; |
|
72 bool tracing = false; |
|
73 |
|
74 // Parse command line |
|
75 CommandLine cmd; |
|
76 cmd.AddValue ("nix", "Enable the use of nix-vector or global routing", nix); |
|
77 cmd.AddValue ("nullmsg", "Enable the use of null-message synchronization", nullmsg); |
|
78 cmd.AddValue ("tracing", "Enable pcap tracing", tracing); |
|
79 cmd.Parse (argc, argv); |
|
80 |
|
81 // Distributed simulation setup; by default use granted time window algorithm. |
|
82 if(nullmsg) |
|
83 { |
|
84 GlobalValue::Bind ("SimulatorImplementationType", |
|
85 StringValue ("ns3::NullMessageSimulatorImpl")); |
|
86 } |
|
87 else |
|
88 { |
|
89 GlobalValue::Bind ("SimulatorImplementationType", |
|
90 StringValue ("ns3::DistributedSimulatorImpl")); |
|
91 } |
|
92 |
|
93 // Enable parallel simulator with the command line arguments |
70 MpiInterface::Enable (&argc, &argv); |
94 MpiInterface::Enable (&argc, &argv); |
71 GlobalValue::Bind ("SimulatorImplementationType", |
|
72 StringValue ("ns3::DistributedSimulatorImpl")); |
|
73 |
95 |
74 LogComponentEnable ("PacketSink", LOG_LEVEL_INFO); |
96 LogComponentEnable ("PacketSink", LOG_LEVEL_INFO); |
75 |
97 |
76 uint32_t systemId = MpiInterface::GetSystemId (); |
98 uint32_t systemId = MpiInterface::GetSystemId (); |
77 uint32_t systemCount = MpiInterface::GetSize (); |
99 uint32_t systemCount = MpiInterface::GetSize (); |
86 |
108 |
87 // Some default values |
109 // Some default values |
88 Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (512)); |
110 Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (512)); |
89 Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("1Mbps")); |
111 Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("1Mbps")); |
90 Config::SetDefault ("ns3::OnOffApplication::MaxBytes", UintegerValue (512)); |
112 Config::SetDefault ("ns3::OnOffApplication::MaxBytes", UintegerValue (512)); |
91 bool nix = true; |
|
92 |
|
93 // Parse command line |
|
94 CommandLine cmd; |
|
95 cmd.AddValue ("nix", "Enable the use of nix-vector or global routing", nix); |
|
96 cmd.Parse (argc, argv); |
|
97 |
113 |
98 // Create leaf nodes on left with system id 0 |
114 // Create leaf nodes on left with system id 0 |
99 NodeContainer leftLeafNodes; |
115 NodeContainer leftLeafNodes; |
100 leftLeafNodes.Create (4, 0); |
116 leftLeafNodes.Create (4, 0); |
101 |
117 |
202 } |
218 } |
203 |
219 |
204 if (!nix) |
220 if (!nix) |
205 { |
221 { |
206 Ipv4GlobalRoutingHelper::PopulateRoutingTables (); |
222 Ipv4GlobalRoutingHelper::PopulateRoutingTables (); |
|
223 } |
|
224 |
|
225 if (tracing == true) |
|
226 { |
|
227 if (systemId == 0) |
|
228 { |
|
229 routerLink.EnablePcap("router-left", routerDevices, true); |
|
230 leafLink.EnablePcap("leaf-left", leftLeafDevices, true); |
|
231 } |
|
232 |
|
233 if (systemId == 1) |
|
234 { |
|
235 routerLink.EnablePcap("router-right", routerDevices, true); |
|
236 leafLink.EnablePcap("leaf-right", rightLeafDevices, true); |
|
237 } |
207 } |
238 } |
208 |
239 |
209 // Create a packet sink on the right leafs to receive packets from left leafs |
240 // Create a packet sink on the right leafs to receive packets from left leafs |
210 uint16_t port = 50000; |
241 uint16_t port = 50000; |
211 if (systemId == 1) |
242 if (systemId == 1) |