21 #include "ns3/propagation-loss-model.h"
22 #include "ns3/jakes-propagation-loss-model.h"
23 #include "ns3/constant-position-mobility-model.h"
25 #include "ns3/config.h"
26 #include "ns3/string.h"
27 #include "ns3/boolean.h"
28 #include "ns3/double.h"
29 #include "ns3/pointer.h"
30 #include "ns3/gnuplot.h"
31 #include "ns3/simulator.h"
39 static double dround (
double number,
double precision)
44 number = floor (number + 0.5);
48 number = ceil (number - 0.5);
63 plot.AppendExtra (
"set ylabel 'rxPower (dBm)'");
64 plot.AppendExtra (
"set key top right");
66 double txPowerDbm = +20;
70 dataset.
SetStyle (Gnuplot2dDataset::LINES);
75 for (
double distance = 0.0; distance < 2500.0; distance += 10.0)
77 b->SetPosition (
Vector (distance, 0.0, 0.0));
80 double rxPowerDbm = model->
CalcRxPower (txPowerDbm, a, b);
82 dataset.
Add (distance, rxPowerDbm);
89 std::ostringstream os;
90 os <<
"txPower " << txPowerDbm <<
"dBm";
93 plot.AddDataset (dataset);
109 plot.AppendExtra (
"set ylabel 'rxPower (dBm)'");
110 plot.AppendExtra (
"set zlabel 'Probability' offset 0,+10");
111 plot.AppendExtra (
"set view 50, 120, 1.0, 1.0");
112 plot.AppendExtra (
"set key top right");
114 plot.AppendExtra (
"set ticslevel 0");
115 plot.AppendExtra (
"set xtics offset -0.5,0");
116 plot.AppendExtra (
"set ytics offset 0,-0.5");
117 plot.AppendExtra (
"set xrange [100:]");
119 double txPowerDbm = +20;
123 dataset.
SetStyle (
"with linespoints");
124 dataset.
SetExtra (
"pointtype 3 pointsize 0.5");
126 typedef std::map<double, unsigned int> rxPowerMapType;
133 for (
double distance = 100.0; distance < 2500.0; distance += 100.0)
135 b->SetPosition (
Vector (distance, 0.0, 0.0));
137 rxPowerMapType rxPowerMap;
139 for (
unsigned int samp = 0; samp < samples; ++samp)
142 double rxPowerDbm = model->
CalcRxPower (txPowerDbm, a, b);
143 rxPowerDbm = dround (rxPowerDbm, 1.0);
145 rxPowerMap[ rxPowerDbm ]++;
151 for (rxPowerMapType::const_iterator i = rxPowerMap.begin ();
152 i != rxPowerMap.end (); ++i)
154 dataset.
Add (distance, i->first, (
double)i->second / (
double)samples);
160 std::ostringstream os;
161 os <<
"txPower " << txPowerDbm <<
"dBm";
164 plot.AddDataset (dataset);
173 double distance = 100.0)
181 plot.AppendExtra (
"set ylabel 'rxPower (dBm)'");
182 plot.AppendExtra (
"set key center right");
184 double txPowerDbm = +20;
188 dataset.
SetStyle (Gnuplot2dDataset::LINES);
192 b->SetPosition (
Vector (distance, 0.0, 0.0));
198 double rxPowerDbm = model->
CalcRxPower (txPowerDbm, a, b);
208 std::ostringstream os;
209 os <<
"txPower " << txPowerDbm <<
"dBm";
212 plot.AddDataset (dataset);
219 int main (
int argc,
char *argv[])
226 Gnuplot plot = TestDeterministic (friis);
227 plot.SetTitle (
"ns3::FriisPropagationLossModel (Default Parameters)");
228 gnuplots.AddPlot (plot);
235 Gnuplot plot = TestDeterministic (log);
236 plot.
SetTitle (
"ns3::LogDistancePropagationLossModel (Exponent = 2.5)");
237 gnuplots.AddPlot (plot);
245 Gnuplot plot = TestDeterministic (random);
246 plot.
SetTitle (
"ns3::RandomPropagationLossModel with Exponential Distribution");
247 gnuplots.AddPlot (plot);
257 plot.
SetTitle (
"ns3::JakesPropagationLossModel (with 477.9 Hz shift and 1 millisec resolution)");
258 gnuplots.AddPlot (plot);
268 plot.
SetTitle (
"ns3::JakesPropagationLossModel (with 477.9 Hz shift and 0.1 millisec resolution)");
269 gnuplots.AddPlot (plot);
275 Gnuplot plot = TestDeterministic (log3);
276 plot.SetTitle (
"ns3::ThreeLogDistancePropagationLossModel (Defaults)");
277 gnuplots.AddPlot (plot);
287 Gnuplot plot = TestDeterministic (log3);
288 plot.
SetTitle (
"ns3::ThreeLogDistancePropagationLossModel (Exponents 1.0, 3.0 and 10.0)");
289 gnuplots.AddPlot (plot);
295 Gnuplot plot = TestProbabilistic (nak);
296 plot.SetTitle (
"ns3::NakagamiPropagationLossModel (Default Parameters)");
297 gnuplots.AddPlot (plot);
306 Gnuplot plot = TestProbabilistic (log3);
307 plot.
SetTitle (
"ns3::ThreeLogDistancePropagationLossModel and ns3::NakagamiPropagationLossModel (Default Parameters)");
308 gnuplots.AddPlot (plot);
311 gnuplots.GenerateOutput (std::cout);
void AppendExtra(const std::string &extra)
Class to represent a 3D points plot. Set the line or points style using SetStyle() and set points usi...
Class to represent a 2D points plot. Set the line or points style using SetStyle() and set points usi...
void SetNext(Ptr< PropagationLossModel > next)
Enables a chain of loss models to act on the signal.
void SetTitle(const std::string &title)
Change line title.
void Add(double x, double y, double z)
void SetExtra(const std::string &extra)
Add extra formatting parameters to this dataset.
double GetSeconds(void) const
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
a simple class to group together multiple gnuplots into one file, e.g. for PDF multi-page output term...
void SetTitle(const std::string &title)
void Add(double x, double y)
double CalcRxPower(double txPowerDbm, Ptr< MobilityModel > a, Ptr< MobilityModel > b) const
static void Destroy(void)
void SetDefault(std::string name, const AttributeValue &value)
hold objects of type Ptr<T>
void SetStyle(enum Style style)
void SetPosition(const Vector &position)
void SetStyle(const std::string &style)
Time Seconds(double seconds)
create ns3::Time instances in units of seconds.
Class to represent a 2D function expression plot.
Hold an floating point type.
void SetAttribute(std::string name, const AttributeValue &value)