20 #include "ns3/core-module.h"
21 #include "ns3/network-module.h"
22 #include "ns3/applications-module.h"
23 #include "ns3/wifi-module.h"
24 #include "ns3/mobility-module.h"
25 #include "ns3/ipv4-global-routing-helper.h"
26 #include "ns3/internet-module.h"
63 int main (
int argc,
char *argv[])
65 std::cout <<
"DataRate" <<
" " <<
"Throughput" <<
'\n';
72 cmd.
AddValue (
"nWifi",
"Number of wifi STA devices", nWifi);
73 cmd.
Parse (argc,argv);
124 "ControlMode", DataRate);
125 mac.
SetType (
"ns3::StaWifiMac",
130 staDevices = wifi.
Install (phy, mac, wifiNodes);
136 apDevice = wifi.
Install (phy, mac, wifiApNode);
162 stack.Install (wifiApNode);
163 stack.Install (wifiNodes);
167 address.
SetBase (
"10.1.3.0",
"255.255.255.0");
171 wifiNodesInterfaces = address.
Assign (staDevices);
172 apNodeInterface = address.
Assign (apDevice);
182 serverApps = myServer.
Install (wifiNodes.
Get (0));
183 serverApps.
Start (Seconds (0.0));
184 serverApps.
Stop (Seconds (t));
188 myClient.SetAttribute (
"Interval",
TimeValue (
Time (
"0.00002")));
192 clientApps.
Start (Seconds (0.0));
193 clientApps.
Stop (Seconds (t));
199 uint16_t
port = 50000;
201 PacketSinkHelper packetSinkHelper (
"ns3::TcpSocketFactory", apLocalAddress);
202 sink1App = packetSinkHelper.
Install (wifiNodes.
Get (0));
204 sink1App.
Start (Seconds (0.0));
205 sink1App.
Stop (Seconds (t));
217 apps.
Start (Seconds (0.0));
218 apps.
Stop (Seconds (t));
231 uint32_t totalPacketsThrough = DynamicCast<UdpServer>(serverApps.
Get (0))->GetReceived ();
232 throughput=totalPacketsThrough*1500*8/(t*1000000.0);
237 uint32_t totalPacketsThrough = DynamicCast<PacketSink>(sink1App.
Get (0))->GetTotalRx ();
238 throughput=totalPacketsThrough*8/((t-3)*1000000.0);
241 std::cout << datarate <<
" " <<
throughput <<
'\n';
holds a vector of ns3::Application pointers.
keep track of time values and allow control of global simulation resolution
static Ipv4Address GetAny(void)
create HT-enabled MAC layers for a ns3::WifiNetDevice.
A random variable that returns a constantClass ConstantVariable defines a random number generator tha...
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ptr< YansWifiChannel > Create(void) const
void SetRemoteStationManager(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())
static void PopulateRoutingTables(void)
Build a routing database and initialize the routing tables of the nodes in the simulation. Makes all nodes in the simulation into routers.
hold variables of type string
Make it easy to create and manage PHY objects for the yans model.
static YansWifiChannelHelper Default(void)
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container. ...
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())
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
void Set(std::string name, const AttributeValue &v)
static YansWifiPhyHelper Default(void)
hold objects of type ns3::RandomVariable
helps to create WifiNetDevice objects
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
a polymophic address class
static HtWifiMacHelper Default(void)
Class for representing data rates.
Keep track of the current position and velocity of an object.
void SetChannel(Ptr< YansWifiChannel > channel)
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
Create a client application which sends udp packets carrying a 32bit sequence number and a 64 bit tim...
hold objects of type ns3::Time
Hold an unsigned integer type.
holds a vector of ns3::NetDevice pointers
void SetStandard(enum WifiPhyStandard standard)
Create a server application which waits for input udp packets and uses the information carried into t...
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
Parse command-line arguments.
static void Destroy(void)
void SetAttribute(std::string name, const AttributeValue &value)
void SetDefault(std::string name, const AttributeValue &value)
keep track of a set of node pointers.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
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())
manage and create wifi channel objects for the yans model.
void SetPosition(const Vector &position)
Helper class used to assign positions and mobility models to nodes.
hold objects of type ns3::Address
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...
NS_LOG_COMPONENT_DEFINE("PacketLossCounter")
int main(int argc, char *argv[])
ApplicationContainer Install(NodeContainer c)
hold objects of type ns3::DataRate
void AddValue(const std::string &name, const std::string &help, T &value)
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
hold objects of type ns3::Ssid
ApplicationContainer Install(NodeContainer c) const
void Parse(int argc, char *argv[])
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.
static void SetPosition(Ptr< Node > node, Vector position)
Ptr< T > GetObject(void) const
ApplicationContainer Install(NodeContainer c) const
void SetAttribute(std::string name, const AttributeValue &value)
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
static WifiHelper Default(void)