A Discrete-Event Network Simulator
API
ipv6-routing-helper.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2008 INRIA
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation;
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 *
18 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19 */
20
21#include "ns3/node.h"
22#include "ns3/node-list.h"
23#include "ns3/simulator.h"
24#include "ns3/ipv6-routing-protocol.h"
25#include "ns3/ipv6-list-routing.h"
26#include "ns3/ipv6-l3-protocol.h"
27#include "ns3/ipv6-interface.h"
28#include "ns3/ndisc-cache.h"
29#include "ns3/names.h"
30#include "ipv6-routing-helper.h"
31
32namespace ns3 {
33
35{
36}
37
38void
40{
41 for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
42 {
44 Simulator::Schedule (printTime, &Ipv6RoutingHelper::Print, node, stream, unit);
45 }
46}
47
48void
50{
51 for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
52 {
54 Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintEvery, printInterval, node, stream, unit);
55 }
56}
57
58void
60{
61 Simulator::Schedule (printTime, &Ipv6RoutingHelper::Print, node, stream, unit);
62}
63
64void
66{
67 Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintEvery, printInterval, node, stream, unit);
68}
69
70void
72{
73 Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
74 if (ipv6)
75 {
76 Ptr<Ipv6RoutingProtocol> rp = ipv6->GetRoutingProtocol ();
77 NS_ASSERT (rp);
78 rp->PrintRoutingTable (stream, unit);
79 }
80}
81
82void
84{
85 Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
86 if (ipv6)
87 {
88 Ptr<Ipv6RoutingProtocol> rp = ipv6->GetRoutingProtocol ();
89 NS_ASSERT (rp);
90 rp->PrintRoutingTable (stream, unit);
91 Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintEvery, printInterval, node, stream, unit);
92 }
93}
94
95void
97{
98 for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
99 {
100 Ptr<Node> node = NodeList::GetNode (i);
101 Simulator::Schedule (printTime, &Ipv6RoutingHelper::PrintNdiscCache, node, stream, unit);
102 }
103}
104
105void
107{
108 for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
109 {
110 Ptr<Node> node = NodeList::GetNode (i);
111 Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintNdiscCacheEvery, printInterval, node, stream, unit);
112 }
113}
114
115void
117{
118 Simulator::Schedule (printTime, &Ipv6RoutingHelper::PrintNdiscCache, node, stream, unit);
119}
120
121void
123{
124 Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintNdiscCacheEvery, printInterval, node, stream, unit);
125}
126
127void
129{
131 if (ipv6)
132 {
133 std::ostream* os = stream->GetStream ();
134
135 *os << "NDISC Cache of node ";
136 std::string found = Names::FindName (node);
137 if (Names::FindName (node) != "")
138 {
139 *os << found;
140 }
141 else
142 {
143 *os << static_cast<int> (node->GetId ());
144 }
145 *os << " at time " << Simulator::Now ().As (unit) << "\n";
146
147 for (uint32_t i=0; i<ipv6->GetNInterfaces(); i++)
148 {
149 Ptr<NdiscCache> ndiscCache = ipv6->GetInterface (i)->GetNdiscCache ();
150 if (ndiscCache)
151 {
152 ndiscCache->PrintNdiscCache (stream);
153 }
154 }
155 }
156}
157
158void
160{
162 if (ipv6)
163 {
164 std::ostream* os = stream->GetStream ();
165
166 *os << "NDISC Cache of node ";
167 std::string found = Names::FindName (node);
168 if (Names::FindName (node) != "")
169 {
170 *os << found;
171 }
172 else
173 {
174 *os << static_cast<int> (node->GetId ());
175 }
176 *os << " at time " << Simulator::Now ().As (unit) << "\n";
177
178 for (uint32_t i=0; i<ipv6->GetNInterfaces(); i++)
179 {
180 Ptr<NdiscCache> ndiscCache = ipv6->GetInterface (i)->GetNdiscCache ();
181 if (ndiscCache)
182 {
183 ndiscCache->PrintNdiscCache (stream);
184 }
185 }
186 Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintNdiscCacheEvery, printInterval, node, stream, unit);
187 }
188}
189
190} // namespace ns3
Access to the IPv6 forwarding table, interfaces, and configuration.
Definition: ipv6.h:82
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:817
void PrintNdiscCache(Ptr< OutputStreamWrapper > stream)
Print the NDISC cache entries.
Definition: ndisc-cache.cc:177
uint32_t GetId(void) const
Definition: node.cc:109
static uint32_t GetNNodes(void)
Definition: node-list.cc:247
static Ptr< Node > GetNode(uint32_t n)
Definition: node-list.cc:241
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:556
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
Unit
The unit to use to interpret a number representing time.
Definition: nstime.h:109
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Definition: time.cc:418
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition: assert.h:67
Every class exported by the ns3 library is enclosed in the ns3 namespace.