Electron tcp vs udp protocol with 3rd party SIM

Our product needs SMS, so it has to be 3rd party SIM. FW 0.6.1.

The application is up to 12 hours online operation ready for a button press, followed by publishing a temperature value, RSSI to a network connected screen in the room. This button press may happen a couple of time a day, up to every 15 seconds for long periods.

Unfortunately available 3rd party SIM+APN does not come with long UDP timeouts. UDP timeouts are around 30-60 seconds. TCP timeouts are about 1800 seconds - so up to 60 times longer. Keep-alive data adds up with UDP at 122 bytes per update.

Being new to the platform, I wonder if the following is all that is needed to change between TCP and UDP protocol, and what experience have others had with frequent UDP keep-alive vs TCP overhead and stability on Electron?

https://docs.particle.io/reference/cli/#particle-keys-protocol

Thanks,

AFAIK the Particle.keepAlive() is only needed to keep the Particle cloud connection alive but it’s not required for cell connection alone.
And what does your question have to do with SMS as this does not require the Particle cloud nor UDP/TCP?

1 Like

Yes, and the intention is to use the particle cloud web hooks, so the connection needs to stay open.

Related? SMS is a requirement for the product for setup/support purposes, and the particle SIM subscription does not include SMS, so we must use 3rd party SIM. With that comes a challenge with short UDP timeouts, compared to particle SIM's excellent ~23 minutes.

Yes, SMS works fine without a data connection - one of the major benefits when deploying a product with a GSM module, as you have a second connection for getting a status or send a setup change.

I get the impression that some of the choices comes off as weird?

Is the one CLI command above really all that is needed to change cloud protocol?

There is some code that can directly trigger SMS via a 3rd party SIM without any other service that would require UDP.

BTW, as of 0.6.2 Twillio SIM support is baked into the system firmware, so you might be able to get SMS and 23min keep alive at some point - maybe @KyleG could chime in with some info from staff about this.

AFAIK no, you'd need to locally compile the system firmware with a TCP switch set, to have your Electron go TCP - but that's also something for @KyleG to relay to the responsible party.

2 Likes

You can use Twilio or Ubidots to send SMS or Email messages without needing a 3rd part SIM.

Yes, when there is a data connection working, online SMS services are great.

Sounds interesting! GSM-SMS is great for putting in a 3rd party SIM and just SMS the APN to the device. Our partners are used to that on another product. Or getting a status from a device that lost data connection.

BTW, I found a public example of network time-outs for TCP and UDP that might be interesting for others:

But the tcp vs udp point seems moot after reading these two threads, indicating that TCP is not a viable option, and may be removed anytime soon:

https://community.particle.io/t/electron-tcp-firmware/21078
https://community.particle.io/t/electron-tcp-callfunction/20935

So, it is best to stay away from TCP, and just real life test, what the data cost will be with a 3rd party SIM, for when coverage demands it.

I’m going to try to recap here:

  • The Electron can connect to the Particle Cloud using either UDP or TCP protocols.
  • The default is UDP since that uses a lot less data due to ACK overhead.
  • Network carriers have different timeout values for UDP and TCP because web traffic is carried over TCP and again TCP uses a lot more data.
  • You can change the Electron from UDP to TCP but you have compile all the code for the device locally on your computer. @ScruffR said this above but I want to emphasize it. And Particle may remove the TCP path in the future since it was only meant as a backup strategy.
  • The Particle Cloud public keys for UDP and TCP are also different so you need to update the keys locally.

So TCP might seem like a bargain in terms of timeout length but it can be much more costly in terms of data usage.

I am not sure what is happening in those two thread you mentioned. A few of us had to use beta Electrons in TCP mode for the first few weeks since UDP wasn’t ready yet and I can say it worked fine then but plowed through data. I was happy with the change to UDP.

3 Likes

Thank you @bko.

My only addition:

  • When using a 3rd party SIM, the default UDP timeout is often 30-120 seconds compared to the Particle SIM’s favourable UDP timeout of 23 minutes, so you can end up using a lot more data.

As I understand it, worst case, staying online with the cloud 24/7 with a 30s keep-alive of 122 bytes every 30 seconds is about 10 MB pr month, compared to about 224kB with the Particle SIM.

1 Like