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

(-)a/src/internet/helper/ipv4-routing-helper.cc (+79 lines)
 Lines 23-28    Link Here 
23
#include "ns3/simulator.h"
23
#include "ns3/simulator.h"
24
#include "ns3/ipv4-routing-protocol.h"
24
#include "ns3/ipv4-routing-protocol.h"
25
#include "ns3/ipv4-list-routing.h"
25
#include "ns3/ipv4-list-routing.h"
26
#include "ns3/ipv4-l3-protocol.h"
27
#include "ns3/ipv4-interface.h"
28
#include "ns3/arp-cache.h"
29
#include "ns3/names.h"
26
#include "ipv4-routing-helper.h"
30
#include "ipv4-routing-helper.h"
27
31
28
namespace ns3 {
32
namespace ns3 {
 Lines 82-85    Link Here 
82
  Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintEvery, this, printInterval, node, stream);
86
  Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintEvery, this, printInterval, node, stream);
83
}
87
}
84
88
89
void
90
Ipv4RoutingHelper::PrintNeighborCacheAllAt (Time printTime, Ptr<OutputStreamWrapper> stream) const
91
{
92
  for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
93
    {
94
      Ptr<Node> node = NodeList::GetNode (i);
95
      Simulator::Schedule (printTime, &Ipv4RoutingHelper::PrintArpCache, this, node, stream);
96
    }
97
}
98
99
void
100
Ipv4RoutingHelper::PrintNeighborCacheAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream) const
101
{
102
  for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
103
    {
104
      Ptr<Node> node = NodeList::GetNode (i);
105
      Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintArpCacheEvery, this, printInterval, node, stream);
106
    }
107
}
108
109
void
110
Ipv4RoutingHelper::PrintNeighborCacheAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
111
{
112
  Simulator::Schedule (printTime, &Ipv4RoutingHelper::PrintArpCache, this, node, stream);
113
}
114
115
void
116
Ipv4RoutingHelper::PrintNeighborCacheEvery (Time printInterval,Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
117
{
118
  Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintArpCacheEvery, this, printInterval, node, stream);
119
}
120
121
void
122
Ipv4RoutingHelper::PrintArpCache (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
123
{
124
  std::ostream* os = stream->GetStream ();
125
126
  *os << "ARP Cache of node ";
127
  std::string found = Names::FindName (node);
128
  if (Names::FindName (node) != "")
129
    {
130
      *os << found;
131
    }
132
  else
133
    {
134
      *os << static_cast<int> (node->GetId ());
135
    }
136
  *os << " at time " << Simulator::Now ().GetSeconds () << "\n";
137
138
  Ptr<Ipv4L3Protocol> ipv4 = node->GetObject<Ipv4L3Protocol> ();
139
  for (uint32_t i=0; i<ipv4->GetNInterfaces(); i++)
140
    {
141
      Ptr<ArpCache> arpCache = ipv4->GetInterface (i)->GetArpCache ();
142
      if (arpCache)
143
        {
144
          arpCache->PrintArpCache (stream);
145
        }
146
    }
147
}
148
149
void
150
Ipv4RoutingHelper::PrintArpCacheEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
151
{
152
  Ptr<Ipv4L3Protocol> ipv4 = node->GetObject<Ipv4L3Protocol> ();
153
  for (uint32_t i=0; i<ipv4->GetNInterfaces(); i++)
154
    {
155
      Ptr<ArpCache> arpCache = ipv4->GetInterface (i)->GetArpCache ();
156
      if (arpCache)
157
        {
158
          arpCache->PrintArpCache (stream);
159
        }
160
    }
161
  Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintArpCacheEvery, this, printInterval, node, stream);
162
}
163
85
} // namespace ns3
164
} // namespace ns3
(-)a/src/internet/helper/ipv4-routing-helper.h (-2 / +99 lines)
 Lines 110-115    Link Here 
110
  void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
110
  void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
111
111
112
  /**
112
  /**
113
   * \brief prints the neighbor cache of all nodes at a particular time.
114
   * \param printTime the time at which the neighbor cache is supposed to be printed.
115
   * \param stream The output stream object to use
116
   *
117
   * This method calls the PrintArpCache() method of the
118
   * ArpCache associated with each Ipv4Interface stored in the Ipv4 object, for all nodes at the
119
   * specified time. The output format is similar to:
120
   * \verbatim
121
     10.1.1.2 dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
122
     \endverbatim
123
   * Note that the MAC address is printed as "type"-"size"-"actual address"
124
   */
125
  void PrintNeighborCacheAllAt (Time printTime, Ptr<OutputStreamWrapper> stream) const;
126
127
  /**
128
   * \brief prints the neighbor cache of all nodes at regular intervals specified by user.
129
   * \param printInterval the time interval for which the neighbor cache is supposed to be printed.
130
   * \param stream The output stream object to use
131
   *
132
   * This method calls the PrintArpCache() method of the
133
   * ArpCache associated with each Ipv4Interface stored in the Ipv4 object, for all nodes at the
134
   * specified time. The output format is similar to:
135
   * \verbatim
136
     10.1.1.2 dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
137
     \endverbatim
138
   * Note that the MAC address is printed as "type"-"size"-"actual address"
139
   */
140
  void PrintNeighborCacheAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream) const;
141
142
  /**
143
   * \brief prints the neighbor cache of a node at a particular time.
144
   * \param printTime the time at which the neighbor cache is supposed to be printed.
145
   * \param node The node ptr for which we need the neighbor cache to be printed
146
   * \param stream The output stream object to use
147
   *
148
   * This method calls the PrintArpCache() method of the
149
   * ArpCache associated with each Ipv4Interface stored in the Ipv4 object, for all nodes at the
150
   * specified time. The output format is similar to:
151
   * \verbatim
152
     10.1.1.2 dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
153
     \endverbatim
154
   * Note that the MAC address is printed as "type"-"size"-"actual address"
155
   */
156
  void PrintNeighborCacheAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
157
158
  /**
159
   * \brief prints the neighbor cache of a node at regular intervals specified by user.
160
   * \param printInterval the time interval for which the neighbor cache is supposed to be printed.
161
   * \param node The node ptr for which we need the neighbor cache to be printed
162
   * \param stream The output stream object to use
163
   *
164
   * This method calls the PrintArpCache() method of the
165
   * ArpCache associated with each Ipv4Interface stored in the Ipv4 object, for all nodes at the
166
   * specified time. The output format is similar to:
167
   * \verbatim
168
     10.1.1.2 dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
169
     \endverbatim
170
   * Note that the MAC address is printed as "type"-"size"-"actual address"
171
   */
172
   void PrintNeighborCacheEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
173
174
  /**
113
   * \brief Request a specified routing protocol &lt;T&gt; from Ipv4RoutingProtocol protocol
175
   * \brief Request a specified routing protocol &lt;T&gt; from Ipv4RoutingProtocol protocol
114
   *
176
   *
115
   * If protocol is Ipv4ListRouting, then protocol will be searched in the list,
177
   * If protocol is Ipv4ListRouting, then protocol will be searched in the list,
 Lines 130-136    Link Here 
130
   * \param stream The output stream object to use
192
   * \param stream The output stream object to use
131
   *
193
   *
132
   * This method calls the PrintRoutingTable() method of the
194
   * This method calls the PrintRoutingTable() method of the
133
   * Ipv6RoutingProtocol stored in the Ipv6 object;
195
   * Ipv4RoutingProtocol stored in the Ipv4 object;
134
   * the output format is routing protocol-specific.
196
   * the output format is routing protocol-specific.
135
   */
197
   */
136
  void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
198
  void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
 Lines 144-153    Link Here 
144
   * \param stream The output stream object to use
206
   * \param stream The output stream object to use
145
   *
207
   *
146
   * This method calls the PrintRoutingTable() method of the
208
   * This method calls the PrintRoutingTable() method of the
147
   * Ipv6RoutingProtocol stored in the Ipv6 object, for the selected node
209
   * Ipv4RoutingProtocol stored in the Ipv4 object, for the selected node
148
   * at the specified interval; the output format is routing protocol-specific.
210
   * at the specified interval; the output format is routing protocol-specific.
149
   */
211
   */
150
  void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
212
  void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
213
214
  /**
215
   * \internal
216
   *
217
   * \brief prints the neighbor cache of a node.
218
   * \param node The node ptr for which we need the neighbor cache to be printed
219
   * \param stream The output stream object to use
220
   *
221
   * This method calls the PrintArpCache() method of the
222
   * ArpCache associated with each Ipv4Interface stored in the Ipv4 object, for all nodes at the
223
   * specified time. The output format is similar to:
224
   * \verbatim
225
     10.1.1.2 dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
226
     \endverbatim
227
   * Note that the MAC address is printed as "type"-"size"-"actual address"
228
   */
229
  void PrintArpCache (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
230
231
  /**
232
   * \internal
233
   *
234
   * \brief prints the neighbor cache of a node at regular intervals specified by user.
235
   * \param printInterval the time interval for which the neighbor cache is supposed to be printed.
236
   * \param node The node ptr for which we need the neighbor cache to be printed
237
   * \param stream The output stream object to use
238
   *
239
   * This method calls the PrintArpCache() method of the
240
   * ArpCache associated with each Ipv4Interface stored in the Ipv4 object, for all nodes at the
241
   * specified time. The output format is similar to:
242
   * \verbatim
243
     10.1.1.2 dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
244
     \endverbatim
245
   * Note that the MAC address is printed as "type"-"size"-"actual address"
246
   */
247
  void PrintArpCacheEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
151
};
248
};
152
249
153
250
(-)a/src/internet/model/arp-cache.cc (+38 lines)
 Lines 24-29    Link Here 
24
#include "ns3/log.h"
24
#include "ns3/log.h"
25
#include "ns3/node.h"
25
#include "ns3/node.h"
26
#include "ns3/trace-source-accessor.h"
26
#include "ns3/trace-source-accessor.h"
27
#include "ns3/names.h"
27
28
28
#include "arp-cache.h"
29
#include "arp-cache.h"
29
#include "arp-header.h"
30
#include "arp-header.h"
 Lines 242-247    Link Here 
242
    }
243
    }
243
}
244
}
244
245
246
void
247
ArpCache::PrintArpCache (Ptr<OutputStreamWrapper> stream)
248
{
249
  NS_LOG_FUNCTION (this << stream);
250
  std::ostream* os = stream->GetStream ();
251
252
  for (CacheI i = m_arpCache.begin (); i != m_arpCache.end (); i++)
253
    {
254
      *os << i->first << " dev ";
255
      std::string found = Names::FindName (m_device);
256
      if (Names::FindName (m_device) != "")
257
        {
258
          *os << found;
259
        }
260
      else
261
        {
262
          *os << static_cast<int> (m_device->GetIfIndex ());
263
        }
264
265
      *os << " lladdr " << i->second->GetMacAddress ();
266
267
      if (i->second->IsAlive ())
268
        {
269
          *os << " REACHABLE\n";
270
        }
271
      else if (i->second->IsWaitReply ())
272
        {
273
          *os << " DELAY\n";
274
        }
275
      else
276
        {
277
          *os << " STALE\n";
278
        }
279
    }
280
}
281
282
245
ArpCache::Entry *
283
ArpCache::Entry *
246
ArpCache::Lookup (Ipv4Address to)
284
ArpCache::Lookup (Ipv4Address to)
247
{
285
{
(-)a/src/internet/model/arp-cache.h (-2 / +10 lines)
 Lines 33-38    Link Here 
33
#include "ns3/object.h"
33
#include "ns3/object.h"
34
#include "ns3/traced-callback.h"
34
#include "ns3/traced-callback.h"
35
#include "ns3/sgi-hashmap.h"
35
#include "ns3/sgi-hashmap.h"
36
#include "ns3/output-stream-wrapper.h"
36
37
37
namespace ns3 {
38
namespace ns3 {
38
39
 Lines 76-83    Link Here 
76
  /**
77
  /**
77
   * \brief Set the NetDevice and Ipv4Interface associated with the ArpCache
78
   * \brief Set the NetDevice and Ipv4Interface associated with the ArpCache
78
   *
79
   *
79
   * \param device The hardware NetDevice associated with this ARP chache
80
   * \param device The hardware NetDevice associated with this ARP cache
80
   * \param interface the Ipv4Interface associated with this ARP chache
81
   * \param interface the Ipv4Interface associated with this ARP cache
81
   */
82
   */
82
  void SetDevice (Ptr<NetDevice> device, Ptr<Ipv4Interface> interface);
83
  void SetDevice (Ptr<NetDevice> device, Ptr<Ipv4Interface> interface);
83
  /**
84
  /**
 Lines 155-160    Link Here 
155
  void Flush (void);
156
  void Flush (void);
156
157
157
  /**
158
  /**
159
   * \brief Print the ARP cache entries
160
   *
161
   * \param stream the ostream the ARP cache entries is printed to
162
   */
163
  void PrintArpCache (Ptr<OutputStreamWrapper> stream);
164
165
  /**
158
   * \brief A record that that holds information about an ArpCache entry
166
   * \brief A record that that holds information about an ArpCache entry
159
   */
167
   */
160
  class Entry {
168
  class Entry {

Return to bug 652