22 #include "ns3/core-module.h"
23 #include "ns3/gnuplot.h"
24 #include "ns3/satellite-module.h"
29 NS_LOG_COMPONENT_DEFINE(
"sat-markov-trace-example");
61 Gnuplot
GetGnuplot(std::string outputName, std::string title);
79 static TypeId tid = TypeId(
"ns3::SatMarkovFadingExamplePlot")
81 .AddConstructor<SatMarkovFadingExamplePlot>();
97 std::cout << time <<
" " << chType <<
" " << 10 * log10(fadingValue) << std::endl;
98 m_fadingValues.push_back(std::make_pair(time, 10 * log10(fadingValue)));
116 Gnuplot2dDataset ret;
118 ret.SetStyle(Gnuplot2dDataset::LINES);
130 Gnuplot ret(outputName +
".png");
132 ret.SetTerminal(
"png");
133 ret.SetLegend(
"Time (s)",
"Fading (dB)");
134 ret.AppendExtra(
"set key top right");
135 ret.AppendExtra(
"set grid xtics mxtics ytics");
143 Config::SetDefault(
"ns3::SatEnvVariables::SimulationCampaignName",
144 StringValue(
"example-markov-fading-trace"));
145 Config::SetDefault(
"ns3::SatEnvVariables::SimulationTag", StringValue(
""));
146 Config::SetDefault(
"ns3::SatEnvVariables::EnableSimulationOutputOverwrite", BooleanValue(
true));
149 Ptr<SatMarkovConf> markovConf = CreateObject<SatMarkovConf>();
157 Ptr<SatMarkovContainer> markovContainer =
158 CreateObject<SatMarkovContainer>(markovConf, elevationCb, velocityCb);
160 markovContainer->TraceConnect(
"FadingTrace",
161 "The trace for fading values",
167 for (uint32_t i = 0; i < 100000; i++)
169 Simulator::Schedule(MilliSeconds(1 * i),
176 Simulator::Schedule(MilliSeconds(0),
181 Simulator::Schedule(MilliSeconds(20000),
186 Simulator::Schedule(MilliSeconds(40000),
191 Simulator::Schedule(MilliSeconds(60000),
196 Simulator::Schedule(MilliSeconds(80000),
205 Gnuplot plot =
GetGnuplot(
"markov_fading_trace",
"Markov Fading Trace");
206 plot.AddDataset(dataset);
208 std::string plotFileName =
"markov_fading_trace.plt";
209 std::ofstream plotFile(plotFileName.c_str());
210 plot.GenerateOutput(plotFile);
213 std::cout <<
"Output file written: " << plotFileName << std::endl;
215 int result = system(
"gnuplot markov_fading_trace.plt");
220 <<
"Unable to open shell process for Gnuplot file conversion, conversion not done!"
225 std::cout <<
"Output file converted to: markov_fading_trace.png" << std::endl;
228 Simulator::Destroy();
234 main(
int argc,
char* argv[])
236 ns3::Ptr<ns3::SatMarkovFadingExamplePlot> stub;
237 stub = ns3::CreateObject<ns3::SatMarkovFadingExamplePlot>();
238 ns3::Config::RegisterRootNamespaceObject(stub);
Callback< double > VelocityCallback
Gets velocity in m/s.
Callback< double > ElevationCallback
Gets elevation angle in degrees.
ChannelType_t
Types of channel.
double DoGetFading(Address macAddress, SatEnums::ChannelType_t channeltype)
Function for getting the fading.
void LockToSetAndState(uint32_t newSet, uint32_t newState)
Function for locking the parameter set and state.
void FadingTraceCb(std::string context, double time, SatEnums::ChannelType_t chType, double fadingValue)
static TypeId GetTypeId()
Gnuplot GetGnuplot(std::string outputName, std::string title)
SatMarkovFadingExamplePlot()
Gnuplot2dDataset GetGnuplotDataset(std::string title)
std::vector< std::pair< double, double > > m_fadingValues
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.