Bug 652 - no public API for IPv4 neighbor table - Print functions

This commit is contained in:
Tommaso Pecorella
2014-09-20 23:53:22 +02:00
parent 78985e5d68
commit 5d52c03318
16 changed files with 616 additions and 15 deletions

View File

@@ -54,6 +54,9 @@ us a note on ns-developers mailing list.</p>
<h1>Changes from ns-3.21 to ns-3.22</h1>
<h2>New API:</h2>
<ul>
<li> It is now possible to print the Neighbor Cache (ARP and NDISC) by using
the RoutingProtocolHelper
</li>
</ul>
<h2>Changes to existing API:</h2>

View File

@@ -21,6 +21,8 @@ Supported platforms
New user-visible features
-------------------------
- It is now possible to print the Neighbor Cache (ARP and NDISC) by using
the RoutingProtocolHelper
Bugs fixed
----------

View File

@@ -227,6 +227,8 @@ int main (int argc, char *argv[])
// Trace routing tables
Ptr<OutputStreamWrapper> routingStream = Create<OutputStreamWrapper> ("wifi-simple-adhoc-grid.routes", std::ios::out);
olsr.PrintRoutingTableAllEvery (Seconds (2), routingStream);
Ptr<OutputStreamWrapper> neighborStream = Create<OutputStreamWrapper> ("wifi-simple-adhoc-grid.neighbors", std::ios::out);
olsr.PrintNeighborCacheAllEvery (Seconds (2), neighborStream);
// To do-- enable an IP-level trace that shows forwarding events only
}
@@ -238,7 +240,7 @@ int main (int argc, char *argv[])
// Output what we are doing
NS_LOG_UNCOND ("Testing from node " << sourceNode << " to " << sinkNode << " with grid distance " << distance);
Simulator::Stop (Seconds (32.0));
Simulator::Stop (Seconds (33.0));
Simulator::Run ();
Simulator::Destroy ();

View File

@@ -2804,6 +2804,26 @@ def register_Ns3Ipv4RoutingHelper_methods(root_module, cls):
'ns3::Ptr< ns3::Ipv4RoutingProtocol >',
[param('ns3::Ptr< ns3::Node >', 'node')],
is_pure_virtual=True, is_const=True, is_virtual=True)
## ipv4-routing-helper.h (module 'internet'): void ns3::Ipv4RoutingHelper::PrintNeighborCacheAllAt(ns3::Time printTime, ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintNeighborCacheAllAt',
'void',
[param('ns3::Time', 'printTime'), param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')],
is_const=True)
## ipv4-routing-helper.h (module 'internet'): void ns3::Ipv4RoutingHelper::PrintNeighborCacheAllEvery(ns3::Time printInterval, ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintNeighborCacheAllEvery',
'void',
[param('ns3::Time', 'printInterval'), param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')],
is_const=True)
## ipv4-routing-helper.h (module 'internet'): void ns3::Ipv4RoutingHelper::PrintNeighborCacheAt(ns3::Time printTime, ns3::Ptr<ns3::Node> node, ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintNeighborCacheAt',
'void',
[param('ns3::Time', 'printTime'), param('ns3::Ptr< ns3::Node >', 'node'), param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')],
is_const=True)
## ipv4-routing-helper.h (module 'internet'): void ns3::Ipv4RoutingHelper::PrintNeighborCacheEvery(ns3::Time printInterval, ns3::Ptr<ns3::Node> node, ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintNeighborCacheEvery',
'void',
[param('ns3::Time', 'printInterval'), param('ns3::Ptr< ns3::Node >', 'node'), param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')],
is_const=True)
## ipv4-routing-helper.h (module 'internet'): void ns3::Ipv4RoutingHelper::PrintRoutingTableAllAt(ns3::Time printTime, ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintRoutingTableAllAt',
'void',
@@ -3508,6 +3528,26 @@ def register_Ns3Ipv6RoutingHelper_methods(root_module, cls):
'ns3::Ptr< ns3::Ipv6RoutingProtocol >',
[param('ns3::Ptr< ns3::Node >', 'node')],
is_pure_virtual=True, is_const=True, is_virtual=True)
## ipv6-routing-helper.h (module 'internet'): void ns3::Ipv6RoutingHelper::PrintNeighborCacheAllAt(ns3::Time printTime, ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintNeighborCacheAllAt',
'void',
[param('ns3::Time', 'printTime'), param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')],
is_const=True)
## ipv6-routing-helper.h (module 'internet'): void ns3::Ipv6RoutingHelper::PrintNeighborCacheAllEvery(ns3::Time printInterval, ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintNeighborCacheAllEvery',
'void',
[param('ns3::Time', 'printInterval'), param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')],
is_const=True)
## ipv6-routing-helper.h (module 'internet'): void ns3::Ipv6RoutingHelper::PrintNeighborCacheAt(ns3::Time printTime, ns3::Ptr<ns3::Node> node, ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintNeighborCacheAt',
'void',
[param('ns3::Time', 'printTime'), param('ns3::Ptr< ns3::Node >', 'node'), param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')],
is_const=True)
## ipv6-routing-helper.h (module 'internet'): void ns3::Ipv6RoutingHelper::PrintNeighborCacheEvery(ns3::Time printInterval, ns3::Ptr<ns3::Node> node, ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintNeighborCacheEvery',
'void',
[param('ns3::Time', 'printInterval'), param('ns3::Ptr< ns3::Node >', 'node'), param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')],
is_const=True)
## ipv6-routing-helper.h (module 'internet'): void ns3::Ipv6RoutingHelper::PrintRoutingTableAllAt(ns3::Time printTime, ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintRoutingTableAllAt',
'void',
@@ -4269,10 +4309,10 @@ def register_Ns3PcapHelper_methods(root_module, cls):
cls.add_constructor([param('ns3::PcapHelper const &', 'arg0')])
## trace-helper.h (module 'network'): ns3::PcapHelper::PcapHelper() [constructor]
cls.add_constructor([])
## trace-helper.h (module 'network'): ns3::Ptr<ns3::PcapFileWrapper> ns3::PcapHelper::CreateFile(std::string filename, std::_Ios_Openmode filemode, uint32_t dataLinkType, uint32_t snapLen=65535, int32_t tzCorrection=0) [member function]
## trace-helper.h (module 'network'): ns3::Ptr<ns3::PcapFileWrapper> ns3::PcapHelper::CreateFile(std::string filename, std::_Ios_Openmode filemode, uint32_t dataLinkType, uint32_t snapLen=std::numeric_limits<unsigned int>::max(), int32_t tzCorrection=0) [member function]
cls.add_method('CreateFile',
'ns3::Ptr< ns3::PcapFileWrapper >',
[param('std::string', 'filename'), param('std::_Ios_Openmode', 'filemode'), param('uint32_t', 'dataLinkType'), param('uint32_t', 'snapLen', default_value='65535'), param('int32_t', 'tzCorrection', default_value='0')])
[param('std::string', 'filename'), param('std::_Ios_Openmode', 'filemode'), param('uint32_t', 'dataLinkType'), param('uint32_t', 'snapLen', default_value='std::numeric_limits<unsigned int>::max()'), param('int32_t', 'tzCorrection', default_value='0')])
## trace-helper.h (module 'network'): std::string ns3::PcapHelper::GetFilenameFromDevice(std::string prefix, ns3::Ptr<ns3::NetDevice> device, bool useObjectNames=true) [member function]
cls.add_method('GetFilenameFromDevice',
'std::string',
@@ -5276,7 +5316,6 @@ def register_Ns3Empty_methods(root_module, cls):
return
def register_Ns3Int64x64_t_methods(root_module, cls):
cls.add_binary_comparison_operator('<=')
cls.add_binary_comparison_operator('!=')
cls.add_inplace_numeric_operator('+=', param('ns3::int64x64_t const &', u'right'))
cls.add_binary_numeric_operator('*', root_module['ns3::int64x64_t'], root_module['ns3::int64x64_t'], param('ns3::int64x64_t const &', u'right'))
@@ -5290,6 +5329,7 @@ def register_Ns3Int64x64_t_methods(root_module, cls):
cls.add_inplace_numeric_operator('-=', param('ns3::int64x64_t const &', u'right'))
cls.add_inplace_numeric_operator('/=', param('ns3::int64x64_t const &', u'right'))
cls.add_output_stream_operator()
cls.add_binary_comparison_operator('<=')
cls.add_binary_comparison_operator('==')
cls.add_binary_comparison_operator('>=')
## int64x64-double.h (module 'core'): ns3::int64x64_t::int64x64_t() [constructor]
@@ -10058,7 +10098,6 @@ def register_Ns3TcpWestwood_methods(root_module, cls):
return
def register_Ns3Time_methods(root_module, cls):
cls.add_binary_comparison_operator('<=')
cls.add_binary_comparison_operator('!=')
cls.add_inplace_numeric_operator('+=', param('ns3::Time const &', u'right'))
cls.add_binary_numeric_operator('*', root_module['ns3::Time'], root_module['ns3::Time'], param('int64_t const &', u'right'))
@@ -10069,6 +10108,7 @@ def register_Ns3Time_methods(root_module, cls):
cls.add_binary_comparison_operator('>')
cls.add_inplace_numeric_operator('-=', param('ns3::Time const &', u'right'))
cls.add_output_stream_operator()
cls.add_binary_comparison_operator('<=')
cls.add_binary_comparison_operator('==')
cls.add_binary_comparison_operator('>=')
## nstime.h (module 'core'): ns3::Time::Time() [constructor]
@@ -10761,6 +10801,10 @@ def register_Ns3ArpCache_methods(root_module, cls):
cls.add_method('Lookup',
'ns3::ArpCache::Entry *',
[param('ns3::Ipv4Address', 'destination')])
## arp-cache.h (module 'internet'): void ns3::ArpCache::PrintArpCache(ns3::Ptr<ns3::OutputStreamWrapper> stream) [member function]
cls.add_method('PrintArpCache',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')])
## arp-cache.h (module 'internet'): void ns3::ArpCache::SetAliveTimeout(ns3::Time aliveTimeout) [member function]
cls.add_method('SetAliveTimeout',
'void',
@@ -13640,6 +13684,11 @@ def register_Ns3Ipv6Interface_methods(root_module, cls):
'uint32_t',
[],
is_const=True)
## ipv6-interface.h (module 'internet'): ns3::Ptr<ns3::NdiscCache> ns3::Ipv6Interface::GetNdiscCache() const [member function]
cls.add_method('GetNdiscCache',
'ns3::Ptr< ns3::NdiscCache >',
[],
is_const=True)
## ipv6-interface.h (module 'internet'): uint16_t ns3::Ipv6Interface::GetReachableTime() const [member function]
cls.add_method('GetReachableTime',
'uint16_t',
@@ -14483,6 +14532,10 @@ def register_Ns3NdiscCache_methods(root_module, cls):
cls.add_method('Lookup',
'ns3::NdiscCache::Entry *',
[param('ns3::Ipv6Address', 'dst')])
## ndisc-cache.h (module 'internet'): void ns3::NdiscCache::PrintNdiscCache(ns3::Ptr<ns3::OutputStreamWrapper> stream) [member function]
cls.add_method('PrintNdiscCache',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')])
## ndisc-cache.h (module 'internet'): void ns3::NdiscCache::Remove(ns3::NdiscCache::Entry * entry) [member function]
cls.add_method('Remove',
'void',

View File

@@ -2804,6 +2804,26 @@ def register_Ns3Ipv4RoutingHelper_methods(root_module, cls):
'ns3::Ptr< ns3::Ipv4RoutingProtocol >',
[param('ns3::Ptr< ns3::Node >', 'node')],
is_pure_virtual=True, is_const=True, is_virtual=True)
## ipv4-routing-helper.h (module 'internet'): void ns3::Ipv4RoutingHelper::PrintNeighborCacheAllAt(ns3::Time printTime, ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintNeighborCacheAllAt',
'void',
[param('ns3::Time', 'printTime'), param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')],
is_const=True)
## ipv4-routing-helper.h (module 'internet'): void ns3::Ipv4RoutingHelper::PrintNeighborCacheAllEvery(ns3::Time printInterval, ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintNeighborCacheAllEvery',
'void',
[param('ns3::Time', 'printInterval'), param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')],
is_const=True)
## ipv4-routing-helper.h (module 'internet'): void ns3::Ipv4RoutingHelper::PrintNeighborCacheAt(ns3::Time printTime, ns3::Ptr<ns3::Node> node, ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintNeighborCacheAt',
'void',
[param('ns3::Time', 'printTime'), param('ns3::Ptr< ns3::Node >', 'node'), param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')],
is_const=True)
## ipv4-routing-helper.h (module 'internet'): void ns3::Ipv4RoutingHelper::PrintNeighborCacheEvery(ns3::Time printInterval, ns3::Ptr<ns3::Node> node, ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintNeighborCacheEvery',
'void',
[param('ns3::Time', 'printInterval'), param('ns3::Ptr< ns3::Node >', 'node'), param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')],
is_const=True)
## ipv4-routing-helper.h (module 'internet'): void ns3::Ipv4RoutingHelper::PrintRoutingTableAllAt(ns3::Time printTime, ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintRoutingTableAllAt',
'void',
@@ -3508,6 +3528,26 @@ def register_Ns3Ipv6RoutingHelper_methods(root_module, cls):
'ns3::Ptr< ns3::Ipv6RoutingProtocol >',
[param('ns3::Ptr< ns3::Node >', 'node')],
is_pure_virtual=True, is_const=True, is_virtual=True)
## ipv6-routing-helper.h (module 'internet'): void ns3::Ipv6RoutingHelper::PrintNeighborCacheAllAt(ns3::Time printTime, ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintNeighborCacheAllAt',
'void',
[param('ns3::Time', 'printTime'), param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')],
is_const=True)
## ipv6-routing-helper.h (module 'internet'): void ns3::Ipv6RoutingHelper::PrintNeighborCacheAllEvery(ns3::Time printInterval, ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintNeighborCacheAllEvery',
'void',
[param('ns3::Time', 'printInterval'), param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')],
is_const=True)
## ipv6-routing-helper.h (module 'internet'): void ns3::Ipv6RoutingHelper::PrintNeighborCacheAt(ns3::Time printTime, ns3::Ptr<ns3::Node> node, ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintNeighborCacheAt',
'void',
[param('ns3::Time', 'printTime'), param('ns3::Ptr< ns3::Node >', 'node'), param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')],
is_const=True)
## ipv6-routing-helper.h (module 'internet'): void ns3::Ipv6RoutingHelper::PrintNeighborCacheEvery(ns3::Time printInterval, ns3::Ptr<ns3::Node> node, ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintNeighborCacheEvery',
'void',
[param('ns3::Time', 'printInterval'), param('ns3::Ptr< ns3::Node >', 'node'), param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')],
is_const=True)
## ipv6-routing-helper.h (module 'internet'): void ns3::Ipv6RoutingHelper::PrintRoutingTableAllAt(ns3::Time printTime, ns3::Ptr<ns3::OutputStreamWrapper> stream) const [member function]
cls.add_method('PrintRoutingTableAllAt',
'void',
@@ -4269,10 +4309,10 @@ def register_Ns3PcapHelper_methods(root_module, cls):
cls.add_constructor([param('ns3::PcapHelper const &', 'arg0')])
## trace-helper.h (module 'network'): ns3::PcapHelper::PcapHelper() [constructor]
cls.add_constructor([])
## trace-helper.h (module 'network'): ns3::Ptr<ns3::PcapFileWrapper> ns3::PcapHelper::CreateFile(std::string filename, std::_Ios_Openmode filemode, uint32_t dataLinkType, uint32_t snapLen=65535, int32_t tzCorrection=0) [member function]
## trace-helper.h (module 'network'): ns3::Ptr<ns3::PcapFileWrapper> ns3::PcapHelper::CreateFile(std::string filename, std::_Ios_Openmode filemode, uint32_t dataLinkType, uint32_t snapLen=std::numeric_limits<unsigned int>::max(), int32_t tzCorrection=0) [member function]
cls.add_method('CreateFile',
'ns3::Ptr< ns3::PcapFileWrapper >',
[param('std::string', 'filename'), param('std::_Ios_Openmode', 'filemode'), param('uint32_t', 'dataLinkType'), param('uint32_t', 'snapLen', default_value='65535'), param('int32_t', 'tzCorrection', default_value='0')])
[param('std::string', 'filename'), param('std::_Ios_Openmode', 'filemode'), param('uint32_t', 'dataLinkType'), param('uint32_t', 'snapLen', default_value='std::numeric_limits<unsigned int>::max()'), param('int32_t', 'tzCorrection', default_value='0')])
## trace-helper.h (module 'network'): std::string ns3::PcapHelper::GetFilenameFromDevice(std::string prefix, ns3::Ptr<ns3::NetDevice> device, bool useObjectNames=true) [member function]
cls.add_method('GetFilenameFromDevice',
'std::string',
@@ -5276,7 +5316,6 @@ def register_Ns3Empty_methods(root_module, cls):
return
def register_Ns3Int64x64_t_methods(root_module, cls):
cls.add_binary_comparison_operator('<=')
cls.add_binary_comparison_operator('!=')
cls.add_inplace_numeric_operator('+=', param('ns3::int64x64_t const &', u'right'))
cls.add_binary_numeric_operator('*', root_module['ns3::int64x64_t'], root_module['ns3::int64x64_t'], param('ns3::int64x64_t const &', u'right'))
@@ -5290,6 +5329,7 @@ def register_Ns3Int64x64_t_methods(root_module, cls):
cls.add_inplace_numeric_operator('-=', param('ns3::int64x64_t const &', u'right'))
cls.add_inplace_numeric_operator('/=', param('ns3::int64x64_t const &', u'right'))
cls.add_output_stream_operator()
cls.add_binary_comparison_operator('<=')
cls.add_binary_comparison_operator('==')
cls.add_binary_comparison_operator('>=')
## int64x64-double.h (module 'core'): ns3::int64x64_t::int64x64_t() [constructor]
@@ -10058,7 +10098,6 @@ def register_Ns3TcpWestwood_methods(root_module, cls):
return
def register_Ns3Time_methods(root_module, cls):
cls.add_binary_comparison_operator('<=')
cls.add_binary_comparison_operator('!=')
cls.add_inplace_numeric_operator('+=', param('ns3::Time const &', u'right'))
cls.add_binary_numeric_operator('*', root_module['ns3::Time'], root_module['ns3::Time'], param('int64_t const &', u'right'))
@@ -10069,6 +10108,7 @@ def register_Ns3Time_methods(root_module, cls):
cls.add_binary_comparison_operator('>')
cls.add_inplace_numeric_operator('-=', param('ns3::Time const &', u'right'))
cls.add_output_stream_operator()
cls.add_binary_comparison_operator('<=')
cls.add_binary_comparison_operator('==')
cls.add_binary_comparison_operator('>=')
## nstime.h (module 'core'): ns3::Time::Time() [constructor]
@@ -10761,6 +10801,10 @@ def register_Ns3ArpCache_methods(root_module, cls):
cls.add_method('Lookup',
'ns3::ArpCache::Entry *',
[param('ns3::Ipv4Address', 'destination')])
## arp-cache.h (module 'internet'): void ns3::ArpCache::PrintArpCache(ns3::Ptr<ns3::OutputStreamWrapper> stream) [member function]
cls.add_method('PrintArpCache',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')])
## arp-cache.h (module 'internet'): void ns3::ArpCache::SetAliveTimeout(ns3::Time aliveTimeout) [member function]
cls.add_method('SetAliveTimeout',
'void',
@@ -13640,6 +13684,11 @@ def register_Ns3Ipv6Interface_methods(root_module, cls):
'uint32_t',
[],
is_const=True)
## ipv6-interface.h (module 'internet'): ns3::Ptr<ns3::NdiscCache> ns3::Ipv6Interface::GetNdiscCache() const [member function]
cls.add_method('GetNdiscCache',
'ns3::Ptr< ns3::NdiscCache >',
[],
is_const=True)
## ipv6-interface.h (module 'internet'): uint16_t ns3::Ipv6Interface::GetReachableTime() const [member function]
cls.add_method('GetReachableTime',
'uint16_t',
@@ -14483,6 +14532,10 @@ def register_Ns3NdiscCache_methods(root_module, cls):
cls.add_method('Lookup',
'ns3::NdiscCache::Entry *',
[param('ns3::Ipv6Address', 'dst')])
## ndisc-cache.h (module 'internet'): void ns3::NdiscCache::PrintNdiscCache(ns3::Ptr<ns3::OutputStreamWrapper> stream) [member function]
cls.add_method('PrintNdiscCache',
'void',
[param('ns3::Ptr< ns3::OutputStreamWrapper >', 'stream')])
## ndisc-cache.h (module 'internet'): void ns3::NdiscCache::Remove(ns3::NdiscCache::Entry * entry) [member function]
cls.add_method('Remove',
'void',

View File

@@ -23,6 +23,10 @@
#include "ns3/simulator.h"
#include "ns3/ipv4-routing-protocol.h"
#include "ns3/ipv4-list-routing.h"
#include "ns3/ipv4-l3-protocol.h"
#include "ns3/ipv4-interface.h"
#include "ns3/arp-cache.h"
#include "ns3/names.h"
#include "ipv4-routing-helper.h"
namespace ns3 {
@@ -82,4 +86,93 @@ Ipv4RoutingHelper::PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStr
Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintEvery, this, printInterval, node, stream);
}
void
Ipv4RoutingHelper::PrintNeighborCacheAllAt (Time printTime, Ptr<OutputStreamWrapper> stream) const
{
for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
{
Ptr<Node> node = NodeList::GetNode (i);
Simulator::Schedule (printTime, &Ipv4RoutingHelper::PrintArpCache, this, node, stream);
}
}
void
Ipv4RoutingHelper::PrintNeighborCacheAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream) const
{
for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
{
Ptr<Node> node = NodeList::GetNode (i);
Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintArpCacheEvery, this, printInterval, node, stream);
}
}
void
Ipv4RoutingHelper::PrintNeighborCacheAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
{
Simulator::Schedule (printTime, &Ipv4RoutingHelper::PrintArpCache, this, node, stream);
}
void
Ipv4RoutingHelper::PrintNeighborCacheEvery (Time printInterval,Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
{
Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintArpCacheEvery, this, printInterval, node, stream);
}
void
Ipv4RoutingHelper::PrintArpCache (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
{
std::ostream* os = stream->GetStream ();
*os << "ARP Cache of node ";
std::string found = Names::FindName (node);
if (Names::FindName (node) != "")
{
*os << found;
}
else
{
*os << static_cast<int> (node->GetId ());
}
*os << " at time " << Simulator::Now ().GetSeconds () << "\n";
Ptr<Ipv4L3Protocol> ipv4 = node->GetObject<Ipv4L3Protocol> ();
for (uint32_t i=0; i<ipv4->GetNInterfaces(); i++)
{
Ptr<ArpCache> arpCache = ipv4->GetInterface (i)->GetArpCache ();
if (arpCache)
{
arpCache->PrintArpCache (stream);
}
}
}
void
Ipv4RoutingHelper::PrintArpCacheEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
{
std::ostream* os = stream->GetStream ();
*os << "ARP Cache of node ";
std::string found = Names::FindName (node);
if (Names::FindName (node) != "")
{
*os << found;
}
else
{
*os << static_cast<int> (node->GetId ());
}
*os << " at time " << Simulator::Now ().GetSeconds () << "\n";
Ptr<Ipv4L3Protocol> ipv4 = node->GetObject<Ipv4L3Protocol> ();
for (uint32_t i=0; i<ipv4->GetNInterfaces(); i++)
{
Ptr<ArpCache> arpCache = ipv4->GetInterface (i)->GetArpCache ();
if (arpCache)
{
arpCache->PrintArpCache (stream);
}
}
Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintArpCacheEvery, this, printInterval, node, stream);
}
} // namespace ns3

View File

@@ -109,6 +109,68 @@ public:
*/
void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
/**
* \brief prints the neighbor cache of all nodes at a particular time.
* \param printTime the time at which the neighbor cache is supposed to be printed.
* \param stream The output stream object to use
*
* This method calls the PrintArpCache() method of the
* ArpCache associated with each Ipv4Interface stored in the Ipv4 object, for all nodes at the
* specified time. The output format is similar to:
* \verbatim
10.1.1.2 dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
\endverbatim
* Note that the MAC address is printed as "type"-"size"-"actual address"
*/
void PrintNeighborCacheAllAt (Time printTime, Ptr<OutputStreamWrapper> stream) const;
/**
* \brief prints the neighbor cache of all nodes at regular intervals specified by user.
* \param printInterval the time interval for which the neighbor cache is supposed to be printed.
* \param stream The output stream object to use
*
* This method calls the PrintArpCache() method of the
* ArpCache associated with each Ipv4Interface stored in the Ipv4 object, for all nodes at the
* specified time. The output format is similar to:
* \verbatim
10.1.1.2 dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
\endverbatim
* Note that the MAC address is printed as "type"-"size"-"actual address"
*/
void PrintNeighborCacheAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream) const;
/**
* \brief prints the neighbor cache of a node at a particular time.
* \param printTime the time at which the neighbor cache is supposed to be printed.
* \param node The node ptr for which we need the neighbor cache to be printed
* \param stream The output stream object to use
*
* This method calls the PrintArpCache() method of the
* ArpCache associated with each Ipv4Interface stored in the Ipv4 object, for all nodes at the
* specified time. The output format is similar to:
* \verbatim
10.1.1.2 dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
\endverbatim
* Note that the MAC address is printed as "type"-"size"-"actual address"
*/
void PrintNeighborCacheAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
/**
* \brief prints the neighbor cache of a node at regular intervals specified by user.
* \param printInterval the time interval for which the neighbor cache is supposed to be printed.
* \param node The node ptr for which we need the neighbor cache to be printed
* \param stream The output stream object to use
*
* This method calls the PrintArpCache() method of the
* ArpCache associated with each Ipv4Interface stored in the Ipv4 object, for all nodes at the
* specified time. The output format is similar to:
* \verbatim
10.1.1.2 dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
\endverbatim
* Note that the MAC address is printed as "type"-"size"-"actual address"
*/
void PrintNeighborCacheEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
/**
* \brief Request a specified routing protocol &lt;T&gt; from Ipv4RoutingProtocol protocol
*
@@ -130,7 +192,7 @@ private:
* \param stream The output stream object to use
*
* This method calls the PrintRoutingTable() method of the
* Ipv6RoutingProtocol stored in the Ipv6 object;
* Ipv4RoutingProtocol stored in the Ipv4 object;
* the output format is routing protocol-specific.
*/
void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
@@ -144,10 +206,45 @@ private:
* \param stream The output stream object to use
*
* This method calls the PrintRoutingTable() method of the
* Ipv6RoutingProtocol stored in the Ipv6 object, for the selected node
* Ipv4RoutingProtocol stored in the Ipv4 object, for the selected node
* at the specified interval; the output format is routing protocol-specific.
*/
void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
/**
* \internal
*
* \brief prints the neighbor cache of a node.
* \param node The node ptr for which we need the neighbor cache to be printed
* \param stream The output stream object to use
*
* This method calls the PrintArpCache() method of the
* ArpCache associated with each Ipv4Interface stored in the Ipv4 object, for all nodes at the
* specified time. The output format is similar to:
* \verbatim
10.1.1.2 dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
\endverbatim
* Note that the MAC address is printed as "type"-"size"-"actual address"
*/
void PrintArpCache (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
/**
* \internal
*
* \brief prints the neighbor cache of a node at regular intervals specified by user.
* \param printInterval the time interval for which the neighbor cache is supposed to be printed.
* \param node The node ptr for which we need the neighbor cache to be printed
* \param stream The output stream object to use
*
* This method calls the PrintArpCache() method of the
* ArpCache associated with each Ipv4Interface stored in the Ipv4 object, for all nodes at the
* specified time. The output format is similar to:
* \verbatim
10.1.1.2 dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
\endverbatim
* Note that the MAC address is printed as "type"-"size"-"actual address"
*/
void PrintArpCacheEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
};

View File

@@ -23,6 +23,10 @@
#include "ns3/simulator.h"
#include "ns3/ipv6-routing-protocol.h"
#include "ns3/ipv6-list-routing.h"
#include "ns3/ipv6-l3-protocol.h"
#include "ns3/ipv6-interface.h"
#include "ns3/ndisc-cache.h"
#include "ns3/names.h"
#include "ipv6-routing-helper.h"
namespace ns3 {
@@ -82,4 +86,93 @@ Ipv6RoutingHelper::PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStr
Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintEvery, this, printInterval, node, stream);
}
void
Ipv6RoutingHelper::PrintNeighborCacheAllAt (Time printTime, Ptr<OutputStreamWrapper> stream) const
{
for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
{
Ptr<Node> node = NodeList::GetNode (i);
Simulator::Schedule (printTime, &Ipv6RoutingHelper::PrintNdiscCache, this, node, stream);
}
}
void
Ipv6RoutingHelper::PrintNeighborCacheAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream) const
{
for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
{
Ptr<Node> node = NodeList::GetNode (i);
Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintNdiscCacheEvery, this, printInterval, node, stream);
}
}
void
Ipv6RoutingHelper::PrintNeighborCacheAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
{
Simulator::Schedule (printTime, &Ipv6RoutingHelper::PrintNdiscCache, this, node, stream);
}
void
Ipv6RoutingHelper::PrintNeighborCacheEvery (Time printInterval,Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
{
Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintNdiscCacheEvery, this, printInterval, node, stream);
}
void
Ipv6RoutingHelper::PrintNdiscCache (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
{
std::ostream* os = stream->GetStream ();
*os << "NDISC Cache of node ";
std::string found = Names::FindName (node);
if (Names::FindName (node) != "")
{
*os << found;
}
else
{
*os << static_cast<int> (node->GetId ());
}
*os << " at time " << Simulator::Now ().GetSeconds () << "\n";
Ptr<Ipv6L3Protocol> ipv6 = node->GetObject<Ipv6L3Protocol> ();
for (uint32_t i=0; i<ipv6->GetNInterfaces(); i++)
{
Ptr<NdiscCache> ndiscCache = ipv6->GetInterface (i)->GetNdiscCache ();
if (ndiscCache)
{
ndiscCache->PrintNdiscCache (stream);
}
}
}
void
Ipv6RoutingHelper::PrintNdiscCacheEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const
{
std::ostream* os = stream->GetStream ();
*os << "NDISC Cache of node ";
std::string found = Names::FindName (node);
if (Names::FindName (node) != "")
{
*os << found;
}
else
{
*os << static_cast<int> (node->GetId ());
}
*os << " at time " << Simulator::Now ().GetSeconds () << "\n";
Ptr<Ipv6L3Protocol> ipv6 = node->GetObject<Ipv6L3Protocol> ();
for (uint32_t i=0; i<ipv6->GetNInterfaces(); i++)
{
Ptr<NdiscCache> ndiscCache = ipv6->GetInterface (i)->GetNdiscCache ();
if (ndiscCache)
{
ndiscCache->PrintNdiscCache (stream);
}
}
Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintNdiscCacheEvery, this, printInterval, node, stream);
}
} // namespace ns3

View File

@@ -111,6 +111,68 @@ public:
*/
void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
/**
* \brief prints the neighbor cache of all nodes at a particular time.
* \param printTime the time at which the neighbor cache is supposed to be printed.
* \param stream The output stream object to use
*
* This method calls the PrintNdiscCache() method of the
* NdiscCache associated with each Ipv6Interface stored in the Ipv6 object, for all nodes at the
* specified time. The output format is similar to:
* \verbatim
2001:db8::f00d:beef:cafe dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
\endverbatim
* Note that the MAC address is printed as "type"-"size"-"actual address"
*/
void PrintNeighborCacheAllAt (Time printTime, Ptr<OutputStreamWrapper> stream) const;
/**
* \brief prints the neighbor cache of all nodes at regular intervals specified by user.
* \param printInterval the time interval for which the neighbor cache is supposed to be printed.
* \param stream The output stream object to use
*
* This method calls the PrintNdiscCache() method of the
* NdiscCache associated with each Ipv6Interface stored in the Ipv6 object, for all nodes at the
* specified time. The output format is similar to:
* \verbatim
2001:db8::f00d:beef:cafe dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
\endverbatim
* Note that the MAC address is printed as "type"-"size"-"actual address"
*/
void PrintNeighborCacheAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream) const;
/**
* \brief prints the neighbor cache of a node at a particular time.
* \param printTime the time at which the neighbor cache is supposed to be printed.
* \param node The node ptr for which we need the neighbor cache to be printed
* \param stream The output stream object to use
*
* This method calls the PrintNdiscCache() method of the
* NdiscCache associated with each Ipv6Interface stored in the Ipv6 object, for all nodes at the
* specified time. The output format is similar to:
* \verbatim
2001:db8::f00d:beef:cafe dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
\endverbatim
* Note that the MAC address is printed as "type"-"size"-"actual address"
*/
void PrintNeighborCacheAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
/**
* \brief prints the neighbor cache of a node at regular intervals specified by user.
* \param printInterval the time interval for which the neighbor cache is supposed to be printed.
* \param node The node ptr for which we need the neighbor cache to be printed
* \param stream The output stream object to use
*
* This method calls the PrintNdiscCache() method of the
* NdiscCache associated with each Ipv6Interface stored in the Ipv6 object, for all nodes at the
* specified time. The output format is similar to:
* \verbatim
2001:db8::f00d:beef:cafe dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
\endverbatim
* Note that the MAC address is printed as "type"-"size"-"actual address"
*/
void PrintNeighborCacheEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
/**
* \brief Request a specified routing protocol &lt;T&gt; from Ipv6RoutingProtocol protocol
*
@@ -150,6 +212,41 @@ private:
* at the specified interval; the output format is routing protocol-specific.
*/
void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
/**
* \internal
*
* \brief prints the neighbor cache of a node.
* \param node The node ptr for which we need the neighbor cache to be printed
* \param stream The output stream object to use
*
* This method calls the PrintNdiscCache() method of the
* NdiscCache associated with each Ipv6Interface stored in the Ipv6 object, for all nodes at the
* specified time. The output format is similar to:
* \verbatim
2001:db8::f00d:beef:cafe dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
\endverbatim
* Note that the MAC address is printed as "type"-"size"-"actual address"
*/
void PrintNdiscCache (Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
/**
* \internal
*
* \brief prints the neighbor cache of a node at regular intervals specified by user.
* \param printInterval the time interval for which the neighbor cache is supposed to be printed.
* \param node The node ptr for which we need the neighbor cache to be printed
* \param stream The output stream object to use
*
* This method calls the PrintNdiscCache() method of the
* NdiscCache associated with each Ipv6Interface stored in the Ipv6 object, for all nodes at the
* specified time. The output format is similar to:
* \verbatim
2001:db8::f00d:beef:cafe dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
\endverbatim
* Note that the MAC address is printed as "type"-"size"-"actual address"
*/
void PrintNdiscCacheEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream) const;
};
/**

View File

@@ -24,6 +24,7 @@
#include "ns3/log.h"
#include "ns3/node.h"
#include "ns3/trace-source-accessor.h"
#include "ns3/names.h"
#include "arp-cache.h"
#include "arp-header.h"
@@ -242,6 +243,42 @@ ArpCache::Flush (void)
}
}
void
ArpCache::PrintArpCache (Ptr<OutputStreamWrapper> stream)
{
NS_LOG_FUNCTION (this << stream);
std::ostream* os = stream->GetStream ();
for (CacheI i = m_arpCache.begin (); i != m_arpCache.end (); i++)
{
*os << i->first << " dev ";
std::string found = Names::FindName (m_device);
if (Names::FindName (m_device) != "")
{
*os << found;
}
else
{
*os << static_cast<int> (m_device->GetIfIndex ());
}
*os << " lladdr " << i->second->GetMacAddress ();
if (i->second->IsAlive ())
{
*os << " REACHABLE\n";
}
else if (i->second->IsWaitReply ())
{
*os << " DELAY\n";
}
else
{
*os << " STALE\n";
}
}
}
ArpCache::Entry *
ArpCache::Lookup (Ipv4Address to)
{
@@ -346,7 +383,6 @@ Address
ArpCache::Entry::GetMacAddress (void) const
{
NS_LOG_FUNCTION (this);
NS_ASSERT (m_state == ALIVE);
return m_macAddress;
}
Ipv4Address

View File

@@ -33,6 +33,7 @@
#include "ns3/object.h"
#include "ns3/traced-callback.h"
#include "ns3/sgi-hashmap.h"
#include "ns3/output-stream-wrapper.h"
namespace ns3 {
@@ -76,8 +77,8 @@ public:
/**
* \brief Set the NetDevice and Ipv4Interface associated with the ArpCache
*
* \param device The hardware NetDevice associated with this ARP chache
* \param interface the Ipv4Interface associated with this ARP chache
* \param device The hardware NetDevice associated with this ARP cache
* \param interface the Ipv4Interface associated with this ARP cache
*/
void SetDevice (Ptr<NetDevice> device, Ptr<Ipv4Interface> interface);
/**
@@ -154,6 +155,13 @@ public:
*/
void Flush (void);
/**
* \brief Print the ARP cache entries
*
* \param stream the ostream the ARP cache entries is printed to
*/
void PrintArpCache (Ptr<OutputStreamWrapper> stream);
/**
* \brief A record that that holds information about an ArpCache entry
*/

View File

@@ -78,6 +78,7 @@ public:
* \returns the underlying NetDevice. This method cannot return zero.
*/
Ptr<NetDevice> GetDevice (void) const;
/**
* \return ARP cache used by this interface
*/

View File

@@ -505,5 +505,11 @@ void Ipv6Interface::SetNsDadUid (Ipv6Address address, uint32_t uid)
/* not found, maybe address has expired */
}
Ptr<NdiscCache> Ipv6Interface::GetNdiscCache () const
{
NS_LOG_FUNCTION (this);
return m_ndCache;
}
} /* namespace ns3 */

View File

@@ -250,6 +250,12 @@ public:
*/
void SetNsDadUid (Ipv6Address address, uint32_t uid);
/**
* \return NDISC cache used by this interface
*/
Ptr<NdiscCache> GetNdiscCache () const;
protected:
/**
* \brief Dispose this object.

View File

@@ -21,6 +21,7 @@
#include "ns3/log.h"
#include "ns3/uinteger.h"
#include "ns3/node.h"
#include "ns3/names.h"
#include "ipv6-l3-protocol.h"
#include "icmpv6-l4-protocol.h"
@@ -149,6 +150,49 @@ uint32_t NdiscCache::GetUnresQlen ()
return m_unresQlen;
}
void NdiscCache::PrintNdiscCache (Ptr<OutputStreamWrapper> stream)
{
NS_LOG_FUNCTION (this << stream);
std::ostream* os = stream->GetStream ();
for (CacheI i = m_ndCache.begin (); i != m_ndCache.end (); i++)
{
*os << i->first << " dev ";
std::string found = Names::FindName (m_device);
if (Names::FindName (m_device) != "")
{
*os << found;
}
else
{
*os << static_cast<int> (m_device->GetIfIndex ());
}
*os << " lladdr " << i->second->GetMacAddress ();
if (i->second->IsReachable ())
{
*os << " REACHABLE\n";
}
else if (i->second->IsDelay ())
{
*os << " DELAY\n";
}
else if (i->second->IsIncomplete ())
{
*os << " INCOMPLETE\n";
}
else if (i->second->IsProbe ())
{
*os << " PROBE\n";
}
else
{
*os << " STALE\n";
}
}
}
NdiscCache::Entry::Entry (NdiscCache* nd)
: m_ndCache (nd),
m_waiting (),

View File

@@ -22,7 +22,6 @@
#define NDISC_CACHE_H
#include <stdint.h>
#include <list>
#include "ns3/packet.h"
@@ -32,6 +31,7 @@
#include "ns3/ptr.h"
#include "ns3/timer.h"
#include "ns3/sgi-hashmap.h"
#include "ns3/output-stream-wrapper.h"
namespace ns3
{
@@ -124,6 +124,13 @@ public:
*/
void SetDevice (Ptr<NetDevice> device, Ptr<Ipv6Interface> interface);
/**
* \brief Print the NDISC cache entries
*
* \param stream the ostream the NDISC cache entries is printed to
*/
void PrintNdiscCache (Ptr<OutputStreamWrapper> stream);
/**
* \class Entry
* \brief A record that holds information about an NdiscCache entry.