DESERT 4.0.0
SunIPRoutingNode Class Reference

#include <sun-ipr-node.h>

Inheritance diagram for SunIPRoutingNode:
Inheritance graph
Collaboration diagram for SunIPRoutingNode:
Collaboration graph

Public Member Functions

 SunIPRoutingNode ()
 
virtual ~SunIPRoutingNode ()
 

Static Public Attributes

static const int LISTLENGTH = 30
 
static const int MINUTE
 

Protected Types

enum  { HOPCOUNT = 1 , SNR , LESSCONGESTED }
 

Protected Member Functions

virtual int command (int, const char *const *)
 
virtual void recv (Packet *)
 
virtual int recvSyncClMsg (ClMessage *)
 
virtual int recvAsyncClMsg (ClMessage *)
 
virtual void clearHops ()
 
virtual void initialize ()
 
virtual void printHopTable () const
 
virtual void printSelectedRoutes () const
 
const long & getNPathsEstablished ()
 
const double getDelay (const double &period_) const
 
const bool isZero (const double &value) const
 
virtual const int & setNumberOfHopToSink (const int &)
 
virtual const int & getNumberOfHopToSink () const
 
virtual void receiveProbe (const Packet *)
 
virtual void searchPath ()
 
virtual void initPktPathEstSearch (Packet *) const
 
virtual void replyPathEstSearch (Packet *)
 
virtual const bool addMyIpInList (Packet *)
 
virtual const bool isMyIpInList (const Packet *) const
 
virtual void updateQuality (Packet *)
 
virtual void answerPath (const Packet *)
 
virtual void initPktPathEstAnswer (Packet *, const Packet *)
 
virtual void sendRouteBack (Packet *)
 
virtual const int & evaluatePath (const Packet *)
 
virtual void initPktDataPacket (Packet *)
 
virtual void forwardDataPacket (Packet *)
 
virtual void sendBackAck (const Packet *)
 
virtual void initPktAck (Packet *)
 
virtual void createRouteError (const Packet *, Packet *)
 
virtual void sendRouteErrorBack (Packet *)
 
virtual void updatePacketsCount ()
 
virtual void updateAcksCount ()
 
virtual const int getPacketsLastMinute () const
 
virtual const int getAcksLastMinute () const
 
virtual const double getLoad () const
 
virtual void bufferManager ()
 
const long & getAckCount () const
 
const long & getDataCount () const
 
const long & getForwardedCount () const
 
const long & getDataDropsCountBuffer () const
 
const long & getDataDropsCountMaxRetx () const
 
const long & getPathEstablishmentCount () const
 
virtual void expTimerHopTable ()
 
virtual void lostSink ()
 
virtual void searchPathExpire ()
 
virtual void tracePacket (const Packet *const, const string &position="UNDEF___")
 
virtual string createTraceString (const string &, const double &, const int &, const int &, const int &, const int &, const int &, const int &, const int &, const double &, const int &, const int &)
 
virtual void writeInTrace (const string &)
 

Static Protected Member Functions

static string printIP (const nsaddr_t &)
 
static string printIP (const ns_addr_t &)
 
static nsaddr_t str2addr (const char *)
 
static const int getAckHeaderSize ()
 
static const int getDataPktHeaderSize ()
 
static const int getPathEstHeaderSize ()
 

Protected Attributes

nsaddr_t ipAddr_
 
int metrics_
 
int PoissonTraffic_
 
double period_status_
 
double period_data_
 
int num_hop_to_sink
 
double quality_link
 
nsaddr_t * hop_table
 
int hop_table_length
 
nsaddr_t sink_associated
 
int printDebug_
 
double probe_min_snr_
 
double snr_to_sink_
 
bool search_path_enable_
 
int disable_path_error_
 
int reset_buffer_if_error_
 
double list_packets [LISTLENGTH]
 
double list_acks [LISTLENGTH]
 
int pointer_packets_
 
int pointer_acks_
 
long list_packets_max_time_
 
long list_acks_max_time_
 
bool packets_array_full
 
bool acks_array_full
 
double alpha_
 
int max_ack_error_
 
int ack_warnings_counter_
 
bool ack_error_state
 
vector< buffer_elementbuffer_data
 
uint32_t buffer_max_size_
 
long pkt_stored_
 
long pkt_tx_
 
int safe_timer_buffer_
 
double timer_route_validity_
 
double timer_sink_probe_validity_
 
double timer_buffer_
 
double timer_search_path_
 
RemoveHopTableTimer rmhopTableTmr_
 
SinkProbeTimer sinkProbeTimer_
 
BufferTimer bufferTmr_
 
SearchPathTimer searchPathTmr_
 
bool trace_
 
char * trace_file_name_
 
ostringstream osstream_
 
ofstream trace_file_
 
char trace_separator_
 
int data_and_hops [MAX_HOP_NUMBER]
 
std::map< uint8_t, uint > paths_selected
 
long n_paths_established
 
uint max_retx_
 

Static Protected Attributes

static long number_of_pathestablishment_ = 0
 
static long number_of_datapkt_ = 0
 
static long number_of_ackpkt_ = 0
 
static long number_of_drops_buffer_full_ = 0
 
static long number_of_drops_maxretx_ = 0
 
static long number_of_pkt_forwarded_ = 0
 

Private Member Functions

 SunIPRoutingNode (const SunIPRoutingNode &)
 

Friends

class RemoveHopTableTimer
 
class AckWaiting
 
class SinkProbeTimer
 
class BufferTimer
 
class SearchPathTimer
 

Detailed Description

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

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
HOPCOUNT 
SNR 
LESSCONGESTED 

Constructor & Destructor Documentation

◆ SunIPRoutingNode() [1/2]

◆ ~SunIPRoutingNode()

SunIPRoutingNode::~SunIPRoutingNode ( )
virtual

Destructor of SunIPRoutingNode class.

References getNumberOfHopToSink(), hop_table, ipAddr_, printDebug_, printIP(), and trace_file_name_.

Here is the call graph for this function:

◆ SunIPRoutingNode() [2/2]

SunIPRoutingNode::SunIPRoutingNode ( const SunIPRoutingNode )
private

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

Parameters
SunIPRoutingNode&SunIPRoutingNode object.

Member Function Documentation

◆ addMyIpInList()

const bool SunIPRoutingNode::addMyIpInList ( Packet *  p)
protectedvirtual

Adds the IP of the current node in the header of a Path Establishment packet passed as argument. It can do it if there is at least one free block. The function returns true if it added the IP, false otherwise.

Parameters
Packet*Pointer to a Path Establishment Search packet in which to add an IP.
Returns
true if the IP was added, false otherwise.

References ipAddr_, hdr_sun_path_est::list_of_hops(), hdr_sun_path_est::list_of_hops_length(), and hdr_sun_path_est::pointer().

Referenced by replyPathEstSearch().

Here is the call graph for this function:

◆ answerPath()

void SunIPRoutingNode::answerPath ( const Packet *  p_old)
protectedvirtual

Creates and sends an Path Establishment Answer packet.

Parameters
Packet*Pointer to a Path Establishment packet with the option field set to Search.
See also
SunIPRoutingNode::getNumberOfHopToSink()
SunIPRoutingNode::initPktPathEstAnswer(Packet*, const Packet*)

References getDelay(), getNumberOfHopToSink(), initPktPathEstAnswer(), ipAddr_, hdr_sun_path_est::list_of_hops_length(), n_paths_established, number_of_pathestablishment_, period_status_, printDebug_, printIP(), hdr_uwip::saddr(), trace_, and tracePacket().

Referenced by replyPathEstSearch().

Here is the call graph for this function:

◆ bufferManager()

◆ clearHops()

void SunIPRoutingNode::clearHops ( )
protectedvirtual

Clears all the route information of the current node.

References getNumberOfHopToSink(), hop_table, hop_table_length, ipAddr_, printDebug_, printIP(), quality_link, and sink_associated.

Referenced by bufferManager(), command(), evaluatePath(), expTimerHopTable(), lostSink(), receiveProbe(), recv(), searchPath(), sendRouteBack(), and SunIPRoutingNode().

Here is the call graph for this function:

◆ command()

int SunIPRoutingNode::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 buffer_data, clearHops(), data_and_hops, getAckCount(), getAckHeaderSize(), getDataCount(), getDataDropsCountBuffer(), getDataDropsCountMaxRetx(), getDataPktHeaderSize(), getForwardedCount(), getNPathsEstablished(), getPathEstablishmentCount(), getPathEstHeaderSize(), initialize(), ipAddr_, num_hop_to_sink, pkt_stored_, pkt_tx_, printHopTable(), printIP(), printSelectedRoutes(), str2addr(), trace_, trace_file_, and trace_file_name_.

Here is the call graph for this function:

◆ createRouteError()

void SunIPRoutingNode::createRouteError ( const Packet *  p_data,
Packet *  p 
)
protectedvirtual

Used to create a route error packet. This packet will be sent by the current node to the source of the data packet that generated the error.

Parameters
Packet*Pointer to a Data packet that the current node is unable to forward.
Packet*Pointer to a Route error packet already allocated to initialize with proper values.
See also
SunIPRoutingNode::initPktPathEstSearch(Packet*)

References hdr_uwip::daddr(), getNumberOfHopToSink(), initPktPathEstSearch(), ipAddr_, hdr_sun_data::list_of_hops(), hdr_sun_path_est::list_of_hops(), hdr_sun_path_est::list_of_hops_length(), hdr_sun_data::pointer(), hdr_sun_path_est::pointer(), printDebug_, printIP(), hdr_sun_path_est::ptype(), and hdr_uwip::saddr().

Referenced by bufferManager().

Here is the call graph for this function:

◆ createTraceString()

string SunIPRoutingNode::createTraceString ( const string &  info_string,
const double &  simulation_time_,
const int &  node_id_,
const int &  pkt_id_,
const int &  pkt_sn_,
const int &  pkt_from_,
const int &  pkt_next_hop,
const int &  pkt_source_,
const int &  pkt_destination_,
const double &  snr_,
const int &  direction_,
const int &  pkt_type 
)
protectedvirtual

Function that accepts a list of string and create an entry for the trace file.

References osstream_, and trace_separator_.

Referenced by tracePacket().

◆ evaluatePath()

const int & SunIPRoutingNode::evaluatePath ( const Packet *  p)
protectedvirtual

Evaluates the route information contained in a Path Establishment packet, and according to different metrics it evaluates if the path contained in the packet is the new best route.

Parameters
Packet*Pointer to a Path Establishment packet to evaluate.
Returns
Number of hops that separate the current node to the sink.
See also
SunIPRoutingNode::clearHops()
SunIPRoutingNode::setNumberOfHopToSink(const int&)
SunIPRoutingNode::getNumberOfHopToSink()

References ack_error_state, ack_warnings_counter_, clearHops(), getNumberOfHopToSink(), hop_table, hop_table_length, HOPCOUNT, ipAddr_, isZero(), LESSCONGESTED, hdr_sun_path_est::list_of_hops(), hdr_sun_path_est::list_of_hops_length(), metrics_, paths_selected, printDebug_, printIP(), hdr_sun_path_est::quality(), quality_link, rmhopTableTmr_, hdr_uwip::saddr(), setNumberOfHopToSink(), sink_associated, hdr_sun_path_est::sinkAssociated(), SNR, and timer_route_validity_.

Referenced by recv().

Here is the call graph for this function:

◆ expTimerHopTable()

void SunIPRoutingNode::expTimerHopTable ( )
protectedvirtual

This function is invoked when the timer of the routing table expires. It removes all the information about routing information and sink association.

See also
SunIPRoutingNode::clearHops()
SunIPRoutingNode::setNumberOfHopToSink(const int&)

References clearHops(), getNumberOfHopToSink(), ipAddr_, printDebug_, printIP(), and setNumberOfHopToSink().

Here is the call graph for this function:

◆ forwardDataPacket()

void SunIPRoutingNode::forwardDataPacket ( Packet *  p)
protectedvirtual

Forwards a data packet to the next hop. All the information to route the packet are contained in the packet. If the current node is in the coverage are of the sink it will forward the packet directly to the sink, otherwise the packet will be forwarded to the next hop.

Parameters
Packet*Pointer to a Data packet to forward.

References hdr_uwip::daddr(), getDelay(), getNumberOfHopToSink(), ipAddr_, hdr_sun_data::list_of_hops(), hdr_sun_data::list_of_hops_length(), number_of_datapkt_, number_of_pkt_forwarded_, period_data_, pkt_tx_, hdr_sun_data::pointer(), printDebug_, printIP(), hdr_uwip::saddr(), sink_associated, trace_, and tracePacket().

Referenced by bufferManager().

Here is the call graph for this function:

◆ getAckCount()

const long & SunIPRoutingNode::getAckCount ( ) const
inlineprotected

Returns the number of Ack packets processed by the entire network.

Returns
Number of Ack packets processed by the entire network.

References number_of_ackpkt_.

Referenced by command().

◆ getAckHeaderSize()

static const int SunIPRoutingNode::getAckHeaderSize ( )
inlinestaticprotected

Returns the size in byte of a hdr_sun_ack packet header.

Returns
The size of a hdr_sun_ack packet header.

Referenced by command().

◆ getAcksLastMinute()

const int SunIPRoutingNode::getAcksLastMinute ( ) const
protectedvirtual

Returns the number of acks received by the current node in the last interval of time (MINUTE).

Returns
Number of acks received by the current node in the last interval of time (MINUTE).
See also
MINUTE.

References acks_array_full, list_acks, list_acks_max_time_, LISTLENGTH, and MINUTE.

Referenced by getLoad().

◆ getDataCount()

const long & SunIPRoutingNode::getDataCount ( ) const
inlineprotected

Returns the number of Data packets processed by the entire network.

Returns
Number of Data packets processed by the entire network.

References number_of_datapkt_.

Referenced by command().

◆ getDataDropsCountBuffer()

const long & SunIPRoutingNode::getDataDropsCountBuffer ( ) const
inlineprotected

Returns the number of packets dropped by the entire network for the reason: buffer is full.

Returns
Number of packets dropped by the entire network.

References number_of_drops_buffer_full_.

Referenced by command().

◆ getDataDropsCountMaxRetx()

const long & SunIPRoutingNode::getDataDropsCountMaxRetx ( ) const
inlineprotected

Returns the number of packets dropped by the entire network for the reason: maximum number of retransmission reached.

Returns
Number of packets dropped by the entire network.

References number_of_drops_maxretx_.

Referenced by command().

◆ getDataPktHeaderSize()

static const int SunIPRoutingNode::getDataPktHeaderSize ( )
inlinestaticprotected

Returns the size in byte of a hdr_sun_data packet header.

Returns
The size of a hdr_sun_data packet header.

Referenced by command().

◆ getDelay()

const double SunIPRoutingNode::getDelay ( const double &  period_) const
inlineprotected

Returns a delay value to use in transmission. The delay can be 0 or poissonian accordingly with the flag PoissonTraffic_.

Returns
Transmission delay.
See also
PoissonTraffic_
periodPoissonTraffic_

References PoissonTraffic_.

Referenced by answerPath(), bufferManager(), forwardDataPacket(), replyPathEstSearch(), searchPath(), sendBackAck(), sendRouteBack(), and sendRouteErrorBack().

◆ getForwardedCount()

const long & SunIPRoutingNode::getForwardedCount ( ) const
inlineprotected

Returns the number of Data packets forwarded by the entire network.

Returns
Number of Data packets forwarded by the entire network.

References number_of_pkt_forwarded_.

Referenced by command().

◆ getLoad()

const double SunIPRoutingNode::getLoad ( ) const
protectedvirtual

Returns the load index of the current node combining the information from getPacketsLastMinute() and getAcksLastMinute() functions.

Returns
The load index of the current node.
See also
SunIPRoutingNode::getPacketsLastMinute()
SunIPRoutingNode::getAcksLastMinute()

References alpha_, getAcksLastMinute(), and getPacketsLastMinute().

Referenced by updateQuality().

Here is the call graph for this function:

◆ getNPathsEstablished()

const long & SunIPRoutingNode::getNPathsEstablished ( )
inlineprotected

Print how many times the node was established as relay node for other nodes of the netwok.

Returns
number of times the node was established as relay node

References n_paths_established.

Referenced by command().

◆ getNumberOfHopToSink()

const int & SunIPRoutingNode::getNumberOfHopToSink ( ) const
protectedvirtual

Returns the number of hops that separate the node to the sink.

  • 0 means no routing information;
  • 1 means directly connected with the sink;
  • a value > 1 correspond to the number of hops;
Returns
The number of hops that separate the node to the sink.
See also
SunIPRoutingNode::getNumberOfHopToSink()

References num_hop_to_sink.

Referenced by answerPath(), bufferManager(), clearHops(), createRouteError(), evaluatePath(), expTimerHopTable(), forwardDataPacket(), initPktDataPacket(), lostSink(), receiveProbe(), recv(), replyPathEstSearch(), searchPath(), sendBackAck(), sendRouteBack(), setNumberOfHopToSink(), updateQuality(), and ~SunIPRoutingNode().

◆ getPacketsLastMinute()

const int SunIPRoutingNode::getPacketsLastMinute ( ) const
protectedvirtual

Returns the number of packets processed by the current node in the last interval of time (MINUTE).

Returns
Number of packets processed by the current node in the last interval of time (MINUTE).
See also
MINUTE.

References list_packets, list_packets_max_time_, LISTLENGTH, MINUTE, and packets_array_full.

Referenced by getLoad(), and updateQuality().

◆ getPathEstablishmentCount()

const long & SunIPRoutingNode::getPathEstablishmentCount ( ) const
inlineprotected

Returns the number of Path Establishment packets processed by the entire network.

Returns
Number of Path Establishment Packets processed by the entire network.

References number_of_pathestablishment_.

Referenced by command().

◆ getPathEstHeaderSize()

static const int SunIPRoutingNode::getPathEstHeaderSize ( )
inlinestaticprotected

Returns the size in byte of a hdr_sun_path_est packet header.

Returns
The size of a hdr_sun_path_est packet header.

Referenced by command().

◆ initialize()

void SunIPRoutingNode::initialize ( )
protectedvirtual

Initializes a SunIPRoutingNode node. It sends to the lower layers a Sync message asking for the IP of the node.

See also
UWIPClMsgReqAddr(int src)
sendSyncClMsgDown(ClMessage* m)

References ipAddr_.

Referenced by command().

◆ initPktAck()

void SunIPRoutingNode::initPktAck ( Packet *  p)
protectedvirtual

Initializes an ack packet passed as argument with the default values.

Parameters
Packet*Pointer to a packet already allocated to fill with the right values.
See also
SunIPRoutingNode::initPktAck(Packet*)

References ipAddr_, and PT_SUN_ACK.

Referenced by sendBackAck().

◆ initPktDataPacket()

void SunIPRoutingNode::initPktDataPacket ( Packet *  p)
protectedvirtual

Initializes a data packet passed as argument with the default values.

Parameters
Packet*Pointer to a packet already allocated to fill with the right values.

References hdr_uwip::daddr(), getNumberOfHopToSink(), hop_table, hop_table_length, ipAddr_, hdr_sun_data::list_of_hops(), hdr_sun_data::list_of_hops_length(), hdr_sun_data::pointer(), hdr_uwip::saddr(), and sink_associated.

Referenced by bufferManager().

Here is the call graph for this function:

◆ initPktPathEstAnswer()

void SunIPRoutingNode::initPktPathEstAnswer ( Packet *  new_pkt,
const Packet *  old_pkt 
)
protectedvirtual

Initializes a Path Establishment Answer packet (previously allocated) retrieving the information from a Path Establishment Request packet.

Parameters
Packet*Pointer to a Path Establishment packet with the option field set to Answer to initialize.
Packet*Pointer to a Path Establishment packet with the option field set to Search.

References hdr_uwip::daddr(), ipAddr_, hdr_sun_path_est::list_of_hops(), hdr_sun_path_est::list_of_hops_length(), hdr_sun_path_est::pointer(), PT_SUN_PATH_EST, hdr_sun_path_est::ptype(), hdr_sun_path_est::quality(), hdr_uwip::saddr(), sink_associated, and hdr_sun_path_est::sinkAssociated().

Referenced by answerPath().

Here is the call graph for this function:

◆ initPktPathEstSearch()

void SunIPRoutingNode::initPktPathEstSearch ( Packet *  p) const
protectedvirtual

Initializes a Path Establishment Search packet (previously allocated).

Parameters
Packet*Pointer to a Path Establishment Packet with the option field set to Search to initialize.

References hdr_uwip::daddr(), ipAddr_, hdr_sun_path_est::list_of_hops(), hdr_sun_path_est::list_of_hops_length(), PT_SUN_PATH_EST, hdr_sun_path_est::ptype(), and hdr_sun_path_est::quality().

Referenced by createRouteError(), and searchPath().

Here is the call graph for this function:

◆ isMyIpInList()

const bool SunIPRoutingNode::isMyIpInList ( const Packet *  p) const
protectedvirtual

Checks if the IP of the current node is in the header of the packet passed as argument. If yes it returns true, otherwise it return false.

Parameters
Packet*Pointer to a Path Establishment packet to analyze.
Returns
true if the IP of the current node is in the header, otherwise false.

References ipAddr_, hdr_sun_path_est::list_of_hops(), and hdr_sun_path_est::list_of_hops_length().

Referenced by replyPathEstSearch().

Here is the call graph for this function:

◆ isZero()

const bool SunIPRoutingNode::isZero ( const double &  value) const
inlineprotected

Evaluates is the number passed as input is equal to zero. When C++ works with double and float number you can't compare them with 0. If the absolute value of the number is smaller than eplison that means that the number is equal to zero.

Parameters
double&Number to evaluate.
Returns
true if the number passed in input is equal to zero, false otherwise.
See also
std::numeric_limits<double>::epsilon()

Referenced by evaluatePath(), receiveProbe(), sendRouteBack(), and updateQuality().

◆ lostSink()

void SunIPRoutingNode::lostSink ( )
protectedvirtual

This function removes all the information about routing information and sink association.

See also
SunIPRoutingNode::clearHops()
SunIPRoutingNode::setNumberOfHopToSink(const int&)

References clearHops(), getNumberOfHopToSink(), setNumberOfHopToSink(), and sink_associated.

Here is the call graph for this function:

◆ printHopTable()

void SunIPRoutingNode::printHopTable ( ) const
protectedvirtual

Prints in the stdout the routing table of the current node.

References hop_table, hop_table_length, and printIP().

Referenced by command().

Here is the call graph for this function:

◆ printIP() [1/2]

string SunIPRoutingNode::printIP ( const ns_addr_t &  ipt_)
staticprotected

Returns a string with an IP in the classic form "x.x.x.x" converting an ns2 ns_addr_t address.

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

References printIP().

Here is the call graph for this function:

◆ printIP() [2/2]

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

Returns 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"

Referenced by answerPath(), bufferManager(), clearHops(), command(), createRouteError(), evaluatePath(), expTimerHopTable(), forwardDataPacket(), printHopTable(), printIP(), printSelectedRoutes(), receiveProbe(), recv(), replyPathEstSearch(), searchPath(), sendBackAck(), sendRouteBack(), and ~SunIPRoutingNode().

◆ printSelectedRoutes()

void SunIPRoutingNode::printSelectedRoutes ( ) const
protectedvirtual

Print the nodes that were chosen as relay nodes to rach the sink and how many times each node was chosen.

References paths_selected, and printIP().

Referenced by command().

Here is the call graph for this function:

◆ receiveProbe()

void SunIPRoutingNode::receiveProbe ( const Packet *  p)
protectedvirtual

Invoked when the node receives a probe packet from a sink. It is used to update the information about routes.

Parameters
Packet*Pointer to a Probe packet.
See also
SunIPRoutingNode::clearHops()
SunIPRoutingNode::setNumberOfHopToSink(const int&)

References clearHops(), getNumberOfHopToSink(), ipAddr_, isZero(), printDebug_, printIP(), probe_min_snr_, hdr_uwip::saddr(), setNumberOfHopToSink(), sink_associated, sinkProbeTimer_, snr_to_sink_, and timer_sink_probe_validity_.

Referenced by recv().

Here is the call graph for this function:

◆ recv()

◆ recvAsyncClMsg()

int SunIPRoutingNode::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.

References UWIPClMsgSendAddr::getAddr(), ipAddr_, and UWIP_CLMSG_SEND_ADDR.

Here is the call graph for this function:

◆ recvSyncClMsg()

int SunIPRoutingNode::recvSyncClMsg ( ClMessage *  m)
protectedvirtual

Cross-Layer messages synchronous interpreter.

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

◆ replyPathEstSearch()

void SunIPRoutingNode::replyPathEstSearch ( Packet *  p)
protectedvirtual

Replies to Path Establishment Search packets. It adds in the packet the IP of the current node and forwards or replies to the request.

Parameters
Packet*Pointer to a Path Establishment Search packets to process.
See also
SunIPRoutingNode::isMyIpInList(const Packet*)
SunIPRoutingNode::addMyIpInList(Packet*)
SunIPRoutingNode::updateQuality(Packet*)
SunIPRoutingNode::getNumberOfHopToSink()
SunIPRoutingNode::answerPath(const Packet*)

References addMyIpInList(), answerPath(), hdr_uwip::daddr(), getDelay(), getNumberOfHopToSink(), ipAddr_, isMyIpInList(), number_of_pathestablishment_, period_status_, printDebug_, printIP(), hdr_sun_path_est::ptype_, hdr_uwip::saddr(), trace_, tracePacket(), and updateQuality().

Referenced by recv().

Here is the call graph for this function:

◆ searchPath()

void SunIPRoutingNode::searchPath ( )
protectedvirtual

Sends a Path Establishment Packet with the option field sets to Search. It also remove all the information about current routes to the sink.

See also
SunIPRoutingNode::clearHops()
SunIPRoutingNode::setNumberOfHopToSink(const int&)
SunIPRoutingNode::initPktPathEstSearch(Packet*)

References clearHops(), getDelay(), getNumberOfHopToSink(), initPktPathEstSearch(), ipAddr_, number_of_pathestablishment_, period_status_, printDebug_, printIP(), setNumberOfHopToSink(), trace_, and tracePacket().

Referenced by bufferManager(), and recv().

Here is the call graph for this function:

◆ searchPathExpire()

void SunIPRoutingNode::searchPathExpire ( )
protectedvirtual

This function enable the possibility to send a new Seath Path packet. It is used to avoid too many control packets in network in a high load condition.

References search_path_enable_.

◆ sendBackAck()

void SunIPRoutingNode::sendBackAck ( const Packet *  p)
protectedvirtual

Creates an ack packet and sends it to the previous hop using the information contained in the header of the data packet passed as input parameter. It is an ack to the previous hop, and not to the source of the packet.

Parameters
Packet*Pointer to a Data packet to acknowledge.
See also
SunIPRoutingNode::initPktAck()
SunIPRoutingNode::clearHops()
SunIPRoutingNode::setNumberOfHopToSink(const int&)

References hdr_uwip::daddr(), getDelay(), getNumberOfHopToSink(), initPktAck(), ipAddr_, number_of_ackpkt_, period_status_, printDebug_, printIP(), hdr_uwcbr::sn(), trace_, tracePacket(), and hdr_sun_ack::uid().

Referenced by recv().

Here is the call graph for this function:

◆ sendRouteBack()

void SunIPRoutingNode::sendRouteBack ( Packet *  p)
protectedvirtual

◆ sendRouteErrorBack()

void SunIPRoutingNode::sendRouteErrorBack ( Packet *  p)
protectedvirtual

Send back an error packet to the previous hop. It uses the information contained in the header of the packet.

Parameters
Packet*Pointer to a Packet to forward to the next hop.

References hdr_uwip::daddr(), getDelay(), hdr_sun_path_est::list_of_hops(), hdr_sun_path_est::list_of_hops_length(), number_of_pathestablishment_, period_status_, hdr_sun_path_est::pointer(), trace_, and tracePacket().

Referenced by recv().

Here is the call graph for this function:

◆ setNumberOfHopToSink()

const int & SunIPRoutingNode::setNumberOfHopToSink ( const int &  hop)
protectedvirtual

Sets the number of hops that the current node needs to reach the sink.

Parameters
int&Number of hops to the sink. The value must be greater or equal to 1.
Returns
Number of hops that separate the current node to the sink.

References getNumberOfHopToSink(), num_hop_to_sink, and snr_to_sink_.

Referenced by bufferManager(), evaluatePath(), expTimerHopTable(), lostSink(), receiveProbe(), recv(), searchPath(), and sendRouteBack().

Here is the call graph for this function:

◆ str2addr()

nsaddr_t SunIPRoutingNode::str2addr ( const char *  str)
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

Referenced by command().

◆ tracePacket()

void SunIPRoutingNode::tracePacket ( const Packet * const  p,
const string &  position = "UNDEF___" 
)
protectedvirtual

Traces a packet.

Parameters
Packetto be traced.
Stringoptional for the packet.

References createTraceString(), hdr_uwip::daddr(), ipAddr_, PT_SUN_ACK, hdr_uwip::saddr(), hdr_uwcbr::sn(), trace_, hdr_sun_ack::uid(), and writeInTrace().

Referenced by answerPath(), bufferManager(), forwardDataPacket(), recv(), replyPathEstSearch(), searchPath(), sendBackAck(), sendRouteBack(), and sendRouteErrorBack().

Here is the call graph for this function:

◆ updateAcksCount()

void SunIPRoutingNode::updateAcksCount ( )
protectedvirtual

Updates the number of acks received by the current node. To be used when the node receives an ack.

References acks_array_full, list_acks, list_acks_max_time_, LISTLENGTH, and pointer_acks_.

Referenced by recv().

◆ updatePacketsCount()

void SunIPRoutingNode::updatePacketsCount ( )
protectedvirtual

Updates the number of packets processed by the current node. To be used when the node receives or generates a packet.

References list_packets, list_packets_max_time_, LISTLENGTH, packets_array_full, and pointer_packets_.

Referenced by recv().

◆ updateQuality()

void SunIPRoutingNode::updateQuality ( Packet *  p)
protectedvirtual

Updates the field quality in the packet passed as parameter. The value written in the packet depends on the metric field.

Parameters
Packet*Pointer to a packet in which to update the quality field.

References getLoad(), getNumberOfHopToSink(), getPacketsLastMinute(), HOPCOUNT, isZero(), LESSCONGESTED, metrics_, hdr_sun_path_est::quality(), SNR, and snr_to_sink_.

Referenced by replyPathEstSearch().

Here is the call graph for this function:

◆ writeInTrace()

void SunIPRoutingNode::writeInTrace ( const string &  string_to_write_)
protectedvirtual

Opens the trace file, writes the string passed as input and closes the file.

Parameters
Stringto write in the trace file.

References trace_file_, and trace_file_name_.

Referenced by tracePacket().

Friends And Related Symbol Documentation

◆ AckWaiting

friend class AckWaiting
friend

Friend class used to implement the timer on Acks.

See also
SinkProbeTimer

◆ BufferTimer

friend class BufferTimer
friend

Friend class used to implement the timer on the Buffer.

See also
BufferTimer

◆ RemoveHopTableTimer

friend class RemoveHopTableTimer
friend

Friend class used to implement the timer on Hop Tables.

See also
SinkProbeTimer

◆ SearchPathTimer

friend class SearchPathTimer
friend

Friend class used to implement the timer on the Search Path mechanism.

See also
SearchPathTimer

◆ SinkProbeTimer

friend class SinkProbeTimer
friend

Friend class used to implement the timer on Probes.

See also
SinkProbeTimer

Member Data Documentation

◆ ack_error_state

bool SunIPRoutingNode::ack_error_state
protected

true if the node is not in an error state (that means that it discovered a broken link), false if the link to the next hop is considered valid.

Referenced by evaluatePath(), recv(), and sendRouteBack().

◆ ack_warnings_counter_

int SunIPRoutingNode::ack_warnings_counter_
protected

Number of acks lost since the last reset.

Referenced by evaluatePath(), recv(), and sendRouteBack().

◆ acks_array_full

bool SunIPRoutingNode::acks_array_full
protected

true if list of acks is full, false otherwise.

Referenced by getAcksLastMinute(), and updateAcksCount().

◆ alpha_

double SunIPRoutingNode::alpha_
protected

Parameters used by Load metric. It is a correlation factor.

Referenced by getLoad(), and SunIPRoutingNode().

◆ buffer_data

vector<buffer_element> SunIPRoutingNode::buffer_data
protected

Buffer used to store data packets.

Referenced by bufferManager(), command(), and recv().

◆ buffer_max_size_

uint32_t SunIPRoutingNode::buffer_max_size_
protected

Maximum length of the data buffer.

Referenced by recv(), and SunIPRoutingNode().

◆ bufferTmr_

BufferTimer SunIPRoutingNode::bufferTmr_
protected

BufferTimer object.

Referenced by bufferManager(), and SunIPRoutingNode().

◆ data_and_hops

int SunIPRoutingNode::data_and_hops[MAX_HOP_NUMBER]
protected

Structure that contains the number of data packets sent by the current node to the sink, for different values of hop count. It is used for statistics purposes.

Referenced by bufferManager(), command(), and SunIPRoutingNode().

◆ disable_path_error_

int SunIPRoutingNode::disable_path_error_
protected

Flag to enable or disable the possibility to send Path Error packets.

Referenced by bufferManager(), and SunIPRoutingNode().

◆ hop_table

nsaddr_t* SunIPRoutingNode::hop_table
protected

◆ hop_table_length

int SunIPRoutingNode::hop_table_length
protected

Current length of the hop_table.

Referenced by clearHops(), evaluatePath(), initPktDataPacket(), printHopTable(), and sendRouteBack().

◆ ipAddr_

◆ list_acks

double SunIPRoutingNode::list_acks[LISTLENGTH]
protected

List of the last LISTLENGTH temporal instants in which the node received acks.

Referenced by getAcksLastMinute(), and updateAcksCount().

◆ list_acks_max_time_

long SunIPRoutingNode::list_acks_max_time_
protected

Clock of the last ack received by the node.

Referenced by getAcksLastMinute(), and updateAcksCount().

◆ list_packets

double SunIPRoutingNode::list_packets[LISTLENGTH]
protected

List of the last LISTLENGTH temporal instants in which the node received data packets.

Referenced by getPacketsLastMinute(), and updatePacketsCount().

◆ list_packets_max_time_

long SunIPRoutingNode::list_packets_max_time_
protected

Clock of the last packet received by the node.

Referenced by getPacketsLastMinute(), and updatePacketsCount().

◆ LISTLENGTH

const int SunIPRoutingNode::LISTLENGTH = 30
static

Used by the load metric to set the number of the acks tracked.

Referenced by getAcksLastMinute(), getPacketsLastMinute(), updateAcksCount(), and updatePacketsCount().

◆ max_ack_error_

int SunIPRoutingNode::max_ack_error_
protected

Maximum number of Ack errors tollerated by the node.

Referenced by bufferManager(), and SunIPRoutingNode().

◆ max_retx_

uint SunIPRoutingNode::max_retx_
protected

Maximum Number of transmissions performed: real retransmissions counter the counter is increased only when the packet is sent downlayer

Referenced by bufferManager(), and SunIPRoutingNode().

◆ metrics_

int SunIPRoutingNode::metrics_
protected

Metric used by the current node.

Referenced by evaluatePath(), sendRouteBack(), SunIPRoutingNode(), and updateQuality().

◆ MINUTE

const int SunIPRoutingNode::MINUTE
static
Initial value:
=
60

Used by the load metric to set the period to consider for the evaluation of the metric.

Referenced by getAcksLastMinute(), and getPacketsLastMinute().

◆ n_paths_established

long SunIPRoutingNode::n_paths_established
protected

Number of times the node is established as realy node by the other nodes of the network

Referenced by answerPath(), and getNPathsEstablished().

◆ num_hop_to_sink

int SunIPRoutingNode::num_hop_to_sink
protected

Number of hops needed to reach the sink using tha path saved tn the routing table. If the node is directly connected this value is equal to 1, is the node doesn't have any valid path to the sink this value is equal to 0

Referenced by command(), getNumberOfHopToSink(), and setNumberOfHopToSink().

◆ number_of_ackpkt_

long SunIPRoutingNode::number_of_ackpkt_ = 0
staticprotected

Comulative number of Ack packets processed by SunIPRoutingNode objects.

Referenced by getAckCount(), and sendBackAck().

◆ number_of_datapkt_

long SunIPRoutingNode::number_of_datapkt_ = 0
staticprotected

Comulative number of Data packets processed by SunIPRoutingNode objects.

Referenced by bufferManager(), forwardDataPacket(), and getDataCount().

◆ number_of_drops_buffer_full_

long SunIPRoutingNode::number_of_drops_buffer_full_ = 0
staticprotected

Comulative number of packets dropped by SunIPRoutingNode objects, reason: the buffer is full.

Referenced by getDataDropsCountBuffer(), and recv().

◆ number_of_drops_maxretx_

long SunIPRoutingNode::number_of_drops_maxretx_ = 0
staticprotected

Comulative number of packets dropped by SunIPRoutingNode objects, reason: max number of retransmission reached.

Referenced by bufferManager(), and getDataDropsCountMaxRetx().

◆ number_of_pathestablishment_

long SunIPRoutingNode::number_of_pathestablishment_ = 0
staticprotected

Comulative number of Path Establishment packets processed by SunIPRoutingNode objects.

Referenced by answerPath(), getPathEstablishmentCount(), replyPathEstSearch(), searchPath(), sendRouteBack(), and sendRouteErrorBack().

◆ number_of_pkt_forwarded_

long SunIPRoutingNode::number_of_pkt_forwarded_ = 0
staticprotected

Comulative number of Data packets forwarded by the network.

Referenced by bufferManager(), forwardDataPacket(), and getForwardedCount().

◆ osstream_

ostringstream SunIPRoutingNode::osstream_
protected

Used to convert to string.

Referenced by createTraceString().

◆ packets_array_full

bool SunIPRoutingNode::packets_array_full
protected

true if list of packets is full, false otherwise.

Referenced by getPacketsLastMinute(), and updatePacketsCount().

◆ paths_selected

std::map<uint8_t, uint> SunIPRoutingNode::paths_selected
protected

Map containing the nodes selected as relay to the sink and the number of times each node was selected

Referenced by evaluatePath(), printSelectedRoutes(), and sendRouteBack().

◆ period_data_

double SunIPRoutingNode::period_data_
protected

Period of the Poisson traffic for data packets in the buffer.

Referenced by bufferManager(), forwardDataPacket(), and SunIPRoutingNode().

◆ period_status_

double SunIPRoutingNode::period_status_
protected

Period of the Poisson traffic for status and ack packets.

Referenced by answerPath(), replyPathEstSearch(), searchPath(), sendBackAck(), sendRouteBack(), sendRouteErrorBack(), and SunIPRoutingNode().

◆ pkt_stored_

long SunIPRoutingNode::pkt_stored_
protected

Keep track of the total number of packet transmitted.

Referenced by command(), and recv().

◆ pkt_tx_

long SunIPRoutingNode::pkt_tx_
protected

Keep track of the total number of packet retransmitted.

Referenced by bufferManager(), command(), and forwardDataPacket().

◆ pointer_acks_

int SunIPRoutingNode::pointer_acks_
protected

Pointer of the first avaiable space in list_acks list.

Referenced by updateAcksCount().

◆ pointer_packets_

int SunIPRoutingNode::pointer_packets_
protected

Pointer of the first avaiable space in list_packets list.

Referenced by updatePacketsCount().

◆ PoissonTraffic_

int SunIPRoutingNode::PoissonTraffic_
protected

Enable (1) or disable (0) the Poisson traffic for SUN packets.

Referenced by getDelay(), and SunIPRoutingNode().

◆ printDebug_

◆ probe_min_snr_

double SunIPRoutingNode::probe_min_snr_
protected

Value below which if a node receives a probe it discards it.

Referenced by receiveProbe(), and SunIPRoutingNode().

◆ quality_link

double SunIPRoutingNode::quality_link
protected

Quality of the link from the node to the sink.

Referenced by clearHops(), evaluatePath(), and sendRouteBack().

◆ reset_buffer_if_error_

int SunIPRoutingNode::reset_buffer_if_error_
protected

If == 1 when a node identify a broken link it will automatically free its buffer.

Referenced by bufferManager(), recv(), and SunIPRoutingNode().

◆ rmhopTableTmr_

RemoveHopTableTimer SunIPRoutingNode::rmhopTableTmr_
protected

RemoveHopTableTimer object.

Referenced by evaluatePath(), and sendRouteBack().

◆ safe_timer_buffer_

int SunIPRoutingNode::safe_timer_buffer_
protected

Enables a mechanism used to modify the timer_buffer_ in case of the sending time is shorter than the time needed to receive acks.

Referenced by recv(), and SunIPRoutingNode().

◆ search_path_enable_

bool SunIPRoutingNode::search_path_enable_
protected

Flag to enable or disable the possibility to send search_path packets.

Referenced by bufferManager(), recv(), and searchPathExpire().

◆ searchPathTmr_

SearchPathTimer SunIPRoutingNode::searchPathTmr_
protected

SearchPathTimer object.

Referenced by bufferManager(), and recv().

◆ sink_associated

nsaddr_t SunIPRoutingNode::sink_associated
protected

◆ sinkProbeTimer_

SinkProbeTimer SunIPRoutingNode::sinkProbeTimer_
protected

SinkProbeTimer object.

Referenced by receiveProbe().

◆ snr_to_sink_

double SunIPRoutingNode::snr_to_sink_
protected

SNR between the sink and the current node.

Referenced by receiveProbe(), setNumberOfHopToSink(), and updateQuality().

◆ timer_buffer_

double SunIPRoutingNode::timer_buffer_
protected

Timer for buffer management.

Referenced by bufferManager(), recv(), and SunIPRoutingNode().

◆ timer_route_validity_

double SunIPRoutingNode::timer_route_validity_
protected

Maximum validity time for a route entry.

Referenced by evaluatePath(), sendRouteBack(), and SunIPRoutingNode().

◆ timer_search_path_

double SunIPRoutingNode::timer_search_path_
protected

Timer for the search path mechanism.

Referenced by bufferManager(), recv(), and SunIPRoutingNode().

◆ timer_sink_probe_validity_

double SunIPRoutingNode::timer_sink_probe_validity_
protected

Maximum validity time for a sink probe.

Referenced by receiveProbe(), and SunIPRoutingNode().

◆ trace_

bool SunIPRoutingNode::trace_
protected

◆ trace_file_

ofstream SunIPRoutingNode::trace_file_
protected

Ofstream used to write the trace file in the disk.

Referenced by command(), and writeInTrace().

◆ trace_file_name_

char* SunIPRoutingNode::trace_file_name_
protected

Name of the trace file writter for the current node.

Referenced by command(), writeInTrace(), and ~SunIPRoutingNode().

◆ trace_separator_

char SunIPRoutingNode::trace_separator_
protected

Used as separator among elements in an entr of the tracefile.

Referenced by createTraceString(), and SunIPRoutingNode().


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