A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
global-route-manager-impl.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright 2007 University of Washington
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Authors: Craig Dowell (craigdo@ee.washington.edu)
19  * Tom Henderson (tomhend@u.washington.edu)
20  */
21 
22 #ifndef GLOBAL_ROUTE_MANAGER_IMPL_H
23 #define GLOBAL_ROUTE_MANAGER_IMPL_H
24 
25 #include <stdint.h>
26 #include <list>
27 #include <queue>
28 #include <map>
29 #include <vector>
30 #include "ns3/object.h"
31 #include "ns3/ptr.h"
32 #include "ns3/ipv4-address.h"
34 
35 namespace ns3 {
36 
37 const uint32_t SPF_INFINITY = 0xffffffff;
38 
39 class CandidateQueue;
40 class Ipv4GlobalRouting;
41 
66 class SPFVertex
67 {
68 public:
77  enum VertexType {
81  };
82 
97  SPFVertex();
98 
116 
125  ~SPFVertex();
126 
137  VertexType GetVertexType (void) const;
138 
149  void SetVertexType (VertexType type);
150 
165  Ipv4Address GetVertexId (void) const;
166 
182  void SetVertexId (Ipv4Address id);
183 
196  GlobalRoutingLSA* GetLSA (void) const;
197 
212  void SetLSA (GlobalRoutingLSA* lsa);
213 
235  uint32_t GetDistanceFromRoot (void) const;
236 
256  void SetDistanceFromRoot (uint32_t distance);
257 
300  void SetRootExitDirection (Ipv4Address nextHop, int32_t id = SPF_INFINITY);
301  typedef std::pair<Ipv4Address, int32_t> NodeExit_t;
351  NodeExit_t GetRootExitDirection (uint32_t i) const;
371  void MergeRootExitDirections (const SPFVertex* vertex);
379  void InheritAllRootExitDirections (const SPFVertex* vertex);
384  uint32_t GetNRootExitDirections () const;
385 
406  SPFVertex* GetParent (uint32_t i = 0) const;
407 
427  void SetParent (SPFVertex* parent);
435  void MergeParent (const SPFVertex* v);
436 
457  uint32_t GetNChildren (void) const;
458 
486  SPFVertex* GetChild (uint32_t n) const;
487 
515  uint32_t AddChild (SPFVertex* child);
516 
524  void SetVertexProcessed (bool value);
525 
533  bool IsVertexProcessed (void) const;
534 
535  void ClearVertexProcessed (void);
536 
537 private:
542  int32_t m_rootOif;
544  typedef std::list< NodeExit_t > ListOfNodeExit_t;
547  typedef std::list<SPFVertex*> ListOfSPFVertex_t;
551 
556  SPFVertex (SPFVertex& v);
557 
563 
564  //friend std::ostream& operator<< (std::ostream& os, const ListOfIf_t& ifs);
565  //friend std::ostream& operator<< (std::ostream& os, const ListOfAddr_t& addrs);
566  friend std::ostream& operator<< (std::ostream& os, const SPFVertex::ListOfSPFVertex_t& vs);
567 };
568 
583 {
584 public:
593 
603 
618  void Insert (Ipv4Address addr, GlobalRoutingLSA* lsa);
619 
635  GlobalRoutingLSA* GetLSA (Ipv4Address addr) const;
650 
663  void Initialize ();
664 
665  GlobalRoutingLSA* GetExtLSA (uint32_t index) const;
666  uint32_t GetNumExtLSAs () const;
667 
668 
669 private:
670  typedef std::map<Ipv4Address, GlobalRoutingLSA*> LSDBMap_t;
671  typedef std::pair<Ipv4Address, GlobalRoutingLSA*> LSDBPair_t;
672 
674  std::vector<GlobalRoutingLSA*> m_extdatabase;
675 
681 
687 };
688 
701 {
702 public:
704  virtual ~GlobalRouteManagerImpl ();
714  virtual void DeleteGlobalRoutes ();
715 
721  virtual void BuildGlobalRoutingDatabase ();
722 
728  virtual void InitializeRoutes ();
729 
735 
740  void DebugSPFCalculate (Ipv4Address root);
741 
742 private:
749 
756 
759  bool CheckForStubNode (Ipv4Address root);
760  void SPFCalculate (Ipv4Address root);
761  void SPFProcessStubs (SPFVertex* v);
762  void ProcessASExternals (SPFVertex* v, GlobalRoutingLSA* extlsa);
763  void SPFNext (SPFVertex*, CandidateQueue&);
765  GlobalRoutingLinkRecord* l, uint32_t distance);
766  void SPFVertexAddParent (SPFVertex* v);
768  GlobalRoutingLinkRecord* prev_link);
769  void SPFIntraAddRouter (SPFVertex* v);
770  void SPFIntraAddTransit (SPFVertex* v);
772  void SPFAddASExternal (GlobalRoutingLSA *extlsa, SPFVertex *v);
774  Ipv4Mask amask = Ipv4Mask ("255.255.255.255"));
775 };
776 
777 } // namespace ns3
778 
779 #endif /* GLOBAL_ROUTE_MANAGER_IMPL_H */