Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am sending small amounts of data (up to 100 bytes) every 10 minutes from devices to TCP server. In my case overhead seems to be huge (we pay for each byte). I found that I have at least 7-10 packets (three-way handshake (3), request with ack(2), response with ack (2, optional) and tear down(3)). Total overhead is at least 400 bytes (40 bytes TCP/IP header for each packet).

Questions are:

  • What is efficient way for sending such small amounts of data reliably? (UDP with ack?)
  • Why my headers are bigger than 40 bytes (60 or 52)? For example this one:

    0x0000:  4500 0034 73d7 4000 3506 d2ee 5c17 1b9b  E..4s.@.5...\...
    0x0010:  2599 61b3 be7e 23a3 31a9 710a 6a2f 6371  %.a..~#.1.q.j/cq
    0x0020:  8010 0073 2672 0000 0101 080a 02dc 02ef  ...s&r..........
    0x0030:  1dc2 dad6                                ....
    
  • How can I print key-value list of headers instead of hex values? (that's minor)

share|improve this question

2 Answers 2

up vote 6 down vote accepted

What is efficient way for sending such small amounts of data reliably? (UDP with ack?)

Yes, this is essentially what UDP was invented for. That or use long lived TCP connections.

Why my headers are bigger than 40 bytes (60 or 52)?

Most OSes include much more than the bare minimum.

How can I print key-value list of headers instead of hex values?

Capture the packet in Wireshark and dump it's analysis.
Might take a bit more than just that to get "key value" format, depending on what you're looking for.

How long TCP connection can live?

Technically, forever. Realistically, it depends... TCP itself has no limit, connections could stay alive for years conceivably. Realistically, most applications have a timeout at which they disconnect inactive clients. Also firewalls usually drop stateful rules for idle connections after a long time.

Is TCP sending additional packets if you keep connection open?

If you have keep-alives enabled, yes. Otherwise, probably not. Depends on the implementation.

Is it efficient to keep all their connections open?

It takes memory to keep each connection open (a few KB typically). One or two thousand connections will only take a few MB. Millions starts cutting into the realm of "a lot" of memory. Modern OSes can easily keep track many thousands of connections; but your application has to be reasonable designed to accommodate that many.

share|improve this answer

What is efficient way for sending such small amounts of data reliably?

Definitely UDP, i would use UDP with some bytes of the packet reserved for checksum or other error detection mechanism for my data, just for precaution.

share|improve this answer
1  
UDP already has checksum. Did you mean acknowledge? –  ruruskyi Jun 3 '13 at 22:51
    
I refer a check sum for my data, just in case something goes wrong, and of course plus the UDP checksum. In this way, if both checksums are correctly check an ACK is sent. –  frico Jun 4 '13 at 8:21
1  
To be honest, I still did not get why do we need two checksums.. –  ruruskyi Jun 4 '13 at 9:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.