|
NS-3 based Named Data Networking (NDN) simulator
ndnSIM 2.5: NDN, CCN, CCNx, content centric networks
|
API Documentation
|
Go to the documentation of this file.
37 if (addr.is_loopback()) {
42 else if (addr.is_v6()) {
43 auto addr6 = addr.to_v6();
44 if (addr6.is_v4_mapped()) {
45 return addr6.to_v4().is_loopback();
54 time::milliseconds pingInterval)
57 , m_pingInterval(pingInterval)
59 const auto& sock = m_server.get_con_from_hdl(hdl)->get_socket();
63 if (
isLoopback(sock.local_endpoint().address()) &&
64 isLoopback(sock.remote_endpoint().address())) {
85 websocketpp::lib::error_code error;
86 m_server.send(m_handle, packet.
wire(), packet.
size(),
87 websocketpp::frame::opcode::binary, error);
89 return processErrorCode(error);
101 std::tie(isOk, element) =
Block::fromBuffer(
reinterpret_cast<const uint8_t*
>(msg.data()), msg.size());
111 WebSocketTransport::schedulePing()
113 m_pingEventId =
getScheduler().schedule(m_pingInterval, [
this] { sendPing(); });
117 WebSocketTransport::sendPing()
121 websocketpp::lib::error_code error;
122 m_server.ping(m_handle,
"NFD-WebSocket", error);
124 return processErrorCode(error);
128 this->schedulePing();
148 WebSocketTransport::processErrorCode(
const websocketpp::lib::error_code& error)
171 websocketpp::lib::error_code error;
172 m_server.close(m_handle, websocketpp::close::status::normal,
"closed by NFD", error);
#define NFD_LOG_FACE_ERROR(msg)
Log a message at ERROR level.
void cancel()
Cancel the operation.
@ CLOSED
the transport is closed, and can be safely deallocated
@ FACE_SCOPE_NON_LOCAL
face is non-local
const ssize_t MTU_UNLIMITED
indicates the transport has no limit on payload size
void setRemoteUri(const FaceUri &uri)
void receiveMessage(const std::string &msg)
Translates a message into a Block and delivers it to the link service.
@ LINK_TYPE_POINT_TO_POINT
link is point-to-point
represents the underlying protocol and address used by a Face
void doClose() final
performs Transport specific operations to close the transport
void setScope(ndn::nfd::FaceScope scope)
void setState(TransportState newState)
set transport state
WebSocketTransport(websocketpp::connection_hdl hdl, websocket::Server &server, time::milliseconds pingInterval)
#define NFD_LOG_FACE_DEBUG(msg)
Log a message at DEBUG level.
@ CLOSING
the transport is being closed gracefully, either by the peer or by a call to close()
A Transport that communicates on a WebSocket connection.
Copyright (c) 2011-2015 Regents of the University of California.
static NDN_CXX_NODISCARD std::tuple< bool, Block > fromBuffer(ConstBufferPtr buffer, size_t offset)
Try to parse Block from a wire buffer.
PacketCounter nOutPings
count of outgoing Pings
websocketpp::server< websocketpp::config::asio > Server
#define NFD_LOG_FACE_TRACE(msg)
Log a message at TRACE level.
Scheduler & getScheduler()
Returns the global Scheduler instance for the calling thread.
void setLinkType(ndn::nfd::LinkType linkType)
@ FACE_PERSISTENCY_ON_DEMAND
face is on-demand
@ FACE_SCOPE_LOCAL
face is local
Represents a TLV element of NDN packet format.
void setPersistency(ndn::nfd::FacePersistency newPersistency)
changes face persistency setting
size_t size() const
Return the size of the encoded wire, i.e.
@ FAILED
the transport is being closed due to a failure
TransportState getState() const
uint64_t EndpointId
Identifies a remote endpoint on the link.
void receive(const Block &packet, const EndpointId &endpoint=0)
Pass a received link-layer packet to the upper layer for further processing.
const uint8_t * wire() const
Return a raw pointer to the beginning of the encoded wire.
PacketCounter nInPongs
count of incoming Pongs
#define NFD_LOG_FACE_WARN(msg)
Log a message at WARN level.
#define NFD_LOG_INIT(name)
static bool isLoopback(const boost::asio::ip::address &addr)
void setLocalUri(const FaceUri &uri)