DESERT 4.0.0
UwFloodingSec Class Reference

#include <uwflooding-sec.h>

Inheritance diagram for UwFloodingSec:
Inheritance graph
Collaboration diagram for UwFloodingSec:
Collaboration graph

Public Member Functions

 UwFloodingSec ()
 
virtual ~UwFloodingSec ()
 

Protected Member Functions

virtual int command (int, const char *const *)
 
virtual void recv (Packet *)
 
virtual int recvSyncClMsg (ClMessage *)
 
virtual int recvAsyncClMsg (ClMessage *)
 
virtual void writePathInTrace (const Packet *, const string &)
 
void addToNeighbor (uint8_t neighbor_addr)
 
void printNeighbor ()
 
bool checkUnconfirmedPkt (uint8_t neighbor_addr, int uid)
 
void sendDown (Packet *p, double delay=0)
 
virtual void sendStatsClMsg (int neighbor_addr)
 
void retrieveInstantNoise (int neighbor_addr)
 

Static Protected Member Functions

static nsaddr_t str2addr (const char *)
 
static string printIP (const nsaddr_t &)
 

Private Types

typedef std::map< uint16_t, double > map_packets
 
typedef std::map< uint8_t, map_packetsmap_forwarded_packets
 
typedef std::map< uint8_t, uint > neighbor_map
 
typedef std::map< uint8_t, NeighborReputationHandlerneighbor_timer_map
 

Private Member Functions

 UwFloodingSec (const UwFloodingSec &)
 
uint8_t getTTL (Packet *p) const
 

Private Attributes

uint8_t ipAddr_
 
int ttl_
 
double maximum_cache_time_
 
int optimize_
 
long packets_forwarded_
 
bool trace_path_
 
char * trace_file_path_name_
 
ofstream trace_file_path_
 
ostringstream osstream_
 
map_forwarded_packets my_forwarded_packets_
 
std::map< uint16_t, uint8_t > ttl_traffic_map
 
bool use_reputation
 
neighbor_map neighbor
 
neighbor_timer_map neighbor_tmr
 
double fwd_to
 
uint8_t prev_hop_temp
 
UwReputationInterface * reputation
 
double alpha_snr
 
bool valid_phy_id
 
int stats_phy_id
 

Friends

class NeighborReputationHandler
 

Detailed Description

UwFloodingSec class is used to represent the routing layer of a node.

Member Typedef Documentation

◆ map_forwarded_packets

typedef std::map<uint8_t, map_packets> UwFloodingSec::map_forwarded_packets
private

Typedef for a map of the packet forwarded (saddr, map_packets).

◆ map_packets

typedef std::map<uint16_t, double> UwFloodingSec::map_packets
private

Typedef for a packet id: (serial_number, timestamp).

◆ neighbor_map

typedef std::map<uint8_t, uint> UwFloodingSec::neighbor_map
private

Typdef for a map of the neighbor with the number of packets received from him.

◆ neighbor_timer_map

Typedef for the forwardig timer of the neigbors.

Constructor & Destructor Documentation

◆ UwFloodingSec() [1/2]

UwFloodingSec::UwFloodingSec ( )

Constructor of UwFloodingSec class.

References alpha_snr, fwd_to, maximum_cache_time_, optimize_, and ttl_.

◆ ~UwFloodingSec()

UwFloodingSec::~UwFloodingSec ( )
virtual

Destructor of UwFloodingSec class.

◆ UwFloodingSec() [2/2]

UwFloodingSec::UwFloodingSec ( const UwFloodingSec )
private

Copy constructor declared as private. It is not possible to create a new UwFloodingSec object passing to its constructor another UwFloodingSec object.

Parameters
UwFloodingSec&UwFloodingSec object.

Member Function Documentation

◆ addToNeighbor()

void UwFloodingSec::addToNeighbor ( uint8_t  neighbor_addr)
protected

Adds a node in the neighbor map, updating the number of packets received from that node

Parameters
neighbor_addrIP address of the neighbor

References alpha_snr, neighbor, neighbor_tmr, NeighborReputationHandler, and reputation.

Referenced by recv(), and sendStatsClMsg().

◆ checkUnconfirmedPkt()

bool UwFloodingSec::checkUnconfirmedPkt ( uint8_t  neighbor_addr,
int  uid 
)
protected

Check if the received packets is an unconfirmed one.

Parameters
neighbor_addrIP address of the neighbor
uiduinique id of the received packet
Returns
true if the packets was between the unchecked, false otherwise

References neighbor_tmr.

Referenced by recvSyncClMsg().

◆ command()

int UwFloodingSec::command ( int  argc,
const char *const *  argv 
)
protectedvirtual

TCL command interpreter. It implements the following OTcl methods:

Parameters
argcNumber of arguments in argv.
argvArray of strings which are the command parameters (Note that argv[0] is the name of the object).
Returns
TCL_OK or TCL_ERROR whether the command has been dispatched successfully or not.

References ipAddr_, packets_forwarded_, printNeighbor(), reputation, stats_phy_id, trace_file_path_, trace_file_path_name_, trace_path_, ttl_traffic_map, use_reputation, and valid_phy_id.

Here is the call graph for this function:

◆ getTTL()

uint8_t UwFloodingSec::getTTL ( Packet *  p) const
private

Get the value of the TTL

Parameters
ppointer to the packet for which the ttl has to be computed.
Returns
the ttl for that packet

References hdr_uwcbr::traffic_type(), ttl_, and ttl_traffic_map.

Referenced by recv().

Here is the call graph for this function:

◆ printIP()

string UwFloodingSec::printIP ( const nsaddr_t &  ip_)
staticprotected

Return a string with an IP in the classic form "x.x.x.x" converting an ns2 nsaddr_t address.

Parameters
nsaddr_t&ns2 address
Returns
String that contains a printable IP in the classic form "x.x.x.x"

◆ printNeighbor()

void UwFloodingSec::printNeighbor ( )
protected

Prints the neighbor list togheter with the number of packets received from the neighbor

References ipAddr_, neighbor, and reputation.

Referenced by command().

◆ recv()

void UwFloodingSec::recv ( Packet *  p)
protectedvirtual

Performs the reception of packets from upper and lower layers.

Parameters
Packet*Pointer to the packet will be received.

References addToNeighbor(), hdr_uwip::daddr(), getTTL(), ipAddr_, maximum_cache_time_, my_forwarded_packets_, optimize_, packets_forwarded_, prev_hop_temp, hdr_uwip::saddr(), sendDown(), trace_path_, hdr_uwflooding::ttl(), use_reputation, and writePathInTrace().

Here is the call graph for this function:

◆ recvAsyncClMsg()

int UwFloodingSec::recvAsyncClMsg ( ClMessage *  m)
protectedvirtual

Cross-Layer messages asynchronous interpreter. Used to retrive the IP od the current node from the IP module.

Parameters
ClMessage*an instance of ClMessage that represent the message received and used for the answer.
Returns
0 if successful.

◆ recvSyncClMsg()

int UwFloodingSec::recvSyncClMsg ( ClMessage *  m)
protectedvirtual

Cross-Layer messages synchronous interpreter.

Parameters
ClMessage*an instance of ClMessage that represent the message received
Returns
0 if successful.

References checkUnconfirmedPkt(), sendStatsClMsg(), and use_reputation.

Here is the call graph for this function:

◆ retrieveInstantNoise()

void UwFloodingSec::retrieveInstantNoise ( int  neighbor_addr)
protected

Send ClMsgStats to retreive instantaneous noise. The ClMsg is sent in unicast only to the module which sent the trigger message

Parameters
neighbor_addrIP address of the neighbor

References UwPhysicalStats::instant_noise_power, neighbor_tmr, stats_phy_id, StatsEnum::STATS_PHY_LAYER, use_reputation, and valid_phy_id.

◆ sendDown()

void UwFloodingSec::sendDown ( Packet *  p,
double  delay = 0 
)
protected

Send down packets and start forwarding timer

Parameters
ppointer to the packet
delay(optional) delay introduced before transmission [sec.]

References hdr_uwip::daddr(), fwd_to, neighbor_tmr, prev_hop_temp, and use_reputation.

Referenced by recv().

Here is the call graph for this function:

◆ sendStatsClMsg()

void UwFloodingSec::sendStatsClMsg ( int  neighbor_addr)
protectedvirtual

Send ClMsgStats message when triggered by the reception of an overherd packets. The ClMsg is sent in unicast only to the module which sent the trigger message

Parameters
neighbor_addrIP address of the neighbor

References addToNeighbor(), UwPhysicalStats::has_error, ipAddr_, UwPhysicalStats::last_interf_power, UwPhysicalStats::last_noise_power, UwPhysicalStats::last_rx_power, neighbor_tmr, stats_phy_id, StatsEnum::STATS_PHY_LAYER, use_reputation, and valid_phy_id.

Referenced by recvSyncClMsg().

Here is the call graph for this function:

◆ str2addr()

static nsaddr_t UwFloodingSec::str2addr ( const char *  )
staticprotected

Returns a nsaddr_t address from an IP written as a string in the form "x.x.x.x".

Parameters
char*IP in string form
Returns
nsaddr_t that contains the IP converter from the input string

◆ writePathInTrace()

void UwFloodingSec::writePathInTrace ( const Packet *  p,
const string &  _info 
)
protectedvirtual

Writes in the Path Trace file the path contained in the Packet

Parameters
Packetto analyze.

References hdr_uwip::daddr(), osstream_, hdr_uwip::saddr(), trace_file_path_, trace_file_path_name_, and hdr_uwflooding::ttl().

Referenced by recv().

Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ NeighborReputationHandler

friend class NeighborReputationHandler
friend

Referenced by addToNeighbor().

Member Data Documentation

◆ alpha_snr

double UwFloodingSec::alpha_snr
private

Value to be used by the NeighborReputationHandler object to combine new snr values and average snr.

Referenced by addToNeighbor(), and UwFloodingSec().

◆ fwd_to

double UwFloodingSec::fwd_to
private

Time out within which the forwarding is expected.

Referenced by sendDown(), and UwFloodingSec().

◆ ipAddr_

◆ maximum_cache_time_

double UwFloodingSec::maximum_cache_time_
private

Validity time of a packet entry.

Referenced by recv(), and UwFloodingSec().

◆ my_forwarded_packets_

map_forwarded_packets UwFloodingSec::my_forwarded_packets_
private

Map of the packet forwarded.

Referenced by recv().

◆ neighbor

neighbor_map UwFloodingSec::neighbor
private

Map with the neighbor.

Referenced by addToNeighbor(), and printNeighbor().

◆ neighbor_tmr

neighbor_timer_map UwFloodingSec::neighbor_tmr
private

Map with the neighbor timer.

Referenced by addToNeighbor(), checkUnconfirmedPkt(), retrieveInstantNoise(), sendDown(), and sendStatsClMsg().

◆ optimize_

int UwFloodingSec::optimize_
private

Flag used to enable the mechanism to drop packets processed twice.

Referenced by recv(), and UwFloodingSec().

◆ osstream_

ostringstream UwFloodingSec::osstream_
private

Used to convert to string.

Referenced by writePathInTrace().

◆ packets_forwarded_

long UwFloodingSec::packets_forwarded_
private

Number of packets forwarded by this module.

Referenced by command(), and recv().

◆ prev_hop_temp

uint8_t UwFloodingSec::prev_hop_temp
private

Previous hop IP address of the last received packet.

Referenced by recv(), and sendDown().

◆ reputation

UwReputationInterface* UwFloodingSec::reputation
private

Reputation of the neighbor.

Referenced by addToNeighbor(), command(), and printNeighbor().

◆ stats_phy_id

int UwFloodingSec::stats_phy_id
private

id of the physical layer from which collect the statistics.

Referenced by command(), retrieveInstantNoise(), and sendStatsClMsg().

◆ trace_file_path_

ofstream UwFloodingSec::trace_file_path_
private

Ofstream used to write the path trace file in the disk.

Referenced by command(), and writePathInTrace().

◆ trace_file_path_name_

char* UwFloodingSec::trace_file_path_name_
private

Name of the trace file that contains the list of paths of the data packets received.

Referenced by command(), and writePathInTrace().

◆ trace_path_

bool UwFloodingSec::trace_path_
private

Flag used to enable or disable the path trace file for nodes,

Referenced by command(), and recv().

◆ ttl_

int UwFloodingSec::ttl_
private

Time to leave of the UWFLOODING packets.

Referenced by getTTL(), and UwFloodingSec().

◆ ttl_traffic_map

std::map<uint16_t, uint8_t> UwFloodingSec::ttl_traffic_map
private

Map with ttl per traffic.

Referenced by command(), and getTTL().

◆ use_reputation

bool UwFloodingSec::use_reputation
private

True if the reputation system is used.

Referenced by command(), recv(), recvSyncClMsg(), retrieveInstantNoise(), sendDown(), and sendStatsClMsg().

◆ valid_phy_id

bool UwFloodingSec::valid_phy_id
private

True if the id of the phy layer from which obtain the statistics is a valid one.

Referenced by command(), retrieveInstantNoise(), and sendStatsClMsg().


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