58 : TclClass(
"Module/UW/SUNNode")
73 module->expTimerHopTable();
87 module->searchPathExpire();
103 , search_path_enable_(true)
104 , reset_buffer_if_error_(0)
105 , pointer_packets_(0)
107 , list_packets_max_time_(0)
108 , list_acks_max_time_(0)
109 , packets_array_full(false)
110 , acks_array_full(false)
113 , ack_warnings_counter_(0)
114 , ack_error_state(false)
115 , buffer_max_size_(1)
116 , safe_timer_buffer_(0)
117 , timer_route_validity_(5)
118 , timer_sink_probe_validity_(200)
120 , timer_search_path_(60)
121 , rmhopTableTmr_(this)
122 , sinkProbeTimer_(this)
124 , searchPathTmr_(this)
126 , n_paths_established(0)
130 std::cout <<
"> SunIPRoutingNode()" << std::endl;
163 std::cout <<
"> ~SunIPRoutingNode()" << std::endl;
178 std::cout <<
"> recvSyncClMsg()" << std::endl;
179 return Module::recvSyncClMsg(
m);
186 std::cout <<
"> recvAsyncClMsg()" << std::endl;
191 return Module::recvAsyncClMsg(
m);
200 std::cout <<
"> clearHops()" << std::endl;
204 <<
"]::CLEARING_HOPS::";
208 std::cout << std::endl;
239 std::cout <<
"> initialize()" << std::endl;
253 std::cout <<
"> printHopTable()" << std::endl;
255 std::cout <<
"HOPS_LIST:" <<
"\n";
259 std::cout << std::endl;
266 std::cout <<
"END_NODES_MAP:" <<
"\n";
268 std::cout <<
"NODE::" <<
printIP(
it->first) <<
"::SELECTED::" << (
uint)
it->second <<
"::TIMES\n";
271 std::cout << std::endl;
282 std::cout <<
"> printIP()" << std::endl;
284 out << ((
ip_ & 0xff000000) >> 24);
286 out << ((
ip_ & 0x00ff0000) >> 16);
288 out << ((
ip_ & 0x0000ff00) >> 8);
290 out << ((
ip_ & 0x000000ff));
307 std::cout <<
"> str2addr()" << std::endl;
308 int level[4] = {0, 0, 0, 0};
321 for (
int i = 0;
i < 4;
i++) {
332 std::cout <<
"> command()" << std::endl;
333 Tcl &
tcl = Tcl::instance();
339 }
else if (
strcasecmp(argv[1],
"clearhops") == 0) {
342 }
else if (
strcasecmp(argv[1],
"printhopcount") == 0) {
345 <<
" not connected to the sink." << std::endl;
353 }
else if (
strcasecmp(argv[1],
"printselectedroutes") == 0) {
359 }
else if (
strcasecmp(argv[1],
"getdatapktcount") == 0) {
362 }
else if (
strcasecmp(argv[1],
"getforwardedcount") == 0) {
365 }
else if (
strcasecmp(argv[1],
"getdatapktdroppedbuffer") == 0) {
368 }
else if (
strcasecmp(argv[1],
"getdatapktdroppedmaxretx") == 0) {
371 }
else if (
strcasecmp(argv[1],
"getpathestablishmentpktcount") == 0) {
374 }
else if (
strcasecmp(argv[1],
"getackheadersize") == 0) {
377 }
else if (
strcasecmp(argv[1],
"getdatapktheadersize") == 0) {
380 }
else if (
strcasecmp(argv[1],
"getpathestheadersize") == 0) {
383 }
else if (
strcasecmp(argv[1],
"getNpathsestablished") == 0) {
402 tcl.resultf(
"%d", 0);
407 double retx = std::max(
double(
num) /
double(
den),
double(0));
415 }
else if (
argc == 3) {
453 std::cout <<
"> recv()" << std::endl;
463 if (
ch->direction() == hdr_cmn::UP) {
481 <<
"]::RECEIVED_PATH_EST::REQUEST_FROM:"
483 <<
"::UID:" <<
ch->uid()
484 <<
"::SENDING_REPLYPATHESTABLISHMENT"
504 std::cout <<
"[" <<
NOW
507 <<
"]::RECEIVED_PATH_EST::PATH_ANSWER_FROM:"
510 <<
"::UID:" <<
ch->uid()
520 std::cout <<
"[" <<
NOW
523 <<
"]::RECEIVED_PATH_EST::PATH_ANSWER_FROM:"
525 <<
"::SEND_ROUTE_BACK"
543 std::cout <<
"[" <<
NOW
546 <<
"]::PATH_EST:PATH_ERROR_FROM:"
583 std::cout <<
"[" <<
NOW
586 <<
"]::RECEIVED_ACK_FROM:"
588 <<
"::UID:" <<
hack->uid()
605 (Scheduler::instance().clock() -
609 (Scheduler::instance().
clock() -
613 (Scheduler::instance().clock() -
619 std::cout <<
"[" <<
NOW
623 <<
"::PACKET_REMOVED:" << ch->uid()
640 std::cout <<
"[" <<
NOW
643 <<
"]::RECEIVED_PROBE_FROM:"
659 std::cout <<
"[" <<
NOW
662 <<
"]::RECEIVED_DATA_FROM:"
664 <<
"::PREV_HOP:" <<
printIP(
ch->prev_hop_)
665 <<
"::UID:" <<
ch->uid()
678 }
else if ((
ch->next_hop() ==
ipAddr_) &&
687 std::cout <<
"[" <<
NOW
690 <<
"]::DATA_PACKET_TO_FORWARD"
695 <<
"::UID:" <<
ch->uid()
696 <<
"::SN:" <<
uwcbrh->sn()
698 for (
int i = 0;
i <
hdata->list_of_hops_length();
i++) {
701 std::cout << std::endl;
719 Scheduler::instance().clock()));
723 std::cout <<
"[" <<
NOW
726 <<
"]::BUFFER_FULL:DROPPING_PACKET"
727 <<
"::UID:" << ch->uid()
738 std::cout <<
"[" <<
NOW
741 <<
"]::DROPPING_PACKET::WRONG_IP"
746 }
else if (
ch->direction() ==
758 std::cout <<
"[" <<
NOW
761 <<
"]::TO_SEND::PACKET_BUFFERED"
762 <<
"::UID:" << ch->uid()
763 <<
"::SN::" <<
uwcbrh->sn()
768 Scheduler::instance().clock()));
772 std::cout <<
"[" <<
NOW
775 <<
"]::TO_SEND::DROPPING::BUFFER_FULL"
787 std::cout <<
"[" <<
NOW
790 <<
"]::TO_SEND::PACKET_BUFFERED"
791 <<
"::UID:" << ch->uid()
792 <<
"::SN::" <<
uwcbrh->sn()
797 Scheduler::instance().clock()));
801 std::cout <<
"[" <<
NOW
804 <<
"]::TO_SEND::DROPPING::BUFFER_FULL"
811 std::cout <<
"[" <<
NOW
814 <<
"]::BEGIN_SEARCH_PATH"
828 std::cout <<
"[" <<
NOW
831 <<
"]::DOWN:DATA:DROP:NO_DIRECTION"
849 std::cout <<
"> setNumberOfHopToSink()" << std::endl;
868 std::cout <<
"> getNumberOfHopToSink()" << std::endl;
876 std::cout <<
"> receiveProbe()" << std::endl;
879 if (this->
isZero(ph->Pn)) {
886 std::cout <<
"[" <<
NOW
889 <<
"]::BECAME_END_NODE"
893 }
else if (10 *
log10(
ph->Pr / (
ph->Pi +
ph->Pn)) >
905 std::cout <<
"[" <<
NOW
908 <<
"]::BECAME_END_NODE"
923 std::cout <<
"> lostSink()" << std::endl;
936 std::cout <<
"> searchPathExpire()" << std::endl;
948 std::cout <<
"> expTimerHopTable()" << std::endl;
950 std::cout <<
"[" <<
NOW
953 <<
"]::ROUTING_TABLE_EXPIRED"
963 std::cout <<
"> tracePacket()" << std::endl;
978 Scheduler::instance().
clock(),
991 Scheduler::instance().
clock(),
1008 const double &simulation_time_,
const int &node_id_,
const int &pkt_id_,
1009 const int &pkt_sn_,
const int &pkt_from_,
const int &pkt_next_hop,
1010 const int &pkt_source_,
const int &pkt_destination_,
const double &snr_,
1011 const int &direction_,
const int &pkt_type)
1014 std::cout <<
"> createTraceString()" << std::endl;
1034 std::cout <<
"> writeInTrace()" << std::endl;
ClMessage_t UWIP_CLMSG_SEND_ADDR
SunIPRoutingNode *virtual void expire(Event *e)
< Pointer to an objet of type SunIPRoutingNode.
SunIPRoutingNode *virtual void expire(Event *e)
< Pointer to an objet of type SunIPRoutingNode.
virtual void expire(Event *e)
Method invoked when the SinkProbeTimer timer expires.
SunIPRoutingNode class is used to represent the routing layer of a node.
virtual void replyPathEstSearch(Packet *)
Replies to Path Establishment Search packets.
static string printIP(const nsaddr_t &)
Returns a string with an IP in the classic form "x.x.x.x" converting an ns2 nsaddr_t address.
double timer_route_validity_
Maximum validity time for a route entry.
uint max_retx_
Maximum Number of transmissions performed: real retransmissions counter the counter is increased only...
const long & getPathEstablishmentCount() const
Returns the number of Path Establishment packets processed by the entire network.
virtual void writeInTrace(const string &)
Opens the trace file, writes the string passed as input and closes the file.
vector< buffer_element > buffer_data
Buffer used to store data packets.
virtual void printSelectedRoutes() const
Print the nodes that were chosen as relay nodes to rach the sink and how many times each node was cho...
double timer_sink_probe_validity_
Maximum validity time for a sink probe.
ostringstream osstream_
Used to convert to string.
const long & getNPathsEstablished()
Print how many times the node was established as relay node for other nodes of the netwok.
char trace_separator_
Used as separator among elements in an entr of the tracefile.
bool search_path_enable_
Flag to enable or disable the possibility to send search_path packets.
static long number_of_datapkt_
Comulative number of Data packets processed by SunIPRoutingNode objects.
virtual int command(int, const char *const *)
TCL command interpreter.
const long & getForwardedCount() const
Returns the number of Data packets forwarded by the entire network.
virtual void clearHops()
Clears all the route information of the current node.
double probe_min_snr_
Value below which if a node receives a probe it discards it.
static const int getDataPktHeaderSize()
Returns the size in byte of a hdr_sun_data packet header.
nsaddr_t * hop_table
List of IPs to reach the sink.
int disable_path_error_
Flag to enable or disable the possibility to send Path Error packets.
std::map< uint8_t, uint > paths_selected
Map containing the nodes selected as relay to the sink and the number of times each node was selected...
bool trace_
Flag used to enable or disable the trace file for nodes,.
static long number_of_ackpkt_
Comulative number of Ack packets processed by SunIPRoutingNode objects.
virtual const int & getNumberOfHopToSink() const
Returns the number of hops that separate the node to the sink.
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".
virtual void updatePacketsCount()
Updates the number of packets processed by the current node.
virtual const int & evaluatePath(const Packet *)
Evaluates the route information contained in a Path Establishment packet, and according to different ...
const long & getDataDropsCountBuffer() const
Returns the number of packets dropped by the entire network for the reason: buffer is full.
int hop_table_length
Current length of the hop_table.
SinkProbeTimer sinkProbeTimer_
SinkProbeTimer object.
virtual void expTimerHopTable()
This function is invoked when the timer of the routing table expires.
int data_and_hops[MAX_HOP_NUMBER]
Structure that contains the number of data packets sent by the current node to the sink,...
virtual void sendRouteBack(Packet *)
Forwards a Path Establishment Answer Packet.
ofstream trace_file_
Ofstream used to write the trace file in the disk.
char * trace_file_name_
Name of the trace file writter for the current node.
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 &)
Function that accepts a list of string and create an entry for the trace file.
int reset_buffer_if_error_
If == 1 when a node identify a broken link it will automatically free its buffer.
static long number_of_pathestablishment_
Comulative number of Path Establishment packets processed by SunIPRoutingNode objects.
double snr_to_sink_
SNR between the sink and the current node.
static long number_of_pkt_forwarded_
Comulative number of Data packets forwarded by the network.
double period_status_
Period of the Poisson traffic for status and ack packets.
BufferTimer bufferTmr_
BufferTimer object.
nsaddr_t sink_associated
IP of the sink associated to the node.
virtual void updateAcksCount()
Updates the number of acks received by the current node.
static const int getPathEstHeaderSize()
Returns the size in byte of a hdr_sun_path_est packet header.
double timer_buffer_
Timer for buffer management.
virtual void receiveProbe(const Packet *)
Invoked when the node receives a probe packet from a sink.
virtual const int & setNumberOfHopToSink(const int &)
Sets the number of hops that the current node needs to reach the sink.
double period_data_
Period of the Poisson traffic for data packets in the buffer.
virtual void sendBackAck(const Packet *)
Creates an ack packet and sends it to the previous hop using the information contained in the header ...
double alpha_
Parameters used by Load metric.
SearchPathTimer searchPathTmr_
SearchPathTimer object.
SunIPRoutingNode()
Constructor of SunIPRoutingNode class.
bool ack_error_state
true if the node is not in an error state (that means that it discovered a broken link),...
const long & getDataCount() const
Returns the number of Data packets processed by the entire network.
int PoissonTraffic_
Enable (1) or disable (0) the Poisson traffic for SUN packets.
static const int getAckHeaderSize()
Returns the size in byte of a hdr_sun_ack packet header.
const long & getAckCount() const
Returns the number of Ack packets processed by the entire network.
double quality_link
Quality of the link from the node to the sink.
virtual void lostSink()
This function removes all the information about routing information and sink association.
virtual void searchPath()
Sends a Path Establishment Packet with the option field sets to Search.
const long & getDataDropsCountMaxRetx() const
Returns the number of packets dropped by the entire network for the reason: maximum number of retrans...
uint32_t buffer_max_size_
Maximum length of the data buffer.
virtual void printHopTable() const
Prints in the stdout the routing table of the current node.
virtual int recvSyncClMsg(ClMessage *)
Cross-Layer messages synchronous interpreter.
int ack_warnings_counter_
Number of acks lost since the last reset.
int max_ack_error_
Maximum number of Ack errors tollerated by the node.
virtual void searchPathExpire()
This function enable the possibility to send a new Seath Path packet.
int printDebug_
Flag to enable or disable dirrefent levels of debug.
virtual void sendRouteErrorBack(Packet *)
Send back an error packet to the previous hop.
virtual ~SunIPRoutingNode()
Destructor of SunIPRoutingNode class.
long pkt_stored_
Keep track of the total number of packet transmitted.
virtual void initialize()
Initializes a SunIPRoutingNode node.
static long number_of_drops_buffer_full_
Comulative number of packets dropped by SunIPRoutingNode objects, reason: the buffer is full.
virtual void tracePacket(const Packet *const, const string &position="UNDEF___")
Traces a packet.
nsaddr_t ipAddr_
IP of the current node.
int metrics_
Metric used by the current node.
virtual int recvAsyncClMsg(ClMessage *)
Cross-Layer messages asynchronous interpreter.
long pkt_tx_
Keep track of the total number of packet retransmitted.
double timer_search_path_
Timer for the search path mechanism.
virtual void recv(Packet *)
Performs the reception of packets from upper and lower layers.
static long number_of_drops_maxretx_
Comulative number of packets dropped by SunIPRoutingNode objects, reason: max number of retransmissio...
const bool isZero(const double &value) const
Evaluates is the number passed as input is equal to zero.
int num_hop_to_sink
Number of hops needed to reach the sink using tha path saved tn the routing table.
int safe_timer_buffer_
Enables a mechanism used to modify the timer_buffer_ in case of the sending time is shorter than the ...
Adds the module for SunIPRoutingNode in ns2.
TclObject * create(int, const char *const *)
Class that manages cross layer messages that require the IP of the node.
Class used to answer to UWIPClMsgReqAddr cross layer messages.
buffer_element describes an entry in the buffer used by SUN.
hdr_sun_ack describes acks packets used by UWSUN.
hdr_sun_data describes data packets used by UWSUN
hdr_sun_path_est describes path establishment packets used by UWSUN
hdr_uwcbr describes UWCBR packets.
hdr_uwip describes UWIP packets.
uint8_t & daddr()
Reference to the daddr_ variable.
uint8_t & saddr()
Reference to the saddr_ variable.
#define HDR_SUN_PATH_EST(p)
#define DROP_BUFFER_IS_FULL
Reason for a drop in a UWSUN module.
#define DROP_PACKET_NOT_FOR_ME
Reason for a drop in a UWSUN module.
#define STACK_TRACE
Used to keep track of methods call.
#define DROP_PACKET_WITHOUT_DIRECTION
Reason for a drop in a UWSUN module.
SunNodeModuleClass class_module_sun_node
Dinamic source routing protocol, this file contains Nodes specifications.
static const int MAX_HOP_NUMBER
Maximum number of hops contained in a SUN Path Establishment packet.
static const uint8_t UWIP_BROADCAST
Variable used to represent a broadcast UWIP.