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

linkp2p.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: linkp2p.h 446 2005-11-15 20:48:03Z riley $
00142 
00143 
00144 
00145 // Georgia Tech Network Simulator - Point to Point Link class
00146 // George F. Riley.  Georgia Tech, Spring 2002
00147 
00148 #ifndef __linkp2p_h__
00149 #define __linkp2p_h__
00150 
00151 #include <vector>
00152 
00153 class InterfaceBasic;
00154 
00155 #include "link-real.h"
00156 #include "interface.h"
00157 #include "l2proto802.3.h"
00158 
00159 class QCanvasLine;
00160 class QCanvasPolygon;
00161 class QColor;
00162 
00163 // Vector of displayed packets
00164 typedef std::vector<QCanvasPolygon*> PacketVec_t;
00165 
00166 
00167 //Doc:ClassXRef
00168 class Linkp2p : public LinkReal {
00169 //Doc:Class Class {\tt Linkp2p} defines a serial point to point link object
00170 //Doc:Class derived from the {\tt Link} object 
00171 public:
00172   
00173   Linkp2p();
00174   Linkp2p(Rate_t b, Time_t d);
00175   Linkp2p(const Linkp2p&);      // Copy constructor
00176   ~Linkp2p();
00177   // Methods from Link
00178   //Doc:Method
00179   Link*      Copy() const ;     // Make a copy of this link
00180   //Doc:Desc This method makes a copy of itself and returns a pointer to
00181   //Doc:Desc the copy
00182   //Doc:Return Pointer to the new {\tt Link} object
00183 
00184   //Doc:Method
00185   void       SetPeer(InterfaceBasic* i) { pPeer = i;}
00186   //Doc:Desc This method sets a specific interface as the peer
00187   //Doc:Arg1 The interface to be set as the peer interface
00188   
00189   //Doc:Method
00190   InterfaceBasic* GetPeer(Packet*) { return pPeer;}
00191   //Doc:Desc This method looks at the packet's destination MAC address and
00192   //Doc:Desc returns the interface corresponding to it
00193   //Doc:Arg1 The packet to be transmitted
00194   //Doc:Return The destination interface
00195   
00196   //Doc:Method
00197   InterfaceBasic* GetPeer(Count_t) { return (Interface*)pPeer;}
00198     //Doc:Desc Get the interface pointer for the remote endpoint of
00199     //Doc:Desc this link for the specified peer index.
00200     //Doc:Arg1 Which peer desired (0 <- i < NeighborCount())
00201     //Doc:Return A pointer to the receiving interface for the specified peer
00202 
00203   //Doc:Method
00204   bool       Transmit(Packet*, Interface*, Node*);
00205   //Doc:Desc Transmit a packet.
00206   //Doc:Arg1 The packet to transmit.
00207   //Doc:Arg2 A pointer to the local (transmitting) interface
00208   //Doc:Arg3 A pointer to the local (transmitting) node.
00209   //Doc:Return True if the transmit succeeded, false if packet was dropped.
00210   
00211   //Doc:Method
00212   bool       Transmit(Packet*, Interface*, Node*, Rate_t);
00213   //Doc:Desc Transmit a packet.
00214   //Doc:Arg1 The packet to transmit.
00215   //Doc:Arg2 A pointer to the local (transmitting) interface
00216   //Doc:Arg3 A pointer to the local (transmitting) node.
00217   //Doc:Arg4 Transmitting rate (bits/sec)
00218   //Doc:Return True if the transmit succeeded, false if packet was dropped.
00219 
00220   //Doc:Method
00221   MACAddr    IPToMac(IPAddr_t);            // Convert peer IP to peer MAC
00222   //Doc:Desc Convert peer IP to peer MAC
00223   //Doc:Arg1 The IP Address whose MAC is to be determined
00224   //Doc:Return The corresponding MAC address
00225   
00226   //Doc:Method
00227   Count_t    NeighborCount(Node*);              // Number of routing neighbors
00228   //Doc:Desc Returns the number of neighbors on this link which are routers
00229   //Doc:Desc technically, count of routing peers
00230   //Doc:Arg1 Node querying neighbors (significant for Ethernet links)
00231   //Doc:Return The number of routing peers.
00232   
00233   // Build neighbor list
00234 
00235   //Doc:Method
00236   void       Neighbors(NodeWeightVec_t&, Interface*, bool);
00237   //Doc:Desc Build the vector of neighbor,interface list
00238   //Doc:Arg1 The NodeWightVec element where we will fill in the neighbors
00239   //Doc:Arg2 The interface, with respect to which we need to find these
00240   //Doc:Arg2 neighbors
00241   //Doc:Arg3 boolean to specify if we need all the neighbors OR if we need
00242   //Doc:Arg3 only routing peers
00243 
00244   //Doc:Method
00245   void       AllNeighbors(NodeWeightVec_t&);    // Build neighbor list
00246   //Doc:Desc AllNeighbors is used by broadcasts even if they are
00247   //Doc:Desc not routing peers. Use this to find all the peers
00248   //Doc:Arg1 The NodeWeightVec element, with respect to which,
00249   //Doc:Arg1 we need all the peers in this link
00250   
00251   // Linkp2p only methods
00252   //Doc:Method
00253   Count_t    PeerCount();                  // Return number of peers
00254   //Doc:Desc Returns the number of peers on this link
00255   //Doc:Return number of peers
00256   
00257   //Doc:Method
00258   IPAddr_t   PeerIP(Count_t);              // Get peer IP Address (if known)
00259   //Doc:Desc Since each node on this link is also associated with a count
00260   //Doc:Desc this returns the IP address of the n'th  peer
00261   //Doc:Arg1 the count index n
00262   //Doc:Return the corresopnding IPAddress
00263   
00264   //Doc:Method
00265   IPAddr_t   NodePeerIP(Node*);            // Get peer IP Address (if known)
00266   //Doc:Desc Return the IP address of the node if it is on this link and
00267   //Doc:Desc is found
00268   //Doc:Arg1 The pointer to the node object
00269   //Doc:Return The IP Address
00270   
00271   //Doc:Method
00272   bool       NodeIsPeer(Node*);            // Find out if node is a peer
00273   //Doc:Desc Find out if node is a peer
00274   //Doc:Arg1 The Node
00275   //Doc:Return boolean result of the test
00276   
00277   //Doc:Method
00278   Count_t    NodePeerIndex(Node*);         // Get peer index for node
00279   //Doc:Desc Returns the index of the node in this link
00280   //Doc:Arg1 The pointer to the node
00281   //Doc:Return The index of the peer
00282   
00283   //Doc:Method
00284   IPAddr_t   DefaultPeer(Interface*);      // Get IP Addr of default peer
00285   //Doc:Desc Find the default peer's IP Address; this will find the default
00286   //Doc:Desc gateway's IP Address in the same subnet
00287   //Doc:Arg1 The interface whose default peerIP is to be known
00288   //Doc:Return The default peer's IP
00289 
00290   //Doc:Method
00291   virtual bool ScheduleFailure(Time_t t);
00292   //Doc:Desc This method scedules the failure of the current link in future
00293   //Doc:Arg1 Time when we want to schedule it
00294   //Doc:Return bool, true on success and false on failure (if schedule fails)
00295 
00296   //Doc:Method
00297   virtual bool ScheduleRestore(Time_t t);
00298   //Doc:Desc This method scedules the link being restored from current failure
00299   //Doc:Desc state. If it is not currently failed, it has no effect
00300   //Doc:Arg1 Time when we want to schedule the event
00301   //Doc:Return bool, true on success and false on failure (if schedule fails)
00302   
00303   // Animation related methods
00304   //Doc:Method
00305   virtual void AnimateLink();
00306     //Doc:Desc Draw the link on the animation display.
00307 
00308   //Doc:Method
00309   virtual void ReAnimateLink();
00310     //Doc:Desc   Redraw link after state change (up/down)
00311 
00312   //Doc:Method
00313   virtual void AnimatePackets();
00314     //Doc:Desc Draw the packets on the link.
00315 
00316 private:
00317   // Private helper to display a single packet
00318   void DisplayOnePacket(Node*, Node*, Mult_t, Mult_t, const QColor&);
00319 public:
00320   InterfaceBasic* pPeer;       // Opposite end of the point to point link
00321   QCanvasLine* linkAnimation;  // QCanvas item for the link display
00322   // Keep a vector of packet animations so we can re-use them
00323   PacketVec_t animatedPackets;
00324   PacketVec_t::size_type usedAnim;
00325 
00326 public:
00327   //Doc:Method
00328   static Linkp2p& Default();               // Get the default link
00329   //Doc:Desc Returns the default link
00330   //Doc:Return a reference to the default point--to--point link
00331   
00332   //Doc:Method
00333   static Linkp2p& Default(const Linkp2p&); // Set new default
00334   //Doc:Desc Sets a new default linkp2p object, and returns
00335   //Doc:Arg1 a reference to the new default linkp2p object
00336   //Doc:Return a reference to the new default point--to--point link
00337 
00338 private:
00339   static Linkp2p* defaultp2p;              // Default p2p link pointer
00340 public:
00341   static Count_t  count;
00342 };
00343 
00344 #endif
00345 
00346 

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