A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
energy-model-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-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)
 
int main (int argc, char *argv[])
 
 NS_LOG_COMPONENT_DEFINE ("EnergyExample")
 
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...
 

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 81 of file energy-model-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:

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 113 of file energy-model-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::NodeContainer::Get(), ns3::Ipv4Address::GetAny(), ns3::Ipv4Address::GetBroadcast(), 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::BasicEnergySourceHelper::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(), ns3::ObjectBase::TraceConnectWithoutContext(), verbose, and ns3::WIFI_PHY_STANDARD_80211b.

NS_LOG_COMPONENT_DEFINE ( "EnergyExample"  )
static std::string PrintReceivedPacket ( Address from)
inlinestatic

Definition at line 39 of file energy-model-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 58 of file energy-model-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 98 of file energy-model-example.cc.

References ns3::Simulator::Now(), and NS_LOG_UNCOND.

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 106 of file energy-model-example.cc.

References ns3::Simulator::Now(), and NS_LOG_UNCOND.

Referenced by main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function: