DESERT 3.5.1
Loading...
Searching...
No Matches
uwicrp-module-sink.h
Go to the documentation of this file.
1//
2// Copyright (c) 2017 Regents of the SIGNET lab, University of Padova.
3// All rights reserved.
4//
5// Redistribution and use in source and binary forms, with or without
6// modification, are permitted provided that the following conditions
7// are met:
8// 1. Redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer.
10// 2. Redistributions in binary form must reproduce the above copyright
11// notice, this list of conditions and the following disclaimer in the
12// documentation and/or other materials provided with the distribution.
13// 3. Neither the name of the University of Padova (SIGNET lab) nor the
14// names of its contributors may be used to endorse or promote products
15// derived from this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
20// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
21// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
24// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
26// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28//
29
40#ifndef UWICRP_MODULE_SINK_H
41#define UWICRP_MODULE_SINK_H
42
43#include "uwicrp-hdr-ack.h"
44#include "uwicrp-hdr-data.h"
45#include "uwicrp-hdr-status.h"
46#include "uwicrp-common.h"
47#include <uwip-module.h>
48#include <uwip-clmsg.h>
49#include "packet.h"
50
51#include <sstream>
52#include <string>
53#include <iostream>
54#include <rng.h>
55#include <ctime>
56#include <module.h>
57#include <tclcl.h>
58#include <vector>
59
60
61
65class UwIcrpSink : public Module
66{
67
68public:
72 UwIcrpSink();
73
78
79protected:
87 virtual int recvSyncClMsg(ClMessage *);
88
97 virtual int recvAsyncClMsg(ClMessage *);
98
109 virtual int command(int, const char *const *);
110
116 virtual void recv(Packet *);
117
125 virtual void initStatusPkt(Packet *, Packet *);
126
135 virtual void initialize();
136
146 virtual void sendBackAck(const Packet *p);
147
155 virtual string printIP(const uint8_t);
156
162 static inline const int
164 {
165 return sizeof(hdr_uwicrp_ack);
166 }
167
173 static inline const int
175 {
176 return sizeof(hdr_uwicrp_data);
177 }
178
184 static inline const int
186 {
187 return sizeof(hdr_uwicrp_status);
188 }
189
190 uint8_t ipAddr_;
194private:
195 static long
198 static long numberofstatuspkt_;
200};
201
202#endif // UWICRP_MODULE_SINK_H
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
hdr_uwicrp_status describes status packets used by UWICRP
Common structures and definition used by UWICRP.
Provides the Ack Messages header description.
Provides the Data Messages header description.
Provides the Status Messages header description.
Cross layer messages definition for the UWIP Module.
Provides the UWIP packets header description. Definition of the class that define the network layer.