A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
global-route-manager.cc
Go to the documentation of this file.
1
/*
2
* Copyright 2007 University of Washington
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Tom Henderson (tomhend@u.washington.edu)
7
*/
8
9
#include "
global-route-manager.h
"
10
11
#include "
global-route-manager-impl.h
"
12
13
#include "ns3/assert.h"
14
#include "ns3/log.h"
15
#include "ns3/simulation-singleton.h"
16
17
#include <iomanip>
18
19
namespace
ns3
20
{
21
22
NS_LOG_COMPONENT_DEFINE
(
"GlobalRouteManager"
);
23
24
// ---------------------------------------------------------------------------
25
//
26
// GlobalRouteManager Implementation
27
//
28
// ---------------------------------------------------------------------------
29
30
template
<
typename
T>
31
uint32_t
GlobalRouteManager<T>::routerId
= 0;
//!< Router ID counter
32
33
template
<
typename
T>
34
void
35
GlobalRouteManager<T>::DeleteGlobalRoutes
()
36
{
37
NS_LOG_FUNCTION_NOARGS
();
38
SimulationSingleton<GlobalRouteManagerImpl<typename GlobalRouteManager<T>::IpManager
>>::Get()
39
->DeleteGlobalRoutes();
40
}
41
42
template
<
typename
T>
43
void
44
GlobalRouteManager<T>::BuildGlobalRoutingDatabase
()
45
{
46
NS_LOG_FUNCTION_NOARGS
();
47
SimulationSingleton<GlobalRouteManagerImpl<typename GlobalRouteManager<T>::IpManager
>>::Get()
48
->BuildGlobalRoutingDatabase();
49
}
50
51
template
<
typename
T>
52
void
53
GlobalRouteManager<T>::InitializeRoutes
()
54
{
55
NS_LOG_FUNCTION_NOARGS
();
56
SimulationSingleton<GlobalRouteManagerImpl<typename GlobalRouteManager<T>::IpManager
>>::Get()
57
->InitializeRoutes();
58
}
59
60
template
<
typename
T>
61
uint32_t
62
GlobalRouteManager<T>::AllocateRouterId
()
63
{
64
NS_LOG_FUNCTION_NOARGS
();
65
return
routerId
++;
66
}
67
68
template
<
typename
T>
69
void
70
GlobalRouteManager<T>::ResetRouterId
()
71
{
72
routerId
= 0;
73
}
74
75
template
<
typename
T>
76
void
77
GlobalRouteManager<T>::PrintRoute
(
Ptr<Node>
sourceNode,
78
IpAddress
dest,
79
Ptr<OutputStreamWrapper>
stream,
80
bool
nodeIdLookup,
81
Time::Unit
unit)
82
{
83
std::ostream* os = stream->GetStream();
84
// Copy the current ostream state
85
std::ios oldState(
nullptr
);
86
oldState.copyfmt(*os);
87
88
*os << std::resetiosflags(std::ios::adjustfield) << std::setiosflags(std::ios::left);
89
*os <<
"PrintRoute at Time: "
<<
Now
().
As
(unit);
90
*os <<
" from Node "
<< sourceNode->GetId() <<
" to address "
<< dest;
91
SimulationSingleton<GlobalRouteManagerImpl<IpManager>
>::Get()->PrintRoute(sourceNode,
92
dest,
93
stream,
94
nodeIdLookup,
95
unit);
96
(*os).copyfmt(oldState);
97
}
98
99
template
<
typename
T>
100
void
101
GlobalRouteManager<T>::PrintRoute
(
Ptr<Node>
sourceNode,
102
IpAddress
dest,
103
bool
nodeIdLookup,
104
Time::Unit
unit)
105
{
106
Ptr<OutputStreamWrapper>
stream =
Create<OutputStreamWrapper>
(&std::cout);
107
GlobalRouteManager<T>::PrintRoute
(sourceNode, dest, stream, nodeIdLookup, unit);
108
}
109
110
template
<
typename
T>
111
void
112
GlobalRouteManager<T>::PrintRoute
(
Ptr<Node>
sourceNode,
113
Ptr<Node>
dest,
114
Ptr<OutputStreamWrapper>
stream,
115
bool
nodeIdLookup,
116
Time::Unit
unit)
117
{
118
std::ostream* os = stream->GetStream();
119
// Copy the current ostream state
120
std::ios oldState(
nullptr
);
121
oldState.copyfmt(*os);
122
123
*os << std::resetiosflags(std::ios::adjustfield) << std::setiosflags(std::ios::left);
124
*os <<
"PrintRoute at Time: "
<<
Now
().
As
(unit);
125
*os <<
" from Node "
<< sourceNode->GetId() <<
" to Node "
<< dest->GetId();
126
SimulationSingleton<GlobalRouteManagerImpl<IpManager>
>::Get()->PrintRoute(sourceNode,
127
dest,
128
stream,
129
nodeIdLookup,
130
unit);
131
(*os).copyfmt(oldState);
132
}
133
134
template
<
typename
T>
135
void
136
GlobalRouteManager<T>::PrintRoute
(
Ptr<Node>
sourceNode,
137
Ptr<Node>
dest,
138
bool
nodeIdLookup,
139
Time::Unit
unit)
140
{
141
Ptr<OutputStreamWrapper>
stream =
Create<OutputStreamWrapper>
(&std::cout);
142
GlobalRouteManager<T>::PrintRoute
(sourceNode, dest, stream, nodeIdLookup, unit);
143
}
144
145
template
<
typename
T>
146
void
147
GlobalRouteManager<T>::InitializeRouters
()
148
{
149
SimulationSingleton<GlobalRouteManagerImpl<typename GlobalRouteManager<T>::IpManager
>>::Get()
150
->InitializeRouters();
151
}
152
153
template
class
ns3::GlobalRouteManager<ns3::Ipv4Manager>
;
154
template
class
ns3::GlobalRouteManager<ns3::Ipv6Manager>
;
155
156
}
// namespace ns3
ns3::GlobalRouteManager
A global global router.
Definition
global-route-manager.h:53
ns3::GlobalRouteManager::IpAddress
typename std::conditional_t< IsIpv4, Ipv4Address, Ipv6Address > IpAddress
Alias for Ipv4Address and Ipv6Address classes.
Definition
global-route-manager.h:63
ns3::GlobalRouteManager::ResetRouterId
static void ResetRouterId()
Reset the router ID counter to zero.
Definition
global-route-manager.cc:70
ns3::GlobalRouteManager::BuildGlobalRoutingDatabase
static void BuildGlobalRoutingDatabase()
Build the routing database by gathering Link State Advertisements from each node exporting a GlobalRo...
Definition
global-route-manager.cc:44
ns3::GlobalRouteManager::PrintRoute
static void PrintRoute(Ptr< Node > sourceNode, IpAddress dest, Ptr< OutputStreamWrapper > stream, bool nodeIdLookup=true, Time::Unit unit=Time::S)
prints the path from this node to the destination node at a particular time.
Definition
global-route-manager.cc:77
ns3::GlobalRouteManager::InitializeRoutes
static void InitializeRoutes()
Compute routes using a Dijkstra SPF computation and populate per-node forwarding tables.
Definition
global-route-manager.cc:53
ns3::GlobalRouteManager::DeleteGlobalRoutes
static void DeleteGlobalRoutes()
Delete all static routes on all nodes that have a GlobalRouterInterface.
Definition
global-route-manager.cc:35
ns3::GlobalRouteManager::routerId
static uint32_t routerId
Router ID counter.
Definition
global-route-manager.h:168
ns3::GlobalRouteManager::AllocateRouterId
static uint32_t AllocateRouterId()
Allocate a 32-bit router ID from monotonically increasing counter.
Definition
global-route-manager.cc:62
ns3::GlobalRouteManager::InitializeRouters
static void InitializeRouters()
initialize all nodes as routers.
Definition
global-route-manager.cc:147
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:70
ns3::SimulationSingleton
This singleton class template ensures that the type for which we want a singleton has a lifetime boun...
Definition
simulation-singleton.h:33
ns3::Time::As
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition
time.cc:408
ns3::Time::Unit
Unit
The unit to use to interpret a number representing time.
Definition
nstime.h:101
uint32_t
global-route-manager-impl.h
global-route-manager.h
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:194
NS_LOG_FUNCTION_NOARGS
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition
log-macros-enabled.h:195
ns3::Create
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition
ptr.h:454
ns3::Now
Time Now()
create an ns3::Time instance which contains the current simulation time.
Definition
simulator.cc:288
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
internet
model
global-route-manager.cc
Generated on
for ns-3 by
1.15.0