63 #include "ns3/core-module.h"
64 #include "ns3/network-module.h"
65 #include "ns3/applications-module.h"
66 #include "ns3/mobility-module.h"
67 #include "ns3/config-store-module.h"
68 #include "ns3/wifi-module.h"
69 #include "ns3/csma-module.h"
70 #include "ns3/olsr-helper.h"
71 #include "ns3/internet-module.h"
88 std::cout <<
"CourseChange " << path <<
" x=" << position.
x <<
", y=" << position.
y <<
", z=" << position.
z << std::endl;
92 main (
int argc,
char *argv[])
98 uint32_t backboneNodes = 10;
99 uint32_t infraNodes = 5;
100 uint32_t lanNodes = 5;
102 bool useCourseChangeCallback =
false;
103 bool enableTracing =
false;
118 cmd.
AddValue (
"backboneNodes",
"number of backbone nodes", backboneNodes);
119 cmd.
AddValue (
"infraNodes",
"number of leaf nodes", infraNodes);
120 cmd.
AddValue (
"lanNodes",
"number of LAN nodes", lanNodes);
121 cmd.
AddValue (
"stopTime",
"simulation stop time (seconds)", stopTime);
122 cmd.
AddValue (
"useCourseChangeCallback",
"whether to enable course change tracing", useCourseChangeCallback);
123 cmd.
AddValue (
"enableTracing",
"enable tracing", enableTracing);
129 cmd.
Parse (argc, argv);
142 backbone.
Create (backboneNodes);
149 mac.
SetType (
"ns3::AdhocWifiMac");
159 NS_LOG_INFO (
"Enabling OLSR routing on all backbone nodes");
176 ipAddrs.
SetBase (
"192.168.0.0",
"255.255.255.0");
177 ipAddrs.
Assign (backboneDevices);
185 CreateObject<ListPositionAllocator> ();
187 for (uint32_t i = 0; i < backboneNodes; ++i)
189 positionAlloc->
Add (
Vector (x, 0.0, 0.0));
195 "Speed",
StringValue (
"ns3::ConstantRandomVariable[Constant=2]"),
196 "Pause",
StringValue (
"ns3::ConstantRandomVariable[Constant=0.2]"));
207 ipAddrs.
SetBase (
"172.16.0.0",
"255.255.255.0");
210 for (uint32_t i = 0; i < backboneNodes; ++i)
212 NS_LOG_INFO (
"Configuring local area network for backbone node " << i);
219 newLanNodes.
Create (lanNodes - 1);
229 csma.SetChannelAttribute (
"Delay",
TimeValue (MilliSeconds (2)));
234 internet.
Install (newLanNodes);
239 ipAddrs.
Assign (lanDevices);
255 ipAddrs.
SetBase (
"10.0.0.0",
"255.255.255.0");
257 for (uint32_t i = 0; i < backboneNodes; ++i)
259 NS_LOG_INFO (
"Configuring wireless network for backbone node " << i);
266 stas.
Create (infraNodes - 1);
276 std::string ssidString (
"wifi-infra");
277 std::stringstream ss;
279 ssidString += ss.str ();
281 wifiInfra.SetRemoteStationManager (
"ns3::ArfWifiManager");
283 macInfra.
SetType (
"ns3::StaWifiMac",
288 macInfra.
SetType (
"ns3::ApWifiMac",
301 ipAddrs.
Assign (infraDevices);
312 CreateObject<ListPositionAllocator> ();
313 for (uint32_t j = 0; j < infra.GetN (); ++j)
321 "Speed",
StringValue (
"ns3::ConstantRandomVariable[Constant=3]"),
322 "Pause",
StringValue (
"ns3::ConstantRandomVariable[Constant=0.4]"));
334 NS_LOG_INFO (
"Enabling global routing on all nodes");
354 NS_ASSERT (lanNodes > 1 && infraNodes > 1);
359 uint32_t lastNodeIndex = backboneNodes + backboneNodes*(lanNodes - 1) + backboneNodes*(infraNodes - 1) - 1;
369 apps.
Start (Seconds (3.0));
370 apps.
Stop (Seconds (20.0));
376 apps.
Start (Seconds (3.0));
385 if (enableTracing ==
true)
410 if (useCourseChangeCallback ==
true)
holds a vector of ns3::Application pointers.
double x
x coordinate of vector
Manage ASCII trace files for device models.
static Ipv4Address GetAny(void)
smart pointer class similar to boost::intrusive_ptr
void SetChannelAttribute(std::string n1, const AttributeValue &v1)
NS_LOG_COMPONENT_DEFINE("GrantedTimeWindowMpiInterface")
Ptr< YansWifiChannel > Create(void) const
void SetRemoteStationManager(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())
static void PopulateRoutingTables(void)
Build a routing database and initialize the routing tables of the nodes in the simulation.
hold variables of type string
static Ptr< Node > GetNode(uint32_t n)
Make it easy to create and manage PHY objects for the yans model.
static YansWifiChannelHelper Default(void)
Create a channel helper in a default working state.
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())
#define NS_ASSERT(condition)
static void Run(void)
Run the simulation until one of:
aggregate IP/TCP/UDP functionality to existing Nodes.
Helper class that adds OLSR routing to nodes.
Vector GetPosition(void) const
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.
void PushReferenceMobilityModel(Ptr< Object > reference)
static void CourseChangeCallback(std::string path, Ptr< const MobilityModel > model)
void Connect(std::string path, const CallbackBase &cb)
helps to create WifiNetDevice objects
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
a polymophic address class
hold objects of type ns3::Rectangle
int main(int argc, char *argv[])
Class for representing data rates.
void SetChannel(Ptr< YansWifiChannel > channel)
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
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 ...
hold objects of type ns3::Time
holds a vector of ns3::NetDevice pointers
void Reset(void)
Return helper internal state to that of a newly constructed one.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
static NqosWifiMacHelper Default(void)
Create a mac helper in a default working state.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
create non QoS-enabled MAC layers for a ns3::WifiNetDevice.
Parse command-line arguments.
void EnableAsciiIpv4All(std::string prefix)
Enable ascii trace output on all Ipv4 and interface pairs existing in the set of all nodes created in...
static void Destroy(void)
Every event scheduled by the Simulator::insertAtDestroy method is invoked.
Access to the Ipv4 forwarding table, interfaces, and configuration.
void SetDefault(std::string name, const AttributeValue &value)
void SetConstantRate(DataRate dataRate, uint32_t packetSize=512)
Helper function to set a constant rate source.
keep track of a set of node pointers.
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 Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
double y
y coordinate of vector
manage and create wifi channel objects for the yans model.
The IEEE 802.11 SSID Information Element.
build a set of CsmaNetDevice objects
Helper class used to assign positions and mobility models to nodes.
Ipv4 addresses are stored in host order in this class.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
uint32_t GetId(void) const
hold objects of type ns3::DataRate
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
static void Stop(void)
If an event invokes this method, it will be the last event scheduled by the Simulator::run method bef...
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
hold objects of type ns3::Ssid
Ipv4Address NewNetwork(void)
Increment the network number and reset the IP address counter to the base value provided in the SetBa...
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
void Parse(int argc, char *argv[])
Parse the program arguments.
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.
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
Ptr< T > GetObject(void) const
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
double z
z coordinate of vector
static WifiHelper Default(void)