|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
31 #include "ns3/command-line.h"
32 #include "ns3/config.h"
33 #include "ns3/uinteger.h"
34 #include "ns3/boolean.h"
35 #include "ns3/string.h"
36 #include "ns3/yans-wifi-helper.h"
37 #include "ns3/internet-stack-helper.h"
38 #include "ns3/ipv4-address-helper.h"
39 #include "ns3/udp-echo-helper.h"
40 #include "ns3/yans-wifi-channel.h"
41 #include "ns3/constant-position-mobility-model.h"
42 #include "ns3/propagation-loss-model.h"
43 #include "ns3/propagation-delay-model.h"
44 #include "ns3/on-off-helper.h"
45 #include "ns3/flow-monitor-helper.h"
46 #include "ns3/ipv4-flow-classifier.h"
51 void experiment (
bool enableCtsRts, std::string wifiManager)
62 for (uint8_t i = 0; i < 3; ++i)
64 nodes.Get (i)->AggregateObject (CreateObject<ConstantPositionMobilityModel> ());
81 wifi.SetRemoteStationManager (
"ns3::" + wifiManager +
"WifiManager");
85 wifiMac.
SetType (
"ns3::AdhocWifiMac");
101 ipv4.
SetBase (
"10.0.0.0",
"255.0.0.0");
106 uint16_t cbrPort = 12345;
131 uint16_t echoPort = 9;
156 for (std::map<FlowId, FlowMonitor::FlowStats>::const_iterator i = stats.begin (); i != stats.end (); ++i)
168 std::cout <<
" Tx Packets: " << i->second.txPackets <<
"\n";
169 std::cout <<
" Tx Bytes: " << i->second.txBytes <<
"\n";
170 std::cout <<
" TxOffered: " << i->second.txBytes * 8.0 / 9.0 / 1000 / 1000 <<
" Mbps\n";
171 std::cout <<
" Rx Packets: " << i->second.rxPackets <<
"\n";
172 std::cout <<
" Rx Bytes: " << i->second.rxBytes <<
"\n";
173 std::cout <<
" Throughput: " << i->second.rxBytes * 8.0 / 9.0 / 1000 / 1000 <<
" Mbps\n";
181 int main (
int argc,
char **argv)
183 std::string wifiManager (
"Arf");
185 cmd.AddValue (
"wifiManager",
"Set wifi rate manager (Aarf, Aarfcd, Amrr, Arf, Cara, Ideal, Minstrel, Onoe, Rraa)", wifiManager);
186 cmd.Parse (argc, argv);
188 std::cout <<
"Hidden station experiment with RTS/CTS disabled:\n" << std::flush;
190 std::cout <<
"------------------------------------------------\n";
191 std::cout <<
"Hidden station experiment with RTS/CTS enabled:\n";
holds a vector of ns3::NetDevice pointers
Make it easy to create and manage PHY objects for the YANS model.
Parse command-line arguments.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void experiment(bool enableCtsRts, std::string wifiManager)
Run single 10 seconds experiment.
helps to create WifiNetDevice objects
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Create an application which sends a UDP packet and waits for an echo of this packet.
Ipv4Address sourceAddress
Source address.
FiveTuple FindFlow(FlowId flowId) const
Searches for the FiveTuple corresponding to the given flowId.
Ipv4 addresses are stored in host order in this class.
Structure to classify a packet.
void SetChannel(Ptr< YansWifiChannel > channel)
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Smart pointer class similar to boost::intrusive_ptr.
Helper to enable IP flow monitoring on a set of Nodes.
Ipv4Address destinationAddress
Destination address.
std::map< FlowId, FlowStats > FlowStatsContainer
Container: FlowId, FlowStats.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
void SetPropagationDelayModel(const Ptr< PropagationDelayModel > delay)
Ptr< FlowMonitor > InstallAll()
Enable flow monitoring on all nodes.
void SetDefaultLoss(double defaultLoss)
Set the default propagation loss (in dB, positive) to be used, infinity if not set.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
ApplicationContainer Install(Ptr< Node > node) const
Create a udp echo client application on the specified node.
Ptr< FlowClassifier > GetClassifier()
Retrieve the FlowClassifier object for IPv4 created by the Install* methods.
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
static void Run(void)
Run the simulation.
Hold variables of type string.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
Time Seconds(double value)
Construct a Time in the indicated unit.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
holds a vector of ns3::Application pointers.
AttributeValue implementation for Time.
Keep track of the current position and velocity of an object.
keep track of a set of node pointers.
void SetType(std::string type, Args &&... args)
Hold an unsigned integer type.
create MAC layers for a ns3::WifiNetDevice.
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
void SetDefault(std::string name, const AttributeValue &value)
void SetPropagationLossModel(const Ptr< PropagationLossModel > loss)
const FlowStatsContainer & GetFlowStats() const
Retrieve all collected the flow statistics.
aggregate IP/TCP/UDP functionality to existing Nodes.
void SetLoss(Ptr< MobilityModel > a, Ptr< MobilityModel > b, double loss, bool symmetric=true)
Set loss (in dB, positive) between pair of ns-3 objects (typically, nodes).
void CheckForLostPackets()
Check right now for packets that appear to be lost.