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
31
32void
38
39void
45
46void
52
59
60void
65
66void
68 Ipv4Address dest,
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;
82 dest,
83 stream,
84 nodeIdLookup,
85 unit);
86 (*os).copyfmt(oldState);
87}
88
89void
91 Ipv4Address dest,
92 bool nodeIdLookup,
93 Time::Unit unit)
94{
96 GlobalRouteManager::PrintRoute(sourceNode, dest, stream, nodeIdLookup, unit);
97}
98
99void
101 Ptr<Node> dest,
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();
115 dest,
116 stream,
117 nodeIdLookup,
118 unit);
119 (*os).copyfmt(oldState);
120}
121
122void
124 Ptr<Node> dest,
125 bool nodeIdLookup,
126 Time::Unit unit)
127{
129 GlobalRouteManager::PrintRoute(sourceNode, dest, stream, nodeIdLookup, unit);
130}
131
132} // namespace ns3
static void DeleteGlobalRoutes()
Delete all static routes on all nodes that have a GlobalRouterInterface.
static uint32_t routerId
Router ID counter.
static void ResetRouterId()
Reset the router ID counter to zero.
static uint32_t AllocateRouterId()
Allocate a 32-bit router ID from monotonically increasing counter.
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.
static void InitializeRoutes()
Compute routes using a Dijkstra SPF computation and populate per-node forwarding tables.
static void BuildGlobalRoutingDatabase()
Build the routing database by gathering Link State Advertisements from each node exporting a GlobalRo...
Ipv4 addresses are stored in host order in this class.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
static T * Get()
Get a pointer to the singleton instance.
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:102
#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.