53 : TclClass(
"Module/UW/FLOODING")
71 : PacketHeaderClass(
"PacketHeader/FLOODING", sizeof(
hdr_uwflooding))
81 , maximum_cache_time_(60)
83 , packets_forwarded_(0)
85 , trace_file_path_name_((char *)
"trace")
100 return Module::recvSyncClMsg(
m);
106 return Module::recvAsyncClMsg(
m);
112 Tcl &
tcl = Tcl::instance();
122 }
else if (
argc == 3) {
144 }
else if (
argc == 4) {
162 if (
ch->direction() == hdr_cmn::UP) {
165 if (
iph->daddr() == 0) {
166 std::cerr <<
"Destination address not set." << std::endl;
191 ch->direction() = hdr_cmn::DOWN;
196 if (
flh->ttl() <= 0) {
203 map_forwarded_packets::iterator
it2 =
206 map_packets::iterator
it3 =
207 it2->second.find(
ch->uid());
209 if (
it3 ==
it2->second.end()) {
213 it2->second.insert(std::pair<uint16_t, double>(
214 ch->uid(),
ch->timestamp()));
220 }
else if (Scheduler::instance().
clock() -
228 it3->second = Scheduler::instance().clock();
241 std::map<uint16_t, double>
tmp_map;
242 tmp_map.insert(std::pair<uint16_t, double>(
243 ch->uid(), Scheduler::instance().clock()));
245 std::pair<uint8_t, map_packets>(
263 ch->direction() = hdr_cmn::DOWN;
267 if (
flh->ttl() <= 0) {
274 map_forwarded_packets::iterator
it2 =
277 map_packets::iterator
it3 =
278 it2->second.find(
ch->uid());
280 if (
it3 ==
it2->second.end()) {
284 it2->second.insert(std::pair<uint16_t, double>(
285 ch->uid(),
ch->timestamp()));
291 }
else if (Scheduler::instance().
clock() -
299 it3->second = Scheduler::instance().clock();
312 std::map<uint16_t, double>
tmp_map;
313 tmp_map.insert(std::pair<uint16_t, double>(
314 ch->uid(), Scheduler::instance().clock()));
316 std::pair<uint8_t, map_packets>(
332 cerr <<
"State machine ERROR." <<
endl;
338 }
else if (
ch->direction() == hdr_cmn::DOWN) {
341 if (
iph->daddr() == 0) {
342 std::cerr <<
"Destination address equals to 0." << std::endl;
364 cerr <<
"Direction different from UP or DOWN." <<
endl;
400 osstream_ << Scheduler::instance().clock();
425 out << ((
ip_ & 0xff000000) >> 24);
427 out << ((
ip_ & 0x00ff0000) >> 16);
429 out << ((
ip_ & 0x0000ff00) >> 8);
431 out << ((
ip_ & 0x000000ff));
#define HDR_UWFLOODING(p)
Adds the module for SunIPRoutingSink in ns2.
TclObject * create(int, const char *const *)
Adds the header for hdr_uwflooding packets in ns2.
UwFlooding class is used to represent the routing layer of a node.
UwFlooding()
Constructor of UwFlooding class.
long packets_forwarded_
Number of packets forwarded by this module.
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 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.
double maximum_cache_time_
Validity time of a packet entry.
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.
virtual ~UwFlooding()
Destructor of UwFlooding class.
std::map< uint16_t, uint8_t > ttl_traffic_map
Map with ttl per traffic.
int optimize_
Flag used to enable the mechanism to drop packets processed twice.
bool trace_path_
Flag used to enable or disable the path trace file for nodes,.
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.
map_forwarded_packets my_forwarded_packets_
Map of the packet forwarded.
int ttl_
Time to leave of the UWFLOODING packets.
hdr_uwcbr describes UWCBR packets.
hdr_uwflooding describes packets used by UWFLOODING.
static int offset_
Required by the PacketHeaderManager.
hdr_uwip describes UWIP packets.
UwFloodingPktClass class_uwflooding_pkt
UwFloodingModuleClass class_module_uwflooding
Flooding based routing protocol.
#define TTL_EQUALS_TO_ZERO
Reason for a drop in a UWFLOODING module.
static const uint8_t UWIP_BROADCAST
Variable used to represent a broadcast UWIP.