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" 53 void SetupPositions ();
63 void SetupCommunications ();
68 void SetupApplications ();
114 mobilityHelper.
Install (m_nodes);
124 energySourceHelper.
Set (
"BasicEnergySourceInitialEnergyJ",
DoubleValue (900000));
125 energySourceHelper.
Install (m_nodes);
136 while (node != m_nodes.End ())
142 acousticModemEnergyModelHelper.
Install (netDeviceContainer, energySourceContainer);
145 internetStackHelper.
Install (m_nodes);
148 ipv4AddressHelper.
SetBase (
"10.0.0.0",
"255.255.255.0");
149 ipv4AddressHelper.
Assign (netDeviceContainer);
150 node = m_nodes.
Begin ();
151 while (node != m_nodes.End ())
153 (*node)->GetObject<
Ipv4L3Protocol> ()->GetInterface (1)->GetArpCache ()->SetWaitReplyTimeout (
Seconds (10));
165 uint8_t energyReading;
166 packet->
CopyData (&energyReading, 1);
172 +energyReading <<
"%");
181 while (node != m_nodes.End ())
184 if((*node)->GetObject<
Ipv4> () != NULL)
187 m_sockets[*node]->Bind (ipv4_local);
203 while (node != m_nodes.End ())
205 uint8_t energy = ((*node)->GetObject<
EnergySourceContainer> ()->Get (0)->GetEnergyFraction ()) * 100;
209 double time = uniformRandomVariable->
GetValue (0, 60);
221 m_sockets[node]->SendTo (pkt, 0, ipv4_destination);
230 SetupCommunications ();
231 SetupApplications ();
238 std::map<Ptr<Node>,
Ptr<Socket> >::iterator socket;
240 for (socket = m_sockets.begin (); socket != m_sockets.end (); socket++)
242 socket->second->Close ();
247 main (
int argc,
char *argv[])
250 cmd.Parse (argc, argv);
UAN configuration helper.
static std::string PrintReceivedPacket(Address &from)
static Ipv4Address GetAny(void)
Holds a vector of ns3::EnergySource pointers.
void Add(EnergySourceContainer container)
void SendSinglePacket(Ptr< Node > node, Ptr< Packet > pkt, Ipv6Address dst)
Send a packet from one of the nodes.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
static void Run(void)
Run the simulation.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
aggregate IP/TCP/UDP functionality to existing Nodes.
Assign AcousticModemEnergyModel to uan devices.
static void SetPosition(Ptr< Node > node, Vector position)
a polymophic address class
Keep track of the current position and velocity of an object.
static EventId Schedule(Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event to expire after delay.
void Prepare()
Prepare the experiment.
Creates a BasicEnergySource object.
holds a vector of ns3::NetDevice pointers
void SetupEnergy()
Set the UAN nodes energy.
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
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...
Parse command-line arguments.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
Iterator Begin(void) const
Get an iterator which refers to the first EnergySource pointer in the container.
void Teardown()
Teardown the experiment.
Access to the IPv4 forwarding table, interfaces, and configuration.
Implement the IPv4 layer.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
keep track of a set of node pointers.
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())
#define NS_LOG_UNCOND(msg)
Output the requested message unconditionally.
Time Hours(double value)
Construct a Time in the indicated unit.
void PrintReceivedPacket(Ptr< Socket > socket)
Print the received packet.
static Time Now(void)
Return the current simulation virtual time.
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
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 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...
EnergySourceContainer Install(Ptr< Node > node) const
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
uint32_t CopyData(uint8_t *buffer, uint32_t size) const
Copy the packet contents to a byte buffer.
Time Seconds(double value)
Construct a Time in the indicated unit.
void Set(std::string name, const AttributeValue &v)
Ipv4InterfaceAddress GetAddress(uint32_t interfaceIndex, uint32_t addressIndex) const
Because addresses can be removed, the addressIndex is not guaranteed to be static across calls to thi...
Ipv4Address GetLocal(void) const
Get the local address.
void SetupApplications()
Set the UAN nodes communication channels.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
This example shows the usage of UDP over 6LoWPAN to transfer data.
void SendPackets()
Send a packet from all the nodes.
Ptr< EnergySource > Get(uint32_t i) const
Get the i-th Ptr<EnergySource> stored in this container.
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.
Time Days(double value)
Construct a Time in the indicated unit.
void SetupPositions()
Set the UAN nodes position.
This class can be used to hold variables of floating point type such as 'double' or 'float'...
void SetupCommunications()
Set the UAN nodes communication channels.
static bool IsMatchingType(const Address &address)
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Iterator Begin(void) const
Get an iterator which refers to the first pair in the container.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
virtual uint32_t GetRxAvailable(void) const =0
Return number of bytes which can be returned from one or multiple calls to Recv.
DeviceEnergyModelContainer Install(Ptr< NetDevice > device, Ptr< EnergySource > source) const
void experiment(bool enableCtsRts, std::string wifiManager)
Run single 10 seconds experiment.