• Main Page
  • Classes
  • Files
  • File List

/Users/yzchen/ns/ns-allinone-2.33/ns-2.33/diffusion3/ns/diffrtg.h

00001 
00002 /*
00003  * Copyright (C) 2004-2005 by the University of Southern California
00004  * $Id: diffrtg.h,v 1.12 2005/09/13 20:47:34 johnh Exp $
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License,
00008  * version 2, as published by the Free Software Foundation.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License along
00016  * with this program; if not, write to the Free Software Foundation, Inc.,
00017  * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00018  *
00019  *
00020  * The copyright of this module includes the following
00021  * linking-with-specific-other-licenses addition:
00022  *
00023  * In addition, as a special exception, the copyright holders of
00024  * this module give you permission to combine (via static or
00025  * dynamic linking) this module with free software programs or
00026  * libraries that are released under the GNU LGPL and with code
00027  * included in the standard release of ns-2 under the Apache 2.0
00028  * license or under otherwise-compatible licenses with advertising
00029  * requirements (or modified versions of such code, with unchanged
00030  * license).  You may copy and distribute such a system following the
00031  * terms of the GNU GPL for this module and the licenses of the
00032  * other code concerned, provided that you include the source code of
00033  * that other code when and as the GNU GPL requires distribution of
00034  * source code.
00035  *
00036  * Note that people who make modified versions of this module
00037  * are not obligated to grant this special exception for their
00038  * modified versions; it is their choice whether to do so.  The GNU
00039  * General Public License gives permission to release a modified
00040  * version without this exception; this exception also makes it
00041  * possible to release a modified version which carries forward this
00042  * exception.
00043  *
00044  */
00045 
00046 // 
00047 // Diffusion Routing Agent - a wrapper class for core diffusion agent, ported from SCADDS's directed diffusion software. --Padma, nov 2001.
00048 //
00049 
00050 #ifdef NS_DIFFUSION
00051 
00052 #ifndef DIFFUSION_RTG
00053 #define DIFFUSION_RTG
00054 
00055 #include "filter_core.hh"
00056 #include "iodev.hh"
00057 #include "events.hh"
00058 #include "classifier-port.h"
00059 #include "ll.h"
00060 #include "ns-process.h"
00061 #include "agent.h"
00062 #include "trace.h"
00063 #include "message.hh"
00064 
00065 class DiffusionCoreAgent;
00066 class DiffRoutingAgent;
00067 extern DiffPacket DupPacket(DiffPacket pkt);
00068 
00069 class LocalApp : public DiffusionIO {
00070 public:
00071         LocalApp(DiffRoutingAgent *agent) { agent_ = agent;}
00072         DiffPacket recvPacket(int fd);
00073         void sendPacket(DiffPacket p, int len, int dst); 
00074 protected:
00075         DiffRoutingAgent *agent_;
00076 };
00077 
00078 class LinkLayerAbs : public DiffusionIO {
00079 public:
00080         LinkLayerAbs(DiffRoutingAgent *agent) { agent_ = agent;}
00081         DiffPacket recvPacket(int fd);
00082         void sendPacket(DiffPacket p, int len, int dst); 
00083 protected:
00084         DiffRoutingAgent *agent_;
00085 };
00086  
00087 class DiffusionData : public AppData {
00088 private:
00089         Message *data_;
00090         int len_;
00091 public:
00092         DiffusionData(Message *data, int len) : AppData(DIFFUSION_DATA), data_(0)
00093         { 
00094                 data_ = data;
00095                 len_ = len;
00096         }
00097         ~DiffusionData() { delete data_; }
00098         Message *data() {return data_;}
00099         int size() const { return len_; }
00100         AppData* copy() { 
00101                 Message *newdata = CopyMessage(data_);
00102                 DiffusionData *dup = new DiffusionData(newdata, len_);
00103                 return dup; 
00104         } 
00105 };
00106 
00107 
00108 class DiffRoutingAgent : public Agent {
00109 public:
00110         DiffRoutingAgent(int nodeid);
00111         int command(int argc, const char*const* argv);
00112 
00113         void initpkt(Packet* p, Message* msg, int len);
00114         Packet* createNsPkt(Message *msg, int len, int dst);  
00115         void recv(Packet*, Handler*);
00116         void sendPacket(DiffPacket p, int len, int dst);
00117   
00118         DiffusionCoreAgent *getagent() { return agent_; }
00119         
00120         //trace support
00121         void trace (char *fmt,...);
00122         
00123         PortClassifier *port_dmux() {return port_dmux_; }
00124 private:
00125         int addr_;
00126         Trace *tracetarget_;
00127         
00128         //  diffusion core agent 
00129         DiffusionCoreAgent *agent_;
00130         
00131         //port-dmux
00132         PortClassifier *port_dmux_;
00133         
00134 }; 
00135 
00136 #endif //diffrtg
00137 #endif // NS
00138 

Generated on Tue Aug 10 2010 16:16:07 for ns-2.33 by  doxygen 1.7.1