33 #include "ns3/core-module.h" 34 #include "ns3/network-module.h" 35 #include "ns3/applications-module.h" 36 #include "ns3/mobility-module.h" 37 #include "ns3/config-store-module.h" 38 #include "ns3/internet-module.h" 39 #include "ns3/dsr-module.h" 40 #include "ns3/yans-wifi-helper.h" 47 main (
int argc,
char *argv[])
81 double TotalTime = 600.0;
82 double dataTime = 500.0;
85 double dataStart = 100.0;
88 double pauseTime = 0.0;
89 double nodeSpeed = 20.0;
90 double txpDistance = 250.0;
92 std::string rate =
"0.512kbps";
93 std::string dataMode (
"DsssRate11Mbps");
94 std::string phyMode (
"DsssRate11Mbps");
98 cmd.AddValue (
"nWifis",
"Number of wifi nodes", nWifis);
99 cmd.AddValue (
"nSinks",
"Number of SINK traffic nodes", nSinks);
100 cmd.AddValue (
"rate",
"CBR traffic rate(in kbps), Default:8", rate);
101 cmd.AddValue (
"nodeSpeed",
"Node speed in RandomWayPoint model, Default:20", nodeSpeed);
103 cmd.AddValue (
"txpDistance",
"Specify node's transmit range, Default:300", txpDistance);
104 cmd.AddValue (
"pauseTime",
"pauseTime for mobility model, Default: 0", pauseTime);
105 cmd.Parse (argc, argv);
111 adhocNodes.
Create (nWifis);
114 NS_LOG_INFO (
"setting the default phy and channel parameters");
120 NS_LOG_INFO (
"setting the default phy and channel parameters ");
132 wifi.SetRemoteStationManager (
"ns3::ConstantRateWifiManager",
"DataMode",
StringValue (dataMode),
"ControlMode",
135 wifiMac.
SetType (
"ns3::AdhocWifiMac");
136 allDevices =
wifi.Install (wifiPhy, wifiMac, adhocNodes);
146 pos.
SetTypeId (
"ns3::RandomRectanglePositionAllocator");
147 pos.
Set (
"X",
StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=300.0]"));
148 pos.
Set (
"Y",
StringValue (
"ns3::UniformRandomVariable[Min=0.0|Max=1500.0]"));
151 std::ostringstream speedUniformRandomVariableStream;
152 speedUniformRandomVariableStream <<
"ns3::UniformRandomVariable[Min=0.0|Max=" 156 std::ostringstream pauseConstantRandomVariableStream;
157 pauseConstantRandomVariableStream <<
"ns3::ConstantRandomVariable[Constant=" 163 "Speed",
StringValue (speedUniformRandomVariableStream.str ()),
164 "Pause",
StringValue (pauseConstantRandomVariableStream.str ()),
167 adhocMobility.
Install (adhocNodes);
173 dsrMain.
Install (dsr, adhocNodes);
177 address.SetBase (
"10.1.1.0",
"255.255.255.0");
179 allInterfaces =
address.Assign (allDevices);
182 double randomStartTime = (1 / ppers) / nSinks;
184 for (uint32_t i = 0; i < nSinks; ++i)
193 onoff1.SetAttribute (
"OffTime",
StringValue (
"ns3::ConstantRandomVariable[Constant=0.0]"));
198 apps1.
Start (
Seconds (dataStart + i * randomStartTime));
199 apps1.
Stop (
Seconds (dataTime + i * randomStartTime));
void AddPropagationLoss(std::string name, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
holds a vector of ns3::Application pointers.
Manage ASCII trace files for device models.
static Ipv4Address GetAny(void)
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Hold variables of type string.
Make it easy to create and manage PHY objects for the yans model.
Helper class that adds DSR routing to nodes.
static void Run(void)
Run the simulation.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
aggregate IP/TCP/UDP functionality to existing Nodes.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
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. ...
static YansWifiPhyHelper Default(void)
Create a phy helper in a default working state.
helps to create WifiNetDevice objects
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
static void SetRun(uint64_t run)
Set the run number of simulation.
a polymophic address class
Ptr< YansWifiChannel > Create(void) const
Class for representing data rates.
void SetChannel(Ptr< YansWifiChannel > channel)
void LogComponentEnable(char const *name, enum LogLevel level)
Enable the logging output associated with that log component.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Hold an unsigned integer type.
holds a vector of ns3::NetDevice pointers
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
Parse command-line arguments.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Hold objects of type Ptr<T>.
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
void Set(std::string name, const AttributeValue &value)
Set an attribute to be set during construction.
manage and create wifi channel objects for the yans model.
create MAC layers for a ns3::WifiNetDevice.
virtual void SetType(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue())
static void SetSeed(uint32_t seed)
Set the seed.
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
Helper class used to assign positions and mobility models to nodes.
Instantiate subclasses of ns3::Object.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
AttributeValue implementation for DataRate.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
DSR helper class to manage creation of DSR routing instance and to insert it on a node as a sublayer ...
Time Seconds(double value)
Construct a Time in the indicated unit.
void SetDefault(std::string name, const AttributeValue &value)
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
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...
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
static const uint32_t packetSize
void SetPropagationDelay(std::string name, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
This class can be used to hold variables of floating point type such as 'double' or 'float'...
void Install(DsrHelper &dsrHelper, NodeContainer nodes)
Install routing to the nodes.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
Allocate a set of positions.