Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

diff_prob.h

Go to the documentation of this file.
00001 // Copyright (c) 2000 by the University of Southern California
00002 // All rights reserved.
00003 //
00004 // Permission to use, copy, modify, and distribute this software and its
00005 // documentation in source and binary forms for non-commercial purposes
00006 // and without fee is hereby granted, provided that the above copyright
00007 // notice appear in all copies and that both the copyright notice and
00008 // this permission notice appear in supporting documentation. and that
00009 // any documentation, advertising materials, and other materials related
00010 // to such distribution and use acknowledge that the software was
00011 // developed by the University of Southern California, Information
00012 // Sciences Institute.  The name of the University may not be used to
00013 // endorse or promote products derived from this software without
00014 // specific prior written permission.
00015 //
00016 // THE UNIVERSITY OF SOUTHERN CALIFORNIA makes no representations about
00017 // the suitability of this software for any purpose.  THIS SOFTWARE IS
00018 // PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
00019 // INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
00020 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00021 //
00022 // Other copyrights might apply to parts of this software and are so
00023 // noted when applicable.
00024 //
00025 
00026 /****************************************************************/
00027 /* diff_prob.h : Chalermek Intanagonwiwat (USC/ISI)  08/16/99   */
00028 /****************************************************************/
00029 
00030 // Important Note: Work still in progress !!! Major improvement is needed.
00031 
00032 #ifndef ns_diff_prob_h
00033 #define ns_diff_prob_h
00034 
00035 #include <assert.h>
00036 #include <math.h>
00037 #include <stdio.h>
00038 #include <signal.h>
00039 #include <float.h>
00040 #include <stdlib.h>
00041 
00042 #include <tcl.h>
00043 
00044 #include "diff_header.h"
00045 #include "agent.h"
00046 #include "tclcl.h"
00047 #include "ip.h"
00048 #include "config.h"
00049 #include "packet.h"
00050 #include "trace.h"
00051 #include "random.h"
00052 #include "classifier.h"
00053 #include "node.h"
00054 #include "iflist.h"
00055 #include "hash_table.h"
00056 #include "arp.h"
00057 #include "mac.h"
00058 #include "ll.h"
00059 #include "dsr/path.h"
00060 #include "routing_table.h"
00061 #include "diffusion.h"
00062 
00063 
00064 //#define DEBUG_PROB
00065 
00066 #define BACKTRACK_            false
00067 #define ENERGY_CHECK          0.05         // (sec) between energy checks
00068 #define INTEREST_DELAY        0.05         // (sec) bw receive and forward
00069 #define MAX_REINFORCE_COUNTER 10           // (pkts) bw pos reinf
00070 
00071 class DiffusionProb;
00072 
00073 class EnergyTimer : public TimerHandler {
00074 public:
00075         EnergyTimer(DiffusionProb *a, Node *b) : TimerHandler() { 
00076                 a_ = a; 
00077                 node_ = b;
00078                 init_eng_ = node_->energy_model()->energy();
00079                 threshold_ = init_eng_ / 2;
00080         }
00081         virtual void expire(Event *e);
00082 protected:
00083         DiffusionProb *a_;
00084         Node *node_;
00085         double init_eng_;
00086         double threshold_;
00087 };
00088 
00089 
00090 class InterestTimer : public TimerHandler {
00091 public:
00092   InterestTimer(DiffusionProb *a, Pkt_Hash_Entry *hashPtr, Packet *pkt) : 
00093     TimerHandler() 
00094   { 
00095       a_ = a; 
00096       hashPtr_ = hashPtr;
00097       pkt_ = pkt;
00098   }
00099 
00100   virtual ~InterestTimer() {
00101     if (pkt_ != NULL) 
00102       Packet::free(pkt_);
00103   }
00104 
00105   virtual void expire(Event *e);
00106 protected:
00107   DiffusionProb *a_;
00108   Pkt_Hash_Entry *hashPtr_;
00109   Packet *pkt_;
00110 };
00111 
00112 
00113 
00114 class DiffusionProb : public DiffusionAgent {
00115  public:
00116   DiffusionProb();
00117   void recv(Packet*, Handler*);
00118 
00119  protected:
00120 
00121   int num_neg_bcast_send;
00122   int num_neg_bcast_rcv;
00123 
00124   EnergyTimer *energy_timer;
00125   bool is_low_power;
00126 
00127   void Start();
00128   void consider_old(Packet *);
00129   void consider_new(Packet *);
00130   void add_outlist(unsigned int, From_List *);
00131   void data_request_all(unsigned int dtype);
00132 
00133   void CreateIOList(Pkt_Hash_Entry *, unsigned int);
00134   void UpdateIOList(From_List *, unsigned int);
00135   void Print_IOlist();
00136 
00137   void CalGradient(unsigned int);
00138   void IncGradient(unsigned int, ns_addr_t);
00139   void DecGradient(unsigned int, ns_addr_t);
00140 
00141   void ForwardData(Packet *);
00142   void ForwardTxFailed(Packet *);
00143   void ReTxData(Packet *);
00144 
00145   void GenPosReinf(unsigned int);
00146   void FwdPosReinf(unsigned int, Packet *);
00147   void InterfaceDown(int, ns_addr_t);
00148   void SendInhibit(int);
00149   void SendNegReinf();
00150 
00151   void InterestPropagate(Packet *pkt, Pkt_Hash_Entry *hashPtr);
00152   void xmitFailed(Packet *pkt);
00153 
00154   friend class InterestTimer;
00155   friend class EnergyTimer;
00156 };
00157 
00158 #endif

Generated on Tue Apr 20 12:14:13 2004 for NS2.26SourcesOriginal by doxygen 1.3.3