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
uint32_t
GlobalRouteManager::routerId
= 0;
31
32
void
33
GlobalRouteManager::DeleteGlobalRoutes
()
34
{
35
NS_LOG_FUNCTION_NOARGS
();
36
SimulationSingleton<GlobalRouteManagerImpl>::Get
()->DeleteGlobalRoutes();
37
}
38
39
void
40
GlobalRouteManager::BuildGlobalRoutingDatabase
()
41
{
42
NS_LOG_FUNCTION_NOARGS
();
43
SimulationSingleton<GlobalRouteManagerImpl>::Get
()->BuildGlobalRoutingDatabase();
44
}
45
46
void
47
GlobalRouteManager::InitializeRoutes
()
48
{
49
NS_LOG_FUNCTION_NOARGS
();
50
SimulationSingleton<GlobalRouteManagerImpl>::Get
()->InitializeRoutes();
51
}
52
53
uint32_t
54
GlobalRouteManager::AllocateRouterId
()
55
{
56
NS_LOG_FUNCTION_NOARGS
();
57
return
routerId
++;
58
}
59
60
void
61
GlobalRouteManager::ResetRouterId
()
62
{
63
routerId
= 0;
64
}
65
66
void
67
GlobalRouteManager::PrintRoute
(
Ptr<Node>
sourceNode,
68
Ipv4Address
dest,
69
Ptr<OutputStreamWrapper>
stream,
70
bool
nodeIdLookup,
71
Time::Unit
unit)
72
{
73
std::ostream* os = stream->GetStream();
74
// Copy the current ostream state
75
std::ios oldState(
nullptr
);
76
oldState.copyfmt(*os);
77
78
*os << std::resetiosflags(std::ios::adjustfield) << std::setiosflags(std::ios::left);
79
*os <<
"PrintRoute at Time: "
<<
Now
().
As
(unit);
80
*os <<
" from Node "
<< sourceNode->GetId() <<
" to address "
<< dest;
81
SimulationSingleton<GlobalRouteManagerImpl>::Get
()->PrintRoute(sourceNode,
82
dest,
83
stream,
84
nodeIdLookup,
85
unit);
86
(*os).copyfmt(oldState);
87
}
88
89
void
90
GlobalRouteManager::PrintRoute
(
Ptr<Node>
sourceNode,
91
Ipv4Address
dest,
92
bool
nodeIdLookup,
93
Time::Unit
unit)
94
{
95
Ptr<OutputStreamWrapper>
stream =
Create<OutputStreamWrapper>
(&std::cout);
96
GlobalRouteManager::PrintRoute
(sourceNode, dest, stream, nodeIdLookup, unit);
97
}
98
99
void
100
GlobalRouteManager::PrintRoute
(
Ptr<Node>
sourceNode,
101
Ptr<Node>
dest,
102
Ptr<OutputStreamWrapper>
stream,
103
bool
nodeIdLookup,
104
Time::Unit
unit)
105
{
106
std::ostream* os = stream->GetStream();
107
// Copy the current ostream state
108
std::ios oldState(
nullptr
);
109
oldState.copyfmt(*os);
110
111
*os << std::resetiosflags(std::ios::adjustfield) << std::setiosflags(std::ios::left);
112
*os <<
"PrintRoute at Time: "
<<
Now
().
As
(unit);
113
*os <<
" from Node "
<< sourceNode->GetId() <<
" to Node "
<< dest->GetId();
114
SimulationSingleton<GlobalRouteManagerImpl>::Get
()->PrintRoute(sourceNode,
115
dest,
116
stream,
117
nodeIdLookup,
118
unit);
119
(*os).copyfmt(oldState);
120
}
121
122
void
123
GlobalRouteManager::PrintRoute
(
Ptr<Node>
sourceNode,
124
Ptr<Node>
dest,
125
bool
nodeIdLookup,
126
Time::Unit
unit)
127
{
128
Ptr<OutputStreamWrapper>
stream =
Create<OutputStreamWrapper>
(&std::cout);
129
GlobalRouteManager::PrintRoute
(sourceNode, dest, stream, nodeIdLookup, unit);
130
}
131
132
}
// namespace ns3
ns3::GlobalRouteManager::DeleteGlobalRoutes
static void DeleteGlobalRoutes()
Delete all static routes on all nodes that have a GlobalRouterInterface.
Definition
global-route-manager.cc:33
ns3::GlobalRouteManager::routerId
static uint32_t routerId
Router ID counter.
Definition
global-route-manager.h:129
ns3::GlobalRouteManager::ResetRouterId
static void ResetRouterId()
Reset the router ID counter to zero.
Definition
global-route-manager.cc:61
ns3::GlobalRouteManager::AllocateRouterId
static uint32_t AllocateRouterId()
Allocate a 32-bit router ID from monotonically increasing counter.
Definition
global-route-manager.cc:54
ns3::GlobalRouteManager::PrintRoute
static void PrintRoute(Ptr< Node > sourceNode, Ipv4Address 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:67
ns3::GlobalRouteManager::InitializeRoutes
static void InitializeRoutes()
Compute routes using a Dijkstra SPF computation and populate per-node forwarding tables.
Definition
global-route-manager.cc:47
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:40
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition
ipv4-address.h:33
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:70
ns3::SimulationSingleton::Get
static T * Get()
Get a pointer to the singleton instance.
Definition
simulation-singleton.h:79
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:102
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