A Discrete-Event Network Simulator
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
10
12
13#include "ns3/assert.h"
14#include "ns3/log.h"
15#include "ns3/simulation-singleton.h"
16
17#include <iomanip>
18
19namespace ns3
20{
21
22NS_LOG_COMPONENT_DEFINE("GlobalRouteManager");
23
24// ---------------------------------------------------------------------------
25//
26// GlobalRouteManager Implementation
27//
28// ---------------------------------------------------------------------------
29
30template <typename T>
31uint32_t GlobalRouteManager<T>::routerId = 0; //!< Router ID counter
32
33template <typename T>
34void
41
42template <typename T>
43void
50
51template <typename T>
52void
59
60template <typename T>
67
68template <typename T>
69void
74
75template <typename T>
76void
78 IpAddress dest,
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
99template <typename T>
100void
102 IpAddress dest,
103 bool nodeIdLookup,
104 Time::Unit unit)
105{
107 GlobalRouteManager<T>::PrintRoute(sourceNode, dest, stream, nodeIdLookup, unit);
108}
109
110template <typename T>
111void
113 Ptr<Node> dest,
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
134template <typename T>
135void
137 Ptr<Node> dest,
138 bool nodeIdLookup,
139 Time::Unit unit)
140{
142 GlobalRouteManager<T>::PrintRoute(sourceNode, dest, stream, nodeIdLookup, unit);
143}
144
145template <typename T>
146void
152
155
156} // namespace ns3
A global global router.
typename std::conditional_t< IsIpv4, Ipv4Address, Ipv6Address > IpAddress
Alias for Ipv4Address and Ipv6Address classes.
static void ResetRouterId()
Reset the router ID counter to zero.
static void BuildGlobalRoutingDatabase()
Build the routing database by gathering Link State Advertisements from each node exporting a GlobalRo...
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.
static void InitializeRoutes()
Compute routes using a Dijkstra SPF computation and populate per-node forwarding tables.
static void DeleteGlobalRoutes()
Delete all static routes on all nodes that have a GlobalRouterInterface.
static uint32_t routerId
Router ID counter.
static uint32_t AllocateRouterId()
Allocate a 32-bit router ID from monotonically increasing counter.
static void InitializeRouters()
initialize all nodes as routers.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
This singleton class template ensures that the type for which we want a singleton has a lifetime boun...
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
Unit
The unit to use to interpret a number representing time.
Definition nstime.h:101
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:194
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:454
Time Now()
create an ns3::Time instance which contains the current simulation time.
Definition simulator.cc:288
Every class exported by the ns3 library is enclosed in the ns3 namespace.