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

mip.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 // $Header: /nfs/jade/vint/CVSROOT/ns-2/mobile/mip.h,v 1.7 2000/09/01 03:04:06 haoboy Exp $
00026 
00027 /*
00028  * Copyright (c) Sun Microsystems, Inc. 1998 All rights reserved.
00029  *
00030  * Redistribution and use in source and binary forms, with or without
00031  * modification, are permitted provided that the following conditions
00032  * are met:
00033  *
00034  * 1. Redistributions of source code must retain the above copyright
00035  *    notice, this list of conditions and the following disclaimer.
00036  *
00037  * 2. Redistributions in binary form must reproduce the above copyright
00038  *    notice, this list of conditions and the following disclaimer in the
00039  *    documentation and/or other materials provided with the distribution.
00040  *
00041  * 3. All advertising materials mentioning features or use of this software
00042  *    must display the following acknowledgement:
00043  *      This product includes software developed by Sun Microsystems, Inc.
00044  *
00045  * 4. The name of the Sun Microsystems, Inc nor may not be used to endorse or
00046  *      promote products derived from this software without specific prior
00047  *      written permission.
00048  *
00049  * SUN MICROSYSTEMS MERCHANTABILITY OF THIS SOFTWARE OR THE SUITABILITY OF THIS
00050  * SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software is provided "as is"
00051  * without express or implied warranty of any kind.
00052  *
00053  * These notices must be retained in any copies of any part of this software.
00054  */
00055 
00056 /* Ported by Ya Xu to official ns release  Jan. 1999 */
00057 
00058 
00059 #ifndef ns_mip_h
00060 #define ns_mip_h
00061 
00062 #include <assert.h>
00063 #include "agent.h"
00064 #include "classifier-addr.h"
00065 
00066 #define MIP_TIMER_SIMPLE        0
00067 #define MIP_TIMER_AGTLIST       1
00068 
00069 struct hdr_ipinip {
00070         hdr_ip hdr_;
00071         struct hdr_ipinip *next_;       // XXX multiple encapsulation OK
00072 
00073         // Header access methods
00074         static int offset_; // required by PacketHeaderManager
00075         inline static int& offset() { return offset_; }
00076         inline static hdr_ipinip* access(const Packet* p) {
00077                 return (hdr_ipinip*) p->access(offset_);
00078         }
00079 };
00080 
00081 typedef enum {
00082         MIPT_REG_REQUEST, MIPT_REG_REPLY, MIPT_ADS, MIPT_SOL
00083 } MipRegType;
00084 
00085 struct hdr_mip {
00086         int haddr_;
00087         int ha_;
00088         int coa_;
00089         MipRegType type_;
00090         double lifetime_;
00091         int seqno_;
00092 
00093         // Header access methods
00094         static int offset_; // required by PacketHeaderManager
00095         inline static int& offset() { return offset_; }
00096         inline static hdr_mip* access(const Packet* p) {
00097                 return (hdr_mip*) p->access(offset_);
00098         }
00099 };
00100 
00101 class MIPEncapsulator : public Connector {
00102 public:
00103         MIPEncapsulator();
00104         void recv(Packet *p, Handler *h);
00105 protected:
00106         ns_addr_t here_;
00107         int mask_;
00108         int shift_;
00109         int defttl_;
00110 };
00111 
00112 class MIPDecapsulator : public AddressClassifier {
00113 public:
00114         MIPDecapsulator();
00115         void recv(Packet* p, Handler* h);
00116 };
00117 
00118 class SimpleTimer : public TimerHandler {
00119 public: 
00120         SimpleTimer(Agent *a) : TimerHandler() { a_ = a; }
00121 protected:
00122         inline void expire(Event *) { a_->timeout(MIP_TIMER_SIMPLE); }
00123         Agent *a_;
00124 };
00125 
00126 class MIPBSAgent : public Agent {
00127 public:
00128         MIPBSAgent();
00129         virtual void recv(Packet *, Handler *);
00130         void timeout(int);
00131 protected:
00132         int command(int argc, const char*const*argv);
00133         void send_ads(int dst = -1, NsObject *target = NULL);
00134         void sendOutBCastPkt(Packet *p);
00135         double beacon_; /* beacon period */
00136         NsObject *bcast_target_; /* where to send out ads */
00137         NsObject *ragent_;     /* where to send reg-replies to MH */
00138         SimpleTimer timer_;
00139         int mask_;
00140         int shift_;
00141 #ifndef notdef
00142         int seqno_;             /* current ad seqno */
00143 #endif
00144         double adlftm_; /* ads lifetime */
00145 };
00146 
00147 class MIPMHAgent;
00148 
00149 class AgtListTimer : public TimerHandler {
00150 public: 
00151         AgtListTimer(MIPMHAgent *a) : TimerHandler() { a_ = a; }
00152 protected:
00153         void expire(Event *e);
00154         MIPMHAgent *a_;
00155 };
00156 
00157 typedef struct _agentList {
00158         int node_;
00159         double expire_time_;
00160         double lifetime_;
00161         struct _agentList *next_;
00162 } AgentList;
00163 
00164 class MIPMHAgent : public Agent {
00165 public:
00166         MIPMHAgent();
00167         void recv(Packet *, Handler *);
00168         void timeout(int);
00169 protected:
00170         int command(int argc, const char*const*argv);
00171         void reg();
00172         void send_sols();
00173         void sendOutBCastPkt(Packet *p);
00174         int ha_;
00175         int coa_;
00176         double reg_rtx_;
00177         double beacon_;
00178         NsObject *bcast_target_; /* where to send out solicitations */
00179         AgentList *agts_;
00180         SimpleTimer rtx_timer_;
00181         AgtListTimer agtlist_timer_;
00182         int mask_;
00183         int shift_;
00184 #ifndef notdef
00185         int seqno_;             /* current registration seqno */
00186 #endif
00187         double reglftm_;        /* registration lifetime */
00188         double adlftm_;         /* current ads lifetime */
00189         MobileNode *node_;      /* ptr to my mobilenode,if appl. */
00190 
00191 };
00192 
00193 #endif

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