OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * This program is free software; you can redistribute it and/or modify | 3 * This program is free software; you can redistribute it and/or modify |
4 * it under the terms of the GNU General Public License version 2 as | 4 * it under the terms of the GNU General Public License version 2 as |
5 * published by the Free Software Foundation; | 5 * published by the Free Software Foundation; |
6 * | 6 * |
7 * This program is distributed in the hope that it will be useful, | 7 * This program is distributed in the hope that it will be useful, |
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 8 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 * GNU General Public License for more details. | 10 * GNU General Public License for more details. |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 // Conveniently, the variable "backboneNodes" holds this node index value | 356 // Conveniently, the variable "backboneNodes" holds this node index value |
357 Ptr<Node> appSource = NodeList::GetNode (backboneNodes); | 357 Ptr<Node> appSource = NodeList::GetNode (backboneNodes); |
358 // We want the sink to be the last node created in the topology. | 358 // We want the sink to be the last node created in the topology. |
359 uint32_t lastNodeIndex = backboneNodes + backboneNodes*(lanNodes - 1) + backbo
neNodes*(infraNodes - 1) - 1; | 359 uint32_t lastNodeIndex = backboneNodes + backboneNodes*(lanNodes - 1) + backbo
neNodes*(infraNodes - 1) - 1; |
360 Ptr<Node> appSink = NodeList::GetNode (lastNodeIndex); | 360 Ptr<Node> appSink = NodeList::GetNode (lastNodeIndex); |
361 // Let's fetch the IP address of the last node, which is on Ipv4Interface 1 | 361 // Let's fetch the IP address of the last node, which is on Ipv4Interface 1 |
362 Ipv4Address remoteAddr = appSink->GetObject<Ipv4> ()->GetAddress (1, 0).GetLoc
al (); | 362 Ipv4Address remoteAddr = appSink->GetObject<Ipv4> ()->GetAddress (1, 0).GetLoc
al (); |
363 | 363 |
364 OnOffHelper onoff ("ns3::UdpSocketFactory",· | 364 OnOffHelper onoff ("ns3::UdpSocketFactory",· |
365 Address (InetSocketAddress (remoteAddr, port))); | 365 Address (InetSocketAddress (remoteAddr, port))); |
366 onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1))); | 366 onoff.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[Consta
nt=1]")); |
367 onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0))); | 367 onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Const
ant=0]")); |
368 ApplicationContainer apps = onoff.Install (appSource); | 368 ApplicationContainer apps = onoff.Install (appSource); |
369 apps.Start (Seconds (3.0)); | 369 apps.Start (Seconds (3.0)); |
370 apps.Stop (Seconds (20.0)); | 370 apps.Stop (Seconds (20.0)); |
371 | 371 |
372 // Create a packet sink to receive these packets | 372 // Create a packet sink to receive these packets |
373 PacketSinkHelper sink ("ns3::UdpSocketFactory",· | 373 PacketSinkHelper sink ("ns3::UdpSocketFactory",· |
374 InetSocketAddress (Ipv4Address::GetAny (), port)); | 374 InetSocketAddress (Ipv4Address::GetAny (), port)); |
375 apps = sink.Install (appSink); | 375 apps = sink.Install (appSink); |
376 apps.Start (Seconds (3.0)); | 376 apps.Start (Seconds (3.0)); |
377 | 377 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 // // | 416 // // |
417 // Run simulation // | 417 // Run simulation // |
418 // // | 418 // // |
419 ///////////////////////////////////////////////////////////////////////////· | 419 ///////////////////////////////////////////////////////////////////////////· |
420 | 420 |
421 NS_LOG_INFO ("Run Simulation."); | 421 NS_LOG_INFO ("Run Simulation."); |
422 Simulator::Stop (Seconds (stopTime)); | 422 Simulator::Stop (Seconds (stopTime)); |
423 Simulator::Run (); | 423 Simulator::Run (); |
424 Simulator::Destroy (); | 424 Simulator::Destroy (); |
425 } | 425 } |
OLD | NEW |