52 : TclClass(
"Module/UW/ICRPSink")
72 cout.setf(ios::floatfield, ios::fixed);
82 return Module::recvSyncClMsg(m);
92 return Module::recvAsyncClMsg(m);
100 sendSyncClMsgDown(m);
107 Tcl &tcl = Tcl::instance();
110 if (strcasecmp(argv[1],
"initialize") == 0) {
113 }
else if (strcasecmp(argv[1],
"getackheadersize") == 0) {
116 }
else if (strcasecmp(argv[1],
"getdataheadersize") == 0) {
119 }
else if (strcasecmp(argv[1],
"getstatusheadersize") == 0) {
122 }
else if (strcasecmp(argv[1],
"getackpktcount") == 0) {
125 }
else if (strcasecmp(argv[1],
"getstatuspktcount") == 0) {
129 }
else if (argc == 3) {
130 if (strcasecmp(argv[1],
"addr") == 0) {
131 ipAddr_ =
static_cast<uint8_t
>(atoi(argv[2]));
134 fprintf(stderr,
"0 is not a valid IP address");
140 return Module::command(argc, argv);
146 hdr_cmn *ch = HDR_CMN(p);
149 if (ch->direction() == hdr_cmn::UP) {
152 cout <<
"@" << Scheduler::instance().clock()
154 <<
" - CP: " << ch->uid()
155 <<
" - UP - Status Packet - Garbage." << endl;
161 cout <<
"@" << Scheduler::instance().clock()
163 <<
" - CP: " << ch->uid()
164 <<
" - UP - Ack Packet - Garbage." << endl;
168 if (ch->next_hop() !=
174 cout <<
"@" << Scheduler::instance().clock()
176 <<
" - CP: " << ch->uid()
177 <<
" - UP - Data Packet Received. Send it up."
186 cout <<
"@" << Scheduler::instance().clock()
188 <<
" - CP: " << ch->uid()
189 <<
" - UP - Data Packet Received: Send it Up and "
190 "Send back the Path."
192 Packet *p_new = Packet::alloc();
200 }
else if (ch->direction() == hdr_cmn::DOWN) {
202 cout <<
"@" << Scheduler::instance().clock()
204 <<
" - P: " << ch->uid()
205 <<
" - DOWN - Packet from upper layer - Garbage." << endl;
210 cout <<
"@" << Scheduler::instance().clock()
212 <<
" - P: " << ch->uid()
213 <<
" - ??? - NO_DIRECTION - Garbage." << endl;
224 hdr_cmn *ch_old = HDR_CMN(p_old);
225 hdr_cmn *ch_new = HDR_CMN(p_new);
229 ch_new->direction() = hdr_cmn::DOWN;
231 ch_new->next_hop() = ch_old->prev_hop_;
254 icrpstatush_new->
creation_time() = Scheduler::instance().clock();
257 ch_new->timestamp() = Scheduler::instance().clock();
263 std::stringstream out;
264 out <<
"0.0.0." << ((_ip & 0x000000ff));
271 Packet *p_ack = Packet::alloc();
273 hdr_cmn *ch = HDR_CMN(p);
274 hdr_cmn *ch_ack = HDR_CMN(p_ack);
278 ch_ack->direction() = hdr_cmn::DOWN;
279 ch_ack->next_hop() = ch->prev_hop_;
282 iph_ack->
daddr() = ch->prev_hop_;
285 ch_ack->timestamp() = Scheduler::instance().clock();
packet_t PT_UWICRP_STATUS
ClMessage_t UWIP_CLMSG_SEND_ADDR
Class that manages cross layer messages that require the IP of the node.
Class used to answer to UWIPClMsgReqAddr cross layer messages.
Adds the module for UwIcrpSinkModuleClass in ns2.
TclObject * create(int, const char *const *)
UwIcrpSink class is used to represent the routing layer of a node.
virtual void initStatusPkt(Packet *, Packet *)
Initializes a Status Packet previously allocated.
static long numberofackpkt_
Comulative number of Ack packets processed by UwIcrpSink objects.
virtual void initialize()
Initializes a UwIcrpSink node.
int printDebug_
Flag to enable or disable dirrefent levels of debug.
virtual void recv(Packet *)
Performs the reception of packets from upper and lower layers.
virtual int recvSyncClMsg(ClMessage *)
Cross-Layer messages synchronous interpreter.
uint8_t ipAddr_
IP of the current node.
static long numberofstatuspkt_
Comulative number of Status packets processed by UwIcrpSink objects.
UwIcrpSink()
Constructor of UwIcrpSink class.
virtual string printIP(const uint8_t)
Return a string with an IP in the classic form "x.x.x.x" converting an ns2 nsaddr_t address.
static const int getAckPktHeaderSize()
Returns the size in byte of a hdr_uwicrp_ack packet header.
static const int getStatusPktHeaderSize()
Returns the size in byte of a hdr_uwicrp_status packet header.
virtual void sendBackAck(const Packet *p)
Creates an ack packet and sends it to the previous hop using the information contained in the header ...
virtual int recvAsyncClMsg(ClMessage *)
Initializes a UwIcrpSink node.
static const int getDataPktHeaderSize()
Returns the size in byte of a hdr_uwicrp_data packet header.
virtual int command(int, const char *const *)
TCL command interpreter.
~UwIcrpSink()
Destructor of UwIcrpSink class.
hdr_uwicrp_ack describes acks packets used by UWICRP.
hdr_uwicrp_data describes data packets used by UWICRP
int & pointer_to_list_of_hops()
Reference to the pointer_to_list_of_hops_ variable.
int & list_of_hops_length()
Reference to the list_of_hops_length_ variable.
nsaddr_t * list_of_hops()
Pointer to the list_of_hops_ variable.
hdr_uwicrp_status describes status packets used by UWICRP
int & list_of_hops_length()
Reference to the list_of_hops_length_ variable.
double & creation_time()
Reference to the creation_time_ variable.
nsaddr_t * list_of_hops()
Pointer to the list_of_hops_ variable.
int & pointer_to_list_of_hops()
Reference to the pointer_to_list_of_hops_ variable.
hdr_uwip describes UWIP packets.
uint8_t & daddr()
Reference to the daddr_ variable.
uint8_t & saddr()
Reference to the saddr_ variable.
#define HDR_UWICRP_DATA(p)
#define HDR_UWICRP_STATUS(p)
packet_t PT_UWICRP_STATUS
UwIcrpSinkModuleClass class_module_uwicrp_sink
Provides a module for sinks that needs a simple and dynamic routing protocol.
static const uint8_t UWIP_BROADCAST
Variable used to represent a broadcast UWIP.