A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv6-routing-helper.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8
10
11#include "ns3/ipv6-interface.h"
12#include "ns3/ipv6-l3-protocol.h"
13#include "ns3/ipv6-list-routing.h"
14#include "ns3/ipv6-routing-protocol.h"
15#include "ns3/names.h"
16#include "ns3/ndisc-cache.h"
17#include "ns3/node-list.h"
18#include "ns3/node.h"
19#include "ns3/simulator.h"
20
21namespace ns3
22{
23
27
28void
31 Time::Unit unit)
32{
33 for (uint32_t i = 0; i < NodeList::GetNNodes(); i++)
34 {
36 Simulator::Schedule(printTime, &Ipv6RoutingHelper::Print, node, stream, unit);
37 }
38}
39
40void
43 Time::Unit unit)
44{
45 for (uint32_t i = 0; i < NodeList::GetNNodes(); i++)
46 {
48 Simulator::Schedule(printInterval,
50 printInterval,
51 node,
52 stream,
53 unit);
54 }
55}
56
57void
59 Ptr<Node> node,
61 Time::Unit unit)
62{
63 Simulator::Schedule(printTime, &Ipv6RoutingHelper::Print, node, stream, unit);
64}
65
66void
68 Ptr<Node> node,
70 Time::Unit unit)
71{
72 Simulator::Schedule(printInterval,
74 printInterval,
75 node,
76 stream,
77 unit);
78}
79
80void
82{
83 Ptr<Ipv6> ipv6 = node->GetObject<Ipv6>();
84 if (ipv6)
85 {
86 Ptr<Ipv6RoutingProtocol> rp = ipv6->GetRoutingProtocol();
87 NS_ASSERT(rp);
88 rp->PrintRoutingTable(stream, unit);
89 }
90}
91
92void
94 Ptr<Node> node,
96 Time::Unit unit)
97{
98 Ptr<Ipv6> ipv6 = node->GetObject<Ipv6>();
99 if (ipv6)
100 {
101 Ptr<Ipv6RoutingProtocol> rp = ipv6->GetRoutingProtocol();
102 NS_ASSERT(rp);
103 rp->PrintRoutingTable(stream, unit);
104 Simulator::Schedule(printInterval,
106 printInterval,
107 node,
108 stream,
109 unit);
110 }
111}
112
113void
116 Time::Unit unit /* = Time::S */)
117{
118 for (uint32_t i = 0; i < NodeList::GetNNodes(); i++)
119 {
121 Simulator::Schedule(printTime, &Ipv6RoutingHelper::PrintNdiscCache, node, stream, unit);
122 }
123}
124
125void
128 Time::Unit unit /* = Time::S */)
129{
130 for (uint32_t i = 0; i < NodeList::GetNNodes(); i++)
131 {
133 Simulator::Schedule(printInterval,
135 printInterval,
136 node,
137 stream,
138 unit);
139 }
140}
141
142void
144 Ptr<Node> node,
146 Time::Unit unit /* = Time::S */)
147{
148 Simulator::Schedule(printTime, &Ipv6RoutingHelper::PrintNdiscCache, node, stream, unit);
149}
150
151void
153 Ptr<Node> node,
155 Time::Unit unit /* = Time::S */)
156{
157 Simulator::Schedule(printInterval,
159 printInterval,
160 node,
161 stream,
162 unit);
163}
164
165void
168 Time::Unit unit /* = Time::S */)
169{
170 Ptr<Ipv6L3Protocol> ipv6 = node->GetObject<Ipv6L3Protocol>();
171 if (ipv6)
172 {
173 std::ostream* os = stream->GetStream();
174
175 *os << "NDISC Cache of node ";
176 std::string found = Names::FindName(node);
177 if (!Names::FindName(node).empty())
178 {
179 *os << found;
180 }
181 else
182 {
183 *os << static_cast<int>(node->GetId());
184 }
185 *os << " at time " << Simulator::Now().As(unit) << "\n";
186
187 for (uint32_t i = 0; i < ipv6->GetNInterfaces(); i++)
188 {
189 Ptr<NdiscCache> ndiscCache = ipv6->GetInterface(i)->GetNdiscCache();
190 if (ndiscCache)
191 {
192 ndiscCache->PrintNdiscCache(stream);
193 }
194 }
195 }
196}
197
198void
200 Ptr<Node> node,
202 Time::Unit unit /* = Time::S */)
203{
204 Ptr<Ipv6L3Protocol> ipv6 = node->GetObject<Ipv6L3Protocol>();
205 if (ipv6)
206 {
207 std::ostream* os = stream->GetStream();
208
209 *os << "NDISC Cache of node ";
210 std::string found = Names::FindName(node);
211 if (!Names::FindName(node).empty())
212 {
213 *os << found;
214 }
215 else
216 {
217 *os << static_cast<int>(node->GetId());
218 }
219 *os << " at time " << Simulator::Now().As(unit) << "\n";
220
221 for (uint32_t i = 0; i < ipv6->GetNInterfaces(); i++)
222 {
223 Ptr<NdiscCache> ndiscCache = ipv6->GetInterface(i)->GetNdiscCache();
224 if (ndiscCache)
225 {
226 ndiscCache->PrintNdiscCache(stream);
227 }
228 }
229 Simulator::Schedule(printInterval,
231 printInterval,
232 node,
233 stream,
234 unit);
235 }
236}
237
238} // namespace ns3
Access to the IPv6 forwarding table, interfaces, and configuration.
Definition ipv6.h:71
IPv6 layer implementation.
static void PrintRoutingTableAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of all nodes at a particular time.
static void PrintNdiscCacheEvery(Time printInterval, Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of a node at regular intervals specified by user.
static void PrintNeighborCacheAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of all nodes at a particular time.
static void PrintNdiscCache(Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of a node.
static void PrintNeighborCacheAllEvery(Time printInterval, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of all nodes at regular intervals specified by user.
static void PrintRoutingTableAt(Time printTime, Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of a node at a particular time.
static void PrintRoutingTableAllEvery(Time printInterval, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of all nodes at regular intervals specified by user.
static void PrintNeighborCacheEvery(Time printInterval, Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of a node at regular intervals specified by user.
static void PrintRoutingTableEvery(Time printInterval, Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of a node at regular intervals specified by user.
virtual ~Ipv6RoutingHelper()
Destroy an Ipv6 Ipv6RoutingHelper.
static void Print(Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit)
prints the routing tables of a node.
static void PrintNeighborCacheAt(Time printTime, Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of a node at a particular time.
static void PrintEvery(Time printInterval, Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit)
prints the routing tables of a node at regular intervals specified by user.
static std::string FindName(Ptr< Object > object)
Given a pointer to an object, look to see if that object has a name associated with it and,...
Definition names.cc:818
static uint32_t GetNNodes()
Definition node-list.cc:247
static Ptr< Node > GetNode(uint32_t n)
Definition node-list.cc:240
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:560
static Time Now()
Return the current simulation virtual time.
Definition simulator.cc:197
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition time.cc:404
Unit
The unit to use to interpret a number representing time.
Definition nstime.h:100
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition assert.h:55
Every class exported by the ns3 library is enclosed in the ns3 namespace.