DESERT 4.0.0
NeighborReputationHandler Class Reference

#include <uwflooding-sec.h>

Inheritance diagram for NeighborReputationHandler:
Inheritance graph
Collaboration diagram for NeighborReputationHandler:
Collaboration graph

Public Member Functions

 NeighborReputationHandler (uint8_t neigh_addr, UwFloodingSec *m, double alpha_val, int dbg)
 
virtual ~NeighborReputationHandler ()
 
bool addUnconfirmedPkt (int uid, double expire_time)
 
bool checkUnconfirmedPkt (int uid)
 
void updateChannelMetrics (double val_snr, double last_noise_val)
 
void updateInstantNoise (double inst_noise_val)
 

Protected Member Functions

bool getNextPacket (int &uid, double &exp_time) const
 
void removeOldPackets ()
 
virtual void expire (Event *e)
 

Protected Attributes

UwFloodingSec *uint8_t neighbor_addr
 
std::map< int, double > unconfirmed_pkts
 
bool is_running
 
int waiting_uid
 
double avg_snr
 
double alpha
 
bool is_first_pkt
 
double last_noise
 
double inst_noise
 
int debug
 

Detailed Description

This class defines the timer used to check the packet forwarding by the neighbor and handle reputation

Constructor & Destructor Documentation

◆ NeighborReputationHandler()

NeighborReputationHandler::NeighborReputationHandler ( uint8_t  neigh_addr,
UwFloodingSec m,
double  alpha_val,
int  dbg 
)

Class constructor

Parameters
neigh_addraddress of the neighbor
mpointer to the UwFloding module
alpha_valparamer to be used to combine new and old snr values
dbgdebug variable

◆ ~NeighborReputationHandler()

NeighborReputationHandler::~NeighborReputationHandler ( )
virtual

Class destructor

Member Function Documentation

◆ addUnconfirmedPkt()

bool NeighborReputationHandler::addUnconfirmedPkt ( int  uid,
double  expire_time 
)

Add in the map the unconfirmed packets with the corresponidg timeout

Parameters
uidunique id of the analyzed packet
expire_timeexpire time for the forwarding of neighbor
Returns
true if the packet is correctly inserted, false oterwhise

References debug, UwFloodingSec::ipAddr_, is_running, neighbor_addr, unconfirmed_pkts, and waiting_uid.

◆ checkUnconfirmedPkt()

bool NeighborReputationHandler::checkUnconfirmedPkt ( int  uid)

Check if the packet with the given uid is an unconfirmed one and set it as confirmed

Parameters
uidunique id if the analyzed packet
Returns
true if the packet is present, false otherwise

References avg_snr, debug, getNextPacket(), inst_noise, is_running, last_noise, neighbor_addr, unconfirmed_pkts, and waiting_uid.

Here is the call graph for this function:

◆ expire()

void NeighborReputationHandler::expire ( Event *  e)
protectedvirtual

Method called when the timer expire

Parameters
Event*pointer to an object of type Event

References avg_snr, debug, getNextPacket(), inst_noise, UwFloodingSec::ipAddr_, is_running, last_noise, neighbor_addr, removeOldPackets(), unconfirmed_pkts, and waiting_uid.

Here is the call graph for this function:

◆ getNextPacket()

bool NeighborReputationHandler::getNextPacket ( int &  uid,
double &  exp_time 
) const
protected

Returns as reference the uid of the next packet that id going to expire. Returns false if there are no packets in the map.

Parameters
uidunique id of the next packet that is going to expire.
exp_timeexpire time of the next packet that is going to expire.
Returns
false if there is no packets in the map, true otherwise.

References unconfirmed_pkts.

Referenced by checkUnconfirmedPkt(), and expire().

◆ removeOldPackets()

void NeighborReputationHandler::removeOldPackets ( )
protected

Removes packet with an old expire time.

References avg_snr, debug, inst_noise, UwFloodingSec::ipAddr_, last_noise, neighbor_addr, and unconfirmed_pkts.

Referenced by expire().

◆ updateChannelMetrics()

void NeighborReputationHandler::updateChannelMetrics ( double  val_snr,
double  last_noise_val 
)

Update average SNR

Parameters
val_snrnew SNR value
last_noise_valvalue of the noise for the last received packet

References alpha, avg_snr, debug, inst_noise, is_first_pkt, last_noise, and neighbor_addr.

◆ updateInstantNoise()

void NeighborReputationHandler::updateInstantNoise ( double  inst_noise_val)

Update the value of the instantaneous noise

Parameters
inst_noise_valvalue of the instantaneous noise

References debug, inst_noise, UwFloodingSec::ipAddr_, last_noise, and neighbor_addr.

Member Data Documentation

◆ alpha

double NeighborReputationHandler::alpha
protected

weight for the new SNR value.

Referenced by updateChannelMetrics().

◆ avg_snr

double NeighborReputationHandler::avg_snr
protected

Uid of the packet that should be forwarded. Average SNR of the last received packets.

Referenced by checkUnconfirmedPkt(), expire(), removeOldPackets(), and updateChannelMetrics().

◆ debug

int NeighborReputationHandler::debug
protected

◆ inst_noise

double NeighborReputationHandler::inst_noise
protected

◆ is_first_pkt

bool NeighborReputationHandler::is_first_pkt
protected

Referenced by updateChannelMetrics().

◆ is_running

bool NeighborReputationHandler::is_running
protected

True if a timer has been already scheduled and not expired yet.

Referenced by addUnconfirmedPkt(), checkUnconfirmedPkt(), and expire().

◆ last_noise

double NeighborReputationHandler::last_noise
protected

Boolean variable to check if the packet is the first received one or not. Used to correctly averaged snr. Noise power of the last correctly received packet.

Referenced by checkUnconfirmedPkt(), expire(), removeOldPackets(), updateChannelMetrics(), and updateInstantNoise().

◆ neighbor_addr

UwFloodingSec* uint8_t NeighborReputationHandler::neighbor_addr
protected

< Pointer to the uwflooding module. Address of the considered neighbor.

Referenced by addUnconfirmedPkt(), checkUnconfirmedPkt(), expire(), removeOldPackets(), updateChannelMetrics(), and updateInstantNoise().

◆ unconfirmed_pkts

std::map<int, double> NeighborReputationHandler::unconfirmed_pkts
protected

Map with the uid of the unconfirmed packets, with the corresponding forwarding timeout.

Referenced by addUnconfirmedPkt(), checkUnconfirmedPkt(), expire(), getNextPacket(), and removeOldPackets().

◆ waiting_uid

int NeighborReputationHandler::waiting_uid
protected

The documentation for this class was generated from the following files: