What is the size of the CoAP packet?

I'm new to this technology, can someone help me find out about some doubts?

Q-1. What is the size of the CoAP packet?
(I know there is a 4-byte fixed header, but what is the maximum size, including the header, parameter, and payload?)

Q-2. Is there a keep alive concept like MQTT?
(It works on UDP, how long does it keep the connection open, is there any default time or does it stay open every time we send a packet?)

Q-3. Can we use CoAP with TCP?
(The main problem with this CoAP is that it works on UDP, is there any concept, for example, QQS MQTT? Let's say the sensor publishes some data every second if the subscriber goes offline, is there a guarantee in CoAP that the subscriber will receive everything data, when did he come online?)

Q-4. What is the duration of the connection?
(CoAP supports a publishing / subscribing architecture, maybe you need a connection to be open all the time, is it possible with CoAP whether it is UDP based.)

Q-5. How does he discover resources?
(I have one gateway and 5 sensors, how will these sensors connect to the gateway? Will the gateway find these sensors? Or will the sensors find the gateway?)

Q-5. How does a sensor register with a gateway?

Please help me, I really need an answer. I am all new to such things and offer me something to implement.

Thanks.

+5
source share
1 answer
  • Depends on:
    • The main CoAP messages should be small enough to fit into their packets at the channel level (~ 64 KiB for UDP), but in any case, the RFC states that:
      • MUST match one IP packet to avoid IP fragmentation (MTU 1280 for IPv6). If nothing is known about the size of the headers, then the good upper bounds are 1152 bytes for the message size and 1024 bytes for the payload size;
      • or less to avoid fragmentation of the adaptation layer (60-80 bytes for 6LoWPAN networks);
    • if you need to transfer large payloads, this IETF project extends the main CoAP with new parameters for transferring several blocks of information from the resource view to a multiple request-response pair (so you can transfer more than 64 kilobytes per message).
  • I never used MQTT, in any case CoAP does not require a connection, requests and responses are exchanged asynchronously via UDP or DTLS. I believe that you are looking for monitoring functionality: it allows CoAP clients to โ€œsubscribeโ€ to resources and servers to send updates to subscribers over a period of time.

  • There is an IETF project that describes CoAP over TCP, but I donโ€™t know how it interacts with the monitoring function: this usually follows the principle of the best approach , it just happens that the client is no longer interested in the resource and is removed from the list of observers by the server.

  • Monitoring stops when the server thinks that the client is no longer interested in the resource or when the client asks to unsubscribe from the resource.

  • The known relative URI is "/.well-known/core". It is defined as the default entry point for querying a list of links about resources hosted by the server. Here for more information.

  • Look at 5.

+2
source

All Articles