43 #include "ns3/bridge-helper.h"
44 #include "ns3/command-line.h"
45 #include "ns3/csma-helper.h"
46 #include "ns3/double.h"
47 #include "ns3/internet-stack-helper.h"
48 #include "ns3/ipv4-address-helper.h"
49 #include "ns3/mobility-helper.h"
50 #include "ns3/on-off-helper.h"
51 #include "ns3/packet-socket-address.h"
52 #include "ns3/rectangle.h"
54 #include "ns3/string.h"
55 #include "ns3/uinteger.h"
56 #include "ns3/yans-wifi-channel.h"
57 #include "ns3/yans-wifi-helper.h"
62 main(
int argc,
char* argv[])
67 bool writeMobility =
false;
70 cmd.AddValue(
"nWifis",
"Number of wifi networks", nWifis);
71 cmd.AddValue(
"nStas",
"Number of stations per wifi network", nStas);
72 cmd.AddValue(
"SendIp",
"Send Ipv4 or raw packets", sendIp);
73 cmd.AddValue(
"writeMobility",
"Write mobility trace", writeMobility);
74 cmd.Parse(argc, argv);
79 std::vector<NodeContainer> staNodes;
81 std::vector<NetDeviceContainer>
apDevices;
82 std::vector<Ipv4InterfaceContainer> staInterfaces;
83 std::vector<Ipv4InterfaceContainer> apInterfaces;
88 ip.
SetBase(
"192.168.0.0",
"255.255.255.0");
90 backboneNodes.
Create(nWifis);
91 stack.Install(backboneNodes);
93 backboneDevices =
csma.Install(backboneNodes);
100 for (uint32_t i = 0; i < nWifis; ++i)
103 std::ostringstream oss;
104 oss <<
"wifi-default-" << i;
120 mobility.SetPositionAllocator(
"ns3::GridPositionAllocator",
135 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
137 wifiMac.
SetType(
"ns3::ApWifiMac",
"Ssid", SsidValue(
ssid));
138 apDev =
wifi.Install(wifiPhy, wifiMac, backboneNodes.
Get(i));
145 apInterface = ip.
Assign(bridgeDev);
150 "ns3::RandomWalk2dMobilityModel",
156 StringValue(
"ns3::ConstantRandomVariable[Constant=1.0]"),
158 RectangleValue(
Rectangle(wifiX, wifiX + 5.0, 0.0, (nStas + 1) * 5.0)));
160 wifiMac.
SetType(
"ns3::StaWifiMac",
"Ssid", SsidValue(
ssid));
161 staDev =
wifi.Install(wifiPhy, wifiMac, sta);
162 staInterface = ip.
Assign(staDev);
165 staNodes.push_back(sta);
167 apInterfaces.push_back(apInterface);
169 staInterfaces.push_back(staInterface);
175 std::string protocol;
179 protocol =
"ns3::UdpSocketFactory";
188 protocol =
"ns3::PacketSocketFactory";
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.
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.
Add capability to bridge multiple LAN segments (IEEE 802.1D bridging)
NetDeviceContainer Install(Ptr< Node > node, NetDeviceContainer c)
This method creates an ns3::BridgeNetDevice with the attributes configured by BridgeHelper::SetDevice...
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'.
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.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Helper class used to assign positions and mobility models to nodes.
static void EnableAsciiAll(Ptr< OutputStreamWrapper > stream)
holds a vector of ns3::NetDevice pointers
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
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.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
an address for a packet socket
void SetProtocol(uint16_t protocol)
Set the protocol.
void SetPhysicalAddress(const Address address)
Set the destination address.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
void EnablePcap(std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
Enable pcap output the indicated net device.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
The IEEE 802.11 SSID Information Element.
Hold variables of type string.
Hold an unsigned integer type.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
void SetType(std::string type, Args &&... args)
void SetPcapDataLinkType(SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
manage and create wifi channel objects for the YANS model.
static YansWifiChannelHelper Default()
Create a channel helper in a default working state.
Ptr< YansWifiChannel > Create() const
Make it easy to create and manage PHY objects for the YANS model.
void SetChannel(Ptr< YansWifiChannel > channel)
void(* DataRate)(DataRate oldValue, DataRate newValue)
TracedValue callback signature for DataRate.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.