LEFT | RIGHT |
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // | 48 // |
49 Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (137)); | 49 Config::SetDefault ("ns3::OnOffApplication::PacketSize", UintegerValue (137)); |
50 | 50 |
51 // ??? try and stick 15kb/s into the data rate | 51 // ??? try and stick 15kb/s into the data rate |
52 Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("14kb/s"))
; | 52 Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue ("14kb/s"))
; |
53 | 53 |
54 // | 54 // |
55 // Default number of nodes in the star. Overridable by command line argument. | 55 // Default number of nodes in the star. Overridable by command line argument. |
56 // | 56 // |
57 uint32_t nSpokes = 8; | 57 uint32_t nSpokes = 8; |
58 uint32_t animPort = 0; | 58 std::string animFile = "star-animation.xml"; |
59 std::string animFile; | |
60 uint8_t useIpv6 = 0; | 59 uint8_t useIpv6 = 0; |
61 uint64_t ipv6AddressBase = 0x2001000000000000; | 60 Ipv6Address ipv6AddressBase = Ipv6Address("2001::"); |
| 61 Ipv6Prefix ipv6AddressPrefix = Ipv6Prefix(64); |
62 | 62 |
63 CommandLine cmd; | 63 CommandLine cmd; |
64 cmd.AddValue ("nSpokes", "Number of spoke nodes to place in the star", nSpokes
); | 64 cmd.AddValue ("nSpokes", "Number of spoke nodes to place in the star", nSpokes
); |
65 cmd.AddValue ("animPort", "Port Number for Remote Animation", animPort); | |
66 cmd.AddValue ("animFile", "File Name for Animation Output", animFile); | 65 cmd.AddValue ("animFile", "File Name for Animation Output", animFile); |
67 cmd.AddValue ("useIpv6", "use Ipv6", useIpv6); | 66 cmd.AddValue ("useIpv6", "use Ipv6", useIpv6); |
68 | 67 |
69 cmd.Parse (argc, argv); | 68 cmd.Parse (argc, argv); |
70 | 69 |
71 NS_LOG_INFO ("Build star topology."); | 70 NS_LOG_INFO ("Build star topology."); |
72 PointToPointHelper pointToPoint; | 71 PointToPointHelper pointToPoint; |
73 pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); | 72 pointToPoint.SetDeviceAttribute ("DataRate", StringValue ("5Mbps")); |
74 pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms")); | 73 pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms")); |
75 PointToPointStarHelper star (nSpokes, pointToPoint); | 74 PointToPointStarHelper star (nSpokes, pointToPoint); |
76 | 75 |
77 NS_LOG_INFO ("Install internet stack on all nodes."); | 76 NS_LOG_INFO ("Install internet stack on all nodes."); |
78 InternetStackHelper internet; | 77 InternetStackHelper internet; |
79 star.InstallStack (internet); | 78 star.InstallStack (internet); |
80 | 79 |
81 NS_LOG_INFO ("Assign IP Addresses."); | 80 NS_LOG_INFO ("Assign IP Addresses."); |
82 if (useIpv6 == 0) | 81 if (useIpv6 == 0) |
83 { | 82 { |
84 star.AssignIpv4Addresses (Ipv4AddressHelper ("10.1.1.0", "255.255.255.0"))
; | 83 star.AssignIpv4Addresses (Ipv4AddressHelper ("10.1.1.0", "255.255.255.0"))
; |
85 } | 84 } |
86 else | 85 else |
87 { | 86 { |
88 star.AssignIpv6Addresses (ipv6AddressBase); | 87 star.AssignIpv6Addresses (ipv6AddressBase, ipv6AddressPrefix); |
89 } | 88 } |
90 | 89 |
91 NS_LOG_INFO ("Create applications."); | 90 NS_LOG_INFO ("Create applications."); |
92 // | 91 // |
93 // Create a packet sink on the star "hub" to receive packets. | 92 // Create a packet sink on the star "hub" to receive packets. |
94 //· | 93 //· |
95 uint16_t port = 50000; | 94 uint16_t port = 50000; |
96 Address hubLocalAddress; | 95 Address hubLocalAddress; |
97 if (useIpv6 == 0) | 96 if (useIpv6 == 0) |
98 { | 97 { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 // | 138 // |
140 if (useIpv6 == 0) | 139 if (useIpv6 == 0) |
141 { | 140 { |
142 Ipv4GlobalRoutingHelper::PopulateRoutingTables (); | 141 Ipv4GlobalRoutingHelper::PopulateRoutingTables (); |
143 } | 142 } |
144 | 143 |
145 // Set the bounding box for animation | 144 // Set the bounding box for animation |
146 star.BoundingBox (1, 1, 100, 100); | 145 star.BoundingBox (1, 1, 100, 100); |
147 | 146 |
148 // Create the animation object and configure for specified output | 147 // Create the animation object and configure for specified output |
149 AnimationInterface anim; | 148 AnimationInterface anim (animFile); |
150 if (animPort > 0) | |
151 { | |
152 anim.SetServerPort (animPort); | |
153 } | |
154 else if (!animFile.empty ()) | |
155 { | |
156 anim.SetOutputFile (animFile); | |
157 } | |
158 anim.StartAnimation (); | |
159 | 149 |
160 NS_LOG_INFO ("Run Simulation."); | 150 NS_LOG_INFO ("Run Simulation."); |
161 Simulator::Run (); | 151 Simulator::Run (); |
162 Simulator::Destroy (); | 152 Simulator::Destroy (); |
163 NS_LOG_INFO ("Done."); | 153 NS_LOG_INFO ("Done."); |
164 | 154 |
165 return 0; | 155 return 0; |
166 } | 156 } |
LEFT | RIGHT |