19#include "ns3/core-module.h"
20#include "ns3/point-to-point-module.h"
21#include "ns3/csma-module.h"
22#include "ns3/network-module.h"
23#include "ns3/applications-module.h"
24#include "ns3/mobility-module.h"
25#include "ns3/internet-module.h"
26#include "ns3/netanim-module.h"
27#include "ns3/basic-energy-source.h"
28#include "ns3/simple-device-energy-model.h"
29#include "ns3/yans-wifi-helper.h"
31#include "ns3/wifi-radio-energy-model.h"
38main (
int argc,
char *argv[])
42 cmd.AddValue (
"nWifi",
"Number of wifi STA devices",
nWifi);
44 cmd.Parse (argc,argv);
61 mac.SetType (
"ns3::StaWifiMac",
67 mac.SetType (
"ns3::ApWifiMac",
101 mobility.SetPositionAllocator (
"ns3::GridPositionAllocator",
108 mobility.SetMobilityModel (
"ns3::RandomWalk2dMobilityModel",
111 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
113 AnimationInterface::SetConstantPosition (
p2pNodes.Get (1), 10, 30);
114 AnimationInterface::SetConstantPosition (
csmaNodes.Get (1), 10, 33);
120 energyModel->SetEnergySource (energySource);
124 wifiApNode.Get (0)->AggregateObject (energySource);
129 stack.Install (allNodes);
134 address.SetBase (
"10.1.1.0",
"255.255.255.0");
137 address.SetBase (
"10.1.2.0",
"255.255.255.0");
140 address.SetBase (
"10.1.3.0",
"255.255.255.0");
160 Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
161 Simulator::Stop (
Seconds (15.0));
166 anim.UpdateNodeDescription (
wifiStaNodes.Get (i),
"STA");
171 anim.UpdateNodeDescription (
wifiApNode.Get (i),
"AP");
172 anim.UpdateNodeColor (
wifiApNode.Get (i), 0, 255, 0);
176 anim.UpdateNodeDescription (
csmaNodes.Get (i),
"CSMA");
177 anim.UpdateNodeColor (
csmaNodes.Get (i), 0, 0, 255);
180 anim.EnablePacketMetadata ();
181 anim.EnableIpv4RouteTracking (
"routingtable-wireless.xml",
Seconds (0),
Seconds (5),
Seconds (0.25));
185 Simulator::Destroy ();
Interface to network animator.
holds a vector of ns3::Application pointers.
void SetInitialEnergy(double initialEnergyJ)
AttributeValue implementation for Boolean.
Parse command-line arguments.
build a set of CsmaNetDevice objects
This class can be used to hold variables of floating point type such as 'double' or 'float'.
void AppendDeviceEnergyModel(Ptr< DeviceEnergyModel > deviceEnergyModelPtr)
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
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 Add(NodeContainer other)
Append the contents of another NodeContainer to the end of this container.
Build a set of PointToPointNetDevice objects.
AttributeValue implementation for Rectangle.
The IEEE 802.11 SSID Information Element.
AttributeValue implementation for Ssid.
Hold variables of type string.
AttributeValue implementation for Time.
Create an application which sends a UDP packet and waits for an echo of this packet.
Create a server application which waits for input UDP packets and sends them back to the original sen...
Hold an unsigned integer type.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
manage and create wifi channel objects for the YANS model.
Make it easy to create and manage PHY objects for the YANS model.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time NanoSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.