But I am getting some Error named Segmentation fault . I am not getting why this error is occurring.
MY code is : (Sorry i was unable to attach the file so pasting the code in this space but, will keep in mind from next time )
#include <fstream>
#include "ns3/core-module.h"
#include "ns3/core-module.h"
#include "ns3/csma-module.h"
#include "ns3/applications-module.h"
#include "ns3/internet-module.h"
#include "ns3/flow-monitor-module.h"
#include "ns3/internet-module.h"
#include "ns3/internet-apps-module.h"
#include "ns3/ipv6-static-routing-helper.h"
#include "ns3/mobility-module.h"
#include "ns3/spectrum-module.h"
#include "ns3/propagation-loss-model.h"
#include "ns3/log.h"
#include "ns3/ipv6-routing-table-entry.h"
#include "ns3/sixlowpan-module.h"
#include "ns3/lr-wpan-module.h"
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("UdpClientServerExample");
//void ThroughputMonitor (FlowMonitorHelper *fmhelper, Ptr<FlowMonitor> flowMon);
int
main (int argc, char *argv[])
{
//
// Enable logging for UdpClient and
//
// LogComponentEnable ("UdpClient", LOG_LEVEL_INFO);
LogComponentEnable ("UdpServer", LOG_LEVEL_INFO);
Address serverAddress;
NS_LOG_INFO ("Create nodes.");
NodeContainer nodes;
nodes.Create (2);
LrWpanHelper lrWpanHelper;
// Add and install the LrWpanNetDevice for each node
NetDeviceContainer lrwpanDevices = lrWpanHelper.Install(nodes);
// Fake PAN association and short address assignment.
lrWpanHelper.AssociateToPan (lrwpanDevices, 0);
InternetStackHelper internetv6;
internetv6.Install (nodes);
SixLowPanHelper sixlowpan;
NetDeviceContainer devices = sixlowpan.Install (lrwpanDevices);
NS_LOG_INFO ("Create channels.");
//
//
Ipv6AddressHelper ipv6;
ipv6.SetBase (Ipv6Address ("2001:2::"), Ipv6Prefix (64));
Ipv6InterfaceContainer i6 = ipv6.Assign (devices);
serverAddress = Address(i6.GetAddress (1,1));
NS_LOG_INFO ("Create Applications.");
//
// Create one udpServer applications on node one.
//
uint16_t port = 9;
UdpServerHelper server (port);
ApplicationContainer apps = server.Install (nodes.Get (1));
apps.Start (Seconds (1.0));
apps.Stop (Seconds (20.0));
//
// Create one UdpClient application to send UDP datagrams from node zero to
// node one.
//
uint32_t MaxPacketSize = 104;
Time interPacketInterval = Seconds (0.05);
uint32_t maxPacketCount = 320;
UdpClientHelper client (serverAddress, port);
client.SetAttribute ("MaxPackets", UintegerValue (maxPacketCount));
client.SetAttribute ("Interval", TimeValue (interPacketInterval));
client.SetAttribute ("PacketSize", UintegerValue (MaxPacketSize));
apps = client.Install (nodes.Get (0));
apps.Start (Seconds (2.0));
apps.Stop (Seconds (20.0));
///
// FlowMonitor
///
FlowMonitorHelper fmHelper;
Ptr<FlowMonitor> allMon = fmHelper.InstallAll();
//Simulator::Schedule(Seconds(3),&ThroughputMonitor,&fmHelper, allMon);
// Now, do the actual simulation.
//
NS_LOG_INFO ("Run Simulation.");
Simulator::Stop(Seconds(20));
Simulator::Run ();
allMon->CheckForLostPackets ();
Ptr<Ipv6FlowClassifier> classing = DynamicCast<Ipv6FlowClassifier> (fmHelper.GetClassifier());
std::map<FlowId, FlowMonitor::FlowStats> flowStats = allMon->GetFlowStats();
for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator stats = flowStats.begin (); stats != flowStats.end (); ++stats)
{
Ipv6FlowClassifier::FiveTuple fiveTuple = classing->FindFlow (stats->first);
std::cout<<"Flow ID : " << stats->first <<" ; "<< fiveTuple.sourceAddress <<" -----> "<<fiveTuple.destinationAddress<<std::endl;
// std::cout<<"Tx Packets = " << stats->second.txPackets<<std::endl;
// std::cout<<"Rx Packets = " << stats->second.rxPackets<<std::endl;
std::cout<<"Duration : "<<stats->second.timeLastRxPacket.GetSeconds()-stats->second.timeFirstTxPacket.GetSeconds()<<std::endl;
std::cout<<"Last Received Packet : "<< stats->second.timeLastRxPacket.GetSeconds()<<" Seconds"<<std::endl;
std::cout<<"Throughput: " << stats->second.rxBytes * 8.0 / (stats->second.timeLastRxPacket.GetSeconds()-stats->second.timeFirstTxPacket.GetSeconds())/1024/1024 << " Mbps"<<std::endl;
std::cout<<"---------------------------------------------------------------------------"<<std::endl;
}
Simulator::Destroy ();
NS_LOG_INFO ("Done.");
}