Thanks for your reply. But it was the same error I got also before changing the dsr source code for a trial. Please I am pasting my code here may be you can tell me what is wrong with it. Thanks in advance.
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2009 University of Washington
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/mobility-module.h"
#include "ns3/config-store-module.h"
#include "ns3/wifi-module.h"
#include "ns3/internet-module.h"
#include "ns3/dsr-helper.h"
#include "ns3/dsr-main-helper.h"
#include "ns3/dsr-module.h"
#include "ns3/flow-monitor-module.h"
#include "myapp.h"
#include "ns3/applications-module.h"
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
NS_LOG_COMPONENT_DEFINE ("wifi7ds");
using namespace ns3;
using namespace dsr;
uint32_t MacTxDropCount, PhyTxDropCount, PhyRxDropCount;
void
MacTxDrop(Ptr<const Packet> p)
{
NS_LOG_INFO("Packet Drop");
MacTxDropCount++;
}
void
PrintDrop()
{
std::cout << Simulator::Now().GetSeconds() << "\t" << MacTxDropCount << "\t"<< PhyTxDropCount << "\t" << PhyRxDropCount << "\n";
Simulator::Schedule(Seconds(5.0), &PrintDrop);
}
void
PhyTxDrop(Ptr<const Packet> p)
{
NS_LOG_INFO("Packet Drop");
PhyTxDropCount++;
}
void
PhyRxDrop(Ptr<const Packet> p)
{
NS_LOG_INFO("Packet Drop");
PhyRxDropCount++;
}
int main (int argc, char *argv[])
{
std::string phyMode ("DsssRate1Mbps");
double distance = 500; // m
uint32_t nWifis = 110; // 11x10
//double interval = 0.001; // seconds
uint32_t packetSize = 600; // bytes
uint32_t numPackets = 10000000;
std::string rtslimit = "1500";
bool tracing = false;
CommandLine cmd;
cmd.AddValue ("phyMode", "Wifi Phy mode", phyMode);
cmd.AddValue ("distance", "distance (m)", distance);
cmd.AddValue ("packetSize", "distance (m)", packetSize);
cmd.AddValue ("rtslimit", "RTS/CTS Threshold (bytes)", rtslimit);
cmd.AddValue ("tracing", "turn on ascii and pcap tracing", tracing);
cmd.Parse (argc, argv);
// Convert to time object
//Time interPacketInterval = Seconds (interval);
// turn off RTS/CTS for frames below 2200 bytes
Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue (rtslimit));
// Fix non-unicast data rate to be the same as that of unicast
Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue (phyMode));
NodeContainer adhocNodes;
adhocNodes.Create (nWifis);
// The below set of helpers will help us to put together the wifi NICs we want
WifiHelper wifi;
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
// set it to zero; otherwise, gain will be added
wifiPhy.Set ("RxGain", DoubleValue (-10) );
// ns-3 supports RadioTap and Prism tracing extensions for 802.11b
wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
YansWifiChannelHelper wifiChannel;
wifiChannel.SetPropagationDelay ("ns3::ConstantSpeedPropagationDelayModel");
wifiChannel.AddPropagationLoss ("ns3::FriisPropagationLossModel");
wifiPhy.SetChannel (wifiChannel.Create ());
// Add a non-QoS upper mac, and disable rate control
NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode",StringValue (phyMode),
"ControlMode",StringValue (phyMode));
// Set it to adhoc mode
wifiMac.SetType ("ns3::AdhocWifiMac");
NetDeviceContainer adhocDevices = wifi.Install (wifiPhy, wifiMac, adhocNodes);
MobilityHelper mobility;
mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
"MinX", DoubleValue (0.0),
"MinY", DoubleValue (0.0),
"DeltaX", DoubleValue (distance),
"DeltaY", DoubleValue (distance),
"GridWidth", UintegerValue (10),
"LayoutType", StringValue ("RowFirst"));
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (adhocNodes);
// Enable DSR
DsrHelper dsr;
DsrMainHelper dsrMain;
dsrMain.Install (dsr, adhocNodes);
Ipv4ListRoutingHelper list;
InternetStackHelper internet;
internet.SetRoutingHelper (list); // has effect on the next Install ()
internet.Install (adhocNodes);
Ipv4AddressHelper addressAdhoc;
Ipv4AddressHelper ipv4;
NS_LOG_INFO ("Assign IP Addresses.");
ipv4.SetBase ("10.0.0.0", "255.0.0.0");
Ipv4InterfaceContainer ifcont = ipv4.Assign (adhocDevices);
// Create Apps
uint16_t sinkPort = 6; // use the same for all apps
/////////////////////////////////////////////////////////////////////////////////
// TCP connection from N0 to N24
Address sinkAddress1 (InetSocketAddress (ifcont.GetAddress (24), sinkPort)); // interface of n24
PacketSinkHelper packetSinkHelper1 ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), sinkPort));
ApplicationContainer sinkApps1 = packetSinkHelper1.Install (adhocNodes.Get (24)); //n2 as sink
sinkApps1.Start (Seconds (0.));
sinkApps1.Stop (Seconds (100.));
Ptr<Socket> ns3TcpSocket1 = Socket::CreateSocket (adhocNodes.Get (0), TcpSocketFactory::GetTypeId ()); //source at n0
// Create TCP application at n0
Ptr<MyApp> app1 = CreateObject<MyApp> ();
app1->Setup (ns3TcpSocket1, sinkAddress1, packetSize, numPackets, DataRate ("1Mbps"));
adhocNodes.Get (0)->AddApplication (app1);
app1->SetStartTime (Seconds (10));
app1->SetStopTime (Seconds (100.));
/////
// TCP connection from N1 to N24
Address sinkAddress2 (InetSocketAddress (ifcont.GetAddress (24), sinkPort)); // interface of n24
PacketSinkHelper packetSinkHelper2 ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), sinkPort));
ApplicationContainer sinkApps2 = packetSinkHelper2.Install (adhocNodes.Get (24)); //n24 as sink
sinkApps2.Start (Seconds (0.));
sinkApps2.Stop (Seconds (100.));
Ptr<Socket> ns3TcpSocket2 = Socket::CreateSocket (adhocNodes.Get (1), TcpSocketFactory::GetTypeId ()); //source at n1
// Create TCP application at n1
Ptr<MyApp> app2 = CreateObject<MyApp> ();
app2->Setup (ns3TcpSocket2, sinkAddress2, packetSize, numPackets, DataRate ("1Mbps"));
adhocNodes.Get (1)->AddApplication (app2);
app2->SetStartTime (Seconds (10));
app2->SetStopTime (Seconds (100.));
/////
/////////////////////////////////////////////////////////////////////////////////////////////////////
// TCP connection from N25 to N49
Address sinkAddress25 (InetSocketAddress (ifcont.GetAddress (49), sinkPort)); // interface of n49
PacketSinkHelper packetSinkHelper25 ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), sinkPort));
ApplicationContainer sinkApps25 = packetSinkHelper25.Install (adhocNodes.Get (49)); //n49 as sink
sinkApps25.Start (Seconds (0.));
sinkApps25.Stop (Seconds (100.));
Ptr<Socket> ns3TcpSocket25 = Socket::CreateSocket (adhocNodes.Get (25), TcpSocketFactory::GetTypeId ()); //source at n25
// Create TCP application at n25
Ptr<MyApp> app25 = CreateObject<MyApp> ();
app25->Setup (ns3TcpSocket25, sinkAddress25, packetSize, numPackets, DataRate ("1Mbps"));
adhocNodes.Get (25)->AddApplication (app25);
app25->SetStartTime (Seconds (11));
app25->SetStopTime (Seconds (100.));
/////
// TCP connection from N26 to N49
Address sinkAddress26 (InetSocketAddress (ifcont.GetAddress (49), sinkPort)); // interface of n49
PacketSinkHelper packetSinkHelper26 ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), sinkPort));
ApplicationContainer sinkApps26 = packetSinkHelper26.Install (adhocNodes.Get (49)); //n49 as sink
sinkApps26.Start (Seconds (0.));
sinkApps26.Stop (Seconds (100.));
Ptr<Socket> ns3TcpSocket26 = Socket::CreateSocket (adhocNodes.Get (26), TcpSocketFactory::GetTypeId ()); //source at n26
// Create TCP application at n26
Ptr<MyApp> app26 = CreateObject<MyApp> ();
app26->Setup (ns3TcpSocket26, sinkAddress26, packetSize, numPackets, DataRate ("1Mbps"));
adhocNodes.Get (26)->AddApplication (app26);
app26->SetStartTime (Seconds (11));
app26->SetStopTime (Seconds (100.));
/////
/////////////////////////////////////////////////////////////////////////////////
// TCP connection from N50 to N74
Address sinkAddress51 (InetSocketAddress (ifcont.GetAddress (74), sinkPort)); // interface of n74
PacketSinkHelper packetSinkHelper51 ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), sinkPort));
ApplicationContainer sinkApps51 = packetSinkHelper51.Install (adhocNodes.Get (74)); //n2 as sink
sinkApps51.Start (Seconds (0.));
sinkApps51.Stop (Seconds (100.));
Ptr<Socket> ns3TcpSocket51 = Socket::CreateSocket (adhocNodes.Get (50), TcpSocketFactory::GetTypeId ()); //source at n0
// Create TCP application at n0
Ptr<MyApp> app51 = CreateObject<MyApp> ();
app51->Setup (ns3TcpSocket51, sinkAddress51, packetSize, numPackets, DataRate ("1Mbps"));
adhocNodes.Get (50)->AddApplication (app51);
app51->SetStartTime (Seconds (12.));
app51->SetStopTime (Seconds (100.));
/////
// TCP connection from N51 to N74
Address sinkAddress52 (InetSocketAddress (ifcont.GetAddress (74), sinkPort)); // interface of n74
PacketSinkHelper packetSinkHelper52 ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), sinkPort));
ApplicationContainer sinkApps52 = packetSinkHelper52.Install (adhocNodes.Get (74)); //n74 as sink
sinkApps52.Start (Seconds (0.));
sinkApps52.Stop (Seconds (100.));
Ptr<Socket> ns3TcpSocket52 = Socket::CreateSocket (adhocNodes.Get (51), TcpSocketFactory::GetTypeId ()); //source at n1
// Create TCP application at n51
Ptr<MyApp> app52 = CreateObject<MyApp> ();
app52->Setup (ns3TcpSocket52, sinkAddress52, packetSize, numPackets, DataRate ("1Mbps"));
adhocNodes.Get (51)->AddApplication (app52);
app52->SetStartTime (Seconds (12.));
app52->SetStopTime (Seconds (100.));
/////
/////////////////////////////////////////////////////////////////////////////////
// TCP connection from N75 to N99
Address sinkAddress76 (InetSocketAddress (ifcont.GetAddress (98), sinkPort)); // interface of n99
PacketSinkHelper packetSinkHelper76 ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), sinkPort));
ApplicationContainer sinkApps76 = packetSinkHelper76.Install (adhocNodes.Get (98)); //n2 as sink
sinkApps76.Start (Seconds (0.));
sinkApps76.Stop (Seconds (100.));
Ptr<Socket> ns3TcpSocket76 = Socket::CreateSocket (adhocNodes.Get (75), TcpSocketFactory::GetTypeId ()); //source at n0
// Create TCP application at n0
Ptr<MyApp> app76 = CreateObject<MyApp> ();
app76->Setup (ns3TcpSocket76, sinkAddress76, packetSize, numPackets, DataRate ("1Mbps"));
adhocNodes.Get (75)->AddApplication (app76);
app76->SetStartTime (Seconds (13));
app76->SetStopTime (Seconds (100.));
/////
// TCP connection from N76 to N99
Address sinkAddress77 (InetSocketAddress (ifcont.GetAddress (98), sinkPort)); // interface of n99
PacketSinkHelper packetSinkHelper77 ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), sinkPort));
ApplicationContainer sinkApps77 = packetSinkHelper77.Install (adhocNodes.Get (98)); //n99 as sink
sinkApps77.Start (Seconds (0.));
sinkApps77.Stop (Seconds (100.));
Ptr<Socket> ns3TcpSocket77 = Socket::CreateSocket (adhocNodes.Get (76), TcpSocketFactory::GetTypeId ()); //source at n76
// Create TCP application at n76
Ptr<MyApp> app77 = CreateObject<MyApp> ();
app77->Setup (ns3TcpSocket77, sinkAddress77, packetSize, numPackets, DataRate ("1Mbps"));
adhocNodes.Get (76)->AddApplication (app77);
app77->SetStartTime (Seconds (13));
app77->SetStopTime (Seconds (100.));
/////
///////
// TCP connection from N24 to N100
Address sinkAddress49 (InetSocketAddress (ifcont.GetAddress (99), sinkPort)); // interface of n100
PacketSinkHelper packetSinkHelper49 ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), sinkPort));
ApplicationContainer sinkApps49 = packetSinkHelper49.Install (adhocNodes.Get (99)); //n100 as sink
sinkApps49.Start (Seconds (0.));
sinkApps49.Stop (Seconds (100.));
Ptr<Socket> ns3TcpSocket49 = Socket::CreateSocket (adhocNodes.Get (24), TcpSocketFactory::GetTypeId ()); //source at n24
// Create TCP application at n24
Ptr<MyApp> app49 = CreateObject<MyApp> ();
app49->Setup (ns3TcpSocket49, sinkAddress49, packetSize, numPackets, DataRate ("1Mbps"));
adhocNodes.Get (24)->AddApplication (app49);
app49->SetStartTime (Seconds (14.));
app49->SetStopTime (Seconds (100.));
//////
// TCP connection from N49 to N100
Address sinkAddress50 (InetSocketAddress (ifcont.GetAddress (99), sinkPort)); // interface of n100
PacketSinkHelper packetSinkHelper50 ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), sinkPort));
ApplicationContainer sinkApps50 = packetSinkHelper50.Install (adhocNodes.Get (99)); //n100 as sink
sinkApps50.Start (Seconds (0.));
sinkApps50.Stop (Seconds (100.));
Ptr<Socket> ns3TcpSocket50 = Socket::CreateSocket (adhocNodes.Get (49), TcpSocketFactory::GetTypeId ()); //source at n49
// Create TCP application at n49
Ptr<MyApp> app50 = CreateObject<MyApp> ();
app50->Setup (ns3TcpSocket50, sinkAddress50, packetSize, numPackets, DataRate ("1Mbps"));
adhocNodes.Get (49)->AddApplication (app50);
app50->SetStartTime (Seconds (15.));
app50->SetStopTime (Seconds (100.));
//////
// TCP connection from N74 to N100
Address sinkAddress75 (InetSocketAddress (ifcont.GetAddress (99), sinkPort)); // interface of n100
PacketSinkHelper packetSinkHelper75 ("ns3::TcpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), sinkPort));
ApplicationContainer sinkApps75 = packetSinkHelper75.Install (adhocNodes.Get (99)); //n100 as sink
sinkApps75.Start (Seconds (0.));
sinkApps75.Stop (Seconds (100.));
Ptr<Socket> ns3TcpSocket75 = Socket::CreateSocket (adhocNodes.Get (74), TcpSocketFactory::GetTypeId ()); //source at n74
// Create TCP application at n74
Ptr<MyApp> app75 = CreateObject<MyApp> ();
app75->Setup (ns3TcpSocket75, sinkAddress75, packetSize, numPackets, DataRate ("1Mbps"));
adhocNodes.Get (74)->AddApplication (app75);
app75->SetStartTime (Seconds (16.));
app75->SetStopTime (Seconds (100.));
///////
// Install FlowMonitor on all nodes
FlowMonitorHelper flowmon;
Ptr<FlowMonitor> monitor = flowmon.InstallAll();
if (tracing == true)
{
AsciiTraceHelper ascii;
wifiPhy.EnableAsciiAll (ascii.CreateFileStream ("
wifi7ds.tr"));
wifiPhy.EnablePcap ("wifi7ds", adhocDevices);
// Trace routing tables
Ptr<OutputStreamWrapper> routingStream = Create<OutputStreamWrapper> ("wifi7ds.routes", std::ios::out);
//dsr.PrintRoutingTableAllEvery (Seconds (2), routingStream);
// To do-- enable an IP-level trace that shows forwarding events only
}
// Trace Collisions
Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/MacTxDrop", MakeCallback(&MacTxDrop));
Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyRxDrop", MakeCallback(&PhyRxDrop));
Config::ConnectWithoutContext("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/PhyTxDrop", MakeCallback(&PhyTxDrop));
Simulator::Schedule(Seconds(5.0), &PrintDrop);
Simulator::Stop (Seconds (100.0));
Simulator::Run ();
PrintDrop();
// Print per flow statistics
monitor->CheckForLostPackets ();
Ptr<Ipv4FlowClassifier> classifier = DynamicCast<Ipv4FlowClassifier> (flowmon.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);
if ((t.sourceAddress == Ipv4Address("10.0.0.1") && t.destinationAddress == Ipv4Address("10.0.0.25"))
|| (t.sourceAddress == Ipv4Address("10.0.0.2") && t.destinationAddress == Ipv4Address("10.0.0.25"))
|| (t.sourceAddress == Ipv4Address("10.0.0.26") && t.destinationAddress == Ipv4Address("10.0.0.50"))
|| (t.sourceAddress == Ipv4Address("10.0.0.27") && t.destinationAddress == Ipv4Address("10.0.0.50"))
|| (t.sourceAddress == Ipv4Address("10.0.0.50") && t.destinationAddress == Ipv4Address("10.0.0.101"))
|| (t.sourceAddress == Ipv4Address("10.0.0.25") && t.destinationAddress == Ipv4Address("10.0.0.101"))
|| (t.sourceAddress == Ipv4Address("10.0.0.51") && t.destinationAddress == Ipv4Address("10.0.0.75"))
|| (t.sourceAddress == Ipv4Address("10.0.0.52") && t.destinationAddress == Ipv4Address("10.0.0.75"))
|| (t.sourceAddress == Ipv4Address("10.0.0.75") && t.destinationAddress == Ipv4Address("10.0.0.101"))
|| (t.sourceAddress == Ipv4Address("10.0.0.76") && t.destinationAddress == Ipv4Address("10.0.0.100"))
|| (t.sourceAddress == Ipv4Address("10.0.0.77") && t.destinationAddress == Ipv4Address("10.0.0.100"))
|| (t.sourceAddress == Ipv4Address("10.0.0.100") && t.destinationAddress == Ipv4Address("10.0.0.101"))
|| (t.sourceAddress == Ipv4Address("10.0.0.101") && t.destinationAddress == Ipv4Address("10.0.0.106")))
{
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("Throughput: " << iter->second.rxBytes * 8.0 / (iter->second.timeLastRxPacket.GetSeconds()-iter->second.timeFirstTxPacket.GetSeconds()) / 1024 << " Kbps");
}
}
monitor->SerializeToXmlFile("wifi7ds.flowmon", true, true);
Simulator::Destroy ();
return 0;
}
Regards.