To send an image every 50 ms, should I use TCP or UDP?

I am creating a C # application using the server-client model where the server sends an image (100kb) to the client via the socket every 50 ms ...

I used TCP, but besides the overhead of this protocol, sometimes the client received more than one image in the socket. And I don't yet have a smart mechanism for splitting the bytes of each image (in fact, I just need the very last one).

I tried using UDP, but came to the conclusion that I can not send 100kb dgrams, only 64kb. And even so, I should not use more than 1500 bytes; otherwise, the packet will be divided over the network, and the probability of losing part of the packet will be greater.

So now I'm a little confused. Should I continue to use TCP and put some escape bytes at the end of each image so that the client can separate them? Or should I use UDP, send dgrams of 1,500 bytes and come up with a mechanism for ordering and recovery?

The main goal here is to transfer images very quickly. I do not mind losing some along the way while the customer continues to receive new ones.

Or should I use a different protocol? Thanks in advance!

+3
source share
5 answers

I would recommend using UDP if:

  • Your application can handle an image or a small package of images that do not pass,
  • You can compress your images to 65535 bytes.

, , UDP.

TCP . RTP. sepcifically , VoIP .

: .Net RTP, .Net . , ConferenceXP .

+1

(aka RTP).

IP-, RTP, UDP, , ..

RTP - , VoIP IP. , #.

, JPEG, RTP/MJPEG. , , - IP .

+15

, , , UDP. , , .

, RTP, , UDT. UDP. TCP.

+2

re: UDP "" , RTP.

, TCP, , . ? . 4 , . .

+1

, , UDP .

But if you are dealing with lager frames and not with 64K, you should do some form of reflow. Do not worry about fragmented frames, as you will have to deal with this, or there will be a lower level. And you only need photos.

What you need is some form of time / sequence encapsulation.

0
source

Source: https://habr.com/ru/post/1706500/


All Articles