40#ifndef UWFLOODINGSEC_H
41#define UWFLOODINGSEC_H
43#define TTL_EQUALS_TO_ZERO \
69#include "uwbase_reputation.h"
91 double alpha_val,
int dbg);
147 virtual void expire(Event *e);
197 virtual int command(
int,
const char *
const *);
315 typedef std::map<uint8_t, map_packets>
Provides the header description for UWFLOODING packets.
This class defines the timer used to check the packet forwarding by the neighbor and handle reputatio...
double inst_noise
Instantaneous noise level.
double avg_snr
Uid of the packet that should be forwarded.
bool addUnconfirmedPkt(int uid, double expire_time)
Add in the map the unconfirmed packets with the corresponidg timeout.
void updateInstantNoise(double inst_noise_val)
Update the value of the instantaneous noise.
std::map< int, double > unconfirmed_pkts
Map with the uid of the unconfirmed packets, with the corresponding forwarding timeout.
bool is_running
True if a timer has been already scheduled and not expired yet.
double alpha
weight for the new SNR value.
virtual void expire(Event *e)
Method called when the timer expire.
virtual ~NeighborReputationHandler()
Class destructor.
void removeOldPackets()
Removes packet with an old expire time.
double last_noise
Boolean variable to check if the packet is the first received one or not.
UwFloodingSec *uint8_t neighbor_addr
< Pointer to the uwflooding module.
void updateChannelMetrics(double val_snr, double last_noise_val)
Update average SNR.
bool getNextPacket(int &uid, double &exp_time) const
Returns as reference the uid of the next packet that id going to expire.
bool checkUnconfirmedPkt(int uid)
Check if the packet with the given uid is an unconfirmed one and set it as confirmed.
UwFloodingSec class is used to represent the routing layer of a node.
double alpha_snr
Value to be used by the NeighborReputationHandler object to combine new snr values and average snr.
std::map< uint8_t, map_packets > map_forwarded_packets
Typedef for a map of the packet forwarded (saddr, map_packets).
void retrieveInstantNoise(int neighbor_addr)
Send ClMsgStats to retreive instantaneous noise.
std::map< uint16_t, double > map_packets
Typedef for a packet id: (serial_number, timestamp).
virtual int recvSyncClMsg(ClMessage *)
Cross-Layer messages synchronous interpreter.
std::map< uint16_t, uint8_t > ttl_traffic_map
Map with ttl per traffic.
double fwd_to
Time out within which the forwarding is expected.
bool valid_phy_id
True if the id of the phy layer from which obtain the statistics is a valid one.
virtual int recvAsyncClMsg(ClMessage *)
Cross-Layer messages asynchronous interpreter.
uint8_t prev_hop_temp
Previous hop IP address of the last received packet.
virtual int command(int, const char *const *)
TCL command interpreter.
neighbor_map neighbor
Map with the neighbor.
int stats_phy_id
id of the physical layer from which collect the statistics.
int optimize_
Flag used to enable the mechanism to drop packets processed twice.
std::map< uint8_t, uint > neighbor_map
Typdef for a map of the neighbor with the number of packets received from him.
ostringstream osstream_
Used to convert to string.
virtual ~UwFloodingSec()
Destructor of UwFloodingSec class.
void addToNeighbor(uint8_t neighbor_addr)
Adds a node in the neighbor map, updating the number of packets received from that node.
neighbor_timer_map neighbor_tmr
Map with the neighbor timer.
virtual void sendStatsClMsg(int neighbor_addr)
Send ClMsgStats message when triggered by the reception of an overherd packets.
int ttl_
Time to leave of the UWFLOODING packets.
virtual void recv(Packet *)
Performs the reception of packets from upper and lower layers.
bool checkUnconfirmedPkt(uint8_t neighbor_addr, int uid)
Check if the received packets is an unconfirmed one.
UwFloodingSec(const UwFloodingSec &)
Copy constructor declared as private.
ofstream trace_file_path_
Ofstream used to write the path trace file in the disk.
UwReputationInterface * reputation
Reputation of the neighbor.
bool use_reputation
True if the reputation system is used.
static nsaddr_t str2addr(const char *)
Returns a nsaddr_t address from an IP written as a string in the form "x.x.x.x".
void printNeighbor()
Prints the neighbor list togheter with the number of packets received from the neighbor.
bool trace_path_
Flag used to enable or disable the path trace file for nodes,.
std::map< uint8_t, NeighborReputationHandler > neighbor_timer_map
Typedef for the forwardig timer of the neigbors.
char * trace_file_path_name_
Name of the trace file that contains the list of paths of the data packets received.
map_forwarded_packets my_forwarded_packets_
Map of the packet forwarded.
long packets_forwarded_
Number of packets forwarded by this module.
virtual void writePathInTrace(const Packet *, const string &)
Writes in the Path Trace file the path contained in the Packet.
UwFloodingSec()
Constructor of UwFloodingSec class.
double maximum_cache_time_
Validity time of a packet entry.
uint8_t getTTL(Packet *p) const
Get the value of the TTL.
void sendDown(Packet *p, double delay=0)
Send down packets and start forwarding timer.
static string printIP(const nsaddr_t &)
Return a string with an IP in the classic form "x.x.x.x" converting an ns2 nsaddr_t address.
Provides the UWCBR packets header description and the definition of the class UWCBR.
Cross layer messages definition for the UWIP Module.
Provides the UWIP packets header description. Definition of the class that define the network layer.