View | Details | Raw Unified | Return to bug 1393
Collapse All | Expand All

(-)a/src/internet/helper/ipv6-routing-helper.cc (+55 lines)
 Lines 18-23    Link Here 
18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19
 */
19
 */
20
20
21
#include "ns3/node.h"
22
#include "ns3/node-list.h"
23
#include "ns3/simulator.h"
24
#include "ns3/ipv6-routing-protocol.h"
21
#include "ipv6-routing-helper.h"
25
#include "ipv6-routing-helper.h"
22
26
23
namespace ns3 {
27
namespace ns3 {
 Lines 26-29    Link Here 
26
{
30
{
27
}
31
}
28
32
33
void
34
Ipv6RoutingHelper::PrintRoutingTableAllAt (Time printTime, Ptr<OutputStreamWrapper> stream) const
35
{
36
  for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
37
    {
38
      Ptr<Node> node = NodeList::GetNode (i);
39
      Simulator::Schedule (printTime, &Ipv6RoutingHelper::Print, this, node, stream);
40
    }
41
}
42
43
void
44
Ipv6RoutingHelper::PrintRoutingTableAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream) const
45
{
46
  for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
47
    {
48
      Ptr<Node> node = NodeList::GetNode (i);
49
      Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintEvery, this, printInterval, node, stream);
50
    }
51
}
52
53
void
54
Ipv6RoutingHelper::PrintRoutingTableAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
55
{
56
  Simulator::Schedule (printTime, &Ipv6RoutingHelper::Print, this, node, stream);
57
}
58
59
void
60
Ipv6RoutingHelper::PrintRoutingTableEvery (Time printInterval,Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
61
{
62
  Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintEvery, this, printInterval, node, stream);
63
}
64
65
void
66
Ipv6RoutingHelper::Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
67
{
68
  Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
69
  Ptr<Ipv6RoutingProtocol> rp = ipv6->GetRoutingProtocol ();
70
  NS_ASSERT (rp);
71
  rp->PrintRoutingTable (stream);
72
}
73
74
void
75
Ipv6RoutingHelper::PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
76
{
77
  Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
78
  Ptr<Ipv6RoutingProtocol> rp = ipv6->GetRoutingProtocol ();
79
  NS_ASSERT (rp);
80
  rp->PrintRoutingTable (stream);
81
  Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintEvery, this, printInterval, node, stream);
82
}
83
29
} // namespace ns3
84
} // namespace ns3
(-)a/src/internet/helper/ipv6-routing-helper.h (+52 lines)
 Lines 22-27    Link Here 
22
#define IPV6_ROUTING_HELPER_H
22
#define IPV6_ROUTING_HELPER_H
23
23
24
#include "ns3/ptr.h"
24
#include "ns3/ptr.h"
25
#include "ns3/nstime.h"
26
#include "ns3/output-stream-wrapper.h"
25
27
26
namespace ns3 {
28
namespace ns3 {
27
29
 Lines 61-66    Link Here 
61
   * \returns a newly-created routing protocol
63
   * \returns a newly-created routing protocol
62
   */
64
   */
63
  virtual Ptr<Ipv6RoutingProtocol> Create (Ptr<Node> node) const = 0;
65
  virtual Ptr<Ipv6RoutingProtocol> Create (Ptr<Node> node) const = 0;
66
67
  /**
68
   * \brief prints the routing tables of all nodes at a particular time.
69
   * \param printTime the time at which the routing table is supposed to be printed.
70
   * \param stream The output stream object to use
71
   *
72
   * This method calls the PrintRoutingTable() method of the
73
   * Ipv6RoutingProtocol stored in the Ipv6 object, for all nodes at the
74
   * specified time; the output format is routing protocol-specific.
75
   */
76
  void PrintRoutingTableAllAt (Time printTime, Ptr<OutputStreamWrapper> stream) const;
77
78
  /**
79
   * \brief prints the routing tables of all nodes at regular intervals specified by user.
80
   * \param printInterval the time interval for which the routing table is supposed to be printed.
81
   * \param stream The output stream object to use
82
   *
83
   * This method calls the PrintRoutingTable() method of the
84
   * Ipv6RoutingProtocol stored in the Ipv6 object, for all nodes at the
85
   * specified time interval; the output format is routing protocol-specific.
86
   */
87
  void PrintRoutingTableAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream) const;
88
89
  /**
90
   * \brief prints the routing tables of a node at a particular time.
91
   * \param printTime the time at which the routing table is supposed to be printed.
92
   * \param node The node ptr for which we need the routing table to be printed
93
   * \param stream The output stream object to use
94
   *
95
   * This method calls the PrintRoutingTable() method of the
96
   * Ipv6RoutingProtocol stored in the Ipv6 object, for the selected node
97
   * at the specified time; the output format is routing protocol-specific.
98
   */
99
  void PrintRoutingTableAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
100
101
  /**
102
   * \brief prints the routing tables of a node at regular intervals specified by user.
103
   * \param printInterval the time interval for which the routing table is supposed to be printed.
104
   * \param node The node ptr for which we need the routing table to be printed
105
   * \param stream The output stream object to use
106
   *
107
   * This method calls the PrintRoutingTable() method of the
108
   * Ipv6RoutingProtocol stored in the Ipv6 object, for the selected node
109
   * at the specified interval; the output format is routing protocol-specific.
110
   */
111
  void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
112
113
private:
114
  void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
115
  void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
64
};
116
};
65
117
66
} // namespace ns3
118
} // namespace ns3
(-)a/src/internet/model/ipv4-routing-protocol.h (+5 lines)
 Lines 142-147    Link Here 
142
   */
142
   */
143
  virtual void SetIpv4 (Ptr<Ipv4> ipv4) = 0;
143
  virtual void SetIpv4 (Ptr<Ipv4> ipv4) = 0;
144
144
145
  /**
146
   * \brief Print the Routing Table entries
147
   *
148
   * \param stream the ostream the Routing table is printed to
149
   */
145
  virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const = 0;
150
  virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const = 0;
146
};
151
};
147
152
(-)a/src/internet/model/ipv6-list-routing.cc (+18 lines)
 Lines 23-28    Link Here 
23
#include "ns3/node.h"
23
#include "ns3/node.h"
24
#include "ns3/ipv6-static-routing.h"
24
#include "ns3/ipv6-static-routing.h"
25
#include "ipv6-list-routing.h"
25
#include "ipv6-list-routing.h"
26
#include "ns3/simulator.h"
26
27
27
NS_LOG_COMPONENT_DEFINE ("Ipv6ListRouting");
28
NS_LOG_COMPONENT_DEFINE ("Ipv6ListRouting");
28
29
 Lines 270-275    Link Here 
270
}
271
}
271
272
272
void
273
void
274
Ipv6ListRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
275
{
276
  NS_LOG_FUNCTION (this);
277
278
  *stream->GetStream () << "Node: " << m_ipv6->GetObject<Node> ()->GetId ()
279
                        << " Time: " << Simulator::Now ().GetSeconds () << "s "
280
                        << "Ipv6ListRouting table" << std::endl;
281
  for (Ipv6RoutingProtocolList::const_iterator i = m_routingProtocols.begin ();
282
       i != m_routingProtocols.end (); i++)
283
    {
284
      *stream->GetStream () << "  Priority: " << (*i).first << " Protocol: " << (*i).second->GetInstanceTypeId () << std::endl;
285
      (*i).second->PrintRoutingTable (stream);
286
    }
287
  *stream->GetStream () << std::endl;
288
}
289
290
void
273
Ipv6ListRouting::SetIpv6 (Ptr<Ipv6> ipv6)
291
Ipv6ListRouting::SetIpv6 (Ptr<Ipv6> ipv6)
274
{
292
{
275
  NS_LOG_FUNCTION (this << ipv6);
293
  NS_LOG_FUNCTION (this << ipv6);
(-)a/src/internet/model/ipv6-list-routing.h (+7 lines)
 Lines 104-109    Link Here 
104
  virtual void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ());
104
  virtual void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ());
105
  virtual void SetIpv6 (Ptr<Ipv6> ipv6);
105
  virtual void SetIpv6 (Ptr<Ipv6> ipv6);
106
106
107
  /**
108
   * \brief Print the Routing Table entries
109
   *
110
   * \param stream the ostream the Routing table is printed to
111
   */
112
  virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
113
107
protected:
114
protected:
108
  /**
115
  /**
109
   * \brief Dispose this object.
116
   * \brief Dispose this object.
(-)a/src/internet/model/ipv6-routing-protocol.h (+8 lines)
 Lines 29-34    Link Here 
29
#include "ipv6-header.h"
29
#include "ipv6-header.h"
30
#include "ipv6-interface-address.h"
30
#include "ipv6-interface-address.h"
31
#include "ipv6.h"
31
#include "ipv6.h"
32
#include "ns3/output-stream-wrapper.h"
32
33
33
namespace ns3 {
34
namespace ns3 {
34
35
 Lines 171-176    Link Here 
171
   * \param ipv6 the ipv6 object this routing protocol is being associated with
172
   * \param ipv6 the ipv6 object this routing protocol is being associated with
172
   */
173
   */
173
  virtual void SetIpv6 (Ptr<Ipv6> ipv6) = 0;
174
  virtual void SetIpv6 (Ptr<Ipv6> ipv6) = 0;
175
176
  /**
177
   * \brief Print the Routing Table entries
178
   *
179
   * \param stream the ostream the Routing table is printed to
180
   */
181
  virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const = 0;
174
};
182
};
175
183
176
} // namespace ns3
184
} // namespace ns3
(-)a/src/internet/model/ipv6-static-routing.cc (-5 / +28 lines)
 Lines 18-25    Link Here 
18
 * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
18
 * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
19
 */
19
 */
20
20
21
#include <iomanip>
21
#include "ns3/log.h"
22
#include "ns3/log.h"
23
#include "ns3/node.h"
22
#include "ns3/packet.h"
24
#include "ns3/packet.h"
25
#include "ns3/simulator.h"
23
#include "ns3/ipv6-route.h"
26
#include "ns3/ipv6-route.h"
24
#include "ns3/net-device.h"
27
#include "ns3/net-device.h"
25
28
 Lines 71-76    Link Here 
71
    }
74
    }
72
}
75
}
73
76
77
// Formatted like output of "route -n" command
78
void
79
Ipv6StaticRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
80
{
81
  NS_LOG_FUNCTION (this);
82
  std::ostream* os = stream->GetStream ();
83
  if (GetNRoutes () > 0)
84
    {
85
      *os << "Node: " << m_ipv6->GetObject<Node> ()->GetId ()
86
          << " Time: " << Simulator::Now ().GetSeconds () << "s "
87
          << "Ipv6StaticRouting table" << std::endl;
88
89
      for (uint32_t j = 0; j < GetNRoutes (); j++)
90
        {
91
          Ipv6RoutingTableEntry route = GetRoute (j);
92
          *os << route << std::endl;
93
        }
94
    }
95
}
96
74
void Ipv6StaticRouting::AddHostRouteTo (Ipv6Address dst, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse, uint32_t metric)
97
void Ipv6StaticRouting::AddHostRouteTo (Ipv6Address dst, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse, uint32_t metric)
75
{
98
{
76
  NS_LOG_FUNCTION (this << dst << nextHop << interface << prefixToUse << metric);
99
  NS_LOG_FUNCTION (this << dst << nextHop << interface << prefixToUse << metric);
 Lines 369-375    Link Here 
369
  return mrtentry;
392
  return mrtentry;
370
}
393
}
371
394
372
uint32_t Ipv6StaticRouting::GetNRoutes ()
395
uint32_t Ipv6StaticRouting::GetNRoutes () const
373
{
396
{
374
  return m_networkRoutes.size ();
397
  return m_networkRoutes.size ();
375
}
398
}
 Lines 412-423    Link Here 
412
    }
435
    }
413
}
436
}
414
437
415
Ipv6RoutingTableEntry Ipv6StaticRouting::GetRoute (uint32_t index)
438
Ipv6RoutingTableEntry Ipv6StaticRouting::GetRoute (uint32_t index) const
416
{
439
{
417
  NS_LOG_FUNCTION (this << index);
440
  NS_LOG_FUNCTION (this << index);
418
  uint32_t tmp = 0;
441
  uint32_t tmp = 0;
419
442
420
  for (NetworkRoutesI it = m_networkRoutes.begin (); it != m_networkRoutes.end (); it++)
443
  for (NetworkRoutesCI it = m_networkRoutes.begin (); it != m_networkRoutes.end (); it++)
421
    {
444
    {
422
      if (tmp == index)
445
      if (tmp == index)
423
        {
446
        {
 Lines 430-441    Link Here 
430
  return 0;
453
  return 0;
431
}
454
}
432
455
433
uint32_t Ipv6StaticRouting::GetMetric (uint32_t index)
456
uint32_t Ipv6StaticRouting::GetMetric (uint32_t index) const
434
{
457
{
435
  NS_LOG_FUNCTION_NOARGS ();
458
  NS_LOG_FUNCTION_NOARGS ();
436
  uint32_t tmp = 0;
459
  uint32_t tmp = 0;
437
460
438
  for (NetworkRoutesI it = m_networkRoutes.begin (); it != m_networkRoutes.end (); it++)
461
  for (NetworkRoutesCI it = m_networkRoutes.begin (); it != m_networkRoutes.end (); it++)
439
    {
462
    {
440
      if (tmp == index)
463
      if (tmp == index)
441
        {
464
        {
(-)a/src/internet/model/ipv6-static-routing.h (-3 / +10 lines)
 Lines 132-138    Link Here 
132
   * \brief Get the number or entries in the routing table.
132
   * \brief Get the number or entries in the routing table.
133
   * \return number of entries
133
   * \return number of entries
134
   */
134
   */
135
  uint32_t GetNRoutes ();
135
  uint32_t GetNRoutes () const;
136
136
137
  /**
137
  /**
138
   * \brief Get the default route.
138
   * \brief Get the default route.
 Lines 147-160    Link Here 
147
   * \param i index
147
   * \param i index
148
   * \return the route whose index is i
148
   * \return the route whose index is i
149
   */
149
   */
150
  Ipv6RoutingTableEntry GetRoute (uint32_t i);
150
  Ipv6RoutingTableEntry GetRoute (uint32_t i) const;
151
151
152
  /**
152
  /**
153
   * \brief Get a metric for route from the static unicast routing table.
153
   * \brief Get a metric for route from the static unicast routing table.
154
   * \param index The index (into the routing table) of the route to retrieve.
154
   * \param index The index (into the routing table) of the route to retrieve.
155
   * \return If route is set, the metric is returned. If not, an infinity metric (0xffffffff) is returned
155
   * \return If route is set, the metric is returned. If not, an infinity metric (0xffffffff) is returned
156
   */
156
   */
157
  uint32_t GetMetric (uint32_t index);
157
  uint32_t GetMetric (uint32_t index) const;
158
158
159
  /**
159
  /**
160
   * \brief Remove a route from the routing table.
160
   * \brief Remove a route from the routing table.
 Lines 236-241    Link Here 
236
  virtual void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ());
236
  virtual void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ());
237
  virtual void SetIpv6 (Ptr<Ipv6> ipv6);
237
  virtual void SetIpv6 (Ptr<Ipv6> ipv6);
238
238
239
  /**
240
   * \brief Print the Routing Table entries
241
   *
242
   * \param stream the ostream the Routing table is printed to
243
   */
244
  virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
245
239
protected:
246
protected:
240
  /**
247
  /**
241
   * \brief Dispose this object.
248
   * \brief Dispose this object.
(-)a/src/internet/test/ipv6-list-routing-test-suite.cc (+2 lines)
 Lines 38-43    Link Here 
38
                         GetZero ()) {}
38
                         GetZero ()) {}
39
  void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse) {}
39
  void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse) {}
40
  void SetIpv6 (Ptr<Ipv6> ipv6) {}
40
  void SetIpv6 (Ptr<Ipv6> ipv6) {}
41
  virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const {};
41
};
42
};
42
43
43
class Ipv6BRouting : public Ipv6RoutingProtocol {
44
class Ipv6BRouting : public Ipv6RoutingProtocol {
 Lines 54-59    Link Here 
54
                         GetZero ()) {}
55
                         GetZero ()) {}
55
  void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse) {}
56
  void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse) {}
56
  void SetIpv6 (Ptr<Ipv6> ipv6) {}
57
  void SetIpv6 (Ptr<Ipv6> ipv6) {}
58
  virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const {};
57
};
59
};
58
60
59
class Ipv6ListRoutingNegativeTestCase : public TestCase
61
class Ipv6ListRoutingNegativeTestCase : public TestCase

Return to bug 1393