33 Multicast,
"MulticastUdpTransport");
36 const protocol::endpoint& multicastGroup,
37 protocol::socket&& recvSocket,
38 protocol::socket&& sendSocket)
40 , m_multicastGroup(multicastGroup)
41 , m_sendSocket(
std::move(sendSocket))
45 this->
setScope(ndn::nfd::FACE_SCOPE_NON_LOCAL);
47 this->
setLinkType(ndn::nfd::LINK_TYPE_MULTI_ACCESS);
56 if (newPersistency != ndn::nfd::FACE_PERSISTENCY_PERMANENT) {
57 BOOST_THROW_EXCEPTION(
58 std::invalid_argument(
"MulticastUdpTransport supports only FACE_PERSISTENCY_PERMANENT"));
67 m_sendSocket.async_send_to(boost::asio::buffer(packet.packet), m_multicastGroup,
69 boost::asio::placeholders::error,
70 boost::asio::placeholders::bytes_transferred,
75 MulticastUdpTransport::doClose()
77 if (m_sendSocket.is_open()) {
82 boost::system::error_code error;
83 m_sendSocket.cancel(error);
84 m_sendSocket.close(error);
95 BOOST_ASSERT(ep.address().is_v4());
97 return (static_cast<uint64_t>(ep.port()) << 32) |
98 static_cast<uint64_t
>(ep.address().to_v4().to_ulong());
void setLocalUri(const FaceUri &uri)
virtual void doClose() override
performs Transport specific operations to close the transport
#define NFD_LOG_FACE_TRACE(msg)
Log a message at TRACE level.
void setScope(ndn::nfd::FaceScope scope)
void setPersistency(ndn::nfd::FacePersistency persistency)
changes face persistency setting
virtual void beforeChangePersistency(ndn::nfd::FacePersistency newPersistency) final
invoked before persistency is changed
stores a packet along with the remote endpoint
MulticastUdpTransport(const protocol::endpoint &localEndpoint, const protocol::endpoint &multicastGroup, protocol::socket &&recvSocket, protocol::socket &&sendSocket)
Creates a UDP-based transport for multicast communication.
void handleSend(const boost::system::error_code &error, size_t nBytesSent, const Block &payload)
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
static EndpointId makeEndpointId(const typename protocol::endpoint &ep)
boost::asio::ip::udp protocol
#define NFD_LOG_FACE_INFO(msg)
Log a message at INFO level.
uint64_t EndpointId
identifies an endpoint on the link
#define NFD_LOG_INCLASS_2TEMPLATE_SPECIALIZATION_DEFINE(cls, s1, s2, name)
void setLinkType(ndn::nfd::LinkType linkType)
ssize_t computeMtu(const boost::asio::ip::udp::endpoint &localEndpoint)
computes maximum payload size in a UDP packet
Implements Transport for datagram-based protocols.
void setRemoteUri(const FaceUri &uri)