Left: | ||
Right: |
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 * Copyright (c) 2011 Yufei Cheng | 3 * Copyright (c) 2011 Yufei Cheng |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 5 * This program is free software; you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 2 as | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 int main (int argc, char *argv[]) | 46 int main (int argc, char *argv[]) |
47 { | 47 { |
48 // | 48 // |
49 // Users may find it convenient to turn on explicit debugging | 49 // Users may find it convenient to turn on explicit debugging |
50 // for selected modules; the below lines suggest how to do this | 50 // for selected modules; the below lines suggest how to do this |
51 // | 51 // |
52 #if 0 | 52 #if 0 |
53 LogComponentEnable ("HttpClient", LOG_LEVEL_ALL); | 53 LogComponentEnable ("HttpClient", LOG_LEVEL_ALL); |
54 LogComponentEnable ("HttpServer", LOG_LEVEL_ALL); | 54 LogComponentEnable ("HttpServer", LOG_LEVEL_ALL); |
55 LogComponentEnable ("HttpDistribution", LOG_LEVEL_ALL); | 55 LogComponentEnable ("HttpDistribution", LOG_LEVEL_ALL); |
56 LogComponentEnable ("HttpRuntimeVariable", LOG_LEVEL_ALL); | 56 LogComponentEnable ("HttpController", LOG_LEVEL_ALL); |
57 LogComponentEnable ("HttpSeqHeader", LOG_LEVEL_ALL); | |
58 #endif | 57 #endif |
58 | |
59 LogComponentEnable ("HttpTest", LOG_LEVEL_ALL); | |
60 | |
61 uint32_t totalTime = 1000; | |
62 uint32_t dataStart = 30; | |
63 uint32_t nNodes = 2; | |
64 std::string delay = "2ms"; | |
65 std::string dataRate = "1Mbps"; | |
66 | |
67 // Allow users to override the default parameters and set it to new ones from CommandLine. | |
68 CommandLine cmd; | |
69 /* | |
70 * The parameter for the p2p link | |
71 */ | |
72 cmd.AddValue ("DataRate", "The data rate for the link", dataRate); | |
73 cmd.AddValue ("Delay", "The delay for the link", delay); | |
74 cmd.Parse (argc, argv); | |
59 | 75 |
60 SeedManager::SetSeed (99); | 76 SeedManager::SetSeed (99); |
61 SeedManager::SetRun (1); | 77 SeedManager::SetRun (1); |
62 | 78 |
63 uint32_t totalTime = 500; | |
64 uint32_t dataStart = 30; | |
65 uint32_t runNo = 1; | |
66 uint32_t nWifis = 2; | |
67 std::string rate = "2048bps"; | |
68 | |
69 // http parameters | |
70 TypeId transportId = TcpSocketFactory::GetTypeId (); | |
71 /* | |
72 * Change this to the routing protocol using when running wireless simulations | |
73 * Set it as wired when using wired simulation | |
74 */ | |
75 | |
76 std::string routingProtocol ("Wired"); | |
77 std::string transportProtocol ("TCP"); | |
Tom Henderson
2012/03/02 02:04:09
I did not really understand the need for the above
| |
78 uint32_t thinkTime = 1; | |
79 uint32_t timeoutLimit = 10; | |
80 uint32_t maxSessions = 10; | |
81 bool forcePersistent = true; | |
82 bool http1_1 = false; | |
83 bool automatic = true; | |
84 uint32_t connectionInterval = 1; | |
85 /* | |
86 * No need to define if using automatic traffic generation mode | |
87 */ | |
88 uint32_t userPages = 3; | |
89 uint32_t userObjects = 3; | |
90 double userServerDelay = 0.1; | |
91 double userRequestGap = 0.1; | |
92 uint32_t userRequestSize = 100; | |
93 uint32_t userResponseSize = 2048; | |
94 uint32_t maxConnections = 50; | |
95 | |
96 //Allow users to override the default parameters and set it to new ones from C ommandLine. | |
97 CommandLine cmd; | |
98 cmd.AddValue ("nWifis", "Number of wifi networks, Default:30", nWifis); | |
99 cmd.AddValue ("RunNo", "The run number of this simulation", runNo); | |
100 //---------------------------------------------------------------------------- --------------------------- | |
101 /* | |
102 * The configuration for HTTP client | |
103 */ | |
104 cmd.AddValue ("TransportId", "The protocol type id to use as transport protoco l", transportId); | |
105 cmd.AddValue ("RoutingProtocol", "The routing protocol to use, set as wired if is wired devices", routingProtocol); | |
106 cmd.AddValue ("TransportProtocol", "The transport to use, this variable is for tracing", transportProtocol); | |
107 cmd.AddValue ("ThinkTime", "The think time(in seconds), Default:1", thinkTime) ; | |
108 cmd.AddValue ("TimeoutLimit", "The timeout limit(in seconds) for transport con nection, Default:15", timeoutLimit); | |
109 cmd.AddValue ("MaxSessions", "number of sessions for each transport connection , Default:100", maxSessions); | |
110 cmd.AddValue ("ForcePersistent", "For the connection to be persistent", forceP ersistent); | |
111 cmd.AddValue ("Http1_1", "When the connection will be using HTTP 1.1 or HTTP 1 .0", http1_1); | |
112 cmd.AddValue ("Automatic", "Enable/disable the automatic variable generation m ode", automatic); | |
113 cmd.AddValue ("ConnectionInterval", "The interval between tranport connections ", connectionInterval); | |
114 /* | |
115 * No need to define if using automatic traffic generation mode | |
116 */ | |
117 cmd.AddValue ("UserPages", "The total number of pages for a web session", user Pages); | |
118 cmd.AddValue ("UserObjects", "The total number of objects for a single page", userObjects); | |
119 cmd.AddValue ("UserServerDelay", "The server delay (in seconds)", userServerDe lay); | |
120 cmd.AddValue ("UserRequestGap", "The user server delay", userRequestGap); | |
121 cmd.AddValue ("UserRequestSize", "The user request size", userRequestSize); | |
122 cmd.AddValue ("UserResponseSize", "The user response size", userResponseSize); | |
123 //---------------------------------------------------------------------------- --------------------------- | |
124 /* | |
125 * The configuration for HTTP server | |
126 */ | |
127 cmd.AddValue ("TransportId", "The protocol type id to use as transport protoco l", transportId); | |
128 cmd.AddValue ("MaxConnections", "Maximum number of connections a server can ha ndle", maxConnections); | |
129 cmd.Parse (argc, argv); | |
130 | |
131 Config::SetDefault ("ns3::OnOffApplication::PacketSize", StringValue ("64")); | |
132 Config::SetDefault ("ns3::OnOffApplication::DataRate", StringValue (rate)); | |
Tom Henderson
2012/03/02 02:04:09
why on-off?
| |
133 | |
134 // Fix non-unicast data rate to be the same as that of unicast | |
Tom Henderson
2012/03/02 02:04:09
this comment doesn't match the code
| |
135 Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringVa lue ("2000")); | |
136 | |
137 NS_LOG_INFO ("Create nodes."); | 79 NS_LOG_INFO ("Create nodes."); |
138 NodeContainer nodes; | 80 NodeContainer nodes; |
139 nodes.Create (nWifis); | 81 nodes.Create (nNodes); |
140 NetDeviceContainer devices; | 82 NetDeviceContainer devices; |
141 | |
142 Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", StringVal ue ("DsssRate11Mbps")); | |
143 //disable fragmentation | |
144 Config::SetDefault ("ns3::WifiRemoteStationManager::FragmentationThreshold", S tringValue ("2200")); | |
145 Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringVa lue ("2200")); | |
146 | 83 |
147 NS_LOG_INFO ("Create channels."); | 84 NS_LOG_INFO ("Create channels."); |
148 // We create the channels first without any IP addressing information | 85 // We create the channels first without any IP addressing information |
149 PointToPointHelper p2p; | 86 PointToPointHelper p2p; |
150 p2p.SetDeviceAttribute ("DataRate", StringValue ("10Mbps")); | 87 p2p.SetDeviceAttribute ("DataRate", StringValue (dataRate)); |
151 p2p.SetChannelAttribute ("Delay", StringValue ("2ms")); | 88 p2p.SetChannelAttribute ("Delay", StringValue (delay)); |
152 devices = p2p.Install (nodes); | 89 devices = p2p.Install (nodes); |
153 | 90 |
154 InternetStackHelper internet; | 91 InternetStackHelper internet; |
155 internet.Install (nodes); | 92 internet.Install (nodes); |
156 | 93 |
157 NS_LOG_INFO ("Setting the address"); | 94 NS_LOG_INFO ("Setting the address"); |
158 Ipv4AddressHelper address; | 95 Ipv4AddressHelper address; |
159 address.SetBase ("10.1.1.0", "255.255.255.0"); | 96 address.SetBase ("10.1.1.0", "255.255.255.0"); |
160 Ipv4InterfaceContainer interfaces; | 97 Ipv4InterfaceContainer interfaces; |
161 interfaces = address.Assign (devices); | 98 interfaces = address.Assign (devices); |
162 | 99 |
163 double randomStartTime = (1.0 / 4) / (nWifis); | 100 double randomStartTime = (1.0 / 4) / (nNodes); |
164 Ptr<http::RuntimeVariable> runtimeVariable = CreateObject<http::RuntimeVariabl e> (); | |
Tom Henderson
2012/03/02 02:04:09
what is the point of creating a (default) runtimeV
| |
165 | 101 |
166 uint16_t port = 80; | 102 uint16_t port = 80; |
167 uint32_t count = 0; | 103 uint32_t count = 0; |
168 | 104 |
169 for (uint32_t i = 0; i < (nWifis - 1); ++i) | 105 HttpHelper httpHelper; |
106 | |
107 for (uint32_t i = 0; i < (nNodes - 1); ++i) | |
170 { | 108 { |
171 HttpServerHelper httpServer; | 109 HttpServerHelper httpServer; |
172 NS_LOG_DEBUG ("Install app in server"); | 110 NS_LOG_LOGIC ("Install app in server"); |
173 httpServer.SetAttribute ("Local", AddressValue (InetSocketAddress (Ipv4Add ress::GetAny (), port))); | 111 httpServer.SetAttribute ("Local", AddressValue (InetSocketAddress (Ipv4Add ress::GetAny (), port))); |
174 httpServer.SetAttribute ("MaxConnections", UintegerValue (maxConnections)) ; | 112 httpServer.SetAttribute ("HttpController", PointerValue (httpHelper.GetCon troller ())); |
175 httpServer.SetAttribute ("Protocol", TypeIdValue (TcpSocketFactory::GetTyp eId ())); | |
176 httpServer.SetAttribute ("RuntimeVariable", PointerValue (runtimeVariable) ); | |
177 | |
178 ApplicationContainer serverApps = httpServer.Install (nodes.Get (i)); | 113 ApplicationContainer serverApps = httpServer.Install (nodes.Get (i)); |
179 | 114 |
180 serverApps.Start (Seconds (0.0)); | 115 serverApps.Start (Seconds (0.0)); |
181 serverApps.Stop (Seconds (totalTime)); | 116 serverApps.Stop (Seconds (totalTime)); |
182 | 117 |
183 HttpClientHelper httpClient; | 118 HttpClientHelper httpClient; |
184 httpClient.SetAttribute ("Remote", AddressValue (InetSocketAddress (interf aces.GetAddress (i), port))); | 119 httpClient.SetAttribute ("Peer", AddressValue (InetSocketAddress (interfac es.GetAddress (i), port))); |
185 httpClient.SetAttribute ("RunNo", UintegerValue (runNo)); | 120 httpClient.SetAttribute ("HttpController", PointerValue (httpHelper.GetCon troller ())); |
186 httpClient.SetAttribute ("TransportId", TypeIdValue (transportId)); | 121 ApplicationContainer clientApps = httpClient.Install (nodes.Get (nNodes - 1)); |
187 httpClient.SetAttribute ("RuntimeVariable", PointerValue (runtimeVariable) ); | |
188 httpClient.SetAttribute ("RoutingProtocol", StringValue (routingProtocol)) ; | |
189 httpClient.SetAttribute ("TransportProtocol", StringValue (transportProtoc ol)); | |
190 httpClient.SetAttribute ("ThinkTime", UintegerValue (thinkTime)); | |
191 httpClient.SetAttribute ("TimeoutLimit", UintegerValue (timeoutLimit)); | |
192 httpClient.SetAttribute ("MaxSessions", UintegerValue (maxSessions)); | |
193 /* | |
194 * No need to define if using automatic traffic generation mode | |
195 */ | |
196 httpClient.SetAttribute ("Automatic", BooleanValue (automatic)); | |
197 httpClient.SetAttribute ("UserPages", UintegerValue (userPages)); | |
198 httpClient.SetAttribute ("UserObjects", UintegerValue (userObjects)); | |
199 httpClient.SetAttribute ("UserServerDelay", DoubleValue (userServerDelay)) ; | |
200 httpClient.SetAttribute ("UserRequestGap", DoubleValue (userRequestGap)); | |
201 httpClient.SetAttribute ("UserRequestSize", UintegerValue (userRequestSize )); | |
202 httpClient.SetAttribute ("UserResponseSize", UintegerValue (userResponseSi ze)); | |
203 // if you want all the Transport connections to be persistent, set this va lue as true | |
204 httpClient.SetAttribute ("ForcePersistent", BooleanValue (forcePersistent) ); | |
205 /* | |
206 * This controls the mode, when using http 1.1 and set the ForcePersistent as false, it will | |
207 * determine the connection type by itself | |
208 */ | |
209 httpClient.SetAttribute ("Http1_1", BooleanValue (http1_1)); | |
210 ApplicationContainer clientApps = httpClient.Install (nodes.Get (nWifis - 1)); | |
211 | 122 |
212 UniformVariable var; | 123 UniformVariable var; |
213 clientApps.Start (Seconds (dataStart + (count * randomStartTime))); | 124 clientApps.Start (Seconds (dataStart + (count * randomStartTime))); |
214 clientApps.Stop (Seconds (totalTime)); | 125 clientApps.Stop (Seconds (totalTime)); |
215 } | 126 } |
216 | 127 |
217 NS_LOG_INFO ("Run Simulation."); | 128 NS_LOG_INFO ("Run Simulation."); |
218 Simulator::Stop (Seconds (totalTime)); | 129 Simulator::Stop (Seconds (totalTime)); |
219 Simulator::Run (); | 130 Simulator::Run (); |
220 Simulator::Destroy (); | 131 Simulator::Destroy (); |
221 } | 132 } |
LEFT | RIGHT |