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.h 446 2005-11-15 20:48:03Z riley $ 00142 00143 00144 00145 // Georgia Tech Network Simulator - Node class 00146 // George F. Riley. Georgia Tech, Spring 2002 00147 00148 #ifndef __node_h__ 00149 #define __node_h__ 00150 00151 #include <vector> 00152 #include <deque> 00153 #include <list> 00154 00155 #include "common-defs.h" 00156 #include "l2proto802.3.h" 00157 #include "mask.h" 00158 #include "location.h" 00159 #include "packet-callbacks.h" 00160 00161 class Link; 00162 class Node; 00163 class Interface; 00164 class InterfaceBasic; 00165 class InterfaceWireless; 00166 class WirelessLink; 00167 class Routing; 00168 class Protocol; 00169 class ProtocolGraph; 00170 class PortDemux; 00171 class Linkp2p; 00172 class Queue; 00173 class Application; 00174 class NodeImpl; 00175 class RoutingAODV; 00176 class AODVRoutingEntry; 00177 class WormContainment; 00178 class Image; 00179 00180 class QTWindow; 00181 class NodeAnimation; 00182 // Definitions from Qt library. Unused if no Qt configured. 00183 class QCanvasPolygonalItem; 00184 class QCanvasItem; 00185 class QPoint; 00186 class QCanvas; 00187 class QColor; 00188 00189 // Define a callback for custom shapes in animation 00190 typedef QCanvasPolygonalItem*(*CustomShape_t)(QCanvas*, Node*, 00191 const QPoint&, 00192 QCanvasPolygonalItem*); 00193 00194 // For radio interface list 00195 class RadioItem 00196 { 00197 public: 00198 RadioItem() : inf(nil), dist(0) {} 00199 RadioItem(InterfaceWireless* i, Meters_t d) : inf(i), dist(d) {} 00200 00201 public: 00202 InterfaceWireless* inf; 00203 Meters_t dist; 00204 }; 00205 00206 //typedef std::vector<RadioItem> RadioVec_t; 00207 typedef std::list<RadioItem> RadioVec_t; 00208 00209 //Doc:ClassXRef 00210 class NodeIfWeight { // Used by routing protocols 00211 public: 00212 NodeIfWeight(Node* n, InterfaceBasic* i, Weight_t w) 00213 : node(n), iface(i), weight(w) { } 00214 public: 00215 Node* node; 00216 InterfaceBasic* iface; 00217 Weight_t weight; 00218 }; 00219 00220 //Doc:ClassXRef 00221 class NodeIf { // Node and Interface used to get there, used by routing 00222 public: 00223 NodeIf(Node* n, Interface* i) 00224 : node(n), iface(i) { } 00225 public: 00226 Node* node; 00227 Interface* iface; 00228 }; 00229 00230 //Doc:ClassXRef 00231 class IpMask { // IP Address and mask 00232 public: 00233 IpMask(IPAddr_t i, Mask_t m) 00234 : ip(i), mask(m) { } 00235 public: 00236 IPAddr_t ip; 00237 Mask_t mask; 00238 }; 00239 00240 typedef std::vector<Link*> LinkVec_t; 00241 typedef std::vector<Node*> NodeVec_t; 00242 typedef std::deque<NodeIf> NodeDeque_t; 00243 typedef std::vector<IPAddr_t> IPAddrVec_t; 00244 typedef std::vector<IpMask> IPMaskVec_t; 00245 typedef std::vector<Interface*> IFVec_t; 00246 typedef std::vector<NodeIfWeight> NodeWeightVec_t; // Neighbors,Iface w/weights 00247 typedef std::vector<NodeIf> NodeIfVec_t; // Nodes and Iface to reach 00248 typedef std::vector<Dist_t> DistVec_t; 00249 00250 const Dist_t INF = 0xffffffff; 00251 00252 #include "routing.h" 00253 #include "trace.h" 00254 #include "macaddr.h" 00255 00256 class RoutingNixVector; 00257 class Mobility; 00258 class Packet; 00259 //Doc:ClassXRef 00260 class Node { 00261 //class Node { 00262 //Doc:Class Objects of class {\tt Node} are used in \GTNS\ to represent all 00263 //Doc:Class nodes in the simulated topology. Nodes represent end-- systems, 00264 //Doc:Class wireless devides, hubs, and routers. When a node is created, it 00265 //Doc:Class automatically has an associated routing object (the default 00266 //Doc:Class is \NV\ routing) and a layer 3 protocol object (the default 00267 //Doc:Class is {\em IPV4}). After nodes are created, interfaces and links 00268 //Doc:Class can be added to describe the connectivity of nodes, using the 00269 //Doc:Class public members described below. 00270 00271 public: 00272 // Define the node shapes for animation 00273 typedef enum { NONE, CIRCLE, SQUARE, HEXAGON, OCTAGON, 00274 CUSTOM, // Displayed by the custom callback 00275 IMAGE // Displayed with a Qt image file 00276 } Shape_t; 00277 00278 public: 00279 //Doc:Method 00280 Node(SystemId_t = 0); 00281 //Doc:Desc Creates a node in the simulated topology. The optional parameter 00282 //Doc:Desc is useful only for distributed simulations, and specifies 00283 //Doc:Desc which simulator is responsible for maintaining the state 00284 //Doc:Desc for this node. If the id specified matches the system 00285 //Doc:Desc id specified on the {\tt Simulator} constructor, then 00286 //Doc:Desc a full--state node is created. If not, a reduced state 00287 //Doc:Desc node, with only connectivity information, is created. 00288 //Doc:Arg1 The system responsible for this node (distributed simulations 00289 //Doc:Arg1 only. 00290 00291 protected: 00292 // Used by node subclasses, such as SatelliteNode, to specify 00293 // type of node implementation needed 00294 Node(NodeImpl*, SystemId_t = 0); 00295 00296 public: 00297 virtual ~Node(); 00298 //Doc:Method 00299 NodeId_t Id() { return id;} 00300 //Doc:Desc Each node in a \GTNS\ simulation has an associated unique 00301 //Doc:Desc integer identifier, starting from zero for the first 00302 //Doc:Desc node created. 00303 //Doc:Return The node identifier for this node. 00304 00305 // IP Address Management 00306 //Doc:Method 00307 IPAddr_t GetIPAddr(); // Get the IPAddres of this node 00308 //Doc:Desc Returns the \IPA\ assigned to this node. Nodes can have 00309 //Doc:Desc multiple \IPA{s}, since \IPA{s} are assigned to interfaces and 00310 //Doc:Desc nodes can have multiple interfaces. This returns the first 00311 //Doc:Desc \IPA\ assigned to this node. 00312 //Doc:Return The first \IPA\ assigned to this node. 00313 00314 //Doc:Method 00315 virtual void SetIPAddr(IPAddr_t); // Set the IPAddres of this node 00316 //Doc:Desc Specifies an \IPA\ for this node. 00317 //Doc:Arg1 The \IPA\ to be assigned to this node. 00318 00319 // Return vector of all known IPAddr's and associated masks for this node 00320 //Doc:Method 00321 void IPAddrs(IPMaskVec_t&); 00322 //Doc:Desc Each interface assigned to a node has an associated \IPA\ and 00323 //Doc:Desc address mask. This method returns a vector of the \IPA\ and 00324 //Doc:Desc masks for each interface on this node. 00325 //Doc:Arg1 An {\em out} parameter that is populated with the 00326 //Doc:Arg1 \IPA\ and mask information. 00327 00328 //Doc:Method 00329 bool LocalIP(IPAddr_t); // True if specified ip is local 00330 //Doc:Desc Determines if the specified \IPA\ is local to this node. 00331 //Doc:Arg1 The \IPA\ to check for locality. 00332 00333 //Doc:Method 00334 bool IPKnown(); // True if non-default ip is assigned 00335 //Doc:Desc Determines if this node has an \IPA\ assigned. 00336 00337 //Doc:Method 00338 bool IsReal(); // True if node is not a Ghost 00339 //Doc:Desc Find out if this node is "real", versus a Ghost 00340 //Doc:Return True if Real node, false if Ghost. 00341 00342 //Doc:Method 00343 bool IsSwitchNode(); // True if node is a switch 00344 //Doc:Desc Find out if this node is switch. 00345 00346 //Doc:Method 00347 void IsSwitchNode(bool); 00348 //Doc:Desc Set the node to a switch or not 00349 00350 //Doc:Method 00351 void PacketRX(Packet*, Interface*); 00352 //Doc:Desc called when a packet is receive on a switch node 00353 00354 00355 // Interfaces 00356 //Doc:Method 00357 Interface* AddInterface(Interface*); 00358 //Doc:Desc Add a new interface, using a pre-allocated interface pointer. 00359 //Doc:Arg1 Interface to add. 00360 //Doc:Return Added interface. 00361 00362 //Doc:Method 00363 Interface* AddInterface(const L2Proto& = L2Proto802_3(), 00364 bool bootstrap=false); 00365 //Doc:Desc Assign a new interface to this node, with no associated 00366 //Doc:Desc \IPA\ or mask. 00367 //Doc:Return A pointer to the newly assigned interface. 00368 //Doc:Arg1 A layer 2 protocol object to be assigned to this interface. 00369 //Doc:Arg1 The object passed in is {\em copied}, so the same object 00370 //Doc:Arg1 may be passed to multiple interfaces without problems. 00371 00372 //Doc:Method 00373 Interface* AddInterface(const L2Proto&, 00374 IPAddr_t, Mask_t, MACAddr m = MACAddr::Allocate(), 00375 bool bootstrap=false); 00376 //Doc:Desc Assign a new interface to this node, with the specified 00377 //Doc:Desc \IPA\ and mask. 00378 //Doc:Return A pointer to the newly assigned interface. 00379 //Doc:Arg1 A layer 2 protocol object to be assigned to this interface. 00380 //Doc:Arg1 The object passed in is {\em copied}, so the same object 00381 //Doc:Arg1 may be passed to multiple interfaces without problems. 00382 //Doc:Arg2 The \IPA\ assigned to this interface. 00383 //Doc:Arg3 The address mask assigned to this interface. 00384 //Doc:Arg4 The {\em MAC} address assigned (normally the default 00385 //Doc:Arg4 should be used) 00386 00387 //Doc:Method 00388 Interface* AddInterface(const L2Proto&,const Interface&, 00389 IPAddr_t, Mask_t, 00390 MACAddr = MACAddr::Allocate(), 00391 bool bootstrap = false); 00392 //Doc:Desc Assign a new interface to this node, with the specified 00393 //Doc:Desc \IPA\ and mask. 00394 //Doc:Return A pointer to the newly assigned interface. 00395 //Doc:Arg1 A layer 2 protocol object to be assigned to this interface. 00396 //Doc:Arg1 The object passed in is {\em copied}, so the same object 00397 //Doc:Arg1 may be passed to multiple interfaces without problems. 00398 //Doc:Arg2 Reference to what type of Interface to add 00399 //Doc:Arg3 The \IPA\ assigned to this interface. 00400 //Doc:Arg4 The address mask assigned to this interface. 00401 //Doc:Arg5 The {\em MAC} address assigned (normally the default 00402 //Doc:Arg5 should be used) 00403 00404 00405 00406 //Interface* LocalSubnet(IPAddr_t); // Determine if local subnet 00407 //Doc:Method 00408 virtual Count_t InterfaceCount(); // Get count of interfaces 00409 //Doc:Desc Returns the number of interfaces assigned to this node. 00410 //Doc:Return The number of interfaces assigned to this node. 00411 00412 //Doc:Method 00413 virtual const IFVec_t& Interfaces(); // Get the complete list of interfaces 00414 //Doc:Desc Returns a reference to a vector of all interfaces assigned 00415 //Doc:Desc to this node. 00416 //Doc:Return A vector of interface pointers for each interfae assigned 00417 //Doc:Return to this node. 00418 00419 //Doc:Method 00420 virtual Interface* GetIfByLink(Link*); // Get interface to the specified link 00421 //Doc:Desc Returns the interface associated with the specified link. 00422 //Doc:Arg1 A pointer to the link object to search for. 00423 //Doc:Return The interface pointer associated with the specified link. 00424 //Doc:Return Returns {\em nil} if not found. 00425 00426 //Doc:Method 00427 virtual Interface* GetIfByNode(Node*); // Get interface to the specified node 00428 //Doc:Desc Returns the interface used to communicate with the specified 00429 //Doc:Desc node. 00430 //Doc:Arg1 A pointer to the node to search for. 00431 //Doc:Return A pointer to the interface used to communicate with the 00432 //Doc:Return specified node. Returns {\em nil} if not found. 00433 00434 //Doc:Method 00435 virtual Interface* GetIfByIP(IPAddr_t);// Get interface by IP Address 00436 //Doc:Desc Returns the interface with the specified \IPA. 00437 //Doc:Arg1 The \IPA\ to find. 00438 //Doc:Return A pointer to the interface with the specified \IPA. 00439 //Doc:Return Returns {\em nil} if not found. 00440 00441 //Doc:Method 00442 void Broadcast(Packet*, Proto_t);// Broadcast packet on all interfaces 00443 //Doc:Desc Broadcasts a packet on all associated interfaces. 00444 //Doc:Arg1 The packet to send. Each interface gets a separate copy of the 00445 //Doc:Arg1 packet, so the caller is still responsible for the memory 00446 //Doc:Arg1 for the packet, and should delete this packet when no 00447 //Doc:Arg1 longer needed. 00448 //Doc:Arg2 The layer 3 protocol number to insert in the layer 2 00449 //Doc:Arg2 header for thiis packet. 00450 00451 // Links. All return local interface 00452 // Add duplex link to/from remote 00453 //Doc:Method 00454 Interface* AddDuplexLink(Node*); 00455 //Doc:Desc Adds a new duplex link (and an associated interface) to 00456 //Doc:Desc this node, using the default link type. 00457 //Doc:Arg1 A node pointer to the peer node for this link. 00458 //Doc:Return A pointer to the newly added interface 00459 //Doc:Return on the local node. 00460 00461 //Doc:Method 00462 Interface* AddDuplexLink(Node*, const Linkp2p&); 00463 //Doc:Desc Adds a new duplex link (and an associated interface) to 00464 //Doc:Desc this node, using the specified link type. 00465 //Doc:Arg1 A node pointer to the peer node for this link. 00466 //Doc:Arg2 The type of link to add. The passed argument is copied, 00467 //Doc:Arg2 so an anonymous temporary object can be passed, or 00468 //Doc:Arg2 the same link object can be passed multiple times. 00469 //Doc:Return A pointer to the newly added interface 00470 //Doc:Return on the local node. 00471 00472 // Next two specify new links between existing interfaces 00473 //Doc:Method 00474 Interface* AddDuplexLink(Interface*,Interface*); 00475 //Doc:Desc Add a new duplex link between two existing interfaces, 00476 //Doc:Desc using the default link type. 00477 //Doc:Arg1 First existing interface. 00478 //Doc:Arg2 Second existing interface. 00479 //Doc:Return A pointer to the first interface specified. 00480 00481 //Doc:Method 00482 Interface* AddDuplexLink(Interface*,Interface*, const Linkp2p&); 00483 //Doc:Desc Add a new duplex link between two existing interfaces, 00484 //Doc:Desc using the specified link object type. 00485 //Doc:Arg1 First existing interface. 00486 //Doc:Arg2 Second existing interface. 00487 //Doc:Arg3 The link object to use. This object is copied, so an 00488 //Doc:Arg3 anonymous temporary object can be used, or the same 00489 //Doc:Arg3 object can be passed multiple times. 00490 //Doc:Return A pointer to the first interface specified. 00491 00492 //Doc:Method 00493 //Interface* AddDuplexLink(Interface*,Interface*, const Linkp2p&, Node*); 00494 //Doc:Desc Add a new duplex link between two existing interfaces, 00495 //Doc:Desc using the specified link object type. 00496 //Doc:Arg1 First existing interface. 00497 //Doc:Arg2 Second existing interface. 00498 //Doc:Arg3 The link object to use. This object is copied, so an 00499 //Doc:Arg3 anonymous temporary object can be used, or the same 00500 //Doc:Arg3 object can be passed multiple times. 00501 //Doc:Arg4 Pointer to the remote node 00502 //Doc:Return A pointer to the first interface specified. 00503 00504 00505 // Next two specify local and remote IPAddress and Masks 00506 //Doc:Method 00507 Interface* AddDuplexLink(Node*, 00508 IPAddr_t, Mask_t = Mask(32), 00509 IPAddr_t = IPADDR_NONE, Mask_t = Mask(32)); 00510 //Doc:Desc Adds a new duplex link (and an associated interface) to 00511 //Doc:Desc this node, using the default link type, and specifying 00512 //Doc:Desc the \IPA\ and mask for both new interfaces. 00513 //Doc:Arg1 A node pointer to the peer node for this link. 00514 //Doc:Arg2 The \IPA\ for the local interface. 00515 //Doc:Arg3 The address mask for the local interface. 00516 //Doc:Arg4 The \IPA\ for the remote interface. 00517 //Doc:Arg5 The address mask for the remote interface. 00518 //Doc:Return A pointer to the newly added interface 00519 //Doc:Return on the local node. 00520 00521 //Doc:Method 00522 Interface* AddDuplexLink(Node*, const Linkp2p&, 00523 IPAddr_t, Mask_t = Mask(32), 00524 IPAddr_t = IPADDR_NONE, Mask_t = Mask(32)); 00525 //Doc:Desc Adds a new duplex link (and an associated interface) to 00526 //Doc:Desc this node, using the specified link type, and specifying 00527 //Doc:Desc the \IPA\ and mask for both new interfaces. 00528 //Doc:Arg1 A node pointer to the peer node for this link. 00529 //Doc:Arg2 The type of link to add. The passed argument is copied, 00530 //Doc:Arg2 so an anonymous temporary object can be passed, or 00531 //Doc:Arg2 the same link object can be passed multiple times. 00532 //Doc:Arg3 The \IPA\ for the local interface. 00533 //Doc:Arg4 The address mask for the local interface. 00534 //Doc:Arg5 The \IPA\ for the remote interface. 00535 //Doc:Arg6 The address mask for the remote interface. 00536 //Doc:Return A pointer to the newly added interface 00537 //Doc:Return on the local node. 00538 00539 // Next two add "LinkRTI" objects for distributed simulations 00540 //Doc:Method 00541 Interface* AddRemoteLink(IPAddr_t, Mask_t); 00542 //Doc:Desc Used for distributed simulations only. Defines a link from 00543 //Doc:Desc this node to another node defined and managed on another 00544 //Doc:Desc simulator process. The default link bandwidth and 00545 //Doc:Desc link delay are used. 00546 //Doc:Arg1 The \IPA\ for the local interface. 00547 //Doc:Arg2 The address mask for the local interface. 00548 00549 //Doc:Method 00550 Interface* AddRemoteLink(IPAddr_t, Mask_t, Rate_t, Time_t); 00551 //Doc:Desc Used for distributed simulations only. Defines a link from 00552 //Doc:Desc this node to another node defined and managed on another 00553 //Doc:Desc simulator process. 00554 //Doc:Arg1 The \IPA\ for the local interface. 00555 //Doc:Arg2 The address mask for the local interface. 00556 //Doc:Arg3 The bandwidth for the remote link. 00557 //Doc:Arg4 The propagation delay for the remote link. 00558 00559 //Doc:Method 00560 Link* GetLink(Node*); // Get link to specified node 00561 //Doc:Desc Returns a pointer to the link used to communicate with 00562 //Doc:Desc the specified node. 00563 //Doc:Arg1 Node pointer to find a link for. 00564 //Doc:Return The link pointer for the link used to communicate with 00565 //Doc:Return the specified node. Returns {\em nil} is none is found. 00566 00567 // Simplex links, for modeling one-way links 00568 //Doc:Method 00569 Interface* AddSimplexLink(Node*); 00570 //Doc:Desc Add a simplex link from this node to the specified node, using 00571 //Doc:Desc the default link object and with no \IPA\ or mask. 00572 //Doc:Arg1 The node pointer for the remote node. 00573 //Doc:Return An interface pointer for the local interface added 00574 //Doc:Return for this link. 00575 00576 //Doc:Method 00577 Interface* AddSimplexLink(Node*, const Linkp2p&); 00578 //Doc:Desc Add a simplex link from this node to the specified node, using 00579 //Doc:Desc the specified link object and with no \IPA\ or mask. 00580 //Doc:Arg1 The node pointer for the remote node. 00581 //Doc:Arg2 The link object to copy for this simplex link. 00582 //Doc:Return An interface pointer for the local interface added 00583 //Doc:Return for this link. 00584 00585 //Doc:Method 00586 Interface* AddSimplexLink(Node*, const Linkp2p&, IPAddr_t, Mask_t); 00587 //Doc:Desc Add a simplex link from this node to the specified node, using 00588 //Doc:Desc the specified link object and with 00589 //Doc:Desc the specified \IPA\ and mask. 00590 //Doc:Arg1 The node pointer for the remote node. 00591 //Doc:Arg2 The link object to copy for this simplex link. 00592 //Doc:Arg3 The \IPA\ for the local interface. 00593 //Doc:Arg4 The address mask for the local interface. 00594 //Doc:Return An interface pointer for the local interface added 00595 //Doc:Return for this link. 00596 00597 // Queues 00598 //Doc:Method 00599 Queue* GetQueue(); // Return queue if only one i/f 00600 //Doc:Desc Get a pointer to the queue object for this node. Since nodes 00601 //Doc:Desc can have multiple interfaces and queues, this is useful 00602 //Doc:Desc only for nodes with a single interface. 00603 //Doc:Return A pointer to the single queue for this node. 00604 //Doc:Return Returns {\em nil} 00605 //Doc:Return if no interfaces, or more than one interface. 00606 00607 //Doc:Method 00608 Queue* GetQueue(Node*); // Get the queue to specified node 00609 //Doc:Desc Get a pointer to the queue object used to buffer packets 00610 //Doc:Desc destined for the specified node. 00611 //Doc:Arg1 The target node to locate the queue for. 00612 //Doc:Return A pointer to the queue object uesd to buffer packets 00613 //Doc:Return destined for the specified node. Returns {\em nil} if 00614 //Doc:Return none is found. 00615 00616 // Applications 00617 //Doc:Method 00618 Application* AddApplication(const Application& a); 00619 //Doc:Desc Adds an application associated with this node. 00620 //Doc:Arg1 The application object to use. 00621 //Doc:Arg1 This application object is copied, 00622 //Doc:Arg1 so an anonymous temporary object can be specified, or the 00623 //Doc:Arg1 same application object can be used multiple times. 00624 //Doc:Return A pointer to the newly added application. 00625 00626 // Neighbor management (used by some routing protocols) 00627 //Doc:Method 00628 virtual void Neighbors(NodeWeightVec_t &, bool = false); // Get all neighbors 00629 //Doc:Desc Get a list of all neighbors for this node. 00630 //Doc:Desc An output parameter, returning a vector of nodes and link 00631 //Doc:Arg1 weights to each directly connected neighbor. 00632 //Doc:Arg1 True if skip leaf neighbors desired 00633 00634 void AddNeighbor(Node*, Weight_t); // Ghost nodes keep neighbor list 00635 //Doc:Method 00636 Count_t NeighborCount(); // Get count of routing neighbors 00637 //Doc:Desc Get a count of directly connected neighbors. 00638 //Doc:Desc //Doc:Arg1 The count of directly connected neighbors. 00639 00640 // Get neighbors on given iface 00641 //Doc:Method 00642 void NeighborsByIf(Interface*, IPAddrVec_t&); 00643 //Doc:Desc Get a list of \IPA{s} neighbors connected using the specified 00644 //Doc:Desc interface. 00645 //Doc:Arg1 The interface to return the neighbors for. 00646 //Doc:Arg2 An output parameter giving a vector of \IPA{s} connected 00647 //Doc:Arg2 on the specified interface. 00648 00649 // Routing 00650 //Doc:Method 00651 void DefaultRoute(RoutingEntry); // Specify default route 00652 //Doc:Desc Specifies the default route for packets leaving 00653 //Doc:Desc this node. 00654 //Doc:Arg1 The routing entry (interface and \IPA) to use when 00655 //Doc:Arg1 no other routing information can be found. 00656 00657 //Doc:Method 00658 void DefaultRoute(Node*); // Specify default route 00659 //Doc:Desc Specifies the default route for packets leaving 00660 //Doc:Desc this node. 00661 //Doc:Arg1 The next hop neighbor to use for routing when 00662 //Doc:Arg1 no other routing information can be found. 00663 00664 //Doc:Method 00665 void AddRoute(IPAddr_t, Count_t, Interface*, IPAddr_t); 00666 //Doc:Desc Add a new routing table entry. 00667 //Doc:Arg1 The \IPA\ specifying the destination address this 00668 //Doc:Arg1 routing entry is for. 00669 //Doc:Arg2 The mask for the destination \IPA, which allows 00670 //Doc:Arg2 route aggregation. 00671 //Doc:Arg3 The interface for the next hop target for the 00672 //Doc:Arg3 specified destination. 00673 //Doc:Arg4 The \IPA\ of the next hop target. 00674 00675 //Doc:Method 00676 RoutingEntry LookupRoute(IPAddr_t); // Find a routing entry 00677 //Doc:Desc Look up the routing table entry for a specified destination 00678 //Doc:Desc \IPA. 00679 //Doc:Arg1 The destination \IPA\ to look up. 00680 //Doc:Return The routing table entry for the specified destination. 00681 //Doc:Return The interface pointer in this entry will be {\em nil} 00682 //Doc:Return if no routing information is found for the specified 00683 //Doc:Return destination. 00684 00685 //Doc:Method 00686 RoutingEntry LookupRouteNix(Count_t); // Lookup route by Neighbor Index 00687 //Doc:Desc Look up the routing table entry by a neighbor index, 00688 //Doc:Desc used by the \NV\ routing method. 00689 //Doc:Arg1 The neighbor index to look up. 00690 //Doc:Return The routing table entry for the specified neighbor index. 00691 //Doc:Return The interface pointer in this entry will be {\em nil} 00692 //Doc:Return if no routing information is found for the specified 00693 //Doc:Return destination. 00694 00695 //Doc:Method 00696 Routing::RType_t RoutingType(); // Report type of routing in use 00697 //Doc:Desc Return the routing type in use at this node. 00698 //Doc:Return The routing type in use. The enumerated type {\tt RType_t} 00699 //Doc:Return is defined in {\tt routing.h}. 00700 00701 //Doc:Method 00702 Interface* LocalRoute(IPAddr_t); // Find if dst is directly connected 00703 //Doc:Desc Determine if the specified \IPA\ is on a directly connected 00704 //Doc:Desc neighbor. 00705 //Doc:Arg1 The \IPA\ to search for. 00706 //Doc:Return An pointer to the interface used to communicate with the 00707 //Doc:Return specified \IPA. Returns {\em nil} if the specified 00708 //Doc:Return \IPA\ is not a directly connected neighbor. 00709 00710 //AODV Routing 00711 //Specially for AODV routing, it is not compatiable with 00712 //other route entry. 00713 // 00714 AODVRoutingEntry *LookupRouteAODV(IPAddr_t); 00715 void SetRoutingAODV(void *pRouting); 00716 RoutingAODV* GetRoutingAODV(); //return the AODV routing object pointer 00717 00718 //Doc:Method 00719 void InitializeRoutes(); // Routing initialization (if any) 00720 //Doc:Desc Perform any initializations needed by the routing protocol 00721 //Doc:Desc used by this node. 00722 00723 //Doc:Method 00724 void ReInitializeRoutes(bool); // Reinit due to topology chanbe 00725 //Doc:Desc Validates existing routes and re-calculates as necessary 00726 //Doc:Arg1 True if node or interface UP, false if DOWN 00727 00728 //Doc:Method 00729 Count_t RoutingFibSize() const; // Statistics, size of FIB 00730 //Doc:Desc Determine the size of the forwarding information base (FIB) 00731 //Doc:Desc at this node. 00732 //Doc:Return The size, in bytes, of the FIB at this node. 00733 00734 //Doc:Method 00735 Count_t GetNix(Node*) const; // Get Neighbor Index for spec'd node 00736 //Doc:Desc Get the neighbor index for the specified node. Used by the 00737 //Doc:Desc \NV\ routing method. 00738 //Doc:Arg1 The node to find the neighbor index for. 00739 //Doc:Return The neighbor index for the specified node. 00740 //Doc:Return Returns MAX_COUNT if the specified node is not a neighbor. 00741 00742 //Doc:Method 00743 RoutingNixVector* GetNixRouting(); // Returns Nix rtg pointer (if Nix) 00744 //Doc:Desc Get a pointer to the \NV\ routing object for this node. 00745 //Doc:Return A pointer to the \NV\ routing object for this node. 00746 //Doc:Return Returns {\em nil} if \NV\ routing is not used at this node. 00747 00748 //Doc:Method 00749 Routing* GetRouting(); 00750 //Doc:Desc Get a pointer to the routing object used by this node. 00751 //Doc:Return Routing object pointer. 00752 00753 void DumpNV(); // Debug, dump NixVector info 00754 00755 // Protocol Graph Interface 00756 //Doc:Method 00757 Protocol* LookupProto(Layer_t, Proto_t);// Lookup protocol by layer 00758 //Doc:Desc Find the protocol object at the specified protocol layer, 00759 //Doc:Desc and protocol number. 00760 //Doc:Arg1 The protocol layer number to look up. 00761 //Doc:Arg2 The protocol number to look up. 00762 //Doc:Return A pointer to the protocol object at the specified layer and 00763 //Doc:Return protocol number. 00764 00765 //Doc:Method 00766 void InsertProto(Layer_t, Proto_t, Protocol*); // Insert a protocol 00767 //Doc:Desc Inserts a new protocol in the protocol graph. 00768 //Doc:Arg1 The protocol layer number to insert the protocol into. 00769 //Doc:Arg2 The protocol number to insert the protocol intol 00770 //Doc:Arg3 A protocol to insert. 00771 00772 // Port Demux Interface 00773 //Doc:Method 00774 bool Bind(Proto_t, PortId_t, Protocol*); // Register port usage 00775 //Doc:Desc Bind a protocol to a port number at a particular protocol 00776 //Doc:Desc number. 00777 //Doc:Arg1 The protocol number for this port. 00778 //Doc:Arg2 The port to bind to. 00779 //Doc:Arg3 The protocol to bind to the port. 00780 //Doc:Return True if successful. 00781 00782 //Doc:Method 00783 bool Bind(Proto_t, 00784 PortId_t, IPAddr_t, 00785 PortId_t, IPAddr_t, 00786 Protocol*); // Register port usage 00787 //Doc:Desc Binds a protocol to a local \IPA, port, remote \IPA, port, 00788 //Doc:Desc at a particular protocol number. 00789 //Doc:Arg1 The protocol number for this binding. 00790 //Doc:Arg2 The local port number. 00791 //Doc:Arg3 The local \IPA. 00792 //Doc:Arg4 The remote port number. 00793 //Doc:Arg5 The remote \IPA. 00794 //Doc:Arg6 The protocol to bind. 00795 //Doc:Return True if successful. 00796 00797 //Doc:Method 00798 PortId_t Bind(Proto_t, Protocol*); // Choose port and register 00799 //Doc:Desc Bind a protocol to any available port. 00800 //Doc:Arg1 The protocol number to use. 00801 //Doc:Arg2 The protocol to bind. 00802 //Doc:Return The port number bound to. 00803 00804 //Doc:Method 00805 bool Unbind(Proto_t, PortId_t, Protocol*); // Remove port binding 00806 //Doc:Desc Remove a port binding. 00807 //Doc:Arg1 The protocol number to use. 00808 //Doc:Arg2 The currently bound port number. 00809 //Doc:Arg3 The protocol to unbind. 00810 //Doc:Return True if successful. 00811 00812 //Doc:Method 00813 bool Unbind(Proto_t, 00814 PortId_t, IPAddr_t, 00815 PortId_t, IPAddr_t, 00816 Protocol*); // Remove port binding 00817 //Doc:Desc Remove a port binding by local and remote port and \IPA. 00818 //Doc:Arg1 The protocol number to use. 00819 //Doc:Arg2 Local port number. 00820 //Doc:Arg3 Local \IPA. 00821 //Doc:Arg4 Remote port number. 00822 //Doc:Arg5 Remote \IPA. 00823 //Doc:Arg6 Protocol to unbind. 00824 //Doc:Return True if successful. 00825 00826 //Doc:Method 00827 Protocol* LookupByPort(Proto_t, PortId_t); // Lookup by port 00828 //Doc:Desc Locate the protocol bound to a specified port and protocol 00829 //Doc:Desc number. 00830 //Doc:Arg1 The protocol number. 00831 //Doc:Arg2 The port to look up. 00832 //Doc:Return A pointer to the protocol bound to the specified port. 00833 //Doc:Return Returns {\em nil} if no protocol is found at the 00834 //Doc:Return specified protocol and port. 00835 00836 //Doc:Method 00837 Protocol* LookupByPort(Proto_t, 00838 PortId_t, IPAddr_t, 00839 PortId_t, IPAddr_t); // Lookup by s/d port/ip 00840 //Doc:Desc Locate the protocol bound to the specified local and remote 00841 //Doc:Desc port and \IPA, at the specified protocol number. 00842 //Doc:Arg1 The protocol number. 00843 //Doc:Arg2 Local port number. 00844 //Doc:Arg3 Local \IPA. 00845 //Doc:Arg4 Remote port number. 00846 //Doc:Arg5 Remote \IPA. 00847 //Doc:Return A pointer to the protocol bound as specified. 00848 //Doc:Return Returns {\em nil} if no protocol is found. 00849 00850 // Packet tracing interface 00851 //Doc:Method 00852 // Trace header if enabled 00853 bool TracePDU(Protocol*, PDU*, Packet* = nil, char* = nil); 00854 //Doc:Desc Log the contents of the specified protocol data unit, from 00855 //Doc:Desc the specified protocol, to the trace file. 00856 //Doc:Arg1 The protocol pointer for the protocol object requesting 00857 //Doc:Arg1 the trace. 00858 //Doc:Arg2 The protocol data unit pointer. 00859 //Doc:Arg3 Packet that contains this PDU (optional) 00860 //Doc:Arg4 Extra text information for trace file (optional) 00861 //Doc:Return Returns true if trace file exists. 00862 00863 //Doc:Method 00864 void SetTrace(Trace::TraceStatus); // Set trace level this node 00865 //Doc:Desc Specifies the tracing status of this node. 00866 //Doc:Desc The trace status desired. This can be either 00867 //Doc:Desc {\tt Trace::ENABLED}, 00868 //Doc:Desc which indicates that all packets requesting tracing 00869 //Doc:Desc at this node will be traced; 00870 //Doc:Desc {\tt Trace::DISABLED} indicating that no packets will 00871 //Doc:Desc be traced, or {\tt Trace::DEFAULT}, indicating that the 00872 //Doc:Desc decision is deferred to the protocols at this node. 00873 //Doc:Arg1 The trace status desired for this node. 00874 00875 // Node location (x, y, z) interface 00876 //Doc:Method 00877 void SetLocation(Meters_t, Meters_t, Meters_t=0); // Set x/y/z location 00878 //Doc:Desc Set the location of this node in the X--Y--Z coordinate. 00879 //Doc:Arg1 The X--coordinate (meters). 00880 //Doc:Arg2 The Y--coordinate (meters). 00881 //Doc:Arg3 The Z--coordinate (meters). 00882 00883 //Doc:Method 00884 void SetLocation(const Location&); // Set x/y/z location 00885 //Doc:Desc Set the location of this node in the X--Y--Z coordinate. 00886 //Doc:Arg1 A {\tt Location} object specifying 00887 //Doc:Arg1 the X--Y--Z coordinate (meters). 00888 00889 //Doc:Method 00890 void SetLocationLongLat(const Location&); // Set x/y location 00891 //Doc:Desc Set the location of this node in the X--Y plane. 00892 // Adjusts the lat/long by the cos(lat) factor for map projections. 00893 //Doc:Arg1 A {\tt Location} object specifying 00894 //Doc:Arg1 the X--coordinate (longitued) and Y--coordinate (latitude). 00895 00896 //Doc:Method 00897 bool HasLocation(); 00898 //Doc:Desc Test if the node has a location assigned. 00899 //Doc:Return True if location assigned for this node. 00900 00901 //Doc:Method 00902 Meters_t LocationX(); 00903 //Doc:Desc Return the X--coordinate of this node. 00904 //Doc:Return The X--coordinate (meters) of this node. 00905 00906 //Doc:Method 00907 Meters_t LocationY(); 00908 //Doc:Desc Return the Y--coordinate of this node. 00909 //Doc:Return The Y--coordinate (meters) of this node. 00910 00911 //Doc:Method 00912 Meters_t LocationZ(); 00913 //Doc:Desc Return the Z--coordinate of this node. 00914 //Doc:Return The Z--coordinate (meters) of this node. 00915 00916 //Doc:Method 00917 Location GetLocation(); // Return current location 00918 //Doc:Desc Return the location of this node. 00919 //Doc:Return A {\tt Location} object specifying the X, Y and Z coordinates 00920 //Doc:Return of this node (meters). 00921 00922 //Doc:Method 00923 Location UpdateLocation(); // Get updated location 00924 //Doc:Desc The location of mobile nodes is not updated continually 00925 //Doc:Desc during the simulation. Rather, it is updated when 00926 //Doc:Desc {\tt UpdateLocation()} is called. 00927 //Doc:Return A {\tt Location} object specifying the X, Y and Z coordinates 00928 //Doc:Return of this node (meters). 00929 00930 //Doc:Method 00931 Mobility* AddMobility(const Mobility&); // Add a mobility model 00932 //Doc:Desc Add a mobility model to this node. 00933 //Doc:Arg1 The {\tt Mobility} object to use. This is copied to the 00934 //Doc:Arg1 node, so an anonymous temporary object can be used, 00935 //Doc:Arg1 or the same {\tt Mobility} object can be passed 00936 //Doc:Arg1 multiple times. 00937 //Doc:Return A pointer to the added mobility object. 00938 00939 //Doc:Method 00940 Mobility* GetMobility(); 00941 //Doc:Desc Return existing mobility model. 00942 //Doc:Return Pointer to this nodes mobility model. NIL if none. 00943 00944 //Doc:Method 00945 bool IsMobile(); // True if mobility enabled 00946 //Doc:Desc Determine if this node has a mobility model. 00947 //Doc:Return True if node has a mobility model. 00948 00949 //Doc:Method 00950 bool IsMoving(); // True if not pausing 00951 //Doc:Desc Determine if this node is presently moving (rather than 00952 //Doc:Desc paused or temporarily stationary). 00953 //Doc:Return True if node is presently moving. 00954 00955 //Doc:Method 00956 Meters_t Distance(Node*); 00957 //Doc:Desc Calculate distance between this node and specified peer node. 00958 //Doc:Arg1 Peer node pointer. 00959 //Doc:Return Distance (meters). 00960 00961 //Doc:Method 00962 void BuildRadioInterfaceList(WirelessLink*); // i/f list in radio range 00963 //Doc:Desc Build a list of nodes in transmission range. 00964 00965 //Doc:Method 00966 const RadioVec_t& GetRadioInterfaceList(); 00967 //Doc:Desc Get a reference to the current radio interface list 00968 //Doc:Return Reference to the current radio interface list 00969 00970 //Doc:Method 00971 void SetRadioRange(Meters_t range); 00972 //Doc:Desc Specify the power range of this wireless transmiter (meters). 00973 //Doc:Arg1 Power range (meters) 00974 00975 //Doc:Method 00976 Meters_t GetRadioRange(void); 00977 //Doc:Desc Return the power range of this transmitter. 00978 //Doc:Return Power range (meters). 00979 00980 // Callback methods 00981 //Doc:Method 00982 void AddCallback(Layer_t, Proto_t, 00983 PacketCallbacks::Type_t, 00984 Interface*, PacketCallbacks::Function_t); 00985 //Doc:Desc Add a callback function to this node. Callbacks allow 00986 //Doc:Desc a function to examine every packet recieved by this node 00987 //Doc:Desc at any protocol layer, and either packet receipt or 00988 //Doc:Desc packet transmission 00989 //Doc:Arg1 Layer to insert callback. Specifying zero indicates 00990 //Doc:Arg1 all layers will call the callback. 00991 //Doc:Arg2 Protocol number for callback. Specifying zero indicates 00992 //Doc:Arg2 the callback should be called for all protocols at the 00993 //Doc:Arg2 specified layer. 00994 //Doc:Arg3 Type of callback. Either PacketCallbacks::RX, indicating 00995 //Doc:Arg3 a callback on packet receipt, or PacketCallbacks::Tx 00996 //Doc:Arg3 indicating callback on packet transmission. 00997 //Doc:Arg4 Interface pointer. Layer 2 callbacks can specify an additional 00998 //Doc:Arg4 restriction specifying a particular interface only. 00999 //Doc:Arg5 Callback function to add. 01000 //Doc:Arg5 The callback function must return true or false indicating 01001 //Doc:Arg5 that the packet should (true) or should not (false) 01002 //Doc:Arg5 continue processing by the caller. In other words, 01003 //Doc:Arg5 if the callback function drops the packet, it sould 01004 //Doc:Arg5 return false. The callback function must accept five 01005 //Doc:Arg5 arguments: Layer_t, PacketCallbacks::Type_t, Packet* 01006 //Doc:Arg5 Node* and Interface*. 01007 //Doc:Arg5 The layer is the layer number from which the 01008 //Doc:Arg5 callback was generated, the Type_t is 01009 //Doc:Arg5 either RX or TX as described above, the 01010 //Doc:Arg5 Packet* is the packet, and the Node* 01011 //Doc:Arg5 is the node processing the packet. The Interface* 01012 //Doc:Arg5 is the interface processing the packet (layer 2 only) 01013 01014 void AddCallbackHead(Layer_t, Proto_t, 01015 PacketCallbacks::Type_t, 01016 Interface*, PacketCallbacks::Function_t); 01017 //Doc:Desc Add a callback function to this node to the HEAD 01018 //Doc:Desc of the callback list, calling this before previous callbacks. 01019 //Doc:Arg1 Layer to insert callback. Specifying zero indicates 01020 //Doc:Arg1 all layers will call the callback. 01021 //Doc:Arg2 Protocol number for callback. Specifying zero indicates 01022 //Doc:Arg2 the callback should be called for all protocols at the 01023 //Doc:Arg2 specified layer. 01024 //Doc:Arg3 Type of callback. Either PacketCallbacks::RX, indicating 01025 //Doc:Arg3 a callback on packet receipt, or PacketCallbacks::Tx 01026 //Doc:Arg3 indicating callback on packet transmission. 01027 //Doc:Arg4 Interface pointer. Layer 2 callbacks can specify an additional 01028 //Doc:Arg4 restriction specifying a particular interface only. 01029 //Doc:Arg5 Callback function to add. 01030 //Doc:Arg5 Arguments are identical to those discussed in 01031 //Doc:Arg5 {\tt AddCallback} above. 01032 01033 //Doc:Method 01034 void DeleteCallback(Layer_t, Proto_t, PacketCallbacks::Type_t, 01035 Interface*); 01036 //Doc:Desc Remove a callback function from this node. 01037 //Doc:Arg1 Layer to remove callback from. 01038 //Doc:Arg2 Protocol number to delete. 01039 //Doc:Arg3 Type or callback to remove, either TX or RX as above. 01040 //Doc:Arg4 Interface to remove callback from. 01041 01042 //Doc:Method 01043 bool CallCallbacks(Layer_t, Proto_t, 01044 PacketCallbacks::Type_t, Packet*, Interface* = nil); 01045 //Doc:Desc Call any callback defined on this node for the layer and type 01046 //Doc:Desc specified. 01047 //Doc:Arg1 Layer for callback. 01048 //Doc:Arg2 Protocol number for callback. 01049 //Doc:Arg3 Type for callback. 01050 //Doc:Arg4 Packet being processed. 01051 //Doc:Method 01052 void UserInformation(void*); 01053 //Doc:Desc Nodes have a blind pointer that can contain arbitrary 01054 //Doc:Desc information useful the the user's simulation. 01055 //Doc:Arg1 Pointer to any information. Will be stored in the node 01056 //Doc:Arg1 object, and returned as needed. 01057 01058 //Doc:Method 01059 void* UserInformation(); 01060 //Doc:Desc Return the previously specified user information pointer. 01061 //Doc:Return User information pointer (nil if none specified) 01062 01063 01064 //Doc:Method 01065 void UseWormContainment(bool b); 01066 //Doc:Desc Specifies if the node is using a wormcontainment algorithm or not 01067 //Doc:Arg1 True means use containment, false dont use 01068 01069 //Doc:Method 01070 bool UseWormContainment(); 01071 //Doc:Desc Is this node using worm containment 01072 //Doc:Return True means use containment, false dont use 01073 01074 //Doc:Method 01075 void SetWormContainment(WormContainment*); 01076 //Doc:Desc Set the worm containment module for this node 01077 //Doc:Arg1 Worm containment module 01078 01079 01080 //Doc:Method 01081 WormContainment* GetWormContainment(); 01082 //Doc:Desc Gives a reference to the wormcontainment module of this node 01083 //Doc:Return Worm containment module 01084 01085 01086 //Doc:Method 01087 void UseARP(bool); 01088 //Doc:Desc Specifies if the node is using arp module or not 01089 //Doc:Arg1 True means use ARP, false dont use 01090 01091 //Doc:Method 01092 bool FirstBitRx(); 01093 //Doc:Desc Specified if the node needs a "first bit received" event. 01094 //Doc:Desc Some nodes, such as satellites and super-computer interconnects 01095 //Doc:Desc forward packets before the entire packet is received. 01096 01097 //Doc:Method 01098 void FirstBitRx(bool); 01099 //Doc:Desc Specify the node needs first bit received event. 01100 //Doc:Arg1 True if first bit received event needed. 01101 01102 //Doc:Method 01103 bool WirelessTx(); 01104 //Doc:Desc Check if the node is transmitting on a wireless link. Used by 01105 //Doc:Desc the animation widow. 01106 //Doc:Return True if transmitting. 01107 01108 //Doc:Method 01109 bool WirelessRx(); 01110 //Doc:Desc Check if the node is receiving on a wireless link. Used by 01111 //Doc:Desc the animation widow. 01112 //Doc:Return True if receiving. 01113 01114 //Doc:Method 01115 bool WirelessCx(); 01116 //Doc:Desc Check if the node is experiencing collision on a wireless link. 01117 //Doc:Desc Used by the animation widow. 01118 //Doc:Return True if colliding. 01119 01120 //Doc:Method 01121 bool WirelessRxMe(); 01122 //Doc:Desc Check if the node is receiving on a wireless link. Used by 01123 //Doc:Desc the animation widow. 01124 //Doc:Return True if receiving. 01125 01126 //Doc:Method 01127 bool WirelessRxZz(); 01128 //Doc:Desc Check if the node is receiving on a wireless link. Used by 01129 //Doc:Desc the animation widow. 01130 //Doc:Return True if receiving. 01131 01132 // QTWindow information 01133 //Doc:Method 01134 void Show(bool); // Turn on/off display 01135 //Doc:Desc Enable or disable the animation window. 01136 //Doc:Arg1 True if animation window should be enabled, false if not. 01137 01138 //Doc:Method 01139 bool Show(); // True if display enabled 01140 //Doc:Desc Determine if the node should be displayed in the anim window 01141 //Doc:Return True if the node should be displayed in the animation window 01142 01143 //Doc:Method 01144 QCanvasItem* Display(QTWindow*); 01145 //Doc:Desc Each node is responsible for "drawing" itself on the animation 01146 //Doc:Desc display. This allows the node to decide shape, size, etc. 01147 //Doc:Arg1 Qt Canvas to use. The node is drawn at present Location(). 01148 //Doc:Return Any subclass of QCanvasItem. 01149 01150 //Doc:Method 01151 QCanvasItem* Display(const QPoint&, QTWindow*); 01152 //Doc:Desc Each node is responsible for "drawing" itself on the animation 01153 //Doc:Desc display. This allows the node to decide shape, size, etc. 01154 //Doc:Arg1 Point in Qt canvas to display this node. 01155 //Doc:Arg2 Qt Canvas to use. 01156 //Doc:Return Any subclass of QCanvasItem. 01157 01158 //Doc:Method 01159 void WirelessTxColor(const QColor&); 01160 //Doc:Desc Specify color for the wireless transmit animation. 01161 //Doc:Arg1 Desired color. 01162 01163 //Doc:Method 01164 const QColor& WirelessTxColor(); 01165 //Doc:Desc Get the specified wireless transmit color 01166 //Doc:Return Color for wireless tx concentric circles 01167 01168 //Doc:Method 01169 bool PushWirelessTx(QCanvasItem*); 01170 //Doc:Desc Add a canvas itemm to the wireless transmit animation list 01171 //Doc:Arg1 Item (one of the concentric circles) to add 01172 01173 //Doc:Method 01174 QCanvasItem* PopWirelessTx(); 01175 //Doc:Desc Pop and return the oldest item in the wireless tx history. 01176 //Doc:Return Oldest item (nil if none). 01177 01178 //Doc:Method 01179 void PixelSize(Count_t); 01180 //Doc:Desc Set the size of this node (pixels) on the animation display. 01181 //Doc:Arg1 Size of this node in pixels (both width and height) 01182 01183 //Doc:Method 01184 Count_t PixelSizeX(); 01185 //Doc:Desc Query the width of this node (pixels) on the animation display. 01186 //Doc:Return Size of this node in pixels. 01187 01188 //Doc:Method 01189 Count_t PixelSizeY(); 01190 //Doc:Desc Query the height of this node (pixels) on the animation display. 01191 //Doc:Return Size of this node in pixels. 01192 01193 //Doc:Method 01194 void Shape(Shape_t); 01195 //Doc:Desc Set the shape for this node on the animation display. 01196 //Doc:Arg1 Shape for this node. See node.h for shape types. 01197 01198 //Doc:Method 01199 Shape_t Shape(); 01200 //Doc:Desc Query the shape for this node on the animation display. 01201 //Doc:Return Shape for this node. See node.h for shape types. 01202 01203 //Doc:Method 01204 CustomShape_t CustomShape(); 01205 //Doc:Desc Get the custom shape callback function. 01206 //Doc:Return Function pointer to custom shape callback function. 01207 01208 //Doc:Method 01209 void CustomShape(CustomShape_t); 01210 //Doc:Desc Specify the custom shape callback function. 01211 //Doc:Arg1 Pointer to new custom shape callback function. 01212 01213 //Doc:Method 01214 bool CustomShapeFile(const char*); 01215 //Doc:Desc Specifies a file containing the custom shape image. 01216 //Doc:Desc Must be in an image format supported by Qt. 01217 //Doc:Desc NOTE: This {\bf must} be called {\em after} the call 01218 //Doc:Desc to Simulator::StartAnimation, since it needs a QTWindow 01219 //Doc:Desc object. If called before StartAnimation, will always 01220 //Doc:Desc return false. 01221 //Doc:Arg1 File name for image. 01222 //Doc:Return True if successfully loaded 01223 01224 //Doc:Method 01225 bool CustomShapeImage(const Image&); 01226 //Doc:Desc Specifies a pre--defined image for the custom shape. 01227 //Doc:Desc GTNetS has a number of pre--defined and pre--processed 01228 //Doc:Desc images that can be used for custom shapes. See the IMAGES 01229 //Doc:Desc directory for the raw images. This method of setting 01230 //Doc:Desc custom shapes is preferred to the above file name method. 01231 //Doc:Arg1 One of the pre--defined Images, for example SatelliteImage. 01232 //Doc:Return True if successfully loaded. 01233 01234 //Doc:Method 01235 void Color(const QColor&); 01236 //Doc:Desc Specifiy a color for this node 01237 //Doc:Arg1 Desired color (see qcolor.h in qt). 01238 01239 //Doc:Method 01240 bool HasColor(); 01241 //Doc:Desc Query if this node has a color assigned 01242 //Doc:Return True if color has been specified. 01243 01244 //Doc:Method 01245 QColor& Color(); 01246 //Doc:Desc Query color for this node. 01247 //Doc:Return Specified display color for this node. 01248 01249 //Doc:Method 01250 NodeAnimation* GetNodeAnimation() const; 01251 //Doc:Desc Get a pointer to the nodes NodeAnimation information block. 01252 //Doc:Desc Always nil for Ghosts, possibly non-nil for real. 01253 //Doc:Return Associated NodeAnimation poiner. 01254 01255 //Doc:Method 01256 bool ICMPEnabled() const; 01257 //Doc:Desc Query if ICMP enabled for this node. 01258 //Doc:Return True if enabled. NOTE. This only means this node will use ICMP 01259 //Doc:Return if globally enabled (see icmp.h) 01260 01261 //Doc:Method 01262 void DisableICMP(); 01263 //Doc:Desc Specify this node does NOT use ICMP, even if globally enabled. 01264 01265 // Node failure management 01266 01267 //Doc:Method 01268 void Down(); 01269 //Doc:Desc Specifies the the node has crashed and should not forward or 01270 //Doc:Desc generate any packets. 01271 01272 //Doc:Method 01273 void Up(); 01274 //Doc:Desc Specifies the node has recovered from failure. 01275 01276 //Doc:Method 01277 bool IsDown(); 01278 //Doc:Desc Determine if node has failed or not. 01279 //Doc:Return TRUE if node is down (failed) 01280 01281 // Data Members 01282 private: 01283 NodeId_t id; // Node id for this node 01284 //protected: 01285 public: 01286 NodeImpl* pImpl; // Node Implementation, ghost or real 01287 // Static members 01288 public: 01289 static NodeId_t nextId; // Next available node id 01290 static NodeVec_t nodes; // Vector of all available nodes 01291 static double defaultMaxSpeed; // Default maximum speed of a node 01292 #ifdef HAVE_QT 01293 static Count_t defaultPixelSize; // Size in pixels of animated nodes 01294 static Shape_t defaultShape; // Default shape for all nodes 01295 #endif 01296 public: 01297 //Doc:Method 01298 static void SetNextNodeId(NodeId_t i) { nextId = i;} // Set non-default Next 01299 //Doc:Desc Set a new value for the next node identifier value. 01300 //Doc:Arg1 The new next node identifier value. 01301 01302 // Get const ref to Node vec 01303 //Doc:Method 01304 static const NodeVec_t& GetNodes() { return nodes;} 01305 //Doc:Desc Get the vector of all existing nodes. 01306 //Doc:Return A const reference to the vector of existing nodes. 01307 01308 //Doc:Method 01309 static Node* GetNode(NodeId_t); // Get a node pointer by id 01310 //Doc:Desc Get the node pointer for the specified node identifier. 01311 //Doc:Arg1 The node identifier desired. 01312 //Doc:Return A pointer to the specified node. Returns {\em nil} if the 01313 //Doc:Return specified node does not exist. 01314 01315 //Doc:Method 01316 static void Clear(); 01317 //Doc:Desc Clear the node vector. 01318 //Doc:Desc Normally only called after the simulation 01319 //Doc:Desc has completed, and we are trying to track memory leaks. 01320 01321 #ifdef HAVE_QT 01322 //Doc:Method 01323 static void DefaultPixelSize(Count_t); 01324 //Doc:Desc Set the default size (in pixels) of the animated nodes 01325 //Doc:Arg1 Default size in pixels. 01326 01327 //Doc:Method 01328 static Count_t DefaultPixelSize(); 01329 //Doc:Desc Query the default node pixel size 01330 //Doc:Return The default node pixel size. 01331 01332 //Doc:Method 01333 static void DefaultShape(Shape_t); 01334 //Doc:Desc Set the default shape for nodes on the animation display 01335 //Doc:Arg1 Default shape. See node.h for shape types. 01336 01337 //Doc:Method 01338 static Shape_t DefaultShape(); 01339 //Doc:Desc Query the default node shape. 01340 //Doc:Return Default shape. See node.h for shape types. 01341 01342 #endif 01343 static void DefaultMaxSpeed(double speed); 01344 static double DefaultMaxSpeed(); 01345 01346 Joules_t getBattery (void); 01347 void setBattery (Joules_t); 01348 01349 double getComputePower(void); 01350 void setComputePower(double); 01351 01352 // The following is for proxy routing 01353 private: 01354 IPAddr_t proxyIP; 01355 Mask proxyMask; 01356 01357 public: 01358 void SetProxyRoutingConfig(IPAddr_t ip, Mask mask); 01359 bool HasProxyRoutingConfig() {return proxyIP!=IPADDR_NONE;}; 01360 bool CanProxyRouteIP(IPAddr_t ip); 01361 IPAddr_t GetProxyIP(); 01362 Mask GetProxyMask(); 01363 int GetLongestPrefixLength(IPAddr_t ip); 01364 01365 public: 01366 01367 RouteTable* getRouteTable(void); 01368 void setRouteTable(RouteTable*); 01369 01370 }; 01371 01372 //#include "interface.h" 01373 01374 #endif
1.3.9.1