A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ipv4-routing-helper.cc
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 #include "ns3/node.h"
21 #include "ns3/node-list.h"
22 #include "ns3/simulator.h"
23 #include "ns3/ipv4-routing-protocol.h"
24 #include "ipv4-routing-helper.h"
25 
26 namespace ns3 {
27 
28 Ipv4RoutingHelper::~Ipv4RoutingHelper ()
29 {
30 }
31 
32 void
34 {
35  for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
36  {
37  Ptr<Node> node = NodeList::GetNode (i);
38  Simulator::Schedule (printTime, &Ipv4RoutingHelper::Print, this, node, stream);
39  }
40 }
41 
42 void
44 {
45  for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
46  {
47  Ptr<Node> node = NodeList::GetNode (i);
48  Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintEvery, this, printInterval, node, stream);
49  }
50 }
51 
52 void
54 {
55  Simulator::Schedule (printTime, &Ipv4RoutingHelper::Print, this, node, stream);
56 }
57 
58 void
60 {
61  Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintEvery, this, printInterval, node, stream);
62 }
63 
64 void
65 Ipv4RoutingHelper::Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
66 {
67  Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
68  Ptr<Ipv4RoutingProtocol> rp = ipv4->GetRoutingProtocol ();
69  NS_ASSERT (rp);
70  rp->PrintRoutingTable (stream);
71 }
72 
73 void
74 Ipv4RoutingHelper::PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
75 {
76  Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
77  Ptr<Ipv4RoutingProtocol> rp = ipv4->GetRoutingProtocol ();
78  NS_ASSERT (rp);
79  rp->PrintRoutingTable (stream);
80  Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintEvery, this, printInterval, node, stream);
81 }
82 
83 } // namespace ns3
keep track of time unit.
Definition: nstime.h:149
static uint32_t GetNNodes(void)
Definition: node-list.cc:198
static Ptr< Node > GetNode(uint32_t n)
Definition: node-list.cc:192
#define NS_ASSERT(condition)
Definition: assert.h:64
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Definition: simulator.h:820
Access to the Ipv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:75
void PrintRoutingTableAllAt(Time printTime, Ptr< OutputStreamWrapper > stream) const
prints the routing tables of all nodes at a particular time.
void PrintRoutingTableAt(Time printTime, Ptr< Node > node, Ptr< OutputStreamWrapper > stream) const
prints the routing tables of a node at a particular time.
void PrintRoutingTableAllEvery(Time printInterval, Ptr< OutputStreamWrapper > stream) const
prints the routing tables of all nodes at regular intervals specified by user.
void PrintRoutingTableEvery(Time printInterval, Ptr< Node > node, Ptr< OutputStreamWrapper > stream) const
prints the routing tables of a node at regular intervals specified by user.
Ptr< T > GetObject(void) const
Definition: object.h:332