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

node-impl.h

Go to the documentation of this file.
00001 // GENERAL PUBLIC LICENSE AGREEMENT
00002 // 
00003 // PLEASE READ THIS DOCUMENT CAREFULLY BEFORE UTILIZING THE PROGRAM
00004 // 
00005 // BY UTILIZING THIS PROGRAM, YOU AGREE TO BECOME BOUND BY THE TERMS OF
00006 // THIS LICENSE.  IF YOU DO NOT AGREE TO THE TERMS OF THIS LICENSE, DO
00007 // NOT USE THIS PROGRAM OR ANY PORTION THEREOF IN ANY FORM OR MANNER.
00008 // 
00009 // This Program is licensed, not sold to you by GEORGIA TECH RESEARCH
00010 // CORPORATION ("GTRC"), owner of all code and accompanying documentation
00011 // (hereinafter "Program"), for use only under the terms of this License,
00012 // and GTRC reserves any rights not expressly granted to you.
00013 // 
00014 // 1.  This License allows you to:
00015 // 
00016 // (a) make copies and distribute copies of the Program's source code
00017 // provide that any such copy clearly displays any and all appropriate
00018 // copyright notices and disclaimer of warranty as set forth in Article 5
00019 // and 6 of this License.  All notices that refer to this License and to
00020 // the absence of any warranty must be kept intact at all times.  A copy
00021 // of this License must accompany any and all copies of the Program
00022 // distributed to third parties.
00023 // 
00024 // A fee may be charged to cover the cost associated with the physical
00025 // act of transferring a copy to a third party.  At no time shall the
00026 // program be sold for commercial gain either alone or incorporated with
00027 // other program(s) without entering into a separate agreement with GTRC.
00028 //  
00029 // 
00030 // (b) modify the original copy or copies of the Program or any portion
00031 // thereof ("Modification(s)").  Modifications may be copied and
00032 // distributed under the terms and conditions as set forth above,
00033 // provided the following conditions are met:
00034 // 
00035 //     i) any and all modified files must be affixed with prominent
00036 // notices that you have changed the files and the date that the changes
00037 // occurred.
00038 //              
00039 //     ii) any work that you distribute, publish, or make available, that
00040 // in whole or in part contains portions of the Program or derivative
00041 // work thereof, must be licensed at no charge to all third parties under
00042 // the terms of this License.
00043 // 
00044 //    iii) if the modified program normally reads commands interactively
00045 // when run, you must cause it, when started running for such interactive
00046 // use in the most ordinary way, to display and/or print an announcement
00047 // with all appropriate copyright notices and disclaimer of warranty as
00048 // set forth in Article 5 and 6 of this License to be clearly displayed.
00049 // In addition, you must provide reasonable access to this License to the
00050 // user.
00051 // 
00052 // Any portion of a Modification that can be reasonably considered
00053 // independent of the Program and separate work in and of itself is not
00054 // subject to the terms and conditions set forth in this License as long
00055 // as it is not distributed with the Program or any portion thereof.
00056 // 
00057 // 
00058 // 2. This License further allows you to copy and distribute the Program
00059 //    or a work based on it, as set forth in Article 1 Section b in
00060 //    object code or executable form under the terms of Article 1 above
00061 //    provided that you also either:
00062 // 
00063 //    i) accompany it with complete corresponding machine-readable source
00064 // code, which must be distributed under the terms of Article 1, on a
00065 // medium customarily used for software interchange; or,
00066 // 
00067 //   ii) accompany it with a written offer, valid for no less than three
00068 // (3) years from the time of distribution, to give any third party, for
00069 // no consideration greater than the cost of physical transfer, a
00070 // complete machine-readable copy of the corresponding source code, to be
00071 // distributed under the terms of Article 1 on a medium customarily used
00072 // for software interchange; or,
00073 // 
00074 // 
00075 // 3.  Export Law Assurance.
00076 // 
00077 // You agree that the Software will not be shipped, transferred or
00078 // exported, directly into any country prohibited by the United States
00079 // Export Administration Act and the regulations thereunder nor will be
00080 // used for any purpose prohibited by the Act.
00081 //  
00082 // 4.  Termination.
00083 // 
00084 // If at anytime you are unable to comply with any portion of this
00085 // License you must immediately cease use of the Program and all
00086 // distribution activities involving the Program or any portion thereof.
00087 // 
00088 // 
00089 // 5.  Disclaimer of Warranties and Limitation on Liability.
00090 // 
00091 // YOU ACCEPT THE PROGRAM ON AN "AS IS" BASIS.  GTRC MAKES NO WARRANTY
00092 // THAT ALL ERRORS CAN BE OR HAVE BEEN ELIMINATED FROM PROGRAM.  GTRC
00093 // SHALL NOT BE RESPONSIBLE FOR LOSSES OF ANY KIND RESULTING FROM THE USE
00094 // OF PROGRAM AND ITS ACCOMPANYING DOCUMENT(S), AND CAN IN NO WAY PROVIDE
00095 // COMPENSATION FOR ANY LOSSES SUSTAINED, INCLUDING BUT NOT LIMITED TO
00096 // ANY OBLIGATION, LIABILITY, RIGHT, CLAIM OR REMEDY FOR TORT, OR FOR ANY
00097 // ACTUAL OR ALLEGED INFRINGEMENT OF PATENTS, COPYRIGHTS, TRADE SECRETS,
00098 // OR SIMILAR RIGHTS OF THIRD PARTIES, NOR ANY BUSINESS EXPENSE, MACHINE
00099 // DOWNTIME OR DAMAGES CAUSED TO YOU BY ANY DEFICIENCY, DEFECT OR ERROR
00100 // IN PROGRAM OR MALFUNCTION THEREOF, NOR ANY INCIDENTAL OR CONSEQUENTIAL
00101 // DAMAGES, HOWEVER CAUSED.  GTRC DISCLAIMS ALL WARRANTIES, BOTH EXPRESS
00102 // AND IMPLIED RESPECTING THE USE AND OPERATION OF PROGRAM AND ITS
00103 // ACCOMPANYING DOCUMENTATION, INCLUDING ALL IMPLIED WARRANTIES OF
00104 // MERCHANTABILITY AND FITNESS FOR PARTICULAR PURPOSE AND ANY IMPLIED
00105 // WARRANTY ARISING FROM COURSE OF PERFORMANCE, COURSE OF DEALING OR
00106 // USAGE OF TRADE.  GTRC MAKES NO WARRANTY THAT PROGRAM IS ADEQUATELY OR
00107 // COMPLETELY DESCRIBED IN, OR BEHAVES IN ACCORDANCE WITH ANY
00108 // ACCOMPANYING DOCUMENTATION.  THE USER OF PROGRAM IS EXPECTED TO MAKE
00109 // THE FINAL EVALUATION OF PROGRAM'S USEFULNESS IN USER'S OWN
00110 // ENVIRONMENT.
00111 // 
00112 // GTRC represents that, to the best of its knowledge, the software
00113 // furnished hereunder does not infringe any copyright or patent.
00114 // 
00115 // GTRC shall have no obligation for support or maintenance of Program.
00116 // 
00117 // 6.  Copyright Notice.
00118 // 
00119 // THE SOFTWARE AND ACCOMPANYING DOCUMENTATION ARE COPYRIGHTED WITH ALL
00120 // RIGHTS RESERVED BY GTRC.  UNDER UNITED STATES COPYRIGHT LAWS, THE
00121 // SOFTWARE AND ITS ACCOMPANYING DOCUMENTATION MAY NOT BE COPIED EXCEPT
00122 // AS GRANTED HEREIN.
00123 // 
00124 // You acknowledge that GTRC is the sole owner of Program, including all
00125 // copyrights subsisting therein.  Any and all copies or partial copies
00126 // of Program made by you shall bear the copyright notice set forth below
00127 // and affixed to the original version or such other notice as GTRC shall
00128 // designate.  Such notice shall also be affixed to all improvements or
00129 // enhancements of Program made by you or portions thereof in such a
00130 // manner and location as to give reasonable notice of GTRC's copyright
00131 // as set forth in Article 1.
00132 // 
00133 // Said copyright notice shall read as follows:
00134 // 
00135 // Copyright 2004
00136 // Dr. George F. Riley
00137 // Georgia Tech Research Corporation
00138 // Atlanta, Georgia 30332-0415
00139 // All Rights Reserved
00140 //
00141 // $Id: node-impl.h 446 2005-11-15 20:48:03Z riley $
00142 
00143 
00144 
00145 // Georgia Tech Network Simulator - Node Implementation class
00146 // George F. Riley.  Georgia Tech, Fall 2002
00147 
00148 // Defines an abstract base class for node implementations
00149 
00150 #ifndef __nodeimpl_h__
00151 #define __nodeimpl_h__
00152 
00153 #include "common-defs.h"
00154 #include "macaddr.h"
00155 #include "node.h"
00156 
00157 class Link;
00158 class Node;
00159 class Interface;
00160 class Routing;
00161 class Protocol;
00162 class ProtocolGraph;
00163 class PortDemux;
00164 class Linkp2p;
00165 class Queue;
00166 class Application;
00167 class RoutingAODV;
00168 class AODVRoutingEntry;
00169 class Image;
00170 class WirelessLink;
00171 
00172 //Doc:ClassXRef
00173 class NodeImpl {
00174 public:
00175   NodeImpl(Node*);
00176   virtual ~NodeImpl();
00177 
00178   virtual NodeImpl* Copy() const = 0;    // All nodeimpl's must be copy'able
00179   NodeId_t Id() { return pNode->Id(); }
00180 
00181   // IP Address Management
00182   virtual IPAddr_t GetIPAddr();          // Get the IPAddres of this node
00183   virtual void     SetIPAddr(IPAddr_t i);// Set the IPAddres of this node
00184   virtual void     IPAddrs(IPMaskVec_t&);// Get all IP/Masks for this node
00185   virtual bool     LocalIP(IPAddr_t);    // True if specified ip is local
00186   virtual bool     IPKnown();            // True if non-default ip assigned
00187 
00188   // Real/Ghost test
00189   virtual bool     IsReal() = 0;         // True if real node
00190 
00191   // Satellite functions, overridden if needed
00192   virtual bool     FirstBitRx() const { return false;}
00193   virtual void     FirstBitRx(bool)   { }
00194   
00195   // switching functions
00196   virtual void IsSwitchNode(bool) = 0;
00197   virtual bool IsSwitchNode() = 0;
00198 
00199   virtual void PacketRX(Packet* p, Interface* iface) = 0;
00200 
00201 
00202 
00203   // Interfaces
00204   virtual Interface* AddInterface(Interface*);
00205   virtual Interface* AddInterface(const L2Proto&, bool bootstrap=false);
00206   virtual Interface* AddInterface(const L2Proto&,
00207                                   IPAddr_t, Mask_t,
00208                                   MACAddr = MACAddr::Allocate(),
00209                                   bool bootstrap = false);
00210   virtual Interface* AddInterface(const L2Proto&,const Interface&,
00211                                   IPAddr_t, Mask_t, 
00212                                   MACAddr = MACAddr::Allocate(),
00213                                   bool bootstrap = false);
00214   virtual Count_t    InterfaceCount();   // Get count of interfaces
00215   virtual const IFVec_t& Interfaces();   // Get complete list of interfaces
00216   virtual Interface* GetIfByLink(Link*); // Get iface to the specified link
00217   virtual Interface* GetIfByNode(Node*); // Get iface to the specified node
00218   virtual Interface* GetIfByIP(IPAddr_t);// Get iface with specified IP
00219 
00220   // Broadcast packet on all interfaces
00221   virtual void       Broadcast(Packet*, Proto_t) = 0;
00222 
00223   // Links.  All return local interface
00224   // Add duplex link to/from remote
00225   virtual Interface* AddDuplexLink(Node*);
00226   virtual Interface* AddDuplexLink(Node*, const Linkp2p&);
00227   // Next two specify new links between existing interfaces
00228   virtual Interface* AddDuplexLink(Interface*,Interface*);
00229   virtual Interface* AddDuplexLink(Interface*,Interface*, const Linkp2p&);
00230   //virtual Interface* AddDuplexLink(Interface*, Interface*, const Linkp2p&, Node*);
00231   // Next two specify local and remote IPAddress and Masks
00232   virtual Interface* AddDuplexLink(Node*,
00233                                    IPAddr_t, Mask_t, IPAddr_t, Mask_t);
00234   virtual Interface* AddDuplexLink(Node*, const Linkp2p&,
00235                                    IPAddr_t, Mask_t, IPAddr_t, Mask_t);
00236   virtual Link*      GetLink(Node*);    // Get link to specified node
00237   // Next two are for distributed simulations
00238   virtual Interface* AddRemoteLink(IPAddr_t, Mask_t);
00239   virtual Interface* AddRemoteLink(IPAddr_t, Mask_t, Rate_t, Time_t);
00240 
00241   // Simplex links, for modeling one-way links
00242   virtual Interface* AddSimplexLink(Node*);
00243   virtual Interface* AddSimplexLink(Node*, const Linkp2p&);
00244   virtual Interface* AddSimplexLink(Node*, const Linkp2p&,
00245                                     IPAddr_t, Mask_t);
00246 
00247   // Queues
00248   virtual Queue*     GetQueue() = 0;        // Return queue if only one i/f
00249   virtual Queue*     GetQueue(Node*) = 0;   // Get the queue to specified node
00250 
00251   // Applications
00252   virtual Application* AddApplication(const Application& a) = 0;
00253 
00254   // Neighbor management (used by some routing protocols)
00255   virtual void        Neighbors(NodeWeightVec_t &, bool); // List of neighbors
00256   virtual Count_t     NeighborCount();       // Count of routing neighbors
00257   // Get neighbors on given iface
00258   virtual void        NeighborsByIf(Interface*, IPAddrVec_t&);
00259 
00260   // Routing
00261   virtual void DefaultRoute(RoutingEntry) = 0;     // Specify default route
00262   virtual void DefaultRoute(Node*) = 0;            // Specify default route
00263   virtual void AddRoute( IPAddr_t, Count_t, Interface*, IPAddr_t) = 0;
00264   virtual RoutingEntry LookupRoute(IPAddr_t) = 0;  // Find a routing entry
00265   virtual RoutingEntry LookupRouteNix(Count_t) = 0;// Lookup route by NIx
00266   virtual Routing::RType_t RoutingType() = 0;      // Report type rtg in use
00267   virtual Interface* LocalRoute(IPAddr_t);         // If dst directly connected
00268   virtual void       InitializeRoutes() = 0;       // Routing init (if any)
00269   virtual void       ReInitializeRoutes(bool) = 0; // Routing re-initialization
00270   virtual Count_t    RoutingFibSize() const = 0;   // Statistics, size of FIB
00271   virtual Count_t    GetNix(Node*) const;          // Neighbor Index for node
00272   virtual RoutingNixVector* GetNixRouting() = 0;   // Returns Nix rtg pointer
00273   virtual Routing*   GetRouting() = 0;             // Returns routing object
00274 
00275   //AODV Routing
00276   //Specially for AODV routing, it is not compatiable with
00277   //other route entry.
00278   //
00279   virtual AODVRoutingEntry *LookupRouteAODV(IPAddr_t ip) =0;
00280   virtual void      SetRoutingAODV(void *pRouting)= 0;
00281   virtual RoutingAODV *GetRoutingAODV() = 0;
00282 
00283   // Protocol Graph Interface
00284   virtual Protocol* LookupProto(Layer_t, Proto_t) = 0;// Lookup proto by layer
00285   virtual void      InsertProto(Layer_t, Proto_t, Protocol*) = 0;
00286 
00287   // Port Demux Interface
00288   // Register port usage
00289   virtual bool      Bind(Proto_t, PortId_t, Protocol*) = 0;
00290   virtual bool      Bind(Proto_t,
00291                          PortId_t, IPAddr_t,
00292                          PortId_t, IPAddr_t,
00293                          Protocol*) = 0;           // Register port usage
00294   virtual PortId_t  Bind(Proto_t, Protocol*) = 0;  // Choose port, register
00295   virtual bool      Unbind(Proto_t, PortId_t, Protocol*) = 0;// Remove binding
00296   virtual bool      Unbind(Proto_t,
00297                            PortId_t, IPAddr_t,
00298                            PortId_t, IPAddr_t,
00299                            Protocol*) = 0;         // Remove port binding
00300   virtual Protocol* LookupByPort(Proto_t, PortId_t) = 0;
00301   virtual Protocol* LookupByPort(Proto_t,
00302                                  PortId_t, IPAddr_t,
00303                                  PortId_t, IPAddr_t) = 0;  // Lookup by s/d port/ip
00304 
00305   // Packet tracing interface
00306   // Trace header if enabled
00307   virtual bool      TracePDU(Protocol*, PDU*, Packet*, char*) = 0;
00308   // Set trace level this node
00309   virtual void      SetTrace(Trace::TraceStatus) = 0;
00310 
00311   // Node location (x, y, z) interface
00312   virtual void      SetLocation(Meters_t, Meters_t, Meters_t) = 0;
00313   virtual void      SetLocation(const Location&) = 0;
00314   virtual void      SetLocationLongLat(const Location&) = 0;
00315   virtual bool      HasLocation() = 0;       // True if location assigned
00316   virtual Meters_t  LocationX() = 0;
00317   virtual Meters_t  LocationY() = 0;
00318   virtual Meters_t  LocationZ() = 0;
00319   virtual Location  GetLocation() = 0;       // Return current location
00320   virtual Location  UpdateLocation() = 0;    // Get updated location
00321   virtual Mobility* AddMobility(const Mobility&) = 0;    // Add mobility model
00322   virtual Mobility* GetMobility() const = 0; // Get the current mobility model
00323   virtual bool      IsMobile() = 0;          // True if mobility enabled
00324   virtual bool      IsMoving() = 0;          // True if not pausing
00325   virtual bool      WirelessTx() = 0;        // True if wireless transmitting
00326   virtual bool      WirelessRx() = 0;        // True if wireless receiving
00327   virtual bool      WirelessCx() = 0;        // True if wireless colliding
00328   virtual bool      WirelessRxMe() = 0;      // True if wireless receiving
00329   virtual bool      WirelessRxZz() = 0;      // True if wireless receiving
00330   virtual void      UserInformation(void*) = 0;   // Specify user info
00331   virtual void*     UserInformation() = 0;        // Return user info
00332   void UseWormContainment(bool);
00333   bool UseWormContainment() { return usewormcontainment; }
00334   virtual void SetWormContainment(WormContainment*) = 0;
00335   virtual void UseARP(bool) = 0;
00336 
00337   virtual WormContainment* GetWormContainment() = 0;
00338 
00339   // QTWindow information
00340   virtual void           Show(bool) = 0;          // Turn on/off display
00341   virtual bool           Show() = 0;              // True if display enabled
00342   virtual QCanvasItem*   Display(QTWindow*) = 0;
00343   virtual QCanvasItem*   Display(const QPoint&, QTWindow*) = 0;
00344   virtual void           WirelessTxColor(const QColor&) = 0;
00345   virtual const QColor&  WirelessTxColor() = 0;
00346   virtual bool           PushWirelessTx(QCanvasItem*) = 0;
00347   virtual QCanvasItem*   PopWirelessTx() = 0;
00348   virtual void           PixelSize(Count_t) = 0;
00349   virtual Count_t        PixelSizeX() = 0;
00350   virtual Count_t        PixelSizeY() = 0;
00351   virtual void           Shape(Node::Shape_t) = 0;
00352   virtual Node::Shape_t  Shape() = 0;
00353   virtual CustomShape_t  CustomShape();
00354   virtual void           CustomShape(CustomShape_t);
00355   virtual bool           CustomShapeFile(const char*);
00356   virtual bool           CustomShapeImage(const Image&);
00357   virtual void           Color(const QColor&) = 0;
00358   virtual bool           HasColor() = 0;
00359   virtual QColor&        Color() = 0;
00360   virtual NodeAnimation* GetNodeAnimation() const = 0;
00361   
00362   // ICMP related
00363   virtual bool   ICMPEnabled() const;
00364   virtual void   DisableICMP();
00365 
00366   // Failure management
00367   virtual void   Down();
00368   virtual void   Up();
00369   virtual bool   IsDown();
00370 
00371   // Wireless transmitter information
00372   virtual Meters_t  Distance(Node*) = 0;
00373   virtual void      BuildRadioInterfaceList(WirelessLink*) = 0;
00374   virtual const RadioVec_t& GetRadioInterfaceList() = 0;
00375   virtual void      SetRadioRange(Meters_t ) =0;
00376   virtual Meters_t  GetRadioRange(void ) =0;
00377 
00378   virtual void      AddCallback(Layer_t, Proto_t,
00379                                 PacketCallbacks::Type_t,
00380                                 Interface*,
00381                                 PacketCallbacks::Function_t) = 0;
00382   virtual void      AddCallbackHead(Layer_t, Proto_t,
00383                                     PacketCallbacks::Type_t,
00384                                     Interface*,
00385                                     PacketCallbacks::Function_t) = 0;
00386   virtual void      DeleteCallback(Layer_t, Proto_t, 
00387                                    PacketCallbacks::Type_t,
00388                                    Interface*) = 0;
00389   virtual bool      CallCallbacks(Layer_t, Proto_t, 
00390                                   PacketCallbacks::Type_t, Packet*,
00391                                   Interface*) = 0;
00392 
00393   virtual void      setBattery (Joules_t) = 0;
00394   virtual Joules_t  getBattery (void) = 0;
00395 
00396   virtual void      setComputePower (double) = 0;
00397   virtual double    getComputePower (void) = 0;
00398 
00399   virtual void        setRouteTable (RouteTable*) = 0;
00400   virtual RouteTable* getRouteTable (void) = 0;
00401 
00402   
00403 protected:
00404   Node*    pNode;         // Points to corresponding node interface object
00405   bool     usewormcontainment;      // Does this node use worm containment
00406   // Data items common between real and ghost nodes
00407   IPAddr_t ipAddr;                  // IP Address for this node
00408   IFVec_t  interfaces;              // All defined network interfaces (may be ghosts)
00409   Count_t  neighborCount;           // Total number of neighbors
00410   bool     down;                    // True if node is down
00411 };
00412 
00413 #endif

Generated on Wed Aug 27 16:17:13 2008 for Georgia Tech Network Simulator (GTNetS) by  doxygen 1.3.9.1