56#include "ns3/aodv-module.h"
57#include "ns3/applications-module.h"
58#include "ns3/core-module.h"
59#include "ns3/dsdv-module.h"
60#include "ns3/dsr-module.h"
61#include "ns3/flow-monitor-module.h"
62#include "ns3/internet-module.h"
63#include "ns3/mobility-module.h"
64#include "ns3/network-module.h"
65#include "ns3/olsr-module.h"
66#include "ns3/yans-wifi-helper.h"
131static inline std::string
134 std::ostringstream
oss;
141 oss <<
" received one packet from " << addr.
GetIpv4();
145 oss <<
" received one packet!";
195 cmd.AddValue(
"CSVfileName",
"The name of the CSV output file name",
m_CSVfileName);
196 cmd.AddValue(
"traceMobility",
"Enable mobility tracing",
m_traceMobility);
197 cmd.AddValue(
"protocol",
"Routing protocol (OLSR, AODV, DSDV, DSR)",
m_protocolName);
198 cmd.AddValue(
"flowMonitor",
"enable FlowMonitor",
m_flowMonitor);
227 out <<
"SimulationSecond,"
229 <<
"PacketsReceived,"
231 <<
"RoutingProtocol,"
232 <<
"TransmissionPower" << std::endl;
238 std::string rate(
"2048bps");
239 std::string
phyMode(
"DsssRate11Mbps");
240 std::string
tr_name(
"manet-routing-compare");
260 wifiChannel.AddPropagationLoss(
"ns3::FriisPropagationLossModel");
265 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
274 wifiMac.SetType(
"ns3::AdhocWifiMac");
281 pos.
SetTypeId(
"ns3::RandomRectanglePositionAllocator");
282 pos.
Set(
"X",
StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=300.0]"));
283 pos.
Set(
"Y",
StringValue(
"ns3::UniformRandomVariable[Min=0.0|Max=1500.0]"));
292 mobilityAdhoc.SetMobilityModel(
"ns3::RandomWaypointMobilityModel",
314 internet.SetRoutingHelper(
list);
320 internet.SetRoutingHelper(
list);
326 internet.SetRoutingHelper(
list);
335 NS_FATAL_ERROR(
"Error: FlowMonitor does not work with DSR. Terminating.");
351 onoff1.SetAttribute(
"OnTime",
StringValue(
"ns3::ConstantRandomVariable[Constant=1.0]"));
352 onoff1.SetAttribute(
"OffTime",
StringValue(
"ns3::ConstantRandomVariable[Constant=0.0]"));
359 onoff1.SetAttribute(
"Remote", remoteAddress);
367 std::stringstream
ss;
371 std::stringstream
ss2;
375 std::stringstream
ss3;
379 std::stringstream
ss4;
Routing experiment class.
void Run()
Run the experiment.
void CommandSetup(int argc, char **argv)
Handles the command-line parameters.
bool m_flowMonitor
Enable FlowMonitor.
void CheckThroughput()
Compute the throughput.
uint32_t packetsReceived
Total received packets.
int m_nSinks
Number of sink nodes.
std::string m_protocolName
Protocol name.
void ReceivePacket(Ptr< Socket > socket)
Receive a packet.
uint32_t bytesTotal
Total received bytes.
std::string m_CSVfileName
CSV filename.
Ptr< Socket > SetupPacketReceive(Ipv4Address addr, Ptr< Node > node)
Setup the receiving socket in a Sink Node.
uint32_t port
Receiving port number.
bool m_traceMobility
Enable mobility tracing.
a polymophic address class
AttributeValue implementation for Address.
Helper class that adds AODV routing to nodes.
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.
Manage ASCII trace files for device models.
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Helper class that adds DSDV routing to nodes.
DSR helper class to manage creation of DSR routing instance and to insert it on a node as a sublayer ...
Helper class that adds DSR routing to nodes.
Helper to enable IP flow monitoring on a set of Nodes.
static bool IsMatchingType(const Address &address)
Ipv4Address GetIpv4() const
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4 addresses are stored in host order in this class.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Helper class that adds ns3::Ipv4ListRouting objects.
Helper class used to assign positions and mobility models to nodes.
static void EnableAsciiAll(Ptr< OutputStreamWrapper > stream)
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.
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.
Helper class that adds OLSR routing to nodes.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
static void EnablePrinting()
Enable printing packets metadata.
AttributeValue implementation for Pointer.
Allocate a set of positions.
virtual int64_t AssignStreams(int64_t stream)=0
Assign a fixed random variable stream number to the random variables used by this model.
Smart pointer class similar to boost::intrusive_ptr.
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.
double GetSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
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.
manage and create wifi channel objects for the YANS model.
void SetPropagationDelay(std::string name, Ts &&... args)
Make it easy to create and manage PHY objects for the YANS model.
void experiment(std::string queue_disc_type)
void SetDefault(std::string name, const AttributeValue &value)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
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.
static std::string PrintReceivedPacket(Ptr< Socket > socket, Ptr< Packet > packet, Address senderAddress)
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...
Ptr< PacketSink > sink
Pointer to the packet sink application.