A Discrete-Event Network Simulator
API
Functions
energy-model-example.cc File Reference
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/mobility-module.h"
#include "ns3/config-store-module.h"
#include "ns3/energy-module.h"
#include "ns3/internet-module.h"
#include "ns3/yans-wifi-helper.h"
#include "ns3/wifi-radio-energy-model-helper.h"

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)
 
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

◆ GenerateTraffic()

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(), sample-rng-plot::n, ns3::Simulator::Schedule(), and ns3::Socket::Send().

◆ PrintReceivedPacket()

static std::string PrintReceivedPacket ( Address from)
inlinestatic

◆ ReceivePacket()

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().

◆ RemainingEnergy()

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.

◆ TotalEnergy()

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.