#include "ns3/csma-module.h"
#include "ns3/netanim-module.h"
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/internet-module.h"
#include "ns3/point-to-point-module.h"
#include "ns3/applications-module.h"
#include "ns3/netanim-module.h"
#include "ns3/flow-monitor-module.h"
#include "ns3/aodv-module.h"
#include "ns3/internet-stack-helper.h"
#include "ns3/udp-socket-factory.h"
#include "ns3/socket.h"
#include "ns3/csma-module.h"
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("FirstLoggingExample");
int
main (int argc, char *argv[])
{
NodeContainer nodes;
nodes.Create (50);
CsmaHelper csma;
csma.SetChannelAttribute ("DataRate", StringValue ("5Mbps"));
csma.SetChannelAttribute ("Delay", TimeValue (NanoSeconds (6560)));
NetDeviceContainer devices;
devices = csma.Install (nodes);
InternetStackHelper stack;
AodvHelper aodv;
stack.SetRoutingHelper (aodv);
stack.Install (nodes);
Ptr<OutputStreamWrapper> routingStream = Create<OutputStreamWrapper> ("aodv.routes",
std::ios::out);
aodv.PrintRoutingTableAllAt (Seconds (125), routingStream);
Ipv4AddressHelper address;
address.SetBase ("192.168.1.0", "255.255.255.0");
Ipv4InterfaceContainer interfaces = address.Assign (devices);
uint64_t port = 9;
UdpEchoServerHelper echoServer (port);
ApplicationContainer serverApps = echoServer.Install (nodes.Get (3));
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));
UdpEchoClientHelper echoClient (interfaces.GetAddress (3), port);
echoClient.SetAttribute ("MaxPackets", UintegerValue (1000));
echoClient.SetAttribute ("Interval", TimeValue (Seconds (0.1)));
echoClient.SetAttribute ("PacketSize", UintegerValue (1024));
ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));
Ptr<FlowMonitor> flowmon;
FlowMonitorHelper flowmonHelper;
flowmon = flowmonHelper.InstallAll ();
AnimationInterface anim ("first_animation_demo.xml");
anim.UpdateNodeDescription (3, "UDP Echo Server");
anim.UpdateNodeDescription (0, "UDP Echo Client");
anim.EnablePacketMetadata ();
anim.EnableIpv4RouteTracking ("firstanim_routetable.xml", Seconds (0), Seconds (2),Seconds (0.25));
anim.EnableIpv4L3ProtocolCounters (Seconds (0), Seconds (10));
anim.EnableQueueCounters (Seconds (0), Seconds (10));
Simulator::Stop (Seconds(11.0));
Simulator::Run ();
flowmon->SerializeToXmlFile ("firstanim_flowmetrics.xml", true, true);
Simulator::Destroy ();
}