28 #if defined(__linux__) 29 #include <linux/sockios.h> 30 #include <sys/ioctl.h> 38 time::milliseconds TcpTransport::s_initialReconnectWait = 1_s;
39 time::milliseconds TcpTransport::s_maxReconnectWait = 5_min;
40 float TcpTransport::s_reconnectWaitMultiplier = 2.0f;
44 , m_remoteEndpoint(m_socket.remote_endpoint())
45 , m_nextReconnectWait(s_initialReconnectWait)
65 #if defined(__linux__) 67 if (ioctl(
m_socket.native_handle(), SIOCOUTQNSD, &nsd) < 0) {
68 NFD_LOG_FACE_WARN(
"Failed to obtain send queue length from socket: " << std::strerror(errno));
106 boost::system::error_code error;
118 TcpTransport::reconnect()
137 m_reconnectEvent =
scheduler::schedule(m_nextReconnectWait, [
this] { this->handleReconnectTimeout(); });
138 m_socket.async_connect(m_remoteEndpoint, [
this] (
const auto& e) { this->handleReconnect(e); });
142 TcpTransport::handleReconnect(
const boost::system::error_code& error)
147 error == boost::asio::error::operation_aborted) {
157 m_reconnectEvent.
cancel();
158 m_nextReconnectWait = s_initialReconnectWait;
167 TcpTransport::handleReconnectTimeout()
170 boost::system::error_code error;
174 m_nextReconnectWait =
175 std::min(time::duration_cast<time::milliseconds>(m_nextReconnectWait * s_reconnectWaitMultiplier),
185 m_reconnectEvent.
cancel();
void afterChangePersistency(ndn::nfd::FacePersistency oldPersistency) final
invoked after the persistency has been changed
void setPersistency(ndn::nfd::FacePersistency newPersistency)
changes face persistency setting
void doClose() override
performs Transport specific operations to close the transport
void doClose() final
performs Transport specific operations to close the transport
NFD_LOG_MEMBER_INIT_SPECIALIZED((DatagramTransport< boost::asio::ip::udp, Multicast >), MulticastUdpTransport)
#define NFD_LOG_FACE_TRACE(msg)
Log a message at TRACE level.
const ssize_t MTU_UNLIMITED
indicates the transport has no limit on payload size
void setRemoteUri(const FaceUri &uri)
virtual void handleError(const boost::system::error_code &error)
detail::SimulatorIo & getGlobalIoService()
void setLinkType(ndn::nfd::LinkType linkType)
size_t getSendQueueBytes() const
ssize_t getSendQueueLength() final
Implements Transport for stream-based protocols.
protocol::socket m_socket
the transport is being closed due to a failure
void setScope(ndn::nfd::FaceScope scope)
#define NFD_LOG_FACE_INFO(msg)
Log a message at INFO level.
TransportState getState() const
Copyright (c) 2011-2015 Regents of the University of California.
the transport is closed, and can be safely deallocated
void post(const std::function< void()> &callback)
void cancel()
Cancel the operation.
TcpTransport(protocol::socket &&socket, ndn::nfd::FacePersistency persistency, ndn::nfd::FaceScope faceScope)
void setLocalUri(const FaceUri &uri)
void handleError(const boost::system::error_code &error) final
the transport is being closed gracefully, either by the peer or by a call to close()
represents the underlying protocol and address used by a Face
void resetReceiveBuffer()
ndn::nfd::FacePersistency getPersistency() const
bool canChangePersistencyToImpl(ndn::nfd::FacePersistency newPersistency) const final
invoked by canChangePersistencyTo to perform the check
EventId schedule(time::nanoseconds after, const EventCallback &event)
Schedule an event.
void setState(TransportState newState)
set transport state
the transport is up and can transmit packets
#define NFD_LOG_FACE_WARN(msg)
Log a message at WARN level.
the transport is temporarily down, and is being recovered