|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
20 #include "ns3/core-module.h"
21 #include "ns3/internet-module.h"
22 #include "ns3/node-container.h"
23 #include "ns3/mobility-helper.h"
24 #include "ns3/mobility-model.h"
25 #include "ns3/basic-energy-source-helper.h"
26 #include "ns3/energy-source-container.h"
27 #include "ns3/uan-helper.h"
28 #include "ns3/uan-channel.h"
29 #include "ns3/acoustic-modem-energy-model-helper.h"
30 #include "ns3/packet-socket-helper.h"
31 #include "ns3/packet-socket-address.h"
116 mobilityHelper.
Install (m_nodes);
126 energySourceHelper.
Set (
"BasicEnergySourceInitialEnergyJ",
DoubleValue (900000));
127 energySourceHelper.
Install (m_nodes);
138 while (node != m_nodes.End ())
144 acousticModemEnergyModelHelper.
Install (netDeviceContainer, energySourceContainer);
156 uint8_t energyReading;
157 packet->
CopyData (&energyReading, 1);
163 +energyReading <<
"%");
173 while (node != m_nodes.End ())
175 packetSocketHelper.
Install (*node);
180 m_sockets[*node]->Bind ();
181 m_sockets[*node]->Connect (socketAddress);
195 while (node != m_nodes.End ())
197 uint8_t energy = ((*node)->GetObject<
EnergySourceContainer> ()->Get (0)->GetEnergyFraction ()) * 100;
201 double time = uniformRandomVariable->
GetValue (0, 60);
216 m_sockets[node]->SendTo (pkt, 0, socketAddress);
225 SetupCommunications ();
226 SetupApplications ();
233 std::map<Ptr<Node>,
Ptr<Socket> >::iterator socket;
235 for (socket = m_sockets.begin (); socket != m_sockets.end (); socket++)
237 socket->second->Close ();
242 main (
int argc,
char *argv[])
245 cmd.Parse (argc, argv);
holds a vector of ns3::NetDevice pointers
DeviceEnergyModelContainer Install(Ptr< NetDevice > device, Ptr< EnergySource > source) const
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void SetupCommunications()
Set the UAN nodes communication channels.
Parse command-line arguments.
A class used for addressing MAC8 MAC's.
static void SetPosition(Ptr< Node > node, Vector position)
static Mac8Address ConvertFrom(const Address &address)
Convert a generic address to a Mac8Address.
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
void PrintReceivedPacket(Ptr< Socket > socket)
Print the received packet.
UAN configuration helper.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
Iterator Begin(void) const
Get an iterator which refers to the first EnergySource pointer in the container.
an address for a packet socket
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
void Prepare()
Prepare the experiment.
void Set(std::string name, const AttributeValue &v)
void SendPackets()
Send a packet from all the nodes.
Holds a vector of ns3::EnergySource pointers.
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
EnergySourceContainer Install(Ptr< Node > node) const
Ptr< EnergySource > Get(uint32_t i) const
Get the i-th Ptr<EnergySource> stored in this container.
void Teardown()
Teardown the experiment.
void experiment(std::string queue_disc_type)
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
a polymophic address class
Creates a BasicEnergySource object.
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
static bool IsMatchingType(const Address &address)
Check that a generic Address is compatible with Mac8Address.
Time Days(double value)
Construct a Time in the indicated unit.
Address GetPhysicalAddress(void) const
Get the destination address.
void SetupPositions()
Set the UAN nodes position.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
Give ns3::PacketSocket powers to ns3::Node.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
static void Run(void)
Run the simulation.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Assign AcousticModemEnergyModel to uan devices.
Time Seconds(double value)
Construct a Time in the indicated unit.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
void SetPhysicalAddress(const Address address)
Set the destination address.
Keep track of the current position and velocity of an object.
keep track of a set of node pointers.
This example shows the usage of UDP over 6LoWPAN to transfer data.
void SetProtocol(uint16_t protocol)
Set the protocol.
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
Time Hours(double value)
Construct a Time in the indicated unit.
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
void SetupApplications()
Set the UAN nodes communication channels.
NetDeviceContainer Install(NodeContainer c) const
This method creates a simple ns3::UanChannel (with a default ns3::UanNoiseModelDefault and ns3::UanPr...
static TypeId LookupByName(std::string name)
Get a TypeId by name.
void Add(EnergySourceContainer container)
virtual uint32_t GetIfIndex(void) const =0
void SetupEnergy()
Set the UAN nodes energy.
static PacketSocketAddress ConvertFrom(const Address &address)
void SendSinglePacket(Ptr< Node > node, Ptr< Packet > pkt, Ipv6Address dst)
Send a packet from one of the nodes.
Helper class used to assign positions and mobility models to nodes.