DESERT 3.5.1
Loading...
Searching...
No Matches
NeighborReputationHandler Class Reference

#include <uwflooding-sec.h>

Inheritance diagram for NeighborReputationHandler:
Collaboration diagram for NeighborReputationHandler:

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.

Definition at line 79 of file uwflooding-sec.h.

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

Definition at line 83 of file uwflooding-sec.cpp.

◆ ~NeighborReputationHandler()

NeighborReputationHandler::~NeighborReputationHandler ( )
virtual

Class destructor.

Definition at line 99 of file uwflooding-sec.cpp.

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

Definition at line 104 of file uwflooding-sec.cpp.

◆ 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

Definition at line 136 of file uwflooding-sec.cpp.

◆ expire()

void NeighborReputationHandler::expire ( Event *  e)
protectedvirtual

Method called when the timer expire.

Parameters
Event*pointer to an object of type Event

Definition at line 177 of file uwflooding-sec.cpp.

◆ 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.

Definition at line 217 of file uwflooding-sec.cpp.

◆ removeOldPackets()

void NeighborReputationHandler::removeOldPackets ( )
protected

Removes packet with an old expire time.

Definition at line 239 of file uwflooding-sec.cpp.

◆ 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

Definition at line 262 of file uwflooding-sec.cpp.

◆ updateInstantNoise()

void NeighborReputationHandler::updateInstantNoise ( double  inst_noise_val)

Update the value of the instantaneous noise.

Parameters
inst_noise_valvalue of the instantaneous noise

Definition at line 281 of file uwflooding-sec.cpp.

Member Data Documentation

◆ alpha

double NeighborReputationHandler::alpha
protected

weight for the new SNR value.

Definition at line 157 of file uwflooding-sec.h.

◆ avg_snr

double NeighborReputationHandler::avg_snr
protected

Uid of the packet that should be forwarded.

Average SNR of the last received packets.

Definition at line 156 of file uwflooding-sec.h.

◆ debug

int NeighborReputationHandler::debug
protected

Definition at line 162 of file uwflooding-sec.h.

◆ inst_noise

double NeighborReputationHandler::inst_noise
protected

Instantaneous noise level.

Definition at line 161 of file uwflooding-sec.h.

◆ is_first_pkt

bool NeighborReputationHandler::is_first_pkt
protected

Definition at line 158 of file uwflooding-sec.h.

◆ is_running

bool NeighborReputationHandler::is_running
protected

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

Definition at line 153 of file uwflooding-sec.h.

◆ 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.

Definition at line 160 of file uwflooding-sec.h.

◆ neighbor_addr

UwFloodingSec* uint8_t NeighborReputationHandler::neighbor_addr
protected

< Pointer to the uwflooding module.

Address of the considered neighbor.

Definition at line 150 of file uwflooding-sec.h.

◆ unconfirmed_pkts

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

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

Definition at line 151 of file uwflooding-sec.h.

◆ waiting_uid

int NeighborReputationHandler::waiting_uid
protected

Definition at line 155 of file uwflooding-sec.h.


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