19#include "ns3/boolean.h"
20#include "ns3/command-line.h"
21#include "ns3/config.h"
22#include "ns3/constant-position-mobility-model.h"
23#include "ns3/flow-monitor-helper.h"
24#include "ns3/internet-stack-helper.h"
25#include "ns3/ipv4-address-helper.h"
26#include "ns3/ipv4-flow-classifier.h"
27#include "ns3/on-off-helper.h"
28#include "ns3/propagation-delay-model.h"
29#include "ns3/propagation-loss-model.h"
30#include "ns3/string.h"
31#include "ns3/udp-echo-helper.h"
32#include "ns3/uinteger.h"
33#include "ns3/yans-wifi-channel.h"
34#include "ns3/yans-wifi-helper.h"
56 for (uint8_t i = 0; i < 3; ++i)
63 lossModel->SetDefaultLoss(200);
73 wifiChannel->SetPropagationLossModel(lossModel);
79 wifi.SetRemoteStationManager(
"ns3::" + wifiManager +
"WifiManager");
83 wifiMac.
SetType(
"ns3::AdhocWifiMac");
97 internet.Install(
nodes);
99 ipv4.SetBase(
"10.0.0.0",
"255.0.0.0");
100 ipv4.Assign(devices);
104 uint16_t cbrPort = 12345;
108 onOffHelper.SetAttribute(
"OnTime",
StringValue(
"ns3::ConstantRandomVariable[Constant=1]"));
109 onOffHelper.SetAttribute(
"OffTime",
StringValue(
"ns3::ConstantRandomVariable[Constant=0]"));
112 onOffHelper.SetAttribute(
"DataRate",
StringValue(
"3000000bps"));
122 onOffHelper.SetAttribute(
"DataRate",
StringValue(
"3001100bps"));
132 uint16_t echoPort = 9;
154 monitor->CheckForLostPackets();
157 for (
auto i = stats.begin(); i != stats.end(); ++i)
168 std::cout <<
"Flow " << i->first - 2 <<
" (" << t.
sourceAddress <<
" -> "
170 std::cout <<
" Tx Packets: " << i->second.txPackets <<
"\n";
171 std::cout <<
" Tx Bytes: " << i->second.txBytes <<
"\n";
172 std::cout <<
" TxOffered: " << i->second.txBytes * 8.0 / 9.0 / 1000 / 1000
174 std::cout <<
" Rx Packets: " << i->second.rxPackets <<
"\n";
175 std::cout <<
" Rx Bytes: " << i->second.rxBytes <<
"\n";
176 std::cout <<
" Throughput: " << i->second.rxBytes * 8.0 / 9.0 / 1000 / 1000
186main(
int argc,
char** argv)
188 std::string wifiManager(
"Arf");
192 "Set wifi rate manager (Aarf, Aarfcd, Amrr, Arf, Cara, Ideal, Minstrel, Onoe, Rraa)",
194 cmd.Parse(argc, argv);
196 std::cout <<
"Hidden station experiment with RTS/CTS disabled:\n" << std::flush;
198 std::cout <<
"------------------------------------------------\n";
199 std::cout <<
"Hidden station experiment with RTS/CTS enabled:\n";
holds a vector of ns3::Application pointers.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
ApplicationContainer Install(NodeContainer c)
Install an application on each node of the input container configured with all the attributes set wit...
void SetAttribute(const std::string &name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
Parse command-line arguments.
Helper to enable IP flow monitoring on a set of Nodes.
Ptr< FlowClassifier > GetClassifier()
Retrieve the FlowClassifier object for IPv4 created by the Install* methods.
Ptr< FlowMonitor > InstallAll()
Enable flow monitoring on all nodes.
std::map< FlowId, FlowStats > FlowStatsContainer
Container: FlowId, FlowStats.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Ipv4 addresses are stored in host order in this class.
Keep track of the current position and velocity of an object.
holds a vector of ns3::NetDevice pointers
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.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
Smart pointer class similar to boost::intrusive_ptr.
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.
Hold variables of type string.
Create an application which sends a UDP packet and waits for an echo of this packet.
Hold an unsigned integer type.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
void SetType(std::string type, Args &&... args)
Make it easy to create and manage PHY objects for the YANS model.
void SetChannel(Ptr< YansWifiChannel > channel)
void SetDefault(std::string name, const AttributeValue &value)
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Structure to classify a packet.
Ipv4Address sourceAddress
Source address.
Ipv4Address destinationAddress
Destination address.
void experiment(bool enableCtsRts, std::string wifiManager)
Run single 10 seconds experiment.