I need to send a sequence of video frames over UDP as quickly as possible and in real time, and while I am working on the basics, I am encountering all the difficulties. Some of my goals:
Data is usually sent via dial-up (hence UDP instead of TCP), but fast Ethernet must also be supported.
It is normal to sometimes drop frames (hence UDP instead of TCP).
Low latency required. The frame that the remote accepts must be the one that was recently sent (no more than a few frames waiting in the buffers).
I need to be able to determine effective throughput so that I can more or less compress frames in order to maintain frame rate.
I managed to implement most of the parts:
I break the frame data into one or more datagrams of about 500 bytes in size and each has a serial number and other information. The receiver reassembles the entire frame and detects the absence of any datagrams.
If the receiver detects more than a certain percentage of dropped frames (for example, 50% compared to the last 10 frames), I send a TCP message to the sender to slow it down by 50%. The sender, than slowly, increases the speed by 5% for each subsequent frame.
Using System.Net.Sockets.UdpClient to send and receive data.
I have a separate TCP channel used for control messages back to the sender.
, (max ~ 4000 /). , 100 000 TcpClient.Send(), , , ( ), , . , TcpClient.Send() , , .
- , :
, , , , - .