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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 Address hubLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port)); | 81 Address hubLocalAddress (InetSocketAddress (Ipv4Address::GetAny (), port)); |
82 PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", hubLocalAddress); | 82 PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", hubLocalAddress); |
83 ApplicationContainer hubApp = packetSinkHelper.Install (star.GetHub ()); | 83 ApplicationContainer hubApp = packetSinkHelper.Install (star.GetHub ()); |
84 hubApp.Start (Seconds (1.0)); | 84 hubApp.Start (Seconds (1.0)); |
85 hubApp.Stop (Seconds (10.0)); | 85 hubApp.Stop (Seconds (10.0)); |
86 | 86 |
87 // | 87 // |
88 // Create OnOff applications to send TCP to the hub, one on each spoke node. | 88 // Create OnOff applications to send TCP to the hub, one on each spoke node. |
89 // | 89 // |
90 OnOffHelper onOffHelper ("ns3::TcpSocketFactory", Address ()); | 90 OnOffHelper onOffHelper ("ns3::TcpSocketFactory", Address ()); |
91 onOffHelper.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (1))
); | 91 onOffHelper.SetAttribute ("OnTime", StringValue ("ns3::ConstantRandomVariable[
Constant=1]")); |
92 onOffHelper.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)
)); | 92 onOffHelper.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable
[Constant=0]")); |
93 | 93 |
94 ApplicationContainer spokeApps; | 94 ApplicationContainer spokeApps; |
95 | 95 |
96 for (uint32_t i = 0; i < star.SpokeCount (); ++i) | 96 for (uint32_t i = 0; i < star.SpokeCount (); ++i) |
97 { | 97 { |
98 AddressValue remoteAddress (InetSocketAddress (star.GetHubIpv4Address (i),
port)); | 98 AddressValue remoteAddress (InetSocketAddress (star.GetHubIpv4Address (i),
port)); |
99 onOffHelper.SetAttribute ("Remote", remoteAddress); | 99 onOffHelper.SetAttribute ("Remote", remoteAddress); |
100 spokeApps.Add (onOffHelper.Install (star.GetSpokeNode (i))); | 100 spokeApps.Add (onOffHelper.Install (star.GetSpokeNode (i))); |
101 } | 101 } |
102 spokeApps.Start (Seconds (1.0)); | 102 spokeApps.Start (Seconds (1.0)); |
(...skipping 11 matching lines...) Expand all Loading... |
114 // | 114 // |
115 pointToPoint.EnablePcapAll ("star"); | 115 pointToPoint.EnablePcapAll ("star"); |
116 | 116 |
117 NS_LOG_INFO ("Run Simulation."); | 117 NS_LOG_INFO ("Run Simulation."); |
118 Simulator::Run (); | 118 Simulator::Run (); |
119 Simulator::Destroy (); | 119 Simulator::Destroy (); |
120 NS_LOG_INFO ("Done."); | 120 NS_LOG_INFO ("Done."); |
121 | 121 |
122 return 0; | 122 return 0; |
123 } | 123 } |
OLD | NEW |