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: interface-real.h 446 2005-11-15 20:48:03Z riley $ 00142 00143 00144 00145 // Georgia Tech Network Simulator - Interface class 00146 // George F. Riley. Georgia Tech, Spring 2002 00147 00148 // Define class to model network link interfaces 00149 // Implements the Layer 2 protocols 00150 00151 #ifndef __interface_real_h__ 00152 #define __interface_real_h__ 00153 00154 #include "common-defs.h" 00155 #include "simulator.h" 00156 #include "protocol.h" 00157 #include "packet.h" 00158 #include "handler.h" 00159 #include "ipaddr.h" 00160 #include "notifier.h" 00161 #include "macaddr.h" 00162 #include "node.h" 00163 #include "link.h" 00164 #include "link-real.h" 00165 #include "eventcq.h" 00166 #include "interface.h" 00167 #include "arp.h" 00168 #include "worm-containment.h" 00169 00170 class L2Proto; 00171 class Node; 00172 class Queue; 00173 class LinkEvent; 00174 class NotifyHandler; 00175 00176 #define CLASS_C_MASK 0xffffff00 00177 #define CLASS_B_MASK 0xffff0000 00178 #define CLASS_A_MASK 0xff000000 00179 #define MASK_NONE 0x00000000 00180 00181 //Doc:ClassXRef 00182 class IpMaskCount { // IP Address, mask, and hop count 00183 public: 00184 IpMaskCount(IPAddr_t i, Mask_t m, Count_t c = 0) 00185 : ip(i), mask(m), hopCount(c) { } 00186 public: 00187 IPAddr_t ip; 00188 Mask_t mask; 00189 Count_t hopCount; 00190 }; 00191 00192 typedef std::vector<IpMaskCount> IPMaskCountVec_t; 00193 00194 //Doc:ClassXRef 00195 class InterfaceReal : public Interface 00196 { 00197 //Doc:Class Interface objects are assigned to nodes, and have 00198 //Doc:Class corresponding link objects to represent the communications 00199 //Doc:Class links. Interfaces also have queues for queuing packets 00200 //Doc:Class when a transmit is requested when the link is busy, 00201 //Doc:Class and an associated layer 2 protocol objects 00202 //Doc:Class Interfaces are typically not allocated directly by 00203 //Doc:Class a \GTNS\ simulation program, but rather are created 00204 //Doc:Class indirectly by {\tt AddDuplexLink} and {\tt AddSimplexLink} 00205 //Doc:Class methods of {\tt Node} objects. 00206 00207 public: 00208 //Doc:Method 00209 InterfaceReal(const L2Proto& l2 = L2Proto802_3(), 00210 IPAddr_t i = IPADDR_NONE, 00211 Mask_t m = MASK_ALL, 00212 MACAddr mac = MACAddr::NONE, 00213 bool bootstrap = false); 00214 //Doc:Desc Constructs a new real interface object. 00215 //Doc:Arg1 The layer 2 protocol type to associate with this interface. 00216 //Doc:Arg2 The \IPA\ to assign to this interface. 00217 //Doc:Arg3 The address mask to assign to this interface. 00218 //Doc:Arg4 The {\tt MAC} address to assign to this interface. 00219 00220 virtual ~InterfaceReal(); 00221 00222 void SetARPTimeout(Time_t t){ arptimeout = t;} 00223 00224 00225 //Doc:Method 00226 bool Send(Packet*, IPAddr_t, int); // Enque and transmit 00227 //Doc:Desc Send a packet on this interface. 00228 //Doc:Arg1 Packet to send. 00229 //Doc:Arg2 \IPA\ of destination 00230 //Doc:Arg3 LLC/SNAP type 00231 //Doc:Return True if packet sent or enqued, false if dropped. 00232 00233 //Doc:Method 00234 bool Xmit(Packet*, IPAddr_t, int); // Enque and transmit 00235 //Doc:Desc Send a packet on this interface. 00236 //Doc:Arg1 Packet to send. 00237 //Doc:Arg2 \IPA\ of destination 00238 //Doc:Arg3 LLC/SNAP type 00239 //Doc:Return True if packet sent or enqued, false if dropped. 00240 00241 //Doc:Method 00242 bool Send(Packet*, const MACAddr&, int); // Enque and transmit 00243 //Doc:Desc Send a packet on this interface. 00244 //Doc:Arg1 Packet to send. 00245 //Doc:Arg2 MAC address of destination 00246 //Doc:Arg3 LLC/SNAP type 00247 //Doc:Return True if packet sent or enqued, false if dropped. 00248 00249 //Doc:Method 00250 bool Send(Packet*, Word_t); // Enque and transmit 00251 //Doc:Desc Send a broadcast packet on this interface. 00252 //Doc:Arg1 Packet to send. 00253 //Doc:Arg2 MAC address of destination 00254 //Doc:Arg3 LLC/SNAP type 00255 //Doc:Return True if packet sent or enqued, false if dropped. 00256 00257 //Doc:Method 00258 bool EnquePacket(Packet*); 00259 //Doc:Desc Enque this packet for later transmission 00260 //Doc:Return True if successfully enqueued, false if dropped. 00261 00262 // Handler 00263 virtual void Handle(Event*, Time_t); 00264 // Notifier 00265 virtual void Notify(void*); 00266 00267 // Interface Methods 00268 //Doc:Method 00269 Count_t PeerCount() const; // Number of peers 00270 //Doc:Desc Determine how many peer nodes are associated with this 00271 //Doc:Desc interface. 00272 //Doc:Return Count of peers. 00273 00274 //Doc:Method 00275 IPAddr PeerIP(int npeer) const; // Get peer IP addr if known 00276 //Doc:Desc Get the \IPA\ of the specified peer, by peer index. 00277 //Doc:Arg1 The peer index of the desired peer. 00278 //Doc:Return The \IPA\ of the specified peer. 00279 //Doc:Return Returns {\tt IPADDR_NONE} if the peer does not exist. 00280 00281 //Doc:Method 00282 IPAddr NodePeerIP(Node*) const; // Get peer IP addr if known 00283 //Doc:Desc Get the \IPA\ of the peer's interface directly connected 00284 //Doc:Desc to this interface. 00285 //Doc:Arg1 Node pointer for the desired peer. 00286 //Doc:Return \IPA\ of the specified peer. 00287 //Doc:Return Returns {\tt IPADDR_NONE} if the peer does not exist. 00288 00289 //Doc:Method 00290 bool NodeIsPeer(Node*) const; // Find out if node is a peer 00291 //Doc:Desc Determine if the specified node is a directly connected 00292 //Doc:Desc peer on this interface. 00293 //Doc:Arg1 Node pointer of the desired peer. 00294 //Doc:Return True if the node is a directly connected peer on this 00295 //Doc:Return interface. 00296 00297 //Doc:Method 00298 Count_t NodePeerIndex(Node*) const; // Get peer index for node 00299 //Doc:Desc Get the peer index for the specified node. 00300 //Doc:Arg1 Node pointer for the desired peer. 00301 //Doc:Return The peer index of the specified node. 00302 00303 //Doc:Method 00304 void SetNode(Node*); 00305 //Doc:Desc Set the node pointer to which this interface is associated. 00306 //Doc:Arg1 Pointer to the node this interface is associated with. 00307 00308 #ifdef MOVED_TO_BASIC 00309 //Doc:Method 00310 Link* GetLink() const; // Return the link pointer 00311 //Doc:Desc Get the link object associated with this interface. 00312 //Doc:Return A pointer to the associated link object. 00313 00314 //Doc:Method 00315 void SetLink(Link*); 00316 //Doc:Desc Set the associated link to the specified link pointer. 00317 //Doc:Arg1 Link pointer to set. 00318 #endif 00319 00320 //Doc:Method 00321 Queue* GetQueue() const; // Return the queue pointer 00322 //Doc:Desc Get the packet queue associated with this interface. 00323 //Doc:Return A pointer to the associated packet queue. 00324 00325 //Doc:Method 00326 void SetQueue(const Queue& q); // Set a new queue object 00327 //Doc:Desc Set a new packet queue object. 00328 //Doc:Arg1 The type of packet queue object to use. This object 00329 //Doc:Arg1 is copied to this interface, so an anonymous temporary 00330 //Doc:Arg1 object can be used, or the same object can be passed 00331 //Doc:Arg1 to multiple interfaces. 00332 00333 bool QueueDetailed() const; // True if queue is detailed 00334 00335 //Doc:Method 00336 L2Proto* GetL2Proto() const { return pL2Proto;} // Layer 2 proto object 00337 //Doc:Desc Get the layer 2 protocol object associated with this interface. 00338 //Doc:Return A pointer to the layer 2 protocol object associated with this 00339 //Doc:Return interface. 00340 00341 //Doc:Method 00342 void SetL2Proto(const L2Proto& l2); 00343 //Doc:Desc Set a new layer 2 protocol object for this interface. 00344 //Doc:Return The new layer 2 protocol object to use. 00345 00346 //Doc:Method 00347 void AddNotify(NotifyHandler*,void*); // Add a notify client 00348 //Doc:Desc Add a notification client. The client is notified when 00349 //Doc:Desc the associated link is free. 00350 //Doc:Arg1 A pointer to the notify client. 00351 //Doc:Arg2 A blind pointer to pass back to the notify client. 00352 00353 //Doc:Method 00354 void CancelNotify(NotifyHandler*); // Cancel pending notif. 00355 //Doc:Desc Cancel an existing notification request. 00356 //Doc:Arg1 A pointer to the notifi client to cancel. 00357 00358 //Doc:Method 00359 MACAddr IPToMac(IPAddr_t) const; // Return mac addr for ip 00360 //Doc:Desc Determine the {\em MAC} address of the interface 00361 //Doc:Desc associated with a peer, specified by \IPA. 00362 //Doc:Arg1 The \IPA\ to search for. 00363 //Doc:Return The {\em MAC} address of the remote interface associated 00364 //Doc:Return with the specified \IPA. 00365 00366 //Doc:Method 00367 Count_t NeighborCount(Node*) const; // Number of rtg neighbors 00368 //Doc:Desc Get the count of directly connected neighbors on this interface. 00369 //Doc:Arg1 Node querying neighbors (significant for Ethernet links) 00370 //Doc:Return Count of directly connect neighbors. 00371 00372 // Get neighbor list 00373 //Doc:Method 00374 void Neighbors(NodeWeightVec_t&, bool forceAll = false); 00375 //Doc:Desc Get a list of directly connected neighbors on this interface. 00376 //Doc:Arg1 An output parameter, with a vector of nodes and associated 00377 //Doc:Arg1 link weights directly connected on this link. 00378 //Doc:Arg2 ForceAll indicates that all neighbors should be reported. 00379 //Doc:Arg2 Some link types (ie. {\tt Ethernet} sometimes report 00380 //Doc:Arg2 zero neighbors, for efficiency in route computations. 00381 00382 //Doc:Method 00383 IPAddr_t DefaultPeer(); // Get default peer from link 00384 //Doc:Desc Get the \IPA\ of the default peer. 00385 //Doc:Return The \IPA\ of the default peer. 00386 00387 //Doc:Method 00388 bool IsLocalIP(IPAddr_t) const; // True if IP is on this i/f 00389 //Doc:Desc Determine if the specified \IPA\ is a node directly connected 00390 //Doc:Desc to this interface. 00391 //Doc:Arg1 \IPA\ to check. 00392 //Doc:Return True if directly connected \IPA, false if not. 00393 00394 //Doc:Method 00395 Mult_t TrafficIntensity() const; // TotBytesSent/LineSpeed 00396 //Doc:Desc Return the traffic intensity on this interface. Calculated 00397 //Doc:Desc as the total bytes sent per second divided by the link 00398 //Doc:Desc bandwidth. 00399 //Doc:Return The traffic intensity for this interface. 00400 00401 // Used by distributed simulation 00402 //Doc:Method 00403 void AddRemoteIP(IPAddr_t, Mask_t, Count_t = 0);// Add to rmt IP list 00404 //Doc:Desc Add an \IPA\ and mask to the list of the \IPA{s} that 00405 //Doc:Desc can be reached via the remote link associated with this 00406 //Doc:Desc interface. 00407 //Doc:Desc Useful only for distributed simulations. 00408 //Doc:Arg1 The \IPA\ to add. 00409 //Doc:Arg2 The address mask to add. 00410 //Doc:Arg3 Hop count to the destination set 00411 00412 //Doc:Method 00413 void HandleLLCSNAP(Packet*, bool); 00414 //Doc:Desc Process the LLCSnap header on a wireless packet. 00415 //Doc:Arg1 Pointer with packet with LLCSnap header to process. 00416 //Doc:Arg2 True if "First bit RX" event 00417 //Doc:Method 00418 virtual bool IsWireless() const { return false;}// True if wireless interface 00419 //Doc:Desc Test if this interface is wireless 00420 //Doc:Return Always false for InterfaceReal nodes 00421 00422 //Doc:Method 00423 virtual bool IsReal() const { return true;} // True if wireless interface 00424 //Doc:Desc Test if this interface is real 00425 //Doc:Return Always true for InterfaceReal interfaces 00426 00427 virtual bool IsEthernet() const {return false;} // True if ethernet interface 00428 00429 void SetWormContainment(WormContainment*); 00430 WormContainment* GetWormContainment() { return wormcontainment;} 00431 00432 void UseARP(bool); // use the ARP protocol 00433 00434 protected: 00435 // PacketRxStart is called by the event handler for the real interface 00436 // before calling the l2 data indication. This 00437 // which allows the wired and wireless interface implementations 00438 // to react differently. 00439 virtual void PacketRxStart(LinkEvent*); 00440 // PacketRxDone is called by the event handler for the real interface 00441 // after calling the l2 data indication. 00442 virtual void PacketRxEnd(bool, Size_t); 00443 00444 // Make all data items private, since we need to access via 00445 // methods, to facilitate real/ghost interface implementation 00446 00447 private: 00448 //Link* pLink; // Associated link (moved to basic) 00449 Queue* pQueue; // Associated Queue 00450 NList_t notifications; // Deque of pending notifications 00451 LinkEvent* notifEvent; // Pending notification event 00452 DCount_t totBytesSent; // Track total bytes requested to send 00453 L2Proto* pL2Proto; // Associated layer 2 protocol 00454 IPAddr_t defaultPeer; // Used to cache defaultPeer IPAddr 00455 bool usearp; // use ARP protocol 00456 ARP* arpmodule; // The ARP module 00457 Time_t arptimeout; // timeout for the arp entries 00458 WormContainment* wormcontainment; // The worm containment module 00459 00460 private: 00461 // The following is for the distibuted version. List IP addresses 00462 // (with masks) that are reached via this interface. The Ghost Node 00463 // approach (when implemented) will obviate the need for this 00464 IPMaskCountVec_t remoteIPList;// List if remote IP/Masks reached via this i/f 00465 private: 00466 void CallNotification(bool); // Notify l4 proto of free buffer space 00467 public: 00468 static Count_t count; // debug 00469 }; 00470 00471 #endif
1.3.9.1