21 #include "ns3/core-module.h"
22 #include "ns3/network-module.h"
23 #include "ns3/mobility-module.h"
24 #include "ns3/stats-module.h"
25 #include "ns3/wifi-module.h"
26 #include "ns3/internet-module.h"
50 uint32_t pktCount,
Time pktInterval );
84 while ((packet = socket->
Recv ()))
93 TypeId tid = TypeId::LookupByName (
"ns3::UdpSocketFactory");
94 Ptr<Socket> sink = Socket::CreateSocket (node, tid);
103 uint32_t pktCount,
Time pktInterval )
107 socket->
Send (Create<Packet> (pktSize));
109 socket, pktSize,pktCount-1, pktInterval);
137 positionAlloc->
Add (
Vector (0.0, 0.0, 0.0));
138 positionAlloc->
Add (
Vector (5.0, 0.0, 0.0));
145 ipv4.
SetBase (
"10.1.1.0",
"255.255.255.0");
150 TypeId tid = TypeId::LookupByName (
"ns3::UdpSocketFactory");
156 uint32_t maxPacketCount = 200;
157 Time interPacketInterval = Seconds (1.);
159 this, source, packetSize, maxPacketCount,interPacketInterval);
162 Simulator::Destroy ();
167 int main (
int argc,
char *argv[])
169 std::ofstream outfile (
"clear-channel.plt");
170 std::vector <std::string> modes;
172 modes.push_back (
"DsssRate1Mbps");
173 modes.push_back (
"DsssRate2Mbps");
174 modes.push_back (
"DsssRate5_5Mbps");
175 modes.push_back (
"DsssRate11Mbps");
181 cmd.
Parse (argc, argv);
185 for (uint32_t i = 0; i < modes.size (); i++)
187 std::cout << modes[i] << std::endl;
190 for (
double rss = -102.0; rss <= -80.0; rss += 0.5)
193 dataset.
SetStyle (Gnuplot2dDataset::LINES);
203 wifiMac.
SetType (
"ns3::AdhocWifiMac");
219 uint32_t pktsRecvd = experiment.
Run (wifi, wifiPhy, wifiMac, wifiChannel);
220 dataset.
Add (rss, pktsRecvd);
225 gnuplot.
SetTerminal (
"postscript eps color enh \"Times-BoldItalic\"");
226 gnuplot.
SetLegend (
"RSS(dBm)",
"Number of packets received");
227 gnuplot.
SetExtra (
"set xrange [-102:-83]");
void AddPropagationLoss(std::string name, 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())
Helper class for UAN CW MAC example.
void experiment(bool enableCtsRts)
Run single 10 seconds experiment with enabled or disabled RTS/CTS mechanism.
void GenerateTraffic(Ptr< Socket > socket, uint32_t pktSize, uint32_t pktCount, Time pktInterval)
keep track of time values and allow control of global simulation resolution
Vector GetPosition(Ptr< Node > node)
Class to represent a 2D points plot.
holds a vector of std::pair of Ptr 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())
hold variables of type string
virtual bool SetAllowBroadcast(bool allowBroadcast)=0
Configure whether broadcast datagram transmissions are allowed.
Make it easy to create and manage PHY objects for the yans model.
NS_LOG_COMPONENT_DEFINE("Main")
static Vector GetPosition(Ptr< Node > node)
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())
static void GenerateTraffic(Ptr< Socket > socket, uint32_t pktSize, Ptr< Node > n, uint32_t pktCount, Time pktInterval)
void ReceivePacket(Ptr< Socket > socket)
aggregate IP/TCP/UDP functionality to existing Nodes.
Vector GetPosition(void) const
void AddDataset(const GnuplotDataset &dataset)
void Set(std::string name, const AttributeValue &v)
helps to create WifiNetDevice objects
void ReceivePacket(Ptr< Socket > socket)
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer c) const
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.
int main(int argc, char *argv[])
a simple class to generate gnuplot-ready plotting commands from a set of datasets.
Gnuplot2dDataset Run(const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, const NqosWifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel, const MobilityHelper &mobility)
holds a vector of ns3::NetDevice pointers
virtual void SetStandard(enum WifiPhyStandard standard)
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
void GenerateOutput(std::ostream &os)
Writes gnuplot commands and data values to a single output stream.
void Add(double x, double y)
void SetRecvCallback(Callback< void, Ptr< Socket > >)
Notify application when new data is available to be read.
create non QoS-enabled MAC layers for a ns3::WifiNetDevice.
Parse command-line arguments.
void SetLegend(const std::string &xLegend, const std::string &yLegend)
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
Ptr< Socket > SetupPacketReceive(Ptr< Node > node)
void SetDefault(std::string name, const AttributeValue &value)
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
keep track of a set of node pointers.
virtual Ptr< Packet > Recv(uint32_t maxSize, uint32_t flags)=0
Read data from the socket.
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
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...
Gnuplot2dDataset m_output
manage and create wifi channel objects for the yans model.
void SetStyle(enum Style style)
void SetExtra(const std::string &extra)
void SetPosition(const Vector &position)
Helper class used to assign positions and mobility models to nodes.
Ipv4 addresses are stored in host order in this class.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
#define NS_LOG_DEBUG(msg)
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.
static void SetPosition(Ptr< Node > node, Vector position)
void SetPropagationDelay(std::string name, 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())
virtual int Send(Ptr< Packet > p, uint32_t flags)=0
Send data (or dummy data) to the remote host.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
virtual int Close(void)=0
Close a socket.
void SetTerminal(const std::string &terminal)
Hold a floating point type.
Ptr< T > GetObject(void) const
void SetPosition(Ptr< Node > node, Vector position)
a unique identifier for an interface.
Ptr< Socket > SetupPacketReceive(Ptr< Node > node)
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.