41#include "mphy_pktheader.h"
58 : TclClass(
"Module/UW/SUNSink")
84 std::cout <<
"> SunIPRoutingSink()" << std::endl;
96 std::cout <<
"> ~SunIPRoutingSink()" << std::endl;
98 std::cout <<
"S: " << this->
printIP(
ipAddr_) <<
" deleted." << std::endl;
105 std::cout <<
"> recvSyncClMsg()" << std::endl;
106 return Module::recvSyncClMsg(
m);
113 std::cout <<
"> recvAsyncClMsg()" << std::endl;
118 return Module::recvAsyncClMsg(
m);
125 std::cout <<
"> command()" << std::endl;
126 Tcl &
tcl = Tcl::instance();
131 }
else if (
strcasecmp(argv[1],
"start") == 0) {
140 }
else if (
strcasecmp(argv[1],
"sendprobe") == 0) {
143 }
else if (
strcasecmp(argv[1],
"getprobetimer") == 0) {
146 }
else if (
strcasecmp(argv[1],
"getprobepktcount") == 0) {
149 }
else if (
strcasecmp(argv[1],
"getackcount") == 0) {
152 }
else if (
strcasecmp(argv[1],
"getprobepktheadersize") == 0) {
155 }
else if (
strcasecmp(argv[1],
"getackheadersize") == 0) {
159 }
else if (argc == 3) {
203 }
else if (
argc == 4) {
226 std::cout <<
"> recv()" << std::endl;
234 if (
ch->direction() == hdr_cmn::UP) {
245 std::cout <<
"[" <<
NOW
248 <<
"::UID:" <<
ch->uid()
249 <<
"::::::PREV_HOP:" <<
printIP(
ch->prev_hop_)
260 int ip_ = (
iph->saddr() & 0x000000ff);
262 [
hdata->list_of_hops_length()]++;
282 }
else if (
ch->direction() == hdr_cmn::DOWN) {
295 std::cout <<
"> initialize()" << std::endl;
308 std::cout <<
"> sendProbe()" << std::endl;
309 Packet *p = Packet::alloc();
315 ch->direction() = hdr_cmn::DOWN;
326 ch->timestamp() = Scheduler::instance().clock();
329 std::cout <<
"[" <<
NOW
332 <<
"::UID:" << ch->uid()
346 std::cout <<
"> printIP()" << std::endl;
348 out << ((
ip_ & 0xff000000) >> 24);
350 out << ((
ip_ & 0x00ff0000) >> 16);
352 out << ((
ip_ & 0x0000ff00) >> 8);
354 out << ((
ip_ & 0x000000ff));
371 std::cout <<
"> str2addr()" << std::endl;
372 int level[4] = {0, 0, 0, 0};
385 for (
int i = 0;
i < 4;
i++) {
395 std::cout <<
"> start()" << std::endl;
403 std::cout <<
"> stop()" << std::endl;
411 std::cout <<
"> transmit()" << std::endl;
420 std::cout <<
"> setProbeTimer()" << std::endl;
430 std::cout <<
"> getProbeTimer()" << std::endl;
438 std::cout <<
"> sendBackAck()" << std::endl;
454 std::cout <<
"[" <<
NOW
456 <<
"]::UID:" << ch->uid()
471 std::cout <<
"> initPktPathEstSearch()" << std::endl;
478 ch->direction() = hdr_cmn::DOWN;
489 ch->timestamp() = Scheduler::instance().clock();
496 std::cout <<
"> tracePacket()" << std::endl;
511 Scheduler::instance().
clock(),
524 Scheduler::instance().
clock(),
541 const double &simulation_time_,
const int &node_id_,
const int &pkt_id_,
542 const int &pkt_sn_,
const int &pkt_from_,
const int &pkt_next_hop,
543 const int &pkt_source_,
const int &pkt_destination_,
const double &snr_,
544 const int &direction_,
const int &pkt_type)
547 std::cout <<
"> createTraceString()" << std::endl;
567 std::cout <<
"> writeInTrace()" << std::endl;
578 std::cout <<
"> writePathInTrace()" << std::endl;
587 osstream_ << Scheduler::instance().clock() <<
'\t' <<
ch->uid() <<
'\t'
588 <<
hdata->list_of_hops_length() + 1 <<
'\t'
590 for (
int i = 0;
i <
hdata->list_of_hops_length();
i++) {
ClMessage_t UWIP_CLMSG_SEND_ADDR
virtual void expire(Event *e)
Method invoked when the SinkProbeTimer timer expires.
SunIPRoutingSink class is used to represent the routing layer of a 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".
int PoissonTraffic_
Enable (1) or disable (0) the Poisson traffic for SUN packets.
virtual void start()
Starts to send Probe packets.
virtual void writePathInTrace(const Packet *)
Writes in the Path Trace file the path contained in the Packet.
SunIPRoutingSink()
Constructor of SunIPRoutingNode class.
static long number_of_ackpkt_
Comulative number of Ack packets processed by SunIPRoutingNode objects.
virtual ~SunIPRoutingSink()
Constructor of SunIPRoutingNode class.
bool trace_
Flag used to enable or disable the trace file for nodes,.
virtual int recvAsyncClMsg(ClMessage *)
Cross-Layer messages asynchronous interpreter.
virtual void setProbeTimer(const double &)
Sets the probe interval timer.
static const int getProbePktHeaderSize()
Returns the size in byte of a hdr_sun_probe packet header.
static const int getAckHeaderSize()
Returns the size in byte of a hdr_sun_ack packet header.
virtual void transmit()
Sends a single Probe packet.
virtual void initPktAck(Packet *)
Initializes an ack packet passed as argument with the default values.
const double getDelay(const double &period_) const
Returns a delay value to use in transmission.
virtual void sendProbe()
Creates and sends in broadcast a probe message to notify the presence of the sink.
const long & getAckCount() const
Returns the number of Ack packets processed by the entire network.
const long & getProbeCount() const
Returns the number of Probe packets processed by the entire network.
double periodPoissonTraffic_
Period of the Poisson traffic.
char trace_separator_
Used as separator among elements in an entr of the tracefile.
bool trace_path_
Flag used to enable or disable the path trace file for nodes,.
SendTimer sendTmr_
SendTimer object.
virtual const double & getProbeTimer() const
Returns the current time interval between two consecutive probes.
char * trace_file_path_name_
Name of the trace file that contains the list of paths of the data packets received.
virtual void sendBackAck(const Packet *)
Creates an ack packet and sends it to the previous hop using the information contained in the header ...
virtual void initialize()
Initializes a SunIPRoutingNode 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 accept a list of string and create an entry for the trace file.
nsaddr_t ipAddr_
IP of the current node.
ostringstream osstream_
Used to convert to string.
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.
virtual int recvSyncClMsg(ClMessage *)
Cross-Layer messages synchronous interpreter.
virtual int command(int, const char *const *)
TCL command interpreter.
virtual void writeInTrace(const string &)
Opens the trace file, writes the string passed as input and closes the file.
virtual void recv(Packet *)
Performs the reception of packets from upper and lower layers.
virtual void tracePacket(const Packet *const, const string &position="UNDEF___")
Traces a packet.
ofstream trace_file_
Ofstream used to write the trace file in the disk.
double t_probe
Period of the probing.
int numberofnodes_
Number of nodes in the network, used for statistic purposes.
int printDebug_
Flag to enable or disable dirrefent levels of debug.
char * trace_file_name_
Name of the trace file writter for the current node.
ofstream trace_file_path_
Ofstream used to write the path trace file in the disk.
unsigned int ** arrayofstats_
Structure that contains the number of data packets received by the the sink, for different nodes and ...
static long probe_count_
Comulative number of probes sent by SunIPRoutingSink objects.
virtual void stop()
Stops to send Probe packets.
Adds the module for SunIPRoutingSink 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.
hdr_sun_ack describes acks packets used by UWSUN.
hdr_sun_data describes data packets used by UWSUN
uint8_t * list_of_hops()
Pointer to the list_of_hops_ variable.
hdr_sun_probe describes probe 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.
Common structures and definition used by SUN.
#define STACK_TRACE
Used to keep track of methods call.
static int sunuid_
Unique identifier for UWSUN packets.
SunSinkModuleClass class_module_sun_sink
Dinamic source routing protocol, this file contains Sinks 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.