20#include "ns3/applications-module.h" 
   21#include "ns3/core-module.h" 
   22#include "ns3/dsdv-helper.h" 
   23#include "ns3/internet-module.h" 
   24#include "ns3/mobility-module.h" 
   25#include "ns3/network-module.h" 
   26#include "ns3/yans-wifi-helper.h" 
   76                 std::string CSVfileName);
 
 
  131main(
int argc, 
char** argv)
 
  136    double totalTime = 100.0;
 
  137    std::string rate(
"8kbps");
 
  138    std::string phyMode(
"DsssRate11Mbps");
 
  140    std::string appl = 
"all";
 
  141    uint32_t periodicUpdateInterval = 15;
 
  143    double dataStart = 50.0;
 
  144    bool printRoutingTable = 
true;
 
  145    std::string CSVfileName = 
"DsdvManetExample.csv";
 
  148    cmd.AddValue(
"nWifis", 
"Number of wifi nodes[Default:30]", nWifis);
 
  149    cmd.AddValue(
"nSinks", 
"Number of wifi sink nodes[Default:10]", nSinks);
 
  150    cmd.AddValue(
"totalTime", 
"Total Simulation time[Default:100]", totalTime);
 
  151    cmd.AddValue(
"phyMode", 
"Wifi Phy mode[Default:DsssRate11Mbps]", phyMode);
 
  152    cmd.AddValue(
"rate", 
"CBR traffic rate[Default:8kbps]", rate);
 
  153    cmd.AddValue(
"nodeSpeed", 
"Node speed in RandomWayPoint model[Default:10]", nodeSpeed);
 
  154    cmd.AddValue(
"periodicUpdateInterval",
 
  155                 "Periodic Interval Time[Default=15]",
 
  156                 periodicUpdateInterval);
 
  157    cmd.AddValue(
"settlingTime",
 
  158                 "Settling Time before sending out an update for changed metric[Default=6]",
 
  160    cmd.AddValue(
"dataStart",
 
  161                 "Time at which nodes start to transmit data[Default=50.0]",
 
  163    cmd.AddValue(
"printRoutingTable",
 
  164                 "print routing table for nodes[Default:1]",
 
  166    cmd.AddValue(
"CSVfileName",
 
  167                 "The name of the CSV output file name[Default:DsdvManetExample.csv]",
 
  169    cmd.Parse(argc, argv);
 
  171    std::ofstream out(CSVfileName);
 
  172    out << 
"SimulationSecond," 
  174        << 
"PacketsReceived," 
  175        << 
"NumberOfSinks," << std::endl;
 
  192                 periodicUpdateInterval,
 
  212    while ((packet = socket->Recv()))
 
 
  258                          std::string CSVfileName)
 
  272    std::stringstream ss;
 
  274    std::string t_nodes = ss.str();
 
  276    std::stringstream ss3;
 
  278    std::string sTotalTime = ss3.str();
 
  280    std::string tr_name = 
"Dsdv_Manet_" + t_nodes + 
"Nodes_" + sTotalTime + 
"SimTime";
 
  281    std::cout << 
"Trace file generated is " << tr_name << 
".tr\n";
 
  289    std::cout << 
"\nStarting simulation for " << 
m_totalTime << 
" s ...\n";
 
 
  301    std::cout << 
"Creating " << (unsigned)
m_nWifis << 
" nodes.\n";
 
  304                  "Sinks must be less or equal to the number of nodes in network");
 
 
  312    pos.
SetTypeId(
"ns3::RandomRectanglePositionAllocator");
 
  313    pos.
Set(
"X", 
StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=1000.0]"));
 
  314    pos.
Set(
"Y", 
StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=1000.0]"));
 
  316    std::ostringstream speedConstantRandomVariableStream;
 
  317    speedConstantRandomVariableStream << 
"ns3::ConstantRandomVariable[Constant=" << 
m_nodeSpeed 
  321    mobility.SetMobilityModel(
"ns3::RandomWaypointMobilityModel",
 
  323                              StringValue(speedConstantRandomVariableStream.str()),
 
  325                              StringValue(
"ns3::ConstantRandomVariable[Constant=2.0]"),
 
  328    mobility.SetPositionAllocator(taPositionAlloc);
 
  329    mobility.Install(
nodes);
 
 
  336    wifiMac.
SetType(
"ns3::AdhocWifiMac");
 
  344    wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
 
 
  363    stack.SetRoutingHelper(dsdv); 
 
  364    stack.Install(
nodes);
 
  366    address.SetBase(
"10.1.1.0", 
"255.255.255.0");
 
 
  382        Ipv4Address nodeAddress = node->GetObject<
Ipv4>()->GetAddress(1, 0).GetLocal();
 
  394                                StringValue(
"ns3::ConstantRandomVariable[Constant=0.0]"));
 
 
uint32_t m_nSinks
number of receiver nodes
void InstallApplications()
Create data sinks and sources.
NodeContainer nodes
the collection of nodes
void ReceivePacket(Ptr< Socket > socket)
Packet receive function.
double m_dataStart
time to start data transmissions (seconds)
std::string m_CSVfileName
CSV file name.
uint32_t packetsReceived
total packets received by all nodes
std::string m_rate
network bandwidth
uint32_t bytesTotal
total bytes received by all nodes
void CreateNodes()
Create and initialize all nodes.
bool m_printRoutes
print routing table
void InstallInternetStack(std::string tr_name)
Create network.
uint32_t m_nodeSpeed
mobility speed
void CreateDevices(std::string tr_name)
Create and initialize all devices.
void CaseRun(uint32_t nWifis, uint32_t nSinks, double totalTime, std::string rate, std::string phyMode, uint32_t nodeSpeed, uint32_t periodicUpdateInterval, uint32_t settlingTime, double dataStart, bool printRoutes, std::string CSVfileName)
Run function.
uint32_t m_settlingTime
routing setting time
Ipv4InterfaceContainer interfaces
the collection of interfaces
void CheckThroughput()
Check network throughput.
void SetupMobility()
Setup mobility model.
NetDeviceContainer devices
the collection of devices
double m_totalTime
total simulation time (in seconds)
std::string m_phyMode
remote station manager data mode
Ptr< Socket > SetupPacketReceive(Ipv4Address addr, Ptr< Node > node)
Setup packet receivers.
uint32_t m_periodicUpdateInterval
routing update interval
uint32_t m_nWifis
total number of nodes
a polymophic address class
holds a vector of ns3::Application pointers.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
ApplicationContainer Install(NodeContainer c)
Install an application on each node of the input container configured with all the attributes set wit...
void SetAttribute(const std::string &name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
void EnableAsciiAll(std::string prefix)
Enable ascii trace output on each device (which is of the appropriate type) in the set of all nodes c...
Manage ASCII trace files for device models.
Ptr< OutputStreamWrapper > CreateFileStream(std::string filename, std::ios::openmode filemode=std::ios::out)
Create and initialize an output stream object we'll use to write the traced bits.
Parse command-line arguments.
Helper class that adds DSDV routing to nodes.
void Set(std::string name, const AttributeValue &value)
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ipv4 addresses are stored in host order in this class.
Access to the IPv4 forwarding table, interfaces, and configuration.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
static void PrintRoutingTableAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of all nodes at a particular time.
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
static Ptr< Node > GetNode(uint32_t n)
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
void EnablePcapAll(std::string prefix, bool promiscuous=false)
Enable pcap output on each device (which is of the appropriate type) in the set of all nodes created ...
AttributeValue implementation for Pointer.
Allocate a set of positions.
Smart pointer class similar to boost::intrusive_ptr.
static void SetSeed(uint32_t seed)
Set the seed.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
Hold variables of type string.
AttributeValue implementation for Time.
a unique identifier for an interface.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
void SetType(std::string type, Args &&... args)
manage and create wifi channel objects for the YANS model.
void SetPropagationDelay(std::string name, Ts &&... args)
void AddPropagationLoss(std::string name, Ts &&... args)
Ptr< YansWifiChannel > Create() const
Make it easy to create and manage PHY objects for the YANS model.
void SetChannel(Ptr< YansWifiChannel > channel)
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
void SetDefault(std::string name, const AttributeValue &value)
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
-ns3 Test suite for the ns3 wrapper script
std::map< Mac48Address, uint64_t > packetsReceived
Map that stores the total packets received per STA (and addressed to that STA)
Ptr< PacketSink > sink
Pointer to the packet sink application.