A Transport that communicates on a UDP multicast group. More...
#include <daemon/face/multicast-udp-transport.hpp>
Classes | |
class | Error |
Public Types | |
using | addressing = Multicast |
using | Counters = TransportCounters |
Counters provided by a transport. More... | |
using | protocol = boost::asio::ip::udp |
Public Member Functions | |
MulticastUdpTransport (const boost::asio::ip::udp::endpoint &multicastGroup, boost::asio::ip::udp::socket &&recvSocket, boost::asio::ip::udp::socket &&sendSocket, ndn::nfd::LinkType linkType) | |
Creates a UDP-based transport for multicast communication. More... | |
bool | canChangePersistencyTo (ndn::nfd::FacePersistency newPersistency) const |
Check whether the persistency can be changed to newPersistency . More... | |
void | close () |
Request the transport to be closed. More... | |
virtual const Counters & | getCounters () const |
time::steady_clock::time_point | getExpirationTime () const noexcept |
Returns the expiration time of the transport. More... | |
const Face * | getFace () const noexcept |
Returns the Face to which this transport is attached. More... | |
const LinkService * | getLinkService () const noexcept |
Returns the LinkService to which this transport is attached. More... | |
LinkService * | getLinkService () noexcept |
Returns the LinkService to which this transport is attached. More... | |
ndn::nfd::LinkType | getLinkType () const noexcept |
Returns the link type of the transport. More... | |
FaceUri | getLocalUri () const noexcept |
Returns a FaceUri representing the local endpoint. More... | |
ssize_t | getMtu () const noexcept |
Returns the maximum payload size. More... | |
ndn::nfd::FacePersistency | getPersistency () const noexcept |
Returns the current persistency setting of the transport. More... | |
FaceUri | getRemoteUri () const noexcept |
Returns a FaceUri representing the remote endpoint. More... | |
ndn::nfd::FaceScope | getScope () const noexcept |
Returns whether the transport is local or non-local for scope control purposes. More... | |
ssize_t | getSendQueueCapacity () const noexcept |
Returns the capacity of the send queue (in bytes). More... | |
ssize_t | getSendQueueLength () final |
Returns the current send queue length of the transport (in octets). More... | |
TransportState | getState () const noexcept |
Returns the current transport state. More... | |
void | receiveDatagram (span< const uint8_t > buffer, const boost::system::error_code &error) |
Receive datagram, translate buffer into packet, deliver to parent class. More... | |
void | send (const Block &packet) |
Send a link-layer packet. More... | |
void | setFaceAndLinkService (Face &face, LinkService &service) noexcept |
Set Face and LinkService for this transport. More... | |
void | setPersistency (ndn::nfd::FacePersistency newPersistency) |
Changes the persistency setting of the transport. More... | |
Static Public Member Functions | |
static void | openRxSocket (boost::asio::ip::udp::socket &sock, const boost::asio::ip::udp::endpoint &multicastGroup, const boost::asio::ip::address &localAddress={}, const ndn::net::NetworkInterface *netif=nullptr) |
Opens and configures the receive-side socket. More... | |
static void | openTxSocket (boost::asio::ip::udp::socket &sock, const boost::asio::ip::udp::endpoint &localEndpoint, const ndn::net::NetworkInterface *netif=nullptr, bool enableLoopback=false) |
Opens and configures the transmit-side socket. More... | |
Public Attributes | |
signal::Signal< Transport, TransportState, TransportState > | afterStateChange |
Called when the transport state changes. More... | |
Protected Member Functions | |
virtual void | afterChangePersistency (ndn::nfd::FacePersistency oldPersistency) |
Invoked after the persistency has been changed. More... | |
virtual bool | canChangePersistencyToImpl (ndn::nfd::FacePersistency newPersistency) const |
Invoked by canChangePersistencyTo to perform the check. More... | |
void | handleReceive (const boost::system::error_code &error, size_t nBytesReceived) |
void | handleSend (const boost::system::error_code &error, size_t nBytesSent) |
bool | hasRecentlyReceived () const |
void | processErrorCode (const boost::system::error_code &error) |
void | receive (const Block &packet, const EndpointId &endpoint={}) |
Pass a received link-layer packet to the upper layer for further processing. More... | |
void | resetRecentlyReceived () |
void | setExpirationTime (const time::steady_clock::time_point &expirationTime) noexcept |
void | setLinkType (ndn::nfd::LinkType linkType) noexcept |
void | setLocalUri (const FaceUri &uri) noexcept |
void | setMtu (ssize_t mtu) noexcept |
void | setRemoteUri (const FaceUri &uri) noexcept |
void | setScope (ndn::nfd::FaceScope scope) noexcept |
void | setSendQueueCapacity (ssize_t sendQueueCapacity) noexcept |
void | setState (TransportState newState) |
Set transport state. More... | |
Protected Attributes | |
protocol::endpoint | m_sender |
protocol::socket | m_socket |
ByteCounter | nInBytes |
Total bytes received. More... | |
PacketCounter | nInPackets |
Count of incoming packets. More... | |
ByteCounter | nOutBytes |
Total bytes sent. More... | |
PacketCounter | nOutPackets |
Count of outgoing packets. More... | |
A Transport that communicates on a UDP multicast group.
Definition at line 41 of file multicast-udp-transport.hpp.
|
inherited |
Definition at line 53 of file datagram-transport.hpp.
|
inherited |
Counters provided by a transport.
Definition at line 128 of file transport.hpp.
|
inherited |
Definition at line 52 of file datagram-transport.hpp.
nfd::face::MulticastUdpTransport::MulticastUdpTransport | ( | const boost::asio::ip::udp::endpoint & | multicastGroup, |
boost::asio::ip::udp::socket && | recvSocket, | ||
boost::asio::ip::udp::socket && | sendSocket, | ||
ndn::nfd::LinkType | linkType | ||
) |
Creates a UDP-based transport for multicast communication.
multicastGroup | multicast group |
recvSocket | socket used to receive multicast packets |
sendSocket | socket used to send to the multicast group |
linkType | either ndn::nfd::LINK_TYPE_MULTI_ACCESS or ndn::nfd::LINK_TYPE_AD_HOC |
Definition at line 47 of file multicast-udp-transport.cpp.
|
protectedvirtualinherited |
Invoked after the persistency has been changed.
The base class implementation does nothing. When overridden in a subclass, the function should update internal states after persistency setting has been changed.
Reimplemented in nfd::face::UnicastUdpTransport, nfd::face::UnicastEthernetTransport, and nfd::face::TcpTransport.
Definition at line 170 of file transport.cpp.
|
inherited |
Check whether the persistency can be changed to newPersistency
.
This function serves as the external API, and invokes the protected function canChangePersistencyToImpl() to perform further checks if newPersistency
differs from the current persistency.
Definition at line 130 of file transport.cpp.
|
protectedvirtualinherited |
Invoked by canChangePersistencyTo to perform the check.
Base class implementation returns false.
newPersistency | the new persistency, guaranteed to be different from current persistency |
Reimplemented in nfd::face::UnicastUdpTransport, nfd::face::UnicastEthernetTransport, and nfd::face::TcpTransport.
Definition at line 146 of file transport.cpp.
|
inherited |
Request the transport to be closed.
This operation is effective only if transport is in UP or DOWN state, otherwise it has no effect. The transport changes state to CLOSING, and performs cleanup procedure. The state will be changed to CLOSED when cleanup is complete, which may happen synchronously or asynchronously.
Definition at line 67 of file transport.cpp.
|
inlinevirtualinherited |
Reimplemented in nfd::face::WebSocketTransport.
Definition at line 179 of file transport.hpp.
|
inlinenoexceptinherited |
Returns the expiration time of the transport.
time::steady_clock::time_point::max() | The transport has an indefinite lifetime. |
Definition at line 315 of file transport.hpp.
|
inlinenoexceptinherited |
Returns the Face to which this transport is attached.
Definition at line 155 of file transport.hpp.
|
inlinenoexceptinherited |
Returns the LinkService to which this transport is attached.
Definition at line 164 of file transport.hpp.
|
inlinenoexceptinherited |
Returns the LinkService to which this transport is attached.
Definition at line 173 of file transport.hpp.
|
inlinenoexceptinherited |
Returns the link type of the transport.
Definition at line 263 of file transport.hpp.
|
inlinenoexceptinherited |
Returns a FaceUri representing the local endpoint.
Definition at line 209 of file transport.hpp.
|
inlinenoexceptinherited |
Returns the maximum payload size.
MTU_UNLIMITED | The transport has no limit on payload size. |
This size is the maximum packet size that can be sent or received through this transport.
For a datagram-based transport, this is typically the Maximum Transmission Unit (MTU), after the overhead of headers introduced by the transport has been accounted for. For a stream-based transport, this is typically unlimited (MTU_UNLIMITED).
Definition at line 279 of file transport.hpp.
|
inlinenoexceptinherited |
Returns the current persistency setting of the transport.
Definition at line 236 of file transport.hpp.
|
inlinenoexceptinherited |
Returns a FaceUri representing the remote endpoint.
Definition at line 218 of file transport.hpp.
|
inlinenoexceptinherited |
Returns whether the transport is local or non-local for scope control purposes.
Definition at line 227 of file transport.hpp.
|
inlinenoexceptinherited |
Returns the capacity of the send queue (in bytes).
QUEUE_UNSUPPORTED | The transport does not support queue capacity retrieval. |
QUEUE_ERROR | The transport was unable to retrieve the queue capacity. |
Definition at line 290 of file transport.hpp.
|
finalvirtual |
Returns the current send queue length of the transport (in octets).
QUEUE_UNSUPPORTED | The transport does not support queue length retrieval. |
QUEUE_ERROR | The transport was unable to retrieve the queue length. |
Reimplemented from nfd::face::Transport.
Definition at line 77 of file multicast-udp-transport.cpp.
|
inlinenoexceptinherited |
Returns the current transport state.
Definition at line 300 of file transport.hpp.
|
protectedinherited |
Definition at line 83 of file datagram-transport.hpp.
|
protectedinherited |
Definition at line 80 of file datagram-transport.hpp.
|
protectedinherited |
Definition at line 89 of file datagram-transport.hpp.
|
static |
Opens and configures the receive-side socket.
Definition at line 136 of file multicast-udp-transport.cpp.
|
static |
Opens and configures the transmit-side socket.
Definition at line 163 of file multicast-udp-transport.cpp.
|
protectedinherited |
Definition at line 86 of file datagram-transport.hpp.
|
protectedinherited |
Pass a received link-layer packet to the upper layer for further processing.
packet | The received packet, must be a valid and well-formed TLV block |
endpoint | The source endpoint, optional for unicast transports |
Definition at line 101 of file transport.cpp.
|
inherited |
Receive datagram, translate buffer into packet, deliver to parent class.
Definition at line 70 of file datagram-transport.hpp.
|
protectedinherited |
Definition at line 92 of file datagram-transport.hpp.
|
inherited |
Send a link-layer packet.
packet | the packet to be sent, must be a valid and well-formed TLV block |
Definition at line 80 of file transport.cpp.
|
inlineprotectednoexceptinherited |
Definition at line 386 of file transport.hpp.
|
noexceptinherited |
Set Face and LinkService for this transport.
Definition at line 57 of file transport.cpp.
|
inlineprotectednoexceptinherited |
Definition at line 361 of file transport.hpp.
|
inlineprotectednoexceptinherited |
Definition at line 343 of file transport.hpp.
|
protectednoexceptinherited |
Definition at line 114 of file transport.cpp.
|
inherited |
Changes the persistency setting of the transport.
Definition at line 152 of file transport.cpp.
|
inlineprotectednoexceptinherited |
Definition at line 349 of file transport.hpp.
|
inlineprotectednoexceptinherited |
Definition at line 355 of file transport.hpp.
|
inlineprotectednoexceptinherited |
Definition at line 370 of file transport.hpp.
|
protectedinherited |
Set transport state.
Only the following transitions are valid: UP->DOWN, DOWN->UP, UP/DOWN->CLOSING/FAILED, CLOSING/FAILED->CLOSED
std::runtime_error | transition is invalid. |
Definition at line 175 of file transport.cpp.
|
inherited |
Called when the transport state changes.
Definition at line 308 of file transport.hpp.
|
protectedinherited |
Definition at line 96 of file datagram-transport.hpp.
|
protectedinherited |
Definition at line 95 of file datagram-transport.hpp.
|
inherited |
Total bytes received.
This counter includes headers imposed by NFD (such as NDNLP), but excludes the overhead of the underlying protocol (such as IP header).
For a datagram-based transport, an incoming packet that cannot be parsed as TLV will not be counted.
Definition at line 85 of file transport.hpp.
|
inherited |
Count of incoming packets.
A 'packet' typically means a top-level TLV element.
For a datagram-based transport, an incoming packet that cannot be parsed as TLV will not be counted.
Definition at line 65 of file transport.hpp.
|
inherited |
Total bytes sent.
This counter includes headers imposed by NFD (such as NDNLP), but excludes the overhead of the underlying protocol (such as IP header).
This counter is increased only when the transport is UP.
Definition at line 95 of file transport.hpp.
|
inherited |
Count of outgoing packets.
A 'packet' typically means a top-level TLV element.
This counter is incremented only when the transport is UP.
Definition at line 74 of file transport.hpp.