Hi, thank you very much sir, the error is solved. But when installing an application I am getting 100% packet loss with below code.
/* Create network nodes */
ns3::NodeContainer n1;
ns3::NodeContainer n2;
ns3::NodeContainer m;
m.Create(4);
n1.Add(m.Get(0));
n1.Add(m.Get(1));
n2.Add(m.Get(2));
n2.Add(m.Get(3));
/* Configure the wireless channel characteristics */
ns3::YansWifiChannelHelper wifiChannel;
ns3::YansWifiChannelHelper c_wifiChannel;
wifiChannel.AddPropagationLoss("ns3::RangePropagationLossModel");
ns3::Config::SetDefault ("ns3::RangePropagationLossModel::MaxRange", ns3::DoubleValue(range));
wifiChannel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
ns3::Config::SetDefault ("ns3::LogDistancePropagationLossModel::Exponent", ns3::DoubleValue(1.85));
ns3::Config::SetDefault ("ns3::LogDistancePropagationLossModel::ReferenceLoss", ns3::DoubleValue(59.7));
c_wifiChannel.AddPropagationLoss("ns3::LogDistancePropagationLossModel");
c_wifiChannel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
ns3::YansWifiPhyHelper wifiPhy = ns3::YansWifiPhyHelper::Default();
ns3::YansWifiPhyHelper c_wifiPhy = ns3::YansWifiPhyHelper::Default();
wifiPhy.SetChannel(wifiChannel.Create());
c_wifiPhy.SetChannel(c_wifiChannel.Create());
/* Install wifiPhy and link it with STDMA medium access control layer implementation */
NetDeviceContainer devices1;
NetDeviceContainer devices2;
devices1 = stdma.Install(wifiPhy, stdmaMac, n1);
devices2 = stdma.Install(c_wifiPhy, stdmaMac, n2);
/* Define positions of the two nodes */
ns3::MobilityHelper mobility;
mobility.InstallAll();
AnimationInterface anim("multi.xml");
anim.EnablePacketMetadata(true);
anim.EnableIpv4RouteTracking("routing-table.txt",Seconds(0.0),Seconds(100.0),Seconds(5.0));
AodvHelper aodv;
/* Install internet stack on all nodes */
InternetStackHelper internet;
internet.SetRoutingHelper (aodv);
internet.Install (m);
/* Assign ip address to each node */
Ipv4AddressHelper ipv4;
ipv4.SetBase ("10.1.1.0", "255.255.255.0");
Ipv4InterfaceContainer I1 = ipv4.Assign (devices1);
Ipv4InterfaceContainer I2 = ipv4.Assign (devices2);
ns3::Config::SetDefault("ns3::Ipv4GlobalRouting::RespondToInterfaceEvents", BooleanValue (true));
InetSocketAddress local = InetSocketAddress (Ipv4Address::GetAny (),80);
/* Install the applications. */
uint32_t packetSize = 400; /* bytes */
uint32_t numPackets = 1500;
double interval = 0.1;
uint16_t port = 45000;
UdpServerHelper server (port);
Time interPacketInterval = Seconds (interval);
uint16_t serverNode = 1;
uint16_t clientNode = 0;
int itr=0;
for( itr=0; itr<1; itr++)
{
ApplicationContainer apps = server.Install (n1.Get(serverNode));
std::cout<<"server: "<<n1.Get(serverNode)<<"\n";
apps.Start (Seconds (0+itr));
apps.Stop (Seconds (150+itr));
UdpClientHelper client(I1.GetAddress (serverNode), port+itr*10);
client.SetAttribute ("MaxPackets", UintegerValue (numPackets));
client.SetAttribute ("Interval", TimeValue (interPacketInterval));
client.SetAttribute ("PacketSize", UintegerValue (packetSize));
apps = client.Install (n1.Get(clientNode));
std::cout<<"client: "<<n1.Get(clientNode)<<"\n";
apps.Start (Seconds (1+10*itr));
apps.Stop (Seconds (140+itr));
}
numPackets = 5000;
port = 46000;
UdpServerHelper server2 (port);
uint16_t servern = 0;
uint16_t client = 1;
for( itr=0; itr<1; itr++)
{
ApplicationContainer apps2 = server2.Install (n2.Get(servern));
apps2.Start (Seconds (0+itr));
apps2.Stop (Seconds (200+itr));
UdpClientHelper client2 (I2.GetAddress (servern), port+itr*10);
client2.SetAttribute ("MaxPackets", UintegerValue (numPackets));
client2.SetAttribute ("Interval", TimeValue (interPacketInterval));
client2.SetAttribute ("PacketSize", UintegerValue (packetSize));
apps2 = client2.Install (n2.Get(client));
apps2.Start (Seconds (1+10*itr));
apps2.Stop (Seconds (200+itr));
}
The first application is 0% loss but second application is resulting into 100% loss.