NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
API Documentation
ndn::net::NetworkMonitor Class Reference

Network interface monitor. More...

#include <network-monitor.hpp>

Inheritance diagram for ndn::net::NetworkMonitor:
Collaboration diagram for ndn::net::NetworkMonitor:

Classes

class  Error
 

Public Types

enum  Capability : uint32_t {
  CAP_NONE = 0, CAP_ENUM = 1 << 0, CAP_IF_ADD_REMOVE = 1 << 1, CAP_STATE_CHANGE = 1 << 2,
  CAP_MTU_CHANGE = 1 << 3, CAP_ADDR_ADD_REMOVE = 1 << 4
}
 

Public Member Functions

 NetworkMonitor (boost::asio::io_service &io)
 Construct instance, request enumeration of all network interfaces, and start monitoring for network state changes. More...
 
uint32_t getCapabilities () const
 Returns a bitwise OR'ed set of Capability flags supported on the current platform. More...
 
shared_ptr< const NetworkInterfacegetNetworkInterface (const std::string &ifname) const
 Returns the NetworkInterface with the given name, or nullptr if it does not exist. More...
 
std::vector< shared_ptr< const NetworkInterface > > listNetworkInterfaces () const
 Lists all network interfaces currently available on the system. More...
 

Public Attributes

util::Signal< NetworkMonitorImpl > & onEnumerationCompleted
 Fires when network interfaces enumeration is complete. More...
 
util::Signal< NetworkMonitorImpl, shared_ptr< const NetworkInterface > > & onInterfaceAdded
 Fires when a new interface is added. More...
 
util::Signal< NetworkMonitorImpl, shared_ptr< const NetworkInterface > > & onInterfaceRemoved
 Fires when an interface is removed. More...
 
util::Signal< NetworkMonitorImpl > & onNetworkStateChanged
 

Protected Member Functions

 NetworkMonitor (unique_ptr< NetworkMonitorImpl > impl)
 
NetworkMonitorImplgetImpl ()
 

Detailed Description

Network interface monitor.

Maintains an up-to-date view of every system network interface and notifies when an interface is added or removed.

Note
The implementation of this class is highly platform dependent, and not all platform backends provide all the features. On macOS, SystemConfiguration and CFNotificationCenterAddObserver are used (notification of MTU change is not supported). On Linux, rtnetlink notifications from the kernel are used. See getCapabilities() for the detailed set of capabilities supported by the platform backend currently in use.

Definition at line 50 of file network-monitor.hpp.

Member Enumeration Documentation

◆ Capability

Enumerator
CAP_NONE 

NetworkMonitor is not supported and is a no-op.

CAP_ENUM 

listNetworkInterfaces() and getNetworkInterface() are supported

CAP_IF_ADD_REMOVE 

NetworkMonitor onInterfaceAdded and onInterfaceRemoved signals are supported.

CAP_STATE_CHANGE 

NetworkInterface onStateChanged signal is supported.

CAP_MTU_CHANGE 

NetworkInterface onMtuChanged signal is supported.

CAP_ADDR_ADD_REMOVE 

NetworkInterface onAddressAdded and onAddressRemoved signals are supported.

Definition at line 73 of file network-monitor.hpp.

Constructor & Destructor Documentation

◆ NetworkMonitor() [1/2]

ndn::net::NetworkMonitor::NetworkMonitor ( boost::asio::io_service &  io)
explicit

Construct instance, request enumeration of all network interfaces, and start monitoring for network state changes.

Parameters
ioio_service instance that will dispatch events
Exceptions
Errorerror starting monitoring

Definition at line 42 of file network-monitor.cpp.

◆ NetworkMonitor() [2/2]

ndn::net::NetworkMonitor::NetworkMonitor ( unique_ptr< NetworkMonitorImpl impl)
explicitprotected

Definition at line 47 of file network-monitor.cpp.

Member Function Documentation

◆ getCapabilities()

uint32_t ndn::net::NetworkMonitor::getCapabilities ( ) const

Returns a bitwise OR'ed set of Capability flags supported on the current platform.

Definition at line 57 of file network-monitor.cpp.

◆ getNetworkInterface()

shared_ptr< const NetworkInterface > ndn::net::NetworkMonitor::getNetworkInterface ( const std::string &  ifname) const

Returns the NetworkInterface with the given name, or nullptr if it does not exist.

Definition at line 63 of file network-monitor.cpp.

◆ listNetworkInterfaces()

std::vector< shared_ptr< const NetworkInterface > > ndn::net::NetworkMonitor::listNetworkInterfaces ( ) const

Lists all network interfaces currently available on the system.

Warning
May return incomplete results if called before the onEnumerationCompleted signal has been emitted.

Definition at line 69 of file network-monitor.cpp.

◆ getImpl()

NetworkMonitorImpl& ndn::net::NetworkMonitor::getImpl ( )
inlineprotected

Definition at line 109 of file network-monitor.hpp.

Member Data Documentation

◆ onEnumerationCompleted

util::Signal<NetworkMonitorImpl>& ndn::net::NetworkMonitor::onEnumerationCompleted

Fires when network interfaces enumeration is complete.

Definition at line 121 of file network-monitor.hpp.

◆ onInterfaceAdded

util::Signal<NetworkMonitorImpl, shared_ptr<const NetworkInterface> >& ndn::net::NetworkMonitor::onInterfaceAdded

Fires when a new interface is added.

Definition at line 124 of file network-monitor.hpp.

◆ onInterfaceRemoved

util::Signal<NetworkMonitorImpl, shared_ptr<const NetworkInterface> >& ndn::net::NetworkMonitor::onInterfaceRemoved

Fires when an interface is removed.

Note
The NetworkInterface object is no longer present in the internal list of network interfaces when this signal is emitted.

Definition at line 131 of file network-monitor.hpp.

◆ onNetworkStateChanged

util::Signal<NetworkMonitorImpl>& ndn::net::NetworkMonitor::onNetworkStateChanged
Deprecated:
Only for backward compatibility

Definition at line 134 of file network-monitor.hpp.


The documentation for this class was generated from the following files: