esp8266ndn
NDN Arduino library for ESP8266 and more
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Static Public Attributes | List of all members
esp8266ndn::UdpTransport Class Reference

A transport that communicates over UDP tunnel or multicast group. More...

#include <udp-transport.hpp>

Inherits ndnph::transport::Transport.

Public Types

enum  { DefaultMtu = 1500 - 20 - 8 }
 
- Public Types inherited from ndnph::transport::Transport
using RxCallback = void(*)(void *ctx, const uint8_t *pkt, size_t pktLen, uint64_t endpointId)
 

Public Member Functions

 UdpTransport (size_t mtu=DefaultMtu)
 Construct using internal buffer. More...
 
 UdpTransport (uint8_t *buffer, size_t capacity)
 Construct using external buffer. More...
 
template<size_t capacity>
 UdpTransport (std::array< uint8_t, capacity > &buffer)
 Construct using external buffer. More...
 
bool beginListen (uint16_t localPort=6363, IPAddress localIp=IPAddress())
 Listen on a UDP port for packets from any remote endpoint. More...
 
bool beginTunnel (IPAddress remoteIp, uint16_t remotePort=6363, uint16_t localPort=6363)
 Establish a UDP tunnel to a remote endpoint. More...
 
bool beginMulticast (IPAddress localIp=IPAddress(), uint16_t groupPort=56363)
 Join a UDP multicast group. More...
 
void end ()
 Disable the transport. More...
 
- Public Member Functions inherited from ndnph::transport::Transport
virtual ~Transport ()=default
 
bool isUp () const
 Determine whether transport is connected. More...
 
void loop ()
 Process periodical events, such as receiving packets. More...
 
void setRxCallback (RxCallback cb, void *ctx)
 Set incoming packet callback. More...
 
bool send (const uint8_t *pkt, size_t pktLen, uint64_t endpointId=0)
 Synchronously transmit a packet. More...
 

Static Public Attributes

static const IPAddress MulticastGroup
 NDN multicast group "224.0.23.170". More...
 

Additional Inherited Members

- Protected Member Functions inherited from ndnph::transport::Transport
void invokeRxCallback (const uint8_t *pkt, size_t pktLen, uint64_t endpointId=0)
 Invoke incoming packet callback for a received packet. More...
 

Detailed Description

A transport that communicates over UDP tunnel or multicast group.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
DefaultMtu 

Default MTU for UDP is Ethernet MTU minus IPv4 and UDP headers.

Constructor & Destructor Documentation

◆ UdpTransport() [1/3]

esp8266ndn::UdpTransport::UdpTransport ( size_t  mtu = DefaultMtu)
explicit

Construct using internal buffer.

Parameters
mtumaximum packet length. Default is default Ethernet MTU minus IP and UDP headers.

◆ UdpTransport() [2/3]

esp8266ndn::UdpTransport::UdpTransport ( uint8_t *  buffer,
size_t  capacity 
)
explicit

Construct using external buffer.

Parameters
bufferbuffer pointer. This must remain valid until transport is destructed.
capacitybuffer capacity.

◆ UdpTransport() [3/3]

template<size_t capacity>
esp8266ndn::UdpTransport::UdpTransport ( std::array< uint8_t, capacity > &  buffer)
inlineexplicit

Construct using external buffer.

Parameters
bufferbuffer array. This must remain valid until transport is destructed.

Member Function Documentation

◆ beginListen()

bool esp8266ndn::UdpTransport::beginListen ( uint16_t  localPort = 6363,
IPAddress  localIp = IPAddress() 
)

Listen on a UDP port for packets from any remote endpoint.

Parameters
localPortlocal port.
localIplocal interface address (ESP32 only).

Up to four simultaneous IPv6 EndpointIds can be tracked.

◆ beginMulticast()

bool esp8266ndn::UdpTransport::beginMulticast ( IPAddress  localIp = IPAddress(),
uint16_t  groupPort = 56363 
)

Join a UDP multicast group.

Parameters
localIplocal interface address (ESP8266 only).
groupPortgroup port.

◆ beginTunnel()

bool esp8266ndn::UdpTransport::beginTunnel ( IPAddress  remoteIp,
uint16_t  remotePort = 6363,
uint16_t  localPort = 6363 
)

Establish a UDP tunnel to a remote endpoint.

Parameters
remoteIpremote host address.
remotePortremote port.
localPortlocal port.

◆ end()

void esp8266ndn::UdpTransport::end ( )

Disable the transport.

Member Data Documentation

◆ MulticastGroup

const IPAddress esp8266ndn::UdpTransport::MulticastGroup
static

NDN multicast group "224.0.23.170".


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