DESERT 3.5.1
Loading...
Searching...
No Matches
uwflooding.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 UWFLOODING_H
41#define UWFLOODING_H
42
43#define TTL_EQUALS_TO_ZERO \
44 "TEZ"
46#include "uwflooding-hdr.h"
47
48#include <uwip-module.h>
49#include <uwip-clmsg.h>
50#include <uwcbr-module.h>
51
52#include "mphy.h"
53#include "packet.h"
54#include <module.h>
55#include <tclcl.h>
56
57#include <cmath>
58#include <limits>
59#include <sstream>
60#include <string>
61#include <iostream>
62#include <rng.h>
63#include <ctime>
64#include <vector>
65#include <fstream>
66#include <map>
67#include <list>
68
69
70
74class UwFlooding : public Module
75{
76
77public:
81 UwFlooding();
82
86 virtual ~UwFlooding();
87
88protected:
89 /*****************************
90 | Internal Functions |
91 *****************************/
102 virtual int command(int, const char *const *);
103
109 virtual void recv(Packet *);
110
118 virtual int recvSyncClMsg(ClMessage *);
119
128 virtual int recvAsyncClMsg(ClMessage *);
129
137 static nsaddr_t str2addr(const char *);
138
144 virtual void writePathInTrace(const Packet *, const string &);
145
153 static string printIP(const nsaddr_t &);
154
155private:
156 // Variables
157
159 int ttl_;
166 char
174 typedef std::map<uint16_t, double> map_packets;
177 typedef std::map<uint8_t, map_packets>
183 std::map<uint16_t,uint8_t> ttl_traffic_map;
192
200 uint8_t getTTL(Packet* p) const;
201};
202
203#endif // UWFLOODING_H
Provides the header description for UWFLOODING packets.
UwFlooding class is used to represent the routing layer of a node.
Definition uwflooding.h:75
std::map< uint16_t, double > map_packets
Typedef for a packet id: (serial_number, timestamp).
Definition uwflooding.h:174
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".
UwFlooding()
Constructor of UwFlooding class.
uint8_t ipAddr_
Definition uwflooding.h:158
long packets_forwarded_
Number of packets forwarded by this module.
Definition uwflooding.h:163
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.
std::map< uint8_t, map_packets > map_forwarded_packets
Typedef for a map of the packet forwarded (saddr, map_packets).
Definition uwflooding.h:178
virtual int command(int, const char *const *)
TCL command interpreter.
virtual int recvAsyncClMsg(ClMessage *)
Cross-Layer messages asynchronous interpreter.
virtual void recv(Packet *)
Performs the reception of packets from upper and lower layers.
ofstream trace_file_path_
Ofstream used to write the path trace file in the disk.
Definition uwflooding.h:170
double maximum_cache_time_
Validity time of a packet entry.
Definition uwflooding.h:160
uint8_t getTTL(Packet *p) const
Get the value of the TTL.
char * trace_file_path_name_
Name of the trace file that contains the list of paths of the data packets received.
Definition uwflooding.h:167
virtual ~UwFlooding()
Destructor of UwFlooding class.
std::map< uint16_t, uint8_t > ttl_traffic_map
Map with ttl per traffic.
Definition uwflooding.h:183
UwFlooding(const UwFlooding &)
Copy constructor declared as private.
int optimize_
Flag used to enable the mechanism to drop packets processed twice.
Definition uwflooding.h:161
bool trace_path_
Flag used to enable or disable the path trace file for nodes,.
Definition uwflooding.h:164
virtual int recvSyncClMsg(ClMessage *)
Cross-Layer messages synchronous interpreter.
virtual void writePathInTrace(const Packet *, const string &)
Writes in the Path Trace file the path contained in the Packet.
ostringstream osstream_
Used to convert to string.
Definition uwflooding.h:172
map_forwarded_packets my_forwarded_packets_
Map of the packet forwarded.
Definition uwflooding.h:181
int ttl_
Time to leave of the UWFLOODING packets.
Definition uwflooding.h:159
Provides the UWCBR packets header description and the definition of the class UWCBR.
Cross layer messages definition for the UWIP Module.
Provides the UWIP packets header description. Definition of the class that define the network layer.