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) 2009 University of Washington | 3 * Copyright (c) 2009 University of Washington |
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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 Simulator::Stop (m_simTime + Seconds (0.6)); | 244 Simulator::Stop (m_simTime + Seconds (0.6)); |
245 Simulator::Run (); | 245 Simulator::Run (); |
246 Simulator::Destroy (); | 246 Simulator::Destroy (); |
247 | 247 |
248 return m_bytesTotal; | 248 return m_bytesTotal; |
249 } | 249 } |
250 int | 250 int |
251 main (int argc, char *argv[]) | 251 main (int argc, char *argv[]) |
252 { | 252 { |
253 | 253 |
254 #if 0 | |
255 LogComponentEnable ("UanRcExample", LOG_LEVEL_ALL); | |
256 #endif | |
257 | |
258 Experiment exp; | 254 Experiment exp; |
| 255 bool quiet = false; |
259 | 256 |
260 CommandLine cmd; | 257 CommandLine cmd; |
261 cmd.AddValue ("TotalRate", "Total channel capacity", exp.m_totalRate); | 258 cmd.AddValue ("TotalRate", "Total channel capacity", exp.m_totalRate); |
262 cmd.AddValue ("NumberRates", "Number of divided rates ( (NumberRates+1)%TotalR
ate should be 0)", exp.m_numRates); | 259 cmd.AddValue ("NumberRates", "Number of divided rates ( (NumberRates+1)%TotalR
ate should be 0)", exp.m_numRates); |
263 cmd.AddValue ("MaxRange", "Maximum range between gateway and acoustic node", e
xp.m_maxRange); | 260 cmd.AddValue ("MaxRange", "Maximum range between gateway and acoustic node", e
xp.m_maxRange); |
264 cmd.AddValue ("SimMin", "Minimum parameter to test (nodes if DoNode=1, \"a\" p
aram otherwise)", exp.m_simMin); | 261 cmd.AddValue ("SimMin", "Minimum parameter to test (nodes if DoNode=1, \"a\" p
aram otherwise)", exp.m_simMin); |
265 cmd.AddValue ("SimMax", "Maximum parameter to test (nodes if DoNode=1, \"a\" p
aram otherwise)", exp.m_simMax); | 262 cmd.AddValue ("SimMax", "Maximum parameter to test (nodes if DoNode=1, \"a\" p
aram otherwise)", exp.m_simMax); |
266 cmd.AddValue ("SimStep", "Amount to increment param per trial", exp.m_simStep)
; | 263 cmd.AddValue ("SimStep", "Amount to increment param per trial", exp.m_simStep)
; |
267 cmd.AddValue ("DataFile", "Filename for GnuPlot", exp.m_gnuplotfile); | 264 cmd.AddValue ("DataFile", "Filename for GnuPlot", exp.m_gnuplotfile); |
268 cmd.AddValue ("NumberNodes", "Number of nodes (invalid for doNode=1)", exp.m_n
umNodes); | 265 cmd.AddValue ("NumberNodes", "Number of nodes (invalid for doNode=1)", exp.m_n
umNodes); |
269 cmd.AddValue ("SIFS", "SIFS time duration", exp.m_sifs); | 266 cmd.AddValue ("SIFS", "SIFS time duration", exp.m_sifs); |
270 cmd.AddValue ("PktSize", "Packet size in bytes", exp.m_pktSize); | 267 cmd.AddValue ("PktSize", "Packet size in bytes", exp.m_pktSize); |
271 cmd.AddValue ("SimTime", "Simulation time per trial", exp.m_simTime); | 268 cmd.AddValue ("SimTime", "Simulation time per trial", exp.m_simTime); |
272 cmd.AddValue ("DoNode", "1 for do max nodes simulation (invalidates AMin and A
Max values)", exp.m_doNode); | 269 cmd.AddValue ("DoNode", "1 for do max nodes simulation (invalidates AMin and A
Max values)", exp.m_doNode); |
| 270 cmd.AddValue ("Quiet", "Run in quiet mode (disable logging)", quiet); |
273 cmd.Parse (argc, argv); | 271 cmd.Parse (argc, argv); |
274 | 272 |
275 | 273 if (!quiet) |
| 274 { |
| 275 LogComponentEnable("UanRcExample", LOG_LEVEL_ALL); |
| 276 } |
276 | 277 |
277 exp.CreateDualModes (12000); | 278 exp.CreateDualModes (12000); |
278 | 279 |
279 ; | 280 ; |
280 | 281 |
281 Gnuplot2dDataset ds; | 282 Gnuplot2dDataset ds; |
282 for (uint32_t param=exp.m_simMin; param<=exp.m_simMax; param += exp.m_simStep) | 283 for (uint32_t param=exp.m_simMin; param<=exp.m_simMax; param += exp.m_simStep) |
283 { | 284 { |
284 uint32_t bytesRx = exp.Run (param); | 285 uint32_t bytesRx = exp.Run (param); |
285 NS_LOG_DEBUG ("param=" << param << ": Received " << bytesRx << " bytes at
sink"); | 286 NS_LOG_DEBUG ("param=" << param << ": Received " << bytesRx << " bytes at
sink"); |
286 | 287 |
287 double util = bytesRx*8.0/(exp.m_simTime.GetSeconds ()*exp.m_totalRate); | 288 double util = bytesRx*8.0/(exp.m_simTime.GetSeconds ()*exp.m_totalRate); |
288 | 289 |
289 ds.Add (param, util); | 290 ds.Add (param, util); |
290 | 291 |
291 SeedManager::SetRun (SeedManager::GetRun () + 1); | 292 SeedManager::SetRun (SeedManager::GetRun () + 1); |
292 } | 293 } |
293 | 294 |
294 Gnuplot gp; | 295 Gnuplot gp; |
295 gp.AddDataset (ds); | 296 gp.AddDataset (ds); |
296 std::ofstream of (exp.m_gnuplotfile.c_str ()); | 297 std::ofstream of (exp.m_gnuplotfile.c_str ()); |
297 if (!of.is_open ()) | 298 if (!of.is_open ()) |
298 { | 299 { |
299 NS_FATAL_ERROR ("Can not open GNU Plot outfile: " << exp.m_gnuplotfile); | 300 NS_FATAL_ERROR ("Can not open GNU Plot outfile: " << exp.m_gnuplotfile); |
300 } | 301 } |
301 gp.GenerateOutput (of); | 302 gp.GenerateOutput (of); |
302 | 303 |
303 } | 304 } |
LEFT | RIGHT |