19 #include "ns3/acoustic-modem-energy-model-helper.h"
20 #include "ns3/basic-energy-source-helper.h"
21 #include "ns3/core-module.h"
22 #include "ns3/energy-source-container.h"
23 #include "ns3/internet-module.h"
24 #include "ns3/mobility-helper.h"
25 #include "ns3/mobility-model.h"
26 #include "ns3/node-container.h"
27 #include "ns3/uan-channel.h"
28 #include "ns3/uan-helper.h"
111 mobilityHelper.
Install(m_nodes);
112 m_nodes.Get(0)->GetObject<
MobilityModel>()->SetPosition(Vector(0, 0, 0));
121 energySourceHelper.
Set(
"BasicEnergySourceInitialEnergyJ",
DoubleValue(900000));
122 energySourceHelper.
Install(m_nodes);
132 auto node = m_nodes.
Begin();
133 while (node != m_nodes.End())
139 acousticModemEnergyModelHelper.
Install(netDeviceContainer, energySourceContainer);
142 internetStackHelper.
Install(m_nodes);
146 ipv6AddressHelper.
Assign(netDeviceContainer);
148 node = m_nodes.
Begin();
149 while (node != m_nodes.End())
167 uint8_t energyReading;
168 packet->
CopyData(&energyReading, 1);
175 <<
" | Energy: " << +energyReading <<
"%");
183 auto node = m_nodes.Begin();
184 while (node != m_nodes.End())
188 if ((*node)->GetObject<
Ipv6>())
191 m_sockets[*node]->Bind(ipv6_local);
204 auto node = m_nodes.Begin();
208 while (node != m_nodes.End())
215 double time = uniformRandomVariable->
GetValue(0, 60);
226 <<
" packet sent to " << dst);
228 m_sockets[node]->SendTo(pkt, 0, ipv6_destination);
237 SetupCommunications();
245 for (
auto socket = m_sockets.begin(); socket != m_sockets.end(); socket++)
247 socket->second->
Close();
252 main(
int argc,
char* argv[])
255 cmd.Parse(argc, argv);
This example shows the usage of UDP over 6LoWPAN to transfer data.
void Teardown()
Teardown the experiment.
void PrintReceivedPacket(Ptr< Socket > socket)
Print the received packet.
void Prepare()
Prepare the experiment.
void SendSinglePacket(Ptr< Node > node, Ptr< Packet > pkt, Ipv6Address dst)
Send a packet from one of the nodes.
void SendPackets()
Send a packet from all the nodes.
void SetupCommunications()
Set the UAN nodes communication channels.
void SetupPositions()
Set the UAN nodes position.
void SetupApplications()
Set the UAN nodes communication channels.
void SetupEnergy()
Set the UAN nodes energy.
Assign AcousticModemEnergyModel to uan devices.
a polymophic address class
Creates a BasicEnergySource object.
void Set(std::string name, const AttributeValue &v) override
Parse command-line arguments.
DeviceEnergyModelContainer Install(Ptr< NetDevice > device, Ptr< EnergySource > source) const
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Holds a vector of ns3::EnergySource pointers.
Ptr< EnergySource > Get(uint32_t i) const
Get the i-th Ptr<EnergySource> stored in this container.
Iterator Begin() const
Get an iterator which refers to the first EnergySource pointer in the container.
void Add(EnergySourceContainer container)
EnergySourceContainer Install(Ptr< Node > node) const
An implementation of the ICMPv6 protocol.
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress.
static bool IsMatchingType(const Address &addr)
If the address match.
aggregate IP/TCP/UDP functionality to existing Nodes.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
Helper class to auto-assign global IPv6 unicast addresses.
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
Describes an IPv6 address.
static Ipv6Address GetAny()
Get the "any" (::) Ipv6Address.
static Ipv6Address ConvertFrom(const Address &address)
Convert the Address object into an Ipv6Address ones.
Access to the IPv6 forwarding table, interfaces, and configuration.
Ipv6Address GetAddress() const
Get the IPv6 address.
Iterator Begin() const
Get an iterator which refers to the first pair in the container.
IPv6 layer implementation.
Ipv6InterfaceAddress GetAddress(uint32_t interfaceIndex, uint32_t addressIndex) const override
Get an address.
Describes an IPv6 prefix.
Helper class used to assign positions and mobility models to nodes.
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
void SetMobilityModel(std::string type, Ts &&... args)
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.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
virtual uint32_t GetRxAvailable() const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
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...
virtual int Close()=0
Close a socket.
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.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
UAN configuration helper.
NetDeviceContainer Install(NodeContainer c) const
This method creates a simple ns3::UanChannel (with a default ns3::UanNoiseModelDefault and ns3::UanPr...
void experiment(std::string queue_disc_type)
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time Days(double value)
Construct a Time in the indicated unit.
Time Hours(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...