Hello,
I try to create *.png file from my simulation with using Gnuplot, but after finish simulation only *.plt file is created.
Here is a part of code:
//GnuPlot
string fileNameWithNoExtension = "FlowVSThroughput";
string graphicsFileName = fileNameWithNoExtension + ".png";
string plotFileName = fileNameWithNoExtension + ".plt";
string plotTitle = "Flow vs Throughput";
string dataTitle = "Throughput";
// Instantiate the plot and set its title.
Gnuplot gnuplot (graphicsFileName);
gnuplot.SetTitle (plotTitle);
// Make the graphics file, which the plot file will be when it
// is used with Gnuplot, be a PNG file.
gnuplot.SetTerminal ("png");
// Set the labels for each axis.
gnuplot.SetLegend ("Flow", "Throughput");
Gnuplot2dDataset dataset;
dataset.SetTitle (dataTitle);
dataset.SetStyle (Gnuplot2dDataset::LINES_POINTS);
//Flow Monitor ... continued
if (enableFlowMonitor)
{
double Throughput=0.0;
monitor->CheckForLostPackets ();
Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowMonHelper.GetClassifier ());
std::map<FlowId, FlowMonitor::FlowStats> stats = monitor->GetFlowStats ();
for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator iter = stats.begin (); iter != stats.end (); ++iter)
{
Ipv4FlowClassifier::FiveTuple t = classifier->FindFlow (iter->first);
NS_LOG_UNCOND("Flow ID: " << iter->first << " Src Addr " << t.sourceAddress << " Dst Addr " << t.destinationAddress);
NS_LOG_UNCOND("Tx Packets = " << iter->second.txPackets);
NS_LOG_UNCOND("Rx Packets = " << iter->second.rxPackets);
NS_LOG_UNCOND("Delay Sum = " << iter->second.delaySum);
NS_LOG_UNCOND("Delay = " << iter->second.delaySum / iter->second.rxPackets << "ns");
NS_LOG_UNCOND("Delay = " << (iter->second.delaySum / iter->second.rxPackets)/1000000 << "ms");
NS_LOG_UNCOND("Jitter Sum = " << iter->second.jitterSum);
NS_LOG_UNCOND("Jitter = " << iter->second.jitterSum / (iter->second.rxPackets - 1) << "ns");
//NS_LOG_UNCOND("Jitter = " << (iter->second.jitterSum / (iter->second.rxPackets - 1))/1000000 << "ms");
NS_LOG_UNCOND("Throughput: " << iter->second.rxBytes * 8.0 / (iter->second.timeLastRxPacket.GetSeconds()-iter->second.timeFirstTxPacket.GetSeconds()) / 1024 << " Kbps");
Throughput=iter->second.rxBytes * 8.0 /
(iter->second.timeLastRxPacket.GetSeconds()-iter->second.timeFirstTxPacket.GetSeconds())
/ 1024;
dataset.Add((double)iter->first,(double) Throughput);
NS_LOG_UNCOND("Lost Packets = " << iter->second.lostPackets);
NS_LOG_UNCOND("-------------------------------------------------");
NS_LOG_UNCOND("-------------------------------------------------");
}
monitor->SerializeToXmlFile ("manetrouting.flowmon", true, true);
}
//Gnuplot ...continued
gnuplot.AddDataset (dataset);
// Open the plot file.
ofstream plotFile (plotFileName.c_str());
// Write the plot file.
gnuplot.GenerateOutput (plotFile);
// Close the plot file.
plotFile.close ();
Simulator::Destroy ();