DESERT 4.0.0
SunIPRoutingSink Class Reference

#include <sun-ipr-sink.h>

Inheritance diagram for SunIPRoutingSink:
Inheritance graph
Collaboration diagram for SunIPRoutingSink:
Collaboration graph

Classes

class  SendTimer
 

Public Member Functions

 SunIPRoutingSink ()
 
virtual ~SunIPRoutingSink ()
 

Protected Member Functions

virtual int command (int, const char *const *)
 
virtual void recv (Packet *)
 
virtual int recvSyncClMsg (ClMessage *)
 
virtual int recvAsyncClMsg (ClMessage *)
 
virtual void initialize ()
 
virtual void sendProbe ()
 
const double getDelay (const double &period_) const
 
virtual void start ()
 
virtual void stop ()
 
virtual void transmit ()
 
virtual void setProbeTimer (const double &)
 
virtual const double & getProbeTimer () const
 
virtual void sendBackAck (const Packet *)
 
virtual void initPktAck (Packet *)
 
const long & getProbeCount () const
 
const long & getAckCount () const
 
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 &)
 
virtual void writePathInTrace (const Packet *)
 

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 getProbePktHeaderSize ()
 
static const int getAckHeaderSize ()
 

Protected Attributes

nsaddr_t ipAddr_
 
double t_probe
 
int PoissonTraffic_
 
double periodPoissonTraffic_
 
int printDebug_
 
int numberofnodes_
 
unsigned int ** arrayofstats_
 
SendTimer sendTmr_
 
bool trace_
 
bool trace_path_
 
char * trace_file_name_
 
char * trace_file_path_name_
 
ostringstream osstream_
 
ofstream trace_file_
 
ofstream trace_file_path_
 
char trace_separator_
 

Static Protected Attributes

static long probe_count_ = 0
 
static long number_of_ackpkt_ = 0
 

Private Member Functions

 SunIPRoutingSink (const SunIPRoutingSink &)
 

Friends

class SendTimer
 

Detailed Description

SunIPRoutingSink class is used to represent the routing layer of a sink.

Constructor & Destructor Documentation

◆ SunIPRoutingSink() [1/2]

SunIPRoutingSink::SunIPRoutingSink ( )

◆ ~SunIPRoutingSink()

SunIPRoutingSink::~SunIPRoutingSink ( )
virtual

Constructor of SunIPRoutingNode class.

References ipAddr_, printDebug_, and printIP().

Here is the call graph for this function:

◆ SunIPRoutingSink() [2/2]

SunIPRoutingSink::SunIPRoutingSink ( const SunIPRoutingSink )
private

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

Parameters
SunIPRoutingSink&SunIPRoutingSink object.

Member Function Documentation

◆ command()

int SunIPRoutingSink::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 arrayofstats_, getAckCount(), getAckHeaderSize(), getProbeCount(), getProbePktHeaderSize(), getProbeTimer(), initialize(), ipAddr_, numberofnodes_, sendProbe(), start(), stop(), str2addr(), trace_, trace_file_, trace_file_name_, trace_file_path_, trace_file_path_name_, and trace_path_.

Here is the call graph for this function:

◆ createTraceString()

string SunIPRoutingSink::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 accept a list of string and create an entry for the trace file.

References osstream_, and trace_separator_.

Referenced by tracePacket().

◆ getAckCount()

const long & SunIPRoutingSink::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 SunIPRoutingSink::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().

◆ getDelay()

const double SunIPRoutingSink::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 sendBackAck(), and sendProbe().

◆ getProbeCount()

const long & SunIPRoutingSink::getProbeCount ( ) const
inlineprotected

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

Returns
Number of Probe packets processed by the entire network.

References probe_count_.

Referenced by command().

◆ getProbePktHeaderSize()

static const int SunIPRoutingSink::getProbePktHeaderSize ( )
inlinestaticprotected

Returns the size in byte of a hdr_sun_probe packet header.

Returns
The size of a hdr_sun_probe packet header.

Referenced by command().

◆ getProbeTimer()

const double & SunIPRoutingSink::getProbeTimer ( ) const
protectedvirtual

Returns the current time interval between two consecutive probes.

Returns
The time interval between two consecutive probes.

References t_probe.

Referenced by command(), start(), and transmit().

◆ initialize()

void SunIPRoutingSink::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 SunIPRoutingSink::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.

References ipAddr_, and PT_SUN_ACK.

Referenced by sendBackAck().

◆ printIP() [1/2]

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

Return 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 SunIPRoutingSink::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"

Referenced by printIP(), recv(), sendBackAck(), sendProbe(), writePathInTrace(), and ~SunIPRoutingSink().

◆ recv()

void SunIPRoutingSink::recv ( Packet *  p)
protectedvirtual

Performs the reception of packets from upper and lower layers.

Parameters
Packet*Pointer to the packet will be received.

References arrayofstats_, hdr_uwip::daddr(), ipAddr_, hdr_sun_data::list_of_hops_length(), numberofnodes_, printDebug_, printIP(), PT_SUN_ACK, PT_SUN_PATH_EST, PT_SUN_PROBE, hdr_uwip::saddr(), sendBackAck(), trace_, trace_path_, tracePacket(), and writePathInTrace().

Here is the call graph for this function:

◆ recvAsyncClMsg()

int SunIPRoutingSink::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 SunIPRoutingSink::recvSyncClMsg ( ClMessage *  m)
protectedvirtual

Cross-Layer messages synchronous interpreter.

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

◆ sendBackAck()

void SunIPRoutingSink::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
SunIPRoutingSink::initPktAck()

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

Referenced by recv().

Here is the call graph for this function:

◆ sendProbe()

void SunIPRoutingSink::sendProbe ( )
protectedvirtual

Creates and sends in broadcast a probe message to notify the presence of the sink.

References hdr_uwip::daddr(), getDelay(), ipAddr_, periodPoissonTraffic_, printDebug_, printIP(), probe_count_, PT_SUN_PROBE, hdr_uwip::saddr(), trace_, and tracePacket().

Referenced by command(), and transmit().

Here is the call graph for this function:

◆ setProbeTimer()

void SunIPRoutingSink::setProbeTimer ( const double &  t_)
protectedvirtual

Sets the probe interval timer.

Parameters
double&Time t in seconds between two consecutive probes.

References t_probe.

◆ start()

void SunIPRoutingSink::start ( )
protectedvirtual

Starts to send Probe packets.

References getProbeTimer(), and sendTmr_.

Referenced by command().

Here is the call graph for this function:

◆ stop()

void SunIPRoutingSink::stop ( )
protectedvirtual

Stops to send Probe packets.

References sendTmr_.

Referenced by command().

◆ str2addr()

nsaddr_t SunIPRoutingSink::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 SunIPRoutingSink::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 recv(), sendBackAck(), and sendProbe().

Here is the call graph for this function:

◆ transmit()

void SunIPRoutingSink::transmit ( )
protectedvirtual

Sends a single Probe packet.

References getProbeTimer(), sendProbe(), and sendTmr_.

Here is the call graph for this function:

◆ writeInTrace()

void SunIPRoutingSink::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().

◆ writePathInTrace()

void SunIPRoutingSink::writePathInTrace ( const Packet *  p)
protectedvirtual

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

Parameters
Packetto analyze.

References hdr_uwip::daddr(), hdr_sun_data::list_of_hops(), hdr_sun_data::list_of_hops_length(), osstream_, printIP(), hdr_uwip::saddr(), trace_file_path_, and trace_file_path_name_.

Referenced by recv().

Here is the call graph for this function:

Friends And Related Symbol Documentation

◆ SendTimer

friend class SendTimer
friend

Member Data Documentation

◆ arrayofstats_

unsigned int** SunIPRoutingSink::arrayofstats_
protected

Structure that contains the number of data packets received by the the sink, for different nodes and for different values of hop count. It is used for statistics purposes.

Referenced by command(), and recv().

◆ ipAddr_

nsaddr_t SunIPRoutingSink::ipAddr_
protected

◆ number_of_ackpkt_

long SunIPRoutingSink::number_of_ackpkt_ = 0
staticprotected

Comulative number of Ack packets processed by SunIPRoutingNode objects.

Referenced by getAckCount(), and sendBackAck().

◆ numberofnodes_

int SunIPRoutingSink::numberofnodes_
protected

Number of nodes in the network, used for statistic purposes.

Referenced by command(), and recv().

◆ osstream_

ostringstream SunIPRoutingSink::osstream_
protected

Used to convert to string.

Referenced by createTraceString(), and writePathInTrace().

◆ periodPoissonTraffic_

double SunIPRoutingSink::periodPoissonTraffic_
protected

Period of the Poisson traffic.

Referenced by sendBackAck(), sendProbe(), and SunIPRoutingSink().

◆ PoissonTraffic_

int SunIPRoutingSink::PoissonTraffic_
protected

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

Referenced by getDelay(), and SunIPRoutingSink().

◆ printDebug_

int SunIPRoutingSink::printDebug_
protected

Flag to enable or disable dirrefent levels of debug.

Referenced by recv(), sendBackAck(), sendProbe(), SunIPRoutingSink(), and ~SunIPRoutingSink().

◆ probe_count_

long SunIPRoutingSink::probe_count_ = 0
staticprotected

Comulative number of probes sent by SunIPRoutingSink objects.

Referenced by getProbeCount(), and sendProbe().

◆ sendTmr_

SendTimer SunIPRoutingSink::sendTmr_
protected

SendTimer object.

Referenced by start(), stop(), and transmit().

◆ t_probe

double SunIPRoutingSink::t_probe
protected

Period of the probing.

Referenced by getProbeTimer(), setProbeTimer(), and SunIPRoutingSink().

◆ trace_

bool SunIPRoutingSink::trace_
protected

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

Referenced by command(), recv(), sendBackAck(), sendProbe(), and tracePacket().

◆ trace_file_

ofstream SunIPRoutingSink::trace_file_
protected

Ofstream used to write the trace file in the disk.

Referenced by command(), and writeInTrace().

◆ trace_file_name_

char* SunIPRoutingSink::trace_file_name_
protected

Name of the trace file writter for the current node.

Referenced by command(), and writeInTrace().

◆ trace_file_path_

ofstream SunIPRoutingSink::trace_file_path_
protected

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

Referenced by command(), and writePathInTrace().

◆ trace_file_path_name_

char* SunIPRoutingSink::trace_file_path_name_
protected

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

Referenced by command(), and writePathInTrace().

◆ trace_path_

bool SunIPRoutingSink::trace_path_
protected

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

Referenced by command(), and recv().

◆ trace_separator_

char SunIPRoutingSink::trace_separator_
protected

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

Referenced by createTraceString(), and SunIPRoutingSink().


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