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

randomtree.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: randomtree.h 163 2004-10-21 14:51:50Z mofta7 $
00142 
00143 
00144 
00145 // Georgia Tech Network Simulator - Random Tree topology
00146 // Monirul I Sharif,  Georgia Tech, Fall 2003
00147 
00148 // Specifies a randomtree structure and specifies non-leaf routers with proxy routing
00149 // capability so that packets destined for non existant nodes are routed to the downstream
00150 // routers as far as possible.
00151 
00152 // Define the tree topology with random structure using point-to-point links
00153 
00154 #ifndef __randomtree_h__
00155 #define __randomtree_h__
00156 
00157 #include "common-defs.h"
00158 #include "node.h"
00159 #include "mask.h"
00160 #include "rng.h"
00161 #include "linkp2p.h"
00162 #include <vector>
00163 
00164 class Node;
00165 class Linkp2p;
00166 class Queue;
00167 
00168 typedef std::vector<NodeVec_t> NodeVecVec_t;
00169 
00170 extern bool TurnOffProxyRouting;
00171 
00172 // define the stages in a randomtree
00173 struct RandomTreeStage {
00174   int levels;
00175   int fanout;
00176   Linkp2p link;
00177 };
00178 
00179 // defined types to keep structure of nodes in the randomtree
00180 
00181 //Doc:ClassXRef
00182 class RandomTree {
00183   //Doc:Class Defines a tree topology using point--to--point links.
00184 public:
00185  RandomTree(Count_t stages, struct RandomTreeStage stage[], IPAddr_t = IPADDR_NONE,
00186 Random_t = 0.8, SystemId_t = 0 , const Random & = Uniform(0,1));
00187 
00188   // Levels, Max Fanout, IP, Mask
00189   //Doc:Method
00190   RandomTree(Count_t, Count_t,
00191        IPAddr_t = IPADDR_NONE,  Random_t = 0.5, const Random & = Uniform(0,1), 
00192              const Location & = Location(0, 0), const Location& =Location(10, 10), SystemId_t = 0);
00193     //Doc:Desc Construct a {\tt Tree} topology object with the specified
00194     //Doc:Desc number of levels, fanout, \IPA\ and address mask.  The
00195     //Doc:Desc default point--to--point link object is used for links.
00196     //Doc:Arg1 Number of levels in the tree.
00197     //Doc:Arg2 Fanout of each level (number of child  nodes for each parent).
00198     //Doc:Arg3 Starting \IPA.  The \IPA\ is incremented by one for each
00199     //Doc:Arg3 node in the tree.
00200     //Doc:Arg4 \IPA\ mask.
00201 
00202   // Specify link to use
00203   //Doc:Method
00204   RandomTree(Count_t, Count_t, const Linkp2p&,
00205              IPAddr_t = IPADDR_NONE, Random_t = 0.5, const Random & = Uniform(0,1), 
00206              const Location& = Location(0,0), const Location & = Location(10.0, 10.0), SystemId_t = 0);
00207     //Doc:Desc Construct a {\tt Tree} topology object with the specified
00208     //Doc:Desc number of levels, fanout, \IPA\ and address mask, and
00209     //Doc:Desc the specified point--to--point link.
00210     //Doc:Arg1 Number of levels in the tree.
00211     //Doc:Arg2 Fanout of each level (number of child  nodes for each parent).
00212     //Doc:Arg3 A reference to a point--to--point link object to copy for 
00213     //Doc:Arg3 each link in the tree.
00214     //Doc:Arg4 Starting \IPA.  The \IPA\ is incremented by one for each
00215     //Doc:Arg5 node in the tree.
00216     //Doc:Arg6 \IPA\ mask.
00217   RandomTree(Count_t, Count_t, const Linkp2p&,
00218              Count_t, Count_t, const Linkp2p&,
00219              IPAddr_t = IPADDR_NONE, Random_t = 0.5, const Random & = Uniform(0,1), 
00220              const Location& = Location(0,0), const Location & = Location(10.0, 10.0), SystemId_t = 0);
00221 
00222   //Doc:Method
00223   //Doc:Method
00224   Node* GetRoot();                    // Get root node
00225     //Doc:Desc Return a pointer to the root node of the tree.
00226     //Doc:Return Pointer to root node.
00227 
00228   
00229   //Doc:Method
00230   Node* GetNode(Count_t, Count_t);    // Get node at specified level, index
00231     //Doc:Desc Return a pointer to the node at the specified level, index.
00232     //Doc:Arg1 Level number (root is level 0).
00233     //Doc:Arg2 Index, range 0 to number of nodes in the level - 1.
00234     //Doc:Return Pointer to the specfied node.
00235 
00236   
00237   //Doc:Method
00238   Node* GetLeaf(Count_t);             // Get specified leaf
00239     //Doc:Desc Return a pointer to the specified leaf node.
00240     //Doc:Arg1 Desired leaf node indexes, counting from zero.
00241     //Doc:Return Pointer to the specified leaf node.
00242   /*
00243   // Get link from specified node to specified child
00244   //Doc:Method
00245   Linkp2p* GetChildLink(Count_t, Count_t, Count_t);
00246     //Doc:Desc Get a pointer to the link from the specified node to its
00247     //Doc:Desc specified child.
00248     //Doc:Arg1 Level number (root is level 0).
00249     //Doc:Arg2 Index, range 0 to number of nodes in the level - 1.
00250     //Doc:Arg3 Child index, range 0 to fanout - 1.
00251     //Doc:Return Pointer to the specfied link.
00252 
00253   // Get link from specified node to parent
00254   //Doc:Method
00255   Linkp2p* GetParentLink(Count_t, Count_t);
00256     //Doc:Desc Get a pointer to the link from the specified node to its parent.
00257     //Doc:Arg1 Level number (root is level 0).
00258     //Doc:Arg2 Index, range 0 to number of nodes in the level - 1.
00259     //Doc:Return Pointer to the specfied link.
00260 
00261   // Get queue from specified node to specified child
00262   //Doc:Method
00263   Queue*   GetChildQueue(Count_t, Count_t, Count_t);
00264     //Doc:Desc Get a pointer to the queue from the specified node to its
00265     //Doc:Desc specified child.
00266     //Doc:Arg1 Level number (root is level 0).
00267     //Doc:Arg2 Index, range 0 to number of nodes in the level - 1.
00268     //Doc:Arg3 Child index, range 0 to fanout - 1.
00269     //Doc:Return Pointer to the specfied queue.
00270 
00271   // Get queue from specified node to parent
00272   //Doc:Method
00273   Queue*   GetParentQueue(Count_t, Count_t);
00274     //Doc:Desc Get a pointer to the queue from the specified node
00275     //Doc:Desc to its parent.
00276     //Doc:Arg1 Level number (root is level 0).
00277     //Doc:Arg2 Index, range 0 to number of nodes in the level - 1.
00278     //Doc:Return Pointer to the specfied queue.
00279     */
00280 
00281   //Doc:Method
00282   Count_t  LeafCount() { return leafCount;}
00283     //Doc:Desc Get a count of the number of leaf nodes in this tree.
00284     //Doc:Return Count of leaf nodes.
00285 
00286   void BoundingBoxOld(const Location&, const Location&);
00287   //Doc:Method
00288   void BoundingBox(const Location&, const Location&);
00289     //Doc:Desc Define a bounding box for this tree object. 
00290     //Doc:Desc The bounding box
00291     //Doc:Desc is used to assign node locations, which are used during
00292     //Doc:Desc the simulation animation.
00293     //Doc:Arg1 Lower left corner of bounding box.
00294     //Doc:Arg2 Upper right corner of bounding box.
00295 
00296   void BoundingBox(const Location&, const Location&, double );
00297 
00298 public:
00299 
00300   Count_t    levels;     // Number of levels
00301   Count_t    maxfanout;     // max Children per node
00302 
00303   Count_t    levels_fs;     // number of levels in first stage of tree
00304   Count_t    maxfanout_fs;  // fanout in first stage of tree
00305 
00306   Count_t    leafCount;  // Number of leaf nodes
00307 
00308 // this is for the new version of the randomtree 
00309   Count_t    stages;
00310   struct RandomTreeStage *stage;
00311 
00312 private:
00313   Random_t   probGenerateChild;  // probability of generating a child from a parent
00314   Random     *probRandom;         // Random number generator for tree creation
00315 
00316   NodeVecVec_t  nodes;
00317 
00318   void MakeSubtree(Node *parent, Count_t l,  Count_t step, const Linkp2p& link, 
00319                    const Linkp2p& linkfs, IPAddr_t leafIP, Mask mask, 
00320                    const Location&, const Location&, const Meters_t, SystemId_t);
00321 
00322   void ConstructorHelper(Count_t, Count_t, const Linkp2p&, 
00323                          Count_t, Count_t, const Linkp2p&, IPAddr_t, Random_t, 
00324                          const Random &, const Location&, const Location&, SystemId_t);
00325 
00326 
00327 };
00328 
00329 #endif
00330 
00331 
00332 

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