classifier-addr-mpls.h

Go to the documentation of this file.
00001 // -*-  Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*-
00002 
00003 /*
00004  * classifier-addr-mpls.h
00005  * Copyright (C) 2000 by the University of Southern California
00006  * $Id: classifier-addr-mpls.h,v 1.5 2005/08/25 18:58:09 johnh Exp $
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License,
00010  * version 2, as published by the Free Software Foundation.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License along
00018  * with this program; if not, write to the Free Software Foundation, Inc.,
00019  * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00020  *
00021  *
00022  * The copyright of this module includes the following
00023  * linking-with-specific-other-licenses addition:
00024  *
00025  * In addition, as a special exception, the copyright holders of
00026  * this module give you permission to combine (via static or
00027  * dynamic linking) this module with free software programs or
00028  * libraries that are released under the GNU LGPL and with code
00029  * included in the standard release of ns-2 under the Apache 2.0
00030  * license or under otherwise-compatible licenses with advertising
00031  * requirements (or modified versions of such code, with unchanged
00032  * license).  You may copy and distribute such a system following the
00033  * terms of the GNU GPL for this module and the licenses of the
00034  * other code concerned, provided that you include the source code of
00035  * that other code when and as the GNU GPL requires distribution of
00036  * source code.
00037  *
00038  * Note that people who make modified versions of this module
00039  * are not obligated to grant this special exception for their
00040  * modified versions; it is their choice whether to do so.  The GNU
00041  * General Public License gives permission to release a modified
00042  * version without this exception; this exception also makes it
00043  * possible to release a modified version which carries forward this
00044  * exception.
00045  *
00046  */
00047 
00048 //
00049 // Other copyrights might apply to parts of this software and are so
00050 // noted when applicable.
00051 //
00052 // Original source contributed by Gaeil Ahn. See below.
00053 //
00054 // $Header: /nfs/jade/vint/CVSROOT/ns-2/mpls/classifier-addr-mpls.h,v 1.5 2005/08/25 18:58:09 johnh Exp $
00055 
00056 /**************************************************************************
00057 * Copyright (c) 2000 by Gaeil Ahn                                         *
00058 * Everyone is permitted to copy and distribute this software.         *
00059 * Please send mail to fog1@ce.cnu.ac.kr when you modify or distribute     *
00060 * this sources.                               *
00061 **************************************************************************/
00062 
00063 /***********************************************************
00064 *                                                          *
00065 *    File: Header File for packet switching in MPLS node   *
00066 *    Author: Gaeil Ahn (fog1@ce.cnu.ac.kr), Dec. 1999      *
00067 *                                                          *
00068 ***********************************************************/
00069 
00070 #ifndef ns_classifier_addr_mpls_h
00071 #define ns_classifier_addr_mpls_h
00072 
00073 #include "address.h"
00074 #include "classifier-addr.h"
00075 #include "tclcl.h"
00076 
00077 const int MPLS_MaxPFTEntryNB = 100;
00078 const int MPLS_MaxLIBEntryNB = 100;
00079 const int MPLS_MaxERBEntryNB = 100;
00080 const int MPLS_MINIMUM_LSPID = 1000;
00081 
00082 const int MPLS_DEFAULT_PHB = -1;
00083 const int MPLS_DONTCARE = -77;
00084 const int MPLS_GOTO_L3 = -99;
00085 
00086 /* option for reroute scheme */
00087 const int MPLS_DROPPACKET = 0;
00088 const int MPLS_L3FORWARDING = 1;
00089 const int MPLS_MAKENEWLSP = 2;
00090 
00091 struct hdr_mpls {
00092     int  label_;
00093     int  bflag_;
00094     int  ttl_;
00095     hdr_mpls* nexthdr_;
00096     hdr_mpls* top_;
00097   
00098     int& label() { return label_; }
00099     int& bflag() { return bflag_; }
00100     int& ttl()   { return ttl_;   }
00101 
00102     // Header access methods
00103     static int offset_; // required by PacketHeaderManager
00104     inline static int& offset() { return offset_; }
00105     inline static hdr_mpls* access(const Packet* p) {
00106         return (hdr_mpls*)p->access(offset_);
00107     }
00108 };
00109 
00110 struct PFTEntry {
00111     int  FEC_;
00112     int  PHB_;
00113     int  LIBptr_;
00114     int  aPATHptr_;     // altanative path 
00115 };
00116 
00117 struct PFT {
00118     PFTEntry Entry_[MPLS_MaxPFTEntryNB];
00119     int NB_;
00120 };
00121 
00122 struct ERBEntry {
00123     int LSPid_;
00124     int FEC_;
00125     int LIBptr_;
00126 };
00127 
00128 struct ERB {
00129     ERBEntry Entry_[MPLS_MaxERBEntryNB];
00130     int NB_;
00131 };
00132 
00133 struct LIBEntry {
00134     int iIface_;
00135     int iLabel_;
00136     int oIface_;
00137     int oLabel_;
00138     int LIBptr_;    // for push operation
00139 };
00140 
00141 struct LIB {
00142     LIBEntry Entry_[MPLS_MaxLIBEntryNB];
00143     int NB_;
00144 };
00145 
00146 struct PktInfo
00147 {
00148     ns_addr_t dst_;
00149     int srcnode_;
00150     int phb_;
00151     hdr_mpls* shimhdr_;     // altanative path 
00152 };
00153 
00154 class MPLSAddressClassifier : public AddressClassifier {
00155 public: 
00156     MPLSAddressClassifier();
00157     virtual int command(int argc, const char*const* argv);
00158 
00159     // Static configuration variables. Exposed to OTcl via methods in 
00160     // MPLSNodeClass (see mpls-node.cc)
00161     static int ordered_control_;
00162     static int on_demand_;
00163 
00164         
00165 protected:
00166     virtual void install(int slot, NsObject *target);
00167     
00168     virtual int classify(Packet* p);
00169     int MPLSclassify(Packet* p);
00170     
00171     int processIP();
00172     int processLabelP();
00173     
00174     int convertL2toL2(int iLabel, int oIface, int oLabel, int LIBptr);
00175     int convertL3toL2(int oIface, int oLabel, int LIBptr);
00176     
00177     void GetIPInfo(Packet* p, ns_addr_t& dstaddr, int& phb, int& srcnode);
00178     hdr_mpls* checkTTL(hdr_mpls* shimhdr);
00179     
00180     hdr_mpls* GetShimHeader(Packet* p);
00181     hdr_mpls* DelAllShimHeader(hdr_mpls* shimhdr);
00182     hdr_mpls* push(hdr_mpls* shimhdr, int oLabel);
00183     hdr_mpls* pop(hdr_mpls* shimhdr);
00184     void swap(hdr_mpls* shimhdr, int oLabel) {
00185         shimhdr->label_ = oLabel;
00186     }
00187     
00188     void PFTinsert(int FEC, int PHB, int LIBptr);
00189     void PFTdelete(int entrynb);
00190     void PFTdeleteLIBptr(int LIBptr);
00191     void PFTupdate(int entrynb, int LIBptr);
00192     int PFTlocate(int FEC, int PHB, int &LIBptr);
00193     int PFTlookup(int FEC, int PHB, int &oIface, 
00194               int &oLabel, int &LIBptr);
00195 
00196     void ERBinsert(int LSPid, int FEC, int LIBptr);
00197     void ERBdelete(int entrynb);
00198     void ERBupdate(int entrynb, int LIBptr);
00199     int ERBlocate(int LSPid, int FEC, int &LIBptr);
00200     
00201     int LIBinsert(int iIface, int iLabel, int oIface, int oLabel);
00202     int LIBisdeleted(int entrynb);
00203     void LIBupdate(int entrynb, int iIface, int iLabel, 
00204                int oIface, int oLabel);
00205     int LIBlookup(int entrynb, int& oIface, int& oLabel, int& LIBptr);
00206     int LIBlookup(int iIface, int iLabel, 
00207               int& oIface, int& oLabel, int& LIBptr);
00208     int LIBgetIncoming(int entrynb, int& iIface, int& iLabel);
00209     
00210     int ErLspBinding(int FEC,int PHB, int erFEC, int LSPid);
00211     int ErLspStacking(int erFEC0, int erLSPid0, int erFEC, int erLSPid);
00212     int FlowAggregation(int fineFEC, int finePHB, int coarseFEC,
00213                 int coarsePHB);
00214 
00215     int aPathBinding(int FEC, int PHB, int erFEC,int LSPid);
00216     int aPathLookup(int FEC, int PHB, 
00217             int& oIface, int& oLabel, int& LIBptr);
00218     int is_link_down(int node);
00219     int do_reroute(Packet* p);
00220        
00221     void PFTdump(const char* id);
00222     void ERBdump(const char* id);
00223     void LIBdump(const char* id);
00224     void trace(char* ptype, int psize, int ilabel, char *op, 
00225            int oiface, int olabel, int ttl);
00226     
00227     // Hash mapping between neighbors and LDP agents
00228     virtual void delay_bind_init_all();
00229     virtual int delay_bind_dispatch(const char*, const char*, TclObject*);
00230 
00231     int size_;
00232     int ttl_;
00233     int label_;
00234     int enable_reroute_;
00235     int reroute_option_;
00236     
00237     int trace_mpls_;
00238 
00239 private:
00240     // Some states
00241     int data_driven_;
00242     int control_driven_;
00243 
00244     LIB     LIB_;
00245     PFT     PFT_;
00246     ERB     ERB_;
00247 
00248     PktInfo  PI_;
00249 };
00250 
00251 #endif

Generated on Tue Mar 6 16:47:43 2007 for ns2 Network Simulator 2.29 by  doxygen 1.4.6