0
votes

Our company developed stations that collect data in an agricultural field. These field could be in the middle of nowhere, so stations use GSM/GPRS with SIM card that automatically switches to strongest provider.

Every 5 minutes, an internet connection is setup to send data to a server. The data has a structure with packet length, command, sensor data and crc check. But these data structures are sent with a http post to an url.

For 480 bytes of data, about 2550 bytes of data traffic is used. There is a lot of overhead in the HTTP protocol. Because we only need to send 480 bytes of data, we have 80% overhead with the post over http. Now we have a few hundreds of stations and that number is growing. So costs for data traffic are increasing rapidly.

We want to do a redesign of the transmission of data. The data is send by microchip microprocessor in the stations.

Our goal is to decrease the overhead as much as possible, with guaranteed data delivery. So I looked into TCP and UDP.

TCP has failure detection and recovery, but has a higher overhead. UDP has lower overhead, but there it is not guaranteed that data is delivered without failure.

My first idea is to build a server that listens to a TCP port. And stations sent the data over TCP. Mainly because of guarantied data delivery.

With UDP we have to develop check and resend of data ourself, but the data structure of our records is already prepared to do checks.

So I am really in doubt what to do. And I am trying to get an answer on these questions:

  • How many bytes overhead would it take by TCP and UDP to sent (and deliver) 480 bytes of data?

  • Are TCP and UDP the best ways to consider for sending 480 bytes of data, or is there a smarter solution with even lower overhead?

1
Experiment and test. If you can measure how much data is sent by your current method, you should be able to measure how it fares when using TCP or UDP. And remember to test with bad reception and bad wired connections, to check how it fares when there's lots of retransmissions and retries needed. - Some programmer dude
Yes, we can measure this. The simcard provider gives us details of bytes send and received per connection. So we have to program the solution first. We are now opting for TCP. - Luc

1 Answers

1
votes

How many bytes overhead would it take by TCP and UDP to sent (and deliver) 480 bytes of data?

A (typical) TCP header is 20 bytes long although it can be (slightly) longer with options. If the entire 480 bytes are sent in a single TCP segment, you'd end up with 480 +20 + 20 (IP header) = 520 bytes before layer-2 overhead.

UDP has an 8 byte header, so for UDP you'll have 480 + 8 + 20 = 508 bytes.

However you should to consider that TCP is a stream protocol. Reading from a TCP socket is like reading from a binary file - you'd need to split that stream into individual messages yourself by using some sort of delimiter or prepending the length of the message to each message.

UDP on the other hand works on individual messages. Reading from a UDP socket would return messages one at a time.

Are TCP and UDP the best ways to consider for sending 480 bytes of data, or is there a smarter solution with even lower overhead?

UDP and TCP are the lowest level transport protocols on the internet. HTTP and other high-level protocols are built on top of them. If the size of data is critical, raw TCP and UDP are as low-overhead as you're going to get without using RAW sockets and embedding your data directly into IP packets.