46 #include "ns3/core-module.h"
47 #include "ns3/mobility-module.h"
48 #include "ns3/applications-module.h"
49 #include "ns3/wifi-module.h"
50 #include "ns3/network-module.h"
51 #include "ns3/csma-module.h"
52 #include "ns3/internet-module.h"
53 #include "ns3/bridge-helper.h"
61 int main (
int argc,
char *argv[])
66 bool writeMobility =
false;
69 cmd.
AddValue (
"nWifis",
"Number of wifi networks", nWifis);
70 cmd.
AddValue (
"nStas",
"Number of stations per wifi network", nStas);
71 cmd.
AddValue (
"SendIp",
"Send Ipv4 or raw packets", sendIp);
72 cmd.
AddValue (
"writeMobility",
"Write mobility trace", writeMobility);
73 cmd.
Parse (argc, argv);
78 std::vector<NodeContainer> staNodes;
79 std::vector<NetDeviceContainer> staDevices;
80 std::vector<NetDeviceContainer> apDevices;
81 std::vector<Ipv4InterfaceContainer> staInterfaces;
82 std::vector<Ipv4InterfaceContainer> apInterfaces;
87 ip.
SetBase (
"192.168.0.0",
"255.255.255.0");
89 backboneNodes.
Create (nWifis);
92 backboneDevices = csma.
Install (backboneNodes);
99 for (uint32_t i = 0; i < nWifis; ++i)
102 std::ostringstream oss;
103 oss <<
"wifi-default-" << i;
131 wifiMac.
SetType (
"ns3::ApWifiMac",
133 apDev = wifi.
Install (wifiPhy, wifiMac, backboneNodes.
Get (i));
139 apInterface = ip.
Assign (bridgeDev);
146 "Speed",
StringValue (
"ns3::ConstantRandomVariable[Constant=1.0]"),
149 wifiMac.
SetType (
"ns3::StaWifiMac",
152 staDev = wifi.
Install (wifiPhy, wifiMac, sta);
153 staInterface = ip.
Assign (staDev);
156 staNodes.push_back (sta);
157 apDevices.push_back (apDev);
158 apInterfaces.push_back (apInterface);
159 staDevices.push_back (staDev);
160 staInterfaces.push_back (staInterface);
166 std::string protocol;
170 protocol =
"ns3::UdpSocketFactory";
179 protocol =
"ns3::PacketSocketFactory";
188 wifiPhy.
EnablePcap (
"wifi-wired-bridging", apDevices[0]);
189 wifiPhy.
EnablePcap (
"wifi-wired-bridging", apDevices[1]);
holds a vector of ns3::Application pointers.
Manage ASCII trace files for device models.
AttributeValue implementation for Boolean.
holds a vector of std::pair of Ptr and interface index.
Ptr< YansWifiChannel > Create(void) const
Hold variables of type string.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
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())
an address for a packet socket
static void Run(void)
Run the simulation.
void SetPcapDataLinkType(enum SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
aggregate IP/TCP/UDP functionality to existing Nodes.
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttri...
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.
Include Radiotap link layer information.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
a polymophic address class
AttributeValue implementation for Rectangle.
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.
Hold an unsigned integer type.
holds a vector of ns3::NetDevice pointers
static NqosWifiMacHelper Default(void)
Create a mac helper in a default working state.
Add capability to bridge multiple LAN segments (IEEE 802.1D bridging)
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.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetConstantRate(DataRate dataRate, uint32_t packetSize=512)
Helper function to set a constant rate source.
void SetPhysicalAddress(const Address address)
Set the destination address.
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...
manage and create wifi channel objects for the yans model.
The IEEE 802.11 SSID Information Element.
build a set of CsmaNetDevice objects
NetDeviceContainer Install(Ptr< Node > node, NetDeviceContainer c)
This method creates an ns3::BridgeNetDevice with the attributes configured by BridgeHelper::SetDevice...
Helper class used to assign positions and mobility models to nodes.
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...
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
Time Seconds(double value)
Construct a Time in the indicated unit.
AttributeValue implementation for Ssid.
void SetProtocol(uint16_t protocol)
Set the protocol.
static void EnableAsciiAll(Ptr< OutputStreamWrapper > stream)
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 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...
This class can be used to hold variables of floating point type such as 'double' or 'float'...
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
static WifiHelper Default(void)