TCP vs UDP for Video SurveillanceBy Ethan Ace, Published Mar 11, 2015, 12:00am EDT (Research)
TCP or UDP?
What should you use for video surveillance?
TCP and UDP are both in use in the video industry today, each with strengths and weaknesses when it comes to live viewing, playback, error correction, artifacting, and more, though many users do not know the difference between the two or how choose one or the other.
Here is a quick summary:
- TCP tends to drop frames when bandwidth is insufficient for video stream needs.
- UDP tends to smear image when bandwidth is insufficient for video stream needs.
- Minimal latency differences between TCP and UDP.
- Potential UDP benefits for live video streaming over congested networks.
- Live viewing tends to be smoother with UDP.
- Recorded video tends to have fewer errors with TCP.
- Most IP cameras support both TCP and UDP but generally it is not user controllable (only VMS or via API).
- VMSes vary significantly in what configuration or control they support for TCP or UDP (details on Avigilon, Exacq, Genetec and Milestone inside).
Impact On Video Quality
In the examples below, we show the difference in video quality using TCP vs. UDP over a simulated 768 Kb/s connection. Note: for a brief primer on key differences between these two protocols, see our overview below.
When using TCP, nearly all frames arrive, but delayed. Stuttering is present, with the subject jumping from one point in the scene to another.
However, in the same scene using UDP, we can see substantial breakup and artifacts as well as gaps in video where frames were dropped and no video was received.
We review these two clips in detail in this video. Users may also download these exports (11 MB .zip file).
This scene is an extreme example, with lower bandwidth and packet loss simulated for demonstration purposes. However, even small amounts of packet loss and constrained bandwidth can have significant impact on video quality.
Impact On Latency
We tested latency using both TCP and UDP in multiple cameras and found little difference between the two on a dedicated network. Latency averaged 250-300ms per camera, regardless of protocol. UDP's connectionless design, lack of error correction, and theoretical lower overhead had little effect in a simple network.
However, in congested (such as shared networks with large amounts of traffic) or complex (such as those using multi-hop wireless links, e.g. city surveillance), UDP may provide lower latency streaming.
Use In Surveillance
In IP video, TCP and UDP may perform very similarly in dedicated surveillance networks, as error correction and its associated overhead are less likely to come into play.
However, in bandwidth-restricted applications such as remote viewing or cameras connected via the internet, TCP and UDP have unique advantages and disadvantages:
Live Viewing: UDP Preferred for Smoother Viewing
In live viewing applications, it is most important that operators receive timely notification of events, making UDP's lower overhead more useful. Network glitches may cause dropped frames, but events generally span more than a handful of frames, allowing the operator to determine what has occured regardless of missing video.
However, if fine movements are to be observed and greater time between the event and detection can be tolerated (such as casinos), the delays possible in TCP (seen in examples above) may be preferred to UDP, to more likely ensure all frames are seen.
Recording: TCP Preferred to Reduce Errors
When recording a camera via a low bandwidth connection, such as cable or DSL, TCP is preferred. This helps to ensure that all frames of video are received and recorded in order.
If UDP is used for recording, edge recording may reduce the risk of lost video due to lost packets. If the VMS detects lost video, it may request it from the camera's edge storage and fill in the gaps, a process typically performed via TCP, unlike video streaming.
Generally, IP cameras support both TCP and UDP protocols, but rarely contain a manual mechinism for switching between the two. Instead, the VMS determines which protocol should be used, in some cases automatically, and in others via manual selection.
Here we outline TCP/UDP support in common VMSes:
Avigilon Control Center
Avigilon offers no manual control of protocol selection. UDP is used by default for live video, both from camera to recorder and recorder to client viewer.
Exacq offers no direct control of protocol selection in most cases. Use of UDP or TCP is determined in the camera's drivers, based on manufacturer recommendations. However, in ONVIF and RTSP cameras protocol may be manually selected by appending "#transport=X" to the IP address when adding the camera, where X is TCP or UDP, seen in this example:
Genetec Security Center
Genetec allows manual configuration of protocol. By default, cameras are set to "auto", which attempts to use multicast UDP, then unicast UDP, then TCP, to connect, in order of priority. If multicast is unavailable, unicast UDP is used. If UDP is completely unavailable, TCP is used. This is found in each camera's video stream setup:
By default, Milestone XProtect connects to cameras using TCP. UDP is available in some cameras (via the dropdown menu shown below), but not all cameras support it. Some simply do not allow it to be selected. Connections from server to client are via TCP only.
Transmission Control Protocol (TCP) and User Datagram Protocol (UDP) are the two most widely used network protocols. Both break down data into frames and packets for transmission via Ethernet, but with two key differences that make each more or less suitable for specific purposes:
Connection-Oriented vs. Connectionless
TCP requires a connection be set up between the two communicating devices, performed via a handshake process, before data may be sent. Once transmission begins, each set of packets is confirmed as received before the next set is sent, attempting to ensure all packets arrive, and in the proper order.
By contrast, UDP does not require a connection be created prior to transmitting. Packets are simply sent to the recipient without confirming their reception. Because of this, packet loss and errors are more common in UDP.
When using TCP, acknowledgments are sent by the receiving device after every transmission, ensuring all data was received, and in the proper order. Packets which were not properly received are retransmitted, until all data is properly sent.
Because UDP is connectionless, no error checking or correction is performed. The sender does not wait or check to see if the recipient has received all packets in one set, it simply continues sending the next set. Packets may arrive out of order or not at all, causing errors, but no notification is given to the sending device to resend lost packets.
Test your knowledge.
Click here to take a 6 question quiz
2 reports cite this report:
Back to Top