1

I am trying to create a small academic project in the area of home automation. I explored various protocols and standards in IOT domain and find COAP close to my requirements.

The intent is pretty simple: To have a peripheral at home (like bulb, temperature sensor etc) which act as COAP server and expose certain resources and services. Since COAP uses an addressing scheme similar to web, any client having the address of this server shall be able to talk to this COAP server (i.e. peripheral) and control its attributes.

I have certain doubts about how a client not present in the same LAN as the server, can discover this server and the resources exposed by it. I understand that COAP facilitates resource discovery using CoRE link format but it seems that it primarily uses multicast which can only work within a LAN. I don't want to put a resource directory server at home and various COAP servers registering with it and then this directory server talking to a server sitting in the cloud. I want to have the ability to just install a peripheral at the home which can communicate to a remote client (like COPPER) using wifi home network. But how to discover the COAP server sitting at home from a remote location and then talk to it considering that COAP server will be on a private IP address. Is this really possible using just COAP?

scorpio
  • 329
  • 1
  • 18
  • I am not sure what the question is, are you looking to scan multiple homes and look for sensor, hence you don't know who has sensor and who does not, or your client as preconceived knowledge of the server's location (public IP) – Simon Jun 07 '16 at 15:36
  • I don't want to scan multiple homes. I want to automate a single home and devices must be accessible remotely. I want to use COAP for connecting devices and cloud server. It seems that COAP is primarily meant for access over LAN and not WAN. Is this correct? – scorpio Jul 10 '16 at 00:53
  • No, CoAP is and application layer protocol, and sits on top of UDP/DTLS, TCP/TLS. So wan should not be an issue, it follows REST paradigm, It uses URI to define resources and is fully bidirectional. Its also important to know that a device can be in way a "client and a server" at the same time in coap term. Hence a device can contact the outside host first. I can go over that in a answer if that it is what you are asking? – Simon Jul 11 '16 at 04:20
  • @simon: Are you talking about opening a connection to server from device first so that a mapping gets created in NAT server? But how long does this mapping last if device doesn't use the channel? – scorpio Jul 27 '16 at 10:34
  • Yes that is what I meant, for the mapping lifespan, That will depend on your middle box configuration. – Simon Aug 17 '16 at 16:34

2 Answers2

1

As you're sitting behind a NAT, that will allow neither direct discovery nor connections; CoAP will not try to magically pierce that.

Popular ways out are:

  • Use IPv6 (obliviating the use of a NAT) and (at least selectively) disable the firewall. You will still only be able to do discovery locally, but once discovered, you can connect to your devices from anywhere.
  • Use a VPN to make your mobile device act as if it were in the NAT.
  • Run a CoAP proxy at the router with a port open to the outside, and tell your mobile device to connect through that proxy. This does not give you local discovery either.

For the proxy and IPv6 cases, you can then still run a resource directory in your local network. That does neither need to connect to nor accept registrations from any cloud service, but it can help you do the very discovery that you'd like to do with multicast but can't because your mobile device is too far away. Both the resource directory and the proxy should be configurable to not talk to devices outside the local network unless they are authenticated.

chrysn
  • 810
  • 6
  • 19
  • thanks chrysn! I stopped working on this project long back but your suggestions make perfect sense. – scorpio Jul 26 '18 at 01:20
0

Make your router accept HTTP requests , and run a HTTP to CoAP proxy in your system, access your CoAP devices via your IP thought HTTP-CoAP proxy.

  • The query is about how to discover a COAP server rather than how to communicate with it using HTTP. – scorpio Apr 09 '18 at 02:46
  • What you are trying to accomplish is perfectly doable, just add couple of proxies : [private N/w] : [public network] CoAP server ->(proxy)CoAP to HTTP -> : ->(proxy)Http to CoAP -> RD -discover coap servers through resource directry, (via HTTP-coAP proxy) in public network. -add http - coap proxy in your local network and access coap servers. – Shrinath Kumar Apr 13 '18 at 09:40