A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
energy-model-with-harvesting-example.cc File Reference
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/mobility-module.h"
#include "ns3/config-store-module.h"
#include "ns3/wifi-module.h"
#include "ns3/energy-module.h"
#include "ns3/internet-module.h"
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
+ Include dependency graph for energy-model-with-harvesting-example.cc:

Go to the source code of this file.

Functions

static void GenerateTraffic (Ptr< Socket > socket, uint32_t pktSize, Ptr< Node > n, uint32_t pktCount, Time pktInterval)
 
void HarvestedPower (double oldValue, double harvestedPower)
 Trace function for the power harvested by the energy harvester. More...
 
int main (int argc, char *argv[])
 
static std::string PrintReceivedPacket (Address &from)
 
void ReceivePacket (Ptr< Socket > socket)
 
void RemainingEnergy (double oldValue, double remainingEnergy)
 Trace function for remaining energy at node. More...
 
void TotalEnergy (double oldValue, double totalEnergy)
 Trace function for total energy consumption at node. More...
 
void TotalEnergyHarvested (double oldValue, double TotalEnergyHarvested)
 Trace function for the total energy harvested by the node. More...
 

Function Documentation

static void GenerateTraffic ( Ptr< Socket socket,
uint32_t  pktSize,
Ptr< Node n,
uint32_t  pktCount,
Time  pktInterval 
)
static
Parameters
socketPointer to socket.
pktSizePacket size.
nPointer to node.
pktCountNumber of packets to generate.
pktIntervalPacket sending interval.

Traffic generator.

Definition at line 110 of file energy-model-with-harvesting-example.cc.

References ns3::Socket::Close(), ns3::Simulator::Schedule(), and ns3::Socket::Send().

Referenced by main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void HarvestedPower ( double  oldValue,
double  harvestedPower 
)

Trace function for the power harvested by the energy harvester.

Definition at line 143 of file energy-model-with-harvesting-example.cc.

References ns3::Time::GetSeconds(), and ns3::Simulator::Now().

Referenced by main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

Wifi PHY

wifi channel

MAC layer

install PHY + MAC

mobility

Energy Model

Internet stack

connect trace sources

simulation setup

Definition at line 160 of file energy-model-with-harvesting-example.cc.

References ns3::ListPositionAllocator::Add(), ns3::NodeContainer::Add(), ns3::YansWifiChannelHelper::AddPropagationLoss(), ns3::CommandLine::AddValue(), ns3::Ipv4AddressHelper::Assign(), ns3::Socket::Bind(), ns3::Socket::Connect(), ns3::YansWifiChannelHelper::Create(), ns3::NodeContainer::Create(), ns3::Socket::CreateSocket(), ns3::NqosWifiMacHelper::Default(), ns3::YansWifiPhyHelper::Default(), ns3::Simulator::Destroy(), first::devices, ns3::WifiHelper::EnableLogComponents(), ns3::EnergySource::FindDeviceEnergyModels(), GenerateTraffic(), ns3::DeviceEnergyModelContainer::Get(), ns3::EnergySourceContainer::Get(), ns3::EnergyHarvesterContainer::Get(), ns3::NodeContainer::Get(), ns3::Ipv4Address::GetAny(), ns3::Ipv4Address::GetBroadcast(), HarvestedPower(), ns3::EnergyHarvesterHelper::Install(), ns3::EnergySourceHelper::Install(), ns3::InternetStackHelper::Install(), ns3::DeviceEnergyModelHelper::Install(), ns3::WifiHelper::Install(), ns3::MobilityHelper::Install(), ns3::TypeId::LookupByName(), ns3::MakeCallback(), NS_ASSERT, NS_LOG_INFO, ns3::CommandLine::Parse(), ReceivePacket(), RemainingEnergy(), ns3::Simulator::Run(), ns3::Simulator::Schedule(), ns3::Seconds(), ns3::BasicEnergySourceHelper::Set(), ns3::BasicEnergyHarvesterHelper::Set(), ns3::WifiRadioEnergyModelHelper::Set(), ns3::YansWifiPhyHelper::Set(), ns3::Socket::SetAllowBroadcast(), ns3::Ipv4AddressHelper::SetBase(), ns3::YansWifiPhyHelper::SetChannel(), ns3::Config::SetDefault(), ns3::MobilityHelper::SetMobilityModel(), ns3::MobilityHelper::SetPositionAllocator(), ns3::YansWifiChannelHelper::SetPropagationDelay(), ns3::Socket::SetRecvCallback(), ns3::WifiHelper::SetRemoteStationManager(), ns3::WifiHelper::SetStandard(), ns3::NqosWifiMacHelper::SetType(), startTime, ns3::Simulator::Stop(), TotalEnergy(), TotalEnergyHarvested(), ns3::ObjectBase::TraceConnectWithoutContext(), verbose, and ns3::WIFI_PHY_STANDARD_80211b.

static std::string PrintReceivedPacket ( Address from)
inlinestatic

Definition at line 68 of file energy-model-with-harvesting-example.cc.

References ns3::InetSocketAddress::ConvertFrom(), ns3::InetSocketAddress::GetIpv4(), ns3::InetSocketAddress::GetPort(), ns3::Time::GetSeconds(), and ns3::Simulator::Now().

Referenced by ReceivePacket().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ReceivePacket ( Ptr< Socket socket)
Parameters
socketPointer to socket.

Packet receiving sink.

Definition at line 87 of file energy-model-with-harvesting-example.cc.

References ns3::Packet::GetSize(), NS_LOG_UNCOND, PrintReceivedPacket(), and ns3::Socket::RecvFrom().

Referenced by main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RemainingEnergy ( double  oldValue,
double  remainingEnergy 
)

Trace function for remaining energy at node.

Definition at line 127 of file energy-model-with-harvesting-example.cc.

References ns3::Time::GetSeconds(), and ns3::Simulator::Now().

Referenced by main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void TotalEnergy ( double  oldValue,
double  totalEnergy 
)

Trace function for total energy consumption at node.

Definition at line 135 of file energy-model-with-harvesting-example.cc.

References ns3::Time::GetSeconds(), and ns3::Simulator::Now().

Referenced by main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void TotalEnergyHarvested ( double  oldValue,
double  TotalEnergyHarvested 
)

Trace function for the total energy harvested by the node.

Definition at line 151 of file energy-model-with-harvesting-example.cc.

References ns3::Time::GetSeconds(), and ns3::Simulator::Now().

Referenced by main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function: