A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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"
33
#include "
global-router-interface.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
{
78
VertexUnknown
= 0,
79
VertexRouter
,
80
VertexNetwork
81
};
82
97
SPFVertex
();
98
115
SPFVertex
(
GlobalRoutingLSA
* lsa);
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
;
342
void
SetRootExitDirection
(
SPFVertex::NodeExit_t
exit);
351
NodeExit_t
GetRootExitDirection
(uint32_t i)
const
;
361
NodeExit_t
GetRootExitDirection
()
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
:
538
VertexType
m_vertexType
;
539
Ipv4Address
m_vertexId
;
540
GlobalRoutingLSA
*
m_lsa
;
541
uint32_t
m_distanceFromRoot
;
542
int32_t
m_rootOif
;
543
Ipv4Address
m_nextHop
;
544
typedef
std::list< NodeExit_t >
ListOfNodeExit_t
;
546
ListOfNodeExit_t
m_ecmpRootExits
;
547
typedef
std::list<SPFVertex*>
ListOfSPFVertex_t
;
548
ListOfSPFVertex_t
m_parents
;
549
ListOfSPFVertex_t
m_children
;
550
bool
m_vertexProcessed
;
551
556
SPFVertex
(
SPFVertex
& v);
557
562
SPFVertex
&
operator=
(
SPFVertex
& v);
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
582
class
GlobalRouteManagerLSDB
583
{
584
public
:
592
GlobalRouteManagerLSDB
();
593
602
~GlobalRouteManagerLSDB
();
603
618
void
Insert
(
Ipv4Address
addr,
GlobalRoutingLSA
* lsa);
619
635
GlobalRoutingLSA
*
GetLSA
(
Ipv4Address
addr)
const
;
649
GlobalRoutingLSA
*
GetLSAByLinkData
(
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
673
LSDBMap_t
m_database
;
674
std::vector<GlobalRoutingLSA*>
m_extdatabase
;
675
680
GlobalRouteManagerLSDB
(
GlobalRouteManagerLSDB
& lsdb);
681
686
GlobalRouteManagerLSDB
&
operator=
(
GlobalRouteManagerLSDB
& lsdb);
687
};
688
700
class
GlobalRouteManagerImpl
701
{
702
public
:
703
GlobalRouteManagerImpl
();
704
virtual
~GlobalRouteManagerImpl
();
714
virtual
void
DeleteGlobalRoutes
();
715
721
virtual
void
BuildGlobalRoutingDatabase
();
722
728
virtual
void
InitializeRoutes
();
729
734
void
DebugUseLsdb
(
GlobalRouteManagerLSDB
*);
735
740
void
DebugSPFCalculate
(
Ipv4Address
root);
741
742
private
:
748
GlobalRouteManagerImpl
(
GlobalRouteManagerImpl
& srmi);
749
755
GlobalRouteManagerImpl
&
operator=
(
GlobalRouteManagerImpl
& srmi);
756
757
SPFVertex
*
m_spfroot
;
758
GlobalRouteManagerLSDB
*
m_lsdb
;
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
&);
764
int
SPFNexthopCalculation
(
SPFVertex
* v,
SPFVertex
*
w
,
765
GlobalRoutingLinkRecord
* l, uint32_t distance);
766
void
SPFVertexAddParent
(
SPFVertex
* v);
767
GlobalRoutingLinkRecord
*
SPFGetNextLink
(
SPFVertex
* v,
SPFVertex
*
w
,
768
GlobalRoutingLinkRecord
* prev_link);
769
void
SPFIntraAddRouter
(
SPFVertex
* v);
770
void
SPFIntraAddTransit
(
SPFVertex
* v);
771
void
SPFIntraAddStub
(
GlobalRoutingLinkRecord
*l,
SPFVertex
* v);
772
void
SPFAddASExternal
(
GlobalRoutingLSA
*extlsa,
SPFVertex
*v);
773
int32_t
FindOutgoingInterfaceId
(
Ipv4Address
a,
774
Ipv4Mask
amask =
Ipv4Mask
(
"255.255.255.255"
));
775
};
776
777
}
// namespace ns3
778
779
#endif
/* GLOBAL_ROUTE_MANAGER_IMPL_H */
src
internet
model
global-route-manager-impl.h
Generated on Tue Nov 13 2012 10:32:14 for ns-3 by
1.8.1.2