NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.3: NDN, CCN, CCNx, content centric networks
API Documentation
nfd::UdpFactory Class Reference

#include <udp-factory.hpp>

Inheritance diagram for nfd::UdpFactory:
Collaboration diagram for nfd::UdpFactory:

Classes

class  Error
 Exception of UdpFactory. More...
 

Public Types

typedef std::map< udp::Endpoint, shared_ptr< Face > > MulticastFaceMap
 

Public Member Functions

shared_ptr< UdpChannelcreateChannel (const udp::Endpoint &localEndpoint, const time::seconds &timeout=time::seconds(600))
 Create UDP-based channel using udp::Endpoint. More...
 
shared_ptr< UdpChannelcreateChannel (const std::string &localIp, const std::string &localPort, const time::seconds &timeout=time::seconds(600))
 Create UDP-based channel using specified IP address and port number. More...
 
shared_ptr< FacecreateMulticastFace (const udp::Endpoint &localEndpoint, const udp::Endpoint &multicastEndpoint, const std::string &networkInterfaceName="")
 Create MulticastUdpFace using udp::Endpoint. More...
 
shared_ptr< FacecreateMulticastFace (const std::string &localIp, const std::string &multicastIp, const std::string &multicastPort, const std::string &networkInterfaceName="")
 
const MulticastFaceMapgetMulticastFaces () const
 Get map of configured multicast faces. More...
 
virtual void createFace (const FaceUri &uri, ndn::nfd::FacePersistency persistency, bool wantLocalFieldsEnabled, const FaceCreatedCallback &onCreated, const FaceCreationFailedCallback &onFailure) override
 Try to create Face using the supplied FaceUri. More...
 
virtual std::vector< shared_ptr< const Channel > > getChannels () const override
 

Detailed Description

Todo:
IPv6 multicast support not implemented

Definition at line 36 of file udp-factory.hpp.

Member Typedef Documentation

◆ MulticastFaceMap

typedef std::map<udp::Endpoint, shared_ptr<Face> > nfd::UdpFactory::MulticastFaceMap

Definition at line 52 of file udp-factory.hpp.

Member Function Documentation

◆ createChannel() [1/2]

shared_ptr< UdpChannel > nfd::UdpFactory::createChannel ( const udp::Endpoint localEndpoint,
const time::seconds &  timeout = time::seconds(600) 
)

Create UDP-based channel using udp::Endpoint.

udp::Endpoint is really an alias for boost::asio::ip::udp::endpoint.

If this method called twice with the same endpoint, only one channel will be created. The second call will just retrieve the existing channel.

If a multicast face is already active on the same local endpoint, the creation fails and an exception is thrown

Once a face is created, if it doesn't send/receive anything for a period of time equal to timeout, it will be destroyed

Todo:
this funcionality has to be implemented
Returns
always a valid pointer to a UdpChannel object, an exception is thrown if it cannot be created.
Exceptions
UdpFactory::Error
See also
http://www.boost.org/doc/libs/1_42_0/doc/html/boost_asio/reference/ip__udp/endpoint.html for details on ways to create udp::Endpoint

Definition at line 92 of file udp-factory.cpp.

References NFD_LOG_DEBUG.

Referenced by createChannel().

◆ createChannel() [2/2]

shared_ptr< UdpChannel > nfd::UdpFactory::createChannel ( const std::string &  localIp,
const std::string &  localPort,
const time::seconds &  timeout = time::seconds(600) 
)

Create UDP-based channel using specified IP address and port number.

This method is just a helper that converts a string representation of localIp and port to udp::Endpoint and calls the other createChannel overload.

If localHost is a IPv6 address of a specific device, it must be in the form: ip addressinterface name Example: fe80::5e96:9dff:fe7d:9c8den1 Otherwise, you can use ::

Exceptions
UdpChannel::Errorif the bind on the socket fails
UdpFactory::Error

Definition at line 121 of file udp-factory.cpp.

References createChannel().

◆ createMulticastFace() [1/2]

shared_ptr< Face > nfd::UdpFactory::createMulticastFace ( const udp::Endpoint localEndpoint,
const udp::Endpoint multicastEndpoint,
const std::string &  networkInterfaceName = "" 
)

Create MulticastUdpFace using udp::Endpoint.

udp::Endpoint is really an alias for boost::asio::ip::udp::endpoint.

The face will join the multicast group

If this method called twice with the same endpoint and group, only one face will be created. The second call will just retrieve the existing channel.

If an unicast face is already active on the same local NIC and port, the creation fails and an exception is thrown

Parameters
localEndpointlocal endpoint
multicastEndpointmulticast endpoint
networkInterfaceNamename of the network interface on which the face will be bound (Used only on multihomed linux machine with more than one MulticastUdpFace for the same multicast group. If specified, will requires CAP_NET_RAW capability) An empty string can be provided in other system or in linux machine with only one MulticastUdpFace per multicast group
Returns
always a valid pointer to a MulticastUdpFace object, an exception is thrown if it cannot be created.
Exceptions
UdpFactory::Error
See also
http://www.boost.org/doc/libs/1_42_0/doc/html/boost_asio/reference/ip__udp/endpoint.html for details on ways to create udp::Endpoint

Definition at line 130 of file udp-factory.cpp.

References nfd::connectFaceClosedSignal(), and nfd::getGlobalIoService().

Referenced by createMulticastFace().

◆ createMulticastFace() [2/2]

shared_ptr< Face > nfd::UdpFactory::createMulticastFace ( const std::string &  localIp,
const std::string &  multicastIp,
const std::string &  multicastPort,
const std::string &  networkInterfaceName = "" 
)

Definition at line 221 of file udp-factory.cpp.

References createMulticastFace().

◆ getMulticastFaces()

const UdpFactory::MulticastFaceMap & nfd::UdpFactory::getMulticastFaces ( ) const
inline

Get map of configured multicast faces.

Definition at line 197 of file udp-factory.hpp.

◆ createFace()

void nfd::UdpFactory::createFace ( const FaceUri uri,
ndn::nfd::FacePersistency  persistency,
bool  wantLocalFieldsEnabled,
const FaceCreatedCallback onCreated,
const FaceCreationFailedCallback onFailure 
)
overridevirtual

Try to create Face using the supplied FaceUri.

This method should automatically choose channel, based on supplied FaceUri and create face.

Parameters
uriremote URI of the new face
persistencypersistency of the new face
wantLocalFieldsEnabledwhether local fields should be enabled on the face
onCreatedcallback if face creation succeeds If a face with the same remote URI already exists, its persistency and LocalFieldsEnabled setting will not be modified.
onFailurecallback if face creation fails

Implements nfd::ProtocolFactory.

Definition at line 234 of file udp-factory.cpp.

References ndn::nfd::FACE_PERSISTENCY_ON_DEMAND, ndn::util::FaceUri::getHost(), ndn::util::FaceUri::getPort(), ndn::util::FaceUri::isCanonical(), and NFD_LOG_TRACE.

◆ getChannels()

std::vector< shared_ptr< const Channel > > nfd::UdpFactory::getChannels ( ) const
overridevirtual

Implements nfd::ProtocolFactory.

Definition at line 285 of file udp-factory.cpp.


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