Flood.h

00001 /* -*- mode:c++ -*- ********************************************************
00002  * file:        Flood.h
00003  *
00004  * author:      Daniel Willkomm
00005  *
00006  * copyright:   (C) 2004 Telecommunication Networks Group (TKN) at
00007  *              Technische Universitaet Berlin, Germany.
00008  *
00009  *              This program is free software; you can redistribute it 
00010  *              and/or modify it under the terms of the GNU General Public 
00011  *              License as published by the Free Software Foundation; either
00012  *              version 2 of the License, or (at your option) any later 
00013  *              version.
00014  *              For further information see file COPYING 
00015  *              in the top level directory
00016  *
00017  ***************************************************************************
00018  * part of:     framework implementation developed by tkn
00019  * description: a simple flooding protocol
00020  *              the user can decide whether to use plain flooding or not
00021  **************************************************************************/
00022 
00023 
00024 #ifndef _FLOOD_H_
00025 #define _FLOOD_H_
00026 
00027 #include <BaseNetwLayer.h>
00028 #include <list>
00029 
00030 
00050 class Flood : public BaseNetwLayer
00051 {
00052 protected:
00054     unsigned long seqNum;
00055 
00057     int defaultTtl;
00058 
00060     bool plainFlooding;
00061 
00062     class Bcast {
00063     public:
00064         unsigned long seqNum;
00065         int srcAddr;
00066         simtime_t delTime;
00067     public:
00068         Bcast(unsigned long n=0, int s=0,  simtime_t d=0) :
00069             seqNum(n), srcAddr(s), delTime(d) {
00070         }
00071     };
00072 
00073     typedef std::list<Bcast> cBroadcastList;
00074 
00076     cBroadcastList bcMsgs;
00077 
00082     unsigned int bcMaxEntries;
00083 
00088     simtime_t bcDelTime;
00089 
00090 public:
00091 
00092 
00094     virtual void initialize(int);
00095     virtual void finish();    
00096 
00097 protected:
00098 
00099     long nbDataPacketsReceived;
00100     long nbDataPacketsSent;
00101     long nbDataPacketsForwarded;
00102     long nbHops;
00103 
00105     virtual void handleUpperMsg(cMessage *);
00106 
00108     virtual void handleLowerMsg(cMessage *);
00109 
00111     virtual void handleSelfMsg(cMessage* msg) {};
00112     
00114     bool notBroadcasted( NetwPkt* );
00115 
00116     //overloading encaps method
00117     NetwPkt* encapsMsg(cPacket*);
00118 };
00119 
00120 #endif